inp2json: extract button inputs out of MAME INP files

A place for people with an interest in developing new shmups.
Post Reply
User avatar
6t8k
Posts: 496
Joined: Wed Aug 14, 2019 2:44 pm

inp2json: extract button inputs out of MAME INP files

Post by 6t8k »

Hey all,

for fun/out of curiosity, I've thrown together a small Python script that takes a MAME INP file and generates JSON output out of it. (context)

This should make the data easier to read/process further for whatever purpuse, like a custom input viewer (example). This can come in handy in situations where such a thing is not available out of the box or does not have the desirable features.
I thought that maybe somebody might find it useful and consequently thought I might post it here so it does not go to waste.

I tested it with shmupmame 4.2 and current (Wolf)MAME versions. Basically, it should work with anything that records version 3.0 or 3.5 INP files.

You need Python 3, there are no other dependencies.

Basic usage:

Code: Select all

inp2json.py --input-file PATH_TO_INP_FILE --check-ports 0,1
The JSON is then written to PATH_TO_INP_FILE.json.
If you see nonsensical or no button presses at all, you might have to play a bit with the --check-ports and/or --ports-count arguments.

Limitations:
- Only recognizes digital inputs
- Currently, the only game supported is Nemesis/Gradius. Games can easily be added by looking up the necessary data in the MAME drivers and incorporating it in line with the existing Nemesis/Gradius data.

Suggestions, in the form of prose, or even merge requests, are of course always welcome. :)

@mods: if this is better placed in Off-Topic as it is not strictly shmup dev, feel free to move it there.
___________________

➤ GitHub
User avatar
hechelion
Posts: 29
Joined: Wed Oct 02, 2019 2:19 am

Re: inp2json: extract button inputs out of MAME INP files

Post by hechelion »

To be honest. I don't think this have a lot of utility, but look awesome.

Where did you get the structure of the INP? did you have to analyze the source code of wolfmame?
User avatar
6t8k
Posts: 496
Joined: Wed Aug 14, 2019 2:44 pm

Re: inp2json: extract button inputs out of MAME INP files

Post by 6t8k »

Thanks! Its scope of application is limited at best, no doubt. I surmise that that must've been the notion of most precursors too so far, otherwise we wouldn't be here right now. But - that's one way how new things sprout, as I like to say on such occasions. :)

On one hand I would've appreciated seeing documentation for this (I've found the MAME tech-docs a bit lacking in some areas), on the other hand the structure of those INP files is not complex and can easily be derived from consulting the source code.
There's this kinda tongue-in-cheek saying that source code is the best documentation - while it's not necessarily laudable, it was the case again.
Post Reply