I'm wondering why no one has ever made any sort of mame cfg file parser program so people could adjust cfg files on the fly without having to open Mame and do it by hand.
That's what I'm working on, I hope to support both ctrlr files and INI file, and be able to batch create them based. I'm doing this to support the issue discussed a week ago about alternating/nonalternating player1 / player2 controls.
-PacManFan
Are you working on ctrlr/ini, ini/ini, and cfg/cfg files, or just ctrlr/ini and ini/ini files? (He's asking about cfg/cfg files.)
(FWIW) About cfg/cfg files:
How to read/write these files can be found in src/inptport.c/h. You would need to get the layout of each cfg file from the drivers in src/drivers order to be able to construct that game's cfg file. Since drivers can change between versions of mame, you would need an update each version of mame. (Off top of my head, easiest way would be to have a second parser that graps the needed info off the driver source files and puts it in a dat type file.) If the cfg/cfg file already exists, you might be able to get away without the driver info if you parse correctly (without game specific error checking, though).
general cfg file layout:
header (8 char)
number inputs (int)
[game's driver default input settings]*
[game's current input settings]*
[other stuff]If default.cfg, all mame inputs are saved; if game.cfg, only the inputs the game uses are saved.
input settings format:
input type (int)
input mask (word)
default value (word)
[sequence of key/joy/mouse set as the inputs]sequence format:
number inputs (word)
"savecode" of input (int)*input type includes info such as button1, AD_stick, or lightgun; player #; center, reverse, 8way, or other flags; and (for analog inputs) sensitivity, joy/key speed, min and max.
input mask is a mask showing which bits in the game memory will be changed.
Items with * at the end mean 0 up to a max (but not always) of 256 repetitions of that thing. Items listed between [] mean that item is a collection of info.
Not that hard, huh? I've thought about making a cfg parser (obviously), but the ctrlr/ini files do one of the major reasons for a cfg/cfg parser (map inputs to game ports). Plus, I'm lazy and analog+ is enough for me ATM.
