diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-05-02 23:15:47 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-05-02 23:15:47 +0200 |
| commit | 5808f00555c48e1cc1cc110af6a5cd73ddf13010 (patch) | |
| tree | dff942b61441bafe297e7a99f0e799f32ae978b1 /memory.c | |
| parent | 9463faa436e1b981ef72000568445a83682f2658 (diff) | |
cleanup and rewrite of ppu_registers.c
Diffstat (limited to 'memory.c')
| -rw-r--r-- | memory.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -3,7 +3,7 @@ __attribute__((hot)) static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { - state->cycles++; + state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -15,8 +15,8 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { } else if(offset == 0x4016 || offset == 0x4017) { uint32_t index = offset & 1; - uint8_t value = (state->input_latch[index] >> state->input_bit[index]) & 1; - state->input_bit[index]++; + uint8_t value = (state->ppu.input_latch[index] >> state->ppu.input_bit[index]) & 1; + state->ppu.input_bit[index]++; return value | 0x40; // Bit 6 open bus high, bit 7 low // } else if(offset == 4015) { @@ -32,7 +32,7 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { __attribute__((hot)) static void memory_write(struct nes_state *restrict state, uint32_t offset, uint8_t value) { - state->cycles++; + state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -51,15 +51,15 @@ static void memory_write(struct nes_state *restrict state, uint32_t offset, uint // state->apu.dmc_dma_enabled = (value & 0x10) ? 1 : 0; } else if(offset == 0x4016) { - uint8_t prev = state->input_strobe; - state->input_strobe = value & 1; + uint8_t prev = state->ppu.input_strobe; + state->ppu.input_strobe = value & 1; if(prev == 1 && (value & 1) == 0) { // Latch current inputs - state->input_latch[0] = state->input[0]; - state->input_latch[1] = state->input[1]; - state->input_bit[0] = 0; - state->input_bit[1] = 0; + state->ppu.input_latch[0] = state->ppu.input[0]; + state->ppu.input_latch[1] = state->ppu.input[1]; + state->ppu.input_bit[0] = 0; + state->ppu.input_bit[1] = 0; } // } else if(offset == 0x4017) { // Frame Counter (APU) @@ -90,7 +90,7 @@ static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset __attribute__((hot)) static uint8_t memory_read_dummy(struct nes_state *restrict state, uint32_t offset) { - state->cycles++; + state->cpu.cycles++; ppu_tick(state); // apu_tick(state); |
