diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-03-31 20:31:05 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-03-31 20:31:05 +0200 |
| commit | a386ef64f6376b3ef8434a6cdf456495287fcbca (patch) | |
| tree | e2da9f72ce0a565b4fac2fc8be19ab3497286b36 /cpu.c | |
| parent | d5486a5af100fb37fac08b60d862ac14943853ce (diff) | |
currently 90% working
Diffstat (limited to 'cpu.c')
| -rw-r--r-- | cpu.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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); } |
