Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace switch-case statement with config file for better management #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
DEPRECATED: the config file feature was ported to [ElRojo/MiSTerRFID](https://github.com/ElRojo/MisTerRFID)
---
Forked from: [javiwwweb/MisTerRFID](https://github.com/javiwwweb/MisTerRFID)

I replaced the big switch-case statement with a config file. This could pave the way to a more efficient way of managing the bank of RFID-game list.
Please note that, inside the config file, RFID and ROM are separated with a TAB.

Note: I didn't fork https://github.com/ElRojo/MisTerRFID because it searches for the switch-case code, but it would be nice to make it evolve to just add the new RFID into the config file.

CAUTION: I couldn't test the new code on a real MisTer because I don't own the RFID hardware needed. I just tested the code on a Linux machine to verify it tries to run the good rom.
I'd like to submit this new code to the original repository to have it tested then integrated into the repository of javiwwweb.

# MisTerRFID
Enables RFID card launching of games for MiSTer FPGA. Launches games without any menu being display using the MiSTer Game Launcher files (MGL) method. Must use a version of MiSTer from Feb 24, 2022 or after to support this method of launching. I have confirmed this working with all Arcade and Neo Geo cores.

Expand Down Expand Up @@ -37,10 +49,10 @@ The HEX 0x03 control the gain. In my case that was the value that would penetrat
On your computer, attach the serial monitor to your Arduino and you should see it repeating `. rfid_process.sh noscan` about every second. As soon as your scan a RFID card, it should output `. rfid_process.sh 12345678`. The number is that card's unique ID. The reader will not scan the same card two times in a row. Make note of the card's unique id.

## MiSTer Setup
Copy the files to your MiSTer SD card based on the structure of this repo. Edit case statement of the "rfid_process.sh" script to associate your RFID card UIDs with the roms files on your MiSTer. (Sample cores and UID's are provided in the file)
Copy the files to your MiSTer SD card based on the structure of this repo. Edit the file "games_rfid.conf" to associate your RFID card UIDs with the roms files on your MiSTer. (Sample cores and UID's are provided in the file)

## Use
After editing the rfid_process.sh script, turn off your MiSTer. Plug your Arduino into an available USB port on your USB board module and turn on your MiSTer. Depending on how many scripts you have running, it can take up to 30 seconds from first turning on the power to the RFID reader becoming available. Once the RFID reader is available, you can scan your RFID card to launch any core.
After copying and editing the files, turn off your MiSTer. Plug your Arduino into an available USB port on your USB board module and turn on your MiSTer. Depending on how many scripts you have running, it can take up to 30 seconds from first turning on the power to the RFID reader becoming available. Once the RFID reader is available, you can scan your RFID card to launch any core.

Note: This can be combined with MisTer.ini option bootcore= to automatically launch an arcade core (MRA file) upon starting up your MisTer. The rfid_process.sh will run in the background waiting for a card to be presented.

Expand Down
19 changes: 19 additions & 0 deletions fat/media/Scripts/games_rfid.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
2208192798 echo load_core /media/fat/_Arcade/'Robocop (World revision 4).mra' > /dev/MiSTer_cmd
1944463134 echo load_core /media/fat/_Arcade/'Final Fight -World, set 1-.mra' > /dev/MiSTer_cmd
2212386078 echo load_core /media/fat/_Arcade/'Ghosts'\''n Goblins (JT).mra' > /dev/MiSTer_cmd
3841642020 echo load_core /media/fat/_Arcade/'Double Dragon.mra' > /dev/MiSTer_cmd
2788154149 echo load_core /media/fat/_Arcade/'Double Dragon II - The Revenge.mra' > /dev/MiSTer_cmd
2785325093 echo load_core /media/fat/_Arcade/'Kung-Fu Master.mra' > /dev/MiSTer_cmd
2532548645 echo load_core /media/fat/_Arcade/'Shinobi (Set 6, World, S16A) [No Protection].mra' > /dev/MiSTer_cmd
3571898404 echo load_core /media/fat/_Arcade/'R-Type (World).mra' > /dev/MiSTer_cmd
3836830500 echo load_core /media/fat/_Arcade/'Vigilante (World, Rev E).mra' > /dev/MiSTer_cmd
4095029796 echo load_core /media/fat/_Arcade/'Bad Dudes vs. Dragonninja (US revision 1).mra' > /dev/MiSTer_cmd
4100998436 echo load_core /media/fat/_Arcade/"Ghouls'n Ghosts -World-.mra" > /dev/MiSTer_cmd
4095293732 echo load_core /media/fat/_Arcade/'Rush'\''n Attack (US).mra' > /dev/MiSTer_cmd
4097148196 echo load_core /media/fat/_Arcade/'Altered Beast (set 8) (8751 317-0078).mra' > /dev/MiSTer_cmd
3841431588 echo load_core /media/fat/_Arcade/'Golden Axe (set 6, US) (8751 317-123A).mra' > /dev/MiSTer_cmd
3570877988 echo load_core /media/fat/_Arcade/"Street Fighter II' Hyper Fighting -World 921209-.mra" > /dev/MiSTer_cmd
2793426725 echo load_core /media/fat/_Arcade/'Rastan (World Rev 1).mra' > /dev/MiSTer_cmd
2790045733 qload_rom NEOGEO mslugx "$1"
3837547300 qload_rom NEOGEO samsho2 "$1"
1107764546 qload_rom SNES DK1.sfc "$1"
44 changes: 24 additions & 20 deletions fat/media/Scripts/rfid_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ qload_rom()
fi
}

case "$1" in
"2208192798") echo load_core /media/fat/_Arcade/'Robocop (World revision 4).mra' > /dev/MiSTer_cmd;;
"1944463134") echo load_core /media/fat/_Arcade/'Final Fight -World, set 1-.mra' > /dev/MiSTer_cmd;;
"2212386078") echo load_core /media/fat/_Arcade/'Ghosts'\''n Goblins (JT).mra' > /dev/MiSTer_cmd;;
"3841642020") echo load_core /media/fat/_Arcade/'Double Dragon.mra' > /dev/MiSTer_cmd;;
"2788154149") echo load_core /media/fat/_Arcade/'Double Dragon II - The Revenge.mra' > /dev/MiSTer_cmd;;
"2785325093") echo load_core /media/fat/_Arcade/'Kung-Fu Master.mra' > /dev/MiSTer_cmd;;
"2532548645") echo load_core /media/fat/_Arcade/'Shinobi (Set 6, World, S16A) [No Protection].mra' > /dev/MiSTer_cmd;;
"3571898404") echo load_core /media/fat/_Arcade/'R-Type (World).mra' > /dev/MiSTer_cmd;;
"3836830500") echo load_core /media/fat/_Arcade/'Vigilante (World, Rev E).mra' > /dev/MiSTer_cmd;;
"4095029796") echo load_core /media/fat/_Arcade/'Bad Dudes vs. Dragonninja (US revision 1).mra' > /dev/MiSTer_cmd;;
"4100998436") echo load_core /media/fat/_Arcade/"Ghouls'n Ghosts -World-.mra" > /dev/MiSTer_cmd;;
"4095293732") echo load_core /media/fat/_Arcade/'Rush'\''n Attack (US).mra' > /dev/MiSTer_cmd;;
"4097148196") echo load_core /media/fat/_Arcade/'Altered Beast (set 8) (8751 317-0078).mra' > /dev/MiSTer_cmd;;
"3841431588") echo load_core /media/fat/_Arcade/'Golden Axe (set 6, US) (8751 317-123A).mra' > /dev/MiSTer_cmd;;
"3570877988") echo load_core /media/fat/_Arcade/"Street Fighter II' Hyper Fighting -World 921209-.mra" > /dev/MiSTer_cmd;;
"2793426725") echo load_core /media/fat/_Arcade/'Rastan (World Rev 1).mra' > /dev/MiSTer_cmd;;
"2790045733") qload_rom NEOGEO mslugx "$1";;
"3837547300") qload_rom NEOGEO samsho2 "$1";;
esac
unset gamefound
while read -r line
do
#echo "$line"
rfid=`echo "$line" | cut -f1`
game=`echo "$line" | cut -f2`
#echo "rfid=$rfid game=$game"
if [ "x$rfid" == "x$1" ]
then
#echo "RFID $rfid found in $line"
gamefound=$game
break
fi
done </media/fat/Scripts/games_rfid.conf

if [ "x$gamefound" == "x" ]
then
echo "RFID tag not found into config file..."
return
fi

echo "Running: $gamefound"
eval $gamefound