shmups.system11.org

Shmups Forum
 
* FAQ    * Search
 * Register  * Login 
It is currently Sun Jul 12, 2020 9:45 pm View unanswered posts
View active topics



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: inp2json: extract button inputs out of MAME INP files
PostPosted: Tue Dec 17, 2019 11:29 pm 


User avatar

Joined: 14 Aug 2019
Posts: 375
Location: BW, Germany
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:
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


Top
 Offline Profile  
 
 Post subject: Re: inp2json: extract button inputs out of MAME INP files
PostPosted: Thu Dec 19, 2019 12:01 am 


User avatar

Joined: 02 Oct 2019
Posts: 15
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?


Top
 Offline Profile  
 
 Post subject: Re: inp2json: extract button inputs out of MAME INP files
PostPosted: Thu Dec 19, 2019 6:18 pm 


User avatar

Joined: 14 Aug 2019
Posts: 375
Location: BW, Germany
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.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Space Pilot 3K template by Jakob Persson
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group