mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
commit
b9b08780ff
|
@ -43,7 +43,7 @@ impl BumpAllocator {
|
||||||
let resulting_ptr = ptr + amount_to_add;
|
let resulting_ptr = ptr + amount_to_add;
|
||||||
let new_current_ptr = resulting_ptr + layout.size();
|
let new_current_ptr = resulting_ptr + layout.size();
|
||||||
|
|
||||||
if new_current_ptr as usize >= (self.start_end.borrow(cs).end)() {
|
if new_current_ptr >= (self.start_end.borrow(cs).end)() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -627,7 +627,7 @@ impl ObjectController {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
|
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
|
||||||
.add((i as usize) * 4)
|
.add(i * 4)
|
||||||
.write_volatile(HIDDEN_VALUE);
|
.write_volatile(HIDDEN_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,7 +794,7 @@ impl ObjectController {
|
||||||
});
|
});
|
||||||
|
|
||||||
let loan = Loan {
|
let loan = Loan {
|
||||||
index: index as u8,
|
index,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -916,8 +916,8 @@ impl<'a> Object<'a> {
|
||||||
/// [ObjectController::commit] is called.
|
/// [ObjectController::commit] is called.
|
||||||
pub fn set_x(&mut self, x: u16) -> &mut Self {
|
pub fn set_x(&mut self, x: u16) -> &mut Self {
|
||||||
let object_inner = unsafe { self.object_inner() };
|
let object_inner = unsafe { self.object_inner() };
|
||||||
object_inner.attrs.a1a.set_x(x.rem_euclid(1 << 9) as u16);
|
object_inner.attrs.a1a.set_x(x.rem_euclid(1 << 9));
|
||||||
object_inner.attrs.a1s.set_x(x.rem_euclid(1 << 9) as u16);
|
object_inner.attrs.a1s.set_x(x.rem_euclid(1 << 9));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ impl VRamManager {
|
||||||
slice::from_raw_parts_mut(
|
slice::from_raw_parts_mut(
|
||||||
tiles
|
tiles
|
||||||
.as_mut_ptr()
|
.as_mut_ptr()
|
||||||
.add((index * tile_format.tile_size()) as usize)
|
.add(index * tile_format.tile_size())
|
||||||
.cast(),
|
.cast(),
|
||||||
tile_format.tile_size() / core::mem::size_of::<u32>(),
|
tile_format.tile_size() / core::mem::size_of::<u32>(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -51,7 +51,7 @@ fn set_bank(bank: u8) -> Result<(), Error> {
|
||||||
Err(Error::OutOfBounds)
|
Err(Error::OutOfBounds)
|
||||||
} else if bank != CURRENT_BANK.read() {
|
} else if bank != CURRENT_BANK.read() {
|
||||||
issue_flash_command(CMD_SET_BANK);
|
issue_flash_command(CMD_SET_BANK);
|
||||||
FLASH_PORT_BANK.set(bank as u8);
|
FLASH_PORT_BANK.set(bank);
|
||||||
CURRENT_BANK.write(bank);
|
CURRENT_BANK.write(bank);
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl RolledDice {
|
||||||
let heal = *face_counts.entry(Face::Heal).or_default();
|
let heal = *face_counts.entry(Face::Heal).or_default();
|
||||||
if heal != 0 {
|
if heal != 0 {
|
||||||
actions.push(Action::PlayerHeal {
|
actions.push(Action::PlayerHeal {
|
||||||
amount: ((heal * (heal + 1)) / 2) as u32,
|
amount: (heal * (heal + 1)) / 2,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl<'a> Level<'a> {
|
||||||
let factor: Number = Number::new(1) / Number::new(8);
|
let factor: Number = Number::new(1) / Number::new(8);
|
||||||
let (x, y) = (v * factor).floor().get();
|
let (x, y) = (v * factor).floor().get();
|
||||||
|
|
||||||
if (x < 0 || x > tilemap::WIDTH as i32) || (y < 0 || y > tilemap::HEIGHT as i32) {
|
if !(0..=tilemap::WIDTH).contains(&x) || !(0..=tilemap::HEIGHT).contains(&y) {
|
||||||
return Some(Rect::new((x * 8, y * 8).into(), (8, 8).into()));
|
return Some(Rect::new((x * 8, y * 8).into(), (8, 8).into()));
|
||||||
}
|
}
|
||||||
let position = tilemap::WIDTH as usize * y as usize + x as usize;
|
let position = tilemap::WIDTH as usize * y as usize + x as usize;
|
||||||
|
@ -1878,7 +1878,7 @@ enum MoveState {
|
||||||
impl<'a> Game<'a> {
|
impl<'a> Game<'a> {
|
||||||
fn has_just_reached_end(&self) -> bool {
|
fn has_just_reached_end(&self) -> bool {
|
||||||
match self.boss {
|
match self.boss {
|
||||||
BossState::NotSpawned => self.offset.x.floor() + 248 >= tilemap::WIDTH as i32 * 8,
|
BossState::NotSpawned => self.offset.x.floor() + 248 >= tilemap::WIDTH * 8,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1901,13 +1901,13 @@ impl<'a> Game<'a> {
|
||||||
|
|
||||||
if self.has_just_reached_end() {
|
if self.has_just_reached_end() {
|
||||||
sfx.boss();
|
sfx.boss();
|
||||||
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
|
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
|
||||||
self.move_state = MoveState::PinnedAtEnd;
|
self.move_state = MoveState::PinnedAtEnd;
|
||||||
self.boss = BossState::Active(Boss::new(object_controller, self.offset))
|
self.boss = BossState::Active(Boss::new(object_controller, self.offset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MoveState::PinnedAtEnd => {
|
MoveState::PinnedAtEnd => {
|
||||||
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
|
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
|
||||||
}
|
}
|
||||||
MoveState::FollowingPlayer => {
|
MoveState::FollowingPlayer => {
|
||||||
Game::update_sunrise(vram, self.sunrise_timer);
|
Game::update_sunrise(vram, self.sunrise_timer);
|
||||||
|
@ -1917,8 +1917,8 @@ impl<'a> Game<'a> {
|
||||||
let difference = self.player.entity.position.x - (self.offset.x + WIDTH / 2);
|
let difference = self.player.entity.position.x - (self.offset.x + WIDTH / 2);
|
||||||
|
|
||||||
self.offset.x += difference / 8;
|
self.offset.x += difference / 8;
|
||||||
if self.offset.x > (tilemap::WIDTH as i32 * 8 - 248).into() {
|
if self.offset.x > (tilemap::WIDTH * 8 - 248).into() {
|
||||||
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
|
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
|
||||||
} else if self.offset.x < 8.into() {
|
} else if self.offset.x < 8.into() {
|
||||||
self.offset.x = 8.into();
|
self.offset.x = 8.into();
|
||||||
self.move_state = MoveState::Ending;
|
self.move_state = MoveState::Ending;
|
||||||
|
|
Loading…
Reference in a new issue