From 32c781c53123d2fd3a27c94bbbb7109cf571b140 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 19 Jul 2019 18:19:53 +0300 Subject: [PATCH] Accuracy fixed, major regression fix --- bsnes/gb/Core/display.c | 7 ++++--- bsnes/sfc/coprocessor/icd/interface.cpp | 3 ++- bsnes/sfc/coprocessor/icd/io.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bsnes/gb/Core/display.c b/bsnes/gb/Core/display.c index 2bf00ba9..64c1aeca 100644 --- a/bsnes/gb/Core/display.c +++ b/bsnes/gb/Core/display.c @@ -772,9 +772,6 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) // Todo: unverified timing gb->current_lcd_line++; - if (gb->icd_hreset_callback) { - gb->icd_hreset_callback(gb); - } if (gb->current_lcd_line == LINES && GB_is_sgb(gb)) { display_vblank(gb); @@ -915,6 +912,10 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) } GB_SLEEP(gb, display, 11, LINE_LENGTH - gb->cycles_for_line); gb->mode_for_interrupt = 2; + + if (gb->icd_hreset_callback) { + gb->icd_hreset_callback(gb); + } } /* Lines 144 - 152 */ diff --git a/bsnes/sfc/coprocessor/icd/interface.cpp b/bsnes/sfc/coprocessor/icd/interface.cpp index b9be5838..5f2f092a 100644 --- a/bsnes/sfc/coprocessor/icd/interface.cpp +++ b/bsnes/sfc/coprocessor/icd/interface.cpp @@ -1,3 +1,4 @@ + auto ICD::ppuScanline() -> void { if(++writeY == 8) { writeBank = (writeBank + 1) & 3; @@ -10,7 +11,7 @@ auto ICD::ppuOutput(uint2 color) -> void { if(writeX >= 160) return; // Unverified behavior if(writeY >= 8) return; // Should never happen - uint addr = writeBank * 512 + writeY * 2 + writeX / 8 * 16; + uint addr = (writeBank & 3) * 512 + writeY * 2 + writeX / 8 * 16; output[addr + 0] = (output[addr + 0] << 1) | !!(color & 1); output[addr + 1] = (output[addr + 1] << 1) | !!(color & 2); writeX++; diff --git a/bsnes/sfc/coprocessor/icd/io.cpp b/bsnes/sfc/coprocessor/icd/io.cpp index b3a64a47..ccab1785 100644 --- a/bsnes/sfc/coprocessor/icd/io.cpp +++ b/bsnes/sfc/coprocessor/icd/io.cpp @@ -3,7 +3,7 @@ auto ICD::readIO(uint addr, uint8 data) -> uint8 { //LY counter if(addr == 0x6000) { - uint y = min((uint8)143, ly); + uint y = ly; return (y & ~7) | writeBank; }