--- M6502/M6502.xs 2007/08/02 16:21:17 99 +++ M6502/M6502.xs 2007/08/02 16:58:07 100 @@ -10,6 +10,8 @@ M6502 *R = NULL; int debug = 0; +byte opCache[MEM_SIZE]; + void update_C_R(void) { R->A = SvIV( get_sv("M6502::A", FALSE) ); R->P = SvIV( get_sv("M6502::P", FALSE) ); @@ -96,19 +98,20 @@ FREETMPS; LEAVE; debugf(("mem(%04x) = %02x", Addr, byte)); + opCache[Addr] = byte; return byte; } byte Rd6502(register word Addr) { byte Value; Value = mem(Addr); -// Value = 0x42; debugf(("Rd6502(%04x) = %02x", Addr, Value)); return Value; } void Wr6502(register word Addr,register byte Value) { debugf(("Wr6502(%04x,%02x)", Addr, Value)); + opCache[Addr] = Value; dSP; ENTER; SAVETMPS; @@ -123,6 +126,7 @@ byte Op6502(register word Addr) { byte Op; + if ( opCache[Addr] ) return opCache[Addr]; Op = mem(Addr); debugf(("Op6502(%04x,%02x) PC:%04x", Addr, Op, R->PC.W)); return Op; @@ -170,6 +174,7 @@ PerlIO_stdoutf("can't alloc %d bytes for M6502", sizeof(M6502)); exit(1); } + memset( opCache, 0, sizeof(opCache) ); } Reset6502(R); debugf(("Reset6502 over"));