Close

Display Game Images on Raspberry Pi When Selecting Games in CoinOPS

A project log for THE ULTIMATE MINI ARCADE

Classic arcade with all the latest technological advancements, ready for the classics. Enjoy!

srrubioSrRubio 07/30/2025 at 12:220 Comments

Contents

  1. Installing the Operating System on the Raspberry Pi

  2. Installing Dependencies on the Raspberry Pi

  3. Folder and File Structure

  4. Raspberry Pi Scripts

    • mostrar_rom_wrapper.sh

    • recibir_rom.sh

  5. systemd Service Setup

  6. Windows Configuration to Send ROM Name

    • launch_rom_with_image.bat Script

    • CoinOPS Emulator Configuration

  7. How It Works - Workflow

  8. Final Notes

1. Installing the Operating System on the Raspberry Pi



sudo apt update && sudo apt upgrade -y


2. Installing Dependencies on the Raspberry Pi

Install necessary tools:



sudo apt install fbi socat nmap -y


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

  1. When the Raspberry Pi boots, it displays logo.jpg and starts listening on TCP port 12345.

  2. When you select a game in CoinOPS on Windows, it runs the batch script which sends the ROM name to the Raspberry Pi.

  3. The Raspberry Pi receives the ROM name and shows the corresponding image (like aliens.jpg), or the default logo if no image is found.

  4. The emulator starts running the selected game.

  5. When the emulator closes, the batch script sends the "logo" command to show the default logo image again.

8. Final Notes

Discussions