diff --git a/Makefile b/Makefile index 42bb8d0..6ea40ff 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ PFLAGS += -g #PFLAGS += -DDEBUG_APU #PFLAGS += -DDEBUG_INPUT #PFLAGS += -DE6502_DEBUG -PFLAGS += -DE6502_ILLEGAL +#PFLAGS += -DE6502_ILLEGAL CFLAGS += $(PFLAGS) -Wall -Werror -Wshadow -Wunused -I../ -Isrc/ CFLAGS += -Iinc/$(PLATFORM)/SDL2 LDFLAGS += $(PFLAGS) diff --git a/src/ppu.c b/src/ppu.c index 53a0a8d..0f1a0b2 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -277,8 +277,8 @@ nes_ppu_Result nes_ppu_run(nes_ppu* ppu, int cycles) { if ( ppu->scanline > nes_ppu_prerender && ppu->scanline < nes_ppu_render) { ppu->scroll_y++; - if (ppu->scroll_y >= nes_ppu_render_h) { - ppu->scroll_y -= nes_ppu_render_h; + if (ppu->scroll_y == nes_ppu_render_h) { + ppu->scroll_y = 0; ppu->control ^= 0b10; } } diff --git a/src/sdl_render.c b/src/sdl_render.c index 7b719aa..b6acd9a 100644 --- a/src/sdl_render.c +++ b/src/sdl_render.c @@ -362,6 +362,7 @@ static void render_bg_scanline(const nes_ppu* ppu,/* int scanline,*/ int page = (ppu->control & ppu_Control_Nametable_Mask); int x = ppu->scroll_x; int y = ppu->scroll_y; + if (y >= nes_ppu_render_h) y -= nes_ppu_render_h; int w = (nes_ppu_render_w - x); if (!(ppu->mask & ppu_Mask_Left_Back)) { // Handle column 0 flag - need to fill with transparency