summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-05-29 23:11:41 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-05-29 23:11:41 +0200
commitf02853edb8a624fbe85ea322eaba9e643756d44e (patch)
tree5ef71cb2cc6a455bfd200a5ff895afc9cb2d624d
parent93fd16dcd4c66ed003363d6e7f0c70bd3d2de92c (diff)
optimization of ppu
-rw-r--r--mknes.c2
-rw-r--r--mknes.h2
-rw-r--r--ppu.c5
3 files changed, 5 insertions, 4 deletions
diff --git a/mknes.c b/mknes.c
index 77bdd45..a2f764c 100644
--- a/mknes.c
+++ b/mknes.c
@@ -146,7 +146,7 @@ int main(int argc, char **argv) {
// ines2_load(nstate, "data/0000/Xevious - The Avenger (USA).zip");
// ines2_load(nstate, "data/tv.nes");
- // ines2_load(nstate, "data/Life Force (USA).zip"); // 2002
+ ines2_load(nstate, "data/Life Force (USA).zip"); // 2002
// ines2_load(nstate, "data/0003/Flipull - An Exciting Cube Game (Japan) (En).zip");
// ines2_load(nstate, "data/0003/Friday the 13th (USA).zip");
diff --git a/mknes.h b/mknes.h
index 27d4f6e..8d12e95 100644
--- a/mknes.h
+++ b/mknes.h
@@ -45,10 +45,10 @@ struct ppu_state {
uint8_t vram_read_buffer;
uint8_t open_bus;
- uint8_t sprite_zero_hit_possible;
uint8_t sprite_count;
uint8_t palette[32];
+// NOTE(peter): one byte left on cacheline
// NOTE(peter): CACHELINE 2 start here!
uint8_t sprite_indexes[8];
diff --git a/ppu.c b/ppu.c
index 570f3dd..e0fce44 100644
--- a/ppu.c
+++ b/ppu.c
@@ -103,7 +103,7 @@ static inline void ppu_fetch_sprite_patterns(struct nes_state *state) {
}
}
-__attribute__((hot, flatten))
+__attribute__((always_inline, hot, flatten))
static inline void ppu_render_pixel(struct nes_state *state) {
struct ppu_state *restrict ppu = &state->ppu;
@@ -171,6 +171,7 @@ static inline void ppu_render_pixel(struct nes_state *state) {
}
__attribute__((hot, flatten))
+__attribute__((optimize("no-jump-tables")))
static inline void ppu_tick(struct nes_state *state) {
struct ppu_state *restrict ppu = &state->ppu;
@@ -178,7 +179,7 @@ static inline void ppu_tick(struct nes_state *state) {
uint32_t scanline = ppu->scanline;
uint8_t rendering = (ppu->reg_mask & 0x18);
- for(uint32_t ppu_loops = 0; ppu_loops < 3; ++ppu_loops) {
+ for(uint8_t ppu_loops = 0; ppu_loops < 3; ++ppu_loops) {
if(rendering) {
switch(scanline) {