/[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 93 by dpavlin, Thu Aug 2 12:53:00 2007 UTC revision 100 by dpavlin, Thu Aug 2 16:58:07 2007 UTC
# Line 10  Line 10 
10  M6502 *R = NULL;  M6502 *R = NULL;
11  int debug = 0;  int debug = 0;
12    
13    byte opCache[MEM_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"));

Legend:
Removed from v.93  
changed lines
  Added in v.100

  ViewVC Help
Powered by ViewVC 1.1.26