Full Code of farmerbb/RED-Project for AI

master d3580d43c8c7 cached
12 files
135.2 KB
49.6k tokens
1 requests
Download .txt
Repository: farmerbb/RED-Project
Branch: master
Commit: d3580d43c8c7
Files: 12
Total size: 135.2 KB

Directory structure:
gitextract_h3mx0wvj/

├── README.md
└── ROM Extraction/
    ├── arcade1up-extract.sh
    ├── arcade1up-pinball-extract.sh
    ├── contra-ac-extract.sh
    ├── decompress-sr-files.sh
    ├── generate-timing-rom.sh
    ├── konami-xbla-extract.sh
    ├── midway-arcade-origins-extract.sh
    ├── namco-ags-extract.sh
    ├── rpf-extract.sh
    ├── super-bomberman-extract.sh
    └── tmnt-cc-arcade-extract.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
## ROM Extraction Documentation Project

### **[Enter the RED-Project Wiki](https://github.com/farmerbb/RED-Project/wiki)**

-------------

### About

Emulation is a great way to experience classic gaming from many different generations, as well as to preserve games and consoles that otherwise would be lost to time.  However, obtaining ROMs to run in emulators is often associated with the stigma of piracy and other illegal acts, which can be a turnoff for a lot of people to get into retro game emulation.

The **ROM Extraction Documentation Project (RED-Project)** serves to be a repository of information and tools for legally obtaining ROMs from various products, such as game compilations and mini consoles, with clear and easy to follow documentation to (hopefully) make it as easy as possible to ethically source your own ROMs to run on any compatible emulator.


================================================
FILE: ROM Extraction/arcade1up-extract.sh
================================================
#!/bin/bash

ROM_LIST=(
  DigDugII.rom
  DigDug.rom
  Galaga.rom
  Galaga88.sav
  Galaxian.rom
  Mappy.rom
  MsPacMan.rom
  PacandPal.rom
  PacLand.rom
  PacMania.sav
  PacMania.org.sav
  PacManPlus.rom
  PacMan.rom
  RallyX.rom
  Rompers.sav
  RT-COLOR.rom
  SuperPacMan.rom
  SuperXevious.rom
  TheTowerofDruaga.rom
  Xevious.rom
)

MD5_LIST=(
  327b6cd567e2d060cb4fe77d424fc56f # Firmware.img
  375f370f96f3b6f033a474bc7b10fa66 # Firmware.img
  459a8b91dcae47304330660660e98364 # Super PacMan Firmware.img
  5c8b642828dac046a4678670c70a1518 # BlackPacMan_8274_firmware.img
  67a8fe555e714f4cc9ef4712b9731dec # MsPacMan_10Game_Patch.img
  7546bcafa9e5af795f816d116f58b27b # Ms_PacMan_8220_Firmware.img
  7dfe07760360a76f35c51e8ac48fc54c # Ms_PacMan_8262_Firmware.img
  ac20288a86bd85cb2a6e928b559499f2 # Ms_PacMan_8266_Firmware.img
  c898f2ed3bb288d9f9c0007f04796568 # Mega Man Firmware.img
  e1e3d98b6b41b39658a421f7e180832c # Ms_PacMan_8267_Firmware.img
)

GAMES_DIR_LIST=(
  games
  Games
  moo
)

extract-rom() {
  WORKING_FILE=$1
  case $1 in
    DigDugII.rom)
      extract-file d21_3.1d $((0x0))     $((0x4000))
      extract-file d21_1.1b $((0x4000))  $((0x4000))
      extract-file d21_4.1k $((0x8000))  $((0x2000))
      extract-file d21_5.3b $((0xA000))  $((0x1000))
      extract-file d21_6.3m $((0xB000))  $((0x4000))
      extract-file d21_7.3n $((0xF000))  $((0x4000))
      extract-file d21-5.5b $((0x13000)) $((0x20))
      extract-file d2x-7.5k $((0x13020)) $((0x100))
      extract-file d21-6.4c $((0x13120)) $((0x100))
      extract-file d21-3.3m $((0x13220)) $((0x100))
      package-zip  digdug2o.zip
    ;;

    DigDug.rom)
      check-variant 1 8d3be278355f9f6213bfc2641768efb1
      check-variant 2 c304db795e14e43d0863f50353f289f3
      extract-file dd1a.1     $((0x0))    $((0x1000))
      extract-file dd1a.2     $((0x1000)) $((0x1000))
      extract-file dd1a.3     $((0x2000)) $((0x1000))
      extract-file dd1a.4     $((0x3000)) $((0x1000))
      extract-file dd1a.5     $((0x4000)) $((0x1000))
      extract-file dd1a.6     $((0x5000)) $((0x1000))
      extract-file dd1.7      $((0x6000)) $((0x1000))
      extract-file dd1.9      $((0x7000)) $((0x800))
      extract-file dd1.11     $((0x7800)) $((0x1000))
      extract-file dd1.15     $((0x8800)) $((0x1000))
      extract-file dd1.14     $((0x9800)) $((0x1000))
      extract-file dd1.13     $((0xA800)) $((0x1000))
      extract-file dd1.12     $((0xB800)) $((0x1000))
      extract-file dd1.10b    $((0xC800)) $((0x1000))
      extract-file 136007.113 $((0xD800)) $((0x20))
      extract-file 136007.112 $((0xD820)) $((0x100))
      extract-file 136007.111 $((0xD920)) $((0x100))
      extract-file 136007.110 $((0xDA20)) $((0x100))
      dummy-file   136007.109             $((0x100))
      package-zip  digdug.zip
    ;;

    Galaga.rom)
      check-unusable && (
        extract-file gg1_1b.3p $((0x0))    $((0x1000))
        extract-file gg1_2b.3m $((0x1000)) $((0x1000))
        extract-file gg1_3.2m  $((0x2000)) $((0x1000))
        extract-file gg1_4b.2l $((0x3000)) $((0x1000))
        extract-file gg1_5b.3f $((0x4000)) $((0x1000))
        extract-file gg1_7b.2c $((0x5000)) $((0x1000))
        extract-file gg1_9.4l  $((0x6000)) $((0x1000))
        extract-file gg1_11.4d $((0x7000)) $((0x1000))
        extract-file gg1_10.4f $((0x8000)) $((0x1000))
        extract-file prom-5.5n $((0x9000)) $((0x20))
        extract-file prom-3.1c $((0x9020)) $((0x100))
        extract-file prom-4.2n $((0x9120)) $((0x100))
        extract-file prom-1.1d $((0x9220)) $((0x100))
        dummy-file   prom-2.5c             $((0x100))
        package-zip  galaga.zip
      )
    ;;

    Galaga88.sav)
      copy-file   cus64-64a1.mcu NS1-MCU.rom
      copy-file   g8_chr-0.bin   G8-CHR0.rom
      copy-file   g8_chr-1.bin   G8-CHR1.rom
      copy-file   g8_chr-2.bin   G8-CHR2.rom
      copy-file   g8_chr-3.bin   G8-CHR3.rom
      copy-file   g8_chr-8.bin   G8-CHR8.rom
      copy-file   g8_obj-0.bin   G8-OBJ0.rom
      copy-file   g8_obj-1.bin   G8-OBJ1.rom
      copy-file   g8_obj-2.bin   G8-OBJ2.rom
      copy-file   g8_obj-3.bin   G8-OBJ3.rom
      copy-file   g8_obj-4.bin   G8-OBJ4.rom
      copy-file   g8_obj-5.bin   G8-OBJ5.rom
      copy-file   g81_p0.bin     G8-PRG0.rom
      copy-file   g81_p1.bin     G8-PRG1.rom
      copy-file   g81_p5.bin     G8-PRG5.rom
      copy-file   g82_p6.bin     G8-PRG6.rom
      copy-file   g82_p7.bin     G8-PRG7.rom
      copy-file   g81_s0.bin     G8-SND0.rom
      copy-file   g81_s1.bin     G8-SND1.rom
      copy-file   g81_v0.bin     G8-VOI0.rom
      copy-file   g81_v1.bin     G8-VOI1.rom
      copy-file   g81_v2.bin     G8-VOI2.rom
      copy-file   g81_v3.bin     G8-VOI3.rom
      copy-file   g81_v4.bin     G8-VOI4.rom
      copy-file   g81_v5.bin     G8-VOI5.rom
      package-zip galaga88.zip
    ;;

    Galaxian.rom)
      extract-file galmidw.u $((0x0))    $((0x800))
      extract-file galmidw.v $((0x800))  $((0x800))
      extract-file galmidw.w $((0x1000)) $((0x800))
      extract-file galmidw.y $((0x1800)) $((0x800))
      extract-file 7l        $((0x2000)) $((0x800))
      extract-file 1h.bin    $((0x2800)) $((0x800))
      extract-file 1k.bin    $((0x3000)) $((0x800))
      extract-file 6l.bpr    $((0x3800)) $((0x20))
      package-zip  galaxian.zip
    ;;

    Mappy.rom)
      check-variant 1 598e8efde55b08ab5c9370315e4c5c64
      check-variant 2 a26d20ec53af00c48b365021728a498b
      extract-file mpx_3.1d $((0x0))    $((0x2000))
      extract-file mp1_2.1c $((0x2000)) $((0x2000))
      extract-file mpx_1.1b $((0x4000)) $((0x2000))
      extract-file mp1_4.1k $((0x6000)) $((0x2000))
      extract-file mp1_5.3b $((0x8000)) $((0x1000))
      extract-file mp1_6.3m $((0x9000)) $((0x2000))
      extract-file mp1_7.3n $((0xB000)) $((0x2000))
      extract-file mp1-5.5b $((0xD000)) $((0x20))
      extract-file mp1-7.5k $((0xD020)) $((0x100))
      extract-file mp1-6.4c $((0xD120)) $((0x100))
      extract-file mp1-3.3m $((0xD220)) $((0x100))
      package-zip  mappy.zip
    ;;

    MsPacMan.rom)
      check-variant 1 e8fa67dc354487ecaead5185f702ac58
      check-variant 2 fd6567dc1ad03f04646908365edcef60
      extract-file boot1     $((0x0))    $((0x1000))
      extract-file boot2     $((0x1000)) $((0x1000))
      extract-file boot3     $((0x2000)) $((0x1000))
      extract-file boot4     $((0x3000)) $((0x1000))
      extract-file boot5     $((0x4000)) $((0x1000))
      extract-file boot6     $((0x5000)) $((0x1000))
      extract-file 5e        $((0x6000)) $((0x1000))
      extract-file 5f        $((0x7000)) $((0x1000))
      extract-file 82s123.7f $((0x8000)) $((0x20))
      extract-file 82s126.4a $((0x8020)) $((0x100))
      extract-file 82s126.1m $((0x8120)) $((0x100))
      dummy-file   82s126.3m             $((0x100))
      package-zip  mspacmab.zip
    ;;

    PacandPal.rom)
      extract-file pap1-3b.1d $((0x0))    $((0x2000))
      extract-file pap1-2b.1c $((0x2000)) $((0x2000))
      extract-file pap3-1.1b  $((0x4000)) $((0x2000))
      extract-file pap1-4.1k  $((0x6000)) $((0x1000))
      extract-file pap1-6.3c  $((0x7000)) $((0x1000))
      extract-file pap1-5.3f  $((0x8000)) $((0x2000))
      extract-file pap1-6.4c  $((0xA000)) $((0x20))
      extract-file pap1-4.3l  $((0xA020)) $((0x100))
      extract-file pap1-5.4e  $((0xA120)) $((0x100))
      extract-file pap1-3.3m  $((0xA220)) $((0x100))
      package-zip  pacnpal.zip
    ;;

    PacLand.rom)
      check-variant 1 5df503b74b0be44ffa1ca0cede81f5f0
      check-variant 2 097f7ce6874bdee73a722e52a38d57e1
      extract-file pl5_01b.8b     $((0x0))     $((0x4000))
      extract-file pl5_02.8d      $((0x4000))  $((0x4000))
      extract-file pl1_3.8e       $((0x8000))  $((0x4000))
      extract-file pl1_4.8f       $((0xC000))  $((0x4000))
      extract-file pl1_5.8h       $((0x10000)) $((0x4000))
      extract-file pl3_6.8j       $((0x14000)) $((0x4000))
      extract-file pl1_7.3e       $((0x18000)) $((0x2000))
      extract-file cus60-60a1.mcu $((0x1A000)) $((0x1000))
      extract-file pl2_12.6n      $((0x1B000)) $((0x2000))
      extract-file pl4_13.6t      $((0x1D000)) $((0x2000))
      extract-file pl1-9.6f       $((0x1F000)) $((0x4000))
      extract-file pl1-8.6e       $((0x23000)) $((0x4000))
      extract-file pl1-10.7e      $((0x27000)) $((0x4000))
      extract-file pl1-11.7f      $((0x2B000)) $((0x4000))
      extract-file pl1-2.1t       $((0x2F000)) $((0x400))
      extract-file pl1-1.1r       $((0x2F400)) $((0x400))
      extract-file pl1-5.5t       $((0x2F800)) $((0x400))
      extract-file pl1-4.4n       $((0x2FC00)) $((0x400))
      extract-file pl1-3.6l       $((0x30000)) $((0x400))
      package-zip  pacland.zip
    ;;

    PacMania.sav | PacMania.org.sav)
      check-variant 1 4e48337a4605a54a20a47cbbcc49472d
      check-variant 2 122164d8b0b341eca98960b0ac0f3c58
      copy-file   cus64-64a1.mcu NS1-MCU.rom
      copy-file   pn_chr-0.bin   PM-CHR0.rom
      copy-file   pn_chr-1.bin   PM-CHR1.rom
      copy-file   pn_chr-2.bin   PM-CHR2.rom
      copy-file   pn_chr-3.bin   PM-CHR3.rom
      copy-file   pn2_c8.bin     PM-CHR8.rom
      copy-file   pn_obj-0.bin   PM-OBJ0.rom
      copy-file   pnx_obj1.bin   PM-OBJ1.rom
      copy-file   pn_prg-6.bin   PM-PRG6.rom
      copy-file   pn2_p7.bin     PM-PRG7.rom
      copy-file   pn2_s0.bin     PM-SND0.rom
      copy-file   pn2_s1.bin     PM-SND1.rom
      copy-file   pn2_v0.bin     PM-VOI0.rom
      package-zip pacmania.zip
    ;;

    PacManPlus.rom | PacMan.rom)
      extract-file pacman.6e $((0x0))    $((0x1000))
      extract-file pacman.6f $((0x1000)) $((0x1000))
      extract-file pacman.6h $((0x2000)) $((0x1000))
      extract-file pacman.6j $((0x3000)) $((0x1000))
      extract-file pacman.5e $((0x4000)) $((0x1000))
      extract-file pacman.5f $((0x5000)) $((0x1000))
      extract-file 82s123.7f $((0x6000)) $((0x20))
      extract-file 82s126.4a $((0x6020)) $((0x100))
      extract-file 82s126.1m $((0x6120)) $((0x100))
      dummy-file   82s126.3m             $((0x100))

      [[ $1  = *Plus* ]] && package-zip pacman.plus.zip
      [[ $1 != *Plus* ]] && package-zip pacman.zip
    ;;

    RallyX.rom)
      extract-file 1b         $((0x0))    $((0x1000))
      extract-file rallyxn.1e $((0x1000)) $((0x1000))
      extract-file rallyxn.1h $((0x2000)) $((0x1000))
      extract-file rallyxn.1k $((0x3000)) $((0x1000))
      extract-file 8e         $((0x4000)) $((0x1000))
      extract-file rx1-1.11n  $((0x5000)) $((0x20))
      extract-file rx1-7.8p   $((0x5020)) $((0x100))
      extract-file rx1-5.3p   $((0x5120)) $((0x100))
      extract-file rx1-6.8m   $((0x5220)) $((0x100))
      dummy-file   rx1-3.7k               $((0x20))
      dummy-file   rx1-4.2m               $((0x100))
      dummy-file   rx1-2.4n               $((0x20))
      package-zip  rallyx.zip
    ;;

    RT-COLOR.rom)
      extract-file rt1-1.3r       $((0x0))    $((0x200))
      extract-file rt1-2.3s       $((0x200))  $((0x200))
      extract-file rt1-3.4v       $((0x400))  $((0x800))
      extract-file rt1-4.5v       $((0xC00))  $((0x800))
      extract-file rt1-5.6u       $((0x1400)) $((0x20))
      copy-file    cus60-60a1.mcu NS86MCU.rom
      copy-file    rt1_7.7r       RT-CHR0.rom
      copy-file    rt1_8.7s       RT-CHR1.rom
      copy-file    rt1_5.4r       RT-CHR2.rom
      copy-file    rt1_6.4s       RT-CHR3.rom
      copy-file    rt3_1b.9c      RT-MPR0.rom
      copy-file    rt1_17.f1      RT-MPR1.rom
      copy-file    rt1_18.h1      RT-MPR2.rom
      copy-file    rt3_19.k1      RT-MPR3.rom
      copy-file    rt3_20.m1      RT-MPR4.rom
      copy-file    rt1_9.12h      RT-OBJ0.rom
      copy-file    rt1_10.12k     RT-OBJ1.rom
      copy-file    rt1_11.12l     RT-OBJ2.rom
      copy-file    rt1_12.12m     RT-OBJ3.rom
      copy-file    rt1_13.12p     RT-OBJ4.rom
      copy-file    rt1_14.12r     RT-OBJ5.rom
      copy-file    rt1_15.12t     RT-OBJ6.rom
      copy-file    rt1_16.12u     RT-OBJ7.rom
      copy-file    rt3_2b.12c     RT-SPR0.rom
      copy-file    rt3_3.12d      RT-SPR1.rom
      copy-file    rt1_21.f3      RT-VOI0.rom
      copy-file    rt2_22.h3      RT-VOI1.rom
      copy-file    rt3_4.6b       RT-XMCU.rom
      package-zip  rthunder.zip
    ;;

    Rompers.sav)
      copy-file   cus64-64a1.mcu NS1-MCU.rom
      copy-file   rp_chr-0.bin   RO-CHR0.rom
      copy-file   rp_chr-1.bin   RO-CHR1.rom
      copy-file   rp_chr-2.bin   RO-CHR2.rom
      copy-file   rp_chr-3.bin   RO-CHR3.rom
      copy-file   rp1_chr8.bin   RO-CHR8.rom
      copy-file   rp_obj-0.bin   RO-OBJ0.rom
      copy-file   rp_obj-1.bin   RO-OBJ1.rom
      copy-file   rp_obj-2.bin   RO-OBJ2.rom
      copy-file   rp_obj-3.bin   RO-OBJ3.rom
      copy-file   rp_obj-4.bin   RO-OBJ4.rom
      copy-file   rp1_obj5.bin   RO-OBJ5.rom
      copy-file   rp1_obj6.bin   RO-OBJ6.rom
      copy-file   rp1_prg4.bin   RO-PRG4.rom
      copy-file   rp1_prg5.bin   RO-PRG5.rom
      copy-file   rp1prg6b.bin   RO-PRG6.rom
      copy-file   rp1prg7b.bin   RO-PRG7.rom
      copy-file   rp1_snd0.bin   RO-SND0.rom
      copy-file   rp_voi-0.bin   RO-VOI0.rom
      package-zip rompers.zip
    ;;

    SuperPacMan.rom)
      extract-file sp1-2.1c    $((0x0))    $((0x2000))
      extract-file sp1-1.1b    $((0x2000)) $((0x2000))
      extract-file spc-3.1k    $((0x4000)) $((0x1000))
      extract-file sp1-6.3c    $((0x5000)) $((0x1000))
      extract-file spv-2.3f    $((0x6000)) $((0x2000))
      extract-file superpac.4c $((0x8000)) $((0x20))
      extract-file superpac.3l $((0x8020)) $((0x100))
      extract-file superpac.4e $((0x8120)) $((0x100))
      extract-file superpac.3m $((0x8220)) $((0x100))
      package-zip  superpac.zip
    ;;

    SuperXevious.rom)
      check-unusable && (
        check-variant 1 772f5eb270295738b53126f776285386
        check-variant 2 cb300927c3d905edfdfd2afbd4dbf089
        extract-file cpu_3p.rom $((0x0))    $((0x1000))
        extract-file cpu_3m.rom $((0x1000)) $((0x1000))
        extract-file xv3_3.2m   $((0x2000)) $((0x1000))
        extract-file xv3_4.2l   $((0x3000)) $((0x1000))
        extract-file xv3_5.3f   $((0x4000)) $((0x1000))
        extract-file xv3_6.3j   $((0x5000)) $((0x1000))
        xevious-shared
        package-zip  sxevious.zip
      )
    ;;

    TheTowerofDruaga.rom)
      extract-file td2_3.1d $((0x0))    $((0x4000))
      extract-file td2_1.1b $((0x4000)) $((0x4000))
      extract-file td1_4.1k $((0x8000)) $((0x2000))
      extract-file td1_5.3b $((0xA000)) $((0x1000))
      extract-file td1_6.3m $((0xB000)) $((0x2000))
      extract-file td1_7.3n $((0xD000)) $((0x2000))
      extract-file td1-5.5b $((0xF000)) $((0x20))
      extract-file td1-7.5k $((0xF020)) $((0x400))
      extract-file td1-6.4c $((0xF420)) $((0x100))
      extract-file td1-3.3m $((0xF520)) $((0x100))
      package-zip  todruaga.zip
    ;;

    Xevious.rom)
      check-unusable && (
        check-variant 1 99a8fa5752e95a6f09173bb1e55a8ef4
        check-variant 2 1d6eb62c695c82f01b5d00ce000c179f
        extract-file xvi_1.3p  $((0x0))     $((0x1000))
        extract-file xvi_2.3m  $((0x1000))  $((0x1000))
        extract-file xvi_3.2m  $((0x2000))  $((0x1000))
        extract-file xvi_4.2l  $((0x3000))  $((0x1000))
        extract-file xvi_5.3f  $((0x4000))  $((0x1000))
        extract-file xvi_6.3j  $((0x5000))  $((0x1000))
        xevious-shared
        package-zip  xevious.zip
      )
    ;;
  esac
}

