ROM stripping

From PHWiki

ROM stripping or "trimming", "truncating/truncing" and "ripping" are all methods of getting the file size of game down by removing unused data.

This can be done to fit a game onto a limited storage medium, like a CD-R or a flash card. Sometimes it's also done to be able to fit more games on the same medium.

Contents

ROM Stripping/Trimming/Truncating

All official GBA and Nintendo DS games are a power of two bits in size, such as 32 Mbit, 64 Mbit, 128 Mbit, etc. due to the properties of solid-state memory. However, not all games use all of the cartridge; instead, they have several Mbits of a repeated byte (usually 0x00 or 0xFF) at the end to make the size match the required standard. For instance, the first Castlevania game for GBA is 64 Mbit, but only the first 52 Mbits contain usable data; the rest is a repeated byte. Truncation chops off repeated bytes at the end of a rom. Some GBA Flashing Software can automatically truncate GBA roms.

Some games can actually be stripped more than usual. For instance, Dr. Mario and Puzzle League (#2261), an 8 MB (64 Mbit) game, has a long series of zeros soon after the 2 MB (16 Mbit) mark. It can be safely trimmed up to that point. It is presumed that this is because the English version only requires English texts, images, and multiboot demos.

Some early GBA Scene releases such as Mode7's Doom had an intro placed at the very end of the rom after several Mbits of blank space and it was impossible to truncate the blank space because the intro was in the way. Newer scene releases put the intro at the start of the blank space so that truncation remains effective.

Ripping

This technique involves unpacking the game's file system (similar to unzipping a zip file), removing or replacing non-crucial files (usually video or audio data), and then repacking the file system.

It was first common in the PC, PlayStation, and Dreamcast piracy scenes so that pirates could more quickly transfer their warez over Usenet or fit games onto a single CD-ROM.

Since the Nintendo DS has a file system similar to those of disc-based platforms, many DS roms can be made smaller by ripping out audio or video files. This can help make the rom below the 256 Mbit limit of the current NDS Patcher and LoadMe, or it can help roms that are originally 512 or above fit on smaller flash cards.

How to size strip GBA/NDS roms

Software for GBA stripping

Use a program like romtrunc.exe (packed with PogoShell) or PogoToolz for flashy gui.

Software for NDS stripping

There are a variety of NDS rom trimmers; 2 prominent ones:

  • "DS-X Manager" - a gui application designed for the ds-x but works with any slot 1 flashcard that uses clean roms. Windows only. Uses a value from the actual nds header to determine where the file ends.

http://forums.ds-xtreme.com/showthread.php?t=1050 ( requires registration )

  • Dslazy's "trim.exe", command line only. windows and linux. Uses the "traditional" method of scanning the file from the end in.

trim-0.22

There is also a simple ROM trimmer for the R4: Information and Download. Windows only. It's not known if ROMs trimmed with this tool will work with other Slot-1 flash cards.

Stripping Roms With a Hex Editor

If the automated size stripping above doesn't work, it can either be because there is no empty space to remove, or there's some garbage data and the end that can be removed. If that's the case then the procedure below helps.

  • Get a hex editor. Hex Workshop is recommended but almost any hex editor will do.
  • Attempt to strip rom with automated software like PogoToolz
  • If only a very small amount is stripped off, or even none, open rom in hex editor
  • See if there's some garbage at the end, with a lot of 00 or FF before it.
  • If there is, remove said garbage.
  • Again strip with automated software (some prefer to do this too manually but to me it's easier to let the software decide exactly where the 00 or FF begins)
  • Test the rom to see if there are any obvious errors
  • If not happily use your new small rom and hope that no errors come up later (if errors should occur later just use a non-stripped rom instead)

See also

ROM Hacking