SubGBHawk: use cycle count to correctly track time

This commit is contained in:
alyosha-tas 2020-05-24 16:25:14 -04:00
parent 23c1ccac7e
commit 334844bde2
7 changed files with 19 additions and 10 deletions

View File

@ -102,7 +102,7 @@ namespace BizHawk.Client.Common
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.Pal)
&& movie.HeaderEntries[HeaderKeys.Pal] == "1";
if (movie.HeaderEntries.ContainsKey(HeaderKeys.CycleCount) && core == "Gambatte")
if (movie.HeaderEntries.ContainsKey(HeaderKeys.CycleCount) && ((core == "Gambatte") || (core == "SubGBHawk")))
{
system = "GB_Clock";
}

View File

@ -175,7 +175,7 @@ namespace BizHawk.Client.Common
}
else if (Global.Emulator is Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk subGb)
{
Header[HeaderKeys.VBlankCount] = subGb.VBL_CNT.ToString();
Header[HeaderKeys.CycleCount] = subGb.Cycle_CNT.ToString();
}
var file = new FileInfo(fn);

View File

@ -61,8 +61,12 @@ namespace BizHawk.Client.Common
return Convert.ToUInt64(Header[HeaderKeys.VBlankCount]);
}
if (Header.ContainsKey(HeaderKeys.CycleCount)
&& Header[HeaderKeys.Core] == CoreNames.Gambatte)
if (Header.ContainsKey(HeaderKeys.CycleCount) && Header[HeaderKeys.Core] == CoreNames.Gambatte)
{
return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
}
if (Header.ContainsKey(HeaderKeys.CycleCount) && Header[HeaderKeys.Core] == CoreNames.SubGbHawk)
{
return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
}

View File

@ -330,9 +330,14 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
movie.HeaderEntries.Add("IsCGBMode", "1");
}
if (emulator is SubGBHawk subgbHawk && subgbHawk._GBCore.IsCGBMode())
if (emulator is SubGBHawk subgbHawk)
{
movie.HeaderEntries.Add("IsCGBMode", "1");
if (subgbHawk._GBCore.IsCGBMode())
{
movie.HeaderEntries.Add("IsCGBMode", "1");
}
movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
}
if (emulator is Gameboy gb)

View File

@ -68,7 +68,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
if (_isLag)
{
_lagCount++;
VBL_CNT++;
}
reset_frame = false;
@ -103,6 +102,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
current_cycle++;
frame_cycle++;
Cycle_CNT++;
if (frame_cycle == 70224)
{

View File

@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
ser.Sync(nameof(frame_cycle), ref frame_cycle);
ser.Sync(nameof(input_frame_length), ref input_frame_length);
ser.Sync(nameof(input_frame_length_int), ref input_frame_length_int);
ser.Sync(nameof(VBL_CNT), ref VBL_CNT);
ser.Sync(nameof(Cycle_CNT), ref Cycle_CNT);
}
}
}

View File

@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
HardReset();
current_cycle = 0;
VBL_CNT = 0;
Cycle_CNT = 0;
_GBStatable = _GBCore.ServiceProvider.GetService<IStatable>();
@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
public GBHawk.GBHawk _GBCore;
// needed for movies to accurately calculate timing
public int VBL_CNT;
public long Cycle_CNT;
public void HardReset() => _GBCore.HardReset();