xevious-shared() {
  extract-file xvi_7.2c  $((0x6000))  $((0x1000))
  extract-file xvi_9.2a  $((0x7000))  $((0x1000))
  extract-file xvi_10.2b $((0x8000))  $((0x2000))
  extract-file xvi_11.2c $((0xA000))  $((0x1000))
  extract-file xvi_12.3b $((0xB000))  $((0x1000))
  extract-file xvi_13.3c $((0xC000))  $((0x1000))
  extract-file xvi_14.3d $((0xD000))  $((0x1000))
  extract-file xvi_15.4m $((0xE000))  $((0x2000))
  extract-file xvi_17.4p $((0x10000)) $((0x2000))
  extract-file xvi_16.4n $((0x12000)) $((0x1000))
  extract-file xvi_18.4r $((0x13000)) $((0x2000))
  dummy-file   xvi-1.5n               $((0x100))

  FILESIZE=$(stat -c%s "$WORKING_FILE")
  if [[ $FILESIZE = 89088 ]]; then
    extract-file xvi-8.6a  $((0x15000)) $((0x100))
    extract-file xvi-9.6d  $((0x15100)) $((0x100))
    extract-file xvi-10.6e $((0x15200)) $((0x100))
    extract-file xvi-7.4h  $((0x15300)) $((0x200))
    extract-file xvi-6.4f  $((0x15500)) $((0x200))
    extract-file xvi-4.3l  $((0x15700)) $((0x200))
    extract-file xvi-5.3m  $((0x15900)) $((0x200))
    extract-file xvi-2.7n  $((0x15B00)) $((0x100))
  fi

  if [[ $FILESIZE = 88064 ]]; then
    # TODO last 2048 bytes are unusable (or encrypted) data.
    # Figure out how to extract properly (if possible)
    true
  fi
}

extract-file() {
  dd if="$WORKING_FILE" of="$WORKING_DIR/roms/$1" skip=$2 count=$3 status=none iflag=skip_bytes,count_bytes
}

copy-file() {
  dd if="$2" of="$WORKING_DIR/roms/$1" status=none
}

dummy-file() {
  dd if=/dev/zero of="$WORKING_DIR/roms/$1" count=$2 status=none iflag=count_bytes
}

package-zip() {
  cd "$WORKING_DIR/roms"
  zip -q "$WORKING_DIR/zips/$1" *
  rm *
  cd "$GAMES_DIR"
}

check-variant() {
  [[ "$WORKING_FILE" = *.sav ]] && FILE_TO_CHECK=PM-CHR0.rom
  [[ "$WORKING_FILE" = *.rom ]] && FILE_TO_CHECK="$WORKING_FILE"
  MD5=$(md5sum "$FILE_TO_CHECK" | cut -d" " -f1)
  [[ $MD5 = $2 ]] && echo "Note: extracting variant #$1 of $WORKING_FILE"
}

check-unusable() {
  [[ $EXTRACT_ALL != 1 ]] && return 1
  [[ $EXTRACT_ALL = 1 ]] && \
    echo "Note: $WORKING_FILE produces an unusable ROM" && return 0
}

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

missing-dependency-awimage() {
  echo "This script requires awimage to be installed."
  echo "Please place awimage in the same directory as this script, then try again."
  echo
  echo "awimage can be compiled from: https://github.com/Ithamar/awutils"
  echo
  exit 1
}

print-usage() {
  echo "$1"
  echo
  echo "Usage: $0 <firmware-image> [-a]"
  echo
  echo "  <firmware-image> is the path to a firmware image from"
  echo "  the \"Updater\" folder of the firmware update zip file."
  echo
  echo "  -a option extracts all ROMs, including unusable ones."
  exit 1
}

#####################################################################################

[[ $# -eq 0 || $1 = "--help" || $1 = "-h" ]] && \
  print-usage "Extracts arcade and NES ROMs from Arcade1Up firmware images."

IMG_PATH=$(realpath "$1")
[[ ! -f "$IMG_PATH" ]] && print-usage "Firmware image path is incorrect."
[[ $(head -c8 "$IMG_PATH" | grep IMAGEWTY) = IMAGEWTY ]] && IS_ALLWINNER_IMAGE=1
[[ $2 = "-a" ]] && EXTRACT_ALL=1

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))
[[ $IS_ALLWINNER_IMAGE = 1 ]] && \
  [[ ! -f "$SCRIPT_DIR/awimage" ]] && \
  missing-dependency-awimage

[[ -z $(which guestmount) ]] && missing-dependency libguestfs-tools
[[ -z $(which zip) ]] && missing-dependency zip

echo "Verifying firmware..."
IMG_MD5=$(md5sum "$IMG_PATH" | cut -d" " -f1)

for i in ${MD5_LIST[@]}; do
  [[ $i = $IMG_MD5 ]] && VERIFIED=1
done

if [[ $VERIFIED != 1 ]]; then
  echo
  echo "Firmware image is not verified to work with this script."
  echo "You may continue to run it, but it may not work as expected."
  echo "Press Enter to continue or CTRL+C to quit..."
  read _
fi

echo "Initializing directories..."
WORKING_DIR=/tmp/.arcade1up
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/mnt"
mkdir -p "$WORKING_DIR/roms"
mkdir -p "$WORKING_DIR/zips"

START_DIR="$PWD"
cd "$WORKING_DIR"

if [[ $IS_ALLWINNER_IMAGE = 1 ]]; then
  echo "Extracting firmware image using awimage..."
  cp "$SCRIPT_DIR/awimage" .
  chmod +x awimage
  ./awimage "$IMG_PATH" firmware >/dev/null 2>&1

  echo "Mounting firmware image using guestmount..."
  guestmount -a firmware/RFSFAT16_ROOTFS_FEX000000 -m /dev/sda --ro mnt
else
  echo "Mounting firmware image using guestmount..."
  guestmount -a "$IMG_PATH" -m /dev/sda5 --ro mnt
fi

echo "Locating games inside firmware image..."
for i in ${GAMES_DIR_LIST[@]}; do
  [[ -d mnt/$i ]] && GAMES_DIR="$WORKING_DIR/mnt/$i"
done

cd "$GAMES_DIR"
[[ -f MegaMan.nes ]] && for i in *.nes; do
  echo "Extracting $i..." && cp "$i" "$WORKING_DIR/zips"
done

for i in ${ROM_LIST[@]}; do
  [[ -f $i ]] && echo "Extracting $i..." && extract-rom $i
done

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/zips"/* .
umount "$WORKING_DIR/mnt"
rm -r "$WORKING_DIR"
rm -r /var/tmp/.guestfs-$UID

echo "Done!"


================================================
FILE: ROM Extraction/arcade1up-pinball-extract.sh
================================================
#!/bin/bash

MD5_LIST=(
  22bb217596afc85943cf62a0df311013 # 20210830_pinball_wms_release_1920x1080_1G-5b.img
  3267505d90c55bae87d742c9152b4fa6 # 20210830_pinball_swp_release_1920x1080_1G-5b.img
  766c35a29838f22fdc74002223f42be7 # 20210830_pinball_mvp_release_1920x1080_1G-5b.img
)

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

missing-dependency-awimage() {
  echo "This script requires awimage to be installed."
  echo "Please place awimage in the same directory as this script, then try again."
  echo
  echo "awimage can be compiled from: https://github.com/Ithamar/awutils"
  echo
  exit 1
}

print-usage() {
  echo "$1"
  echo
  echo "Usage: $0 <firmware-image>"
  echo
  echo "  <firmware-image> is the path to a firmware image from"
  echo "  the firmware update zip file."
  exit 1
}

#####################################################################################

[[ $# -eq 0 || $1 = "--help" || $1 = "-h" ]] && \
  print-usage "Extracts APKs from Arcade1Up pinball firmware images."

IMG_PATH=$(realpath "$1")
[[ ! -f "$IMG_PATH" ]] && print-usage "Firmware image path is incorrect."
[[ $(head -c8 "$IMG_PATH" | grep IMAGEWTY) != IMAGEWTY ]] && \
  print-usage "Specified file is not a valid Allwinner firmware image."

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))
[[ ! -f "$SCRIPT_DIR/awimage" ]] && missing-dependency-awimage
[[ -z $(which simg2img) ]] && missing-dependency simg2img
[[ -z $(which guestmount) ]] && missing-dependency libguestfs-tools

echo "Verifying firmware..."
IMG_MD5=$(md5sum "$IMG_PATH" | cut -d" " -f1)

for i in ${MD5_LIST[@]}; do
  [[ $i = $IMG_MD5 ]] && VERIFIED=1
done

if [[ $VERIFIED != 1 ]]; then
  echo
  echo "Firmware image is not verified to work with this script."
  echo "You may continue to run it, but it may not work as expected."
  echo "Press Enter to continue or CTRL+C to quit..."
  read _
fi

echo "Initializing directories..."
WORKING_DIR=/tmp/.arcade1up
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/mnt"
mkdir -p "$WORKING_DIR/apks"

START_DIR="$PWD"
cd "$WORKING_DIR"

echo "Extracting firmware image using awimage..."
cp "$SCRIPT_DIR/awimage" .
chmod +x awimage
./awimage "$IMG_PATH" firmware >/dev/null 2>&1

echo "Unsparsifying firmware image using simg2img..."
simg2img firmware/RFSFAT16_SYSTEM_FEX000000 firmware/raw.img

echo "Mounting firmware image using guestmount..."
guestmount -a firmware/raw.img -m /dev/sda --ro mnt

echo "Locating games inside firmware image..."
cd "$WORKING_DIR/mnt/app"
for i in MVP SWP WMS; do
  [[ -f "$i/$i.apk" ]] && echo "Extracting $i.apk..." && cp "$i/$i.apk" "$WORKING_DIR/apks"
done

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/apks"/* .
umount "$WORKING_DIR/mnt"
rm -r "$WORKING_DIR"
rm -r /var/tmp/.guestfs-$UID

echo "Done!"


================================================
FILE: ROM Extraction/contra-ac-extract.sh
================================================
#!/bin/bash

MD5_LIST=(
  d9255086fadc4179b9298e7e9d9787bc
)

extract-rom() {
  WORKING_FILE="$EXE_PATH"

  extract-file      633i02.17a            $((0x27ED60)) $((0x10000))
  extract-file      633i03.18a-1          $((0x28ED60)) $((0x8000))
  extract-file      633e01.12a            $((0x296DD0)) $((0x8000))
  extract-file      633f10.18g            $((0x29EDD0)) $((0x100))
  extract-file      633e09.12g            $((0x2BEED0)) $((0x100))
  extract-file      633f11.20g            $((0x2BEED0)) $((0x100))
  extract-file      633e08.10g            $((0x2BEFD0)) $((0x100))
  extract-file      633i03.18a-2          $((0x2D70D0)) $((0x8000))
  extract-file      633e06.16d+633e07.16f $((0x2E71D0)) $((0x80000))
  extract-file      633e04.7d+633e05.7f   $((0x3671D0)) $((0x80000))
  concatenate-files 633i03.18a
  deinterleave-file 633e06.16d+633e07.16f
  deinterleave-file 633e04.7d+633e05.7f
  package-zip       contra1.zip

  extract-file      633e01.12a            $((0x296DD0)) $((0x8000))
  extract-file      633f10.18g            $((0x29EDD0)) $((0x100))
  extract-file      633e09.12g            $((0x2BEED0)) $((0x100))
  extract-file      633f11.20g            $((0x2BEED0)) $((0x100))
  extract-file      633e08.10g            $((0x2BEFD0)) $((0x100))
  extract-file      633k02.17a            $((0x2BF0D0)) $((0x10000))
  extract-file      633n03.18a-1          $((0x2CF0D0)) $((0x8000))
  extract-file      633n03.18a-2          $((0x2DF0D0)) $((0x8000))
  extract-file      633e06.16d+633e07.16f $((0x2E71D0)) $((0x80000))
  extract-file      633e04.7d+633e05.7f   $((0x3671D0)) $((0x80000))
  concatenate-files 633n03.18a
  deinterleave-file 633e06.16d+633e07.16f
  deinterleave-file 633e04.7d+633e05.7f
  package-zip       contraj.zip

  extract-file      633e01.12a            $((0x296DD0)) $((0x8000))
  extract-file      633f10.18g            $((0x29EDD0)) $((0x100))
  extract-file      633g3.17a             $((0x29EED0)) $((0x10000))
  extract-file      633g2.18a             $((0x2AEED0)) $((0x10000))
  extract-file      633e09.12g            $((0x2BEED0)) $((0x100))
  extract-file      633f11.20g            $((0x2BEED0)) $((0x100))
  extract-file      633e08.10g            $((0x2BEFD0)) $((0x100))
  extract-file      633e06.16d+633e07.16f $((0x2E71D0)) $((0x80000))
  extract-file      633e04.7d+633e05.7f   $((0x3671D0)) $((0x80000))
  deinterleave-file 633e06.16d+633e07.16f
  deinterleave-file 633e04.7d+633e05.7f
  package-zip       gryzor1.zip

  check-unusable scontra.zip && (
    extract-file 775-e02.k11  $((0x467360)) $((0x10000))
    extract-file 775-e03.k13  $((0x477360)) $((0x10000))
    extract-file 775-c01.bin  $((0x487360)) $((0x8000))
    extract-file 775-a04a.11b $((0x4AF360)) $((0x10000))
    extract-file 775-a04b.10b $((0x4BF360)) $((0x10000)) # DAT mismatch
    extract-file 775-a04c.9b  $((0x4CF360)) $((0x10000))
    extract-file 775-a04d.8b  $((0x4DF360)) $((0x10000))
    extract-file 775-f04e.11a $((0x4EF360)) $((0x10000))
    extract-file 775-f04f.10a $((0x4FF360)) $((0x10000)) # DAT mismatch
    extract-file 775-f04g.9a  $((0x50F360)) $((0x10000))
    extract-file 775-f04h.8a  $((0x51F360)) $((0x10000))
    package-zip  scontra.zip
  )

  check-unusable scontraj.zip && (
    extract-file 775-c01.bin  $((0x487360)) $((0x8000))
    extract-file 775-f02.bin  $((0x48F360)) $((0x10000))
    extract-file 775-f03.bin  $((0x49F360)) $((0x10000))
    extract-file 775-a04a.bin $((0x4AF360)) $((0x10000))
    extract-file 775-a04b.bin $((0x4BF360)) $((0x10000)) # DAT mismatch
    extract-file 775-a04c.bin $((0x4CF360)) $((0x10000))
    extract-file 775-a04d.bin $((0x4DF360)) $((0x10000))
    extract-file 775-f04e.bin $((0x4EF360)) $((0x10000))
    extract-file 775-f04f.bin $((0x4FF360)) $((0x10000)) # DAT mismatch
    extract-file 775-f04g.bin $((0x50F360)) $((0x10000))
    extract-file 775-f04h.bin $((0x51F360)) $((0x10000))
    package-zip  scontraj.zip
  )
}

extract-file() {
  dd if="$WORKING_FILE" of="$WORKING_DIR/roms/$1" skip=$2 count=$3 status=none iflag=skip_bytes,count_bytes
}

deinterleave-file() {
  FILE1=$(echo $1 | cut -d+ -f1)
  FILE2=$(echo $1 | cut -d+ -f2)
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -deinterleave "$WORKING_DIR/roms/$1" "$WORKING_DIR/roms/$FILE1" "$WORKING_DIR/roms/$FILE2"
  rm "$WORKING_DIR/roms/$1"
}

concatenate-files() {
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -concat "$WORKING_DIR/roms/$1-1" "$WORKING_DIR/roms/$1-2" "$WORKING_DIR/roms/$1"
  rm "$WORKING_DIR/roms/$1-1"
  rm "$WORKING_DIR/roms/$1-2"
}

package-zip() {
  cd "$WORKING_DIR/roms"
  zip -q "$WORKING_DIR/zips/$1" *
  rm *
  cd "$SCRIPT_DIR"
}

check-unusable() {
  [[ $EXTRACT_ALL != 1 ]] && return 1
  [[ $EXTRACT_ALL = 1 ]] && \
    BASENAME=$(basename "$WORKING_FILE") && \
    echo "Note: $BASENAME produces an unusable ROM ($1)" && return 0
}

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

missing-dependency-tsromtool() {
  echo "This script requires ts_rom_tool.py to be installed."
  echo "Please place ts_rom_tool.py in the same directory as this script, then try again."
  echo
  echo "ts_rom_tool.py can be obtained from: https://github.com/twistedsymphony/ts_rom_tool"
  echo
  exit 1
}

