1
0
Fork 0
mirror of https://github.com/italicsjenga/agb.git synced 2025-02-23 22:58:18 +11:00

Fix spellings ()

Fixes a bunch of spellings found by the cspell vscode extension.

- [x] Changelog updated / no changelog update needed
This commit is contained in:
Gwilym Kuiper 2022-11-17 21:48:01 +00:00 committed by GitHub
commit bdf994cab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 257 additions and 146 deletions

108
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,108 @@
{
"cSpell.words": [
"aeabi",
"agb",
"agbabi",
"asefile",
"aseprite",
"Atmel",
"behaviour",
"bindgen",
"binutils",
"bitarray",
"Bitfield",
"bitflags",
"bitmask",
"boing",
"boops",
"chipsets",
"chrono",
"clonable",
"collidable",
"Colour",
"Colours",
"constness",
"COOLDOWN",
"cooldowns",
"cstring",
"Customise",
"Datelike",
"dealloc",
"EABI",
"EEPROM",
"ewram",
"fixnum",
"fixnums",
"fontdue",
"fract",
"FRAM",
"framebuffer",
"framebuffers",
"gameboy",
"Gamepak",
"gbafix",
"hadamard",
"Hasher",
"HBLANK",
"healthbar",
"hflip",
"hurtbox",
"initialisation",
"initialise",
"Initialises",
"iwram",
"justfile",
"Knockback",
"lateout",
"Macronix",
"mgba",
"normalise",
"normalised",
"Normalises",
"nostack",
"objcopy",
"Optimisation",
"optimise",
"optimised",
"Optimiser",
"optimises",
"pacman",
"Paks",
"paletted",
"prioritised",
"replacen",
"repr",
"Respawn",
"rustc",
"rustdoc",
"rustup",
"Sanyo",
"screenblock",
"screenblocks",
"signum",
"SRAM",
"struct",
"subcrates",
"subpat",
"synchronisation",
"syscall",
"syscalls",
"THUMBV",
"tilemap",
"tileset",
"tilesets",
"tonc",
"trunc",
"Uninit",
"uninitialised",
"vblank",
"VCOUNT",
"vdraw",
"vflip",
"vram",
"Woah",
"WRAM",
"xmin",
"ymin"
]
}

View file

