From ef2f56f739fbb18d0e7506f9075c0e61997b68ab Mon Sep 17 00:00:00 2001 From: KonKeyHD Date: Wed, 28 Mar 2018 23:51:50 +0200 Subject: [PATCH 1/2] Add BizHawk Scripts Some script i wrote. Still needs some patching to get `event.oninputpoll(on_latch)` working --- .../SNES/BizHawk/bizhawk_gamepad_dump.lua | 69 +++++++++++++++++++ .../SNES/BizHawk/bizhawk_multitap_dump.lua | 69 +++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua create mode 100644 scripts/emulator/SNES/BizHawk/bizhawk_multitap_dump.lua diff --git a/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua b/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua new file mode 100644 index 0000000..fa5c7e1 --- /dev/null +++ b/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua @@ -0,0 +1,69 @@ +print ("TASLink Bizhawk Gamepad Latch Dumper loaded") +dumpfile = nil; + +pollcount = 0; + +start_dump = function(filename) + file, err = io.open(filename .. ".latch.r08", "wb"); + if not file then + error("Error opening output file: " .. err); + end + print(string.format('Dumping to %s.latch.r08', filename)); + + dumpfile = file; + + pollcount = 0; +end + +stop_dump = function() + if (dumpfile) then + dumpfile:close(); + dumpfile = nil; + print("Dumping halted") + else + print("Cannot stop: Dumping not started") + end +end + +get_button = function(choice) + local conn_tbl = + { + [15] = 'B', + [14] = 'Y', + [13] = 'Select', + [12] = 'Start', + [11] = 'Up', + [10] = 'Down', + [9] = 'Left', + [8] = 'Right', + [7] = 'A', + [6] = 'X', + [5] = 'L', + [4] = 'R' + } + + local func = conn_tbl[choice] + if(func) then + return func + end +end +on_latch = function() + if dumpfile then + pollcount = pollcount + 1 + + local frame = emu.framecount () + for i = 1, 2, 1 do + out = 0x00 + for j = 4, 15, 1 do + if movie.getinput(frame)[string.format("P%s %s", i, get_button(j))] then + out = bit.bor(out, bit.lshift(1, j)) + end + end + dumpfile:write(string.char(bit.band(bit.ror(out, 8), 0xff), bit.band(out, 0xff))); +-- print(string.char(bit.band(bit.ror(out, 8), 0xff), bit.band(out, 0xff))) + end + + end +end + +event.oninputpoll(on_latch); \ No newline at end of file diff --git a/scripts/emulator/SNES/BizHawk/bizhawk_multitap_dump.lua b/scripts/emulator/SNES/BizHawk/bizhawk_multitap_dump.lua new file mode 100644 index 0000000..56ddacf --- /dev/null +++ b/scripts/emulator/SNES/BizHawk/bizhawk_multitap_dump.lua @@ -0,0 +1,69 @@ +print ("TASLink Bizhawk multitap Latch Dumper loaded") +dumpfile = nil; + +pollcount = 0; + +start_dump = function(filename) + file, err = io.open(filename .. ".latch.r16m", "wb"); + if not file then + error("Error opening output file: " .. err); + end + print(string.format('Dumping to %s.latch.r16m', filename)); + + dumpfile = file; + + pollcount = 0; +end + +stop_dump = function() + if (dumpfile) then + dumpfile:close(); + dumpfile = nil; + print("Dumping halted") + else + print("Cannot stop: Dumping not started") + end +end + +get_button = function(choice) + local conn_tbl = + { + [15] = 'B', + [14] = 'Y', + [13] = 'Select', + [12] = 'Start', + [11] = 'Up', + [10] = 'Down', + [9] = 'Left', + [8] = 'Right', + [7] = 'A', + [6] = 'X', + [5] = 'L', + [4] = 'R' + } + + local func = conn_tbl[choice] + if(func) then + return func + end +end +on_latch = function() + if dumpfile then + pollcount = pollcount + 1 + + local frame = emu.framecount() + for i = 1, 8, 1 do + out = 0x00 + for j = 4, 15, 1 do + if movie.getinput(frame)[string.format("P%s %s", i, get_button(j))] then + out = bit.bor(out, bit.lshift (1, j)) + end + end + dumpfile:write(string.char(bit.band(bit.ror(out, 8), 0xff), bit.band(out, 0xff))); +-- print(string.char(bit.band(bit.ror(out, 8), 0xff), bit.band(out, 0xff))) + end + + end +end + +event.oninputpoll(on_latch); From f982852d3f2c4dfe68343869d78e859a1954ee52 Mon Sep 17 00:00:00 2001 From: KonKeyHD Date: Wed, 28 Mar 2018 23:54:43 +0200 Subject: [PATCH 2/2] Add newline at end of file --- scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua b/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua index fa5c7e1..5dff880 100644 --- a/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua +++ b/scripts/emulator/SNES/BizHawk/bizhawk_gamepad_dump.lua @@ -66,4 +66,4 @@ on_latch = function() end end -event.oninputpoll(on_latch); \ No newline at end of file +event.oninputpoll(on_latch);