print-usage() {
  echo "$1"
  echo
  echo "Usage: $0 <path-to-exe> [-a]"
  echo
  echo "  <path-to-exe> is the path to the \"game.exe\" file inside the game folder."
  echo "  Currently only the Steam version is supported."
  echo
  echo "  -a option extracts all ROMs, including unusable ones."
  exit 1
}

#####################################################################################

[[ $# -eq 0 || $1 = "--help" || $1 = "-h" ]] && \
  print-usage "Extracts arcade ROMs from the Contra Anniversary Collection."

EXE_PATH=$(realpath "$1")
[[ ! -f "$EXE_PATH" ]] && print-usage "EXE path is incorrect."
[[ $2 = "-a" ]] && EXTRACT_ALL=1

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))

[[ ! -f "$SCRIPT_DIR/ts_rom_tool.py" ]] && missing-dependency-tsromtool
[[ -z $(which zip) ]] && missing-dependency zip
[[ -z $(which python3) ]] && missing-dependency python3

echo "Verifying EXE..."
EXE_MD5=$(md5sum "$EXE_PATH" | cut -d" " -f1)

for i in ${MD5_LIST[@]}; do
  [[ $i = $EXE_MD5 ]] && VERIFIED=1
done

if [[ $VERIFIED != 1 ]]; then
  echo
  echo "This EXE is not verified to work with this script."
  echo "You may continue to run it, but it may not work as expected."
  echo "Press Enter to continue or CTRL+C to quit..."
  read _
fi

echo "Initializing directories..."
WORKING_DIR=/tmp/.contra-ac
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/roms"
mkdir -p "$WORKING_DIR/zips"

START_DIR="$PWD"
cd "$WORKING_DIR"

echo "Extracting $(basename "$EXE_PATH")..."
extract-rom

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/zips"/* .
rm -r "$WORKING_DIR"

echo "Done!"


================================================
FILE: ROM Extraction/decompress-sr-files.sh
================================================
#!/bin/bash

[[ ! -f offzip ]] && \
  echo "Please compile and place the offzip program in the current directory, alongside your SR files." && \
  echo "offzip can be downloaded from: http://aluigi.altervista.org/mytoolz/offzip.zip" && \
  exit 1

chmod +x ./offzip

for i in *.SR *.sr; do
  [[ ! -f $i ]] && continue

  echo "Decompressing $i..."
  DIR=$(echo $i | sed -e "s/.SR//" -e "s/.sr//")
  mkdir -p $DIR
  rm -rf $DIR/*

  NUM_OF_ENTRIES=$(strings $i | head -n1 | cut -d' ' -f1)
  INITIAL_OFFSET=$(strings $i | head -n1 | cut -d' ' -f3)

  FILENAMES=($(strings $i | tail -n +2 | head -n $NUM_OF_ENTRIES | awk '{$1=$1};1' | cut -d' ' -f6))
  OFFSETS=($(strings $i | tail -n +2 | head -n $NUM_OF_ENTRIES | awk '{$1=$1};1' | cut -d' ' -f1))
  SIZES=($(strings $i | tail -n +2 | head -n $NUM_OF_ENTRIES | awk '{$1=$1};1' | cut -d' ' -f2))

  for n in $(seq 0 $(($NUM_OF_ENTRIES - 1))); do
    dd if=$i of=$DIR/${FILENAMES[$n]} skip=$(($INITIAL_OFFSET + ${OFFSETS[$n]})) count=${SIZES[$n]} status=none iflag=skip_bytes,count_bytes
  done

  for ext in qz QZ; do
    [[ -n "$(find $DIR -maxdepth 1 -type f -name "*.$ext" -print -quit)" ]] || continue

    for qz in $(ls -1 $DIR/*.$ext); do
      ./offzip -Q -o -a $qz $DIR 0 > /dev/null
      mv $DIR/00000004.* $(echo $qz | sed "s/.$ext//") >/dev/null 2>&1 && rm $qz
    done
  done
done


================================================
FILE: ROM Extraction/generate-timing-rom.sh
================================================
#!/bin/bash

# Generates timing ROMs used in various Namco arcade games.
# Needed in order to get Xevious and Super Xevious working.

timing-rom() {
  ROM="$1"
  append-bytes '\x0F\x0D\x0F\x0F' 16 "$ROM"
  append-bytes '\x07'             1  "$ROM"
  append-bytes '\x0F\x0E\x0D\x0F' 5  "$ROM"
  append-bytes '\x0F\x0F\x0B\x07' 1  "$ROM"
  append-bytes '\x0F\x0E\x0D\x0F' 4  "$ROM"
  append-bytes '\x0F\x0F\x0B\x07' 1  "$ROM"
  append-bytes '\x0F\x0E\x0D\x0F' 4  "$ROM"
  append-bytes '\x0F\x0F\x0B'     1  "$ROM"
  truncate -s 256 "$ROM"
}

append-bytes() {
  for i in $(seq $2); do
    echo -n -e $1 >> "$3"
  done
}

[[ $# -eq 1 ]] && rm -f "$1" && timing-rom "$1"


================================================
FILE: ROM Extraction/konami-xbla-extract.sh
================================================
#!/bin/bash

ROM_LIST=(
  contra.rom
  Frogger.rom
  Gyruss.rom
  RushNAttack.rom
  Scramble.rom
  Supercontra.rom
  TimePilot.rom
  TrackAndField.rom
  YieArKungFu.rom
)

MD5_LIST=(
  094dc6223cb8da773f53d0e6ebdeb7aa # Contra
  10ff61c9f1e57239acf8a402ec9dfdb2 # Track and Field
  385164fe0eb34174ffd160ab98e4898d # Yie Ar Kung-Fu
  72566a62a16aebe5f42c183d10af0bcb # Scramble
  8f9f430355477cc9a480d8498b8221de # Time Pilot
  97af60f8bdf8c3785b027bb46dc52b4e # Super Contra
  9f2b8cbf6197a442e64213bc2c8d2d01 # Rush'n Attack
  b972e1c15c73eb00606e3b378a0e1c82 # Frogger
  ba6754ebc31c4a98eb303b314753aa46 # Gyruss
)

extract-rom() {
  WORKING_FILE=$1
  case $1 in
    contra.rom)
      extract-file      633i03.18a            $((0x0))      $((0x10000))
      extract-file      633i02.17a            $((0x10000))  $((0x10000))
      extract-file      633e01.12a            $((0x20000))  $((0x8000))
      extract-file      633e04.7d+633e05.7f   $((0x28000))  $((0x80000))
      extract-file      633e06.16d+633e07.16f $((0xA8000))  $((0x80000))
      extract-file      633e08.10g            $((0x128000)) $((0x100))
      extract-file      633e09.12g            $((0x128100)) $((0x100))
      extract-file      633f10.18g            $((0x128200)) $((0x100))
      extract-file      633f11.20g            $((0x128300)) $((0x100))
      deinterleave-file 633e04.7d+633e05.7f
      deinterleave-file 633e06.16d+633e07.16f
      package-zip       contra1.zip
    ;;

    Frogger.rom)
      extract-file frogger.26  $((0x0))    $((0x1000))
      extract-file frogger.27  $((0x1000)) $((0x1000))
      extract-file frsm3.7     $((0x2000)) $((0x1000))
      extract-file frogger.608 $((0x3000)) $((0x800))
      extract-file frogger.609 $((0x3800)) $((0x800))
      extract-file frogger.610 $((0x4000)) $((0x800))
      extract-file frogger.606 $((0x4800)) $((0x800))
      extract-file frogger.607 $((0x5000)) $((0x800))
      extract-file pr-91.6l    $((0x5800)) $((0x20))
      package-zip  frogger.zip
    ;;

    Gyruss.rom)
      extract-file gyrussk.1   $((0x0))     $((0x2000))
      extract-file gyrussk.2   $((0x2000))  $((0x2000))
      extract-file gyrussk.3   $((0x4000))  $((0x2000))
      extract-file gyrussk.1a  $((0x6000))  $((0x2000))
      extract-file gyrussk.2a  $((0x8000))  $((0x2000))
      extract-file gyrussk.9   $((0xA000))  $((0x2000))
      extract-file gyrussk.3a  $((0xC000))  $((0x1000))
      extract-file gyrussk.4   $((0xD000))  $((0x2000))
      extract-file gyrussk.6   $((0xF000))  $((0x2000))
      extract-file gyrussk.5   $((0x11000)) $((0x2000))
      extract-file gyrussk.8   $((0x13000)) $((0x2000))
      extract-file gyrussk.7   $((0x15000)) $((0x2000))
      extract-file gyrussk.pr3 $((0x17000)) $((0x20))
      extract-file gyrussk.pr1 $((0x17020)) $((0x100))
      extract-file gyrussk.pr2 $((0x17120)) $((0x100))
      package-zip  gyruss.zip
    ;;

    RushNAttack.rom)
      extract-file 577h03.10c   $((0x0))     $((0x4000))
      extract-file 577h02.8c    $((0x4000))  $((0x4000))
      extract-file 577h01.7c    $((0x8000))  $((0x4000))
      extract-file 577h07.3f    $((0xC000))  $((0x4000))
      extract-file 577l06.5e    $((0x10000)) $((0x4000))
      extract-file 577h05.4e    $((0x14000)) $((0x4000))
      extract-file 577l08.4f    $((0x18000)) $((0x4000))
      extract-file 577l04.3e    $((0x1C000)) $((0x4000))
      extract-file 577h09.2f    $((0x20000)) $((0x20))
      extract-file 577h10.5f    $((0x20020)) $((0x100))
      extract-file 577h11.6f    $((0x20120)) $((0x100))
      package-zip  rushatck.zip
    ;;

    Scramble.rom)
      extract-file s1.2d        $((0x0))    $((0x800))
      extract-file s2.2e        $((0x0800)) $((0x800))
      extract-file s3.2f        $((0x1000)) $((0x800))
      extract-file s4.2h        $((0x1800)) $((0x800))
      extract-file s5.2j        $((0x2000)) $((0x800))
      extract-file s6.2l        $((0x2800)) $((0x800))
      extract-file s7.2m        $((0x3000)) $((0x800))
      extract-file s8.2p        $((0x3800)) $((0x800))
      extract-file ot1.5c       $((0x4000)) $((0x800))
      extract-file ot2.5d       $((0x4800)) $((0x800))
      extract-file ot3.5e       $((0x5000)) $((0x800))
      extract-file c2.5f        $((0x5800)) $((0x800))
      extract-file c1.5h        $((0x6000)) $((0x800))
      extract-file c01s.6e      $((0x6800)) $((0x20))
      package-zip  scramble.zip
    ;;

    Supercontra.rom)
      extract-file            775-e02.k11                                       $((0x0))      $((0x10000))
      extract-file            775-e03.k13                                       $((0x10000))  $((0x10000))
      extract-file            775-c01.bin                                       $((0x20000))  $((0x8000))
      extract-file            775-a08e.3f+775-a08a.4f+775-a07e.5f+775-a07a.6f   $((0x28000))  $((0x80000))
      extract-file            775-f08g.3d+775-f08c.4d+775-f07g.5d+775-f07c.6d   $((0xA8000))  $((0x40000))
      extract-file            775-f08h.7c+775-f08d.7d+775-f07h.7e+775-f07d.7f   $((0xE8000))  $((0x40000))
      extract-file            775-a05a.11f+775-a05e.10f+775-a06a.9f+775-a06e.8f $((0x128000)) $((0x40000))
      extract-file            775-a05b.11e+775-a05f.10e+775-a06b.9e+775-a06f.8e $((0x168000)) $((0x40000))
      extract-file            775-f05c.11d+775-f05g.10d+775-f06c.9d+775-f06g.8d $((0x1A8000)) $((0x40000))
      extract-file            775-f05d.11c+775-f05h.10c+775-f06d.9c+775-f06h.8c $((0x1E8000)) $((0x40000))
      extract-file            775-a04a.11b                                      $((0x228000)) $((0x10000))
      extract-file            775-a04b.10b                                      $((0x238000)) $((0x10000))
      extract-file            775-a04c.9b                                       $((0x248000)) $((0x10000))
      extract-file            775-a04d.8b                                       $((0x258000)) $((0x10000))
      extract-file            775-f04e.11a                                      $((0x268000)) $((0x10000))
      extract-file            775-f04f.10a                                      $((0x278000)) $((0x10000))
      extract-file            775-f04g.9a                                       $((0x288000)) $((0x10000))
      extract-file            775-f04h.8a                                       $((0x298000)) $((0x10000))
      dummy-file              775a09.b19                                                      $((0x100))
      deinterleave-file-32bit 775-a08e.3f+775-a08a.4f+775-a07e.5f+775-a07a.6f
      deinterleave-file-32bit 775-f08g.3d+775-f08c.4d+775-f07g.5d+775-f07c.6d
      deinterleave-file-32bit 775-f08h.7c+775-f08d.7d+775-f07h.7e+775-f07d.7f
      deinterleave-file-32bit 775-a05a.11f+775-a05e.10f+775-a06a.9f+775-a06e.8f
      deinterleave-file-32bit 775-a05b.11e+775-a05f.10e+775-a06b.9e+775-a06f.8e
      deinterleave-file-32bit 775-f05c.11d+775-f05g.10d+775-f06c.9d+775-f06g.8d
      deinterleave-file-32bit 775-f05d.11c+775-f05h.10c+775-f06d.9c+775-f06h.8c
      package-zip             scontra.zip
    ;;

    TimePilot.rom)
      extract-file tm1         $((0x0))    $((0x2000))
      extract-file tm2         $((0x2000)) $((0x2000))
      extract-file tm3         $((0x4000)) $((0x2000))
      extract-file tm7         $((0x6000)) $((0x1000))
      extract-file tm6         $((0x7000)) $((0x2000))
      extract-file tm4         $((0x9000)) $((0x2000))
      extract-file tm5         $((0xB000)) $((0x2000))
      extract-file timeplt.b4  $((0xD000)) $((0x20))
      extract-file timeplt.b5  $((0xD020)) $((0x20))
      extract-file timeplt.e9  $((0xD040)) $((0x100))
      extract-file timeplt.e12 $((0xD140)) $((0x100))
      package-zip  timeplt.zip
    ;;

    TrackAndField.rom)
      extract-file a01_e01.bin  $((0x0))     $((0x2000))
      extract-file a02_e02.bin  $((0x2000))  $((0x2000))
      extract-file a03_k03.bin  $((0x4000))  $((0x2000))
      extract-file a04_e04.bin  $((0x6000))  $((0x2000))
      extract-file a05_e05.bin  $((0x8000))  $((0x2000))
      extract-file c2_d13.bin   $((0xA000))  $((0x2000))
      extract-file h16_e12.bin  $((0xC000))  $((0x2000))
      extract-file h15_e11.bin  $((0xE000))  $((0x2000))
      extract-file h14_e10.bin  $((0x10000)) $((0x2000))
      extract-file c11_d06.bin  $((0x12000)) $((0x2000))
      extract-file c12_d07.bin  $((0x14000)) $((0x2000))
      extract-file c13_d08.bin  $((0x16000)) $((0x2000))
      extract-file c14_d09.bin  $((0x18000)) $((0x2000))
      extract-file 361b16.f1    $((0x1A000)) $((0x20))
      extract-file 361b17.b16   $((0x1A020)) $((0x100))
      extract-file 361b18.e15   $((0x1A120)) $((0x100))
      extract-file c9_d15.bin   $((0x1A220)) $((0x2000))
      package-zip  trackfld.zip
    ;;

    YieArKungFu.rom)
      extract-file 407_i08.10d $((0x0))     $((0x4000))
      extract-file 407_i07.8d  $((0x4000))  $((0x4000))
      extract-file 407_c01.6h  $((0x8000))  $((0x2000))
      extract-file 407_c02.7h  $((0xA000))  $((0x2000))
      extract-file 407_d05.16h $((0xC000))  $((0x4000))
      extract-file 407_d06.17h $((0x10000)) $((0x4000))
      extract-file 407_d03.14h $((0x14000)) $((0x4000))
      extract-file 407_d04.15h $((0x18000)) $((0x4000))
      extract-file 407c10.1g   $((0x1C000)) $((0x20))
      extract-file 407_c09.8b  $((0x1C020)) $((0x2000))
      package-zip  yiear.zip
    ;;
  esac
}

extract-file() {
  dd if="$WORKING_FILE" of="$WORKING_DIR/roms/$1" skip=$2 count=$3 status=none iflag=skip_bytes,count_bytes
}

dummy-file() {
  dd if=/dev/zero of="$WORKING_DIR/roms/$1" count=$2 status=none iflag=count_bytes
}

deinterleave-file() {
  FILE1=$(echo $1 | cut -d+ -f1)
  FILE2=$(echo $1 | cut -d+ -f2)
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -deinterleave "$WORKING_DIR/roms/$1" "$WORKING_DIR/roms/$FILE1" "$WORKING_DIR/roms/$FILE2"
  rm "$WORKING_DIR/roms/$1"
}

deinterleave-file-32bit() {
  FILE1_32BIT=$(echo $1 | cut -d+ -f1)
  FILE2_32BIT=$(echo $1 | cut -d+ -f2)
  FILE3_32BIT=$(echo $1 | cut -d+ -f3)
  FILE4_32BIT=$(echo $1 | cut -d+ -f4)

  mv "$WORKING_DIR/roms/$1" "$WORKING_DIR/roms/1and3+2and4"
  deinterleave-file 1and3+2and4

  mv "$WORKING_DIR/roms/1and3" "$WORKING_DIR/roms/$FILE1_32BIT+$FILE3_32BIT"
  deinterleave-file $FILE1_32BIT+$FILE3_32BIT

  mv "$WORKING_DIR/roms/2and4" "$WORKING_DIR/roms/$FILE2_32BIT+$FILE4_32BIT"
  deinterleave-file $FILE2_32BIT+$FILE4_32BIT
}

package-zip() {
  cd "$WORKING_DIR/roms"
  zip -q "$WORKING_DIR/zips/$1" *
  rm *
  cd "$SCRIPT_DIR"
}

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

missing-dependency-tsromtool() {
  echo "This script requires ts_rom_tool.py to be installed."
  echo "Please place ts_rom_tool.py in the same directory as this script, then try again."
  echo
  echo "ts_rom_tool.py can be obtained from: https://github.com/twistedsymphony/ts_rom_tool"
  echo
  exit 1
}

missing-dependency-extract360() {
  echo "This script requires extract360.py to be installed."
  echo "Please place extract360.py in the same directory as this script, then try again."
  echo
  echo "extract360.py can be obtained from: https://github.com/rene0/xbox360"
  echo
  exit 1
}

print-usage() {
  echo "$1"
  echo
  echo "Usage: $0 <path-to-game> [-a]"
  echo
  echo "  <path-to-game> is the path to the XBLA game copied from your console."
  echo "  These can be found on your USB drive within the \"Content\" directory."
  echo
  echo "  -a option extracts all ROMs, including unusable ones."
  exit 1
}

#####################################################################################

[[ $# -eq 0 || $1 = "--help" || $1 = "-h" ]] && \
  print-usage "Extracts arcade ROMs from Konami XBLA games."

STFS_PATH=$(realpath "$1")
[[ ! -f "$STFS_PATH" ]] && print-usage "XBLA game path is incorrect."
[[ $2 = "-a" ]] && EXTRACT_ALL=1

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))

[[ ! -f "$SCRIPT_DIR/ts_rom_tool.py" ]] && missing-dependency-tsromtool
[[ ! -f "$SCRIPT_DIR/extract360.py" ]] && missing-dependency-extract360
[[ -z $(which zip) ]] && missing-dependency zip
[[ -z $(which python2) ]] && missing-dependency python2
[[ -z $(which python3) ]] && missing-dependency python3

echo "Verifying file..."
STFS_MD5=$(dd if="$STFS_PATH" skip=$((0x971A)) status=none iflag=skip_bytes | md5sum | cut -d" " -f1)

for i in ${MD5_LIST[@]}; do
  [[ $i = $STFS_MD5 ]] && VERIFIED=1
done

if [[ $VERIFIED != 1 ]]; then
  echo
  echo "This XBLA title is not verified to work with this script."
  echo "You may continue to run it, but it may not work as expected."
  echo "Press Enter to continue or CTRL+C to quit..."
  read _
fi

echo "Initializing directories..."
WORKING_DIR=/tmp/.konami-xbla
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/roms"
mkdir -p "$WORKING_DIR/zips"

START_DIR="$PWD"
cd "$WORKING_DIR"

if [[ $EXTRACT_ALL != 1 && $STFS_MD5 = ba6754ebc31c4a98eb303b314753aa46 ]]; then
  echo
  echo "Unfortunately, Gyruss is not usable with emulators. If you would"
  echo "like to extract it anyway, re-run this script with the [-a] option."
  echo

  rm -r "$WORKING_DIR"
  exit 1
fi

echo "Extracting STFS container..."
cp "$STFS_PATH" stfs
python2 "$SCRIPT_DIR/extract360.py" stfs >/dev/null 2>&1

cd stfs.dir/classic
for i in ${ROM_LIST[@]}; do
  [[ -f $i ]] && echo "Extracting $i..." && extract-rom $i
done

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/zips"/* .
rm -r "$WORKING_DIR"

echo "Done!"


================================================
FILE: ROM Extraction/midway-arcade-origins-extract.sh
================================================
#!/bin/bash

extract-file() {
  dd if=$1 skip=$3 count=$4 status=none iflag=skip_bytes,count_bytes >> roms/$2
}

deinterleave-file() {
  dd if=$1 skip=$4 count=$5 status=none iflag=skip_bytes,count_bytes | od -An -v -t o1 -w2 > .tmp-file
  cat .tmp-file | sed 's/^ \([0-7]*\) \([0-7]*\).*/printf \\\\\1/' | sh >> roms/$2
  cat .tmp-file | sed 's/^ \([0-7]*\) \([0-7]*\).*/printf \\\\\2/' | sh >> roms/$3
  rm .tmp-file
}

