summaryrefslogtreecommitdiff
path: root/ppu.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-05-08 21:03:43 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-05-08 21:03:43 +0200
commite28ad1546509de31b706f0fd300a906e5bc55199 (patch)
tree40d708336cf770b8c68302bd32b069951a3df428 /ppu.c
parentda9d961bbc3662064599f4b0b4759a2c641924a2 (diff)
new and changed mappers
Diffstat (limited to 'ppu.c')
-rw-r--r--ppu.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/ppu.c b/ppu.c
index fe54be5..6f5a4eb 100644
--- a/ppu.c
+++ b/ppu.c
@@ -155,19 +155,18 @@ static inline void ppu_render_pixel(struct nes_state *state) {
}
// Final pixel composition
- uint8_t palette_index = 0;
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);
+ // uint8_t palette_index;
+ uint8_t palette_index = (sp_prio) ? bg_index : 0x10 | sp_index;
+
switch(selector) {
- 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) ? 0x40 : 0; // NOTE(peter): Sprite zero hit!
- palette_index = (sp_prio) ? bg_index : 0x10 | sp_index;
- } 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) ? 0x40 : 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).