@echo off

REM - Move to the folder this script is in
cd /D "%~dp0"

REM - Set the filenames according to the emulator type
set "conf=.\dosbox-x.conf"
set "emu=.\dosbox-x.exe"

REM - Set the regex string for finding the previously run game
set "game_old_regex=th.{2,3}.hdi"

REM - Set the new game chosen
set "game_new=%1.hdi"

REM - Replace the game on the config file
call jrepl "%game_old_regex%" "%game_new%" /f "%conf%" /o -

REM - Run the emulator
start "" "%emu%"
