GBHawk: GBC HW IO

This commit is contained in:
alyosha-tas 2018-12-28 10:11:37 -06:00
parent 36e159da72
commit 19f3aeec3a
3 changed files with 87 additions and 4 deletions

View File

@ -90,6 +90,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
ser.Sync("speed_switch", ref speed_switch);
ser.Sync("HDMA_transfer", ref HDMA_transfer);
ser.Sync("undoc_6C", ref undoc_6C);
ser.Sync("undoc_72", ref undoc_72);
ser.Sync("undoc_73", ref undoc_73);
ser.Sync("undoc_74", ref undoc_74);
ser.Sync("undoc_75", ref undoc_75);
ser.Sync("undoc_76", ref undoc_76);
ser.Sync("undoc_77", ref undoc_77);
ser.Sync("Use_MT", ref Use_MT);
ser.Sync("addr_access", ref addr_access);

View File

@ -56,6 +56,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public bool speed_switch;
public bool HDMA_transfer; // stalls CPU when in progress
// several undocumented GBC Registers
public byte undoc_6C, undoc_72, undoc_73, undoc_74, undoc_75, undoc_76, undoc_77;
public byte[] _bios;
public readonly byte[] _rom;
public readonly byte[] header = new byte[0x50];

View File

@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// Speed Control for GBC
case 0xFF4D:
if (is_GBC)
if (GBC_compat)
{
ret = (byte)(((double_speed ? 1 : 0) << 7) + ((speed_switch ? 1 : 0)));
}
@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// Speed Control for GBC
case 0xFF70:
if (is_GBC)
if (GBC_compat)
{
ret = (byte)RAM_Bank;
}
@ -159,6 +159,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
break;
case 0xFF6C:
if (GBC_compat) { ret = undoc_6C; }
else { ret = 0xFF; }
break;
case 0xFF72:
if (is_GBC) { ret = undoc_72; }
else { ret = 0xFF; }
break;
case 0xFF73:
if (is_GBC) { ret = undoc_73; }
else { ret = 0xFF; }
break;
case 0xFF74:
if (GBC_compat) { ret = undoc_74; }
else { ret = 0xFF; }
break;
case 0xFF75:
if (is_GBC) { ret = undoc_75; }
else { ret = 0xFF; }
break;
case 0xFF76:
if (is_GBC) { ret = undoc_76; }
else { ret = 0xFF; }
break;
case 0xFF77:
if (is_GBC) { ret = undoc_77; }
else { ret = 0xFF; }
break;
// interrupt control register
case 0xFFFF:
ret = REG_FFFF;
@ -323,7 +358,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// Speed Control for GBC
case 0xFF4D:
if (is_GBC)
if (GBC_compat)
{
speed_switch = (value & 1) > 0;
}
@ -365,13 +400,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// RAM Bank in GBC mode
case 0xFF70:
//Console.WriteLine(value);
if (is_GBC)
if (GBC_compat)
{
RAM_Bank = value & 7;
if (RAM_Bank == 0) { RAM_Bank = 1; }
}
break;
case 0xFF6C:
if (GBC_compat) { undoc_6C |= (byte)(value & 1); }
break;
case 0xFF72:
if (is_GBC) { undoc_72 = value; }
break;
case 0xFF73:
if (is_GBC) { undoc_73 = value; }
break;
case 0xFF74:
if (GBC_compat) { undoc_74 = value; }
break;
case 0xFF75:
if (is_GBC) { undoc_75 |= (byte)(value & 0x70); }
break;
case 0xFF76:
// read only
break;
case 0xFF77:
// read only
break;
// interrupt control register
case 0xFFFF:
REG_FFFF = value;
@ -401,6 +464,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public void Register_Reset()
{
input_register = 0xCF; // not reading any input
//undocumented registers
undoc_6C = 0xFE;
undoc_72 = 0;
undoc_73 = 0;
undoc_74 = 0;
undoc_75 = 0x8F;
undoc_76 = 0;
undoc_77 = 0;
}
}
}