@ -424,7 +424,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Num<I, N> {
impl<const N: usize> Num<i32, N> { impl<const N: usize> Num<i32, N> {
#[must_use] #[must_use]
/// Returns the square root of a number, it is calcuated a digit at a time. /// Returns the square root of a number, it is calculated a digit at a time.
/// ``` /// ```
/// # use agb_fixnum::*; /// # use agb_fixnum::*;
/// let n: Num<i32, 8> = num!(16.); /// let n: Num<i32, 8> = num!(16.);
@ -530,7 +530,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Display for Num<I, N> {
let mut fractional = self.0 & mask; let mut fractional = self.0 & mask;
// Negative fix nums are awkward to print if they have non zero fractional part. // Negative fixnums are awkward to print if they have non zero fractional part.
// This is because you can think of them as `number + non negative fraction`. // This is because you can think of them as `number + non negative fraction`.
// //
// But if you think of a negative number, you'd like it to be `negative number - non negative fraction` // But if you think of a negative number, you'd like it to be `negative number - non negative fraction`
@ -569,7 +569,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Debug for Num<I, N> {
} }
} }
/// A vector of two points: (x, y) represened by integers or fixed point numbers /// A vector of two points: (x, y) represented by integers or fixed point numbers
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
pub struct Vector2D<T: Number> { pub struct Vector2D<T: Number> {
/// The x coordinate /// The x coordinate
@ -675,7 +675,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Vector2D<Num<I, N>> {
} }
#[must_use] #[must_use]
/// Floors the x and y coordnate, see [Num::floor] /// Floors the x and y coordinate, see [Num::floor]
/// ``` /// ```
/// # use agb_fixnum::*; /// # use agb_fixnum::*;
/// let v1: Vector2D<Num<i32, 8>> = Vector2D::new(num!(1.56), num!(-2.2)); /// let v1: Vector2D<Num<i32, 8>> = Vector2D::new(num!(1.56), num!(-2.2));
@ -984,7 +984,7 @@ impl<T: Number> Vector2D<T> {
Vector2D { x, y } Vector2D { x, y }
} }
/// Returns the tuple of the coorinates /// Returns the tuple of the coordinates
/// ``` /// ```
/// # use agb_fixnum::*; /// # use agb_fixnum::*;
/// let v = Vector2D::new(1, 2); /// let v = Vector2D::new(1, 2);

View file

@ -28,7 +28,7 @@ pub(crate) trait Config {
pub(crate) trait Image { pub(crate) trait Image {
fn filename(&self) -> String; fn filename(&self) -> String;
fn tilesize(&self) -> TileSize; fn tile_size(&self) -> TileSize;
fn colours(&self) -> Colours; fn colours(&self) -> Colours;
} }
@ -84,7 +84,7 @@ impl Image for ImageV1 {
self.filename.clone() self.filename.clone()
} }
fn tilesize(&self) -> TileSize { fn tile_size(&self) -> TileSize {
self.tile_size.into() self.tile_size.into()
} }

View file

@ -84,7 +84,7 @@ pub fn include_gfx(input: TokenStream) -> TokenStream {
match settings.colours() { match settings.colours() {
Colours::Colours16 => { Colours::Colours16 => {
let tile_size = settings.tilesize().to_size(); let tile_size = settings.tile_size().to_size();
if image.width % tile_size != 0 || image.height % tile_size != 0 { if image.width % tile_size != 0 || image.height % tile_size != 0 {
panic!("Image size not a multiple of tile size"); panic!("Image size not a multiple of tile size");
} }
@ -96,7 +96,7 @@ pub fn include_gfx(input: TokenStream) -> TokenStream {
config.transparent_colour(), config.transparent_colour(),
); );
let num_tiles = image.width * image.height / settings.tilesize().to_size().pow(2); let num_tiles = image.width * image.height / settings.tile_size().to_size().pow(2);
assignment_offsets.insert(name, assignment_offset); assignment_offsets.insert(name, assignment_offset);
assignment_offset += num_tiles; assignment_offset += num_tiles;
} }
@ -183,7 +183,7 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream {
let height = frame.height(); let height = frame.height();
assert!( assert!(
valid_sprite_size(width, height), valid_sprite_size(width, height),
"File {} contains sprites with unrepresentable size {}x{}", "File {} contains sprites with size {}x{} which cannot be represented on the GameBoy Advance",
filename.display(), filename.display(),
width, width,
height height
@ -290,7 +290,7 @@ fn convert_image(
optimisation_results, optimisation_results,
&image, &image,
&image_filename.to_string_lossy(), &image_filename.to_string_lossy(),
settings.tilesize(), settings.tile_size(),
crate_prefix.to_owned(), crate_prefix.to_owned(),
assignment_offset, assignment_offset,
) )

View file

@ -32,10 +32,10 @@ fn main(mut gba: agb::Gba) -> ! {
let back = Mutex::new(RefCell::new(BackCosines { cosines, row: 0 })); let back = Mutex::new(RefCell::new(BackCosines { cosines, row: 0 }));
let _a = agb::interrupt::add_interrupt_handler(Interrupt::HBlank, |key: CriticalSection| { let _a = agb::interrupt::add_interrupt_handler(Interrupt::HBlank, |key: CriticalSection| {
let mut backc = back.borrow(key).borrow_mut(); let mut back = back.borrow(key).borrow_mut();
let deflection = backc.cosines[backc.row % 32]; let deflection = back.cosines[back.row % 32];
unsafe { ((0x0400_0010) as *mut u16).write_volatile(deflection) } unsafe { ((0x0400_0010) as *mut u16).write_volatile(deflection) }
backc.row += 1; back.row += 1;
}); });
let vblank = agb::interrupt::VBlank::get(); let vblank = agb::interrupt::VBlank::get();
@ -43,10 +43,10 @@ fn main(mut gba: agb::Gba) -> ! {
loop { loop {
vblank.wait_for_vblank(); vblank.wait_for_vblank();
free(|key| { free(|key| {
let mut backc = back.borrow(key).borrow_mut(); let mut back = back.borrow(key).borrow_mut();
backc.row = 0; back.row = 0;
time += 1; time += 1;
for (r, a) in backc.cosines.iter_mut().enumerate() { for (r, a) in back.cosines.iter_mut().enumerate() {
let n: FixedNum<8> = (FixedNum::new(r as i32) / 32 + FixedNum::new(time) / 128) let n: FixedNum<8> = (FixedNum::new(r as i32) / 32 + FixedNum::new(time) / 128)
.cos() .cos()
* (256 * 4 - 1) * (256 * 4 - 1)

View file

@ -67,9 +67,9 @@ impl BlockAllocator {
let mut count = 0; let mut count = 0;
let mut list_ptr = &mut state.first_free_block; let mut list_ptr = &mut state.first_free_block;
while let Some(mut curr) = list_ptr { while let Some(mut current) = list_ptr {
count += 1; count += 1;
list_ptr = &mut curr.as_mut().next; list_ptr = &mut current.as_mut().next;
} }
count count
@ -89,18 +89,18 @@ impl BlockAllocator {
let mut list_ptr = &mut state.first_free_block; let mut list_ptr = &mut state.first_free_block;
while let Some(mut curr) = list_ptr { while let Some(mut current) = list_ptr {
if let Some(next_elem) = curr.as_mut().next { if let Some(next_elem) = current.as_mut().next {
let difference = next_elem let difference = next_elem
.as_ptr() .as_ptr()
.cast::<u8>() .cast::<u8>()
.offset_from(curr.as_ptr().cast::<u8>()); .offset_from(current.as_ptr().cast::<u8>());
let usize_difference: usize = difference let usize_difference: usize = difference
.try_into() .try_into()
.expect("distances in alloc'd blocks must be positive"); .expect("distances in alloc'd blocks must be positive");
if usize_difference == curr.as_mut().size { if usize_difference == current.as_mut().size {
let current = curr.as_mut(); let current = current.as_mut();
let next = next_elem.as_ref(); let next = next_elem.as_ref();
current.size += next.size; current.size += next.size;
@ -108,7 +108,7 @@ impl BlockAllocator {
continue; continue;
} }
} }
list_ptr = &mut curr.as_mut().next; list_ptr = &mut current.as_mut().next;
} }
}); });
} }
@ -128,18 +128,18 @@ impl BlockAllocator {
// This iterates the free list until it either finds a block that // This iterates the free list until it either finds a block that
// is the exact size requested or a block that can be split into // is the exact size requested or a block that can be split into
// one with the desired size and another block header. // one with the desired size and another block header.
while let Some(mut curr) = current_block { while let Some(mut current) = current_block {
let curr_block = curr.as_mut(); let block_to_examine = current.as_mut();
if curr_block.size == full_layout.size() { if block_to_examine.size == full_layout.size() {
*list_ptr = curr_block.next; *list_ptr = block_to_examine.next;
return Some(curr.cast()); return Some(current.cast());
} else if curr_block.size >= block_after_layout.size() { } else if block_to_examine.size >= block_after_layout.size() {
// can split block // can split block
let split_block = Block { let split_block = Block {
size: curr_block.size - block_after_layout_offset, size: block_to_examine.size - block_after_layout_offset,
next: curr_block.next, next: block_to_examine.next,
}; };
let split_ptr = curr let split_ptr = current
.as_ptr() .as_ptr()
.cast::<u8>() .cast::<u8>()
.add(block_after_layout_offset) .add(block_after_layout_offset)
@ -147,10 +147,10 @@ impl BlockAllocator {
*split_ptr = split_block; *split_ptr = split_block;
*list_ptr = NonNull::new(split_ptr).map(SendNonNull); *list_ptr = NonNull::new(split_ptr).map(SendNonNull);
return Some(curr.cast()); return Some(current.cast());
} }
current_block = curr_block.next; current_block = block_to_examine.next;
list_ptr = &mut curr_block.next; list_ptr = &mut block_to_examine.next;
} }
self.new_block(layout, key) self.new_block(layout, key)

View file

@ -1,50 +1,50 @@
#![deny(missing_docs)] #![deny(missing_docs)]
//! # Affine matricies for the Game Boy Advance //! # Affine matrices for the Game Boy Advance
//! //!
//! An affine matrix represents an affine transformation, an affine //! An affine matrix represents an affine transformation, an affine
//! transformation being one which preserves parallel lines (note that this //! transformation being one which preserves parallel lines (note that this
//! therefore cannot represent perspective seen in games like Super Mario Kart). //! therefore cannot represent perspective seen in games like Super Mario Kart).
//! Affine matricies are used in two places on the GBA, for affine backgrounds //! Affine matrices are used in two places on the GBA, for affine backgrounds
//! and for affine objects. //! and for affine objects.
//! //!
//! # Linear Algebra //! # Linear Algebra
//! As a matrix, they can be manipulated using linear algebra. The short version //! As a matrix, they can be manipulated using linear algebra. The short version
//! of this section is to beware that the matrix is the inverse of the normal //! of this section is to beware that the matrix is the inverse of the normal
//! transformation matricies. //! transformation matrices.
//! //!
//! One quick thing to point out at the start as it will become very relevant is //! One quick thing to point out at the start as it will become very relevant is
//! that matrix-matrix multiplication is not commutative, meaning swapping the //! that matrix-matrix multiplication is not commutative, meaning swapping the
//! order changes the result, or **A** × **B** ≢ **B** × **A**. However, //! order changes the result, or **A** × **B** ≢ **B** × **A**. However,
//! matricies are, at least in the case they are used here, associative, meaning //! matrices are, at least in the case they are used here, associative, meaning
//! (**AB**)**C** = **A**(**BC**). //! (**AB**)**C** = **A**(**BC**).
//! //!
//! ## Normal (wrong on GBA!) transformation matricies //! ## Normal (wrong on GBA!) transformation matrices
//! //!
//! As a start, normal transformation matricies will transform a shape from it's //! As a start, normal transformation matrices will transform a shape from it's
//! original position to it's new position. Generally when people talk about //! original position to it's new position. Generally when people talk about
//! transformation matricies they are talking about them in this sense. //! transformation matrices they are talking about them in this sense.
//! //!
//! > If **A** and **B** are transformation matricies, then matrix **C** = **A** //! > If **A** and **B** are transformation matrices, then matrix **C** = **A**
//! > × **B** represents the transformation **A** performed on **B**, or //! > × **B** represents the transformation **A** performed on **B**, or
//! > alternatively **C** is transformation **B** followed by transformation //! > alternatively **C** is transformation **B** followed by transformation
//! > **A**. //! > **A**.
//! //!
//! This is not what they represent on the GBA! If you are looking up more //! This is not what they represent on the GBA! If you are looking up more
//! information about tranformation matricies bear this in mind. //! information about transformation matrices bear this in mind.
//! //!
//! ## Correct (on GBA) transformation matricies //! ## Correct (on GBA) transformation matrices
//! //!
//! On the GBA, the affine matrix works the other way around. The GBA wants to //! On the GBA, the affine matrix works the other way around. The GBA wants to
//! know for each pixel what colour it should render, to do this it applies the //! know for each pixel what colour it should render, to do this it applies the
//! affine transformation matrix to the pixel it is rendering to lookup correct //! affine transformation matrix to the pixel it is rendering to lookup correct
//! pixel in the texture. //! pixel in the texture.
//! //!
//! This describes the inverse of the previously given transformation matricies. //! This describes the inverse of the previously given transformation matrices.
//! //!
//! Above I described the matrix **C** = **A** × **B**, but what the GBA wants //! Above I described the matrix **C** = **A** × **B**, but what the GBA wants
//! is the inverse of **C**, or **C**<sup>-1</sup> = (**AB**)<sup>-1</sup> = //! is the inverse of **C**, or **C**<sup>-1</sup> = (**AB**)<sup>-1</sup> =
//! **B**<sup>-1</sup> × **A**<sup>-1</sup>. This means that if we have the //! **B**<sup>-1</sup> × **A**<sup>-1</sup>. This means that if we have the
//! matricies **I** and **J** in the form the GBA expects then //! matrices **I** and **J** in the form the GBA expects then
//! //!
//! > Transformation **K** = **I** × **J** is the transformation **I** followed //! > Transformation **K** = **I** × **J** is the transformation **I** followed
//! > by the transformation **J**. //! > by the transformation **J**.
@ -278,7 +278,7 @@ impl AffineMatrixBackground {
#[must_use] #[must_use]
/// Creates a transformation matrix using GBA specific syscalls. /// Creates a transformation matrix using GBA specific syscalls.
/// This can be done using the standard transformation matricies like /// This can be done using the standard transformation matrices like
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # #![no_std] /// # #![no_std]

View file

@ -58,10 +58,10 @@ impl Bitmap4 {
/// index whose colour is specified in the background palette. Panics if (x, /// index whose colour is specified in the background palette. Panics if (x,
/// y) is out of the bounds of the screen. /// y) is out of the bounds of the screen.
pub fn draw_point(&mut self, x: i32, y: i32, colour: u8) { pub fn draw_point(&mut self, x: i32, y: i32, colour: u8) {
let disp = DISPLAY_CONTROL.get(); let display = DISPLAY_CONTROL.get();
// get other page // get other page
let page = if disp & GraphicsSettings::PAGE_SELECT.bits() != 0 { let page = if display & GraphicsSettings::PAGE_SELECT.bits() != 0 {
Page::Front Page::Front
} else { } else {
Page::Back Page::Back
@ -78,8 +78,8 @@ impl Bitmap4 {
/// Flips page, changing the Gameboy advance to draw the contents of the /// Flips page, changing the Gameboy advance to draw the contents of the
/// other page /// other page
pub fn flip_page(&mut self) { pub fn flip_page(&mut self) {
let disp = DISPLAY_CONTROL.get(); let display = DISPLAY_CONTROL.get();
let swapped = disp ^ GraphicsSettings::PAGE_SELECT.bits(); let swapped = display ^ GraphicsSettings::PAGE_SELECT.bits();
DISPLAY_CONTROL.set(swapped); DISPLAY_CONTROL.set(swapped);
} }
} }

View file

@ -3,7 +3,7 @@
//! For now a description of how blending can be used is found on [the tonc page //! For now a description of how blending can be used is found on [the tonc page
//! for graphic //! for graphic
//! effects](https://www.coranac.com/tonc/text/gfx.htm#ssec-bld-gba). See the //! effects](https://www.coranac.com/tonc/text/gfx.htm#ssec-bld-gba). See the
//! [Blend] struct for all the functions to manage blend effects. You accquire //! [Blend] struct for all the functions to manage blend effects. You acquire
//! the Blend struct through the [Display][super::Display] struct. //! the Blend struct through the [Display][super::Display] struct.
//! ```no_run //! ```no_run
//! # #![no_main] //! # #![no_main]
@ -28,12 +28,12 @@ pub enum Layer {
Bottom = 1, Bottom = 1,
} }
/// The different blend modes avaliable on the GBA /// The different blend modes available on the GBA
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub enum BlendMode { pub enum BlendMode {
// No blending // No blending
Off = 0, Off = 0,
// Aditive blending, use the [Blend::set_blend_weight] function to use this // Additive blending, use the [Blend::set_blend_weight] function to use this
Normal = 0b01, Normal = 0b01,
// Brighten, use the [Blend::set_fade] to use this // Brighten, use the [Blend::set_fade] to use this
FadeToWhite = 0b10, FadeToWhite = 0b10,
@ -129,7 +129,7 @@ impl Blend {
self self
} }
/// Reset targers, blend weights, and fades /// Reset targets, blend weights, and fades
pub fn reset(&mut self) -> &mut Self { pub fn reset(&mut self) -> &mut Self {
self.reset_targets().reset_fades().reset_weights() self.reset_targets().reset_fades().reset_weights()
} }

View file

@ -26,7 +26,7 @@ use attributes::*;
/// Include this type if you call `get_object_controller` in impl block. This /// Include this type if you call `get_object_controller` in impl block. This
/// helps you use the right lifetimes and doesn't impl Sync (using from two /// helps you use the right lifetimes and doesn't impl Sync (using from two
/// "threads" without syncronisation is not safe), but sending to another /// "threads" without synchronisation is not safe), but sending to another
/// "thread" is safe. /// "thread" is safe.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
struct ObjectControllerReference<'a> { struct ObjectControllerReference<'a> {
@ -314,7 +314,7 @@ impl TagMap {
/// Gets a tag associated with the name. A tag in aseprite refers to a /// Gets a tag associated with the name. A tag in aseprite refers to a
/// sequence of sprites with some metadata for how to animate it. You should /// sequence of sprites with some metadata for how to animate it. You should
/// call this in a constant context so it is evalulated at compile time. It /// call this in a constant context so it is evaluated at compile time. It
/// is inefficient to call this elsewhere. /// is inefficient to call this elsewhere.
/// ```rust,no_run /// ```rust,no_run
/// # #![no_std] /// # #![no_std]
@ -348,7 +348,7 @@ impl TagMap {
enum Direction { enum Direction {
Forward, Forward,
Backward, Backward,
Pingpong, PingPong,
} }
impl Direction { impl Direction {
@ -356,7 +356,7 @@ impl Direction {
match a { match a {
0 => Direction::Forward, 0 => Direction::Forward,
1 => Direction::Backward, 1 => Direction::Backward,
2 => Direction::Pingpong, 2 => Direction::PingPong,
_ => panic!("Invalid direction, this is a bug in image converter or agb"), _ => panic!("Invalid direction, this is a bug in image converter or agb"),
} }
} }
@ -376,7 +376,7 @@ impl Tag {
unsafe { slice::from_raw_parts(self.sprites, self.len) } unsafe { slice::from_raw_parts(self.sprites, self.len) }
} }
/// A single sprite refered to by index in the animation sequence. /// A single sprite referred to by index in the animation sequence.
#[must_use] #[must_use]
pub const fn sprite(&self, idx: usize) -> &'static Sprite { pub const fn sprite(&self, idx: usize) -> &'static Sprite {
if idx >= self.len { if idx >= self.len {
@ -400,7 +400,7 @@ impl Tag {
match self.direction { match self.direction {
Direction::Forward => self.sprite(idx % self.len), Direction::Forward => self.sprite(idx % self.len),
Direction::Backward => self.sprite(len_sub_1 - (idx % self.len)), Direction::Backward => self.sprite(len_sub_1 - (idx % self.len)),
Direction::Pingpong => self.sprite( Direction::PingPong => self.sprite(
(((idx + len_sub_1) % (len_sub_1 * 2)) as isize - len_sub_1 as isize) (((idx + len_sub_1) % (len_sub_1 * 2)) as isize - len_sub_1 as isize)
.unsigned_abs(), .unsigned_abs(),
), ),
@ -667,7 +667,7 @@ struct ObjectInner {
} }
struct ObjectControllerStatic { struct ObjectControllerStatic {
_free_affine_matricies: Vec<u8>, _free_affine_matrices: Vec<u8>,
free_object: Vec<u8>, free_object: Vec<u8>,
shadow_oam: Vec<Option<ObjectInner>>, shadow_oam: Vec<Option<ObjectInner>>,
z_order: Vec<u8>, z_order: Vec<u8>,
@ -680,7 +680,7 @@ impl ObjectControllerStatic {
shadow_oam: (0..128).map(|_| None).collect(), shadow_oam: (0..128).map(|_| None).collect(),
z_order: (0..128).collect(), z_order: (0..128).collect(),
free_object: (0..128).collect(), free_object: (0..128).collect(),
_free_affine_matricies: (0..32).collect(), _free_affine_matrices: (0..32).collect(),
sprite_controller: SpriteControllerInner::new(), sprite_controller: SpriteControllerInner::new(),
} }
} }
@ -1033,7 +1033,7 @@ impl<'a> Object<'a> {
self self
} }
/// Sets the z priority of the sprite. Higher priority will be dislayed /// Sets the z priority of the sprite. Higher priority will be displayed
/// above background layers with lower priorities. No change will be seen /// above background layers with lower priorities. No change will be seen
/// until [ObjectController::commit] is called. /// until [ObjectController::commit] is called.
pub fn set_priority(&mut self, priority: Priority) -> &mut Self { pub fn set_priority(&mut self, priority: Priority) -> &mut Self {
@ -1067,7 +1067,7 @@ impl<'a> Object<'a> {
} }
/// Sets the z position of the sprite, this controls which sprites are above /// Sets the z position of the sprite, this controls which sprites are above
/// eachother. No change will be seen until [ObjectController::commit] is /// each other. No change will be seen until [ObjectController::commit] is
/// called. /// called.
pub fn set_z(&mut self, z: i32) -> &mut Self { pub fn set_z(&mut self, z: i32) -> &mut Self {
{ {

View file

@ -128,8 +128,8 @@ impl Window {
/// Sets whether the blend is enabled inside of this window, must call /// Sets whether the blend is enabled inside of this window, must call
/// [Windows::commit] for this change to be seen. /// [Windows::commit] for this change to be seen.
#[inline(always)] #[inline(always)]
pub fn set_blend_enable(&mut self, blnd: bool) -> &mut Self { pub fn set_blend_enable(&mut self, blend: bool) -> &mut Self {
self.set_bit(5, blnd); self.set_bit(5, blend);
self self
} }
@ -204,8 +204,8 @@ impl MovableWindow {
/// Sets whether the blend is enabled inside of this window, must call /// Sets whether the blend is enabled inside of this window, must call
/// [Windows::commit] for this change to be seen. /// [Windows::commit] for this change to be seen.
#[inline(always)] #[inline(always)]
pub fn set_blend_enable(&mut self, blnd: bool) -> &mut Self { pub fn set_blend_enable(&mut self, blend: bool) -> &mut Self {
self.inner.set_blend_enable(blnd); self.inner.set_blend_enable(blend);
self self
} }
/// Sets whether the given background will be rendered inside this window, /// Sets whether the given background will be rendered inside this window,

View file

@ -27,7 +27,7 @@ type HashType = u32;
// The key concept is to keep the distance from the initial bucket chosen for a given // The key concept is to keep the distance from the initial bucket chosen for a given
// key to a minimum. We shall call this distance the "distance to the initial bucket" // key to a minimum. We shall call this distance the "distance to the initial bucket"
// or DIB for short. With each key - value pair, we store its DIB. When inserting // or DIB for short. With each key - value pair, we store its DIB. When inserting
// a value into the hashtable, we check to see if there is an element in the initial // a value into the hash table, we check to see if there is an element in the initial
// bucket. If there is, we move onto the next value. Then, we check to see if there // bucket. If there is, we move onto the next value. Then, we check to see if there
// is already a value there and if there is, we check its DIB. If our DIB is greater // is already a value there and if there is, we check its DIB. If our DIB is greater
// than or equal to the DIB of the value that is already there, we swap the working // than or equal to the DIB of the value that is already there, we swap the working
@ -942,7 +942,7 @@ impl<K, V> Node<K, V> {
let old_value = mem::replace(&mut self.value, MaybeUninit::new(value)); let old_value = mem::replace(&mut self.value, MaybeUninit::new(value));
unsafe { old_value.assume_init() } unsafe { old_value.assume_init() }
} else { } else {
panic!("Cannot replace an unininitalised node"); panic!("Cannot replace an uninitialised node");
} }
} }

View file

@ -66,7 +66,7 @@ bitflags! {
const BUTTON_INPUT: *mut u16 = (0x04000130) as *mut u16; const BUTTON_INPUT: *mut u16 = (0x04000130) as *mut u16;
// const BUTTON_INTURRUPT: *mut u16 = (0x04000132) as *mut u16; // const BUTTON_INTERRUPT: *mut u16 = (0x04000132) as *mut u16;
/// Helper to make it easy to get the current state of the GBA's buttons. /// Helper to make it easy to get the current state of the GBA's buttons.
/// ///

View file

@ -312,7 +312,7 @@ where
pub struct VBlank {} pub struct VBlank {}
impl VBlank { impl VBlank {
/// Handles setting up everything reqired to be able to use the wait for /// Handles setting up everything required to be able to use the wait for
/// interrupt syscall. /// interrupt syscall.
#[must_use] #[must_use]
pub fn get() -> Self { pub fn get() -> Self {

View file

@ -437,11 +437,11 @@ mod test {
let address = iwram_ptr as usize; let address = iwram_ptr as usize;
assert!( assert!(
(0x0300_0000..0x0300_8000).contains(&address), (0x0300_0000..0x0300_8000).contains(&address),
"iwram is located beween 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}", "iwram is located between 0x0300_0000 and 0x0300_8000, but was actually found to be at {:#010X}",
address address
); );
let c = iwram_ptr.read_volatile(); let c = iwram_ptr.read_volatile();
assert_eq!(c, 9, "exctected content to be 9"); assert_eq!(c, 9, "expected content to be 9");
iwram_ptr.write_volatile(u32::MAX); iwram_ptr.write_volatile(u32::MAX);
let c = iwram_ptr.read_volatile(); let c = iwram_ptr.read_volatile();
assert_eq!(c, u32::MAX, "expected content to be {}", u32::MAX); assert_eq!(c, u32::MAX, "expected content to be {}", u32::MAX);
@ -460,7 +460,7 @@ mod test {
address address
); );
let c = iwram_ptr.read_volatile(); let c = iwram_ptr.read_volatile();
assert_eq!(c, 9, "exctected content to be 9"); assert_eq!(c, 9, "expected content to be 9");
iwram_ptr.write_volatile(u32::MAX); iwram_ptr.write_volatile(u32::MAX);
let c = iwram_ptr.read_volatile(); let c = iwram_ptr.read_volatile();
assert_eq!(c, u32::MAX, "expected content to be {}", u32::MAX); assert_eq!(c, u32::MAX, "expected content to be {}", u32::MAX);

View file

@ -36,14 +36,14 @@ agb_thumb_end agb_rs__WramVerifyBuf
@ @
@ void WramXferBuf(const char* source, char* dest, int count); @ void WramTransferBuf(const char* source, char* dest, int count);
@ @
@ A routine that copies one buffer into another. @ A routine that copies one buffer into another.
@ @
agb_thumb_func agb_rs__WramXferBuf agb_thumb_func agb_rs__WramTransferBuf
0: sub r2, #1 0: sub r2, #1
ldrb r3, [r0,r2] ldrb r3, [r0,r2]
strb r3, [r1,r2] strb r3, [r1,r2]
bne 0b bne 0b
bx lr bx lr
agb_thumb_end agb_rs__WramXferBuf agb_thumb_end agb_rs__WramTransferBuf

View file

@ -3,7 +3,7 @@
//! performed via code in WRAM and cannot be accessed by DMA. //! performed via code in WRAM and cannot be accessed by DMA.
extern "C" { extern "C" {
fn agb_rs__WramXferBuf(src: *const u8, dst: *mut u8, count: usize); fn agb_rs__WramTransferBuf(src: *const u8, dst: *mut u8, count: usize);
fn agb_rs__WramReadByte(src: *const u8) -> u8; fn agb_rs__WramReadByte(src: *const u8) -> u8;
fn agb_rs__WramVerifyBuf(buf1: *const u8, buf2: *const u8, count: usize) -> bool; fn agb_rs__WramVerifyBuf(buf1: *const u8, buf2: *const u8, count: usize) -> bool;
} }
@ -18,7 +18,7 @@ extern "C" {
#[inline(always)] #[inline(always)]
pub unsafe fn read_raw_buf(dst: &mut [u8], src: usize) { pub unsafe fn read_raw_buf(dst: &mut [u8], src: usize) {
if !dst.is_empty() { if !dst.is_empty() {
agb_rs__WramXferBuf(src as _, dst.as_mut_ptr(), dst.len()); agb_rs__WramTransferBuf(src as _, dst.as_mut_ptr(), dst.len());
} }
} }
@ -31,7 +31,7 @@ pub unsafe fn read_raw_buf(dst: &mut [u8], src: usize) {
#[inline(always)] #[inline(always)]
pub unsafe fn write_raw_buf(dst: usize, src: &[u8]) { pub unsafe fn write_raw_buf(dst: usize, src: &[u8]) {
if !src.is_empty() { if !src.is_empty() {
agb_rs__WramXferBuf(src.as_ptr(), dst as _, src.len()); agb_rs__WramTransferBuf(src.as_ptr(), dst as _, src.len());
} }
} }

View file

@ -61,14 +61,14 @@ impl BufferData {
/// Reads a number from the input buffer. /// Reads a number from the input buffer.
fn read_num(&mut self, off: usize, count: usize) -> u32 { fn read_num(&mut self, off: usize, count: usize) -> u32 {
let mut accum = 0; let mut accumulator = 0;
unsafe { unsafe {
for i in 0..count { for i in 0..count {
accum <<= 1; accumulator <<= 1;
accum |= self.data.bits[off + i] as u32; accumulator |= self.data.bits[off + i] as u32;
} }
} }
accum accumulator
} }
/// Receives a number of words into the input buffer. /// Receives a number of words into the input buffer.

View file

@ -44,8 +44,8 @@
//! [`SaveManager::access_with_timer`] methods to create a new [`SaveData`] //! [`SaveManager::access_with_timer`] methods to create a new [`SaveData`]
//! object. Its methods are used to read or write save media. //! object. Its methods are used to read or write save media.
//! //!
//! Reading data from the savegame is simple. Use [`read`] to copy data from an //! Reading data from the save media is simple. Use [`read`] to copy data from an
//! offset in the savegame into a buffer in memory. //! offset in the save media into a buffer in memory.
//! //!
//! Writing to save media requires you to prepare the area for writing by //! Writing to save media requires you to prepare the area for writing by
//! calling the [`prepare_write`] method to return a [`SavePreparedBlock`], //! calling the [`prepare_write`] method to return a [`SavePreparedBlock`],
@ -185,7 +185,7 @@ fn set_save_implementation(access_impl: &'static dyn RawSaveAccess) {
let mut access = CURRENT_SAVE_ACCESS.lock(); let mut access = CURRENT_SAVE_ACCESS.lock();
assert!( assert!(
access.is_none(), access.is_none(),
"Cannot initialize the savegame engine more than once." "Cannot initialize the save media engine more than once."
); );
*access = Some(access_impl); *access = Some(access_impl);
} }
@ -202,7 +202,7 @@ pub struct SaveData {
timeout: utils::Timeout, timeout: utils::Timeout,
} }
impl SaveData { impl SaveData {
/// Creates a new save accessor around the current save implementaiton. /// Creates a new save accessor around the current save implementation.
fn new(timer: Option<Timer>) -> Result<SaveData, Error> { fn new(timer: Option<Timer>) -> Result<SaveData, Error> {
match get_save_implementation() { match get_save_implementation() {
Some(access) => Ok(SaveData { Some(access) => Ok(SaveData {

View file

@ -22,8 +22,8 @@ const DMA2_SOURCE_ADDR: MemoryMapped<u32> = unsafe { MemoryMapped::new(dma_sourc
const DMA2_DEST_ADDR: MemoryMapped<u32> = unsafe { MemoryMapped::new(dma_dest_addr(2)) }; const DMA2_DEST_ADDR: MemoryMapped<u32> = unsafe { MemoryMapped::new(dma_dest_addr(2)) };
const DMA2_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(dma_control_addr(2)) }; const DMA2_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(dma_control_addr(2)) };
const FIFOA_DEST_ADDR: u32 = 0x0400_00a0; const FIFO_A_DEST_ADDR: u32 = 0x0400_00a0;
const FIFOB_DEST_ADDR: u32 = 0x0400_00a4; const FIFO_B_DEST_ADDR: u32 = 0x0400_00a4;
const SOUND_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0082) }; const SOUND_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0082) };
const SOUND_CONTROL_X: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0084) }; const SOUND_CONTROL_X: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0084) };
@ -56,14 +56,14 @@ pub(super) fn enable_dma_for_sound(sound_memory: &[i8], lr: LeftOrRight) {
fn enable_dma1_for_sound(sound_memory: &[i8]) { fn enable_dma1_for_sound(sound_memory: &[i8]) {
DMA1_CONTROL.set(0); DMA1_CONTROL.set(0);
DMA1_SOURCE_ADDR.set(sound_memory.as_ptr() as u32); DMA1_SOURCE_ADDR.set(sound_memory.as_ptr() as u32);
DMA1_DEST_ADDR.set(FIFOA_DEST_ADDR); DMA1_DEST_ADDR.set(FIFO_A_DEST_ADDR);
DMA1_CONTROL.set(DMA_CONTROL_SETTING_FOR_SOUND); DMA1_CONTROL.set(DMA_CONTROL_SETTING_FOR_SOUND);
} }
fn enable_dma2_for_sound(sound_memory: &[i8]) { fn enable_dma2_for_sound(sound_memory: &[i8]) {
DMA2_CONTROL.set(0); DMA2_CONTROL.set(0);
DMA2_SOURCE_ADDR.set(sound_memory.as_ptr() as u32); DMA2_SOURCE_ADDR.set(sound_memory.as_ptr() as u32);
DMA2_DEST_ADDR.set(FIFOB_DEST_ADDR); DMA2_DEST_ADDR.set(FIFO_B_DEST_ADDR);
DMA2_CONTROL.set(DMA_CONTROL_SETTING_FOR_SOUND); DMA2_CONTROL.set(DMA_CONTROL_SETTING_FOR_SOUND);
} }

View file

@ -306,7 +306,7 @@ impl SoundChannel {
/// Creates a new high priority [`SoundChannel`]. /// Creates a new high priority [`SoundChannel`].
/// ///
/// A high priority sound channel will override low priority ones if /// A high priority sound channel will override low priority ones if
/// the mixer runs out of channels. They will also never be overriden /// the mixer runs out of channels. They will also never be overridden
/// by other high priority channels. /// by other high priority channels.
/// ///
/// High priority channels are intended for background music and for /// High priority channels are intended for background music and for

View file

@ -6,7 +6,7 @@
//! which allows for Game Boy and Game Boy Color style sound effects, or the mixer //! which allows for Game Boy and Game Boy Color style sound effects, or the mixer
//! which allows for more advanced sounds. //! which allows for more advanced sounds.
//! //!
//! The [`dmg`](crate::sound::dmg) module is very rudimentry and doesn't support most of the possible //! The [`dmg`](crate::sound::dmg) module is very rudimentary and doesn't support most of the possible
//! sounds possible. However, it may be expanded in the future. //! sounds possible. However, it may be expanded in the future.
//! //!
//! The [`mixer`](crate::sound::mixer) module is high performance, and allows for playing wav files at //! The [`mixer`](crate::sound::mixer) module is high performance, and allows for playing wav files at

View file

@ -26,7 +26,7 @@ impl RawMutex {
/// Locks the mutex and returns whether a lock was successfully acquired. /// Locks the mutex and returns whether a lock was successfully acquired.
fn raw_lock(&self) -> bool { fn raw_lock(&self) -> bool {
if self.0.replace(true) { if self.0.replace(true) {
// value was already true, opps. // value was already true, oops.
false false
} else { } else {
// prevent any weird reordering, and continue // prevent any weird reordering, and continue

View file

@ -3,4 +3,4 @@
Environment setup will depend on the platform you are using. Environment setup will depend on the platform you are using.
agb's requirements are [rust nightly](https://www.rust-lang.org/) edition and the gnu binutils for `arm-none-eabi`. agb's requirements are [rust nightly](https://www.rust-lang.org/) edition and the gnu binutils for `arm-none-eabi`.
See the subpages here for platform specific setup guides. See the sub-pages here for platform specific setup guides.

View file

@ -280,12 +280,12 @@ pub(crate) fn customise_screen(
} }
} }
CustomiseState::Upgrade => { CustomiseState::Upgrade => {
let old_updade = cursor.upgrade; let old_upgrade = cursor.upgrade;
cursor.upgrade = (cursor.upgrade as isize + ud as isize) cursor.upgrade = (cursor.upgrade as isize + ud as isize)
.rem_euclid(upgrades.len() as isize) as usize; .rem_euclid(upgrades.len() as isize) as usize;
if (upgrades[cursor.upgrade] as u32) < 17 { if (upgrades[cursor.upgrade] as u32) < 17 {
if cursor.upgrade != old_updade { if cursor.upgrade != old_upgrade {
load_description( load_description(
upgrades[cursor.upgrade] as usize, upgrades[cursor.upgrade] as usize,
descriptions_map, descriptions_map,

View file

@ -37,8 +37,8 @@ impl FaceSprites {
const S_MALFUNCTION: &Sprite = SPRITES.tags().get("malfunction").sprite(0); const S_MALFUNCTION: &Sprite = SPRITES.tags().get("malfunction").sprite(0);
const S_HEAL: &Sprite = SPRITES.tags().get("player_heal").sprite(0); const S_HEAL: &Sprite = SPRITES.tags().get("player_heal").sprite(0);
const S_BYPASS: &Sprite = SPRITES.tags().get("shield bypass").sprite(0); const S_BYPASS: &Sprite = SPRITES.tags().get("shield bypass").sprite(0);
const S_DOUBLESHOT: &Sprite = SPRITES.tags().get("double shoot").sprite(0); const S_DOUBLE_SHOT: &Sprite = SPRITES.tags().get("double shoot").sprite(0);
const S_TRIPLESHOT: &Sprite = SPRITES.tags().get("triple shoot").sprite(0); const S_TRIPLE_SHOT: &Sprite = SPRITES.tags().get("triple shoot").sprite(0);
const S_BLANK: &Sprite = SPRITES.tags().get("blank").sprite(0); const S_BLANK: &Sprite = SPRITES.tags().get("blank").sprite(0);
const S_DISRUPT: &Sprite = SPRITES.tags().get("disruption").sprite(0); const S_DISRUPT: &Sprite = SPRITES.tags().get("disruption").sprite(0);
const S_MALFUNCTION_SHOOT: &Sprite = SPRITES.tags().get("malfunction shot").sprite(0); const S_MALFUNCTION_SHOOT: &Sprite = SPRITES.tags().get("malfunction shot").sprite(0);
@ -57,8 +57,8 @@ impl FaceSprites {
S_MALFUNCTION, S_MALFUNCTION,
S_HEAL, S_HEAL,
S_BYPASS, S_BYPASS,
S_DOUBLESHOT, S_DOUBLE_SHOT,
S_TRIPLESHOT, S_TRIPLE_SHOT,
S_BLANK, S_BLANK,
S_DISRUPT, S_DISRUPT,
S_MALFUNCTION_SHOOT, S_MALFUNCTION_SHOOT,

View file

@ -1,8 +1,8 @@
use agb::Gba;
use agb::save::Error; use agb::save::Error;
use agb::sync::Static; use agb::sync::Static;
use agb::Gba;
static HIGHSCORE: Static<u32> = Static::new(0); static HIGH_SCORE: Static<u32> = Static::new(0);
pub fn init_save(gba: &mut Gba) -> Result<(), Error> { pub fn init_save(gba: &mut Gba) -> Result<(), Error> {
gba.save.init_sram(); gba.save.init_sram();
@ -22,9 +22,9 @@ pub fn init_save(gba: &mut Gba) -> Result<(), Error> {
let high_score = u32::from_le_bytes(buffer); let high_score = u32::from_le_bytes(buffer);
if high_score > 100 { if high_score > 100 {
HIGHSCORE.write(0) HIGH_SCORE.write(0)
} else { } else {
HIGHSCORE.write(high_score) HIGH_SCORE.write(high_score)
} }
} }
@ -32,11 +32,14 @@ pub fn init_save(gba: &mut Gba) -> Result<(), Error> {
} }
pub fn load_high_score() -> u32 { pub fn load_high_score() -> u32 {
HIGHSCORE.read() HIGH_SCORE.read()
} }
pub fn save_high_score(gba: &mut Gba, score: u32) -> Result<(), Error> { pub fn save_high_score(gba: &mut Gba, score: u32) -> Result<(), Error> {
gba.save.access()?.prepare_write(1..5)?.write(1, &score.to_le_bytes())?; gba.save
HIGHSCORE.write(score); .access()?
.prepare_write(1..5)?
.write(1, &score.to_le_bytes())?;
HIGH_SCORE.write(score);
Ok(()) Ok(())
} }

View file

@ -77,8 +77,8 @@ fn extract_tiles(layer: &'_ tiled::LayerData) -> impl Iterator<Item = u16> + '_
.map(get_map_id) .map(get_map_id)
} }
fn get_map_id(tileid: u32) -> u16 { fn get_map_id(tile_id: u32) -> u16 {
match tileid { match tile_id {
0 => 0, 0 => 0,
i => i as u16 - 1, i => i as u16 - 1,
} }

View file

@ -33,17 +33,17 @@ use sfx::Sfx;
const GRAPHICS: &Graphics = agb::include_aseprite!("gfx/objects.aseprite", "gfx/boss.aseprite"); const GRAPHICS: &Graphics = agb::include_aseprite!("gfx/objects.aseprite", "gfx/boss.aseprite");
const TAG_MAP: &TagMap = GRAPHICS.tags(); const TAG_MAP: &TagMap = GRAPHICS.tags();
const LONGSWORD_IDLE: &Tag = TAG_MAP.get("Idle - longsword"); const LONG_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - longsword");
const LONGSWORD_WALK: &Tag = TAG_MAP.get("Walk - longsword"); const LONG_SWORD_WALK: &Tag = TAG_MAP.get("Walk - longsword");
const LONGSWORD_JUMP: &Tag = TAG_MAP.get("Jump - longsword"); const LONG_SWORD_JUMP: &Tag = TAG_MAP.get("Jump - longsword");
const LONGSWORD_ATTACK: &Tag = TAG_MAP.get("Attack - longsword"); const LONG_SWORD_ATTACK: &Tag = TAG_MAP.get("Attack - longsword");
const LONGSWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("Jump attack - longsword"); const LONG_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("Jump attack - longsword");
const SHORTSWORD_IDLE: &Tag = TAG_MAP.get("Idle - shortsword"); const SHORT_SWORD_IDLE: &Tag = TAG_MAP.get("Idle - shortsword");
const SHORTSWORD_WALK: &Tag = TAG_MAP.get("Walk - shortsword"); const SHORT_SWORD_WALK: &Tag = TAG_MAP.get("Walk - shortsword");
const SHORTSWORD_JUMP: &Tag = TAG_MAP.get("jump - shortsword"); const SHORT_SWORD_JUMP: &Tag = TAG_MAP.get("jump - shortsword");
const SHORTSWORD_ATTACK: &Tag = TAG_MAP.get("attack - shortsword"); const SHORT_SWORD_ATTACK: &Tag = TAG_MAP.get("attack - shortsword");
const SHORTSWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - shortsword"); const SHORT_SWORD_JUMP_ATTACK: &Tag = TAG_MAP.get("jump attack - shortsword");
const KNIFE_IDLE: &Tag = TAG_MAP.get("idle - knife"); const KNIFE_IDLE: &Tag = TAG_MAP.get("idle - knife");
const KNIFE_WALK: &Tag = TAG_MAP.get("walk - knife"); const KNIFE_WALK: &Tag = TAG_MAP.get("walk - knife");
@ -166,7 +166,7 @@ struct Entity<'a> {
impl<'a> Entity<'a> { impl<'a> Entity<'a> {
fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self { fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self {
let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0)); let s = object_controller.sprite(LONG_SWORD_IDLE.sprite(0));
let mut sprite = object_controller.object(s); let mut sprite = object_controller.object(s);
sprite.set_priority(Priority::P1); sprite.set_priority(Priority::P1);
Entity { Entity {
@ -353,16 +353,16 @@ impl SwordState {
fn idle_animation(self, counter: u16) -> &'static Sprite { fn idle_animation(self, counter: u16) -> &'static Sprite {
let counter = counter as usize; let counter = counter as usize;
match self { match self {
SwordState::LongSword => LONGSWORD_IDLE.animation_sprite(counter / 8), SwordState::LongSword => LONG_SWORD_IDLE.animation_sprite(counter / 8),
SwordState::ShortSword => SHORTSWORD_IDLE.animation_sprite(counter / 8), SwordState::ShortSword => SHORT_SWORD_IDLE.animation_sprite(counter / 8),
SwordState::Dagger => KNIFE_IDLE.animation_sprite(counter / 8), SwordState::Dagger => KNIFE_IDLE.animation_sprite(counter / 8),
SwordState::Swordless => SWORDLESS_IDLE.animation_sprite(counter / 8), SwordState::Swordless => SWORDLESS_IDLE.animation_sprite(counter / 8),
} }
} }
fn jump_tag(self) -> &'static Tag { fn jump_tag(self) -> &'static Tag {
match self { match self {
SwordState::LongSword => LONGSWORD_JUMP, SwordState::LongSword => LONG_SWORD_JUMP,
SwordState::ShortSword => SHORTSWORD_JUMP, SwordState::ShortSword => SHORT_SWORD_JUMP,
SwordState::Dagger => KNIFE_JUMP, SwordState::Dagger => KNIFE_JUMP,
SwordState::Swordless => SWORDLESS_JUMP, SwordState::Swordless => SWORDLESS_JUMP,
} }
@ -370,8 +370,8 @@ impl SwordState {
fn walk_animation(self, counter: u16) -> &'static Sprite { fn walk_animation(self, counter: u16) -> &'static Sprite {
let counter = counter as usize; let counter = counter as usize;
match self { match self {
SwordState::LongSword => LONGSWORD_WALK.animation_sprite(counter / 4), SwordState::LongSword => LONG_SWORD_WALK.animation_sprite(counter / 4),
SwordState::ShortSword => SHORTSWORD_WALK.animation_sprite(counter / 4), SwordState::ShortSword => SHORT_SWORD_WALK.animation_sprite(counter / 4),
SwordState::Dagger => KNIFE_WALK.animation_sprite(counter / 4), SwordState::Dagger => KNIFE_WALK.animation_sprite(counter / 4),
SwordState::Swordless => SWORDLESS_WALK.animation_sprite(counter / 4), SwordState::Swordless => SWORDLESS_WALK.animation_sprite(counter / 4),
} }
@ -402,8 +402,8 @@ impl SwordState {
} }
fn jump_attack_tag(self) -> &'static Tag { fn jump_attack_tag(self) -> &'static Tag {
match self { match self {
SwordState::LongSword => LONGSWORD_JUMP_ATTACK, SwordState::LongSword => LONG_SWORD_JUMP_ATTACK,
SwordState::ShortSword => SHORTSWORD_JUMP_ATTACK, SwordState::ShortSword => SHORT_SWORD_JUMP_ATTACK,
SwordState::Dagger => KNIFE_JUMP_ATTACK, SwordState::Dagger => KNIFE_JUMP_ATTACK,
SwordState::Swordless => SWORDLESS_JUMP_ATTACK, SwordState::Swordless => SWORDLESS_JUMP_ATTACK,
} }
@ -425,8 +425,8 @@ impl SwordState {
} }
fn attack_tag(self) -> &'static Tag { fn attack_tag(self) -> &'static Tag {
match self { match self {
SwordState::LongSword => LONGSWORD_ATTACK, SwordState::LongSword => LONG_SWORD_ATTACK,
SwordState::ShortSword => SHORTSWORD_ATTACK, SwordState::ShortSword => SHORT_SWORD_ATTACK,
SwordState::Dagger => KNIFE_ATTACK, SwordState::Dagger => KNIFE_ATTACK,
SwordState::Swordless => SWORDLESS_ATTACK, SwordState::Swordless => SWORDLESS_ATTACK,
} }
@ -539,7 +539,7 @@ impl<'a> Player<'a> {
object_controller, object_controller,
Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()), Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()),
); );
let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0)); let s = object_controller.sprite(LONG_SWORD_IDLE.sprite(0));
entity.sprite.set_sprite(s); entity.sprite.set_sprite(s);
entity.sprite.show(); entity.sprite.show();
entity.position = (144, 0).into(); entity.position = (144, 0).into();
@ -739,7 +739,7 @@ impl<'a> Player<'a> {
instruction instruction
} }
// retuns true if the player is alive and false otherwise // returns true if the player is alive and false otherwise
fn damage(&mut self) -> (bool, bool) { fn damage(&mut self) -> (bool, bool) {
if self.damage_cooldown != 0 { if self.damage_cooldown != 0 {
return (true, false); return (true, false);
@ -1284,9 +1284,9 @@ impl EmuData {
let gravity = gravity / 16; let gravity = gravity / 16;
entity.velocity.y += gravity; entity.velocity.y += gravity;
let distance_travelled = entity.update_position(level); let distance_traveled = entity.update_position(level);
if distance_travelled.x == 0.into() { if distance_traveled.x == 0.into() {
sfx.emu_crash(); sfx.emu_crash();
self.state = EmuState::Knockback; self.state = EmuState::Knockback;
entity.velocity = (-direction / 2, Number::new(-1)).into(); entity.velocity = (-direction / 2, Number::new(-1)).into();

View file

@ -26,7 +26,7 @@ fn main() {
.compile("test-runner"); .compile("test-runner");
println!("cargo:rustc-link-search={}", out_path.to_str().unwrap()); println!("cargo:rustc-link-search={}", out_path.to_str().unwrap());
println!("cargo:rustc-link-lib=static={}", "mgba-cycle"); println!("cargo:rustc-link-lib=static=mgba-cycle");
println!("cargo:rustc-link-lib=elf"); println!("cargo:rustc-link-lib=elf");
let bindings = bindgen::Builder::default() let bindings = bindgen::Builder::default()

View file

@ -14,7 +14,7 @@ use std::path::Path;
enum Status { enum Status {
Running, Running,
Failed, Failed,
Sucess, Success,
} }
enum Timing { enum Timing {
@ -84,7 +84,7 @@ fn test_file(file_to_run: &str) -> Status {
} }
if out == "Tests finished successfully" { if out == "Tests finished successfully" {
finished = Status::Sucess; finished = Status::Success;
} }
} }
}); });
@ -111,7 +111,7 @@ fn main() -> Result<(), Error> {
match output { match output {
Status::Failed => Err(anyhow!("Tests failed!")), Status::Failed => Err(anyhow!("Tests failed!")),
Status::Sucess => Ok(()), Status::Success => Ok(()),
_ => { _ => {
unreachable!("very bad thing happened"); unreachable!("very bad thing happened");
} }

View file

@ -129,7 +129,7 @@ fn update_to_version(
toml_edit::Item::None => continue, toml_edit::Item::None => continue,
_ => { _ => {
return Err(Error::InvalidToml(format!( return Err(Error::InvalidToml(format!(
"{:?} while seaching dependencies in {}", "{:?} while searching dependencies in {}",
this_dep, this_dep,
cargo_toml_file.to_string_lossy() cargo_toml_file.to_string_lossy()
))) )))