GBHawk: add RTC offset setting
This commit is contained in:
parent
06d53a106a
commit
1c51f09e65
|
@ -111,6 +111,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
set { _RTCInitialTime = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset
|
||||
{
|
||||
get { return _RTCOffset; }
|
||||
set { _RTCOffset = Math.Max(-127, Math.Min(127, 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(8)]
|
||||
|
@ -128,6 +137,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
|
||||
[JsonIgnore]
|
||||
private int _RTCInitialTime;
|
||||
private int _RTCOffset;
|
||||
[JsonIgnore]
|
||||
public ushort _DivInitialTime = 8;
|
||||
|
||||
|
|
|
@ -470,28 +470,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
if (mppr == "MBC3")
|
||||
{
|
||||
Use_MT = true;
|
||||
|
||||
mapper.RTC_Get(_syncSettings.RTCOffset, 5);
|
||||
|
||||
int days = (int)Math.Floor(_syncSettings.RTCInitialTime / 86400.0);
|
||||
|
||||
int days_upper = ((days & 0x100) >> 8) | ((days & 0x200) >> 2);
|
||||
|
||||
mapper.RTC_Get((byte)days_upper, 4);
|
||||
mapper.RTC_Get((byte)(days & 0xFF), 3);
|
||||
mapper.RTC_Get(days_upper, 4);
|
||||
mapper.RTC_Get(days & 0xFF, 3);
|
||||
|
||||
int remaining = _syncSettings.RTCInitialTime - (days * 86400);
|
||||
|
||||
int hours = (int)Math.Floor(remaining / 3600.0);
|
||||
|
||||
mapper.RTC_Get((byte)(hours & 0xFF), 2);
|
||||
mapper.RTC_Get(hours & 0xFF, 2);
|
||||
|
||||
remaining = remaining - (hours * 3600);
|
||||
|
||||
int minutes = (int)Math.Floor(remaining / 60.0);
|
||||
|
||||
mapper.RTC_Get((byte)(minutes & 0xFF), 1);
|
||||
mapper.RTC_Get(minutes & 0xFF, 1);
|
||||
|
||||
remaining = remaining - (minutes * 60);
|
||||
|
||||
mapper.RTC_Get((byte)(remaining & 0xFF), 0);
|
||||
mapper.RTC_Get(remaining & 0xFF, 0);
|
||||
}
|
||||
|
||||
if (mppr == "HuC3")
|
||||
|
@ -500,23 +503,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
|
||||
int years = (int)Math.Floor(_syncSettings.RTCInitialTime / 31536000.0);
|
||||
|
||||
mapper.RTC_Get((byte)years, 24);
|
||||
mapper.RTC_Get(years, 24);
|
||||
|
||||
int remaining = _syncSettings.RTCInitialTime - (years * 31536000);
|
||||
|
||||
int days = (int)Math.Floor(remaining / 86400.0);
|
||||
int days_upper = (days >> 8) & 0xF;
|
||||
|
||||
mapper.RTC_Get((byte)days_upper, 20);
|
||||
mapper.RTC_Get((byte)(days & 0xFF), 12);
|
||||
mapper.RTC_Get(days_upper, 20);
|
||||
mapper.RTC_Get(days & 0xFF, 12);
|
||||
|
||||
remaining = remaining - (days * 86400);
|
||||
|
||||
int minutes = (int)Math.Floor(remaining / 60.0);
|
||||
int minutes_upper = (minutes >> 8) & 0xF;
|
||||
|
||||
mapper.RTC_Get((byte)(minutes_upper), 8);
|
||||
mapper.RTC_Get((byte)(remaining & 0xFF), 0);
|
||||
mapper.RTC_Get(minutes_upper, 8);
|
||||
mapper.RTC_Get(remaining & 0xFF, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void RTC_Get(byte value, int index)
|
||||
public virtual void RTC_Get(int value, int index)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void RTC_Get(byte value, int index)
|
||||
public override void RTC_Get(int value, int index)
|
||||
{
|
||||
time |= (uint)((value & 0xFF) << index);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
public int RTC_timer;
|
||||
public int RTC_low_clock;
|
||||
public bool halt;
|
||||
public int RTC_offset;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
@ -200,9 +201,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
WriteMemory(addr, value);
|
||||
}
|
||||
|
||||
public override void RTC_Get(byte value, int index)
|
||||
public override void RTC_Get(int value, int index)
|
||||
{
|
||||
RTC_regs[index] = value;
|
||||
if (index < 5)
|
||||
{
|
||||
RTC_regs[index] = (byte)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
RTC_offset = value;
|
||||
|
||||
Console.WriteLine("RTC: " + RTC_offset);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Mapper_Tick()
|
||||
|
@ -217,10 +227,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
|
||||
RTC_low_clock++;
|
||||
|
||||
if (RTC_low_clock == 32767) // the RTC appears to be off by one cycle (would be 32768)
|
||||
if (RTC_low_clock == 32768)
|
||||
{
|
||||
RTC_low_clock = 0;
|
||||
|
||||
// adjust for slight RTC error
|
||||
RTC_timer = RTC_offset;
|
||||
|
||||
RTC_regs[0]++;
|
||||
|
||||
if (RTC_regs[0] > 59)
|
||||
|
@ -273,6 +286,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
ser.Sync(nameof(RTC_regs_latch_wr), ref RTC_regs_latch_wr);
|
||||
ser.Sync(nameof(RTC_timer), ref RTC_timer);
|
||||
ser.Sync(nameof(RTC_low_clock), ref RTC_low_clock);
|
||||
ser.Sync(nameof(RTC_offset), ref RTC_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|||
set { _RTCInitialTime_R = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset L")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_L
|
||||
{
|
||||
get { return _RTCOffset_L; }
|
||||
set { _RTCOffset_L = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset R")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_R
|
||||
{
|
||||
get { return _RTCOffset_R; }
|
||||
set { _RTCOffset_R = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("Timer Div Initial Time L")]
|
||||
[Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")]
|
||||
[DefaultValue(8)]
|
||||
|
@ -128,6 +146,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|||
[JsonIgnore]
|
||||
private int _RTCInitialTime_L;
|
||||
private int _RTCInitialTime_R;
|
||||
private int _RTCOffset_L;
|
||||
private int _RTCOffset_R;
|
||||
[JsonIgnore]
|
||||
public ushort _DivInitialTime_L = 8;
|
||||
public ushort _DivInitialTime_R = 8;
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|||
temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R;
|
||||
temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L;
|
||||
temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R;
|
||||
temp_sync_L.RTCOffset = linkSyncSettings.RTCOffset_L;
|
||||
temp_sync_R.RTCOffset = linkSyncSettings.RTCOffset_R;
|
||||
|
||||
L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
|
||||
game_L, rom_L, temp_set_L, temp_sync_L);
|
||||
|
|
|
@ -122,6 +122,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
set { _RTCInitialTime_R = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset L")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_L
|
||||
{
|
||||
get { return _RTCOffset_L; }
|
||||
set { _RTCOffset_L = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset C")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_C
|
||||
{
|
||||
get { return _RTCOffset_C; }
|
||||
set { _RTCOffset_C = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset R")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_R
|
||||
{
|
||||
get { return _RTCOffset_R; }
|
||||
set { _RTCOffset_R = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("Timer Div Initial Time L")]
|
||||
[Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")]
|
||||
[DefaultValue(8)]
|
||||
|
@ -158,6 +185,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
private int _RTCInitialTime_L;
|
||||
private int _RTCInitialTime_C;
|
||||
private int _RTCInitialTime_R;
|
||||
private int _RTCOffset_L;
|
||||
private int _RTCOffset_C;
|
||||
private int _RTCOffset_R;
|
||||
[JsonIgnore]
|
||||
public ushort _DivInitialTime_L = 8;
|
||||
public ushort _DivInitialTime_C = 8;
|
||||
|
|
|
@ -61,6 +61,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
temp_sync_L.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_L;
|
||||
temp_sync_C.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_C;
|
||||
temp_sync_R.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_R;
|
||||
temp_sync_L.RTCOffset = Link3xSyncSettings.RTCOffset_L;
|
||||
temp_sync_C.RTCOffset = Link3xSyncSettings.RTCOffset_C;
|
||||
temp_sync_R.RTCOffset = Link3xSyncSettings.RTCOffset_R;
|
||||
|
||||
L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
|
||||
game_L, rom_L, temp_set_L, temp_sync_L);
|
||||
|
|
|
@ -142,6 +142,42 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
set { _RTCInitialTime_D = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset A")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_A
|
||||
{
|
||||
get { return _RTCOffset_A; }
|
||||
set { _RTCOffset_A = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset B")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_B
|
||||
{
|
||||
get { return _RTCOffset_B; }
|
||||
set { _RTCOffset_B = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset C")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_C
|
||||
{
|
||||
get { return _RTCOffset_C; }
|
||||
set { _RTCOffset_C = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("RTC Offset D")]
|
||||
[Description("Set error in RTC clocking (-127 to 127)")]
|
||||
[DefaultValue(0)]
|
||||
public int RTCOffset_D
|
||||
{
|
||||
get { return _RTCOffset_D; }
|
||||
set { _RTCOffset_D = Math.Max(-127, Math.Min(127, value)); }
|
||||
}
|
||||
|
||||
[DisplayName("Timer Div Initial Time A")]
|
||||
[Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")]
|
||||
[DefaultValue(8)]
|
||||
|
@ -188,6 +224,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
private int _RTCInitialTime_B;
|
||||
private int _RTCInitialTime_C;
|
||||
private int _RTCInitialTime_D;
|
||||
private int _RTCOffset_A;
|
||||
private int _RTCOffset_B;
|
||||
private int _RTCOffset_C;
|
||||
private int _RTCOffset_D;
|
||||
[JsonIgnore]
|
||||
public ushort _DivInitialTime_A = 8;
|
||||
public ushort _DivInitialTime_B = 8;
|
||||
|
|
|
@ -68,6 +68,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
temp_sync_B.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_B;
|
||||
temp_sync_C.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_C;
|
||||
temp_sync_D.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_D;
|
||||
temp_sync_A.RTCOffset = Link4xSyncSettings.RTCOffset_A;
|
||||
temp_sync_B.RTCOffset = Link4xSyncSettings.RTCOffset_B;
|
||||
temp_sync_C.RTCOffset = Link4xSyncSettings.RTCOffset_C;
|
||||
temp_sync_D.RTCOffset = Link4xSyncSettings.RTCOffset_D;
|
||||
|
||||
A = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
|
||||
game_A, rom_A, temp_set_A, temp_sync_A);
|
||||
|
|
Loading…
Reference in New Issue