From 205dc47111125aa2f7458be948cd9cd434d0344c Mon Sep 17 00:00:00 2001 From: Peter Fors Date: Tue, 8 Apr 2025 02:26:58 +0200 Subject: Back at 2618fps --- ppu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ppu.c') diff --git a/ppu.c b/ppu.c index cc223b7..cef45fa 100644 --- a/ppu.c +++ b/ppu.c @@ -11,14 +11,14 @@ static uint8_t __attribute__((aligned(64))) ppu_bitreverse_lut[256] = { #undef R6 static void ppu_reset(struct nes_state *state) { - struct ppu_state *ppu = &state->ppu; + struct ppu_state *restrict ppu = &state->ppu; memset(ppu, 0, sizeof(struct ppu_state)); } __attribute__((always_inline, hot)) static inline void ppu_evaluate_sprites(struct nes_state *state) { - struct ppu_state *ppu = &state->ppu; + struct ppu_state *restrict ppu = &state->ppu; uint8_t sprite_height = (ppu->reg_ctrl & 0x20) ? 16 : 8; uint8_t n = 0; @@ -52,7 +52,7 @@ static inline void ppu_evaluate_sprites(struct nes_state *state) { __attribute__((always_inline, hot)) static inline void ppu_fetch_sprite_patterns(struct nes_state *state) { - struct ppu_state *ppu = &state->ppu; + struct ppu_state *restrict ppu = &state->ppu; uint32_t addr; uint32_t bank; @@ -87,6 +87,7 @@ static inline void ppu_fetch_sprite_patterns(struct nes_state *state) { ppu->sprite_shift_lo[i] = lsb; ppu->sprite_shift_hi[i] = msb; + ppu->sprite_positions[i] = x; ppu->sprite_priorities[i] = attr & 0x20; s += 4; @@ -95,7 +96,7 @@ static inline void ppu_fetch_sprite_patterns(struct nes_state *state) { __attribute__((always_inline, hot)) static inline void ppu_render_pixel(struct nes_state *state) { - struct ppu_state *ppu = &state->ppu; + struct ppu_state *restrict ppu = &state->ppu; uint32_t x = ppu->dot - 1; uint32_t y = ppu->scanline; @@ -160,7 +161,8 @@ static inline void ppu_render_pixel(struct nes_state *state) { __attribute__((hot, flatten)) static void ppu_tick(struct nes_state *state) { - struct ppu_state *ppu = &state->ppu; + struct ppu_state *restrict ppu = &state->ppu; + uint32_t dot = ppu->dot; uint32_t scanline = ppu->scanline; -- cgit v1.2.3