Move VsyncNum and VsyncDen out of CoreComm and into IVideoProvider
This commit is contained in:
parent
34d1e4fe57
commit
62a13d961d
|
@ -52,5 +52,15 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,6 +221,16 @@ namespace BizHawk.Client.Common
|
|||
public int BufferWidth { get; set; }
|
||||
public int BufferHeight { get; set; }
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe bool Load(IVideoProvider v, Stream s)
|
||||
|
|
|
@ -112,6 +112,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
public int BufferWidth { get; }
|
||||
public int BufferHeight { get; }
|
||||
public int BackgroundColor { get; }
|
||||
public int VsyncNum { get; }
|
||||
public int VsyncDen { get; }
|
||||
public VideoCopy(IVideoProvider c)
|
||||
{
|
||||
_vb = (int[])c.GetVideoBuffer().Clone();
|
||||
|
@ -120,6 +122,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
BackgroundColor = c.BackgroundColor;
|
||||
VirtualWidth = c.VirtualWidth;
|
||||
VirtualHeight = c.VirtualHeight;
|
||||
VsyncNum = c.VsyncNum;
|
||||
VsyncDen = c.VsyncDen;
|
||||
}
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
|
@ -128,7 +132,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// opens an avi file for recording with the supplied enumerator used to name files.
|
||||
/// set a video codec token first.
|
||||
|
|
|
@ -49,5 +49,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
public int BufferHeight => _bmp.Height;
|
||||
|
||||
public int BackgroundColor => 0;
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -416,6 +416,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
public int BufferWidth { get; set; }
|
||||
public int BufferHeight { get; set; }
|
||||
public int BackgroundColor { get; set; }
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
}
|
||||
|
||||
void FixRatio(float x, float y, int inw, int inh, out int outw, out int outh)
|
||||
|
|
|
@ -1861,7 +1861,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Global.DisableSecondaryThrottling = _unthrottled || turbo || fastForward || rewind;
|
||||
|
||||
// realtime throttle is never going to be so exact that using a double here is wrong
|
||||
_throttle.SetCoreFps(Emulator.CoreComm.VsyncRate);
|
||||
_throttle.SetCoreFps(Emulator.VsyncRate());
|
||||
_throttle.signal_paused = EmulatorPaused;
|
||||
_throttle.signal_unthrottle = _unthrottled || turbo;
|
||||
//zero 26-mar-2016 - vsync and vsync throttle here both is odd, but see comments elsewhere about triple buffering
|
||||
|
@ -3034,7 +3034,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
aw = new AudioStretcher(aw);
|
||||
}
|
||||
|
||||
aw.SetMovieParameters(Emulator.CoreComm.VsyncNum, Emulator.CoreComm.VsyncDen);
|
||||
aw.SetMovieParameters(Emulator.VsyncNum(), Emulator.VsyncDen());
|
||||
if (_avwriterResizew > 0 && _avwriterResizeh > 0)
|
||||
{
|
||||
aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Threading;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -99,7 +100,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (source.SyncMode == SyncSoundMode.Async)
|
||||
{
|
||||
_bufferedAsync.RecalculateMagic(Global.Emulator.CoreComm.VsyncRate);
|
||||
_bufferedAsync.RecalculateMagic(Global.Emulator.VsyncRate());
|
||||
_bufferedProvider = _bufferedAsync;
|
||||
}
|
||||
else throw new InvalidOperationException("Unsupported sync mode.");
|
||||
|
@ -112,7 +113,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
internal void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded)
|
||||
{
|
||||
// Fill device buffer with silence but leave enough room for one frame
|
||||
int samplesPerFrame = (int)Math.Round(SampleRate / Global.Emulator.CoreComm.VsyncRate);
|
||||
int samplesPerFrame = (int)Math.Round(SampleRate / (double)Global.Emulator.VsyncRate());
|
||||
int silenceSamples = Math.Max(samplesNeeded - samplesPerFrame, 0);
|
||||
_outputDevice.WriteSamples(new short[silenceSamples * 2], silenceSamples);
|
||||
samplesNeeded -= silenceSamples;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -120,7 +121,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private double AdvertisedSamplesPerFrame
|
||||
{
|
||||
get { return SampleRate / Global.Emulator.CoreComm.VsyncRate; }
|
||||
get { return SampleRate / Global.Emulator.VsyncRate(); }
|
||||
}
|
||||
|
||||
public void GetSamples(short[] samples)
|
||||
|
|
|
@ -282,6 +282,16 @@ namespace BizHawk.Client.MultiHawk
|
|||
public int BufferWidth { get; set; }
|
||||
public int BufferHeight { get; set; }
|
||||
public int BackgroundColor { get; set; }
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
get { throw new InvalidOperationException(); }
|
||||
}
|
||||
}
|
||||
|
||||
void FixRatio(float x, float y, int inw, int inh, out int outw, out int outh)
|
||||
|
|
|
@ -956,7 +956,7 @@ namespace BizHawk.Client.MultiHawk
|
|||
Global.DisableSecondaryThrottling = /*_unthrottled || TODO */ turbo || fastForward;
|
||||
|
||||
// realtime throttle is never going to be so exact that using a double here is wrong
|
||||
_throttle.SetCoreFps(EmulatorWindows.Master.Emulator.CoreComm.VsyncRate);
|
||||
_throttle.SetCoreFps(EmulatorWindows.Master.Emulator.VsyncRate());
|
||||
_throttle.signal_paused = EmulatorPaused;
|
||||
_throttle.signal_unthrottle = /*_unthrottled || TODO */ turbo;
|
||||
_throttle.signal_overrideSecondaryThrottle = fastForward && (Global.Config.SoundThrottle || Global.Config.VSyncThrottle || Global.Config.VSync);
|
||||
|
|
|
@ -110,6 +110,10 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public int BackgroundColor => NullVideo.DefaultBackgroundColor;
|
||||
|
||||
public int VsyncNum => NullVideo.DefaultVsyncNum;
|
||||
|
||||
public int VsyncDen => NullVideo.DefaultVsyncDen;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISoundProvider
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
public static int DefaultWidth { get; } = 256;
|
||||
public static int DefaultHeight { get; } = 192;
|
||||
public static int DefaultBackgroundColor { get; } = 0;
|
||||
public static int DefaultVsyncNum { get; } = 60;
|
||||
public static int DefaultVsyncDen { get; } = 1;
|
||||
|
||||
public int VirtualWidth => DefaultWidth;
|
||||
|
||||
|
@ -27,5 +29,9 @@
|
|||
public int BufferHeight => DefaultHeight;
|
||||
|
||||
public int BackgroundColor => DefaultBackgroundColor;
|
||||
|
||||
public int VsyncNum => DefaultVsyncNum;
|
||||
|
||||
public int VsyncDen => DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,6 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public ICoreFileProvider CoreFileProvider { get; set; }
|
||||
|
||||
public double VsyncRate => VsyncNum / (double)VsyncDen;
|
||||
|
||||
public int VsyncNum { get; set; } = 60;
|
||||
public int VsyncDen { get; set; } = 1;
|
||||
|
||||
// a core should set these if you wish to provide rom status information yourself. otherwise it will be calculated by the frontend in a way you may not like, using RomGame-related concepts.
|
||||
public string RomStatusAnnotation { get; set; }
|
||||
public string RomStatusDetails { get; set; }
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
public static ISoundProvider AsSoundProviderOrDefault(this IEmulator core)
|
||||
{
|
||||
return core.ServiceProvider.GetService<ISoundProvider>()
|
||||
?? CachedNullSoundProviders.GetValue(core, e => new NullSound(e.CoreComm.VsyncNum, e.CoreComm.VsyncDen));
|
||||
?? CachedNullSoundProviders.GetValue(core, e => new NullSound(core.VsyncNum(), core.VsyncDen()));
|
||||
}
|
||||
|
||||
public static bool HasMemoryDomains(this IEmulator core)
|
||||
|
@ -262,7 +262,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// once upon a time, we did a try { poke(peek) } here, but that was before Writable was added. the poke(peek) is not acceptable. If there are further problems, make sure Writable is correct.
|
||||
return true;
|
||||
}
|
||||
|
@ -342,6 +342,31 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
return core.ServiceProvider.GetService<IBoardInfo>();
|
||||
}
|
||||
|
||||
public static int VsyncNum(this IEmulator core)
|
||||
{
|
||||
if (core != null && core.HasVideoProvider())
|
||||
{
|
||||
//return core.AsVideoProvider().VsyncNum
|
||||
}
|
||||
|
||||
return 60;
|
||||
}
|
||||
|
||||
public static int VsyncDen(this IEmulator core)
|
||||
{
|
||||
if (core != null && core.HasVideoProvider())
|
||||
{
|
||||
//return core.AsVideoProvider().VsyncDen
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int VsyncRate(this IEmulator core)
|
||||
{
|
||||
return core.VsyncNum() / core.VsyncDen();
|
||||
}
|
||||
|
||||
// TODO: a better place for these
|
||||
public static bool IsImplemented(this MethodInfo info)
|
||||
{
|
||||
|
@ -366,4 +391,4 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplemented);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,6 +44,16 @@
|
|||
/// </summary>
|
||||
int BufferHeight { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vsync Numerator. Combined with the <seealso cref="VsyncDen"/> can be used to calculate a precise vsync rate.
|
||||
/// </summary>
|
||||
int VsyncNum { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vsync Denominator. Combined with the <seealso cref="VsyncDen"/> can be used to calculate a precise vsync rate.
|
||||
/// </summary>
|
||||
int VsyncDen { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default color when no other color is applied
|
||||
/// Often cores will set this to something other than black
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
public int BufferWidth => 96;
|
||||
public int BufferHeight => 64;
|
||||
public int BackgroundColor => 0;
|
||||
public int VsyncNum => NullVideo.DefaultVsyncNum;
|
||||
public int VsyncDen => NullVideo.DefaultVsyncDen;
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
|
|
|
@ -18,5 +18,23 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
|||
public int BufferWidth => 560;
|
||||
public int BufferHeight => 384;
|
||||
public int BackgroundColor => 0;
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,10 +244,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|||
_board = new Motherboard(this, initRegion, borderType, sidType, tapeDriveType, diskDriveType);
|
||||
InitRoms(diskDriveType);
|
||||
_board.Init();
|
||||
|
||||
// configure video
|
||||
CoreComm.VsyncDen = _board.Vic.CyclesPerFrame;
|
||||
CoreComm.VsyncNum = _board.Vic.CyclesPerSecond;
|
||||
}
|
||||
|
||||
private void InitMedia()
|
||||
|
|
|
@ -70,5 +70,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
|||
|
||||
[SaveState.DoNotSave]
|
||||
public int VirtualHeight { get; private set; }
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
public int VsyncNum => CyclesPerFrame;
|
||||
|
||||
[SaveState.DoNotSave]
|
||||
public int VsyncDen => CyclesPerSecond;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,13 +310,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
}
|
||||
|
||||
// dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
|
||||
_tia = new TIA(this, _pal, Settings.SECAMColors, CoreComm.VsyncRate > 55.0 ? 735 : 882);
|
||||
|
||||
int vsyncNum, vsyncDen;
|
||||
_tia.GetFrameRate(out vsyncNum, out vsyncDen);
|
||||
|
||||
CoreComm.VsyncNum = vsyncNum;
|
||||
CoreComm.VsyncDen = vsyncDen;
|
||||
_tia = new TIA(this, _pal, Settings.SECAMColors);
|
||||
|
||||
_dcfilter = new DCFilter(_tia, 256);
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
private const int BackColor = unchecked((int)0xff000000);
|
||||
|
||||
private int _vsyncNum, _vsyncDen;
|
||||
|
||||
static TIA()
|
||||
{
|
||||
// add alpha to palette entries
|
||||
|
@ -234,7 +236,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
public int NominalNumScanlines => _pal ? 312 : 262;
|
||||
|
||||
public void GetFrameRate(out int num, out int den)
|
||||
private void CalcFrameRate()
|
||||
{
|
||||
// TODO when sound timing is made exact:
|
||||
// NTSC refclock is actually 315 / 88 mhz
|
||||
|
@ -243,8 +245,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
int clockrate = _pal ? 3546895 : 3579545;
|
||||
int clocksperframe = 228 * NominalNumScanlines;
|
||||
int gcd = (int)BigInteger.GreatestCommonDivisor(clockrate, clocksperframe);
|
||||
num = clockrate / gcd;
|
||||
den = clocksperframe / gcd;
|
||||
_vsyncNum = clockrate / gcd;
|
||||
_vsyncDen = clocksperframe / gcd;
|
||||
}
|
||||
|
||||
private const int ScreenWidth = 160;
|
||||
|
@ -325,14 +327,18 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
//public byte[] current_audio_register = new byte[6];
|
||||
public short[] _local_audio_cycles = new short[2000];
|
||||
|
||||
public TIA(Atari2600 core, bool pal, bool secam, int spf)
|
||||
public TIA(Atari2600 core, bool pal, bool secam)
|
||||
{
|
||||
_core = core;
|
||||
_player0.ScanCnt = 8;
|
||||
_player1.ScanCnt = 8;
|
||||
_pal = pal;
|
||||
SetSECAM(secam);
|
||||
_spf = spf;
|
||||
|
||||
|
||||
CalcFrameRate();
|
||||
|
||||
_spf = _vsyncNum / (double)_vsyncDen > 55.0 ? 735 : 882;
|
||||
}
|
||||
|
||||
public void SetSECAM(bool secam)
|
||||
|
@ -387,6 +393,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
public int BackgroundColor => _core.Settings.BackgroundColor.ToArgb();
|
||||
|
||||
public int VsyncNum => _vsyncNum;
|
||||
|
||||
public int VsyncDen => _vsyncDen;
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
return FrameBuffer;
|
||||
|
|
|
@ -205,10 +205,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
|
||||
_avProvider.ConnectToMachine(theMachine, GameInfo);
|
||||
|
||||
// to sync exactly with audio as this emulator creates and times it, the frame rate should be exactly 60:1 or 50:1
|
||||
CoreComm.VsyncNum = theMachine.FrameHZ;
|
||||
CoreComm.VsyncDen = 1;
|
||||
|
||||
SetupMemoryDomains(hsc7800);
|
||||
}
|
||||
|
||||
|
@ -218,9 +214,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
|
||||
private class MyAVProvider : IVideoProvider, ISoundProvider, IDisposable
|
||||
{
|
||||
// to sync exactly with audio as this emulator creates and times it, the frame rate should be exactly 60:1 or 50:1
|
||||
private int _frameHz;
|
||||
|
||||
public FrameBuffer Framebuffer { get; private set; }
|
||||
public void ConnectToMachine(MachineBase m, EMU7800.Win.GameProgram g)
|
||||
{
|
||||
_frameHz = m.FrameHZ;
|
||||
Framebuffer = m.CreateFrameBuffer();
|
||||
BufferWidth = Framebuffer.VisiblePitch;
|
||||
BufferHeight = Framebuffer.Scanlines;
|
||||
|
@ -281,6 +281,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
|||
public int BufferWidth { get; private set; }
|
||||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
public int VsyncNum => _frameHz;
|
||||
public int VsyncDen => 1;
|
||||
|
||||
#region ISoundProvider
|
||||
|
||||
|
|
|
@ -23,5 +23,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
|||
public int BufferHeight { get; }
|
||||
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
|
||||
public int VsyncNum => 16000000; // 16.00 mhz refclock
|
||||
|
||||
public int VsyncDen => 16 * 105 * 159;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
|||
Core = LibLynx.Create(realfile, realfile.Length, bios, bios.Length, pagesize0, pagesize1, false);
|
||||
try
|
||||
{
|
||||
CoreComm.VsyncNum = 16000000; // 16.00 mhz refclock
|
||||
CoreComm.VsyncDen = 16 * 105 * 159;
|
||||
|
||||
_savebuff = new byte[LibLynx.BinStateSize(Core)];
|
||||
_savebuff2 = new byte[_savebuff.Length + 13];
|
||||
|
||||
|
|
|
@ -465,6 +465,24 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
public int BufferHeight => 192;
|
||||
public int BackgroundColor => 0;
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int[] PaletteTMS9918 =
|
||||
{
|
||||
unchecked((int)0xFF000000),
|
||||
|
|
|
@ -82,6 +82,24 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public int BufferHeight => 208;
|
||||
public int BackgroundColor => 0;
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Sr1 = true;
|
||||
|
|
|
@ -17,6 +17,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
|
||||
|
||||
public int VsyncNum => 262144;
|
||||
|
||||
public int VsyncDen => 4389;
|
||||
|
||||
private readonly int[] _videobuff = new int[240 * 160];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
|
||||
ServiceProvider = ser;
|
||||
CoreComm = comm;
|
||||
|
||||
CoreComm.VsyncNum = 262144;
|
||||
CoreComm.VsyncDen = 4389;
|
||||
CoreComm.NominalWidth = 240;
|
||||
CoreComm.NominalHeight = 160;
|
||||
PutSettings(_settings);
|
||||
|
|
|
@ -19,6 +19,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
return _videobuff;
|
||||
}
|
||||
|
||||
public int VsyncNum => 262144;
|
||||
|
||||
public int VsyncDen => 4389;
|
||||
|
||||
private readonly int[] _videobuff = new int[240 * 160];
|
||||
private readonly int[] _videopalette = new int[65536];
|
||||
|
||||
|
|
|
@ -71,8 +71,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
};
|
||||
ser.Register<ITraceable>(Tracer);
|
||||
|
||||
CoreComm.VsyncNum = 262144;
|
||||
CoreComm.VsyncDen = 4389;
|
||||
CoreComm.NominalWidth = 240;
|
||||
CoreComm.NominalHeight = 160;
|
||||
|
||||
|
|
|
@ -21,5 +21,9 @@
|
|||
public int BufferHeight => 144;
|
||||
|
||||
public int BackgroundColor => 0;
|
||||
|
||||
public int VsyncNum => 262144;
|
||||
|
||||
public int VsyncDen => 4389;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,8 +104,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
InitMemoryCallbacks();
|
||||
CoreComm = comm;
|
||||
|
||||
comm.VsyncNum = 262144;
|
||||
comm.VsyncDen = 4389;
|
||||
comm.RomStatusAnnotation = null;
|
||||
comm.RomStatusDetails = null;
|
||||
comm.NominalWidth = 160;
|
||||
|
|
|
@ -10,6 +10,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
public int BufferWidth { get { return 320; } }
|
||||
public int BufferHeight { get { return 144; } }
|
||||
|
||||
public int VsyncNum => L.VsyncNum;
|
||||
|
||||
public int VsyncDen => L.VsyncDen;
|
||||
|
||||
public int BackgroundColor
|
||||
{
|
||||
get { return unchecked((int)0xff000000); }
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
L.ConnectMemoryCallbackSystem(_memorycallbacks);
|
||||
R.ConnectMemoryCallbackSystem(_memorycallbacks);
|
||||
|
||||
comm.VsyncNum = L.CoreComm.VsyncNum;
|
||||
comm.VsyncDen = L.CoreComm.VsyncDen;
|
||||
comm.RomStatusAnnotation = null;
|
||||
comm.RomStatusDetails = "LEFT:\r\n" + L.CoreComm.RomStatusDetails + "RIGHT:\r\n" + R.CoreComm.RomStatusDetails;
|
||||
comm.NominalWidth = L.CoreComm.NominalWidth + R.CoreComm.NominalWidth;
|
||||
|
|
|
@ -103,17 +103,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
_display_type = DisplayType.NTSC;
|
||||
break;
|
||||
}
|
||||
switch (Region)
|
||||
{
|
||||
case DisplayType.NTSC:
|
||||
comm.VsyncNum = 60000;
|
||||
comm.VsyncDen = 1001;
|
||||
break;
|
||||
default:
|
||||
comm.VsyncNum = 50;
|
||||
comm.VsyncDen = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
StartThreadLoop();
|
||||
|
||||
|
@ -134,6 +123,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(_videoProvider);
|
||||
(ServiceProvider as BasicServiceProvider).Register<ISoundProvider>(_audioProvider.Resampler);
|
||||
|
||||
switch (Region)
|
||||
{
|
||||
case DisplayType.NTSC:
|
||||
_videoProvider.VsyncNum = 60000;
|
||||
_videoProvider.VsyncDen = 1001;
|
||||
break;
|
||||
default:
|
||||
_videoProvider.VsyncNum = 50;
|
||||
_videoProvider.VsyncDen = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
string rsp;
|
||||
switch (_syncSettings.Rsp)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
public int BufferWidth { get; private set; }
|
||||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return 0; } }
|
||||
public int VsyncNum { get; internal set; }
|
||||
public int VsyncDen { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fetches current frame buffer from mupen64
|
||||
|
|
|
@ -211,8 +211,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
case Common.DisplayType.PAL:
|
||||
apu = new APU(this, apu, true);
|
||||
ppu.region = PPU.Region.PAL;
|
||||
CoreComm.VsyncNum = 50;
|
||||
CoreComm.VsyncDen = 1;
|
||||
VsyncNum = 50;
|
||||
VsyncDen = 1;
|
||||
cpuclockrate = 1662607;
|
||||
cpu_sequence = cpu_sequence_PAL;
|
||||
_display_type = DisplayType.PAL;
|
||||
|
@ -220,8 +220,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
case Common.DisplayType.NTSC:
|
||||
apu = new APU(this, apu, false);
|
||||
ppu.region = PPU.Region.NTSC;
|
||||
CoreComm.VsyncNum = 39375000;
|
||||
CoreComm.VsyncDen = 655171;
|
||||
VsyncNum = 39375000;
|
||||
VsyncDen = 655171;
|
||||
cpuclockrate = 1789773;
|
||||
cpu_sequence = cpu_sequence_NTSC;
|
||||
break;
|
||||
|
@ -229,8 +229,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
case Common.DisplayType.Dendy:
|
||||
apu = new APU(this, apu, false);
|
||||
ppu.region = PPU.Region.Dendy;
|
||||
CoreComm.VsyncNum = 50;
|
||||
CoreComm.VsyncDen = 1;
|
||||
VsyncNum = 50;
|
||||
VsyncDen = 1;
|
||||
cpuclockrate = 1773448;
|
||||
cpu_sequence = cpu_sequence_NTSC;
|
||||
_display_type = DisplayType.Dendy;
|
||||
|
@ -246,7 +246,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
// apu has some specific power up bahaviour that we will emulate here
|
||||
apu.NESHardReset();
|
||||
|
||||
|
||||
if (SyncSettings.InitialWRamStatePattern != null && SyncSettings.InitialWRamStatePattern.Any())
|
||||
{
|
||||
for (int i = 0; i < 0x800; i++)
|
||||
|
@ -291,6 +290,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
}
|
||||
|
||||
private int VsyncNum { get; set; }
|
||||
private int VsyncDen { get; set; }
|
||||
|
||||
private IController _controller;
|
||||
|
||||
bool resetSignal;
|
||||
|
|
|
@ -337,6 +337,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
}
|
||||
}
|
||||
|
||||
public int VsyncNum => emu.VsyncNum;
|
||||
public int VsyncDen => emu.VsyncDen;
|
||||
}
|
||||
|
||||
MyVideoProvider videoProvider;
|
||||
|
|
|
@ -8,6 +8,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum => 39375000;
|
||||
public int VsyncDen => 655171;
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
return VideoOutput;
|
||||
|
|
|
@ -56,8 +56,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
string mappername = Marshal.PtrToStringAnsi(QN.qn_get_mapper(Context, ref mapper));
|
||||
Console.WriteLine("QuickNES: Booted with Mapper #{0} \"{1}\"", mapper, mappername);
|
||||
BoardName = mappername;
|
||||
CoreComm.VsyncNum = 39375000;
|
||||
CoreComm.VsyncDen = 655171;
|
||||
PutSettings((QuickNESSettings)Settings ?? new QuickNESSettings());
|
||||
|
||||
_syncSettings = (QuickNESSyncSettings)SyncSettings ?? new QuickNESSyncSettings();
|
||||
|
|
|
@ -19,6 +19,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
return _videoBuffer;
|
||||
}
|
||||
|
||||
public int VsyncNum { get; }
|
||||
public int VsyncDen { get; }
|
||||
|
||||
private int[] _videoBuffer = new int[256 * 224];
|
||||
private int _videoWidth = 256;
|
||||
private int _videoHeight = 224;
|
||||
|
|
|
@ -156,14 +156,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
if (Api.Region == LibsnesApi.SNES_REGION.NTSC)
|
||||
{
|
||||
// similar to what aviout reports from snes9x and seems logical from bsnes first principles. bsnes uses that numerator (ntsc master clockrate) for sure.
|
||||
CoreComm.VsyncNum = 21477272;
|
||||
CoreComm.VsyncDen = 4 * 341 * 262;
|
||||
VsyncNum = 21477272;
|
||||
VsyncDen = 4 * 341 * 262;
|
||||
}
|
||||
else
|
||||
{
|
||||
// http://forums.nesdev.com/viewtopic.php?t=5367&start=19
|
||||
CoreComm.VsyncNum = 21281370;
|
||||
CoreComm.VsyncDen = 4 * 341 * 312;
|
||||
VsyncNum = 21281370;
|
||||
VsyncDen = 4 * 341 * 312;
|
||||
}
|
||||
|
||||
Api.CMD_power();
|
||||
|
|
|
@ -66,6 +66,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
public int BufferHeight { get { return 224; } }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISoundProvider
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
|
@ -439,5 +440,23 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public int BufferWidth => FramePitch;
|
||||
public int BufferHeight => FrameHeight;
|
||||
public int BackgroundColor => vce.Palette[256];
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -528,5 +528,23 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public int BufferWidth => FrameWidth;
|
||||
public int BufferHeight => FrameHeight;
|
||||
public int BackgroundColor => VCE.Palette[0];
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
Region = DisplayType.NTSC; // all game gears run at 60hz/NTSC mode
|
||||
}
|
||||
|
||||
CoreComm.VsyncNum = Region == DisplayType.NTSC ? 60 : 50;
|
||||
CoreComm.VsyncDen = 1;
|
||||
|
||||
RegionStr = SyncSettings.ConsoleRegion;
|
||||
if (RegionStr == "Auto")
|
||||
{
|
||||
|
|
|
@ -496,5 +496,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
{
|
||||
get { return Palette[BackdropColor]; }
|
||||
}
|
||||
|
||||
public int VsyncNum => DisplayType == DisplayType.NTSC ? 60 : 50;
|
||||
|
||||
public int VsyncDen => 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,6 +346,24 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISyncSoundProvider
|
||||
|
|
|
@ -17,6 +17,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum { get; }
|
||||
|
||||
public int VsyncDen { get; }
|
||||
|
||||
private int[] vidbuff = new int[0];
|
||||
private int vwidth;
|
||||
private int vheight;
|
||||
|
|
|
@ -126,9 +126,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
int fpsnum = 60;
|
||||
int fpsden = 1;
|
||||
LibGPGX.gpgx_get_fps(ref fpsnum, ref fpsden);
|
||||
CoreComm.VsyncNum = fpsnum;
|
||||
CoreComm.VsyncDen = fpsden;
|
||||
Region = CoreComm.VsyncRate > 55 ? DisplayType.NTSC : DisplayType.PAL;
|
||||
VsyncNum = fpsnum;
|
||||
VsyncDen = fpsden;
|
||||
Region = VsyncNum / VsyncDen > 55 ? DisplayType.NTSC : DisplayType.PAL;
|
||||
}
|
||||
|
||||
// compute state size
|
||||
|
|
|
@ -17,6 +17,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
|
|||
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum { get; }
|
||||
|
||||
public int VsyncDen { get; }
|
||||
|
||||
private int[] vidbuff = new int[0];
|
||||
private int vwidth;
|
||||
private int vheight;
|
||||
|
|
|
@ -134,9 +134,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
|
|||
int fpsnum = 60;
|
||||
int fpsden = 1;
|
||||
Core.gpgx_get_fps(ref fpsnum, ref fpsden);
|
||||
CoreComm.VsyncNum = fpsnum;
|
||||
CoreComm.VsyncDen = fpsden;
|
||||
Region = CoreComm.VsyncRate > 55 ? DisplayType.NTSC : DisplayType.PAL;
|
||||
VsyncNum = fpsnum;
|
||||
VsyncDen = fpsden;
|
||||
Region = VsyncNum / VsyncDen > 55 ? DisplayType.NTSC : DisplayType.PAL;
|
||||
}
|
||||
|
||||
// compute state size
|
||||
|
|
|
@ -83,8 +83,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
|
|||
if (!good)
|
||||
throw new Exception("PPSSPP Init failed!");
|
||||
|
||||
CoreComm.VsyncDen = 1;
|
||||
CoreComm.VsyncNum = 60;
|
||||
CoreComm.RomStatusDetails = "It puts the scythe in the chicken or it gets the abyss again!";
|
||||
|
||||
attachedcore = this;
|
||||
|
@ -173,6 +171,24 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
|
|||
public int BufferHeight { get { return screenheight; } }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncNum;
|
||||
}
|
||||
}
|
||||
|
||||
public int VsyncDen
|
||||
{
|
||||
[FeatureNotImplemented]
|
||||
get
|
||||
{
|
||||
return NullVideo.DefaultVsyncDen;
|
||||
}
|
||||
}
|
||||
|
||||
readonly short[] audiobuffer = new short[2048 * 2];
|
||||
int nsampavail = 0;
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
|
|
|
@ -331,14 +331,14 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
int VidClock_d = CpuClock_d * 7;
|
||||
if (SystemRegion == OctoshockDll.eRegion.EU)
|
||||
{
|
||||
CoreComm.VsyncNum = VidClock_n;
|
||||
CoreComm.VsyncDen = VidClock_d * 314 * 3406;
|
||||
VsyncNum = VidClock_n;
|
||||
VsyncDen = VidClock_d * 314 * 3406;
|
||||
SystemVidStandard = OctoshockDll.eVidStandard.PAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreComm.VsyncNum = VidClock_n;
|
||||
CoreComm.VsyncDen = VidClock_d * 263 * 3413;
|
||||
VsyncNum = VidClock_n;
|
||||
VsyncDen = VidClock_d * 263 * 3413;
|
||||
SystemVidStandard = OctoshockDll.eVidStandard.NTSC;
|
||||
}
|
||||
|
||||
|
@ -868,6 +868,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
public int BufferWidth { get; private set; }
|
||||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return 0; } }
|
||||
public int VsyncNum { get; private set; }
|
||||
public int VsyncDen { get; private set; }
|
||||
|
||||
public System.Drawing.Size VideoProvider_Padding { get; private set; }
|
||||
|
||||
#region Debugging
|
||||
|
|
|
@ -38,9 +38,6 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
if (!BizSwan.bizswan_load(Core, file, file.Length, ref ss, ref rotate))
|
||||
throw new InvalidOperationException("bizswan_load() returned FALSE!");
|
||||
|
||||
CoreComm.VsyncNum = 3072000; // master CPU clock, also pixel clock
|
||||
CoreComm.VsyncDen = (144 + 15) * (224 + 32); // 144 vislines, 15 vblank lines; 224 vispixels, 32 hblank pixels
|
||||
|
||||
InitISaveRam();
|
||||
|
||||
InitVideo(rotate);
|
||||
|
@ -216,6 +213,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
public int VsyncNum => 3072000; // master CPU clock, also pixel clock
|
||||
public int VsyncDen => (144 + 15) * (224 + 32); // 144 vislines, 15 vblank lines; 224 vispixels, 32 hblank pixels
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,8 +128,8 @@ namespace BizHawk.Emulation.Cores.Libretro
|
|||
savebuff2 = new byte[savebuff.Length + 13];
|
||||
|
||||
// TODO: more precise
|
||||
CoreComm.VsyncNum = (int)(10000000 * api.comm->env.retro_system_av_info.timing.fps);
|
||||
CoreComm.VsyncDen = 10000000;
|
||||
VsyncNum = (int)(10000000 * api.comm->env.retro_system_av_info.timing.fps);
|
||||
VsyncDen = 10000000;
|
||||
|
||||
SetupResampler(api.comm->env.retro_system_av_info.timing.fps, api.comm->env.retro_system_av_info.timing.sample_rate);
|
||||
(ServiceProvider as BasicServiceProvider).Register<ISoundProvider>(resampler);
|
||||
|
@ -217,6 +217,9 @@ namespace BizHawk.Emulation.Cores.Libretro
|
|||
int IVideoProvider.BufferWidth { get { return vidWidth; } }
|
||||
int IVideoProvider.BufferHeight { get { return vidHeight; } }
|
||||
|
||||
public int VsyncNum { get; private set; }
|
||||
public int VsyncDen { get; private set; }
|
||||
|
||||
#region ISoundProvider
|
||||
|
||||
SpeexResampler resampler;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<Value>savestate</Value>
|
||||
<Value>savestates</Value>
|
||||
<Value>Speex</Value>
|
||||
<Value>vsync</Value>
|
||||
</CollectionProperty>
|
||||
</GlobalSettings>
|
||||
<Analyzers>
|
||||
|
|
Loading…
Reference in New Issue