From a3087dd6d0938056f7f0e3d89e60f36e56ac27d2 Mon Sep 17 00:00:00 2001 From: Peter Fors Date: Tue, 28 Oct 2025 22:18:16 +0100 Subject: reached 2944fps again --- mknes_memory.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'mknes_memory.c') diff --git a/mknes_memory.c b/mknes_memory.c index 49546b2..57f527e 100644 --- a/mknes_memory.c +++ b/mknes_memory.c @@ -1,11 +1,12 @@ __attribute__((hot)) static inline uint8_t memory_read(struct nes_state *state, uint32_t offset) { + if(offset >= 0x10000) __builtin_unreachable(); + state->cpu.cycles++; apu_tick(state); ppu_tick(state); - if(offset >= 0x10000) __builtin_unreachable(); if(offset <= 0x1fff) { return state->ram[offset & 0x07ff]; @@ -51,13 +52,14 @@ static inline uint8_t memory_read_dummy(struct nes_state *state, uint32_t offset return result; } -__attribute__((hot, optimize("no-jump-tables"))) +__attribute__((hot)) static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_t value) { + if(offset >= 0x10000) __builtin_unreachable(); + state->cpu.cycles++; apu_tick(state); ppu_tick(state); - if(offset >= 0x10000) __builtin_unreachable(); if(offset <= 0x1fff) { state->ram[offset & 0x07ff] = value; @@ -109,9 +111,3 @@ static inline void memory_write(struct nes_state *state, uint32_t offset, uint8_ return; } } - -__attribute__((hot, flatten)) -static inline uint8_t memory_read_dma(struct nes_state *state, uint32_t offset) { - // NOTE(peter): DO NOT tick CPU/PPU/APU — caller handles timing - return state->ram[offset & 0x07ff]; -} -- cgit v1.2.3