Crate ggbasm

source ·
Expand description

The main API of GGBASM is the RomBuilder struct.

Various methods are called on the RomBuilder to insert assembly, graphics and raw bytes.


 use ggbasm::RomBuilder;

 RomBuilder::new()?
    // Starts off in the first rom bank
    // A simple example doesnt need to deal with interrupts and jumps, so generate a dummy
    .add_basic_interrupts_and_jumps()?

    // generate a header from data in the passed header struct
    .add_header(header)?

    // Add game code via an asm file
    .add_asm_file("main.asm")?

    // Add an image to the second rom bank
    .advance_address(1, 0)?
    .add_image("tiles.png", "Tileset", &colors_map)?

    // Consume the RomBuilder and write the rom to disk
    .write_to_disk("my_cool_game.gb")?;

The RomBuilder searches for images in the graphics directory and assembly files in the gbasm directory. These directories are in the root directory of the crate, the innermost directory containing a Cargo.toml file.

Parser

If you are after a lower level api, the parser and ast modules can be used without the RomBuilder. You can also construct the ast types yourself and give them to the RomBuilder.

Rust version

Requires nightly rust, because I thought it would be fun to use rust 2018 and I didn’t realize I would make progress this quickly. >.>

Modules

The AST produced by the parser.
Generate audio data.
Miscellaneous gameboy hardware constants.
Define the ROM header via a typed interface.
Parse asm files into an AST.

Structs

Represents a color in modern images. Used when mapping colors from modern images to gameboy graphics.
Keeps track of the state of a rom as it is being constructed.