GBHawk: GBC Bug fixes

This commit is contained in:
alyosha-tas 2018-03-27 17:24:55 -04:00
parent ae6ce00d7c
commit 220b41cc16
5 changed files with 32 additions and 9 deletions

View File

@ -43,7 +43,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// controls for tile attributes
public int VRAM_sel;
public bool BG_V_flip;
public bool HDMA_active;
public bool HDMA_mode;
public ushort cur_DMA_src;
public ushort cur_DMA_dest;
@ -196,7 +195,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
cur_DMA_dest = (ushort)(((HDMA_dest_hi & 0x1F) << 8) | (HDMA_dest_lo & 0xF0));
cur_DMA_src = (ushort)(((HDMA_src_hi & 0xFF) << 8) | (HDMA_src_lo & 0xF0));
HDMA_length = ((HDMA_ctrl & 0x7F) + 1) * 16;
HDMA_length = ((value & 0x7F) + 1) * 16;
}
else
{
@ -244,17 +243,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
if (HDMA_countdown == 0)
{
if (!HDMA_mode)
{
// immediately transfer bytes, 2 bytes per cycles
if (HDMA_length > 0)
{
Core.VRAM[(Core.VRAM_Bank * 0x2000) + cur_DMA_dest] = Core.ReadMemory(cur_DMA_src);
Core.VRAM[(Core.VRAM_Bank * 0x2000) + cur_DMA_dest] = Core.ReadMemory(cur_DMA_src);
cur_DMA_dest = (ushort)((cur_DMA_dest + 1) & 0x1FFF);
cur_DMA_src = (ushort)((cur_DMA_src + 1) & 0xFFFF);
HDMA_length--;
Core.VRAM[(Core.VRAM_Bank * 0x2000) + cur_DMA_dest] = Core.ReadMemory(cur_DMA_src);
Core.VRAM[(Core.VRAM_Bank * 0x2000) + cur_DMA_dest] = Core.ReadMemory(cur_DMA_src);
cur_DMA_dest = (ushort)((cur_DMA_dest + 1) & 0x1FFF);
cur_DMA_src = (ushort)((cur_DMA_src + 1) & 0xFFFF);
HDMA_length--;
@ -268,7 +267,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
else
{
// only transfer during mode 3, and only 16 bytes at a time
// only transfer during mode 0, and only 16 bytes at a time
if (((STAT & 3) == 0) && (LY != last_HBL) && HBL_test)
{
HBL_HDMA_go = true;
@ -286,6 +285,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
cur_DMA_src = (ushort)((cur_DMA_src + 1) & 0xFFFF);
HDMA_length--;
HBL_HDMA_count--;
Core.VRAM[(Core.VRAM_Bank * 0x2000) + cur_DMA_dest] = Core.ReadMemory(cur_DMA_src);
cur_DMA_dest = (ushort)((cur_DMA_dest + 1) & 0x1FFF);
cur_DMA_src = (ushort)((cur_DMA_src + 1) & 0xFFFF);
@ -303,6 +303,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
HBL_test = true;
last_HBL = LY;
HBL_HDMA_count = 0x10;
HBL_HDMA_go = false;
}
}
}
@ -1448,7 +1449,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
ser.Sync("VRAM_sel", ref VRAM_sel);
ser.Sync("BG_V_flip", ref BG_V_flip);
ser.Sync("HDMA_active", ref HDMA_active);
ser.Sync("HDMA_mode", ref HDMA_mode);
ser.Sync("cur_DMA_src", ref cur_DMA_src);
ser.Sync("cur_DMA_dest", ref cur_DMA_dest);

View File

@ -135,6 +135,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
timer.tick_2();
}
}
else
{
cpu.TotalExecutedCycles++;
if (double_speed)
{
cpu.TotalExecutedCycles++;
}
}
if (in_vblank && !in_vblank_old)
{

View File

@ -101,6 +101,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
set { _RTCInitialTime = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); }
}
[DisplayName("Timer Div Initial Time")]
[Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")]
[DefaultValue(0)]
public int DivInitialTime
{
get { return _DivInitialTime; }
set { _DivInitialTime = Math.Min((ushort)65535, (ushort)value); }
}
[DisplayName("Use Existing SaveRAM")]
[Description("When true, existing SaveRAM will be loaded at boot up")]
[DefaultValue(false)]
@ -109,6 +118,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
[JsonIgnore]
private int _RTCInitialTime;
[JsonIgnore]
private ushort _DivInitialTime;
public GBSyncSettings Clone()

View File

@ -319,7 +319,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// VBK
case 0xFF4F:
if (is_GBC)
if (is_GBC && !ppu.HDMA_active)
{
VRAM_Bank = (byte)(value & 1);
}
@ -353,7 +353,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// RAM Bank in GBC mode
case 0xFF70:
//Console.WriteLine(value);
if (is_GBC)
if (is_GBC && !ppu.HDMA_active)
{
RAM_Bank = value & 7;
if (RAM_Bank == 0) { RAM_Bank = 1; }

View File

@ -12,6 +12,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public uint[] BG_palette = new uint[32];
public uint[] OBJ_palette = new uint[32];
public bool HDMA_active;
// register variables
public byte LCDC;
public byte STAT;
@ -160,6 +163,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
ser.Sync("BG_palette", ref BG_palette, false);
ser.Sync("OBJ_palette", ref OBJ_palette, false);
ser.Sync("HDMA_active", ref HDMA_active);
ser.Sync("LCDC", ref LCDC);
ser.Sync("STAT", ref STAT);