From d95cd4becb82c9defc3212bc4b77471db1693362 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Sun, 2 Apr 2023 16:53:00 +0300 Subject: [PATCH] mame: use biggest int multiple of 60 as a framerate numerator denominator is determined by taking refresh attoseconts `as_ticks(numerator)` which reduces the initial 64bit value to what can be used for video mame needs flat 60fps for screenless machines, so we use a numerator that is a multiple, while also being a tiny bit more accurate than with 1,000,000,000 --- .../Arcades/MAME/MAME.IVideoProvider.cs | 4 ++-- src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IVideoProvider.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IVideoProvider.cs index b918039771..5e51f39b75 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IVideoProvider.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IVideoProvider.cs @@ -27,9 +27,9 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME private void UpdateFramerate() { - VsyncNumerator = 1000000000; VsyncAttoseconds = _core.mame_lua_get_long(MAMELuaCommand.GetRefresh); - VsyncDenominator = (int)(VsyncAttoseconds / 1000000000); + VsyncNumerator = 0x7ffffff8; + VsyncDenominator = _core.mame_lua_get_int(MAMELuaCommand.GetFramerateDenominator(VsyncNumerator)); } private void UpdateAspect() diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index 2749588a81..7f7a687a9b 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -331,6 +331,10 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME "table.sort(final) " + "return table.concat(final)"; + public static string GetFramerateDenominator(int frequency) => + "for k,v in pairs(manager.machine.screens) do " + + $"return emu.attotime(0, v.refresh_attoseconds):as_ticks({ frequency }) " + + "end"; public static string MakeLookupKey(string gameName, string luaCode) => $"[{ gameName }] { luaCode }"; public static string InputField(string tag, string fieldName) =>