5 |
|
|
6 |
#if DEBUGF |
#if DEBUGF |
7 |
#define debugf(x) do { \ |
#define debugf(x) do { \ |
8 |
|
PerlIO_stdoutf("#> "); \ |
9 |
PerlIO_stdoutf x ; \ |
PerlIO_stdoutf x ; \ |
10 |
} while (0) |
} while (0) |
11 |
#else |
#else |
47 |
XPUSHs( sv_2mortal( newSViv( R->S ) ) ); |
XPUSHs( sv_2mortal( newSViv( R->S ) ) ); |
48 |
XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) ); |
XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) ); |
49 |
PUTBACK; |
PUTBACK; |
50 |
call_pv("M6502::_push_R", G_DISCARD ); |
call_pv("M6502::push_R", G_DISCARD ); |
51 |
printf("push_R called\n"); |
printf("push_R called\n"); |
52 |
dump_R; |
dump_R; |
53 |
FREETMPS; |
FREETMPS; |
112 |
byte Op; |
byte Op; |
113 |
Op = mem(Addr); |
Op = mem(Addr); |
114 |
debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W)); |
debugf(("Op6502(%04x,%02x) PC:%04x\n", Addr, Op, R->PC.W)); |
115 |
|
return Op; |
116 |
} |
} |
117 |
|
|
118 |
/** Loop6502() ***********************************************/ |
/** Loop6502() ***********************************************/ |
122 |
/** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the **/ |
/** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the **/ |
123 |
/** emulation loop. **/ |
/** emulation loop. **/ |
124 |
/************************************ TO BE WRITTEN BY USER **/ |
/************************************ TO BE WRITTEN BY USER **/ |
125 |
|
|
126 |
|
int hw_int = INT_NONE; |
127 |
|
|
128 |
byte Loop6502(register M6502 *R) { |
byte Loop6502(register M6502 *R) { |
129 |
debugf(("Loop6502\n")); |
debugf(("Loop6502\n")); |
130 |
dump_R; |
dump_R; |
131 |
return INT_NONE; |
return hw_int; |
132 |
} |
} |
133 |
|
|
134 |
/** Patch6502() **********************************************/ |
/** Patch6502() **********************************************/ |
175 |
dSP; |
dSP; |
176 |
PUSHMARK(SP); |
PUSHMARK(SP); |
177 |
call_pv("Arch::init", G_DISCARD | G_NOARGS ); |
call_pv("Arch::init", G_DISCARD | G_NOARGS ); |
178 |
|
FREETMPS; |
179 |
|
LEAVE; |
180 |
|
|
181 |
pull_R(R); |
int cycles = 1; |
182 |
printf("run CPU\n"); |
while ( cycles ) { |
183 |
dump_R; |
dSP; |
184 |
//Run6502(R); |
PUSHMARK(SP); |
185 |
Exec6502(R, 10); |
call_pv("Arch::cli", G_DISCARD | G_NOARGS ); |
186 |
dump_R; |
pull_R(R); |
187 |
push_R(R); |
FREETMPS; |
188 |
printf("end of CPU run\n"); |
LEAVE; |
189 |
|
cycles = SvIV( get_sv("M6502::run_for", FALSE) ); |
190 |
|
printf("run CPU for %d cycles\n", cycles); |
191 |
|
dump_R; |
192 |
|
//Run6502(R); |
193 |
|
Exec6502(R, cycles); |
194 |
|
dump_R; |
195 |
|
push_R(R); |
196 |
|
printf("end of %d cycles CPU run\n", cycles); |
197 |
|
} |
198 |
} |
} |
199 |
free(R); |
free(R); |
200 |
perl_destruct(my_perl); |
perl_destruct(my_perl); |