2022-01-01 23:38:13 +00:00
|
|
|
// Games made using `agb` are no_std which means you don't have access to the standard
|
|
|
|
// rust library. This is because the game boy advance doesn't really have an operating
|
|
|
|
// system, so most of the content of the standard library doesn't apply.
|
|
|
|
//
|
|
|
|
// Provided you haven't disabled it, agb does provide an allocator, so it is possible
|
|
|
|
// to use both the `core` and the `alloc` built in crates.
|
2022-01-01 22:37:39 +00:00
|
|
|
#![no_std]
|
2022-01-01 23:38:13 +00:00
|
|
|
// `agb` defines its own `main` function, so you must declare your game's main function
|
|
|
|
// using the #[agb::entry] proc macro. Failing to do so will cause failure in linking
|
|
|
|
// which won't be a particularly clear error message.
|
2022-01-01 22:37:39 +00:00
|
|
|
#![no_main]
|
|
|
|
|
2022-01-01 23:38:13 +00:00
|
|
|
// This is required in order to ensure that the panic handler defined in `agb` is set
|
|
|
|
// up correctly.
|
2022-01-01 22:37:39 +00:00
|
|
|
extern crate agb;
|
|
|
|
|
2022-01-02 00:27:53 +00:00
|
|
|
use agb::Gba;
|
|
|
|
|
|
|
|
// Put all the graphics related code in the gfx module
|
2022-01-02 00:21:59 +00:00
|
|
|
mod gfx {
|
2022-01-02 00:27:53 +00:00
|
|
|
use agb::display::object::ObjectControl;
|
|
|
|
|
|
|
|
// Import the sprites into this module. This will create a `sprites` module
|
|
|
|
// and within that will be a constant called `sprites` which houses all the
|
|
|
|
// palette and tile data.
|
2022-01-02 00:21:59 +00:00
|
|
|
agb::include_gfx!("gfx/sprites.toml");
|
2022-01-02 00:27:53 +00:00
|
|
|
|
|
|
|
// Loads the sprites tile data and palette data into VRAM
|
|
|
|
pub fn load_sprite_data(object: &mut ObjectControl) {
|
|
|
|
object.set_sprite_palettes(sprites::sprites.palettes);
|
|
|
|
object.set_sprite_tilemap(sprites::sprites.tiles);
|
|
|
|
}
|
2022-01-02 00:21:59 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 23:38:13 +00:00
|
|
|
// The main function must take 0 arguments and never return. The agb::entry decorator
|
|
|
|
// ensures that everything is in order. `agb` will call this after setting up the stack
|
|
|
|
// and interrupt handlers correctly.
|
2022-01-01 22:37:39 +00:00
|
|
|
#[agb::entry]
|
|
|
|
fn main() -> ! {
|
2022-01-02 00:27:53 +00:00
|
|
|
let mut gba = Gba::new();
|
2022-01-01 22:37:39 +00:00
|
|
|
|
2022-01-02 00:21:59 +00:00
|
|
|
let mut object = gba.display.object.get();
|
2022-01-02 00:27:53 +00:00
|
|
|
gfx::load_sprite_data(&mut object);
|
2022-01-02 00:21:59 +00:00
|
|
|
|
2022-01-01 23:38:13 +00:00
|
|
|
loop {}
|
2022-01-01 22:37:39 +00:00
|
|
|
}
|