diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs index a9c80825a1..e41ba27540 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_GB_PPU.cs @@ -763,9 +763,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // i.e. just keeping track of the lowest x-value sprite if (render_cycle == 0) { - // window X is latched for the scanline, mid-line changes have no effect - window_x_latch = window_x; - OAM_scan_index = 0; read_case = 0; internal_cycle = 0; @@ -1012,6 +1009,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { // calculate the row number of the tiles to be fetched y_tile = (((int)scroll_y + LY) >> 3) % 32; + x_tile = scroll_x >> 3; temp_fetch = y_tile * 32 + (x_tile + tile_inc) % 32; tile_byte = Core.VRAM[0x1800 + (LCDC.Bit(3) ? 1 : 0) * 0x400 + temp_fetch]; @@ -1103,8 +1101,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // here we set up rendering pre_render = false; - // x scroll is latched here - x_tile = scroll_x >> 3; + // window X is latched for the scanline, mid-line changes have no effect + window_x_latch = window_x; + + // x scroll is latched here, only the lower 3 bits are latched though render_offset = scroll_offset = scroll_x % 8; render_counter = 0; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs index f3cf3e619d..2886ed19ed 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -754,9 +754,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // i.e. just keeping track of the lowest x-value sprite if (render_cycle == 0) { - // window X is latched for the scanline, mid-line changes have no effect - window_x_latch = window_x; - OAM_scan_index = 0; read_case = 0; internal_cycle = 0; @@ -966,6 +963,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { // calculate the row number of the tiles to be fetched y_tile = (((int)scroll_y + LY) >> 3) % 32; + x_tile = scroll_x >> 3; temp_fetch = y_tile * 32 + (x_tile + tile_inc) % 32; tile_byte = Core.VRAM[0x1800 + (LCDC.Bit(3) ? 1 : 0) * 0x400 + temp_fetch]; @@ -1058,8 +1056,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // here we set up rendering pre_render = false; - // calculate the column number of the tile to start with - x_tile = scroll_x >> 3; + // window X is latched for the scanline, mid-line changes have no effect + window_x_latch = window_x; + + // x scroll is latched here, only the lower 3 bits are latched though render_offset = scroll_offset = scroll_x % 8; render_counter = 0; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs index 701cdefde1..77a9359cfc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs @@ -445,9 +445,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // i.e. just keeping track of the lowest x-value sprite if (render_cycle == 0) { - // window X is latched for the scanline, mid-line changes have no effect - window_x_latch = window_x; - OAM_scan_index = 0; read_case = 0; internal_cycle = 0; @@ -642,6 +639,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { // calculate the row number of the tiles to be fetched y_tile = (((int)scroll_y + LY) >> 3) % 32; + x_tile = scroll_x >> 3; temp_fetch = y_tile * 32 + (x_tile + tile_inc) % 32; @@ -720,8 +718,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // here we set up rendering pre_render = false; + // window X is latched for the scanline, mid-line changes have no effect + window_x_latch = window_x; + // x scroll is latched here - x_tile = scroll_x >> 3; render_offset = scroll_offset = scroll_x % 8; render_counter = 0; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs index 5651ff7a5f..07036610cc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs @@ -1,5 +1,6 @@ using BizHawk.Common; using BizHawk.Emulation.Cores.Components.LR35902; +using System; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { @@ -210,6 +211,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } else if ((RAM_bank >= 8) && (RAM_bank <= 0xC)) { + // not all bits are writable + switch (RAM_bank - 8) + { + case 0: value &= 0x3F; break; + case 1: value &= 0x3F; break; + case 2: value &= 0x1F; break; + case 3: value &= 0xFF; break; + case 4: value &= 0xC1; break; + } + RTC_regs[RAM_bank - 8] = value; if ((RAM_bank - 8) == 0) { RTC_low_clock = RTC_timer = 0; } @@ -256,15 +267,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk RTC_regs[0]++; - if (RTC_regs[0] > 59) + if (RTC_regs[0] == 60) { RTC_regs[0] = 0; RTC_regs[1]++; - if (RTC_regs[1] > 59) + if (RTC_regs[1] == 60) { RTC_regs[1] = 0; RTC_regs[2]++; - if (RTC_regs[2] > 23) + if (RTC_regs[2] == 24) { RTC_regs[2] = 0; if (RTC_regs[3] < 0xFF) @@ -286,7 +297,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } } } + else + { + RTC_regs[2] &= 0x1F; + } } + else + { + RTC_regs[1] &= 0x3F; + } + } + else + { + RTC_regs[0] &= 0x3F; } } }