Skip to content

Commit 11e83ee

Browse files
Storing refresh rate in savestate -- update it on load if different
1 parent 66b61e2 commit 11e83ee

File tree

1 file changed

+13
-1
lines changed
  • src/BizHawk.Emulation.Cores/Computers/DOS

1 file changed

+13
-1
lines changed

src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController contro
380380
DOSBox.MouseState mouseState = new()
381381
{
382382
PosX = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.PosX}"),
383-
PosY = controller.AxisValue($"{Inputs.Mouse} { MouseInputs.PosY}"),
383+
PosY = controller.AxisValue($"{Inputs.Mouse} {MouseInputs.PosY}"),
384384
LeftButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.LeftButton}"),
385385
MiddleButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.MiddleButton}"),
386386
RightButtonHeld = controller.IsPressed($"{Inputs.Mouse} {MouseInputs.RightButton}"),
@@ -499,6 +499,10 @@ protected override void SaveStateBinaryInternal(BinaryWriter writer)
499499
writer.Write(_lastMouseState.LeftButtonHeld);
500500
writer.Write(_lastMouseState.MiddleButtonHeld);
501501
writer.Write(_lastMouseState.RightButtonHeld);
502+
503+
// Storing current refresh rate
504+
writer.Write(VsyncNumerator);
505+
writer.Write(VsyncDenominator);
502506
}
503507

504508
protected override void LoadStateBinaryInternal(BinaryReader reader)
@@ -513,6 +517,14 @@ protected override void LoadStateBinaryInternal(BinaryReader reader)
513517
_lastMouseState.LeftButtonHeld = reader.ReadBoolean();
514518
_lastMouseState.MiddleButtonHeld = reader.ReadBoolean();
515519
_lastMouseState.RightButtonHeld = reader.ReadBoolean();
520+
521+
// Restoring refresh rate
522+
var newVsyncNumerator = reader.ReadInt32();
523+
var newVsyncDenominator = reader.ReadInt32();
524+
525+
// Updating it now, if different
526+
if (newVsyncNumerator != VsyncNumerator || newVsyncDenominator != VsyncDenominator)
527+
updateFramerate(newVsyncNumerator, newVsyncDenominator);
516528
}
517529

518530
private static class FileNames

0 commit comments

Comments
 (0)