TASEmulators / TASEmulators/BizHawk
MAME .inp importer
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
Pearl made a MAME+libTAS movie, which I used to create a MAME replay file (-record file.inp / -playback file.inp). I ran that file in actual MAME while running a script that dumps bizhawk inputs:
fields = {
{ name = "|"},
{ tag = ":COIN", mask = 0x1, name = "Coin 1", value = ".", mnemonic = "C" },
{ tag = ":COIN", mask = 0x2, name = "Coin 2", value = ".", mnemonic = "C" },
{ tag = ":SYSTEM", mask = 0x1, name = "1 Player Start", value = ".", mnemonic = "1" },
{ tag = ":SYSTEM", mask = 0x2, name = "2 Players Start", value = ".", mnemonic = "2" },
{ tag = ":SYSTEM", mask = 0x8, name = "Service 1", value = ".", mnemonic = "s" },
{ tag = ":SYSTEM", mask = 0x4, name = "Service Mode", value = ".", mnemonic = "S" },
{ name = "|"},
{ tag = ":INPUTS", mask = 0x10, name = "P1 Button 1", value = ".", mnemonic = "1" },
{ tag = ":INPUTS", mask = 0x20, name = "P1 Button 2", value = ".", mnemonic = "2" },
{ tag = ":INPUTS", mask = 0x40, name = "P1 Button 3", value = ".", mnemonic = "3" },
{ tag = ":INPUTS", mask = 0x2, name = "P1 Down", value = ".", mnemonic = "D" },
{ tag = ":INPUTS", mask = 0x4, name = "P1 Left", value = ".", mnemonic = "L" },
{ tag = ":INPUTS", mask = 0x8, name = "P1 Right", value = ".", mnemonic = "R" },
{ tag = ":INPUTS", mask = 0x1, name = "P1 Up", value = ".", mnemonic = "U" },
{ name = "|"},
{ tag = ":INPUTS", mask = 0x1000, name = "P2 Button 1", value = ".", mnemonic = "1" },
{ tag = ":INPUTS", mask = 0x2000, name = "P2 Button 2", value = ".", mnemonic = "2" },
{ tag = ":INPUTS", mask = 0x4000, name = "P2 Button 3", value = ".", mnemonic = "3" },
{ tag = ":INPUTS", mask = 0x200, name = "P2 Down", value = ".", mnemonic = "D" },
{ tag = ":INPUTS", mask = 0x400, name = "P2 Left", value = ".", mnemonic = "L" },
{ tag = ":INPUTS", mask = 0x800, name = "P2 Right", value = ".", mnemonic = "R" },
{ tag = ":INPUTS", mask = 0x100, name = "P2 Up", value = ".", mnemonic = "U" },
{ name = "|"}
}
local function getscreen()
for k,v in pairs(manager.machine.screens) do return v end
end
local screen = getscreen()
local curframe = -1
local function log(s, name)
logfile = io.open(name, "ab")
logfile:write(s)
logfile:close()
end
function framecount()
if curframe == screen:frame_number() then return end
local line = ""
for i = 1, #fields do
local char0 = "!"
if fields[i].name ~= "|" then
local state = manager.machine.ioport.ports[fields[i].tag]:read()
char0 = (state & fields[i].mask == 0) and fields[i].mnemonic or "_"
end
line = line .. char0
end
log(line .. "\n", "log.txt")
curframe = screen:frame_number()
end
emu.register_frame_done(framecount)
And barring a single place where a frame had to be inserted, it also synced on MAMEHawk. Which made me think it'd be not too hard to come up with a Hawk side .inp importer, because MAME replays use to sync across versions quite well.
The main advantage of such an importer is crazy amounts of existing MAME replays over the internet, so one could use them as a foundation for a TAS, or any kind of project that could benefit from Hawk tools. Also easier to encode them with Hawk than with MAME, that only dumps uncompressed. All that would be a good selling point of MAMEHawk IMO.
Bonus points if MAME-RR replays could also be imported.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the referenced MAME ioport.cpp and MAME-RR inptport.c implementations to understand their .inp replay formats and compare them with MAMEHawk behavior. Done means BizHawk can import MAME replay files and preserve synchronization, with MAME-RR support as an optional extension.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100