summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh4
-rw-r--r--mknes.c2
-rw-r--r--ppu.c11
3 files changed, 9 insertions, 8 deletions
diff --git a/build.sh b/build.sh
index b8f6a4e..fbe27e9 100755
--- a/build.sh
+++ b/build.sh
@@ -8,7 +8,7 @@ CFLAGS="-std=gnu11 "
CFLAGS+="-mbmi2 "
CFLAGS+="-mfunction-return=keep "
CFLAGS+="-mindirect-branch=keep "
-CFLAGS+="-fwrapv -ffast-math -fno-trapping-math -fwhole-program "
+CFLAGS+="-fwrapv -ffast-math -fno-trapping-math -fwhole-program -fvisibility=hidden "
CFLAGS+="-fno-stack-protector -fno-PIE -no-pie -fno-strict-aliasing -ffunction-sections -fdata-sections "
# CFLAGS+="-fno-exceptions -fno-rtti -fno-use-cxa-atexit "
CFLAGS+="-fno-non-call-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables "
@@ -16,7 +16,7 @@ CFLAGS+="-Wall -Wextra "
CFLAGS+="-Wno-unused-parameter -Wno-sign-compare -Wno-trigraphs -Wno-maybe-uninitialized "
CFLAGS+="-Wno-unused-variable -Wno-unused-const-variable -Wno-unused-function -Wno-write-strings -Wno-missing-field-initializers "
-LDFLAGS="-Wl,--gc-sections "
+LDFLAGS="-Wl,--gc-sections -Wl,--as-needed "
# Base include paths (common for all platforms)
INCLUDE_PATHS="-Ibase -I.."
diff --git a/mknes.c b/mknes.c
index 09da608..007046f 100644
--- a/mknes.c
+++ b/mknes.c
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
}
#else
while(!glfwWindowShouldClose(window)) {
- // timer_wait(timer);
+ timer_wait(timer);
glfwPollEvents();
while(!nstate->ppu.frame_ready) {
diff --git a/ppu.c b/ppu.c
index bab97d5..be22921 100644
--- a/ppu.c
+++ b/ppu.c
@@ -35,7 +35,6 @@ static inline void ppu_evaluate_sprites(struct nes_state *state) {
dst[2] = src[2];
dst[3] = src[3];
ppu->sprite_indexes[n] = i;
- ppu->sprite_zero_hit_possible |= (i == 0);
dst += 4;
n++;
@@ -115,6 +114,11 @@ static inline void ppu_render_pixel(struct nes_state *state) {
uint8_t bg_mask = (ppu->reg_mask & 0x08) ? 0xff : 0x00;
uint8_t sp_mask = (ppu->reg_mask & 0x10) ? 0xff : 0x00;
+ // uint8_t left_mask = (x >= 8) ? 0xff : 0x00;
+ // bg_mask &= ((ppu->reg_mask & 0x02) ? 0xff : 0x00) | left_mask;
+ // sp_mask &= ((ppu->reg_mask & 0x04) ? 0xff : 0x00) | left_mask;
+
+
// Background
uint8_t p0 = !!(ppu->bg_shift_pattern_low & bit);
uint8_t p1 = !!(ppu->bg_shift_pattern_high & bit);
@@ -151,9 +155,7 @@ static inline void ppu_render_pixel(struct nes_state *state) {
case 1: { palette_index = 0x10 | sp_index; } break;
case 2: { palette_index = bg_index; } break;
case 3: {
- if(sp_zero && ppu->sprite_zero_hit_possible && x < 255) {
- ppu->reg_status |= 0x40;
- }
+ ppu->reg_status |= (sp_zero && x < 255) ? 0x40 : 0; // NOTE(peter): Sprite zero hit!
palette_index = (sp_prio) ? bg_index : 0x10 | sp_index;
} break;
}
@@ -395,7 +397,6 @@ static void ppu_tick(struct nes_state *state) {
if(UNLIKELY(scanline == 261) && dot == 1) {
ppu->reg_status &= ~0x80;
ppu->reg_status &= ~0x40;
- ppu->sprite_zero_hit_possible = 0;
}
dot++;