mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
fix
This commit is contained in:
parent
fd82b259cc
commit
22b3497bb3
BIN
agb/examples/font/pixelated.ttf
Normal file
BIN
agb/examples/font/pixelated.ttf
Normal file
Binary file not shown.
|
@ -17,7 +17,7 @@ use agb_fixnum::Rect;
|
||||||
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
const FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
const FONT: Font = include_font!("examples/font/pixelated.ttf", 8);
|
||||||
#[agb::entry]
|
#[agb::entry]
|
||||||
fn entry(gba: agb::Gba) -> ! {
|
fn entry(gba: agb::Gba) -> ! {
|
||||||
main(gba);
|
main(gba);
|
||||||
|
@ -32,12 +32,14 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let palette = Palette16::new(palette);
|
let palette = Palette16::new(palette);
|
||||||
let palette = PaletteVram::new(&palette).unwrap();
|
let palette = PaletteVram::new(&palette).unwrap();
|
||||||
|
|
||||||
let config = Configuration::new(Size::S16x16, palette);
|
let config = Configuration::new(Size::S16x8, palette);
|
||||||
|
|
||||||
let mut wr = BufferedWordRender::new(&FONT, config);
|
let mut wr = BufferedWordRender::new(&FONT, config);
|
||||||
let _ = writeln!(
|
let _ = writeln!(
|
||||||
wr,
|
wr,
|
||||||
"Hello there!\nI spent this weekend writing this text system! Is it any good?\n\nOh, by the way, you can press A to restart!"
|
"{}",
|
||||||
|
"counts for three shoot dice for damage calculation\nmalfunctions all dice after use"
|
||||||
|
.to_ascii_uppercase()
|
||||||
);
|
);
|
||||||
|
|
||||||
let vblank = agb::interrupt::VBlank::get();
|
let vblank = agb::interrupt::VBlank::get();
|
||||||
|
@ -59,7 +61,10 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
wr.commit(oam);
|
wr.commit(oam);
|
||||||
|
|
||||||
let start = timer.value();
|
let start = timer.value();
|
||||||
wr.update(Rect::new((0, 0).into(), (WIDTH, 100).into()), num_letters);
|
wr.update(
|
||||||
|
Rect::new((WIDTH / 8, 0).into(), (80, 100).into()),
|
||||||
|
num_letters,
|
||||||
|
);
|
||||||
wr.process();
|
wr.process();
|
||||||
let end = timer.value();
|
let end = timer.value();
|
||||||
|
|
||||||
|
@ -67,13 +72,22 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
|
||||||
frame += 1;
|
frame += 1;
|
||||||
|
|
||||||
if frame % 4 == 0 {
|
// if frame % 2 == 0 {
|
||||||
num_letters += 1;
|
num_letters += 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if input.is_just_pressed(Button::A) {
|
if input.is_just_pressed(Button::A) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let start = timer.value();
|
||||||
|
drop(wr);
|
||||||
|
let oam = unmanaged.iter();
|
||||||
|
drop(oam);
|
||||||
|
let end = timer.value();
|
||||||
|
agb::println!(
|
||||||
|
"Drop took {} cycles",
|
||||||
|
256 * (end.wrapping_sub(start) as u32)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ impl WordRenderCache {
|
||||||
&& prospective_x > position.position.x + position.size.x
|
&& prospective_x > position.position.x + position.size.x
|
||||||
{
|
{
|
||||||
self.state.head_position.x = position.position.x;
|
self.state.head_position.x = position.position.x;
|
||||||
self.state.head_position.y += 15;
|
self.state.head_position.y += 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
for letter in word.letters.iter().skip(self.state.depth_in_word) {
|
for letter in word.letters.iter().skip(self.state.depth_in_word) {
|
||||||
|
@ -175,10 +175,10 @@ impl WordRenderCache {
|
||||||
}
|
}
|
||||||
TextElementReference::WhiteSpace(space) => {
|
TextElementReference::WhiteSpace(space) => {
|
||||||
match space {
|
match space {
|
||||||
WhiteSpace::Space => self.state.head_position.x += 10,
|
WhiteSpace::Space => self.state.head_position.x += 2,
|
||||||
WhiteSpace::NewLine => {
|
WhiteSpace::NewLine => {
|
||||||
self.state.head_position.x = position.position.x;
|
self.state.head_position.x = position.position.x;
|
||||||
self.state.head_position.y += 15;
|
self.state.head_position.y += 14;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.state.depth_in_elements += 1;
|
self.state.depth_in_elements += 1;
|
||||||
|
@ -244,7 +244,6 @@ impl WorkingLetter {
|
||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
self.x_position = 0;
|
self.x_position = 0;
|
||||||
self.x_offset = 0;
|
self.x_offset = 0;
|
||||||
self.dynamic.clear(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,11 +381,10 @@ impl WordRender<'_> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sprite = self
|
let mut new_sprite = DynamicSprite::new(self.config.sprite_size);
|
||||||
.working
|
core::mem::swap(&mut self.working.letter.dynamic, &mut new_sprite);
|
||||||
.letter
|
let sprite = new_sprite.to_vram(self.config.palette.clone());
|
||||||
.dynamic
|
|
||||||
.to_vram(self.config.palette.clone());
|
|
||||||
let group = LetterGroup {
|
let group = LetterGroup {
|
||||||
sprite,
|
sprite,
|
||||||
width: self.working.letter.x_offset as u16,
|
width: self.working.letter.x_offset as u16,
|
||||||
|
@ -416,8 +414,7 @@ impl WordRender<'_> {
|
||||||
self.working.letter.x_offset += font_letter.xmin as i32;
|
self.working.letter.x_offset += font_letter.xmin as i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
let y_position =
|
let y_position = self.font.ascent() - font_letter.height as i32 - font_letter.ymin as i32;
|
||||||
self.font.ascent() - font_letter.height as i32 - font_letter.ymin as i32 + 4;
|
|
||||||
|
|
||||||
for y in 0..font_letter.height as usize {
|
for y in 0..font_letter.height as usize {
|
||||||
for x in 0..font_letter.width as usize {
|
for x in 0..font_letter.width as usize {
|
||||||
|
|
Loading…
Reference in a new issue