mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-26 13:33:27 -04:00
@@ -1421,6 +1421,7 @@ function love.run()
|
||||
if love.timer then love.timer.step() end
|
||||
|
||||
local FrameCap = require("src.core.FrameCap")
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = true
|
||||
FrameCap.bootPanelSync()
|
||||
local RefreshRate = require("src.core.RefreshRate")
|
||||
local FixedStep = require("src.core.FixedStep")
|
||||
|
||||
@@ -23,7 +23,12 @@ end
|
||||
-- numeric FrameCap default. Android/iOS/UWP need uncapped probe isolation
|
||||
-- so composed GLES swapchains can lock; PortMaster handhelds likewise
|
||||
-- follow KMSDRM through PresentSync.
|
||||
function FrameCap.loopSupportsPanelSync()
|
||||
return rawget(_G, "POKEPORT_LOOP_PANEL_SYNC") == true
|
||||
end
|
||||
|
||||
function FrameCap.prefersPanelSync()
|
||||
if not FrameCap.loopSupportsPanelSync() then return false end
|
||||
if isHandheldEnv() then return true end
|
||||
if love and love.system and love.system.getOS then
|
||||
local osName = love.system.getOS()
|
||||
@@ -56,7 +61,10 @@ FrameCap.current = FrameCap.DEFAULT
|
||||
function FrameCap.normalize(value)
|
||||
value = tonumber(value)
|
||||
if not value then return FrameCap.DEFAULT end
|
||||
if value <= 0 then return FrameCap.DISPLAY end
|
||||
if value <= 0 then
|
||||
if FrameCap.loopSupportsPanelSync() then return FrameCap.DISPLAY end
|
||||
return FrameCap.DEFAULT
|
||||
end
|
||||
local best, bestDiff = FrameCap.DEFAULT, math.huge
|
||||
for _, step in ipairs(FrameCap.STEPS) do
|
||||
local diff = math.abs(step - value)
|
||||
|
||||
@@ -7,7 +7,7 @@ local Version = {
|
||||
engine = "0.0.0-dev", -- game/engine release (semver). Repo default is the
|
||||
-- "-dev" placeholder; CI stamps the real X.Y.Z into
|
||||
-- the packed game.love only, never the working tree.
|
||||
shell = 1, -- native-shell contract this build implements
|
||||
shell = 2, -- native-shell contract this build implements
|
||||
payloadHost = "love", -- native host family for in-place Lua payloads.
|
||||
-- A payload must name the same family; this prevents
|
||||
-- mounting code packaged for a different native host.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = true
|
||||
local FrameCap = require("src.core.FrameCap")
|
||||
local RefreshRate = require("src.core.RefreshRate")
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = nil
|
||||
package.loaded["src.core.FrameCap"] = nil
|
||||
local FrameCap = require("src.core.FrameCap")
|
||||
|
||||
T.eq(FrameCap.loopSupportsPanelSync(), false,
|
||||
"no marker means a run loop that predates DISPLAY pacing")
|
||||
T.eq(FrameCap.normalize(0), FrameCap.DEFAULT,
|
||||
"a stored DISPLAY cap paces at the default instead of 1/0")
|
||||
T.eq(FrameCap.normalize(-5), FrameCap.DEFAULT, "and so does a negative cap")
|
||||
|
||||
love = love or {}
|
||||
love.system = love.system or {}
|
||||
local savedGetOS = love.system.getOS
|
||||
local savedGetenv = os.getenv
|
||||
os.getenv = function(name)
|
||||
if name == "POKEPORT_HANDHELD" then return "1" end
|
||||
return savedGetenv(name)
|
||||
end
|
||||
for _, osName in ipairs({ "Android", "iOS", "UWP" }) do
|
||||
love.system.getOS = function() return osName end
|
||||
T.eq(FrameCap.prefersPanelSync(), false,
|
||||
osName .. " does not prefer panel sync under a legacy loop")
|
||||
FrameCap.current = FrameCap.DEFAULT
|
||||
FrameCap.applyOptions({})
|
||||
T.check(FrameCap.current > 0, osName .. " boots with a positive cap")
|
||||
FrameCap.applyOptions({ fpsCap = 0 })
|
||||
T.check(FrameCap.current > 0, osName .. " keeps a positive cap for a stored 0")
|
||||
FrameCap.current = FrameCap.DEFAULT
|
||||
FrameCap.bootPanelSync()
|
||||
T.check(FrameCap.current > 0, "bootPanelSync stays positive on " .. osName)
|
||||
end
|
||||
os.getenv = savedGetenv
|
||||
love.system.getOS = savedGetOS
|
||||
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = true
|
||||
T.eq(FrameCap.normalize(0), FrameCap.DISPLAY,
|
||||
"the marker from a current love.run restores DISPLAY")
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = nil
|
||||
package.loaded["src.core.FrameCap"] = nil
|
||||
|
||||
T.finish("frame cap legacy loop #2106")
|
||||
@@ -10,6 +10,7 @@
|
||||
-- OPTION screen's equivalent rows), plus a vanilla no-mod case proving the
|
||||
-- fallback is unchanged.
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = true
|
||||
|
||||
local T = require("tests.harness")
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.modkit")
|
||||
_G.POKEPORT_LOOP_PANEL_SYNC = true
|
||||
local FrameCap = require("src.core.FrameCap")
|
||||
local RefreshRate = require("src.core.RefreshRate")
|
||||
local VSync = require("src.core.VSync")
|
||||
|
||||
Reference in New Issue
Block a user