--- M6502/perl.c 2007/07/30 14:02:31 25 +++ M6502/perl.c 2007/07/30 14:23:22 26 @@ -7,16 +7,16 @@ static M6502 *R; -#define dump_R printf("PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x", R->PC.W, R->A, R->P, R->X, R->Y, R->S ); +#define dump_R printf("# PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", R->PC.W, R->A, R->P, R->X, R->Y, R->S ); void update_R(M6502 *R) { - R->A = atoi( SvPV_nolen( get_sv("M6502::A", TRUE) ) ); - R->P = atoi( SvPV_nolen( get_sv("M6502::P", TRUE) ) ); - R->X = atoi( SvPV_nolen( get_sv("M6502::X", TRUE) ) ); - R->Y = atoi( SvPV_nolen( get_sv("M6502::Y", TRUE) ) ); - R->S = atoi( SvPV_nolen( get_sv("M6502::S", TRUE) ) ); - R->PC.W = atoi( SvPV_nolen( get_sv("M6502::PC", TRUE) ) ); - R->IPeriod = atoi( SvPV_nolen( get_sv("M6502::IPeriod", TRUE) ) ); + R->A = atoi( SvPV_nolen( get_sv("M6502::A", FALSE) ) ); + R->P = atoi( SvPV_nolen( get_sv("M6502::P", FALSE) ) ); + R->X = atoi( SvPV_nolen( get_sv("M6502::X", FALSE) ) ); + R->Y = atoi( SvPV_nolen( get_sv("M6502::Y", FALSE) ) ); + R->S = atoi( SvPV_nolen( get_sv("M6502::S", FALSE) ) ); + R->PC.W = atoi( SvPV_nolen( get_sv("M6502::PC", FALSE) ) ); + R->IPeriod = atoi( SvPV_nolen( get_sv("M6502::IPeriod", FALSE) ) ); // ICount IRequest IAutoReset TrapBadOps Trap Trace dump_R; } @@ -94,10 +94,18 @@ printf("can't alloc %d bytes for M6502", sizeof(M6502)); exit(1); } + update_R(R); + printf("reset CPU\n"); Reset6502(R); - printf("reset CPU\n"); + + printf("call M6502::init\n"); + dSP; + PUSHMARK(SP); + call_pv("M6502::init", G_DISCARD | G_NOARGS ); + + printf("run CPU\n"); Run6502(R); }