Contents
-
Installing the Operating System on the Raspberry Pi
-
Installing Dependencies on the Raspberry Pi
-
Folder and File Structure
-
Raspberry Pi Scripts
-
mostrar_rom_wrapper.sh -
recibir_rom.sh
-
-
systemd Service Setup
-
Windows Configuration to Send ROM Name
-
launch_rom_with_image.batScript -
CoinOPS Emulator Configuration
-
-
How It Works - Workflow
-
Final Notes
1. Installing the Operating System on the Raspberry Pi
-
Download and install Raspberry Pi OS Lite (recommended for this project).
-
Perform initial setup (Wi-Fi, user account, password).
-
Update system packages:
sudo apt update && sudo apt upgrade -y
2. Installing Dependencies on the Raspberry Pi
Install necessary tools:
sudo apt install fbi socat nmap -y
-
fbi: used to display images on the console
-
socat: to listen for TCP connections
-
nmap: includes
ncatwhich will be used on Windows to send data
3. Folder and File Structure
/home/arcade/ ├── caratulas/ │ ├── logo.jpg # Default logo image │ ├── aliens.jpg # Example image for ROM "aliens" │ └── other_roms.jpg # Other ROM images ├── mostrar_rom_debug.log # Debug log file /usr/local/bin/ ├── recibir_rom.sh # Script to receive ROM name and display image ├── mostrar_rom_wrapper.sh # Script that displays image based on ROM name /etc/systemd/system/ └── recibir_rom.service # systemd service to run recibir_rom.sh
4. Raspberry Pi Scripts
mostrar_rom_wrapper.sh
#!/bin/bash
ROM="$1"
ROM=${ROM//\"/} # Remove quotes from the received name
DEBUG_LOG="/home/arcade/mostrar_rom_debug.log"
TTY="/dev/tty1"
CARATULAS="/home/arcade/caratulas"
IMG="$CARATULAS/${ROM}.jpg"
LOGO="$CARATULAS/logo.jpg"
FBI_PID_FILE="/tmp/fbi_logo.pid"
# Stop the current fbi image if running
if [[ -f "$FBI_PID_FILE" ]]; then FBI_PID=$(cat "$FBI_PID_FILE") sudo kill "$FBI_PID" 2>/dev/null rm -f "$FBI_PID_FILE"
fi
# Show the ROM image or logo if not found
if [[ -f "$IMG" ]]; then echo "$(date) Received: $ROM → $IMG" >> "$DEBUG_LOG" sudo fbi -T 1 -noverbose -a "$IMG" > /dev/null 2>&1 &
else echo "$(date) Image not found: $IMG. Showing logo." >> "$DEBUG_LOG" if [[ -f "$LOGO" ]]; then sudo fbi -T 1 -noverbose -a "$LOGO" > /dev/null 2>&1 & fi
fi
recibir_rom.sh
#!/bin/bash PORT=12345 LOGO="/home/arcade/caratulas/logo.jpg" TTY="/dev/tty1" FBI_PID_FILE="/tmp/fbi_logo.pid" # Wait for the system to finish booting (prevents logo from disappearing) sleep 5 # Show the initial logo with fbi if [[ -f "$LOGO" ]]; then sudo fbi -T 1 -noverbose -a "$LOGO" > /dev/null 2>&1 & echo $! > "$FBI_PID_FILE" fi # Listen for new ROM names on TCP port socat TCP-LISTEN:$PORT,reuseaddr,fork SYSTEM:'/usr/local/bin/mostrar_rom_wrapper.sh $(cat)'
5. systemd Service Setup
Create file /etc/systemd/system/recibir_rom.service with:
[Unit] Description=Service to receive ROM names and show their images After=network.target [Service] ExecStart=/usr/local/bin/recibir_rom.sh Restart=always User=root [Install] WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable recibir_rom.service sudo systemctl start recibir_rom.service
6. Windows Configuration to Send ROM Name
launch_rom_with_image.bat
@echo off set ROM_NAME=%1 :: Local log echo Sent: %ROM_NAME% >> c:\temp\rom_debug.log :: Send the ROM name to the Raspberry Pi echo %ROM_NAME% | "C:\Program Files (x86)\Nmap\ncat.exe" 192.168.1.138 12345 :: Launch the emulator and wait for it to close "E:\Deluxe 4x3\emulators\mame\mame64nocfg.exe" %1 -rompath "E:\Deluxe 4x3\emulators\mame\roms" :: After closing the emulator, show the logo again echo logo | "C:\Program Files (x86)\Nmap\ncat.exe" 192.168.1.138 12345 echo Sent: logo (after exiting game) >> c:\temp\rom_debug.log
CoinOPS (RetroFE) Emulator Configuration
In the emulator config file, for example mame.conf:
executable = E:\Deluxe 4x3\scripts\launch_rom_with_image.bat arguments = "%ITEM_NAME%" LEDBlinkyEmulator = mame
7. How It Works - Workflow
-
When the Raspberry Pi boots, it displays
logo.jpgand starts listening on TCP port 12345. -
When you select a game in CoinOPS on Windows, it runs the batch script which sends the ROM name to the Raspberry Pi.
-
The Raspberry Pi receives the ROM name and shows the corresponding image (like
aliens.jpg), or the default logo if no image is found. -
The emulator starts running the selected game.
-
When the emulator closes, the batch script sends the "logo" command to show the default logo image again.
8. Final Notes
-
Ensure
/home/arcade/caratulascontains all your JPG images named exactly as the ROM names. -
The debug log on the Raspberry Pi at
/home/arcade/mostrar_rom_debug.logis very helpful for troubleshooting. -
Install Nmap on Windows to get
ncat.exeat the path used in the script or adjust paths accordingly. -
Make sure the paths in the batch script and emulator config reflect your actual installation locations.
-
The script removes quotation marks from ROM names to avoid issues when received from CoinOPS.
SrRubio
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.