From 2ab09f9b4c95caefd154615aa9c005de49faa6a0 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Wed, 19 Feb 2025 07:34:36 -0700 Subject: [PATCH] fixed lyc interrupt when lyc = 0 --- lib/lcd.c | 4 ++-- lib/ppu_sm.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/lcd.c b/lib/lcd.c index c8a20a7..64f64d3 100644 --- a/lib/lcd.c +++ b/lib/lcd.c @@ -59,11 +59,11 @@ void lcd_write(u16 address, u8 value) { p[offset] = value; if(offset == 2) { - printf("YScroll: %02X\n", value); + //printf("YScroll: %02X\n", value); } if(offset == 0xA) { - printf("WinY: %02X\n", value); + //printf("WinY: %02X\n", value); } if(offset == 6) { diff --git a/lib/ppu_sm.c b/lib/ppu_sm.c index 36ef1f5..d5de13e 100644 --- a/lib/ppu_sm.c +++ b/lib/ppu_sm.c @@ -17,7 +17,6 @@ void increment_ly() { if(lcd_get_context()->ly == lcd_get_context()->ly_compare) { LCDS_LYC_SET(1); - if(LCDS_STAT_INT(SS_LYC)) { cpu_request_interrupt(IT_LCD_STAT); } @@ -128,6 +127,14 @@ void ppu_mode_vblank() { cpu_request_interrupt(IT_LCD_STAT); } lcd_get_context()->ly = 0; + if(lcd_get_context()->ly == lcd_get_context()->ly_compare) { + LCDS_LYC_SET(1); + if(LCDS_STAT_INT(SS_LYC)) { + cpu_request_interrupt(IT_LCD_STAT); + } + } else { + LCDS_LYC_SET(0); + } ppu_get_context()->window_line = 0; }