extern uint32 nes_registers[0x10];
extern uint32 pc_base;
extern uint8 nes_internal_ram[0x800];
+extern uint32 timestamp_a;
uint32 PC_prev = 0xcccccc, OP_prev = 0xcccccc;
int32 g_cnt = 0;
-static int pending_add_cycles = 0, pending_rebase = 0;
+static int pending_add_cycles = 0, pending_rebase = 0, pending_irq = 0;
uint8 dreads[4];
uint32 dwrites_c[2], dwrites_a[2];
int dread_count_c, dread_count_a, dwrite_count_c, dwrite_count_a;
+int mapirq_cyc_c, mapirq_cyc_a;
static void leave(void)
{
printf("\nA: %02x, X: %02x, Y: %02x, S: %02x\n", X.A, X.X, X.Y, X.S);
printf("PC = %04lx, OP=%02lX\n", PC_prev, OP_prev);
+ printf("rest = %08lx\n", nes_registers[4]);
exit(1);
}
fail = 1;
}
- if ((int32)nes_registers[7] != X.count) {
- printf("cycles: %li vs %li\n", (int32)nes_registers[7], X.count);
+ if (((int32)nes_registers[7] >> 16) != X.count) {
+ printf("cycles: %li vs %li\n", (int32)nes_registers[7] >> 16, X.count);
fail = 1;
}
fail = 1;
}
+ if (mapirq_cyc_a != mapirq_cyc_c) {
+ printf("mapirq_cyc: %i vs %i\n", mapirq_cyc_a, mapirq_cyc_c);
+ fail = 1;
+ }
+
+ if (timestamp_a != timestamp) {
+ printf("timestamp: %lu vs %lu\n", timestamp_a, timestamp);
+ fail = 1;
+ }
+
if (fail) leave();
}
void TriggerIRQ_d(void)
{
printf("-- irq\n");
- TriggerIRQ_c();
- TriggerIRQ_a();
- compare_state();
+ pending_irq |= 0x100;
}
void TriggerNMI_d(void)
while (g_cnt > 0)
{
- nes_registers[7]=1;
+ if (pending_irq) {
+ if (pending_irq & 0x100) {
+ TriggerIRQ_c();
+ TriggerIRQ_a();
+ }
+ if (pending_irq & 0xff) {
+ TriggerIRQ_c();
+ TriggerIRQ_a();
+ X6502_IRQBegin_c(pending_irq & 0xff);
+ X6502_IRQBegin_a(pending_irq & 0xff);
+ }
+ pending_irq = 0;
+ }
+
+ nes_registers[7]=1<<16;
X.count=1;
dread_count_c = dread_count_a = dwrite_count_c = dwrite_count_a = 0;
+ mapirq_cyc_a = mapirq_cyc_c = 0;
+ timestamp_a = timestamp;
+
X6502_Run_c();
X6502_Run_a();
compare_state();
g_cnt -= 1 - X.count;
if (pending_add_cycles) {
- //X6502_AddCycles_c(pending_add_cycles);
- //X6502_AddCycles_a(pending_add_cycles);
g_cnt -= pending_add_cycles*48;
pending_add_cycles = 0;
}
printf("-- power\n");
if (nes_internal_ram == RAM) printf("nes_internal_ram == RAM!!\n");
dread_count_c = dread_count_a = dwrite_count_c = dwrite_count_a = 0;
+ mapirq_cyc_c = mapirq_cyc_a = 0;
X6502_Power_c();
X6502_Power_a();
{
printf("-- IRQBegin(%02x)\n", w);
- X6502_IRQBegin_c(w);
- X6502_IRQBegin_a(w);
+ // X6502_IRQBegin_c(w);
+ // X6502_IRQBegin_a(w);
+ pending_irq |= w;
}
void X6502_IRQEnd_d(int w)