From 2a5f0839293adcc1424cac25a3090731f7dd71c3 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Thu, 22 May 2025 20:51:04 -0600 Subject: [PATCH] Fixed zelda lyc first line timing issue --- lib/ppu_pipeline.c | 4 ++-- lib/ppu_sm.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/ppu_pipeline.c b/lib/ppu_pipeline.c index 3f151a1..689e14b 100644 --- a/lib/ppu_pipeline.c +++ b/lib/ppu_pipeline.c @@ -104,7 +104,7 @@ bool pipeline_fifo_add() { color = lcd_get_context()->bg_colors[0]; } - if(LCDC_OBJ_ENABLE && !ppu_get_context()->debug) { + if(LCDC_OBJ_ENABLE) { color = fetch_sprite_pixels(bit, color, hi | lo); } @@ -287,7 +287,7 @@ void pipeline_push_pixel() { } if(ppu_get_context()->rendering_window) { ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x + - (lcd_get_context()->ly * XRES)] = pixel_data;//interpolate(ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x + + (lcd_get_context()->ly * XRES)] = ppu_get_context()->debug ? 0xFF0000 : pixel_data;//interpolate(ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x + //(lcd_get_context()->ly * XRES)], pixel_data); ppu_get_context()->pfc.pushed_x++; diff --git a/lib/ppu_sm.c b/lib/ppu_sm.c index 1986be1..a7f4e8d 100644 --- a/lib/ppu_sm.c +++ b/lib/ppu_sm.c @@ -121,14 +121,8 @@ void ppu_mode_xfer() { void ppu_mode_vblank() { if(ppu_get_context()->line_ticks >= TICKS_PER_LINE) { increment_ly(); - - if(lcd_get_context()->ly >= LINES_PER_FRAME) { - LCDS_MODE_SET(MODE_OAM); - if(LCDS_STAT_INT(SS_OAM)) { - cpu_request_interrupt(IT_LCD_STAT); - } - lcd_get_context()->ly = 0; - if(lcd_get_context()->ly == lcd_get_context()->ly_compare) { + if(lcd_get_context()->ly == LINES_PER_FRAME-1) { + if(lcd_get_context()->ly_compare == 0) { LCDS_LYC_SET(1); if(LCDS_STAT_INT(SS_LYC)) { cpu_request_interrupt(IT_LCD_STAT); @@ -136,6 +130,13 @@ void ppu_mode_vblank() { } else { LCDS_LYC_SET(0); } + } + if(lcd_get_context()->ly >= LINES_PER_FRAME) { + LCDS_MODE_SET(MODE_OAM); + if(LCDS_STAT_INT(SS_OAM)) { + cpu_request_interrupt(IT_LCD_STAT); + } + lcd_get_context()->ly = 0; ppu_get_context()->window_line = 0; }