My testing with this is with Mala, but I've heard that it happens in other front-ends too. So putting it here for more visibility.
Ok, so one problem I've had with my setup is with some of the Taito X games. The problem is the front-end (Mala in my case) having a screwed up layout or other oddities when exiting the game. I even
asked about it before, but nobody had the answer.
So what causes this? Well, most of my Taito X games are launched using the command "typex_loader.exe game.exe" or similar. What happens is typex_loader.exe gets game.exe running, and then typex_loader.exe exits while game.exe runs.
The problem is, the front end watches for the executable it called to end, before going back to normal operation. So typex_loader.exe exits and the front-end resumes. The problem is, game.exe is still running.
One way I used to get around it is putting a pause in the batch routine after the game. That way, it keeps the batch routine open, and the front end won't resume until the batch routine closes. (By the way, here the batch routine has the same problem as above: once typex_loader.exe closes, the routine continues.)
echo Don't press any joysticks or buttons until the game loads.
echo After you quit the game, pressing any button to return
echo to the Mala Frontend.
pause
Not, the problem is that the big DOS prompt looks out of place on an arcade machine. Kinda looks tacky. Also, because I have to have the prompt open for people to read, I can't have any of the games in that list minimized or hidden (even if they work normally). DOS boxes everywhere.
After some looking, I found what I think is a good solution. Still using batch routines, I found out how to monitor for a specific program, and keep the batch routine running in a loop until that program closes.
@echo off
REM [any pre-stuff, like keyboard encoder programming, goes here]
REM /d [path] "[executable only]" "[arguments for executable]"
START "" /d G:\PC_Arcade\BBCS "typex_loader.exe" "game.exe"
REM timeout for game to start
Timeout /T 5 /Nobreak >nul 2>&1
:LOOP
REM Executable to monitor, like "GAME", goes in quotes here.
tasklist | find /i "GAME" >nul 2>&1
IF ERRORLEVEL 1 (
GOTO CONTINUE
) ELSE (
Timeout /T 1 /Nobreak >nul 2>&1
GOTO LOOP
)
:CONTINUE
REM [post stuff, like resetting encoder to default, goes here.]
This will run the game as before, but once every second, it checks to see if "game.exe" is running in memory. If it's still running, it waits a second and then returns to the top of the loop, checking again. Once game.exe closes, the routine goes to the "continue" part.
This can be tested by using ALT-TAB while the game is runing. You can then see the batch routine is still open. If you stick a "echo Game Running" in the loop (right before or after the TIMEOUT command), you can see that line displayed again and again once a second. (Please note that most of these games aren't designed for task switching, and the game will have to be closed from task manager if you ALT-TAB out of it.)
If you edit this file for your setup, change the path to your Taito_X game on the "START" line. If the game is one that uses launcher.exe, make sure to change "game" to "launcher" in the "tasklist" line too. I've tried to label everything, so it can be easily modified as needed (such as programming keyboard encoders).
Hopefully this will help people out with not just Taito_X, but any other games or programs that do something like this too.
Uploaded a copy of the batch file (had to change extension to .txt to upload it. Just change it back to .bat)