--- M6502/perl.c 2007/07/30 15:45:03 27 +++ M6502/perl.c 2007/07/30 18:07:29 31 @@ -29,17 +29,14 @@ /** required if there is a #define FAST_RDOP. **/ /************************************ TO BE WRITTEN BY USER **/ -byte Rd6502(register word Addr) { - byte Value; - Value = 0x42; - printf("Rd6502(%04x,%02x)\n", Addr, Value); - +byte mem(word Addr) { + byte byte; int count; dSP; ENTER; SAVETMPS; PUSHMARK(SP); - XPUSHs( sv_2mortal( newSViv( Value ) ) ); + XPUSHs( sv_2mortal( newSViv( Addr ) ) ); PUTBACK; count = call_pv("M6502::read", G_ARRAY ); if ( count != 1 ) { @@ -50,11 +47,16 @@ SPAGAIN; SV *sv; sv = POPs; - Value = SvIV(sv); -// Value = savepv(SvPV_nolen(POPs)); + byte = SvIV(sv); FREETMPS; LEAVE; - printf("Rd6502(%04x) = %02x\n", Addr, Value); + printf("Rd6502(%04x) = %02x\n", Addr, byte); + return byte; +} + +byte Rd6502(register word Addr) { + byte Value; + Value = mem(Addr); return Value; } @@ -74,7 +76,7 @@ byte Op6502(register word Addr) { byte Op; - Op = 0xff; + Op = mem(Addr); printf("Op6502(%04x,%02x)\n", Addr, Op); dump_R; } @@ -89,6 +91,7 @@ byte Loop6502(register M6502 *R) { printf("Loop6502\n"); dump_R; + return INT_NONE; } /** Patch6502() **********************************************/ @@ -101,6 +104,7 @@ byte Patch6502(register byte Op,register M6502 *R) { printf("Patch6502(%02x)\n", Op); dump_R; + return 0; } /** @@ -109,12 +113,11 @@ **/ int main(int argc, char **argv) { - char *command_line[] = {"", "-e", - "use M6502; print \"Loaded M6502 module\n\";"}; + char *command_line[] = {"", "-e", EMU_START }; my_perl = perl_alloc(); perl_construct(my_perl); - if (perl_parse(my_perl, NULL, 3, command_line, (char **)NULL)) { - printf("Failed to parse\n"); + if (perl_parse(my_perl, xs_init, 3, command_line, (char **)NULL)) { + printf("Failed to parse initial: %s\n", EMU_START ); return 0; } perl_run(my_perl);