Fix affine background matrix creation outside of the 1st quadrant

This commit is contained in:
Gwilym Inzani 2024-05-27 14:42:53 +01:00
parent 27ee9c7b85
commit fde444e253
2 changed files with 4 additions and 4 deletions

View file

@ -43,8 +43,8 @@ fn main(mut gba: agb::Gba) -> ! {
loop { loop {
input.update(); input.update();
scroll_x += input.x_tri() as i32; scroll_x += input.x_tri() as i16;
scroll_y += input.y_tri() as i32; scroll_y += input.y_tri() as i16;
let scroll_pos = (scroll_x, scroll_y); let scroll_pos = (scroll_x, scroll_y);

View file

@ -298,11 +298,11 @@ impl AffineMatrixBackground {
transform_origin: impl Into<Vector2D<Num<i32, 8>>>, transform_origin: impl Into<Vector2D<Num<i32, 8>>>,
scale: impl Into<Vector2D<Num<i32, 8>>>, scale: impl Into<Vector2D<Num<i32, 8>>>,
rotation: Num<i32, 16>, rotation: Num<i32, 16>,
position: impl Into<Vector2D<Num<i32, 8>>>, position: impl Into<Vector2D<i16>>,
) -> Self { ) -> Self {
crate::syscall::bg_affine_matrix( crate::syscall::bg_affine_matrix(
transform_origin.into(), transform_origin.into(),
position.into().try_change_base::<i16, 8>().unwrap().floor(), position.into(),
scale.into().try_change_base().unwrap(), scale.into().try_change_base().unwrap(),
rotation.rem_euclid(1.into()).try_change_base().unwrap(), rotation.rem_euclid(1.into()).try_change_base().unwrap(),
) )