From a8e0c141b0184d629504b9f0ee8dbc4fefb90934 Mon Sep 17 00:00:00 2001 From: Peter Fors Date: Sat, 24 May 2025 15:45:54 +0200 Subject: 3011fps --- memory.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 6e0c6df..90ae8b6 100644 --- a/memory.c +++ b/memory.c @@ -2,7 +2,7 @@ __attribute__((hot)) -static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read(struct nes_state *state, uint32_t offset) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -23,33 +23,11 @@ static uint8_t memory_read(struct nes_state *restrict state, uint32_t offset) { return value | 0x40; // Bit 6 open bus high, bit 7 low } -#if 0 - if(LIKELY(offset < 0x2000)) { // SECOND - return state->ram[offset & 0x07ff]; - - } else if(offset < 0x4000) { // THIRD - return ppu_read(state, offset); - - } else if(offset == 0x4016 || offset == 0x4017) { - uint32_t index = offset & 1; - 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) { - // static uint32_t apuread = 0; - // // printf("%.5d apu\n", apuread++); - - } else if(LIKELY(offset >= 0x6000)) { // MOST - return state->mapper.prg_read(state, offset); - - } -#endif return 0; } __attribute__((hot)) -static void memory_write(struct nes_state *restrict state, uint32_t offset, uint8_t value) { +static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_t value) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); @@ -93,8 +71,7 @@ static void memory_write(struct nes_state *restrict state, uint32_t offset, uint } } -__attribute__((hot)) -static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read_dma(struct nes_state *state, uint32_t offset) { // Do not tick CPU/PPU/APU — caller handles timing if(LIKELY(offset < 0x2000)) { return state->ram[offset & 0x07ff]; @@ -106,8 +83,7 @@ static uint8_t memory_read_dma(struct nes_state *restrict state, uint32_t offset return 0; } -__attribute__((hot)) -static uint8_t memory_read_dummy(struct nes_state *restrict state, uint32_t offset) { +static inline uint8_t memory_read_dummy(struct nes_state *state, uint32_t offset) { state->cpu.cycles++; ppu_tick(state); // apu_tick(state); -- cgit v1.2.3