dummy-file() {
  dd if=/dev/zero count=$2 status=none iflag=count_bytes >> roms/$1
}

package-zip() {
  cd roms
  rm -f ../../$1
  zip -q ../../$1 *
  cd ..
}

extract-rom() {
  case $1 in
    _720)
      deinterleave-file _720_a.t11   136047-3126.7lm 136047-3127.7mn $((0x0))     $((0x8000))
      deinterleave-file _720_a.t11   136047-3128.6fh 136047-4131.6mn $((0x8000))  $((0x20000))
      deinterleave-file _720_a.t11   136047-1129.6hj 136047-1132.6p  $((0x28000)) $((0x20000))
      deinterleave-file _720_a.t11   136047-1130.6k  136047-1133.6r  $((0x48000)) $((0x20000))

      extract-file      _720_a.6502  136047-2134.2a                  $((0x0))     $((0x4000))
      extract-file      _720_a.6502  136047-1135.2b                  $((0x4000))  $((0x4000))
      extract-file      _720_a.6502  136047-2136.2cd                 $((0x8000))  $((0x4000))

      extract-file      _720.pfrom   136047-1121.6a                  $((0x0))     $((0x8000))
      extract-file      _720.pfrom   136047-1122.6b                  $((0x8000))  $((0x8000))
      extract-file      _720.pfrom   136047-1123.7a                  $((0x10000)) $((0x8000))
      extract-file      _720.pfrom   136047-1124.7b                  $((0x18000)) $((0x8000))
      extract-file      _720.pfrom   136047-1117.6c                  $((0x20000)) $((0x8000))
      extract-file      _720.pfrom   136047-1118.6d                  $((0x28000)) $((0x8000))
      extract-file      _720.pfrom   136047-1119.7d                  $((0x30000)) $((0x8000))
      extract-file      _720.pfrom   136047-1120.7c                  $((0x38000)) $((0x8000))

      extract-file      _720.mobrom  136047-1109.6t                  $((0x20000)) $((0x8000))
      extract-file      _720.mobrom  136047-1109.6t                  $((0x0))     $((0x8000))
      extract-file      _720.mobrom  136047-1110.6sr                 $((0x28000)) $((0x8000))
      extract-file      _720.mobrom  136047-1110.6sr                 $((0x8000))  $((0x8000))
      extract-file      _720.mobrom  136047-1111.6p                  $((0x30000)) $((0x8000))
      extract-file      _720.mobrom  136047-1111.6p                  $((0x10000)) $((0x8000))
      extract-file      _720.mobrom  136047-1112.6n                  $((0x38000)) $((0x8000))
      extract-file      _720.mobrom  136047-1112.6n                  $((0x18000)) $((0x8000))
      extract-file      _720.mobrom  136047-1113.6m                  $((0x60000)) $((0x8000))
      extract-file      _720.mobrom  136047-1113.6m                  $((0x40000)) $((0x8000))
      extract-file      _720.mobrom  136047-1114.6l                  $((0x68000)) $((0x8000))
      extract-file      _720.mobrom  136047-1114.6l                  $((0x48000)) $((0x8000))
      extract-file      _720.mobrom  136047-1115.6kj                 $((0x70000)) $((0x8000))
      extract-file      _720.mobrom  136047-1115.6kj                 $((0x50000)) $((0x8000))
      extract-file      _720.mobrom  136047-1116.6jh                 $((0x78000)) $((0x8000))
      extract-file      _720.mobrom  136047-1116.6jh                 $((0x58000)) $((0x8000))
      extract-file      _720.mobrom  136047-1101.5t                  $((0xA0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1101.5t                  $((0x80000)) $((0x8000))
      extract-file      _720.mobrom  136047-1102.5sr                 $((0xA8000)) $((0x8000))
      extract-file      _720.mobrom  136047-1102.5sr                 $((0x88000)) $((0x8000))
      extract-file      _720.mobrom  136047-1103.5p                  $((0xB0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1103.5p                  $((0x90000)) $((0x8000))
      extract-file      _720.mobrom  136047-1104.5n                  $((0xB8000)) $((0x8000))
      extract-file      _720.mobrom  136047-1104.5n                  $((0x98000)) $((0x8000))
      extract-file      _720.mobrom  136047-1105.5m                  $((0xE0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1105.5m                  $((0xC0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1106.5l                  $((0xE8000)) $((0x8000))
      extract-file      _720.mobrom  136047-1106.5l                  $((0xC8000)) $((0x8000))
      extract-file      _720.mobrom  136047-1107.5kj                 $((0xF0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1107.5kj                 $((0xD0000)) $((0x8000))
      extract-file      _720.mobrom  136047-1108.5jh                 $((0xF8000)) $((0x8000))
      extract-file      _720.mobrom  136047-1108.5jh                 $((0xD8000)) $((0x8000))

      extract-file      _720_a.anrom 136047-1125.4t                  $((0x0))     $((0x4000))

      dummy-file                     720-eeprom.bin                               $((0x200))
      package-zip                    720.zip
    ;;

    ABEAST16)
      deinterleave-file ABEAST16_V.68K         epr-11705.a7 epr-11704.a5 $((0x0))     $((0x40000))

      extract-file      ABEAST16_V_TILES.ROM   opr-11674.a14             $((0x0))     $((0x20000))
      extract-file      ABEAST16_V_TILES.ROM   opr-11675.a15             $((0x20000)) $((0x20000))
      extract-file      ABEAST16_V_TILES.ROM   opr-11676.a16             $((0x40000)) $((0x20000))

      deinterleave-file ABEAST16_V_SPRITES.ROM epr-11681.b5 epr-11677.b1 $((0x0))     $((0x40000))
      deinterleave-file ABEAST16_V_SPRITES.ROM epr-11682.b6 epr-11678.b2 $((0x40000)) $((0x40000))
      deinterleave-file ABEAST16_V_SPRITES.ROM epr-11683.b7 epr-11679.b3 $((0x80000)) $((0x40000))
      deinterleave-file ABEAST16_V_SPRITES.ROM epr-11684.b8 epr-11680.b4 $((0xC0000)) $((0x40000))

      # epr-11686.a10 is already decrypted and matches epr-11671.a10 from other Altered Beast sets.
      # Despite this, MAME tries to decrypt it anyway and runs the game without sound.
      # An altered MAME driver is needed in order to run the game correctly with working sound.
      extract-file      ABEAST16_V_SOUND.ROM   epr-11686.a10             $((0x0))     $((0x8000))
      extract-file      ABEAST16_V_SOUND.ROM   opr-11672.a11             $((0x8000))  $((0x20000))
      extract-file      ABEAST16_V_SOUND.ROM   opr-11673.a12             $((0x28000)) $((0x20000))

      dummy-file                               317-0066.key                           $((0x2000))
      dummy-file                               315-5298.b9                            $((0xEB))
      package-zip                              altbeast2.nosound.zip
    ;;

    apb)
      deinterleave-file apb_a.t11  136051-2126.7l 136051-2127.7n $((0x0))     $((0x8000))
      deinterleave-file apb_a.t11  136051-7128.6f 136051-7129.6n $((0x8000))  $((0x20000))
      deinterleave-file apb_a.t11  136051-1130.6j 136051-1131.6p $((0x28000)) $((0x20000))
      deinterleave-file apb_a.t11  136051-1132.6l 136051-1133.6s $((0x48000)) $((0x20000))

      extract-file      apb_a.6502 136051-5134.2a                $((0x0))     $((0x4000))
      extract-file      apb_a.6502 136051-5135.2bc               $((0x4000))  $((0x4000))
      extract-file      apb_a.6502 136051-5136.2d                $((0x8000))  $((0x4000))

      extract-file      apb.pfrom  136051-1118.6a                $((0x0))     $((0x8000))
      extract-file      apb.pfrom  136051-1120.6bc               $((0x28000)) $((0x8000))
      extract-file      apb.pfrom  136051-1120.6bc               $((0x8000))  $((0x8000))
      extract-file      apb.pfrom  136051-1122.7a                $((0x30000)) $((0x8000))
      extract-file      apb.pfrom  136051-1122.7a                $((0x10000)) $((0x8000))
      extract-file      apb.pfrom  136051-1124.7bc               $((0x38000)) $((0x8000))
      extract-file      apb.pfrom  136051-1124.7bc               $((0x18000)) $((0x8000))
      extract-file      apb.pfrom  136051-1117.6cd               $((0x40000)) $((0x8000))
      extract-file      apb.pfrom  136051-1119.6de               $((0x68000)) $((0x8000))
      extract-file      apb.pfrom  136051-1119.6de               $((0x48000)) $((0x8000))
      extract-file      apb.pfrom  136051-1121.7de               $((0x70000)) $((0x8000))
      extract-file      apb.pfrom  136051-1121.7de               $((0x50000)) $((0x8000))
      extract-file      apb.pfrom  136051-1123.7cd               $((0x78000)) $((0x8000))
      extract-file      apb.pfrom  136051-1123.7cd               $((0x58000)) $((0x8000))

      extract-file      apb.mobrom 136051-1105.6t                $((0x20000)) $((0x8000))
      extract-file      apb.mobrom 136051-1105.6t                $((0x0))     $((0x8000))
      extract-file      apb.mobrom 136051-1106.6rs               $((0x28000)) $((0x8000))
      extract-file      apb.mobrom 136051-1106.6rs               $((0x8000))  $((0x8000))
      extract-file      apb.mobrom 136051-1107.6pr               $((0x30000)) $((0x8000))
      extract-file      apb.mobrom 136051-1107.6pr               $((0x10000)) $((0x8000))
      extract-file      apb.mobrom 136051-1108.6n                $((0x38000)) $((0x8000))
      extract-file      apb.mobrom 136051-1108.6n                $((0x18000)) $((0x8000))
      extract-file      apb.mobrom 136051-1113.6m                $((0x60000)) $((0x8000))
      extract-file      apb.mobrom 136051-1113.6m                $((0x40000)) $((0x8000))
      extract-file      apb.mobrom 136051-1114.6kl               $((0x68000)) $((0x8000))
      extract-file      apb.mobrom 136051-1114.6kl               $((0x48000)) $((0x8000))
      extract-file      apb.mobrom 136051-1115.6jk               $((0x70000)) $((0x8000))
      extract-file      apb.mobrom 136051-1115.6jk               $((0x50000)) $((0x8000))
      extract-file      apb.mobrom 136051-1116.6h                $((0x78000)) $((0x8000))
      extract-file      apb.mobrom 136051-1116.6h                $((0x58000)) $((0x8000))
      extract-file      apb.mobrom 136051-1101.5t                $((0xA0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1101.5t                $((0x80000)) $((0x8000))
      extract-file      apb.mobrom 136051-1102.5rs               $((0xA8000)) $((0x8000))
      extract-file      apb.mobrom 136051-1102.5rs               $((0x88000)) $((0x8000))
      extract-file      apb.mobrom 136051-1103.5pr               $((0xB0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1103.5pr               $((0x90000)) $((0x8000))
      extract-file      apb.mobrom 136051-1104.5n                $((0xB8000)) $((0x8000))
      extract-file      apb.mobrom 136051-1104.5n                $((0x98000)) $((0x8000))
      extract-file      apb.mobrom 136051-1109.5m                $((0xE0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1109.5m                $((0xC0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1110.5kl               $((0xE8000)) $((0x8000))
      extract-file      apb.mobrom 136051-1110.5kl               $((0xC8000)) $((0x8000))
      extract-file      apb.mobrom 136051-1111.5jk               $((0xF0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1111.5jk               $((0xD0000)) $((0x8000))
      extract-file      apb.mobrom 136051-1112.5h                $((0xF8000)) $((0x8000))
      extract-file      apb.mobrom 136051-1112.5h                $((0xD8000)) $((0x8000))

      extract-file      apb.anrom  136051-1125.4t                $((0x0))     $((0x4000))

      package-zip                  apb.zip
    ;;

    archrivals)
      deinterleave-file archrivals.68k    arch_rivals_3c_rev4.3c arch_rivals_3b_rev4.3b $((0x0))     $((0x20000))
      deinterleave-file archrivals.68k    arch_rivals_2c_rev4.2c arch_rivals_2b_rev4.2b $((0x20000)) $((0x20000))

      extract-file      archrivals.6809   arch_rivals_u4_rev1.u4                        $((0x0))     $((0x8000))
      extract-file      archrivals.6809   arch_rivals_u19_rev1.u19                      $((0x8000))  $((0x8000))
      extract-file      archrivals.6809   arch_rivals_u20_rev1.u20                      $((0x10000)) $((0x8000))

      extract-file      archrivals.1.grom arch_rivals_11d_rev1.11d                      $((0x0))     $((0x10000))
      extract-file      archrivals.1.grom arch_rivals_12d_rev1.12d                      $((0x10000)) $((0x10000))

      extract-file      archrivals.2.grom arch_rivals_7j_rev1.7j                        $((0x0))     $((0x20000))
      extract-file      archrivals.2.grom arch_rivals_8j_rev1.8j                        $((0x20000)) $((0x20000))
      extract-file      archrivals.2.grom arch_rivals_9j_rev1.9j                        $((0x40000)) $((0x20000))
      extract-file      archrivals.2.grom arch_rivals_10j_rev1.10j                      $((0x60000)) $((0x20000))

      dummy-file                          pls153.11j                                                 $((0xEB))
      dummy-file                          pls153.12j                                                 $((0xEB))
      dummy-file                          pls153.14h                                                 $((0xEB))
      package-zip                         archrivl.zip
    ;;

    bubbles)
      extract-file bubbles.6800 video_sound_rom_5_std_771.ic12 $((0x0))    $((0x1000))

      extract-file bubbles.6809 bubbles_rom_10b_16-3012-49.a7  $((0x0))    $((0x1000))
      extract-file bubbles.6809 bubbles_rom_11b_16-3012-50.c7  $((0x1000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_12b_16-3012-51.e7  $((0x2000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_1b_16-3012-40.4e   $((0x3000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_2b_16-3012-41.4c   $((0x4000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_3b_16-3012-42.4a   $((0x5000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_4b_16-3012-43.5e   $((0x6000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_5b_16-3012-44.5c   $((0x7000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_6b_16-3012-45.5a   $((0x8000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_7b_16-3012-46.6e   $((0x9000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_8b_16-3012-47.6c   $((0xA000)) $((0x1000))
      extract-file bubbles.6809 bubbles_rom_9b_16-3012-48.6a   $((0xB000)) $((0x1000))

      dummy-file                decoder_rom_4.3g                           $((0x200))
      dummy-file                decoder_rom_6.3c                           $((0x200))
      package-zip               bubbles.zip
    ;;

    championshipsprint)
      deinterleave-file championshipsprint_a.t11  136045-3126.7l 136045-2127.7n $((0x0))     $((0x8000))
      deinterleave-file championshipsprint_a.t11  136045-2125.6f 136045-2122.6n $((0x8000))  $((0x10000))
      deinterleave-file championshipsprint_a.t11  136045-1124.6k 136045-1121.6r $((0x18000)) $((0x10000))
      deinterleave-file championshipsprint_a.t11  136045-1123.6l 136045-1120.6s $((0x28000)) $((0x10000))

      extract-file      championshipsprint_a.6502 136045-1118.2bc               $((0x0))     $((0x4000))
      extract-file      championshipsprint_a.6502 136045-1119.2d                $((0x4000))  $((0x4000))

      extract-file      championshipsprint.pfrom  136045-1105.6a                $((0x0))     $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1106.6b                $((0x8000))  $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1101.7a                $((0x30000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1101.7a                $((0x10000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1102.7b                $((0x18000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1107.6c                $((0x40000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1108.6de               $((0x48000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1104.7de               $((0x70000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1104.7de               $((0x50000)) $((0x8000))
      extract-file      championshipsprint.pfrom  136045-1103.7c                $((0x58000)) $((0x8000))

      extract-file      championshipsprint.mobrom 136045-1112.6l                $((0x0))     $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1111.6k                $((0x8000))  $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1110.6hj               $((0x10000)) $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1109.6fh               $((0x18000)) $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1116.6rs               $((0x20000)) $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1115.6pr               $((0x28000)) $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1114.6n                $((0x30000)) $((0x8000))
      extract-file      championshipsprint.mobrom 136045-1113.6m                $((0x38000)) $((0x8000))


      extract-file      championshipsprint.anrom  136045-1117.6t                $((0x0))     $((0x4000))

      dummy-file                                  csprint-eeprom.bin                         $((0x200))
      package-zip                                 csprint.zip
    ;;

    defender)
      extract-file defender.6800   video_sound_rom_1.ic12 $((0x0))    $((0x800))

      extract-file defender_a.6809 defend.1               $((0x0))    $((0x800))
      extract-file defender_a.6809 defend.4               $((0x800))  $((0x800))
      extract-file defender_a.6809 defend.2               $((0x1000)) $((0x1000))
      extract-file defender_a.6809 defend.3               $((0x2000)) $((0x1000))
      extract-file defender_a.6809 defend.9               $((0x3000)) $((0x800))
      extract-file defender_a.6809 defend.12              $((0x3800)) $((0x800))
      extract-file defender_a.6809 defend.8               $((0x4000)) $((0x800))
      extract-file defender_a.6809 defend.11              $((0x4800)) $((0x800))
      extract-file defender_a.6809 defend.7               $((0x5000)) $((0x800))
      extract-file defender_a.6809 defend.10              $((0x5800)) $((0x800))
      extract-file defender_a.6809 defend.6               $((0x6000)) $((0x800))

      dummy-file                   decoder.2                          $((0x200))
      dummy-file                   decoder.3                          $((0x200))
      package-zip                  defender.zip
    ;;

    gauntlet)
      deinterleave-file gauntlet.68k    136037-1307.9a 136037-1308.9b $((0x8000))  $((0x8000))
      deinterleave-file gauntlet.68k    136037-1307.9a 136037-1308.9b $((0x0))     $((0x8000))

      deinterleave-file gauntlet.2.68k  136037-205.10a 136037-206.10b $((0x0))     $((0x8000))
      deinterleave-file gauntlet.2.68k  136037-1409.7a 136037-1410.7b $((0x10000)) $((0x8000))
      deinterleave-file gauntlet.2.68k  136037-1409.7a 136037-1410.7b $((0x8000))  $((0x8000))

      extract-file      gauntlet.6502   136037-120.16r                $((0x0))     $((0x4000))
      extract-file      gauntlet.6502   136037-119.16s                $((0x4000))  $((0x8000))

      extract-file      gauntlet.1.grom 136037-104.6p                 $((0x0))     $((0x2000))

      extract-file      gauntlet.2.grom 136037-111.1a                 $((0x0))     $((0x8000))
      extract-file      gauntlet.2.grom 136037-112.1b                 $((0x8000))  $((0x8000))
      extract-file      gauntlet.2.grom 136037-113.1l                 $((0x10000)) $((0x8000))
      extract-file      gauntlet.2.grom 136037-114.1mn                $((0x18000)) $((0x8000))
      extract-file      gauntlet.2.grom 136037-115.2a                 $((0x20000)) $((0x8000))
      extract-file      gauntlet.2.grom 136037-116.2b                 $((0x28000)) $((0x8000))
      extract-file      gauntlet.2.grom 136037-117.2l                 $((0x30000)) $((0x8000))
      extract-file      gauntlet.2.grom 136037-118.2mn                $((0x38000)) $((0x8000))

      dummy-file                        74s472-136037-101.7u                       $((0x200))
      dummy-file                        74s472-136037-102.5l                       $((0x200))
      dummy-file                        74s287-136037-103.4r                       $((0x100))
      package-zip                       gauntlet.zip
    ;;

    gauntlet2)
      deinterleave-file gauntlet2_4a.68k    136037-1307.9a 136037-1308.9b   $((0x8000))  $((0x8000))
      deinterleave-file gauntlet2_4a.68k    136037-1307.9a 136037-1308.9b   $((0x0))     $((0x8000))

      deinterleave-file gauntlet2_4a.2.68k  136043-1105.10a 136043-1106.10b $((0x0))     $((0x8000))
      deinterleave-file gauntlet2_4a.2.68k  136043-1109.7a 136043-1110.7b   $((0x10000)) $((0x8000))
      deinterleave-file gauntlet2_4a.2.68k  136043-1109.7a 136043-1110.7b   $((0x8000))  $((0x8000))
      deinterleave-file gauntlet2_4a.2.68k  136043-1121.6a 136043-1122.6b   $((0x20000)) $((0x8000))
      deinterleave-file gauntlet2_4a.2.68k  136043-1121.6a 136043-1122.6b   $((0x18000)) $((0x8000))

      extract-file      gauntlet2.6502   136043-1120.16r                    $((0x0))     $((0x4000))
      extract-file      gauntlet2.6502   136043-1119.16s                    $((0x4000))  $((0x8000))

      extract-file      gauntlet2.1.grom 136043-1104.6p                     $((0x0))     $((0x2000))

      extract-file      gauntlet2.2.grom 136043-1111.1a                     $((0x0))     $((0x8000))
      extract-file      gauntlet2.2.grom 136037-112.1b                      $((0x8000))  $((0x8000))
      extract-file      gauntlet2.2.grom 136043-1123.1c                     $((0x10000)) $((0x4000))
      extract-file      gauntlet2.2.grom 136043-1113.1l                     $((0x18000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136037-114.1mn                     $((0x20000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136043-1124.1p                     $((0x28000)) $((0x4000))
      extract-file      gauntlet2.2.grom 136043-1115.2a                     $((0x30000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136037-116.2b                      $((0x38000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136043-1125.2c                     $((0x40000)) $((0x4000))
      extract-file      gauntlet2.2.grom 136043-1117.2l                     $((0x48000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136037-118.2mn                     $((0x50000)) $((0x8000))
      extract-file      gauntlet2.2.grom 136043-1126.2p                     $((0x58000)) $((0x4000))

      dummy-file                         74s472-136037-101.7u                            $((0x200))
      dummy-file                         74s472-136037-102.5l                            $((0x200))
      dummy-file                         82s129-136043-1103.4r                           $((0x100))
      package-zip                        gaunt2.zip
    ;;

    GAXE16)
      # epr-12523.a7 and epr-12522.a5 do not match MAME.
      # Single-byte differences scattered throughout.
      deinterleave-file GoldenAxeProgram.rom epr-12523.a7 epr-12522.a5 $((0x0))      $((0x40000))
      deinterleave-file GoldenAxeProgram.rom epr-12521.a8 epr-12519.a6 $((0x40000))  $((0x40000))

      extract-file      GoldenAxeChars.rom   epr-12385.a14             $((0x0))      $((0x20000))
      extract-file      GoldenAxeChars.rom   epr-12386.a15             $((0x20000))  $((0x20000))
      extract-file      GoldenAxeChars.rom   epr-12387.a16             $((0x40000))  $((0x20000))

      deinterleave-file GoldenAxeSprites.rom mpr-12379.b5 mpr-12378.b1 $((0x0))      $((0x40000))
      deinterleave-file GoldenAxeSprites.rom mpr-12379.b5 mpr-12378.b1 $((0x100000)) $((0x40000))
      deinterleave-file GoldenAxeSprites.rom mpr-12381.b6 mpr-12380.b2 $((0x40000))  $((0x40000))
      deinterleave-file GoldenAxeSprites.rom mpr-12381.b6 mpr-12380.b2 $((0x140000)) $((0x40000))
      deinterleave-file GoldenAxeSprites.rom mpr-12383.b7 mpr-12382.b3 $((0x80000))  $((0x40000))
      deinterleave-file GoldenAxeSprites.rom mpr-12383.b7 mpr-12382.b3 $((0x180000)) $((0x40000))

      extract-file      GoldenAxeSound.rom   epr-12390.a10             $((0x0))      $((0x8000))
      extract-file      GoldenAxeSound.rom   mpr-12384.a11             $((0x8000))   $((0x20000))

      dummy-file                             317-0112.c2                             $((0x1000))
      dummy-file                             315-5298.b9                             $((0xEB))
      package-zip                            goldnaxe2.noboot.zip
    ;;

    joust)
      extract-file joust.6800 video_sound_rom_4_std_780.ic12 $((0x0))    $((0x1000))

      extract-file joust.6809 joust_rom_10b_3006-22.a7       $((0x0))    $((0x1000))
      extract-file joust.6809 joust_rom_11b_3006-23.c7       $((0x1000)) $((0x1000))
      extract-file joust.6809 joust_rom_12b_3006-24.e7       $((0x2000)) $((0x1000))
      extract-file joust.6809 joust_rom_1b_3006-13.e4        $((0x3000)) $((0x1000))
      extract-file joust.6809 joust_rom_2b_3006-14.c4        $((0x4000)) $((0x1000))
      extract-file joust.6809 joust_rom_3b_3006-15.a4        $((0x5000)) $((0x1000))
      extract-file joust.6809 joust_rom_4b_3006-16.e5        $((0x6000)) $((0x1000))
      extract-file joust.6809 joust_rom_5b_3006-17.c5        $((0x7000)) $((0x1000))
      extract-file joust.6809 joust_rom_6b_3006-18.a5        $((0x8000)) $((0x1000))
      extract-file joust.6809 joust_rom_7b_3006-19.e6        $((0x9000)) $((0x1000))
      extract-file joust.6809 joust_rom_8b_3006-20.c6        $((0xA000)) $((0x1000))
      extract-file joust.6809 joust_rom_9b_3006-21.a6        $((0xB000)) $((0x1000))

      dummy-file              decoder_rom_4.3g                           $((0x200))
      dummy-file              decoder_rom_6.3c                           $((0x200))
      package-zip             joust.zip
    ;;

    joust2)
      extract-file joust2.1.6809 cpu_2732_ic55_rom2_rev1.4c        $((0x0))     $((0x1000))
      extract-file joust2.1.6809 cpu_2732_ic9_rom3_rev2.4d         $((0x1000))  $((0x1000))
      extract-file joust2.1.6809 cpu_2732_ic10_rom4_rev2.4f        $((0x2000))  $((0x1000))
      extract-file joust2.1.6809 cpu_2732_ic18_rom11_rev1.8j       $((0x3000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic16_rom9_rev2.8h        $((0x5000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic14_rom7_rev2.6j        $((0x7000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic12_rom5_rev2.6h        $((0x9000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic26_rom19_rev1.10j      $((0xB000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic24_rom17_rev1.10h      $((0xD000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic22_rom15_rev1.9j       $((0xF000))  $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic20_rom13_rev1.9h       $((0x11000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic17_rom10_rev1.8i       $((0x13000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic15_rom8_rev1.8g        $((0x15000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic13_rom6_rev2.6i        $((0x17000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic25_rom18_rev1.10i      $((0x19000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic23_rom16_rev1.10g      $((0x1B000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic21_rom14_rev1.9i       $((0x1D000)) $((0x2000))
      extract-file joust2.1.6809 cpu_2732_ic19_rom12_rev1.9g       $((0x1F000)) $((0x2000))

      extract-file joust2.2.6809 snd_27256_rom23_rev1.u4           $((0x0))     $((0x8000))
      extract-file joust2.2.6809 snd_27256_rom24_rev1.u19          $((0x8000))  $((0x8000))
      extract-file joust2.2.6809 snd_27256_rom25_rev1.u20          $((0x10000)) $((0x8000))

      extract-file joust2.6800   cpu_2764_ic8_rom1_rev1.0f         $((0x0))     $((0x2000))

      extract-file joust2.grom   vid_27128_ic57_rom20_rev1.8f      $((0x0))     $((0x4000))
      extract-file joust2.grom   vid_27128_ic58_rom21_rev1.9f      $((0x4000))  $((0x4000))
      extract-file joust2.grom   vid_27128_ic41_rom22_rev1.9d      $((0x8000))  $((0x4000))

      dummy-file                 vid_82s123_ic14_a-5282-10295.2b                $((0x20))
      dummy-file                 vid_82s129_ic47_a-5282-10294.15d               $((0x100))
      dummy-file                 vid_82s147a_ic60_a-5282-10292.12f              $((0x200))
      package-zip                joust2.zip
    ;;

    marblemadness)
      deinterleave-file marblemadness_b.68k  136033.401 136033.402         $((0x0))     $((0x10000))
      deinterleave-file marblemadness_b.68k  136033.403 136033.404         $((0x10000)) $((0x10000))

      deinterleave-file marblemadness.slap   136033.107 136033.108         $((0x0))     $((0x8000))

      extract-file      marblemadness_a.6502 136033.421                    $((0x0))     $((0x4000))
      extract-file      marblemadness_a.6502 136033.422                    $((0x4000))  $((0x4000))

      extract-file      marblemadness_a.prom 136033.118                    $((0x0))     $((0x200))
      extract-file      marblemadness_a.prom 136033.119                    $((0x200))   $((0x200))

      deinterleave-file system1_bios_0.68k   136032.205.l13 136032.206.l12 $((0x0))     $((0x8000))

      # Graphics ROMs unable to be converted to MAME format:
      # marblemadness.1.grom, marblemadness.2.grom, marblemadness.anrom
      dummy-file                             136033.137                                 $((0x04000))
      dummy-file                             136033.138                                 $((0x04000))
      dummy-file                             136033.139                                 $((0x04000))
      dummy-file                             136033.140                                 $((0x04000))
      dummy-file                             136033.141                                 $((0x04000))
      dummy-file                             136033.142                                 $((0x04000))
      dummy-file                             136033.143                                 $((0x04000))
      dummy-file                             136033.144                                 $((0x04000))
      dummy-file                             136033.145                                 $((0x04000))
      dummy-file                             136033.146                                 $((0x04000))
      dummy-file                             136033.149                                 $((0x04000))
      dummy-file                             136033.151                                 $((0x04000))
      dummy-file                             136033.153                                 $((0x04000))

      # Atari System 1 BIOS files not included with Midway Arcade Origins
      dummy-file                             136032.101.e3                              $((0x100))
      dummy-file                             136032.102.e5                              $((0x100))
      dummy-file                             136032.104.f5                              $((0x2000))
      dummy-file                             136032.105.l13                             $((0x4000))
      dummy-file                             136032.106.l12                             $((0x4000))
      dummy-file                             136032.107.b2                              $((0x2000))
      dummy-file                             136032.114.j11                             $((0x4000))
      dummy-file                             136032.115.j10                             $((0x4000))

      package-zip                            marble2.partial.zip
    ;;

    pitfighter)
      deinterleave-file pitfighter.68k    136081-9028.05d 136081-9029.05b   $((0x0))      $((0x20000))
      deinterleave-file pitfighter.68k    136081-9030.15d 136081-9031.15b   $((0x20000))  $((0x20000))

      extract-file      pitfighter.6502   136081-1060.1b                    $((0x0))      $((0x10000))

      extract-file      pitfighter.1.grom 136081-1017.130m                  $((0x0))      $((0x10000))
      extract-file      pitfighter.1.grom 136081-1018.120m                  $((0x10000))  $((0x10000))
      extract-file      pitfighter.1.grom 136081-1021.90m                   $((0x20000))  $((0x10000))
      extract-file      pitfighter.1.grom 136081-1022.75m                   $((0x30000))  $((0x10000))
      extract-file      pitfighter.1.grom 136081-1025.45m                   $((0x40000))  $((0x10000))

      extract-file      pitfighter.2.grom 136081-1027.15l                   $((0x0))      $((0x10000))

      deinterleave-file pitfighter.3.grom 136081-1002.65n  136081-1001.65r  $((0x0))      $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1004.70n  136081-1003.70r  $((0x40000))  $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1006.75n  136081-1005.75r  $((0x80000))  $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1008.90n  136081-1007.90r  $((0xC0000))  $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1010.100n 136081-1009.100r $((0x100000)) $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1012.115n 136081-1011.115r $((0x140000)) $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1014.120n 136081-1013.120r $((0x180000)) $((0x40000))
      deinterleave-file pitfighter.3.grom 136081-1016.130n 136081-1015.130r $((0x1C0000)) $((0x40000))

      extract-file      pitfighter.pcmrom 136081-1061.7k                    $((0x0))      $((0x10000))
      extract-file      pitfighter.pcmrom 136081-1062.7j                    $((0x10000))  $((0x10000))
      extract-file      pitfighter.pcmrom 136081-1063.7e                    $((0x20000))  $((0x10000))
      extract-file      pitfighter.pcmrom 136081-1064.7d                    $((0x30000))  $((0x10000))

      dummy-file                          136081-1040.30s                                 $((0x200))
      dummy-file                          136081-1041.25s                                 $((0x200))
      dummy-file                          136081-1042.20s                                 $((0x200))
      dummy-file                          gal16v8a-136081-1043.15e                        $((0x117))
      dummy-file                          gal16v8a-136079-1045.40p                        $((0x117))
      dummy-file                          gal16v8a-136079-1046.65d                        $((0x117))
      dummy-file                          gal16v8a-136079-1047.40s                        $((0x117))
      dummy-file                          gal16v8a-136079-1048.125f                       $((0x117))
      dummy-file                          gal16v8a-136079-1049.120f                       $((0x117))
      dummy-file                          gal16v8a-136079-1050.115f                       $((0x117))
      dummy-file                          gal16v8a-136079-1051.105f                       $((0x117))
      dummy-file                          gal16v8a-136079-1052.30n                        $((0x117))
      package-zip                         pitfight.zip
    ;;

    rampage)
      extract-file      rampage.z80    pro-0_3b_rev_3_8-27-86.3b                   $((0x0))     $((0x8000))
      extract-file      rampage.z80    pro-1_5b_rev_3_8-27-86.5b                   $((0x8000))  $((0x8000))

      deinterleave-file rampage.68k    u-7_rev.2_8-14-86.u7 u-17_rev.2_8-14-86.u17 $((0x0))     $((0x10000))
      deinterleave-file rampage.68k    u-8_rev.2_8-14-86.u8 u-18_rev.2_8-14-86.u18 $((0x10000)) $((0x10000))

      extract-file      rampage.1.grom bg-0_u15_7-23-86.15a                        $((0x0))    $((0x4000))
      extract-file      rampage.1.grom bg-1_u14_7-23-86.14b                        $((0x4000)) $((0x4000))

      extract-file      rampage.2.grom fg-0_8e_6-30-86.8e                          $((0x0))     $((0x10000))
      extract-file      rampage.2.grom fg-1_6e_6-30-86.6e                          $((0x10000)) $((0x10000))
      extract-file      rampage.2.grom fg-2_5e_6-30-86.5e                          $((0x20000)) $((0x10000))
      extract-file      rampage.2.grom fg-3_4e_6-30-86.4e                          $((0x30000)) $((0x10000))

      package-zip                      rampage.zip
    ;;

    rampart)
      deinterleave-file rampart_a.68k  136082-1033.13l 136082-1032.13j $((0x0))     $((0x100000))
      deinterleave-file rampart_a.68k  136082-2031.13l 136082-2030.13h $((0x0))     $((0x20000))

      extract-file      rampart.1.grom 136082-1009.2n                  $((0x0))     $((0x20000))

      extract-file      rampart.pcmrom 136082-1007.2d                  $((0x0))     $((0x20000))
      extract-file      rampart.pcmrom 136082-1008.1d                  $((0x20000)) $((0x20000))

      extract-file      rampart.pals   gal16v8-136082-1000.1j          $((0x0))     $((0x117))
      extract-file      rampart.pals   gal16v8-136082-1001.4l          $((0x117))   $((0x117))
      extract-file      rampart.pals   gal16v8-136082-1002.7k          $((0x22E))   $((0x117))
      extract-file      rampart.pals   gal20v8-136082-1003.8j          $((0x345))   $((0x157))
      extract-file      rampart.pals   gal20v8-136082-1004.8m          $((0x49C))   $((0x157))
      extract-file      rampart.pals   gal16v8-136082-1006.12c         $((0x5F3))   $((0x117))

      dummy-file                       rampart-eeprom.bin                           $((0x800))
      package-zip                      rampart.zip
    ;;

    robotron)
      extract-file robotron.6800 video_sound_rom_3_std_767.ic12 $((0x0))    $((0x1000))

      extract-file robotron.6809 2084_rom_10b_3005-22.a7        $((0x0))    $((0x1000))
      extract-file robotron.6809 2084_rom_11b_3005-23.c7        $((0x1000)) $((0x1000))
      extract-file robotron.6809 2084_rom_12b_3005-24.e7        $((0x2000)) $((0x1000))
      extract-file robotron.6809 2084_rom_1b_3005-13.e4         $((0x3000)) $((0x1000))
      extract-file robotron.6809 2084_rom_2b_3005-14.c4         $((0x4000)) $((0x1000))
      extract-file robotron.6809 2084_rom_3b_3005-15.a4         $((0x5000)) $((0x1000))
      extract-file robotron.6809 2084_rom_4b_3005-16.e5         $((0x6000)) $((0x1000))
      extract-file robotron.6809 2084_rom_5b_3005-17.c5         $((0x7000)) $((0x1000))
      extract-file robotron.6809 2084_rom_6b_3005-18.a5         $((0x8000)) $((0x1000))
      extract-file robotron.6809 2084_rom_7b_3005-19.e6         $((0x9000)) $((0x1000))
      extract-file robotron.6809 2084_rom_8b_3005-20.c6         $((0xA000)) $((0x1000))
      extract-file robotron.6809 2084_rom_9b_3005-21.a6         $((0xB000)) $((0x1000))

      dummy-file                 decoder_rom_4.3g                           $((0x200))
      dummy-file                 decoder_rom_6.3c                           $((0x200))
      package-zip                robotron.zip
    ;;

    satanshollow)
      extract-file satanshollow.1.z80  sh-pro.00   $((0x0))    $((0x2000))
      extract-file satanshollow.1.z80  sh-pro.01   $((0x2000)) $((0x2000))
      extract-file satanshollow.1.z80  sh-pro.02   $((0x4000)) $((0x2000))
      extract-file satanshollow.1.z80  sh-pro.03   $((0x6000)) $((0x2000))
      extract-file satanshollow.1.z80  sh-pro.04   $((0x8000)) $((0x2000))
      extract-file satanshollow.1.z80  sh-pro.05   $((0xA000)) $((0x2000))

      extract-file satanshollow.2.z80  sh-snd.01   $((0x0))    $((0x1000))
      extract-file satanshollow.2.z80  sh-snd.02   $((0x1000)) $((0x1000))
      extract-file satanshollow.2.z80  sh-snd.03   $((0x2000)) $((0x1000))

      extract-file satanshollow.1.grom sh-bg.00    $((0x0))    $((0x2000))
      extract-file satanshollow.1.grom sh-bg.01    $((0x2000)) $((0x2000))

      extract-file satanshollow.2.grom sh-fg.00    $((0x0))    $((0x2000))
      extract-file satanshollow.2.grom sh-fg.01    $((0x2000)) $((0x2000))
      extract-file satanshollow.2.grom sh-fg.02    $((0x4000)) $((0x2000))
      extract-file satanshollow.2.grom sh-fg.03    $((0x6000)) $((0x2000))

      dummy-file                       82s123.12d              $((0x20))
      package-zip                      shollow.zip
    ;;

    SHINOARC)
      # These files match the shinobi6 set
      deinterleave-file SHINOARC_V.68K         epr-11360.a7 epr-11359.a5 $((0x0))     $((0x40000))

      # These files match the shinobi5 set
      extract-file      SHINOARC_V_TILES.ROM   opr-11284.b9              $((0x0))     $((0x10000))
      extract-file      SHINOARC_V_TILES.ROM   opr-11285.b10             $((0x10000)) $((0x10000))
      extract-file      SHINOARC_V_TILES.ROM   opr-11286.b11             $((0x20000)) $((0x10000))

      # These files match the shinobi5 set
      deinterleave-file SHINOARC_V_SPRITES.ROM opr-11294.b5 opr-11290.b1 $((0x0))     $((0x20000))
      deinterleave-file SHINOARC_V_SPRITES.ROM opr-11295.b6 opr-11291.b2 $((0x20000)) $((0x20000))
      deinterleave-file SHINOARC_V_SPRITES.ROM opr-11296.b7 opr-11292.b3 $((0x40000)) $((0x20000))
      deinterleave-file SHINOARC_V_SPRITES.ROM opr-11297.b8 opr-11293.b4 $((0x60000)) $((0x20000))

      # epr-11361.a10 matches the shinobi6 set
      # epr-11288.a8 and epr-11289.a9 match the shinobi5 set
      extract-file      SHINOARC_V_SOUND.ROM   epr-11361.a10            $((0x0))     $((0x8000))
      extract-file      SHINOARC_V_SOUND.ROM   epr-11288.a8             $((0x8000))  $((0x8000))
      extract-file      SHINOARC_V_SOUND.ROM   epr-11289.a9             $((0x10000)) $((0x8000))

      package-zip                              shinobi5+shinobi6.partial.zip
    ;;

    sinistar)
      extract-file sinistar.6800 3004_speech_ic7_r1_16-3004-52.ic7 $((0x0))    $((0x1000))
      extract-file sinistar.6800 3004_speech_ic5_r1_16-3004-50.ic5 $((0x1000)) $((0x1000))
      extract-file sinistar.6800 3004_speech_ic6_r1_16-3004-51.ic6 $((0x2000)) $((0x1000))
      extract-file sinistar.6800 3004_speech_ic4_r1_16-3004-49.ic4 $((0x3000)) $((0x1000))
      extract-file sinistar.6800 video_sound_rom_9_std.808.ic12    $((0x4000)) $((0x1000))

      extract-file sinistar.6809 sinistar_rom_10-b_16-3004-62.4c   $((0x0))    $((0x1000))
      extract-file sinistar.6809 sinistar_rom_11-b_16-3004-63.4a   $((0x1000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_1-b_16-3004-53.1d    $((0x2000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_2-b_16-3004-54.1c    $((0x3000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_3-b_16-3004-55.1a    $((0x4000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_4-b_16-3004-56.2d    $((0x5000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_5-b_16-3004-57.2c    $((0x6000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_6-b_16-3004-58.2a    $((0x7000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_7-b_16-3004-59.3d    $((0x8000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_8-b_16-3004-60.3c    $((0x9000)) $((0x1000))
      extract-file sinistar.6809 sinistar_rom_9-b_16-3004-61.3a    $((0xA000)) $((0x1000))

      dummy-file                 decoder_rom_4.3g                              $((0x200))
      dummy-file                 decoder_rom_6.3c                              $((0x200))
      package-zip                sinistar.zip
    ;;

    smashtv)
      deinterleave-file smashtv.34010 la8_smash_tv_game_rom_u105.u105 la8_smash_tv_game_rom_u89.u89 $((0x0))      $((0x40000))

      extract-file      smashtv.6809  sl2_smash_tv_sound_rom_u4.u4                                  $((0x0))      $((0x10000))
      extract-file      smashtv.6809  sl2_smash_tv_sound_rom_u19.u19                                $((0x10000))  $((0x10000))
      extract-file      smashtv.6809  sl2_smash_tv_sound_rom_u20.u20                                $((0x20000))  $((0x10000))

      extract-file      smashtv.grom  la1_smash_tv_game_rom_u111.u111                               $((0x0))      $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u112.u112                               $((0x20000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u113.u113                               $((0x40000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u95.u95                                 $((0x60000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u96.u96                                 $((0x80000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u97.u97                                 $((0xA0000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u106.u106                               $((0xC0000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u107.u107                               $((0xE0000))  $((0x20000))
      extract-file      smashtv.grom  la1_smash_tv_game_rom_u108.u108                               $((0x100000)) $((0x20000))

      package-zip                     smashtv.zip
    ;;

    spyhunter)
      extract-file      spyhunter.1.grom spy-hunter_cpu_bg0_11-18-83.3a                                                $((0x0))     $((0x2000))
      extract-file      spyhunter.1.grom spy-hunter_cpu_bg1_11-18-83.4a                                                $((0x2000))  $((0x2000))
      extract-file      spyhunter.1.grom spy-hunter_cpu_bg2_11-18-83.5a                                                $((0x4000))  $((0x2000))
      extract-file      spyhunter.1.grom spy-hunter_cpu_bg3_11-18-83.6a                                                $((0x6000))  $((0x2000))

      extract-file      spyhunter.2.grom spy-hunter_video_1fg_11-18-83.a7                                              $((0x0))     $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_0fg_11-18-83.a8                                              $((0x4000))  $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_3fg_11-18-83.a5                                              $((0x8000))  $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_2fg_11-18-83.a6                                              $((0xC000))  $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_5fg_11-18-83.a3                                              $((0x10000)) $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_4fg_11-18-83.a4                                              $((0x14000)) $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_7fg_11-18-83.a1                                              $((0x18000)) $((0x4000))
      extract-file      spyhunter.2.grom spy-hunter_video_6fg_11-18-83.a2                                              $((0x1C000)) $((0x4000))

      extract-file      spyhunter.3.grom spy-hunter_cpu_alpha-n_11-18-83                                               $((0x0))     $((0x1000))

      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg0_2-9-84.6d                                                  $((0x0))     $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg1_2-9-84.7d                                                  $((0x2000))  $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg2_2-9-84.8d                                                  $((0x4000))  $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg3_2-9-84.9d                                                  $((0x6000))  $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg4_2-9-84.10d                                                 $((0x8000))  $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg5_2-9-84.11d                                                 $((0xC000))  $((0x2000))
      extract-file      spyhunter.1.z80  spy-hunter_cpu_pg5_2-9-84.11d                                                 $((0xA000))  $((0x2000))

      extract-file      spyhunter.2.z80  spy-hunter_snd_0_sd_11-18-83.a7                                               $((0x0))     $((0x1000))
      extract-file      spyhunter.2.z80  spy-hunter_snd_1_sd_11-18-83.a8                                               $((0x1000))  $((0x1000))

      deinterleave-file spyhunter.68k    spy-hunter_cs_deluxe_u7_a_11-18-83.u7 spy-hunter_cs_deluxe_u17_b_11-18-83.u17 $((0x0))     $((0x4000))
      deinterleave-file spyhunter.68k    spy-hunter_cs_deluxe_u8_c_11-18-83.u8 spy-hunter_cs_deluxe_u18_d_11-18-83.u18 $((0x4000))  $((0x4000))

      dummy-file                         82s123.12d                                                                                 $((0x20))
      dummy-file                         0304-00803-0052.u15                                                                        $((0x4A))
      package-zip                        spyhunt.zip
    ;;

    spyhunter2)
      deinterleave-file spyhunter2.1.68k  sh2_3c_rev2.3c sh2_3b_rev2.3b                       $((0x0))     $((0x20000))
      deinterleave-file spyhunter2.1.68k  sh2_2c_rev2.2c sh2_2b_rev2.2b                       $((0x20000)) $((0x20000))

      deinterleave-file spyhunter2.2.68k  spyhunter_ii_u7_sound.u7 spyhunter_ii_u17_sound.u17 $((0x0))     $((0x20000))

      extract-file      spyhunter2.6809   spyhunter_ii_u5.u5                                  $((0x0))     $((0x4000))
      extract-file      spyhunter2.6809   spyhunter_ii_u4.u4                                  $((0x4000))  $((0x4000))

      extract-file      spyhunter2.1.grom sh2_bg0_rev2.11d                                    $((0x0))     $((0x8000))
      extract-file      spyhunter2.1.grom sh2_bg1_rev2.12d                                    $((0x8000))  $((0x8000))

      extract-file      spyhunter2.2.grom fg0.7j                                              $((0x0))     $((0x20000))
      extract-file      spyhunter2.2.grom fg1.8j                                              $((0x20000)) $((0x20000))
      extract-file      spyhunter2.2.grom fg2.9j                                              $((0x40000)) $((0x20000))
      extract-file      spyhunter2.2.grom fg3.10j                                             $((0x60000)) $((0x20000))

      package-zip                         spyhunt2.zip
    ;;

    stargate*)
      [[ $1 == *defender2 ]] && ROM_SUFFIX=_p

      extract-file stargate.6800              video_sound_rom_2_std_744.ic12 $((0x0))    $((0x800))

      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_10-a_3002-10.a7   $((0x0))    $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_11-a_3002-11.c7   $((0x1000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_12-a_3002-12.e7   $((0x2000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_1-a_3002-1.e4     $((0x3000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_2-a_3002-2.c4     $((0x4000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_3-a_3002-3.a4     $((0x5000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_4-a_3002-4.e5     $((0x6000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_5-a_3002-5.c5     $((0x7000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_6-a_3002-6.a5     $((0x8000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_7-a_3002-7.e6     $((0x9000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_8-a_3002-8.c6     $((0xA000)) $((0x1000))
      extract-file stargate${ROM_SUFFIX}.6809 stargate_rom_9-a_3002-9.a6     $((0xB000)) $((0x1000))

      dummy-file                              decoder_rom_4.3g                           $((0x200))
      dummy-file                              decoder_rom_5.3c                           $((0x200))
      package-zip                             $1.zip
    ;;

    superoffroad)
      extract-file      superoffroad.1.z80  03-22121-04.u58t                  $((0x0))     $((0x10000))
      extract-file      superoffroad.1.z80  03-22122-03.u59t                  $((0x10000)) $((0x10000))
      extract-file      superoffroad.1.z80  03-22120-01.u57t                  $((0x20000)) $((0x10000))
      extract-file      superoffroad.1.z80  03-22119-02.u56t                  $((0x30000)) $((0x10000))

      extract-file      superoffroad.2.z80  03-22100-02.u3                    $((0x0))     $((0x2000))
      extract-file      superoffroad.2.z80  03-22108-02.u4t                   $((0x2000))  $((0x10000))
      extract-file      superoffroad.2.z80  03-22109-02.u5t                   $((0x12000)) $((0x10000))
      extract-file      superoffroad.2.z80  03-22110-02.u6t                   $((0x22000)) $((0x10000))
      extract-file      superoffroad.2.z80  03-22111-01.u7t                   $((0x32000)) $((0x10000))
      extract-file      superoffroad.2.z80  03-22112-01.u8t                   $((0x42000)) $((0x10000))

      deinterleave-file superoffroad.186    03-22113-03.u13t 03-22116-03.u25t $((0x0))     $((0x20000))
      deinterleave-file superoffroad.186    03-22114-03.u14t 03-22117-03.u26t $((0x20000)) $((0x20000))
      deinterleave-file superoffroad.186    03-22115-03.u15t 03-22118-03.u27t $((0x40000)) $((0x20000))

      extract-file      superoffroad.1.grom 03-22105-02.u93                   $((0x0))     $((0x8000))
      extract-file      superoffroad.1.grom 03-22106-02.u94                   $((0x8000))  $((0x8000))
      extract-file      superoffroad.1.grom 03-22107-02.u95                   $((0x10000)) $((0x8000))

      extract-file      superoffroad.user   03-22104-01.u92                   $((0x0))     $((0x4000))
      extract-file      superoffroad.user   03-22102-01.u69                   $((0x4000))  $((0x4000))
      extract-file      superoffroad.user   03-22103-02.u90                   $((0x8000))  $((0x4000))
      extract-file      superoffroad.user   03-22101-02.u67                   $((0xC000))  $((0x4000))

      extract-file      superoffroad.eeprom eeprom-offroad.bin                $((0x0))     $((0x80))

      package-zip                           offroad.zip
    ;;

    supersprint)
      deinterleave-file supersprint_a.t11  136042-330.7l 136042-331.7n $((0x0))     $((0x8000))
      deinterleave-file supersprint_a.t11  136042-329.6f 136042-325.6n $((0x8000))  $((0x10000))
      deinterleave-file supersprint_a.t11  136042-127.6k 136042-123.6r $((0x18000)) $((0x10000))
      deinterleave-file supersprint_a.t11  136042-126.6l 136042-122.6s $((0x28000)) $((0x10000))

      extract-file      supersprint_a.6502 136042-419.2bc              $((0x0))     $((0x4000))
      extract-file      supersprint_a.6502 136042-420.2d               $((0x4000))  $((0x4000))

      extract-file      supersprint.pfrom  136042-105.6a               $((0x20000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-105.6a               $((0x0))     $((0x8000))
      extract-file      supersprint.pfrom  136042-106.6b               $((0x8000))  $((0x8000))
      extract-file      supersprint.pfrom  136042-101.7a               $((0x30000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-101.7a               $((0x10000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-102.7b               $((0x18000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-107.6c               $((0x60000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-107.6c               $((0x40000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-108.6de              $((0x48000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-104.7de              $((0x70000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-104.7de              $((0x50000)) $((0x8000))
      extract-file      supersprint.pfrom  136042-103.7c               $((0x58000)) $((0x8000))

      extract-file      supersprint.mobrom 136042-113.6l               $((0x0))     $((0x8000))
      extract-file      supersprint.mobrom 136042-112.6k               $((0x8000))  $((0x8000))
      extract-file      supersprint.mobrom 136042-110.6jh              $((0x10000)) $((0x8000))
      extract-file      supersprint.mobrom 136042-109.6fh              $((0x18000)) $((0x8000))
      extract-file      supersprint.mobrom 136042-117.6rs              $((0x20000)) $((0x8000))
      extract-file      supersprint.mobrom 136042-116.6pr              $((0x28000)) $((0x8000))
      extract-file      supersprint.mobrom 136042-115.6n               $((0x30000)) $((0x8000))
      extract-file      supersprint.mobrom 136042-114.6m               $((0x38000)) $((0x8000))


      extract-file      supersprint.anrom  136042-118.6t               $((0x0))     $((0x4000))

      dummy-file                           ssprint-eeprom.bin                       $((0x200))
      package-zip                          ssprint.zip
    ;;

    tapper)
      extract-file tapper_r.1.grom rbtbg1.bin   $((0x0))     $((0x4000))
      extract-file tapper_r.1.grom rbtbg0.bin   $((0x4000))  $((0x4000))

      extract-file tapper_r.2.grom rbtfg1.bin   $((0x0))     $((0x4000))
      extract-file tapper_r.2.grom rbtfg0.bin   $((0x4000))  $((0x4000))
      extract-file tapper_r.2.grom rbtfg3.bin   $((0x8000))  $((0x4000))
      extract-file tapper_r.2.grom rbtfg2.bin   $((0xC000))  $((0x4000))
      extract-file tapper_r.2.grom rbtfg5.bin   $((0x10000)) $((0x4000))
      extract-file tapper_r.2.grom rbtfg4.bin   $((0x14000)) $((0x4000))
      extract-file tapper_r.2.grom rbtfg7.bin   $((0x18000)) $((0x4000))
      extract-file tapper_r.2.grom rbtfg6.bin   $((0x1C000)) $((0x4000))

      extract-file tapper_r.1.z80  rbtpg0.bin   $((0x0))     $((0x4000))
      extract-file tapper_r.1.z80  rbtpg1.bin   $((0x4000))  $((0x4000))
      extract-file tapper_r.1.z80  rbtpg2.bin   $((0x8000))  $((0x4000))
      extract-file tapper_r.1.z80  rbtpg3.bin   $((0xC000))  $((0x2000))

      extract-file tapper_r.2.z80  5788         $((0x0))     $((0x1000))
      extract-file tapper_r.2.z80  5787         $((0x1000))  $((0x1000))
      extract-file tapper_r.2.z80  5786         $((0x2000))  $((0x1000))
      extract-file tapper_r.2.z80  5785         $((0x3000))  $((0x1000))

      dummy-file                   82s123.12d              $((0x20))
      package-zip                  rbtapper.zip
    ;;

    toobin)
      deinterleave-file toobin_a.68k  3133-1j.061 3137-1f.061 $((0x0))      $((0x20000))
      deinterleave-file toobin_a.68k  3134-2j.061 3138-2f.061 $((0x20000))  $((0x20000))
      deinterleave-file toobin_a.68k  3135-4j.061 3139-4f.061 $((0x40000))  $((0x20000))
      deinterleave-file toobin_a.68k  1136-5j.061 1140-5f.061 $((0x60000))  $((0x20000))

      extract-file      toobin.6502   1141-2k.061             $((0x0))      $((0x10000))

      extract-file      toobin.1.grom 1101-1a.061             $((0x0))      $((0x10000))
      extract-file      toobin.1.grom 1102-2a.061             $((0x10000))  $((0x10000))
      extract-file      toobin.1.grom 1103-4a.061             $((0x20000))  $((0x10000))
      extract-file      toobin.1.grom 1104-5a.061             $((0x30000))  $((0x10000))
      extract-file      toobin.1.grom 1105-1b.061             $((0x40000))  $((0x10000))
      extract-file      toobin.1.grom 1106-2b.061             $((0x50000))  $((0x10000))
      extract-file      toobin.1.grom 1107-4b.061             $((0x60000))  $((0x10000))
      extract-file      toobin.1.grom 1108-5b.061             $((0x70000))  $((0x10000))

      extract-file      toobin.2.grom 1143-10a.061            $((0x0))      $((0x20000))
      extract-file      toobin.2.grom 1144-13a.061            $((0x20000))  $((0x20000))
      extract-file      toobin.2.grom 1145-16a.061            $((0x40000))  $((0x20000))
      extract-file      toobin.2.grom 1146-18a.061            $((0x60000))  $((0x20000))
      extract-file      toobin.2.grom 1125-21a.061            $((0x80000))  $((0x10000))
      extract-file      toobin.2.grom 1126-23a.061            $((0x90000))  $((0x10000))
      extract-file      toobin.2.grom 1127-24a.061            $((0xA0000))  $((0x10000))
      extract-file      toobin.2.grom 1128-25a.061            $((0xB0000))  $((0x10000))
      extract-file      toobin.2.grom 1147-10b.061            $((0xC0000))  $((0x20000))
      extract-file      toobin.2.grom 1148-13b.061            $((0xE0000))  $((0x20000))
      extract-file      toobin.2.grom 1149-16b.061            $((0x100000)) $((0x20000))
      extract-file      toobin.2.grom 1150-18b.061            $((0x120000)) $((0x20000))
      extract-file      toobin.2.grom 1129-21b.061            $((0x140000)) $((0x10000))
      extract-file      toobin.2.grom 1130-23b.061            $((0x150000)) $((0x10000))
      extract-file      toobin.2.grom 1131-24b.061            $((0x160000)) $((0x10000))
      extract-file      toobin.2.grom 1132-25b.061            $((0x170000)) $((0x10000))

      extract-file      toobin.3.grom 1142-20h.061            $((0x0))      $((0x4000))

      package-zip       toobin.zip
    ;;

    totalcarnage)
      deinterleave-file totalcarnage.34010  la1_total_carnage_game_rom_u105.u105 la1_total_carnage_game_rom_u89.u89 $((0x0))      $((0x80000))

      extract-file      totalcarnage.6809   sl1_total_carnage_sound_rom_u3.u3                                       $((0x0))      $((0x20000))

      extract-file      totalcarnage.pcmrom sl1_total_carnage_sound_rom_u12.u12                                     $((0x0))      $((0x40000))
      extract-file      totalcarnage.pcmrom sl1_total_carnage_sound_rom_u13.u13                                     $((0x40000))  $((0x40000))

      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u111.u111                                    $((0x0))      $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u112.u112                                    $((0x40000))  $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u113.u113                                    $((0x80000))  $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u114.u114                                    $((0xC0000))  $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u95.u95                                      $((0x100000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u96.u96                                      $((0x140000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u97.u97                                      $((0x180000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u98.u98                                      $((0x1C0000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u106.u106                                    $((0x200000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u107.u107                                    $((0x240000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u108.u108                                    $((0x280000)) $((0x40000))
      extract-file      totalcarnage.grom   la1_total_carnage_game_rom_u109.u109                                    $((0x2C0000)) $((0x40000))

      package-zip                           totcarn.zip
    ;;

    tournamentcyberball2072)
      deinterleave-file tournamentcyberball2072.1.68k  136073-2007.1m 136073-2008.1kl $((0x0))      $((0x20000))
      deinterleave-file tournamentcyberball2072.1.68k  136073-2009.3m 136073-2010.3kl $((0x20000))  $((0x20000))

      deinterleave-file tournamentcyberball2072.2.68k  136073-2011.3cd 136073-2012.1b $((0x0))      $((0x20000))
      deinterleave-file tournamentcyberball2072.2.68k  136073-1013.1cd 136073-1014.3b $((0x20000))  $((0x20000))

      deinterleave-file tournamentcyberball2072.3.68k  136064-1132.3cd 136064-1133.1b $((0x0))      $((0x20000))
      deinterleave-file tournamentcyberball2072.3.68k  136064-1134.1cd 136064-1135.3b $((0x20000))  $((0x20000))

      extract-file      tournamentcyberball2072.6502   136073-1029.2f                 $((0x0))      $((0x10000))

      extract-file      tournamentcyberball2072.1.grom 136071-1001.55l                $((0x0))      $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1005.43l                $((0x20000))  $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1032.18a                $((0x40000))  $((0x10000))
      extract-file      tournamentcyberball2072.1.grom 136071-1002.55n                $((0x170000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1006.43n                $((0x190000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1033.13a                $((0x210000)) $((0x10000))
      extract-file      tournamentcyberball2072.1.grom 136071-1003.90l                $((0x2E0000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1007.78l                $((0x300000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1034.18c                $((0x320000)) $((0x10000))
      extract-file      tournamentcyberball2072.1.grom 136071-1004.90n                $((0x450000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1008.78n                $((0x470000)) $((0x20000))
      extract-file      tournamentcyberball2072.1.grom 136071-1035.13c                $((0x490000)) $((0x10000))

      extract-file      tournamentcyberball2072.2.grom 136073-1001.9lm                $((0x0))      $((0x10000))
      extract-file      tournamentcyberball2072.2.grom 136073-1002.8lm                $((0x10000))  $((0x10000))
      extract-file      tournamentcyberball2072.2.grom 136073-1003.11lm               $((0x20000))  $((0x10000))
      extract-file      tournamentcyberball2072.2.grom 136073-1004.10lm               $((0x30000))  $((0x10000))

      extract-file      tournamentcyberball2072.3.grom 136073-1005.15n                $((0x0))      $((0x10000))
      extract-file      tournamentcyberball2072.3.grom 136073-1006.16n                $((0x10000))  $((0x10000))

      dummy-file                                       cyberbalt-eeprom.bin                         $((0x800))
      package-zip                                      cyberbalt.zip
    ;;

    vindicators2)
      deinterleave-file vindicators2_a.68k    136059-1186.9a 136059-1187.9b   $((0x8000))  $((0x8000))
      deinterleave-file vindicators2_a.68k    136059-1186.9a 136059-1187.9b   $((0x0))     $((0x8000))

      deinterleave-file vindicators2_a.2.68k  136059-1196.10a 136059-1197.10b $((0x0))     $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-3188.7a 136059-3189.7b   $((0x10000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-3188.7a 136059-3189.7b   $((0x8000))  $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-2190.6a 136059-2191.6b   $((0x20000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-2190.6a 136059-2191.6b   $((0x18000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-2192.5a 136059-2193.5b   $((0x30000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-2192.5a 136059-2193.5b   $((0x28000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-1194.3a 136059-1195.3b   $((0x40000)) $((0x8000))
      deinterleave-file vindicators2_a.2.68k  136059-1194.3a 136059-1195.3b   $((0x38000)) $((0x8000))

      extract-file      vindicators2.6502     136059-1160.16s                 $((0x0))     $((0x4000))
      extract-file      vindicators2.6502     136059-1161.16r                 $((0x4000))  $((0x8000))

      extract-file      vindicators2.1.grom   136059-1198.6p                  $((0x0))     $((0x4000))

      extract-file      vindicators2.2.grom   136059-1162.1a                  $((0x0))     $((0x8000))
      extract-file      vindicators2.2.grom   136059-1166.1b                  $((0x8000))  $((0x8000))
      extract-file      vindicators2.2.grom   136059-1170.1c                  $((0x10000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1174.1d                  $((0x18000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1178.1ef                 $((0x20000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1182.1j                  $((0x28000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1163.1l                  $((0x30000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1167.1mn                 $((0x38000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1171.1p                  $((0x40000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1175.1r                  $((0x48000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1179.1st                 $((0x50000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1183.1u                  $((0x58000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1164.2a                  $((0x60000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1168.2b                  $((0x68000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1172.2c                  $((0x70000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1176.2d                  $((0x78000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1180.2ef                 $((0x80000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1184.2j                  $((0x88000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1165.2l                  $((0x90000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1169.2mn                 $((0x98000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1173.2p                  $((0xA0000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1177.2r                  $((0xA8000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1181.2st                 $((0xB0000)) $((0x8000))
      extract-file      vindicators2.2.grom   136059-1185.2u                  $((0xB8000)) $((0x8000))

      dummy-file                              74s472-136037-101.7u                         $((0x200))
      dummy-file                              74s472-136037-102.5l                         $((0x200))
      dummy-file                              74s287-136037-103.4r                         $((0x100))
      package-zip                             vindctr2.zip
    ;;

    wizardofwor)
      extract-file wizardofwor.z80 wow.x1  $((0x0))    $((0x1000))
      extract-file wizardofwor.z80 wow.x2  $((0x1000)) $((0x1000))
      extract-file wizardofwor.z80 wow.x3  $((0x2000)) $((0x1000))
      extract-file wizardofwor.z80 wow.x4  $((0x3000)) $((0x1000))
      extract-file wizardofwor.z80 wow.x5  $((0x4000)) $((0x1000))
      extract-file wizardofwor.z80 wow.x6  $((0x5000)) $((0x1000))
      extract-file wizardofwor.z80 wow.x7  $((0x6000)) $((0x1000))

      package-zip                  wow.zip
    ;;

    xenophobe)
      deinterleave-file xenophobe.1.68k  xeno_pro.3c xeno_pro.3b  $((0x0))     $((0x20000))
      deinterleave-file xenophobe.1.68k  xeno_pro.2c xeno_pro.2b  $((0x20000)) $((0x20000))

      deinterleave-file xenophobe.2.68k  xeno_snd.u7 xeno_snd.u17 $((0x0))     $((0x20000))
      deinterleave-file xenophobe.2.68k  xeno_snd.u8 xeno_snd.u18 $((0x20000)) $((0x20000))

      extract-file      xenophobe.1.grom xeno_bg.11d              $((0x0))     $((0x8000))
      extract-file      xenophobe.1.grom xeno_bg.12d              $((0x8000))  $((0x8000))

      extract-file      xenophobe.2.grom xeno_fg.7j               $((0x0))     $((0x10000))
      extract-file      xenophobe.2.grom xeno_fg.8j               $((0x10000)) $((0x10000))
      extract-file      xenophobe.2.grom xeno_fg.9j               $((0x20000)) $((0x10000))
      extract-file      xenophobe.2.grom xeno_fg.10j              $((0x30000)) $((0x10000))

      dummy-file                         e36a31axnaxad.bin                     $((0xCC))
      package-zip                        xenophob.zip
    ;;

    xybots)
      deinterleave-file xybots_a.68k  136054-2112.17cd 136054-2113.19cd $((0x0))     $((0x20000))
      deinterleave-file xybots_a.68k  136054-2114.17b 136054-2115.19b   $((0x20000)) $((0x10000))

      extract-file      xybots.6502   136054-1116.2k                    $((0x0))     $((0x10000))

      extract-file      xybots.1.grom 136054-2102.12l                   $((0x0))     $((0x8000))
      extract-file      xybots.1.grom 136054-2103.11l                   $((0x8000))  $((0x10000))
      extract-file      xybots.1.grom 136054-2117.8l                    $((0x18000)) $((0x10000))

      extract-file      xybots.2.grom 136054-1105.2e                    $((0x0))     $((0x10000))
      extract-file      xybots.2.grom 136054-1106.2ef                   $((0x10000)) $((0x10000))
      extract-file      xybots.2.grom 136054-1107.2f                    $((0x20000)) $((0x10000))
      extract-file      xybots.2.grom 136054-1108.2fj                   $((0x30000)) $((0x10000))
      extract-file      xybots.2.grom 136054-1109.2jk                   $((0x40000)) $((0x10000))
      extract-file      xybots.2.grom 136054-1110.2k                    $((0x50000)) $((0x10000))
      extract-file      xybots.2.grom 136054-1111.2l                    $((0x60000)) $((0x10000))

      extract-file      xybots.3.grom 136054-1101.5c                    $((0x0))     $((0x2000))

      package-zip                     xybots.zip
    ;;
  esac
}

GAMES_LIST=(
  # Midway Arcade Origins (Xbox 360)
  # All games except Marble Madness extract correctly
  _720
  apb
  archrivals
  bubbles
  championshipsprint
  defender
  gauntlet
  gauntlet2
  joust
  joust2
  marblemadness
  pitfighter
  rampage
  rampart
  robotron
  satanshollow
  sinistar
  smashtv
  spyhunter
  spyhunter2
  stargate
  stargate.defender2
  superoffroad
  supersprint
  tapper
  toobin
  totalcarnage
  tournamentcyberball2072
  vindicators2
  wizardofwor
  xenophobe
  xybots

  # Sega XBLA games
  # NOTE: none of these will extract 100% correctly
  ABEAST16
  GAXE16
  SHINOARC
)

if [[ -f ./decompress-sr-files.sh ]]; then
  chmod +x ./decompress-sr-files.sh
  ./decompress-sr-files.sh || exit 1
fi

for i in ${GAMES_LIST[@]}; do
  ROM_DIR=$(echo $i | cut -d'.' -f1)
  [[ ! -d $ROM_DIR ]] && continue

  cd $ROM_DIR
  mkdir -p roms

  echo "Extracting $i..."
  extract-rom $i

  rm -r roms
  cd ..
done


================================================
FILE: ROM Extraction/namco-ags-extract.sh
================================================
#!/bin/bash

MD5_LIST=(
  35c711a43ff21e6634cf136618d95566 # Release_0.dll
  92934b771109d8073cf85038548c9dcd # Release_1.dll
  d6f27e05e97c39d9aa4f9032c14c22ce # Release_2.dll
  e55329760178c2dc654cbe17648dc4c4 # Release_3.dll
)

extract-rom() {
  WORKING_FILE="$DLL_PATH"
  case $1 in
    Release_0.dll) # Dig Dug
      extract-file 136007.110 $((0x1D9F0)) $((0x100))
      extract-file dd1.10b    $((0x1DAF0)) $((0x1000))
      extract-file 136007.113 $((0x1EAF0)) $((0x20))
      extract-file 136007.111 $((0x1EB10)) $((0x100))
      extract-file 136007.112 $((0x1EC10)) $((0x100))
      extract-file dd1.15     $((0x1ED10)) $((0x1000))
      extract-file dd1.14     $((0x1FD10)) $((0x1000))
      extract-file dd1.13     $((0x20D10)) $((0x1000))
      extract-file dd1.12     $((0x21D10)) $((0x1000))
      extract-file dd1.9      $((0x22D10)) $((0x800))
      extract-file dd1.11     $((0x23510)) $((0x1000))
      extract-file dd1.7      $((0x35420)) $((0x1000))
      extract-file dd1a.5     $((0x36420)) $((0x1000))
      extract-file dd1a.6     $((0x37420)) $((0x1000))
      extract-file dd1a.1     $((0x38420)) $((0x1000))
      extract-file dd1a.2     $((0x39420)) $((0x1000))
      extract-file dd1a.3     $((0x3A420)) $((0x1000))
      extract-file dd1a.4     $((0x3B420)) $((0x1000))
      dummy-file   136007.109              $((0x100))
      package-zip  digdug.zip
    ;;

    Release_1.dll) # Galaga
      extract-file prom-1.1d $((0x56710)) $((0x100))
      extract-file prom-5.5n $((0x56810)) $((0x20))
      extract-file prom-3.1c $((0x56830)) $((0x100))
      extract-file prom-4.2n $((0x56930)) $((0x100))
      extract-file gg1_11.4d $((0x56A30)) $((0x1000))
      extract-file gg1_10.4f $((0x57A30)) $((0x1000))
      extract-file gg1_9.4l  $((0x58A30)) $((0x1000))
      extract-file gg1_7b.2c $((0x64A00)) $((0x1000))
      extract-file gg1_5b.3f $((0x65A00)) $((0x1000))
      extract-file gg1_1b.3p $((0x66A00)) $((0x1000))
      extract-file gg1_2b.3m $((0x67A00)) $((0x1000))
      extract-file gg1_3.2m  $((0x68A00)) $((0x1000))
      extract-file gg1_4b.2l $((0x69A00)) $((0x1000))
      dummy-file   prom-2.5c              $((0x100))
      package-zip  galaga.zip
    ;;

    Release_2.dll) # Ms. Pac-Man
      check-unusable && (
        extract-file 82s126.1m $((0x1AE30)) $((0x100))
        extract-file 82s123.7f $((0x1AF30)) $((0x20))
        extract-file 82s126.4a $((0x1AF50)) $((0x100))
        extract-file 5f        $((0x1B050)) $((0x1000))
      # extract-file 5e        $((0x1C050)) $((0x1000)) # alternate ROM?
        extract-file 5e        $((0x1D050)) $((0x1000))
        extract-file boot1     $((0x28C20)) $((0x1000))
        extract-file boot2     $((0x29C20)) $((0x1000))
        extract-file boot3     $((0x2AC20)) $((0x1000))
        extract-file boot4     $((0x2BC20)) $((0x1000))
        extract-file boot5     $((0x30C20)) $((0x1000))
        extract-file boot6     $((0x31C20)) $((0x1000))
        dummy-file   82s126.3m              $((0x100))
        package-zip  mspacmab.zip
      )
    ;;

    Release_3.dll) # Pac-Man
      extract-file 82s126.1m $((0x1AA30)) $((0x100))
      extract-file 82s123.7f $((0x1AB30)) $((0x20))
      extract-file 82s126.4a $((0x1AB50)) $((0x100))
      extract-file pacman.5f $((0x1AC50)) $((0x1000))
      extract-file pacman.5e $((0x1C050)) $((0x1000))
      extract-file pacman.6e $((0x28020)) $((0x1000))
      extract-file pacman.6f $((0x29020)) $((0x1000))
      extract-file pacman.6h $((0x2A020)) $((0x1000))
      extract-file pacman.6j $((0x2B020)) $((0x1000))
      dummy-file   82s126.3m              $((0x100))
      package-zip  pacman.zip
    ;;
  esac
}

extract-file() {
  dd if="$WORKING_FILE" of="$WORKING_DIR/roms/$1" skip=$2 count=$3 status=none iflag=skip_bytes,count_bytes
}

dummy-file() {
  dd if=/dev/zero of="$WORKING_DIR/roms/$1" count=$2 status=none iflag=count_bytes
}

package-zip() {
  cd "$WORKING_DIR/roms"
  zip -q "$WORKING_DIR/zips/$1" *
  rm *
  cd "$GAMES_DIR"
}

check-unusable() {
  [[ $EXTRACT_ALL != 1 ]] && return 1
  [[ $EXTRACT_ALL = 1 ]] && \
    echo "Note: "$(basename "$WORKING_FILE")" produces an unusable ROM" && return 0
}

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

print-usage() {
  echo "$1"
  echo
  echo "Usage: $0 <release-dll> [-a]"
  echo
  echo "  <release-dll> is the path to a \"Release_<x>.dll\" file inside"
  echo "  the \"Plugins\" folder of the Arcade Game Series data folder."
  echo
  echo "  -a option extracts all ROMs, including unusable ones."
  exit 1
}

#####################################################################################

[[ $# -eq 0 || $1 = "--help" || $1 = "-h" ]] && \
  print-usage "Extracts ROMs from the Arcade Game Series, available on Steam."

DLL_PATH=$(realpath "$1")
[[ ! -f "$DLL_PATH" ]] && print-usage "DLL path is incorrect."
[[ $2 = "-a" ]] && EXTRACT_ALL=1

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))

[[ -z $(which zip) ]] && missing-dependency zip

echo "Verifying DLL..."
DLL_MD5=$(md5sum "$DLL_PATH" | cut -d" " -f1)

for i in ${MD5_LIST[@]}; do
  [[ $i = $DLL_MD5 ]] && VERIFIED=1
done

if [[ $VERIFIED != 1 ]]; then
  echo
  echo "This DLL is not verified to work with this script."
  echo "You may continue to run it, but it may not work as expected."
  echo "Press Enter to continue or CTRL+C to quit..."
  read _
fi

echo "Initializing directories..."
WORKING_DIR=/tmp/.namco-ags
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/roms"
mkdir -p "$WORKING_DIR/zips"

START_DIR="$PWD"
cd "$WORKING_DIR"

if [[ $EXTRACT_ALL != 1 && "$DLL_PATH" = *Release_2.dll ]]; then
  echo
  echo "Unfortunately, Ms. Pac-Man from the Arcade Game Series is"
  echo "not usable with emulators. If you would like to extract"
  echo "it anyway, re-run this script with the [-a] option."
  echo

  rm -r "$WORKING_DIR"
  exit 1
fi

for i in $(basename "$DLL_PATH"); do
  echo "Extracting $i..." && extract-rom $i
done

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/zips"/* .
rm -r "$WORKING_DIR"

echo "Done!"


================================================
FILE: ROM Extraction/rpf-extract.sh
================================================
#!/bin/bash
# Extract files from an RPF archive (Activision resource pack format)
#
# RPF is a simple resource archive used by Activision compilations
# (e.g., Activision Anthology for PS2) to bundle ROM files, cover art,
# manuals, and screenshots.
#
# Requires only GNU coreutils (dd, od, tr, stat, head, mkdir)
#
# Format reference and QuickBMS implementation by Edness:
# https://github.com/EdnessP/scripts/blob/main/other/activisionRPF.bms

ALIGNMENT=64
HEADER_SIZE=64
DIR_ENTRY_SIZE=84

# Read a little-endian uint32 from file $1 at byte offset $2
read-u32le() {
    local b0 b1 b2 b3
    read -r b0 b1 b2 b3 <<< "$(od -An -tu1 -j "$2" -N 4 "$1")"
    echo $(( b0 + b1 * 256 + b2 * 65536 + b3 * 16777216 ))
}

# Read a null-terminated string from file $1 at offset $2, max length $3
read-string() {
    dd if="$1" skip="$2" count="$3" iflag=skip_bytes,count_bytes status=none \
        | tr '\0' '\n' | head -1
}

# Round $1 up to the next ALIGNMENT boundary
align() {
    echo $(( ($1 + ALIGNMENT - 1) / ALIGNMENT * ALIGNMENT ))
}

print-usage() {
    echo "Extract files from an RPF archive (Activision resource pack format)"
    echo ""
    echo "Usage: $(basename "$0") <archive.rpf> [output_directory]"
}

###########################################################

if [[ $# -lt 1 ]]; then
    print-usage
    exit 1
fi

WORKING_FILE=$(realpath "$1")
OUTPUT_DIR=${2:-.}

if [[ ! -f "$WORKING_FILE" ]]; then
    echo "Error: File not found: $WORKING_FILE" >&2
    exit 1
fi

ACTUAL_SIZE=$(stat -c%s "$WORKING_FILE")
if [[ $ACTUAL_SIZE -lt $HEADER_SIZE ]]; then
    echo "Error: File too small to be a valid RPF archive" >&2
    exit 1
fi

mkdir -p "$OUTPUT_DIR"

# Parse header
FILE_SIZE=$(read-u32le "$WORKING_FILE" 0)
ENTRY_COUNT=$(read-u32le "$WORKING_FILE" 4)
DATA_SECTION_SIZE=$(read-u32le "$WORKING_FILE" $((0x20)))

if [[ $FILE_SIZE -ne $ACTUAL_SIZE ]]; then
    echo "Warning: header file_size ($FILE_SIZE) != actual ($ACTUAL_SIZE)" >&2
fi

DATA_START=$(( HEADER_SIZE + ENTRY_COUNT * DIR_ENTRY_SIZE ))
POS=0

for (( i = 0; i < ENTRY_COUNT; i++ )); do
    ENTRY_BASE=$(( HEADER_SIZE + i * DIR_ENTRY_SIZE ))

    CONTENT_SIZE=$(read-u32le "$WORKING_FILE" "$ENTRY_BASE")
    FILENAME=$(read-string "$WORKING_FILE" $(( ENTRY_BASE + 0x14 )) 64)

    dd if="$WORKING_FILE" of="$OUTPUT_DIR/$FILENAME" \
        skip=$(( DATA_START + POS )) count="$CONTENT_SIZE" \
        iflag=skip_bytes,count_bytes status=none

    echo "$FILENAME ($CONTENT_SIZE bytes)"

    POS=$(( POS + CONTENT_SIZE ))

    # Check for MSVC debug-heap 0xFD padding before the next entry
    if [[ $i -lt $(( ENTRY_COUNT - 1 )) ]]; then
        MARKER=$(od -An -tx1 -j $(( DATA_START + POS )) -N 4 "$WORKING_FILE" | tr -d ' ')
        if [[ "$MARKER" = "fdfdfdfd" ]]; then
            POS=$(align $(( POS + 4 )))
        elif [[ $(( CONTENT_SIZE % ALIGNMENT )) -ne 0 ]]; then
            BYTE=$(od -An -tu1 -j $(( DATA_START + POS )) -N 1 "$WORKING_FILE" | tr -d ' ')
            if [[ "$BYTE" = "253" ]]; then
                POS=$(align "$POS")
            fi
        fi
    fi
done

echo "Extracted $ENTRY_COUNT files to $OUTPUT_DIR"


================================================
FILE: ROM Extraction/super-bomberman-extract.sh
================================================
#!/usr/bin/env bash
set -euo pipefail

if [ $# -lt 1 ]; then
  echo "Usage: $0 <input-file> [output-file-without-extension]"
  exit 1
fi

INPUT="$1"
BASENAME="${2:-${INPUT%.*}}"

# Read first 4 bytes (filename length, little-endian 32-bit)
FILENAME_LEN=$(od -An -t u4 -N4 -v "$INPUT" | tr -d ' ')

# Round up to next multiple of 4
PADDED_FILENAME_LEN=$(( (FILENAME_LEN + 3) & ~3 ))

# Offset where data length field begins
DATA_LEN_OFFSET=$(( 4 + PADDED_FILENAME_LEN ))

# Read 4-byte data length
DATA_LEN=$(od -An -t u4 -j "$DATA_LEN_OFFSET" -N4 -v "$INPUT" | tr -d ' ')

# Data starts after:
# 4 bytes (filename length)
# padded filename
# 4 bytes (data length)
DATA_OFFSET=$(( DATA_LEN_OFFSET + 4 ))

# Extract data to temporary file first
TMP_FILE=$(mktemp)
dd if="$INPUT" of="$TMP_FILE" bs=1 skip="$DATA_OFFSET" count="$DATA_LEN" status=none

# Binary-safe magic check
if head -c 3 "$TMP_FILE" | cmp -s - <(printf 'NES'); then
  EXT="nes"
else
  EXT="sfc"
fi

OUTPUT="${BASENAME}.${EXT}"
mv "$TMP_FILE" "$OUTPUT"

echo "Extracted $DATA_LEN bytes to $OUTPUT"


================================================
FILE: ROM Extraction/tmnt-cc-arcade-extract.sh
================================================
#!/bin/bash

ROM_LIST=(
  TeenageMutantNinjaTurtles
  TeenageMutantNinjaTurtles2
)

extract-rom() {
  WORKING_FILE="$START_DIR/$1"
  cd "$WORKING_FILE"

  case $1 in
    TeenageMutantNinjaTurtles)
      split-file                                      tmnt.maincpu         $((0x40000))
      split-file                                      tmnt.k051960         $((0x100000))
      split-file                                      tmnt.proms           $((0x100))
      patch-file                                      tmnt.maincpu.split0  $((0x15A0))
      dummy-file              963a25.d5                                    $((0x80000))
      copy-file               963e20.g13              tmnt.audiocpu
      copy-file               963a30.g7               tmnt.proms.split0
      copy-file               963a31.g19              tmnt.proms.split1
      copy-file               963a26.c13              tmnt.k007232
      copy-file               963a27.d18              tmnt.upd
      deinterleave-file       963-x23.j17+963-x24.k17 tmnt.maincpu.split0
      deinterleave-file       963-x21.j15+963-x22.k15 tmnt.maincpu.split1
      deinterleave-file-16bit 963a28.h27+963a29.k27   tmnt.k052109
      deinterleave-file-16bit 963a17.h4+963a15.k4     tmnt.k051960.split0
      deinterleave-file-16bit 963a18.h6+963a16.k6     tmnt.k051960.split1
      package-zip             tmnt.zip

      split-file                                      tmntj.maincpu        $((0x40000))
      patch-file                                      tmntj.maincpu.split0 $((0x15A8))
      deinterleave-file       963_223.j17+963_224.k17 tmntj.maincpu.split0
      deinterleave-file       963_221.j15+963_222.k15 tmntj.maincpu.split1
      package-zip             tmntj.zip
    ;;

    TeenageMutantNinjaTurtles2)
      split-file                                        tmnt2.maincpu        $((0x40000))
      split-file                                        tmnt2.k053245        $((0x200000))
      patch-file                                        tmnt2.maincpu.split0 $((0x19FA))
      copy-file               063b01.2f                 tmnt2.audiocpu
      copy-file               063b06.1d                 tmnt2.k053260
      copy-file               tmnt2_uaa.nv              tmnt2.eeprom
      deinterleave-file       063uaa02.8e+063uaa03.8g   tmnt2.maincpu.split0
      deinterleave-file       063uaa04.10e+063uaa05.10g tmnt2.maincpu.split1
      deinterleave-file-16bit 063b12.16k+063b11.12k     tmnt2.k052109
      deinterleave-file-16bit 063b09.7l+063b07.3l       tmnt2.k053245.split0
      deinterleave-file-16bit 063b10.7k+063b08.3k       tmnt2.k053245.split1
      package-zip             tmnt2.zip
    ;;
  esac
}

split-file() {
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -split $1 $2 $1.split
}

copy-file() {
  dd if="$2" of="$WORKING_DIR/roms/$1" status=none
}

dummy-file() {
  dd if=/dev/zero of="$WORKING_DIR/roms/$1" count=$2 status=none iflag=count_bytes
}

patch-file() {
  printf '\x60' | dd of="$1" bs=1 seek=$2 count=1 conv=notrunc status=none
}

deinterleave-file() {
  FILE1=$(echo $1 | cut -d+ -f1)
  FILE2=$(echo $1 | cut -d+ -f2)
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -deinterleave $2 "$WORKING_DIR/roms/$FILE1" "$WORKING_DIR/roms/$FILE2"
}

deinterleave-file-16bit() {
  FILE1_16BIT=$(echo $1 | cut -d+ -f1)
  FILE2_16BIT=$(echo $1 | cut -d+ -f2)

  deinterleave-file 1and3+2and4 $2

  mv "$WORKING_DIR/roms/1and3" .
  deinterleave-file 1+3 1and3

  mv "$WORKING_DIR/roms/2and4" .
  deinterleave-file 2+4 2and4

  python3 "$SCRIPT_DIR/ts_rom_tool.py" -interleave "$WORKING_DIR/roms/1" "$WORKING_DIR/roms/2" "$WORKING_DIR/roms/$FILE1_16BIT"
  python3 "$SCRIPT_DIR/ts_rom_tool.py" -interleave "$WORKING_DIR/roms/3" "$WORKING_DIR/roms/4" "$WORKING_DIR/roms/$FILE2_16BIT"

  rm "$WORKING_DIR/roms/1"
  rm "$WORKING_DIR/roms/2"
  rm "$WORKING_DIR/roms/3"
  rm "$WORKING_DIR/roms/4"
  rm 1and3
  rm 2and4
}

package-zip() {
  cd "$WORKING_DIR/roms"
  zip -q "$WORKING_DIR/zips/$1" *
  rm *
  rm "$WORKING_FILE"/*.split*
  cd - > /dev/null
}

missing-dependency() {
  echo "This script requires $1 to be installed."
  echo "On a Debian / Ubuntu machine, this can be installed by running:"
  echo
  echo "  sudo apt install $1"
  echo
  exit 1
}

missing-dependency-tsromtool() {
  echo "This script requires ts_rom_tool.py to be installed."
  echo "Please place ts_rom_tool.py in the same directory as this script, then try again."
  echo
  echo "ts_rom_tool.py can be obtained from: https://github.com/twistedsymphony/ts_rom_tool"
  echo
  exit 1
}

print-usage() {
  echo "Extracts arcade ROMs from the TMNT Cowabunga Collection."
  echo
  echo "Place this script in the roms/Konami folder from your extracted assets.pie."
  echo "To extract assets.pie, please use the Cowabunga tool, which can be obtained from:"
  echo
  echo "https://github.com/Masquerade64/Cowabunga"
  echo
  exit 1
}

#####################################################################################

[[ ! -d TeenageMutantNinjaTurtles ]] && print-usage

echo "Checking dependencies..."
SCRIPT_DIR=$(pwd $(dirname "$0"))

[[ ! -f "$SCRIPT_DIR/ts_rom_tool.py" ]] && missing-dependency-tsromtool
[[ -z $(which zip) ]] && missing-dependency zip
[[ -z $(which python3) ]] && missing-dependency python3

echo "Initializing directories..."
WORKING_DIR=/tmp/.tmnt-cc-arcade
rm -rf "$WORKING_DIR"
mkdir -p "$WORKING_DIR/roms"
mkdir -p "$WORKING_DIR/zips"

START_DIR="$PWD"
cd "$WORKING_DIR"

for i in ${ROM_LIST[@]}; do
  [[ -d "$START_DIR"/$i ]] && echo "Extracting $i..." && extract-rom $i
done

echo "Cleaning up..."
cd "$START_DIR"
mv "$WORKING_DIR/zips"/* .
rm -r "$WORKING_DIR"

echo "Done!"
Download .txt
gitextract_h3mx0wvj/

├── README.md
└── ROM Extraction/
    ├── arcade1up-extract.sh
    ├── arcade1up-pinball-extract.sh
    ├── contra-ac-extract.sh
    ├── decompress-sr-files.sh
    ├── generate-timing-rom.sh
    ├── konami-xbla-extract.sh
    ├── midway-arcade-origins-extract.sh
    ├── namco-ags-extract.sh
    ├── rpf-extract.sh
    ├── super-bomberman-extract.sh
    └── tmnt-cc-arcade-extract.sh
Condensed preview — 12 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (143K chars).
[
  {
    "path": "README.md",
    "chars": 872,
    "preview": "## ROM Extraction Documentation Project\n\n### **[Enter the RED-Project Wiki](https://github.com/farmerbb/RED-Project/wiki"
  },
  {
    "path": "ROM Extraction/arcade1up-extract.sh",
    "chars": 20576,
    "preview": "#!/bin/bash\n\nROM_LIST=(\n  DigDugII.rom\n  DigDug.rom\n  Galaga.rom\n  Galaga88.sav\n  Galaxian.rom\n  Mappy.rom\n  MsPacMan.ro"
  },
  {
    "path": "ROM Extraction/arcade1up-pinball-extract.sh",
    "chars": 2932,
    "preview": "#!/bin/bash\n\nMD5_LIST=(\n  22bb217596afc85943cf62a0df311013 # 20210830_pinball_wms_release_1920x1080_1G-5b.img\n  3267505d"
  },
  {
    "path": "ROM Extraction/contra-ac-extract.sh",
    "chars": 6937,
    "preview": "#!/bin/bash\n\nMD5_LIST=(\n  d9255086fadc4179b9298e7e9d9787bc\n)\n\nextract-rom() {\n  WORKING_FILE=\"$EXE_PATH\"\n\n  extract-file"
  },
  {
    "path": "ROM Extraction/decompress-sr-files.sh",
    "chars": 1343,
    "preview": "#!/bin/bash\n\n[[ ! -f offzip ]] && \\\n  echo \"Please compile and place the offzip program in the current directory, alongs"
  },
  {
    "path": "ROM Extraction/generate-timing-rom.sh",
    "chars": 666,
    "preview": "#!/bin/bash\n\n# Generates timing ROMs used in various Namco arcade games.\n# Needed in order to get Xevious and Super Xevi"
  },
  {
    "path": "ROM Extraction/konami-xbla-extract.sh",
    "chars": 13544,
    "preview": "#!/bin/bash\n\nROM_LIST=(\n  contra.rom\n  Frogger.rom\n  Gyruss.rom\n  RushNAttack.rom\n  Scramble.rom\n  Supercontra.rom\n  Tim"
  },
  {
    "path": "ROM Extraction/midway-arcade-origins-extract.sh",
    "chars": 75486,
    "preview": "#!/bin/bash\n\nextract-file() {\n  dd if=$1 skip=$3 count=$4 status=none iflag=skip_bytes,count_bytes >> roms/$2\n}\n\ndeinter"
  },
  {
    "path": "ROM Extraction/namco-ags-extract.sh",
    "chars": 6195,
    "preview": "#!/bin/bash\n\nMD5_LIST=(\n  35c711a43ff21e6634cf136618d95566 # Release_0.dll\n  92934b771109d8073cf85038548c9dcd # Release_"
  },
  {
    "path": "ROM Extraction/rpf-extract.sh",
    "chars": 3121,
    "preview": "#!/bin/bash\n# Extract files from an RPF archive (Activision resource pack format)\n#\n# RPF is a simple resource archive u"
  },
  {
    "path": "ROM Extraction/super-bomberman-extract.sh",
    "chars": 1063,
    "preview": "#!/usr/bin/env bash\nset -euo pipefail\n\nif [ $# -lt 1 ]; then\n  echo \"Usage: $0 <input-file> [output-file-without-extensi"
  },
  {
    "path": "ROM Extraction/tmnt-cc-arcade-extract.sh",
    "chars": 5662,
    "preview": "#!/bin/bash\n\nROM_LIST=(\n  TeenageMutantNinjaTurtles\n  TeenageMutantNinjaTurtles2\n)\n\nextract-rom() {\n  WORKING_FILE=\"$STA"
  }
]

About this extraction

This page contains the full source code of the farmerbb/RED-Project GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 12 files (135.2 KB), approximately 49.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!