/[VRac]/M6502/M6502.xs
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /M6502/M6502.xs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 91 by dpavlin, Thu Aug 2 12:37:06 2007 UTC revision 108 by dpavlin, Fri Aug 3 09:18:08 2007 UTC
# Line 10  Line 10 
10  M6502 *R = NULL;  M6502 *R = NULL;
11  int debug = 0;  int debug = 0;
12    
13    byte opCache[CACHE_SIZE];
14    
15  void update_C_R(void) {  void update_C_R(void) {
16          R->A = SvIV( get_sv("M6502::A", FALSE) );          R->A = SvIV( get_sv("M6502::A", FALSE) );
17          R->P = SvIV( get_sv("M6502::P", FALSE) );          R->P = SvIV( get_sv("M6502::P", FALSE) );
# Line 96  byte mem(word Addr) { Line 98  byte mem(word Addr) {
98          FREETMPS;          FREETMPS;
99          LEAVE;          LEAVE;
100          debugf(("mem(%04x) = %02x", Addr, byte));          debugf(("mem(%04x) = %02x", Addr, byte));
101            opCache[Addr] = byte;
102          return byte;          return byte;
103  }  }
104    
105  byte Rd6502(register word Addr) {  byte Rd6502(register word Addr) {
106          byte Value;          byte Value;
107          Value = mem(Addr);          Value = mem(Addr);
 //      Value = 0x42;  
108          debugf(("Rd6502(%04x) = %02x", Addr, Value));          debugf(("Rd6502(%04x) = %02x", Addr, Value));
109          return Value;          return Value;
110  }  }
111    
112  void Wr6502(register word Addr,register byte Value) {  void Wr6502(register word Addr,register byte Value) {
113          debugf(("Wr6502(%04x,%02x)", Addr, Value));          debugf(("Wr6502(%04x,%02x)", Addr, Value));
114            opCache[Addr] = Value;
115          dSP;          dSP;
116          ENTER;          ENTER;
117          SAVETMPS;          SAVETMPS;
# Line 123  void Wr6502(register word Addr,register Line 126  void Wr6502(register word Addr,register
126    
127  byte Op6502(register word Addr) {  byte Op6502(register word Addr) {
128          byte Op;          byte Op;
129            if ( opCache[Addr] ) return opCache[Addr];
130          Op = mem(Addr);          Op = mem(Addr);
131          debugf(("Op6502(%04x,%02x) PC:%04x", Addr, Op, R->PC.W));          debugf(("Op6502(%04x,%02x) PC:%04x", Addr, Op, R->PC.W));
132          return Op;          return Op;
# Line 170  reset (void) { Line 174  reset (void) {
174                          PerlIO_stdoutf("can't alloc %d bytes for M6502", sizeof(M6502));                          PerlIO_stdoutf("can't alloc %d bytes for M6502", sizeof(M6502));
175                          exit(1);                          exit(1);
176                  }                  }
177                    memset( opCache, 0, sizeof(opCache) );
178          }          }
179          Reset6502(R);          Reset6502(R);
180          debugf(("Reset6502 over"));          debugf(("Reset6502 over"));
# Line 179  reset (void) { Line 184  reset (void) {
184  }  }
185    
186  int exec(int cycles) {  int exec(int cycles) {
187            int left;
188          debugf(("exec for %d cycles", cycles));          debugf(("exec for %d cycles", cycles));
189    
190          if (!R) reset();          if (!R) reset();
191    
192          update_C_R();          update_C_R();
193          Exec6502(R, cycles);          left = Exec6502(R, cycles);
194          update_perl_R();          update_perl_R();
195          debugf(("end of %d cycles CPU run\n", cycles));          debugf(("end of %d cycles CPU run\n", cycles));
196            return left;
197  }  }
198    
199  int set_debug(int state) {  int set_debug(int state) {

Legend:
Removed from v.91  
changed lines
  Added in v.108

  ViewVC Help
Powered by ViewVC 1.1.26