Barthax's MAME batch file

  1. Barthax's MAME batch file

    01-08-2015, 04:10 AM
    Hi all,

    As requested by multiple individuals, attached are a pair of zips which can be used to generate similar posts to those I've been posting in the MAME submissions here. The check.zip contains the batch file which must be used from the command-prompt for 0.106+ (don't double-click: it won't wok that way). The dips.zip contains the current set of source analysis (the content is largely driven by the submissions, so content for each version will vary). There used to be old analysis under the old referee system which was written into the hidden fields of the TG database: but I didn't keep a copy.

    Expected installs and configuration of those

    The batch file has been designed to work across all MARP submissions, including configuring and firing up DOSBox for DOS MAME executables and resolving the mameplib.dll clashes of old WolfMAMEs (none of that is relevant here but if you go digging, you now know why it is all there).

    The batch file expects a few things to be available as indicated inside it (add DOS Box if you're thinking of going down that road - see batch file for similar to the others). [Note that in a future update in this thread, you should now be making any changes to the checkconf.bat file and not directly in the check.bat file.]
    Code:
    REM Expectations:
    REM Gnu's CoreUtils installed
    REM http://gnuwin32.sourceforge.net/packages/coreutils.htm
    REM Gnu's Grep installed (install to same location!)
    REM http://gnuwin32.sourceforge.net/packages/grep.htm
    SET GNU=C:\Program Files\GnuWin32\bin
    
    REM 7-Zip installation location
    REM http://www.7-zip.org/download.html
    SET ZIP=C:\Program Files\7-Zip\7z.exe
    SET ZIPFLAGS=e -y -o%DOWNLOCATION%
    SET ZIPTEST=t
    SET ZIPLIST=l -slt
    
    REM XD
    REM https://www.fourmilab.ch/xd/
    SET HEXDUMP=xd.exe
    SET HEXDUMPFLAGS=-c
    REM -or-
    REM Rich Paso's HEXDump copied to MAMELOCATION
    REM http://www.richpasco.org/utilities/hexdump.html
    REM SET HEXDUMP=hexdump.exe
    REM SET HEXDUMPFLAGS=
    You only need one hexdump utility - xd.exe works quicker than HEXDump but I did start with HEXDump and kept the knowledge in there for choice. For 64-bit machines the GNU utilities will probably get installed to Program Files (x86) so use:

    SET GNU=C:\Program Files (x86)\GnuWin32\bin

    Obviously alter to wherever you install them if not default. For unzipping, 7-Zip is assumed: if you don't like it, adjust the parameters to your utility preference and if 7-Zip isn't installed to its default location (64-bit 7-Zip does go in Program Files).

    MAME executables

    The batch file expects Win executables to be named mame<ver>.exe. So WolfMAME 0.106 should be renamed to mame106.exe. Any accompanying files will need to be kept in the original names (mamep106lib-vc.dll and any other DLLs and exes you may think are required for your system). Change the wlfview.exe to wlfview<ver>.exe (so wlfview106.exe). [Note: some WolfMAMEs don't have a wlfview.exe so copy the wlfview.exe from the prior version.]
    If you plan to use multiple MAMEs, then I use suffixes for the different types - WolfMAMEs are always mame<ver>.exe (note that 91u1 is <ver> portion, for example). MAME32s I rename to mame<ver>w.exe
    If you're planning on helping/check out MARP stuff, the batch file expects DOS executables to be named M<ver>.exe. So MAME 0.33's mame.exe should be renamed to m33.exe.

    If you are planning on using multiple MAMEs, there's a snapshot of my current C:\MAME folder called "MAME folder.jpg" so you get an idea of how messy they all sit together. ;) You may also notice I have multiple roms folders which I switch between (just rename the existing roms to something else & a different one to roms) for coping with the disparity between versions.

    Environment

    ... or where it finds the Zip & INP files and what it does with them afterwards. At the top of the batch file you will find the following:

    Code:
    REM Environment variables
    SET MAMELOCATION=C:\MAME
    SET INPLOCATION=%MAMELOCATION%\inp
    SET DOWNLOCATION=%INPLOCATION%\MARP
    SET DONELOCATION=%DOWNLOCATION%\Done
    SET SRCLOCATION=E:\projects\MAME\dips
    MAMELOCATION is where your MAME executables exist. The INP location is where the INP files will live and should be the INP folder beneath the MAMELOCATION.

    DOWNLOCATION is the folder where the Zip files should be placed. The check.bat expects one zip file to exist there on any given run. DONELOCATION is the folder where the Zip file will be moved to after check.bat has been run.

    SRCLOCATION is where the Dips.zip should be extract to - do change this path to wherever you feel comfortable with.

    So that your own configuration is not overwritten by any changes I make in check.bat, the batch file sets up the defaults and then looks for a checkconf.bat file. If that file exists, it runs checkconf.bat. I don't update checkconf.bat so you can keep your localised settings in there without disturbance.

    Using the batch file

    Use a command line!

    check.bat <version> <romset>

    ... where <version> is the version of MAME and <romset> is the shortname of the roms. For example, to run version 0.106 with Pac-Man game:

    check.bat 106 pacman

    What this does is extract the zip file in the DOWNLOCATION (without sub-folders so all files are in the one folder). Moves all the INP files to <romset>.inp in the INPLOCATION (which means only one INP will survive) and all WLF files to <romset>.wlf in the INPLOCATION. It then checks the <version> you've requested: if 37 or before, it'll check for an M<ver>.exe then MAME<ver>.exe to run but if after 37 it'll check the other way around. If a suitable executable is found it'll fire it up with appropriate command-line options including the -iv of WolfMAME to see the player 1's input.

    ... I'm bound to have missed something and not explained everything properly so I expect stunned silence through people not wanting to go to this effort and questions abound from those that do. :)

    Additional tools
    INPDecomp is a decompressor for MAME INPs of 0.129 and onwards. Features introduced in 0.149 negate the need for this but it still works. NB: this is the work of an anonymous third-party.
    ROMChanged.bat is a very simplistic batch file to run through a suite of MAME versions running -listfull and -listclones for a single rom set.

    [update]
    checkconf.bat: checkconf.zip
    2015-04-14:
    inpdecomp: Attachment 3064 (source and 32-bit Windows exectuable)
    2016-04-29:
    check.bat: Attachment 14624
    romchanged.bat: Attachment 14625
    dips: download zip from https://github.com/Barthax/TGDips - dips folder.
    TGMAME.txt: Attachment 14627
    Attached Images Attached Images  
    Last edited by Barthax; 04-29-2016 at 08:27 AM.
    I'd rather be last on every game than throw my time away chasing only one score.
  2. 01-08-2015, 04:37 AM
    Great stuff. Thank you for the resources. I've already familiarized myself with the process for checking DIPs in 106 but haven't really done so with other versions. I know that the ability to use -iv 1 and press the Del key was implemented in 149. Do you have a method for checking DIPs in the versions with compressed INPs that came before 149 (129 - 148, I believe)? And is there an easy way to determine the DIP offset and number of bytes in the headers/frames for versions other than 106?

    I know we're all locked into 106 at the moment, but it might not always be that way. :)
  3. 01-08-2015, 04:43 AM
    Quote Originally Posted by xelnia View Post
    Great stuff. Thank you for the resources. I've already familiarized myself with the process for checking DIPs in 106 but haven't really done so with other versions. I know that the ability to use -iv 1 and press the Del key was implemented in 149. Do you have a method for checking DIPs in the versions with compressed INPs that came before 149 (129 - 148, I believe)? And is there an easy way to determine the DIP offset and number of bytes in the headers/frames for versions other than 106?
    I really haven't tried discovering DIPs outside of 0.106 very much (have a few before 0.106 but not many) and didn't know the 0.129-0.148 were not plain binaries. I'm in the same boat more-or-less, I'm afraid: haven't had the need, so haven't bothered to try, sorry. I've had one memorable need to check a 0.155 DIP as the -iv + DEL didn't seem to be correct. However, it turned out I was just being stupidly tired and it was correct all along. :)

    Quote Originally Posted by xelnia View Post
    I know we're all locked into 106 at the moment, but it might not always be that way. :)
    Here's hoping. :)
    I'd rather be last on every game than throw my time away chasing only one score.
  4. 01-09-2015, 09:37 AM
    Barthax I have a question. Can you from the batch file information re-create the original inp and wlf file?
  5. 01-09-2015, 10:49 AM
    Quote Originally Posted by erockbrox View Post
    Barthax I have a question. Can you from the batch file information re-create the original inp and wlf file?
    Not a chance - there is nothing like the minute information required to re-create the INP file in the information.
    I'd rather be last on every game than throw my time away chasing only one score.
  6. 01-25-2015, 06:45 AM
    Got this to work without any questions. Albeit with a bit of hassle from my end. Your instructions were sufficient
    Made me realise I really do need to sort my mame/marp folders out. What a mess that has become over the past while. I'm sure you can attest to that too, Andrew

    Thanks Barthax thanked this post
  7. 01-25-2015, 06:54 AM
    Quote Originally Posted by Barra View Post
    Got this to work without any questions. Albeit with a bit of hassle from my end. Your instructions were sufficient
    Made me realise I really do need to sort my mame/marp folders out. What a mess that has become over the past while. I'm sure you can attest to that too, Andrew

    Glad to hear (read) it. :) Yeah, the ROMs have changed massively over the years and if (at MARP, for example) you use multiple different MAMEs then even more complications arrive: especially with older MAME32s in the mix.

    I've attached a couple of updated zip files. The check.bat now looks for a checkconf.bat file and if it exists it runs that after setting up the environment. I've had to do this so that I can use the same check.bat in multiple locations: the checkconf.bat then performs the localising away from any defaults of check.bat (you'll see in the zip files). Of course, this also means I can maintain the check.bat (which has other minor updates) without disturbing everyone's install. :) Also attached is an updated dips.zip.

    I'm still going through my backlog of stuff to submit - it'd be great to see a breakdown from someone else when I get around to them: I'd feel quite conscious of analysing my own as part of the submission package.
    Attached Files Attached Files
    Last edited by Barthax; 01-25-2015 at 06:56 AM.
    I'd rather be last on every game than throw my time away chasing only one score.
    Likes Barra liked this post
  8. 01-25-2015, 07:00 AM
    Quote Originally Posted by Barthax View Post
    I'm still going through my backlog of stuff to submit - it'd be great to see a breakdown from someone else when I get around to them: I'd feel quite conscious of analysing my own as part of the submission package.
    I'd be happy to run the analysis for your submissions (and others too if need be)
    I'll keep an eye out. Still got a lot to catch up on as I was not active over the weekend.

    Thanks Conjured Entertainment thanked this post
    Likes Conjured Entertainment liked this post
  9. 02-28-2015, 04:35 PM
    Updated dips attached (dips-20150301.zip). I notice the number of submissions is increasing which will inevitably mean I won't keep up with 'em all - just fair warning: if I miss some it'll probably be due to lack of time currently & eventually lack of interest/burn out as bites every MAME referee TG has ever seen.
    I'd rather be last on every game than throw my time away chasing only one score.
  10. 03-01-2015, 05:59 AM
    So I got the following via PM & was given permission to continue the discussion here: one location for all to see seems a better discussion area. :)

    Quote Originally Posted by xelnia
    1) In most, if not all, of your analyses the DIP info is stated as being at offset 0x2F and repeating every 0x7C. Is this a universal value? I see that this is true for Donkey Kong (dkong) for example, but when looking at Intrepid (intrepid) or Crazy Kong (ckong/ckongpt2) it appears that the DIP values are at offset 0x2B. Is there something in each game's source that can be used to determine exactly where to look for this? In the past my approach has just been to record
    several INPs with different settings and compare, looking for wherever the values are different.
    First, a quick overview of the source layout: over the years the MAME devs have had some very savvy programmers included in the project management side of stuff. While it was (0.106 era) programmed in C (now a C/C++ mix) you can be forgiven if looking at the drivers for not knowing that: they use a lot of pre-processor macros to ensure there are less & less stupid mistakes. To this end, the below snapshots into the source are all pre-processor macro calls which generate a consistent C output.

    Quick disclaimer: I know that games with analogue inputs behave differently and I haven't had any need to delve much deeper than "knowing" they're different, so the below is in reference to digital input games.

    The repeating offset is dependent on the game. For most early-era games (which, let's face it, is most of the popular games on the scoreboard) are on real machines which had very little inputs: some dip switches and one or two 4/8-way joysticks. Cast your mind back to the golden era: most manufacturers had no imagination in what a gamer would use and as a result, the number of inputs is similar for many games. That's the only reason most have a 0x7C repetition: the manufacturers used similar input mechanisms for so many years there is very little variety. It is commonality and not universality. You could also blame the gamers for having no imagination in what they play. j/k

    In terms of the initial offset you mention (0x2B in others vs. 0x2F in dkong), it can be determined from the source but the practice you put in is something I still do to be certain. :)

    DKong:
    Code:
    INPUT_PORTS_START( dkong )
        PORT_START      /* IN0 */
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY
        PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY
        PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
    
        PORT_START      /* IN1 */
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
        PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
        PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
    
        PORT_START      /* IN2 */
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME(DEF_STR( Service_Mode )) PORT_CODE(KEYCODE_F2)
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
        PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 )
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL )    /* status from sound cpu */
        PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )
    
        PORT_START      /* DSW0 */
        PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
        PORT_DIPSETTING(    0x00, "3" )
        PORT_DIPSETTING(    0x01, "4" )
        PORT_DIPSETTING(    0x02, "5" )
        PORT_DIPSETTING(    0x03, "6" )
        PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
        PORT_DIPSETTING(    0x00, "7000" )
        PORT_DIPSETTING(    0x04, "10000" )
        PORT_DIPSETTING(    0x08, "15000" )
        PORT_DIPSETTING(    0x0c, "20000" )
        PORT_DIPNAME( 0x70, 0x00, DEF_STR( Coinage ) )
        PORT_DIPSETTING(    0x70, DEF_STR( 5C_1C ) )
        PORT_DIPSETTING(    0x50, DEF_STR( 4C_1C ) )
        PORT_DIPSETTING(    0x30, DEF_STR( 3C_1C ) )
        PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
        PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
        PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
        PORT_DIPSETTING(    0x60, DEF_STR( 1C_4C ) )
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
        PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
        PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
    INPUT_PORTS_END
    So each game starts with an INPUT_PORTS_START and ends with an INPUT_PORTS_END. The start tag includes the short name of the ROM set in question. If you can't find the ROM set you are looking for, look to the end of the file instead for the GAME maco:

    Code:
    GAME( 1980, radarscp, 0,        radarscp, dkong,    radarscp, ROT90, "Nintendo", "Radar Scope", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
    
    GAME( 1981, dkong,    0,        dkong,    dkong,    0,        ROT90, "Nintendo of America", "Donkey Kong (US set 1)", GAME_SUPPORTS_SAVE )
    GAME( 1981, dkongo,   dkong,    dkong,    dkong,    0,        ROT90, "Nintendo", "Donkey Kong (US set 2)", GAME_SUPPORTS_SAVE )
    GAME( 1981, dkongjp,  dkong,    dkong,    dkong,    0,        ROT90, "Nintendo", "Donkey Kong (Japan set 1)", GAME_SUPPORTS_SAVE )
    GAME( 1981, dkongjo,  dkong,    dkong,    dkong,    0,        ROT90, "Nintendo", "Donkey Kong (Japan set 2)", GAME_SUPPORTS_SAVE )
    GAME( 1981, dkongjo1, dkong,    dkong,    dkong,    0,        ROT90, "Nintendo", "Donkey Kong (Japan set 3) (bad dump?)", GAME_SUPPORTS_SAVE )
    
    GAME( 1982, dkongjr,  0,        dkongjr,  dkong,    0,        ROT90, "Nintendo of America", "Donkey Kong Junior (US)", GAME_SUPPORTS_SAVE )
    [etc...]
    The second parameter of each GAME macro is the ROM set used. The fifth parameter is the INPUT set used. So you can see that for radarscp and dkongjr, the dkong INPUT set is used:

    GAME( 1980, radarscp, 0, radarscp, dkong, radarscp, ROT90, "Nintendo", "Radar Scope", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
    GAME( 1982, dkongjr, 0, dkongjr, dkong, 0, ROT90, "Nintendo of America", "Donkey Kong Junior (US)", GAME_SUPPORTS_SAVE )

    OK, so back to your question about the offset. You can determine the expected offset by the number of PORT_START macro calls. Each PORT_START represents a 32-bit value (this makes more sense in more recent games where banks of dips are across more than one byte) and are stored in the INP file in Most Significant Byte (MSB)-first: the highest value at the left and the lowest value sits at the right. As the first 0x20 bytes (offsets 0x00 through 0x1F) are taken up by the INP header, we know this first PORT_START sits at offset 0x20 (the 0x21st byte). The second PORT_START will occupy offset 0x24, third at 0x28, fourth at 0x2C and fifth at 0x30, etc. As we a largely seeing 8-bit PORT_BIT/PORT_DIPNAME macros used, the first three bytes (the MSBs) are zero by default and as such the Least Significant Byte (LSB) of the first PORT_START sits at offset 0x23, second at offset 0x27, third at 0x2B, fourth at 0x2F and the fifth at 0x33.

    To break this down to dkong: the input one (IN0) begins at offset 0x20 and occupies bytes 0x20-0x23, input two (IN1) begins at offset 0x24 and occupies 0x24-0x27, IN2 at 0x28 in 0x28-0x2B and the one we're after (DSW0) is at offset 0x2C, occupying 0x2C through 0x2F.

    Code:
        PORT_START      /* DSW0 */
        PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
        PORT_DIPSETTING(    0x00, "3" )
        PORT_DIPSETTING(    0x01, "4" )
        PORT_DIPSETTING(    0x02, "5" )
        PORT_DIPSETTING(    0x03, "6" )
        PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
        PORT_DIPSETTING(    0x00, "7000" )
        PORT_DIPSETTING(    0x04, "10000" )
        PORT_DIPSETTING(    0x08, "15000" )
        PORT_DIPSETTING(    0x0c, "20000" )
        PORT_DIPNAME( 0x70, 0x00, DEF_STR( Coinage ) )
        PORT_DIPSETTING(    0x70, DEF_STR( 5C_1C ) )
        PORT_DIPSETTING(    0x50, DEF_STR( 4C_1C ) )
        PORT_DIPSETTING(    0x30, DEF_STR( 3C_1C ) )
        PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
        PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
        PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
        PORT_DIPSETTING(    0x60, DEF_STR( 1C_4C ) )
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
        PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
        PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
    The PORT_DIPNAME macro determines the mask within the input value to look at for the value in question. Masks are a way of identifying which bits are relevant. The Lives setting is in mask location 0x03. The inputs are all 32-bit and so we're only looking for a value in the LSB, 0x03 is the equivalent of 0x00000003 for the full 32-bit. As the 32-bit value is stored in offset 0x2C and we only want the LSB, its offset is in 0x2F: we don't need evaluate 0x2C-0x2E values because there's nothing stored there.

    Code:
    Offset: 20 21 22 23 24 25 26 27  28 29 2A 2B 2C 2D 2E 2F
        20: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 80 | ................
    Last edited by Barthax; 03-01-2015 at 06:39 AM.
    I'd rather be last on every game than throw my time away chasing only one score.
    Thanks xelnia thanked this post
    Likes xelnia, Barra liked this post
Page 1 of 7 1 2 3 ... LastLast
Results 1 to 10 of 62
Page 1 of 7 1 2 3 ... LastLast
Join us