9 extern uint32 nes_registers[0x10];
10 extern uint32 pc_base;
11 extern uint8 nes_internal_ram[0x800];
12 uint32 PC_prev = 0xcccccc, OP_prev = 0xcccccc;
17 static int pending_add_cycles = 0, pending_rebase = 0;
19 static void leave(void)
21 printf("\nA: %02x, X: %02x, Y: %02x, S: %02x\n", X.A, X.X, X.Y, X.S);
22 printf("PC = %04lx, OP=%02lX\n", PC_prev, OP_prev);
23 printf("cpu_lastval = %02x\n", cpu_lastval);
27 static void compare_state(void)
32 if ((nes_registers[0] >> 24) != X.A) {
33 printf("A: %02lx vs %02x\n", nes_registers[0] >> 24, X.A);
37 if ((nes_registers[1] & 0xff) != X.X) {
38 printf("X: %02lx vs %02x\n", nes_registers[1] & 0xff, X.X);
42 if ((nes_registers[2] & 0xff) != X.Y) {
43 printf("Y: %02lx vs %02x\n", nes_registers[2] & 0xff, X.Y);
47 if (nes_registers[3] - pc_base != X.PC) {
48 printf("PC: %04lx vs %04x\n", nes_registers[3] - pc_base, X.PC);
52 if ((nes_registers[4] >> 24) != X.S) {
53 printf("S: %02lx vs %02x\n", nes_registers[4] >> 24, X.S);
57 if (((nes_registers[4]>>8)&0xff) != X.IRQlow) {
58 printf("IRQlow: %02lx vs %02x\n", ((nes_registers[4]>>8)&0xff), X.IRQlow);
63 nes_flags = nes_registers[4] & 0x5d;
64 if ( nes_registers[5]&0x80000000) nes_flags |= 0x80; // N
65 if (!(nes_registers[5]&0x000000ff)) nes_flags |= 0x02; // Z
66 // nes_flags |= 0x20; // U, not set in C core (set only when pushing)
68 if (nes_flags != (X.P&~0x20)) {
69 printf("flags: %02x vs %02x\n", nes_flags, (X.P&~0x20));
73 if ((int32)nes_registers[7] != X.count) {
74 printf("cycles: %li vs %li\n", (int32)nes_registers[7], X.count);
82 static void compare_ram(void)
85 for (i = 0; i < 0x800/4; i++)
87 if (((int *)nes_internal_ram)[i] != ((int32 *)RAM)[i]) {
90 for (u = i*4; u < i*4+4; u++)
91 if (nes_internal_ram[u] != RAM[u])
92 printf("RAM[%03x]: %02x vs %02x\n", u, nes_internal_ram[u], RAM[u]);
100 void TriggerIRQ_d(void)
108 void TriggerNMI_d(void)
116 void TriggerNMINSF_d(void)
120 void X6502_Run_d(int32 c)
122 int32 cycles = c << 4; /* *16 */
123 if (PAL) cycles -= c; /* *15 */
125 //printf("-- %06i: run(%i)\n", (int)g_cnt, (int)c);
144 g_cnt -= 1 - X.count;
145 if (pending_add_cycles) {
146 //X6502_AddCycles_c(pending_add_cycles);
147 //X6502_AddCycles_a(pending_add_cycles);
148 g_cnt -= pending_add_cycles*48;
149 pending_add_cycles = 0;
151 if (pending_rebase) {
157 //printf("-- run_end\n");
160 void X6502_Reset_d(void)
162 printf("-- reset\n");
169 void X6502_Power_d(void)
171 printf("-- power\n");
172 if (nes_internal_ram == RAM) printf("nes_internal_ram == RAM!!\n");
179 void X6502_AddCycles_d(int x)
181 printf("-- AddCycles(%i|%i)\n", x, x*48);
183 pending_add_cycles = x; // *48;
184 // printf("can't use this in debug\n");
186 //X6502_AddCycles_c(x);
187 //X6502_AddCycles_a(x);
191 void X6502_IRQBegin_d(int w)
193 printf("-- IRQBegin(%02x)\n", w);
199 void X6502_IRQEnd_d(int w)
201 printf("-- IRQEnd(%02x)\n", w);
208 void X6502_Rebase_d(void)