mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Bitmap4 fix (#487)
Expands on #486 by updating example and updating changelog. - [x] Changelog updated
This commit is contained in:
commit
fc721ea060
|
@ -96,6 +96,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Zero volume now plays no sound.
|
- Zero volume now plays no sound.
|
||||||
- Fixed issue where volume was incorrect for volumes which were powers of 2.
|
- Fixed issue where volume was incorrect for volumes which were powers of 2.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed a bug in bitmap4 that caused setting pixels to be always incorrect.
|
||||||
|
|
||||||
## [0.12.2] - 2022/10/22
|
## [0.12.2] - 2022/10/22
|
||||||
|
|
||||||
This is a minor release to fix an alignment issue with background tiles.
|
This is a minor release to fix an alignment issue with background tiles.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use agb::display;
|
use agb::display::{self, HEIGHT, WIDTH};
|
||||||
|
|
||||||
#[agb::entry]
|
#[agb::entry]
|
||||||
fn main(mut gba: agb::Gba) -> ! {
|
fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
@ -11,25 +11,22 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
bitmap.set_palette_entry(1, 0x001F);
|
bitmap.set_palette_entry(1, 0x001F);
|
||||||
bitmap.set_palette_entry(2, 0x03E0);
|
bitmap.set_palette_entry(2, 0x03E0);
|
||||||
|
|
||||||
bitmap.draw_point_page(
|
for y in 0..HEIGHT {
|
||||||
display::WIDTH / 2,
|
for x in 0..WIDTH {
|
||||||
display::HEIGHT / 2,
|
bitmap.draw_point_page(x, y, 0xF, display::bitmap4::Page::Front);
|
||||||
1,
|
bitmap.draw_point_page(x, y, 1, display::bitmap4::Page::Front);
|
||||||
display::bitmap4::Page::Front,
|
bitmap.draw_point_page(x, y, 0xFF, display::bitmap4::Page::Back);
|
||||||
);
|
bitmap.draw_point_page(x, y, 2, display::bitmap4::Page::Back);
|
||||||
bitmap.draw_point_page(
|
}
|
||||||
display::WIDTH / 2 + 5,
|
}
|
||||||
display::HEIGHT / 2,
|
|
||||||
2,
|
|
||||||
display::bitmap4::Page::Back,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut count = 0;
|
let mut input = agb::input::ButtonController::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
count += 1;
|
input.update();
|
||||||
if count % 6 == 0 {
|
|
||||||
|
if input.is_just_pressed(agb::input::Button::A) {
|
||||||
bitmap.flip_page();
|
bitmap.flip_page();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,9 +54,9 @@ impl Bitmap4<'_> {
|
||||||
|
|
||||||
let c = addr.get(x_in_screen, y_in_screen);
|
let c = addr.get(x_in_screen, y_in_screen);
|
||||||
if x & 0b1 != 0 {
|
if x & 0b1 != 0 {
|
||||||
addr.set(x_in_screen, y_in_screen, c | u16::from(colour) << 8);
|
addr.set(x_in_screen, y_in_screen, c & 0xff | u16::from(colour) << 8);
|
||||||
} else {
|
} else {
|
||||||
addr.set(x_in_screen, y_in_screen, c | u16::from(colour));
|
addr.set(x_in_screen, y_in_screen, c & 0xff00 | u16::from(colour));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue