User File #39104462224501020

Upload All User Files

#39104462224501020 - SNES Push-Over - Script to skip transitions. (fix)

PushOver_AVskipTransitionsv2.lua
849 downloads
Uploaded 5/19/2017 1:30 AM by FatRatKnight (see all 245)
Version 2 is out! Now with fewer errors!
... I sort of used the wrong name for a particular function. Error fixed! Just about the entire version log, really.
So, with 50% fewer known errors (and who knows how many fewer unknown errors), I hope this script can be used and with no need to fiddle with the internals.
Run script, preferably before a few hundred thousand frames passed (running it after that time should quit the script immediately, an error I don't plan to fix without a sufficient reason explained for the fix), then run whatever video capturing stuff you encoders do for TASes. Should remove a total just under 15 and a half minutes of transitions.
--SNES Push-Over
--AV trim script to remove transition frames (v2)
--Run script, run movie, run AV recorder.
--The input ends just before the screen transition to the ending, as G.I. Ant
--goes through a few frames of walking. Just set MovieEndFrame at or before that
--point, and there should be no interruptions for the ending, such as it is.
--FatRatKnight

--Settings
local MovieEndFrame= 266400 --Pick some point before it ends, to record ending.

--##############################################################################
--Stuff to do.
local R1u= memory.read_u8

--******************************************************************************
local function LevelShown()
--******************************************************************************
--Reads a specific memory address to assess whether level is being shown.
--Theoretically, we can modify this function to add delays if desired.
--Will be rather tricky to pick some point before the transitions, though.

  return R1u(0x7E01FC,"System Bus") == 0x56
end

--******************************************************************************
local function AV_Trim()
--******************************************************************************
  while true do

    --Assume we want to record initially.
    client.unpause_av()
    while     LevelShown() do  emu.frameadvance()  end
    --We'll fall right past the emu.frameadvance if level isn't shown.

    --If level isn't shown, don't record to video file.
    client.pause_av()
    while not LevelShown() do
      --If the movie is done, we'll want to escape.
      if emu.framecount() > MovieEndFrame then client.unpause_av(); return end

      --Aside from that, do nothing.
      emu.frameadvance()
    end
    --After this, we wrap back to the start, the level is shown again.

  end --forever loop
end --function
AV_Trim()

--******************************************************************************
local function TestFn()
--******************************************************************************
--I'm not an encoder. Since I'm not generating a video file, I need to see how
--my logic works, so this is the test function.

  while true do

  --All good
    print(string.format("Rising edge: %d",emu.framecount()))
    while     LevelShown() do  emu.frameadvance()  end

  --Not all good
    print(string.format("Falling edge: %d",emu.framecount()))
    while not LevelShown() do
      if emu.framecount() > MovieEndFrame then return end
      gui.drawLine(  0,  0,255,223,0xFFFF2000)  --Giant red X.
      gui.drawLine(  0,223,255,  0,0xFFFF2000)  --We love giant red Xes.
      emu.frameadvance()
    end
  end
end
--TestFn()