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 |
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() **********************************************/ |
141 |
byte Patch6502(register byte Op,register M6502 *R) { |
byte Patch6502(register byte Op,register M6502 *R) { |
142 |
debugf(("Patch6502(%02x)\n", Op)); |
debugf(("Patch6502(%02x)\n", Op)); |
143 |
dump_R; |
dump_R; |
144 |
|
hw_int = INT_QUIT; |
145 |
return 0; |
return 0; |
146 |
} |
} |
147 |
|
|
176 |
dSP; |
dSP; |
177 |
PUSHMARK(SP); |
PUSHMARK(SP); |
178 |
call_pv("Arch::init", G_DISCARD | G_NOARGS ); |
call_pv("Arch::init", G_DISCARD | G_NOARGS ); |
179 |
|
FREETMPS; |
180 |
|
LEAVE; |
181 |
|
|
182 |
pull_R(R); |
int cycles = 1; |
183 |
int cycles = SvIV( get_sv("M6502::run_for", FALSE) ); |
while ( cycles ) { |
184 |
printf("run CPU for %d cycles\n", cycles); |
dSP; |
185 |
dump_R; |
PUSHMARK(SP); |
186 |
//Run6502(R); |
call_pv("Arch::cli", G_DISCARD | G_NOARGS ); |
187 |
Exec6502(R, cycles); |
pull_R(R); |
188 |
dump_R; |
FREETMPS; |
189 |
push_R(R); |
LEAVE; |
190 |
printf("end of CPU run\n"); |
cycles = SvIV( get_sv("M6502::run_for", FALSE) ); |
191 |
|
if ( cycles > 0 ) { |
192 |
|
printf("run CPU for %d cycles\n", cycles); |
193 |
|
dump_R; |
194 |
|
//Run6502(R); |
195 |
|
Exec6502(R, cycles); |
196 |
|
dump_R; |
197 |
|
push_R(R); |
198 |
|
printf("end of %d cycles CPU run\n", cycles); |
199 |
|
} else { |
200 |
|
printf("no cpu cycles set for run\n"); |
201 |
|
cycles = 1; // never exit, prevents segfault |
202 |
|
} |
203 |
|
} |
204 |
} |
} |
205 |
free(R); |
free(R); |
206 |
perl_destruct(my_perl); |
perl_destruct(my_perl); |