diff options
Diffstat (limited to 'memory.c')
| -rw-r--r-- | memory.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -3,10 +3,9 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { state->cycle++; - for(uint32_t i = 0; i < 3; ++i) { - ppu_tick(state); - } + ppu_tick(state); ppu_tick(state); ppu_tick(state); + // state->ram[0x301] = 0x1; if(offset < 0x2000) { return state->ram[offset & 0x07ff]; } else if(offset < 0x4000) { @@ -28,16 +27,18 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { static void memory_write(struct nes_state *restrict state, uint32_t offset, uint8_t value) { state->cycle++; - for(uint32_t i = 0; i < 3; ++i) { - ppu_tick(state); - } + ppu_tick(state); ppu_tick(state); ppu_tick(state); + +// if(offset == 0x0300) { +// printf("WRITE $0300 = %02x @ PC=%04x\n", value, state->cpu.pc); +// } if(offset < 0x2000) { state->ram[offset & 0x07ff] = value; } else if(offset < 0x4000) { switch(offset & 7) { - case 0: state->ppu.ctrl = value; break; - case 1: state->ppu.mask = value; break; + case 0: ppu_write_2000(state, value); break; + case 1: ppu_write_2001(state, value); break; case 3: ppu_write_2003(state, value); break; case 4: ppu_write_2004(state, value); break; case 5: ppu_write_2005(state, value); break; @@ -73,9 +74,7 @@ static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset static uint8_t memory_read_dummy(struct nes_state *restrict state, uint32_t offset) { state->cycle++; - for(uint32_t i = 0; i < 3; ++i) { - ppu_tick(state); - } + ppu_tick(state); ppu_tick(state); ppu_tick(state); if(offset < 0x2000) { return 0; |
