52 lines
2.4 KiB
Text
52 lines
2.4 KiB
Text
-- The original ActionMax emulator, driven by the shared inputs, tracing what a port must match:
|
|
-- its state, its counts, and the disc frame at every input and every change of state. Run
|
|
-- with -v <library>/ActionMax/frame_38AmbushAlley.txt; PORT_GAME names another of the five.
|
|
local library = os.getenv("SINGE_LIBRARY") or (os.getenv("HOME") .. "/claude/singetest/ported")
|
|
local game = os.getenv("PORT_GAME") or "38AmbushAlley"
|
|
local script = library .. "/ActionMax/" .. game .. ".singe"
|
|
|
|
-- The inputs sit beside this script, wherever the engine was started from.
|
|
local here = ((debug.getinfo(1, "S").source:gsub("^@", "")):match("^(.*[/\\])") or "")
|
|
|
|
dofile(here .. "actionMaxInputs.singe")
|
|
|
|
-- The emulator finds its files by its own script's path, and draws sprites in the 2.10 order,
|
|
-- which its games.dat entry would have said.
|
|
SINGE_LEGACY_SPRITE_ARGS = true
|
|
local realScriptPath = singeGetScriptPath
|
|
singeGetScriptPath = function() return script end
|
|
dofile(script)
|
|
singeGetScriptPath = realScriptPath
|
|
|
|
local realUpdate = onOverlayUpdate
|
|
local frames = 0
|
|
local lastState = nil
|
|
|
|
|
|
function onOverlayUpdate()
|
|
frames = frames + 1
|
|
local input = portInputAt(frames)
|
|
|
|
if input then
|
|
onMouseMoved(input.x, input.y, 0, 0)
|
|
onInputPressed(SWITCH_BUTTON3)
|
|
debugPrint(string.format("TRACE input %d at %d,%d: state %d frame %d shots %d good %d bad %d", frames, input.x, input.y, currentState, discGetFrame(), shotsFired, shotsGood, shotsBad))
|
|
end
|
|
local r = realUpdate()
|
|
|
|
if os.getenv("PORT_SENSOR_TRACE") and (frames >= tonumber(os.getenv("PORT_SENSOR_TRACE"))) and (frames < tonumber(os.getenv("PORT_SENSOR_TRACE")) + 12) then
|
|
debugPrint(string.format("SENSOR frame %d disc %d pulled %d spot %s/%s gun %s/%s mouse %d,%d", frames, discGetFrame(), triggerPulled, tostring(sensorLastState), tostring(sensorState), tostring(gunLastState), tostring(gunState), mouseX, mouseY))
|
|
end
|
|
-- The startup and setup states are the emulator's own housekeeping; the title is the first
|
|
-- state a port has.
|
|
if (currentState ~= lastState) and (currentState >= 2) then
|
|
lastState = currentState
|
|
debugPrint(string.format("TRACE state %d from frame %d: disc %d shots %d good %d bad %d", currentState, frames, discGetFrame(), shotsFired, shotsGood, shotsBad))
|
|
end
|
|
if frames >= PORT_LAST then
|
|
debugPrint(string.format("TRACE end: state %d disc %d shots %d good %d bad %d", currentState, discGetFrame(), shotsFired, shotsGood, shotsBad))
|
|
singeQuit()
|
|
end
|
|
|
|
return r
|
|
end
|