User File #638273167943803772

Upload All User Files

#638273167943803772 - Action 52 - Meong Checker

a52_meong_checker.lua
87 downloads
Uploaded 8/11/2023 2:13 AM by warmCabin (see all 30)
A simple script I used to validate my Meong submission. Action 52 managed to fill this basic RAM search task with a shocking amount of jank. You'd think I could just check if the Y coordinate decreases every 4 frames, right? WRONG. You go through 06 twice, for reasons unknowable. So my code has to account for that.

-- Start 1 frame after the first up input in each level, because reasons.

local startFrame = emu.framecount()
local prevJoy = {}
local prevY = -1
local firstTime06 = true

print(string.format("Starting on frame %d", startFrame))

emu.registerafter(function()

    local joy = joypad.get(1)
    local y = memory.readbyte(0x0664) -- Upper 4 bits is screen, lower 4 is tile Y.
    
    gui.text(10, 10, string.format("%02X", y))
    
    if (emu.framecount() - startFrame) % 2 == 0 and emu.lagged() then
        print("Level complete.")
        emu.pause()
        return
    end
    
    -- There is an anomaly at the end of each stage. When you hit 06 for the first time, your next movement is going to
    -- nudge you down by 01, invisibly. Seems like they're accounting for some hideous fencepost error.
    -- This statement counters that nudge so the validation still works.
    if prevY == 0x06 and firstTime06 then
        prevY = 0x07
    end

    if (emu.framecount() - startFrame) % 4 == 0 then
        if not joy.up or prevJoy.up then
            print(string.format("%d - Why aren't you pressing up!?", emu.framecount()))
            emu.pause()
        elseif y >= prevY then
            print(string.format("%d - You're not moving!", emu.framecount()))
            emu.pause()
        end
    end
    
    prevJoy = joy
    prevY = y

end)