Skip to content

Commit d95cd4b

Browse files
committed
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
1 parent df71de6 commit d95cd4b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.IVideoProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public partial class MAME : IVideoProvider
2727

2828
private void UpdateFramerate()
2929
{
30-
VsyncNumerator = 1000000000;
3130
VsyncAttoseconds = _core.mame_lua_get_long(MAMELuaCommand.GetRefresh);
32-
VsyncDenominator = (int)(VsyncAttoseconds / 1000000000);
31+
VsyncNumerator = 0x7ffffff8;
32+
VsyncDenominator = _core.mame_lua_get_int(MAMELuaCommand.GetFramerateDenominator(VsyncNumerator));
3333
}
3434

3535
private void UpdateAspect()

src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ private static class MAMELuaCommand
331331
"table.sort(final) " +
332332
"return table.concat(final)";
333333

334+
public static string GetFramerateDenominator(int frequency) =>
335+
"for k,v in pairs(manager.machine.screens) do " +
336+
$"return emu.attotime(0, v.refresh_attoseconds):as_ticks({ frequency }) " +
337+
"end";
334338
public static string MakeLookupKey(string gameName, string luaCode) =>
335339
$"[{ gameName }] { luaCode }";
336340
public static string InputField(string tag, string fieldName) =>

0 commit comments

Comments
 (0)