User File #39117950642069638

Upload All User Files

#39117950642069638 - PushOver_skip-transitions

PushOver_AVskipTransitionsv2_+avisynthfriendly_output.lua
Game: Push-Over ( SNES, see all files )
850 downloads
Uploaded 5/19/2017 4:05 PM by partyboy1a (see all 14)
FatRatKnight's script + avisynthfriendly output.
The script must be started while not in a level (will crash otherwise), and must be run until the movie almost finishes (will create an empty file otherwise)
--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()

local function AVISynthFriendlyOutput()
  file = io.open("pushover-notransitions.avs", "w")
  file:write("AVISource(\"Push-Over (USA).avi\")\n")
  file:write("offset_before = 0\n")
  file:write("offset_after = 0\n")
  firstline = true
  last = LevelShown()
  while emu.framecount() < MovieEndFrame do
	now = LevelShown()
	if(last == false and now == true) then
	  segment_start = emu.framecount()
	end
	if(last == true and now == false) then
	  -- Trim command includes last specified frame, so...
	  segment_end = emu.framecount() - 1
	  if not firstline then
	    file:write(string.format(" ++ \\\nTrim(%d + offset_before, %d + offset_after)", segment_start, segment_end))
      else
		file:write(string.format("Trim(%d + offset_before, %d + offset_after)", segment_start, segment_end))
		firstline = false
	  end
	end
	last = now
	emu.frameadvance()
  end
  file:write(string.format(" ++ \\\nTrim(%d + offset_before, 0)\n", segment_start))
  file:close()
end
AVISynthFriendlyOutput()