diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs index fe5a9db913..b4695e81d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -644,9 +644,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk no_sprites = false; evaled_sprites = 0; window_pre_render = false; + window_latch = LCDC.Bit(5); // TODO: If Window is turned on midscanline what happens? When is this check done exactly? - if ((window_started && LCDC.Bit(5)) || (window_is_reset && !LCDC.Bit(5) && (LY > window_y))) + if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY > window_y))) { window_y_tile_inc++; if (window_y_tile_inc==8) @@ -665,7 +666,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } // before anything else, we have to check if windowing is in effect - if (LCDC.Bit(5) && !window_started && (LY >= window_y) && (pixel_counter >= (window_x_latch - 7)) && (window_x_latch < 167)) + if (window_latch && !window_started && (LY >= window_y) && (pixel_counter >= (window_x_latch - 7)) && (window_x_latch < 167)) { /* Console.Write(LY); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs index 087a47d296..0e41731261 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs @@ -415,9 +415,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk evaled_sprites = 0; window_pre_render = false; + window_latch = LCDC.Bit(5); // TODO: If Window is turned on midscanline what happens? When is this check done exactly? - if ((window_started && LCDC.Bit(5)) || (window_is_reset && !LCDC.Bit(5) && (LY > window_y))) + if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY > window_y))) { window_y_tile_inc++; if (window_y_tile_inc==8) @@ -436,7 +437,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } // before anything else, we have to check if windowing is in effect - if (LCDC.Bit(5) && !window_started && (LY >= window_y) && (pixel_counter >= (window_x_latch - 7)) && (window_x_latch < 167)) + if (window_latch && !window_started && (LY >= window_y) && (pixel_counter >= (window_x_latch - 7)) && (window_x_latch < 167)) { /* Console.Write(LY); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs index 1953dbd410..12037bdc4a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs @@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (ppu.DMA_start) { // some of gekkio's tests require these to be accessible during DMA - if (addr < 0x4000) + if (addr < 0x8000) { if (ppu.DMA_addr < 0x80) { @@ -270,7 +270,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (ppu.DMA_start) { // some of gekkio's tests require these to be accessible during DMA - if (addr < 0x4000) + if (addr < 0x8000) { if (ppu.DMA_addr < 0x80) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs index 2783853b34..6c86840b18 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -93,6 +93,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public int evaled_sprites; public int sprite_ordered_index; public bool blank_frame; + public bool window_latch; // windowing state public int window_counter; @@ -244,6 +245,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk ser.Sync("SL_sprites_ordered", ref SL_sprites_ordered, false); ser.Sync("sprite_ordered_index", ref sprite_ordered_index); ser.Sync("blank_frame", ref blank_frame); + ser.Sync("window_latch", ref window_latch); ser.Sync("window_counter", ref window_counter); ser.Sync("window_pre_render", ref window_pre_render);