require "inputs_truncated"
input_index = 0
input_changed = false
input_change_cooldown = 0
dpad_poll_frame = 0
abss_poll_frame = 0
function update_dpad_poll_frame()
dpad_poll_frame = emu.framecount()
end
function update_abss_poll_frame()
abss_poll_frame = emu.framecount()
end
event.onmemoryexecute(update_dpad_poll_frame,0x21A1)
event.onmemoryexecute(update_abss_poll_frame,0x21B7)
function change_input(f)
local input = inputs[input_index]
tastudio.submitinputchange(f,"A",input["A"])
tastudio.submitinputchange(f,"B",input["B"])
tastudio.submitinputchange(f,"Down",input["Down"])
tastudio.submitinputchange(f,"Left",input["Left"])
tastudio.submitinputchange(f,"Power",input["Power"])
tastudio.submitinputchange(f,"Right",input["Right"])
tastudio.submitinputchange(f,"Select",input["Select"])
tastudio.submitinputchange(f,"Start",input["Start"])
tastudio.submitinputchange(f,"Up",input["Up"])
end
function apply_next_input()
if input_change_cooldown == 0 then
input_changed = true
input_change_cooldown = 1
else
input_change_cooldown = input_change_cooldown - 1
end
end
event.onmemoryexecute(apply_next_input,0x02F5) -- title screen
event.onmemoryexecute(apply_next_input,0x09E0) -- dpad input
event.onmemoryexecute(apply_next_input,0x1DE8) -- menus
while true do
if input_changed then
input_index = input_index + 1
local input = inputs[input_index]
if input["A"] or input["B"] or input["Start"] or input["Select"] then
change_input(abss_poll_frame)
else
change_input(dpad_poll_frame)
end
tastudio.applyinputchanges()
end
input_changed = false
emu.frameadvance()
end