From 496b4a49531e97f9b3a15a124ce4878565300eda Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 22 Sep 2022 21:33:59 +0100 Subject: [PATCH] repr packed --- agb/src/display/object.rs | 2 +- agb/src/syscall.rs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 744be038..4389a0fa 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -1198,7 +1198,7 @@ enum ColourMode { /// This can be obtained from X/Y scale and rotation angle with /// [`agb::syscall::affine_matrix`]. #[derive(Copy, Clone, Default, Debug, PartialEq, Eq)] -#[repr(C)] +#[repr(C, packed)] pub struct AffineMatrixAttributes { /// Adjustment made to *X* coordinate when drawing *horizontal* lines. /// Also known as "dx". diff --git a/agb/src/syscall.rs b/agb/src/syscall.rs index a91b8b79..e7d342bd 100644 --- a/agb/src/syscall.rs +++ b/agb/src/syscall.rs @@ -139,7 +139,7 @@ pub fn arc_tan2(x: i16, y: i32) -> i16 { result } -#[repr(C)] +#[repr(C, packed)] pub struct BgAffineSetData { pub matrix: AffineMatrixAttributes, pub position: Vector2D>, @@ -180,11 +180,12 @@ pub fn bg_affine_matrix( unsafe { asm!( - "swi {SWI}", - SWI = const { swi_map(0x0E) }, - in("r0") &input as *const Input, - in("r1") output.as_mut_ptr(), - in("r2") 1, + "swi {SWI}", + SWI = const { swi_map(0x0E) }, + in("r0") &input as *const Input, + in("r1") output.as_mut_ptr(), + in("r2") 1, + lateout("r3") _, ); } @@ -235,7 +236,9 @@ mod tests { let one: Num = 1.into(); let aff = obj_affine_matrix((one, one).into(), Num::default()); - assert_eq!(aff.p_a, one); - assert_eq!(aff.p_d, one); + let (p_a, p_d) = (aff.p_a, aff.p_d); + + assert_eq!(p_a, one); + assert_eq!(p_d, one); } }