From f117e321e1526fde7f6943e708d67395453b3874 Mon Sep 17 00:00:00 2001 From: Keith Leonardo Date: Mon, 27 Nov 2023 21:23:02 +1100 Subject: [PATCH] tmp --- src/ppu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ppu.c b/src/ppu.c index 1d83782..1d53e2d 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -21,6 +21,11 @@ void create_ppu(ppu_t *ppu, ppu_bus_t *bus, interrupt_t *interrupt) { ppu->suppress_vbl = false; ppu->suppress_nmi = false; + ppu->sprite_index = 0; + ppu->sprite_m = 0; + ppu->sprite_count = 0; + ppu->sprite_count_latch = 0; + create_event_tables_ppu(ppu); } @@ -430,6 +435,7 @@ bool sprite_in_range_ppu(ppu_t *ppu, unsigned char y) { } void evaluate_sprites_ppu(ppu_t *ppu) { + // TODO: This algorithm is iffy if (ppu->sprite_index >= 64) { return; } @@ -457,7 +463,9 @@ void evaluate_sprites_ppu(ppu_t *ppu) { ppu->sprite_indices[ppu->sprite_count] = ppu->sprite_index; ppu->sprite_m = 0; ppu->sprite_index++; - ppu->sprite_count++; + if (ppu->sprite_count < 8) { + ppu->sprite_count++; + } } } }