Author Topic: Batch file scripting guide for Attract-mode (Basic)  (Read 2379 times)

checkist

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
Batch file scripting guide for Attract-mode (Basic)
« on: June 25, 2014, 01:48:38 AM »
First I planned to write this to wiki, but since it's not directly related to attract-mode frontend, so I write here.
Actually, this is more likely to 'tips & techniques' or something.....

Anyway, let's get started.

Using MESS in attract-mode can easily become copy-and-paste work, as MESS handles many console types, with slightly different running switches. (like 'mess sms -cart something.sms', 'mess famicom -cart something.nes')

Batch files, can be used to overcome such repetitions by simple scripting. Linux systems are known to have great shell scripts. Windows systems, on the other hand, have very-limited-functionalities-batch-files. Fortunately, even with their limited capabilities, it can (barely) achieve what we want.


Here is brief structure and strengths of how everything works together:
1) Mess.bat handles all kinds of file extension-emulator associations, using basic batch file syntaxes
1-1) Since it's just a batch file, it has transparent working mechanism. For those who doesn't like black-box.exe styles, it has its merits
1-2) You can easily switch between various emulators (mess.exe / snes.exe...).

2) Attract-mode has single configuration for Mess.bat.
2-1) This greatly reduces copy-and-paste operations.



<Setting up basic Mess.bat>
The key syntax in batch file is argument handling.
Suppose you called Mess.bat f:\something.nes, the f:\something.nes is passed into Mess.bat
You can refer them in batch file as belows:

"%1"   : complete path (f:\something.nes)
"%~n1" : file name (something)
"%~x1" : file ext (.nes)

then you can create basic batch file as belows:

------------------------------------------------
if "%~x1"==".sms"   SET MACHINE=smsj
...
if "%~x1"==".md"   SET MACHINE=megadrij
cd /d "C:\Emuls\Mess 0.152\"
mess.exe %MACHINE% -cart %1
------------------------------------------------

Note 'cd /d' command in batch file. It changes 'current working directory' to the target location.
Some emulators can work without such process (such as ZSNES), but most cases requires it.

You can even associate above batch file with rom extensions (like .sms, .md). Just double-click them on windows explorer, and associate them with your Mess.bat file. Next time, you can easily launch your emulators for selected roms by just double-clicking them on windows explorer.



<Setting up attract-mode>
Since Mess.bat will handle neccessary options, you can just pass [romfilename] to Mess.bat..

executable           C:\Emuls\Mess.bat
args                 "[romfilename]"
rompath              C:\Emuls\attract-1.3.1\roms\
romext               .sms;.nes;.rom;.smc;.gb;.gbc;.gba;.sg;.md;.pce;

Be sure to use quotation marks for "[romfilename]"



<Advanced topic 1 - Using other emulator than MESS in Mess.bat>
By using GOTO statement, you can choose other emulators as well.
For example, SNES implementation in MESS is not quite satisfactory. Let's use ZSNES emulator for .smc.

------------------------------------------------
if "%~x1"==".sms"   SET MACHINE=smsj
...
if "%~x1"==".md"   SET MACHINE=megadrij
if "%~x1"==".smc"   GOTO SNES

cd /d "C:\Emuls\Mess 0.152\"
mess.exe %MACHINE% -cart %1
GOTO END

:SNES
cd /d "C:\Emuls\zsnesw151\"
zsnesw.exe %1
GOTO END

:END
------------------------------------------------

You can practically add/change any emulator which supports command-line options.
(And almost every emulators supports command-line options)


<Advanced topic 2 - Using CD-ROM based games in Mess.bat>
With sufficient trial-and-error process, you can even use CD-ROM based games in Mess.bat as well.
It's quite complicated, so if anyone is interested in this, please let me know.


raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 371
    • View Profile
Re: Batch file scripting guide for Attract-mode (Basic)
« Reply #1 on: June 27, 2014, 10:28:53 PM »
Thanks for this checkist.

It looks like setting things up for MESS can get out of hand pretty quickly when you have a bunch of systems.  I wonder if there is anything else the frontend could be doing to better support multi-system MESS setups... any ideas?

cools

  • Full Member
  • ***
  • Posts: 61
    • View Profile
Re: Batch file scripting guide for Attract-mode (Basic)
« Reply #2 on: July 05, 2014, 01:38:01 AM »
If you're using mess software lists (and auditing roms against them) then attract mode works flawlessly already, checkists stuff above is useful if you're not.