summaryrefslogtreecommitdiff
path: root/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpu.c')
-rw-r--r--cpu.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/cpu.c b/cpu.c
index 3e731e5..b773e57 100644
--- a/cpu.c
+++ b/cpu.c
@@ -26,11 +26,7 @@ static inline void update_zn(struct cpu_state *cpu, uint8_t result) {
cpu->n = (result & 0x80) != 0;
}
-
-
-static void (*opcode_lut[256])(struct nes_state *state);
-
-uint32_t line = 1;
+static void (*opcode_lut[256*2])(struct nes_state *) __attribute__((aligned(4096)));
struct addr_result {
uint32_t addr;
@@ -84,6 +80,7 @@ static inline void check_interrupts(struct nes_state * restrict state) {
state->nmi_pending = 0;
do_nmi(state);
} else if(state->irq_pending && cpu->i == 0) {
+ state->irq_pending = 0;
do_irq(state);
}
}
@@ -93,9 +90,15 @@ static void cpu_tick(struct nes_state *state) {
check_interrupts(state);
- // printf("%5.5d %4.4x: ", line++, cpu->pc);
- uint8_t opcode = memory_read(state, cpu->pc++);
- // printf("%2.2x a:%2.2x x:%2.2x y:%2.2x p:%2.2x sp:%2.2x cycle: %d\n", opcode, cpu->a, cpu->x, cpu->y, pack_flags(cpu), cpu->sp, cycle);
+ uint8_t opcode;
+
+ // if(cpu->pc <= 0x90cc || cpu->pc >= 0x90e6) {
+ // printf("%5.5d %4.4x: ", line++, cpu->pc);
+ // opcode = memory_read(state, cpu->pc++);
+ // printf("%2.2x a:%2.2x x:%2.2x y:%2.2x p:%2.2x sp:%2.2x cycle: %ld\n", opcode, cpu->a, cpu->x, cpu->y, pack_flags(cpu), cpu->sp, state->cycle);
+ // } else {
+ opcode = memory_read(state, cpu->pc++);
+ // }
opcode_lut[opcode](state);
}