8 unstable releases (3 breaking)

0.4.2 Dec 1, 2024
0.4.1 Nov 8, 2024
0.3.0 Oct 19, 2024
0.2.2 Sep 9, 2024
0.1.0 Jul 19, 2024

#557 in Filesystem

Download history 113/week @ 2024-09-02 313/week @ 2024-09-09 41/week @ 2024-09-16 7/week @ 2024-09-23 9/week @ 2024-09-30 5/week @ 2024-10-07 145/week @ 2024-10-14 21/week @ 2024-10-21 63/week @ 2024-10-28 156/week @ 2024-11-04 23/week @ 2024-11-11 8/week @ 2024-11-18 62/week @ 2024-11-25 74/week @ 2024-12-02

185 downloads per month

MIT license

240KB
5K SLoC

ds-rom

Library for extracting and building matching Nintendo DS ROMs. DSi/DSiware not supported yet.

Contents

Goals

  • Extract all components of a ROM to files on disk.
  • Build ROMs using those files.
  • The files should be modifiable so that a modded ROM can be built.
  • The built ROMs should exactly match the originals when the files are unmodified.

Extraction

ds-rom has two representations of the ROM: raw and plain. To extract files from a ROM, it first reads the raw ROM, with the exact byte-for-byte content of the ROM file. Then, the plain ROM can extract all the components out of the raw ROM. Lastly, the plain ROM can be saved to files on disk.

use ds_rom::{rom::{raw, Rom}};

let raw_rom = raw::Rom::from_file("mygame.nds")?;
let rom = Rom::extract(&raw_rom)?;
rom.save("mygame_extracted/", None)?;

[!IMPORTANT] If the raw ROM is encrypted, you must pass an encryption key to Rom::save in place of the None value. See an example of this here.

Building

Building a ROM is exactly the opposite of extracting. ds-rom starts by loading a plain ROM from files on disk, the same files generated by Rom::save. Then, the raw ROM can be built and saved as a single ROM file.

use ds_rom::rom::Rom;

let rom = Rom::load("mygame_extracted/", None)?;
let raw_rom = rom.build(None)?;
raw_rom.save("mygame_rebuilt.nds")?;

[!IMPORTANT] If the ROM is encrypted, you must pass an encryption key to Rom::load and optionally Rom::build in place of the None value. See an example of this here.
(It is optional for Rom::build as it is only for computing a CRC checksum in the ROM header.)

You can configure whether a ROM should be encrypted by editing the YAML files inside the extraction directory.

Command-line interface

ds-rom is also available as a CLI, and you can download the latest release here. Use dsrom --help for a list of subcommands.

Dependencies

~12–22MB
~414K SLoC