--- M6502/perl.c 2007/07/31 08:41:06 40 +++ M6502/perl.c 2007/07/31 09:37:01 42 @@ -5,6 +5,7 @@ #if DEBUGF #define debugf(x) do { \ + PerlIO_stdoutf("#> "); \ PerlIO_stdoutf x ; \ } while (0) #else @@ -121,10 +122,13 @@ /** INT_NONE, INT_IRQ, INT_NMI, or INT_QUIT to exit the **/ /** emulation loop. **/ /************************************ TO BE WRITTEN BY USER **/ + +int hw_int = INT_NONE; + byte Loop6502(register M6502 *R) { debugf(("Loop6502\n")); dump_R; - return INT_NONE; + return hw_int; } /** Patch6502() **********************************************/ @@ -172,15 +176,19 @@ PUSHMARK(SP); call_pv("Arch::init", G_DISCARD | G_NOARGS ); - pull_R(R); - int cycles = SvIV( get_sv("M6502::run_for", FALSE) ); - printf("run CPU for %d cycles\n", cycles); - dump_R; - //Run6502(R); - Exec6502(R, cycles); - dump_R; - push_R(R); - printf("end of CPU run\n"); + int cycles = 1; + while ( cycles ) { + call_pv("Arch::cli", G_DISCARD | G_NOARGS ); + pull_R(R); + cycles = SvIV( get_sv("M6502::run_for", FALSE) ); + printf("run CPU for %d cycles\n", cycles); + dump_R; + //Run6502(R); + Exec6502(R, cycles); + dump_R; + push_R(R); + printf("end of %d cycles CPU run\n", cycles); + } } free(R); perl_destruct(my_perl);