summaryrefslogtreecommitdiff
path: root/mknes_ppu.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_ppu.c
parenta12149c9aff979949c86cc5a66929f985db4caa4 (diff)
reached 2944fps again
Diffstat (limited to 'mknes_ppu.c')
-rw-r--r--mknes_ppu.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/mknes_ppu.c b/mknes_ppu.c
index 7c2b4ac..6e8e3ae 100644
--- a/mknes_ppu.c
+++ b/mknes_ppu.c
@@ -164,21 +164,22 @@ no_sprite:
uint8_t bg_index = (bg_palette << 2) + bg_pixel;
uint8_t sp_index = (sp_palette << 2) + sp_pixel;
uint8_t selector = (bg_pixel ? 2 : 0) | (sp_pixel ? 1 : 0);
-
- // NOTE(peter): It's actually faster to preset case 3 version of palette_index than to start from zero
- uint8_t palette_index = (sp_prio) ? bg_index : 0x10 | sp_index;
+ uint8_t palette_index = 0;
switch(selector) {
- case 0: { palette_index = 0; } break;
+ // case 0: { palette_index = 0; } break;
case 1: { palette_index = 0x10 | sp_index; } break;
case 2: { palette_index = bg_index; } break;
- case 3: { ppu->reg_status |= (sp_zero && x < 255) ? PPU_STATUS_SPRITE_ZERO_HIT : 0; } break; // NOTE(peter): Sprite zero hit!
+ case 3: {
+ palette_index = (sp_prio) ? bg_index : 0x10 | sp_index;
+ ppu->reg_status |= (sp_zero && x < 255) ? PPU_STATUS_SPRITE_ZERO_HIT : 0;
+ } break; // NOTE(peter): Sprite zero hit!
}
state->pixels[y * 256 + x] = ppu->palette[palette_index]; // NOTE(peter): Add color_emphasis bits (expand palette to 8x).
}
-__attribute__((hot, optimize("no-jump-tables", "unroll-loops")))
+__attribute__((noinline, hot, optimize("no-jump-tables", "unroll-loops")))
static void ppu_tick(struct nes_state *state) {
struct ppu_state *restrict ppu = &state->ppu;
@@ -387,9 +388,7 @@ stupid2: if(reg_mask & PPU_MASK_SHOW_SPRITES) {
if(dot >= 280 && dot <= 304) {
ppu->vram_addr = (ppu->vram_addr & ~0x7be0) | (ppu->temp_addr & 0x7be0);
}
-
}
-
}
if(dot == 1) {