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) ); |
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; |
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; |
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")); |