From 2174b3f369e59286ccd10348117a16e08c412508 Mon Sep 17 00:00:00 2001 From: Peter Fors Date: Fri, 14 Nov 2025 22:17:03 +0100 Subject: Rearranged the ppu_state to be even more cacheline aware, gained another 1% performance --- mknes.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'mknes.h') diff --git a/mknes.h b/mknes.h index b6739d3..944f762 100644 --- a/mknes.h +++ b/mknes.h @@ -56,7 +56,6 @@ struct ppu_state { uint8_t open_bus; // 29 uint8_t sprite_count; // 30 - Number of sprites in secondary OAM (0-8) - uint8_t palette[32]; // 31 // NOTE(peter): CACHELINE 2 uint8_t secondary_oam[32] __attribute__((aligned(64))); @@ -68,16 +67,18 @@ struct ppu_state { uint8_t position; uint8_t priority; uint8_t palette; - } __attribute__((packed)) sprites[8]; + } __attribute__((packed)) sprites[8]; // 32 -> +40 - uint8_t input[2]; // 40 - Controller 1 & 2 - uint8_t input_latch[2]; // 42 - Latched inputs after strobe - uint8_t input_bit[2]; // 44 - Current bit position being shifted out - uint8_t input_strobe; // 46 - Control bit (0 or 1) - uint8_t frame_ready; // 47 - uint8_t sprite_zero_in_range; // 48 - Boolean: is sprite 0 in range (will always be slot 0 if true) + uint8_t input_strobe; // 76 - Control bit (0 or 1) + uint8_t input[2]; // 73 - Controller 1 & 2 + uint8_t input_latch[2]; // 74 - Latched inputs after strobe + uint8_t input_bit[2]; // 75 - Current bit position being shifted out + uint8_t frame_ready; // 77 + uint8_t sprite_zero_in_range; // 78 - Boolean: is sprite 0 in range (will always be slot 0 if true) - // NOTE(peter): CACHELINE 4 + uint8_t palette[32]; // 79 + + // NOTE(peter): CACHELINE 5 uint8_t oam[256] __attribute__((aligned(64))); } __attribute__((packed)); -- cgit v1.2.3