Remove FPU precision (probably not needed according to natt)

This commit is contained in:
YoshiRulz 2019-10-25 21:21:56 +10:00
parent 4974807b21
commit 60cf4e6c02
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 51 additions and 88 deletions

View File

@ -30,47 +30,44 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
[CoreConstructor("NES")] [CoreConstructor("NES")]
public QuickNES(CoreComm comm, byte[] file, object settings, object syncSettings) public QuickNES(CoreComm comm, byte[] file, object settings, object syncSettings)
{ {
using (FP.Save()) ServiceProvider = new BasicServiceProvider(this);
CoreComm = comm;
Context = QN.qn_new();
if (Context == IntPtr.Zero)
{ {
ServiceProvider = new BasicServiceProvider(this); throw new InvalidOperationException($"{nameof(QN.qn_new)}() returned NULL");
CoreComm = comm; }
Context = QN.qn_new();
if (Context == IntPtr.Zero)
{
throw new InvalidOperationException($"{nameof(QN.qn_new)}() returned NULL");
}
try try
{ {
file = FixInesHeader(file); file = FixInesHeader(file);
LibQuickNES.ThrowStringError(QN.qn_loadines(Context, file, file.Length)); LibQuickNES.ThrowStringError(QN.qn_loadines(Context, file, file.Length));
InitSaveRamBuff(); InitSaveRamBuff();
InitSaveStateBuff(); InitSaveStateBuff();
InitAudio(); InitAudio();
InitMemoryDomains(); InitMemoryDomains();
int mapper = 0; int mapper = 0;
string mappername = Marshal.PtrToStringAnsi(QN.qn_get_mapper(Context, ref mapper)); string mappername = Marshal.PtrToStringAnsi(QN.qn_get_mapper(Context, ref mapper));
Console.WriteLine("QuickNES: Booted with Mapper #{0} \"{1}\"", mapper, mappername); Console.WriteLine("QuickNES: Booted with Mapper #{0} \"{1}\"", mapper, mappername);
BoardName = mappername; BoardName = mappername;
PutSettings((QuickNESSettings)settings ?? new QuickNESSettings()); PutSettings((QuickNESSettings)settings ?? new QuickNESSettings());
_syncSettings = (QuickNESSyncSettings)syncSettings ?? new QuickNESSyncSettings(); _syncSettings = (QuickNESSyncSettings)syncSettings ?? new QuickNESSyncSettings();
_syncSettingsNext = _syncSettings.Clone(); _syncSettingsNext = _syncSettings.Clone();
SetControllerDefinition(); SetControllerDefinition();
ComputeBootGod(); ComputeBootGod();
ConnectTracer(); ConnectTracer();
} }
catch catch
{ {
Dispose(); Dispose();
throw; throw;
}
} }
} }
@ -79,37 +76,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public IEmulatorServiceProvider ServiceProvider { get; private set; } public IEmulatorServiceProvider ServiceProvider { get; private set; }
#region FPU precision
private class FPCtrl : IDisposable
{
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern uint _control87(uint @new, uint mask);
public static void PrintCurrentFP()
{
uint curr = _control87(0, 0);
Console.WriteLine("Current FP word: 0x{0:x8}", curr);
}
uint cw;
public IDisposable Save()
{
cw = _control87(0, 0);
_control87(0x00000, 0x30000);
return this;
}
public void Dispose()
{
_control87(cw, 0x30000);
}
}
FPCtrl FP = new FPCtrl();
#endregion
#region Controller #region Controller
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
@ -183,35 +149,32 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public bool FrameAdvance(IController controller, bool render, bool rendersound = true) public bool FrameAdvance(IController controller, bool render, bool rendersound = true)
{ {
CheckDisposed(); CheckDisposed();
using (FP.Save()) if (controller.IsPressed("Power"))
{ QN.qn_reset(Context, true);
if (controller.IsPressed("Power")) if (controller.IsPressed("Reset"))
QN.qn_reset(Context, true); QN.qn_reset(Context, false);
if (controller.IsPressed("Reset"))
QN.qn_reset(Context, false);
int j1, j2; int j1, j2;
SetPads(controller, out j1, out j2); SetPads(controller, out j1, out j2);
if (Tracer.Enabled) if (Tracer.Enabled)
QN.qn_set_tracecb(Context, _tracecb); QN.qn_set_tracecb(Context, _tracecb);
else else
QN.qn_set_tracecb(Context, null); QN.qn_set_tracecb(Context, null);
Frame++; Frame++;
LibQuickNES.ThrowStringError(QN.qn_emulate_frame(Context, j1, j2)); LibQuickNES.ThrowStringError(QN.qn_emulate_frame(Context, j1, j2));
IsLagFrame = QN.qn_get_joypad_read_count(Context) == 0; IsLagFrame = QN.qn_get_joypad_read_count(Context) == 0;
if (IsLagFrame) if (IsLagFrame)
LagCount++; LagCount++;
if (render) if (render)
Blit(); Blit();
if (rendersound) if (rendersound)
DrainAudio(); DrainAudio();
if (CB1 != null) CB1(); if (CB1 != null) CB1();
if (CB2 != null) CB2(); if (CB2 != null) CB2();
}
return true; return true;
} }