User File #75124732183056273

Upload All User Files

#75124732183056273 (unlisted) -

second_pass.lua
49 downloads
Uploaded 10/27/2021 5:55 AM by CasualPokePlayer (see all 9)
require "inputs_truncated"
input_index = 0
input_changed = false
last_input_change_frame = 0
dpad_poll_frame = 0
abss_poll_frame = 0

function update_dpad_poll_frame()
	if not input_changed then
		dpad_poll_frame = emu.framecount()
	end
end

function update_abss_poll_frame()
	if not input_changed then
		abss_poll_frame = emu.framecount()
	end
end

function submit_input_changes(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 signal_input_change()
	if emu.framecount() > last_input_change_frame then
		input_changed = true
	end
end

--function apply_input_callbacks()
	event.onmemoryexecute(update_dpad_poll_frame,0x21A1)
	event.onmemoryexecute(update_abss_poll_frame,0x21B7)

	--event.onmemoryexecute(signal_input_change,0x02F5) -- title screen
	--title screen fucks up for some reason, just do it manually
	event.onmemoryexecute(signal_input_change,0x09E0) -- dpad input
	event.onmemoryexecute(signal_input_change,0x1DE8) -- menus
--end

--event.onmemoryexecute(apply_input_callbacks,0x0100) -- bios end

while true do
	if input_changed then
		input_index = input_index + 1
		last_input_change_frame = emu.framecount()
		local input = inputs[input_index]
		if input["A"] or input["B"] or input["Start"] or input["Select"] then
			submit_input_changes(abss_poll_frame)
		else
			submit_input_changes(dpad_poll_frame)
		end
		tastudio.applyinputchanges()
	end
	input_changed = false
	emu.frameadvance()
end