From fde444e253f29c4f38ae5a701829cfbd3a5149c9 Mon Sep 17 00:00:00 2001
From: Gwilym Inzani <email@gwilym.dev>
Date: Mon, 27 May 2024 14:42:53 +0100
Subject: [PATCH] Fix affine background matrix creation outside of the 1st
 quadrant

---
 agb/examples/affine_background.rs | 4 ++--
 agb/src/display/affine.rs         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/agb/examples/affine_background.rs b/agb/examples/affine_background.rs
index d852238e..ae09643f 100644
--- a/agb/examples/affine_background.rs
+++ b/agb/examples/affine_background.rs
@@ -43,8 +43,8 @@ fn main(mut gba: agb::Gba) -> ! {
 
     loop {
         input.update();
-        scroll_x += input.x_tri() as i32;
-        scroll_y += input.y_tri() as i32;
+        scroll_x += input.x_tri() as i16;
+        scroll_y += input.y_tri() as i16;
 
         let scroll_pos = (scroll_x, scroll_y);
 
diff --git a/agb/src/display/affine.rs b/agb/src/display/affine.rs
index 008b58ad..921d460d 100644
--- a/agb/src/display/affine.rs
+++ b/agb/src/display/affine.rs
@@ -298,11 +298,11 @@ impl AffineMatrixBackground {
         transform_origin: impl Into<Vector2D<Num<i32, 8>>>,
         scale: impl Into<Vector2D<Num<i32, 8>>>,
         rotation: Num<i32, 16>,
-        position: impl Into<Vector2D<Num<i32, 8>>>,
+        position: impl Into<Vector2D<i16>>,
     ) -> Self {
         crate::syscall::bg_affine_matrix(
             transform_origin.into(),
-            position.into().try_change_base::<i16, 8>().unwrap().floor(),
+            position.into(),
             scale.into().try_change_base().unwrap(),
             rotation.rem_euclid(1.into()).try_change_base().unwrap(),
         )