mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-23 19:01:30 +11:00
commit the changes
This commit is contained in:
parent
120cfc87b2
commit
273a8bd676
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "gba"
|
name = "gba"
|
||||||
description = "A crate (and book) for making GBA games with Rust."
|
description = "A crate (and book) for making GBA games with Rust."
|
||||||
version = "0.4.0"
|
version = "0.4.0-pre"
|
||||||
authors = ["Lokathor <zefria@gmail.com>", "Thomas Winwood <twwinwood@gmail.com>"]
|
authors = ["Lokathor <zefria@gmail.com>", "Thomas Winwood <twwinwood@gmail.com>"]
|
||||||
repository = "https://github.com/rust-console/gba"
|
repository = "https://github.com/rust-console/gba"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -14,6 +14,13 @@ However, currently the development focus is leaning towards having minimal
|
||||||
coverage of all the parts of the GBA. Until that's done, unfortunately the book
|
coverage of all the parts of the GBA. Until that's done, unfortunately the book
|
||||||
will be in a rather messy state.
|
will be in a rather messy state.
|
||||||
|
|
||||||
|
**Branches:**
|
||||||
|
|
||||||
|
* `master` is the code that's on crates.io, though maybe the book has been
|
||||||
|
updated since then.
|
||||||
|
* `dev` is the hopefully more settled parts of the next version.
|
||||||
|
* Anything else is just stuff scratch space basically.
|
||||||
|
|
||||||
## What's Missing
|
## What's Missing
|
||||||
|
|
||||||
The following major GBA features are still missing from the crate:
|
The following major GBA features are still missing from the crate:
|
||||||
|
|
|
@ -5,52 +5,37 @@
|
||||||
use gba::{
|
use gba::{
|
||||||
fatal,
|
fatal,
|
||||||
io::display::{DisplayControlSetting, DisplayMode, DISPCNT},
|
io::display::{DisplayControlSetting, DisplayMode, DISPCNT},
|
||||||
vram::bitmap::{Mode3, Mode4, Mode5, Page},
|
vram::bitmap::Mode3,
|
||||||
warn, Color,
|
Color,
|
||||||
};
|
};
|
||||||
|
use gba::io::keypad::read_key_input;
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
|
// This kills the emulation with a message if we're running within mGBA.
|
||||||
fatal!("{}", info);
|
fatal!("{}", info);
|
||||||
|
// If we're _not_ running within mGBA then we still need to not return, so
|
||||||
|
// loop forever doing nothing.
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||||
const SETTING: DisplayControlSetting =
|
const SETTING: DisplayControlSetting =
|
||||||
DisplayControlSetting::new().with_mode(DisplayMode::Mode5).with_bg2(true);
|
DisplayControlSetting::new().with_mode(DisplayMode::Mode3).with_bg2(true);
|
||||||
DISPCNT.write(SETTING);
|
DISPCNT.write(SETTING);
|
||||||
|
|
||||||
use gba::io::timers::*;
|
let mut px = Mode3::WIDTH / 2;
|
||||||
let tcs0 = TimerControlSetting::new().with_enabled(true);
|
let mut py = Mode3::HEIGHT / 2;
|
||||||
let tcs1 = TimerControlSetting::new().with_tick_rate(TimerTickRate::Cascade).with_enabled(true);
|
let mut color = Color::from_rgb(31, 0, 0);
|
||||||
|
|
||||||
TM1CNT_H.write(tcs1);
|
|
||||||
TM0CNT_H.write(tcs0);
|
|
||||||
let start = TM0CNT_L.read();
|
|
||||||
Mode5::clear_to(Page::Zero, Color(0));
|
|
||||||
let end0 = TM0CNT_L.read();
|
|
||||||
let end1 = TM1CNT_L.read();
|
|
||||||
warn!("CLEAR_TO: start:{}, end0:{}, end1:{}", start, end0, end1);
|
|
||||||
|
|
||||||
// reset
|
|
||||||
TM1CNT_H.write(TimerControlSetting::new());
|
|
||||||
TM0CNT_H.write(TimerControlSetting::new());
|
|
||||||
|
|
||||||
TM1CNT_H.write(tcs1);
|
|
||||||
TM0CNT_H.write(tcs0);
|
|
||||||
let start = TM0CNT_L.read();
|
|
||||||
Mode5::dma_clear_to(Page::Zero, Color(0));
|
|
||||||
let end0 = TM0CNT_L.read();
|
|
||||||
let end1 = TM1CNT_L.read();
|
|
||||||
warn!("DMA_CLEAR_TO: start:{}, end0:{}, end1:{}", start, end0, end1);
|
|
||||||
|
|
||||||
DISPCNT.write(DisplayControlSetting::new().with_mode(DisplayMode::Mode3).with_bg2(true));
|
|
||||||
loop {
|
loop {
|
||||||
let this_frame_keys = gba::io::keypad::read_key_input();
|
// read our keys for this frame
|
||||||
|
let this_frame_keys = read_key_input();
|
||||||
|
|
||||||
gba::io::display::spin_until_vblank();
|
gba::io::display::spin_until_vblank();
|
||||||
Mode3::dma_clear_to(Color(111));
|
Mode5::dma_clear_to(Page::Zero, Color(111));
|
||||||
Mode3::draw_line(5, 5, 240, 160, Color(0b0_11111_11111_11111));
|
Mode5::draw_line(Page::Zero, 5, 5, 100, 100, Color(0b0_11111_11111_11111));
|
||||||
gba::io::display::spin_until_vdraw();
|
gba::io::display::spin_until_vdraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,3 +181,23 @@ macro_rules! debug {
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Using timers 0 and 1, performs a crude timing of the expression given.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! time_this01 {
|
||||||
|
($x:expr) => {{
|
||||||
|
use $crate::io::timers::*;
|
||||||
|
const NORMAL_ON: TimerControlSetting = TimerControlSetting::new().with_enabled(true);
|
||||||
|
const CASCADE_ON: TimerControlSetting =
|
||||||
|
TimerControlSetting::new().with_enabled(true).with_tick_rate(TimerTickRate::Cascade);
|
||||||
|
const OFF: TimerControlSetting = TimerControlSetting::new();
|
||||||
|
TM1CNT_H.write(CASCADE_ON);
|
||||||
|
TM0CNT_H.write(NORMAL_ON);
|
||||||
|
$x;
|
||||||
|
TM0CNT_H.write(OFF);
|
||||||
|
TM1CNT_H.write(OFF);
|
||||||
|
let end_low = TM0CNT_L.read() as u32;
|
||||||
|
let end_high = TM1CNT_L.read() as u32;
|
||||||
|
end_high << 16 | end_low
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue