summaryrefslogtreecommitdiff
path: root/mknes_memory.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-10-28 22:18:16 +0100
committerPeter Fors <peter.fors@mindkiller.com>2025-10-28 22:18:16 +0100
commita3087dd6d0938056f7f0e3d89e60f36e56ac27d2 (patch)
tree42e230aa90c1a9932bac340439b5b55b9d2294dc /mknes_memory.c
parenta12149c9aff979949c86cc5a66929f985db4caa4 (diff)
reached 2944fps again
Diffstat (limited to 'mknes_memory.c')
-rw-r--r--mknes_memory.c14
1 files changed, 5 insertions, 9 deletions
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];
-}