parent
87209aa11b
commit
a9c04524c7
|
@ -295,7 +295,7 @@ namespace BizHawk.Client.Common
|
|||
movie.HeaderEntries.Add(HeaderKeys.VsyncAttoseconds, mame.VsyncAttoseconds.ToString());
|
||||
}
|
||||
|
||||
if (emulator is ICycleTiming)
|
||||
if (emulator.HasCycleTiming())
|
||||
{
|
||||
movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0");
|
||||
movie.HeaderEntries.Add(HeaderKeys.ClockRate, "0");
|
||||
|
|
|
@ -342,12 +342,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void HandlePlaybackEnd()
|
||||
{
|
||||
if (Movie.IsAtEnd() && (Movie.Emulator is ICycleTiming cycleCore))
|
||||
if (Movie.IsAtEnd() && Movie.Emulator.HasCycleTiming())
|
||||
{
|
||||
long coreValue = cycleCore.CycleCount;
|
||||
bool movieHasValue = Movie.HeaderEntries.TryGetValue(HeaderKeys.CycleCount, out string movieValueStr);
|
||||
var coreValue = Movie.Emulator.AsCycleTiming().CycleCount;
|
||||
var movieHasValue = Movie.HeaderEntries.TryGetValue(HeaderKeys.CycleCount, out var movieValueStr);
|
||||
|
||||
long movieValue = movieHasValue ? Convert.ToInt64(movieValueStr) : 0;
|
||||
var movieValue = movieHasValue ? Convert.ToInt64(movieValueStr) : 0;
|
||||
var valuesMatch = movieValue == coreValue;
|
||||
|
||||
if (!movieHasValue || !valuesMatch)
|
||||
|
|
|
@ -54,7 +54,8 @@ namespace BizHawk.Client.Common
|
|||
// The saved cycle value will only be valid if the end of the movie has been emulated.
|
||||
if (this.IsAtEnd())
|
||||
{
|
||||
if (Emulator is ICycleTiming cycleCore)
|
||||
var cycleCore = Emulator.AsCycleTiming();
|
||||
if (cycleCore != null)
|
||||
{
|
||||
Header[HeaderKeys.CycleCount] = cycleCore.CycleCount.ToString();
|
||||
Header[HeaderKeys.ClockRate] = cycleCore.ClockRate.ToString(CultureInfo.InvariantCulture);
|
||||
|
|
|
@ -354,6 +354,12 @@ namespace BizHawk.Emulation.Common
|
|||
return core.VsyncNumerator() / (double)core.VsyncDenominator();
|
||||
}
|
||||
|
||||
public static bool HasCycleTiming(this IEmulator core)
|
||||
=> core != null && core.ServiceProvider.HasService<ICycleTiming>();
|
||||
|
||||
public static ICycleTiming AsCycleTiming(this IEmulator core)
|
||||
=> core.ServiceProvider.GetService<ICycleTiming>();
|
||||
|
||||
public static bool IsImplemented(this MethodInfo info)
|
||||
{
|
||||
return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute);
|
||||
|
|
Loading…
Reference in New Issue