Cores: All cores must update Frame counter post-emulation. NOTE: This is a sync breaking change for MGBA movies using RTC, as the time sent to the core was the pre-incremented time.

This commit is contained in:
alyosha-tas 2021-05-20 09:24:49 -04:00
parent 7c661b5520
commit 4165b2893d
28 changed files with 60 additions and 45 deletions

View File

@ -38,6 +38,7 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// Gets the current frame count
/// Frame must be incremented after emulation in the core
/// </summary>
int Frame { get; }

View File

@ -30,8 +30,6 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
if (_controller.IsPressed("P2 B2")) ctrl2_byte -= 0x20;
if (current_controller == MSXControllerKB) { kb_rows_check(controller); }
_frame++;
if (Tracer.Enabled)
{
@ -45,7 +43,9 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
LibMSX.MSX_settracecallback(MSX_Pntr, tracecb);
LibMSX.MSX_frame_advance(MSX_Pntr, ctrl1_byte, ctrl2_byte, kb_rows, true, true);
_frame++;
return true;
}

View File

@ -13,7 +13,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
_controller = controller;
_frame++;
_islag = true;
// Handle all the console controls here
@ -76,6 +75,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_tia.LineCount = 0;
_frame++;
return true;
}

View File

@ -68,8 +68,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("Power"))
{
// it seems that theMachine.Reset() doesn't clear ram, etc
@ -89,6 +87,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
_lagCount++;
}
_frame++;
return true;
}

View File

@ -121,7 +121,6 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public bool FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
if (controller.IsPressed("Power"))
{
LibLynx.Reset(Core);
@ -135,6 +134,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
LagCount++;
}
Frame++;
return true;
}

View File

@ -25,8 +25,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
SoftReset();
}
_frame++;
_isLag = true;
if (_tracer.Enabled)
{
@ -164,6 +162,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
_lagCount++;
}
_frame++;
return true;
}

View File

@ -21,8 +21,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("Power"))
{
HardReset();
@ -74,6 +72,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
_lagcount++;
}
_frame++;
return true;
}

View File

@ -19,7 +19,6 @@ namespace BizHawk.Emulation.Cores.Intellivision
_cpu.TraceCallback = null;
}
_frame++;
_sticRow = -1;
// read the controller state here for now
@ -125,6 +124,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
SoftReset();
}
_frame++;
return true;
}

View File

@ -27,8 +27,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("Power"))
{
HardReset();
@ -48,6 +46,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
_lagcount++;
}
_frame++;
return true;
}

View File

@ -116,7 +116,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public bool FrameAdvance(IController controller, bool render, bool renderSound = true)
{
Frame++;
if (controller.IsPressed("Power"))
{
LibmGBA.BizReset(Core);
@ -147,6 +146,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
// this should be called in hblank on the appropriate line, but until we implement that, just do it here
_scanlinecb?.Invoke();
Frame++;
return true;
}

View File

@ -54,8 +54,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("P1 Power"))
{
HardReset();
@ -90,6 +88,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
_lagcount++;
}
_frame++;
return true;
}

View File

@ -53,8 +53,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
L.cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("P1 Power"))
{
L.HardReset();
@ -91,6 +89,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
_lagcount++;
}
_frame++;
return true;
}

View File

@ -68,8 +68,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
L.cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("P1 Power"))
{
L.HardReset();
@ -130,6 +128,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
_lagcount++;
}
_frame++;
return true;
}

View File

@ -83,8 +83,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
A.cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("P1 Power"))
{
A.HardReset();
@ -166,6 +164,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
_lagcount++;
}
_frame++;
return true;
}

View File

@ -276,8 +276,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
internal void FrameAdvancePrep(IController controller)
{
Frame++;
// update our local copy of the controller data
CurrentButtons = 0;
@ -327,6 +325,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
LagCount++;
}
Frame++;
endofframecallback?.Invoke(LibGambatte.gambatte_cpuread(GambatteState, 0xff40));
}

View File

@ -38,7 +38,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_cablediscosignal = cablediscosignalNew;
Frame++;
L.FrameAdvancePrep(LCont);
R.FrameAdvancePrep(RCont);
@ -148,6 +147,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
LagCount++;
}
Frame++;
return true;
}

