cleanup ICycleTiming header value setting
notably don't unset the ClockRate just because the current cycle count is invalid
This commit is contained in:
parent
ec0f761bd9
commit
09c57cf86e
|
@ -51,19 +51,15 @@ namespace BizHawk.Client.Common
|
|||
public void SetCycleValues() //TODO IEmulator should not be an instance prop of movies, it should be passed in to every call (i.e. from MovieService) --yoshi
|
||||
{
|
||||
// The saved cycle value will only be valid if the end of the movie has been emulated.
|
||||
if (this.IsAtEnd())
|
||||
if (this.IsAtEnd() && Emulator.AsCycleTiming() is { } cycleCore)
|
||||
{
|
||||
var cycleCore = Emulator.AsCycleTiming();
|
||||
if (cycleCore != null)
|
||||
{
|
||||
Header[HeaderKeys.CycleCount] = cycleCore.CycleCount.ToString();
|
||||
Header[HeaderKeys.ClockRate] = cycleCore.ClockRate.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
// legacy movies may incorrectly have no ClockRate header value set
|
||||
Header[HeaderKeys.ClockRate] = cycleCore.ClockRate.ToString(NumberFormatInfo.InvariantInfo);
|
||||
Header[HeaderKeys.CycleCount] = cycleCore.CycleCount.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
Header.Remove(HeaderKeys.CycleCount);
|
||||
Header.Remove(HeaderKeys.ClockRate);
|
||||
Header.Remove(HeaderKeys.CycleCount); // don't allow invalid cycle count fields to stay set
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -279,8 +280,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (Emulator.HasCycleTiming())
|
||||
{
|
||||
movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
|
||||
movie.HeaderEntries.Add(HeaderKeys.ClockRate, "0");
|
||||
movie.HeaderEntries.Add(HeaderKeys.ClockRate, Emulator.AsCycleTiming().ClockRate.ToString(NumberFormatInfo.InvariantInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue