ggbasm 0.1.1

Generating Gameboy Assembler
# GGBASM (Generating Gameboy Assembler)
[![Build Status](https://travis-ci.org/rukai/ggbasm.svg?branch=master)](https://travis-ci.org/rukai/ggbasm) [![dependency status](https://deps.rs/repo/github/rukai/ggbasm/status.svg)](https://deps.rs/repo/github/rukai/ggbasm) [![Crates.io](https://img.shields.io/crates/v/ggbasm.svg)](https://crates.io/crates/ggbasm)

A gameboy assembler as a rust crate library.
Being a library instead of command line application, allows for an elegant combination of:
*   raw bytes and instructions generated from rust code
*   instructions read from *.asm files.

## Development Status

This library is extremely WIP.

## RomBuilder

The RomBuilder is the core rust api of GGBASM.

```rust
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(0, 1)?
    .add_bytes(image)?;

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

## Comparison with [RGBDS]https://github.com/rednex/rgbds

RGBDS is the only other gameboy assembler i've used.
I assume other assemblers are similar.

*   RGBDS requires only *.asm files, while GGBASM requires *.asm, and an entire rust crate.
*   RGBDS needs to run `RGBDS -o main.obj src/main.asm; rgblink -m game.map -n game.sym -o out.gb main.obj; rgbfix -p 0 -v out.gb` to build the rom, while GGBASM uses `cargo run` to build the rom
*   RGBDS uses includes inside the *.asm files, while GGBASM uses rust to insert instructions and raw bytes at the correct location in the rom.
*   GGBASM has helper functions for generating bytes such as: png_to_gb_sprite
*   RGBDS has its own intel-like syntax, while GGBASM uses a different intel-like syntax. Changes from RGBDS are:
    +   hexadecimal is represented as 0x2a instead of $2a
    +   uses `advance_address 0xYYYY` instead of `section "FOO",$HOME[$YY]`
    +   no commas between arguments: `ld a b` instead of `ld a, b`
    +   the load high instruction from RGBDS `ld [$FF00 + $YY], a` is automatically used when doing `ld [0xFFYY] a`