View File

@ -304,8 +304,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
HardReset();
}
Frame++;
//if (resetSignal)
//Controller.UnpressButton("Reset"); TODO fix this
resetSignal = controller.IsPressed("Reset");
@ -381,6 +379,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// any cheats still active will be re-applied by the buspoke at the start of the next frame
num_cheats = 0;
Frame++;
return true;
}

View File

@ -363,7 +363,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//quite strange that is makes the sprite hit flag go high like this
if (nes._isVS2c05==2)
{
if (nes.Frame<4)
if (nes.Frame<3)
{
return (byte)((Reg2002_vblank_active << 7) | (Reg2002_objhit << 6) | (1 << 5) | (0x1D));

View File

@ -196,7 +196,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
QN.qn_set_tracecb(Context, Tracer.Enabled ? _traceCb : null);
Frame++;
LibQuickNES.ThrowStringError(QN.qn_emulate_frame(Context, j1, j2));
IsLagFrame = QN.qn_get_joypad_read_count(Context) == 0;
if (IsLagFrame)
@ -210,6 +209,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
_callBack1?.Invoke();
_callBack2?.Invoke();
Frame++;
return true;
}
}

View File

@ -70,8 +70,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
RefreshMemoryCallbacks(false);
// apparently this is one frame?
_timeFrameCounter++;
Api.CMD_run();
_timeFrameCounter++;
// once upon a time we forwarded messages from bsnes here, by checking for queued text messages, but I don't think it's needed any longer
if (IsLagFrame)

View File

@ -36,8 +36,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
_GBCore.cpu.TraceCallback = null;
}
_frame++;
reset_frame = false;
if (controller.IsPressed("P1 Power"))
{
@ -81,6 +79,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
}
reset_frame = false;
_frame++;
return ret;
}

View File

@ -21,8 +21,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
_nesCore.cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("Power"))
{
HardReset();
@ -62,6 +60,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
}
reset_frame = false;
_frame++;
return ret;
}

View File

@ -13,7 +13,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
_controller = controller;
_lagged = true;
DriveLightOn = false;
Frame++;
CheckSpriteLimit();
PSG.BeginFrame(Cpu.TotalExecutedCycles);
@ -40,6 +39,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
_isLag = false;
}
Frame++;
return true;
}

View File

@ -24,8 +24,6 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
L.Cpu.TraceCallback = null;
}
_frame++;
if (controller.IsPressed("Power"))
{
HardReset();
@ -53,6 +51,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
_lagCount++;
}
_frame++;
return true;
}

View File

@ -46,7 +46,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
{
_controller = controller;
_lagged = true;
_frame++;
if (!IsGameGear)
{
@ -129,6 +128,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
_isLag = false;
}
_frame++;
return true;
}
@ -136,7 +137,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public void FrameAdvancePrep()
{
_lagged = true;
_frame++;
if (!IsGameGear && IsGameGear_C)
{
@ -156,6 +156,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
{
_isLag = false;
}
_frame++;
}
public int Frame => _frame;

View File

@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
throw new Exception($"{nameof(Core.gpgx_put_control)}() failed!");
IsLagFrame = true;
Frame++;
_driveLight = false;
Core.gpgx_advance();
@ -68,7 +68,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
LagCount++;
if (_cds != null)
DriveLightOn = _driveLight;
DriveLightOn = _driveLight;
Frame++;
return true;
}

View File

@ -808,8 +808,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//TODO - actually, make this feedback from the core. there should be a register or status which effectively corresponds to whether it's reading.
DriveLightOn = false;
Frame++;
SetInput();
OctoshockDll.shock_SetLEC(psx, _SyncSettings.EnableLEC);
@ -899,6 +897,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
OctoshockDll.shock_GetSamples(psx, samples);
}
Frame++;
return true;
}

View File

@ -62,7 +62,6 @@ namespace BizHawk.Emulation.Cores.WonderSwan
public bool FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
IsLagFrame = true;
if (controller.IsPressed("Power"))
@ -79,6 +78,8 @@ namespace BizHawk.Emulation.Cores.WonderSwan
if (IsLagFrame)
LagCount++;
Frame++;
return true;
}