2022-01-02 10:36:53 +11: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.
|
2021-05-23 15:24:00 +10:00
|
|
|
#![no_std]
|
2022-01-02 10:36:53 +11: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.
|
2021-05-23 15:24:00 +10:00
|
|
|
#![no_main]
|
2022-07-04 03:30:58 +10:00
|
|
|
// This is required to allow writing tests
|
|
|
|
#![cfg_attr(test, feature(custom_test_frameworks))]
|
|
|
|
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
|
|
|
|
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
|
2021-05-23 15:24:00 +10:00
|
|
|
|
|
|
|
use agb::{display, syscall};
|
|
|
|
|
2022-01-17 08:46:53 +11:00
|
|
|
// The main function must take 1 arguments and never return. The agb::entry decorator
|
2022-01-02 10:36:53 +11:00
|
|
|
// ensures that everything is in order. `agb` will call this after setting up the stack
|
2022-01-17 08:46:53 +11:00
|
|
|
// and interrupt handlers correctly. It will also handle creating the `Gba` struct for you.
|
2021-08-08 03:27:10 +10:00
|
|
|
#[agb::entry]
|
2022-01-17 08:46:53 +11:00
|
|
|
fn main(mut gba: agb::Gba) -> ! {
|
2021-05-23 15:24:00 +10:00
|
|
|
let mut bitmap = gba.display.video.bitmap3();
|
|
|
|
|
|
|
|
for x in 0..display::WIDTH {
|
|
|
|
let y = syscall::sqrt(x << 6);
|
|
|
|
let y = (display::HEIGHT - y).clamp(0, display::HEIGHT - 1);
|
|
|
|
bitmap.draw_point(x, y, 0x001F);
|
|
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
|
|
syscall::halt();
|
|
|
|
}
|
|
|
|
}
|