# System-Specific Scripts Directory This directory contains custom processing scripts for each gaming system supported by the ROM Groomer. These scripts are automatically called during **Step 5** of the ROM organization workflow. ## How It Works During Step 5 of the workflow, the main processor looks for a script named `custom-{SYSTEM}.sh` in this directory. If found and executable, it will be run with the following environment variables available: - `SYSTEM`: The system name (e.g., `nes`, `sega32x`, `psx`) - `FILTER`: The filter type (e.g., `all`, `usa`, `english`) - `ORGSYSTEMDIR`: Path to the organization directory for this system - `FILTERSYSTEMDIR`: Path to the filtered ROMs directory - `SOURCESYSTEMDIR`: Path to the source ROMs directory - `STAGESYSTEMDIR`: Path to the staging directory for this system - `SHARESYSTEMDIR`: Path to the share directory for this system ## Available Scripts The following system-specific scripts are available (all start as stubs): ### Nintendo Systems - `custom-nes.sh` - Nintendo Entertainment System - `custom-snes.sh` - Super Nintendo Entertainment System - `custom-n64.sh` - Nintendo 64 - `custom-gb.sh` - Game Boy - `custom-gbc.sh` - Game Boy Color - `custom-gba.sh` - Game Boy Advance - `custom-nds.sh` - Nintendo DS - `custom-3ds.sh` - Nintendo 3DS ### Sega Systems - `custom-mastersystem.sh` - Sega Master System - `custom-megadrive.sh` - Sega Mega Drive / Genesis - `custom-sega32x.sh` - Sega 32X - `custom-segacd.sh` - Sega CD - `custom-saturn.sh` - Sega Saturn - `custom-dreamcast.sh` - Sega Dreamcast - `custom-gamegear.sh` - Sega Game Gear - `custom-sg1000.sh` - Sega SG-1000 ### Atari Systems - `custom-atari2600.sh` - Atari 2600 - `custom-atari5200.sh` - Atari 5200 - `custom-atari7800.sh` - Atari 7800 - `custom-jaguar.sh` - Atari Jaguar - `custom-lynx.sh` - Atari Lynx ### Sony Systems - `custom-psx.sh` - Sony PlayStation - `custom-psp.sh` - Sony PlayStation Portable - `custom-pspminis.sh` - PSP Minis ### Other Systems - `custom-3do.sh` - 3DO Interactive Multiplayer - `custom-colecovision.sh` - ColecoVision - `custom-ngp.sh` - Neo Geo Pocket - `custom-ngpc.sh` - Neo Geo Pocket Color - `custom-pcengine.sh` - PC Engine / TurboGrafx-16 - `custom-pcenginecd.sh` - PC Engine CD / TurboGrafx-CD - `custom-vectrex.sh` - Vectrex - `custom-virtualboy.sh` - Virtual Boy ## Common Use Cases Here are examples of what you might want to implement in these scripts: ### Multi-Disc Games For systems like PlayStation, Sega CD, PC Engine CD: ```bash # Group multi-disc games into subdirectories # Convert between disc formats (BIN/CUE to CHD) # Validate disc images and cue sheets ``` ### Region-Specific Processing ```bash # Apply NTSC/PAL-specific processing # Convert between regional ROM formats # Handle region-specific naming conventions ``` ### Format Conversion ```bash # Convert archives (ZIP to 7Z) # Convert disc images (BIN/CUE to CHD) # Compress ROMs for space efficiency ``` ### Validation and Cleanup ```bash # Verify ROM checksums # Remove duplicate files # Fix file naming inconsistencies # Validate ROM headers ``` ### System-Specific Metadata ```bash # Extract and process system-specific metadata # Generate playlists or catalogs # Create thumbnail images # Process save files or memory cards ``` ## Getting Started 1. **Choose a system** you want to customize (e.g., `psx` for PlayStation) 2. **Edit the script** `custom-psx.sh` 3. **Replace the stub code** with your custom processing 4. **Test your script** by running a build for that system 5. **Check the logs** to verify your script executed correctly ## Example Implementation Here's an example of a simple custom script for PlayStation: ```bash #!/bin/bash # ... header comments ... # Load shared libraries source "${SCRIPT_DIR}/../config.sh" source "${SCRIPT_DIR}/../logger.sh" source "${SCRIPT_DIR}/../utils.sh" log "INFO" "Executing custom PlayStation processing" # Convert BIN/CUE files to CHD format for space efficiency if command -v chdman >/dev/null 2>&1; then log "INFO" "Converting PlayStation disc images to CHD format" find "$ORGSYSTEMDIR" -name "*.cue" | while read -r cuefile; do local baseName=$(basename "$cuefile" .cue) local dirName=$(dirname "$cuefile") local chdFile="$dirName/$baseName.chd" if [ ! -f "$chdFile" ]; then log "INFO" "Converting: $baseName" chdman createcd -i "$cuefile" -o "$chdFile" if [ $? -eq 0 ]; then log "INFO" "Successfully converted $baseName to CHD" # Optionally remove original files # rm "$cuefile" "${cuefile%.*}.bin" fi fi done else log "WARN" "chdman not found - skipping CHD conversion" fi log "INFO" "PlayStation custom processing completed" exit 0 ``` ## Notes - All scripts start as **stubs** that just log they were called - Scripts must be **executable** (`chmod +x`) to be run - Scripts have access to all **shared utilities** (logger.sh, utils.sh, config.sh) - Scripts should **exit 0** on success or non-zero on failure - Use the **logging functions** to provide feedback during processing - Test your scripts thoroughly before using in production