mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
fix test
This commit is contained in:
parent
6d7bc75bbb
commit
f6dd65ae52
|
@ -139,9 +139,10 @@ pub fn arc_tan2(x: i16, y: i32) -> i16 {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `rotation` is in revolutions.
|
/// `rotation` is in revolutions. It is hard to create the rotation, usually
|
||||||
|
/// you'll go in from a larger sized type.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bg_affine_matrix(
|
pub(crate) fn bg_affine_matrix(
|
||||||
bg_center: Vector2D<Num<i32, 8>>,
|
bg_center: Vector2D<Num<i32, 8>>,
|
||||||
display_center: Vector2D<i16>,
|
display_center: Vector2D<i16>,
|
||||||
scale: Vector2D<Num<i16, 8>>,
|
scale: Vector2D<Num<i16, 8>>,
|
||||||
|
@ -185,54 +186,12 @@ pub fn bg_affine_matrix(
|
||||||
unsafe { output.assume_init() }
|
unsafe { output.assume_init() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `rotation` is in revolutions.
|
|
||||||
#[must_use]
|
|
||||||
pub fn obj_affine_matrix(scale: Vector2D<Num<i16, 8>>, rotation: Num<u8, 8>) -> AffineMatrixObject {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[repr(C, packed(4))]
|
|
||||||
struct Input {
|
|
||||||
scale: Vector2D<Num<i16, 8>>,
|
|
||||||
rotation: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
let input = Input {
|
|
||||||
scale,
|
|
||||||
rotation: u16::from(rotation.to_raw()) << 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut output = MaybeUninit::uninit();
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
asm!(
|
|
||||||
"swi {SWI}",
|
|
||||||
SWI = const { swi_map(0x0F) },
|
|
||||||
in("r0") &input as *const Input,
|
|
||||||
in("r1") output.as_mut_ptr(),
|
|
||||||
in("r2") 1,
|
|
||||||
in("r3") 2,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe { output.assume_init() }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::display::affine::AffineMatrix;
|
use crate::display::affine::AffineMatrix;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test_case]
|
|
||||||
fn affine_obj(_gba: &mut crate::Gba) {
|
|
||||||
// expect identity matrix
|
|
||||||
let one: Num<i16, 8> = 1.into();
|
|
||||||
|
|
||||||
let aff = obj_affine_matrix((one, one).into(), Num::default());
|
|
||||||
let matrix = aff.to_affine_matrix();
|
|
||||||
|
|
||||||
assert_eq!(matrix, AffineMatrix::identity());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn affine_bg(_gba: &mut crate::Gba) {
|
fn affine_bg(_gba: &mut crate::Gba) {
|
||||||
// expect the identity matrix
|
// expect the identity matrix
|
||||||
|
@ -240,7 +199,7 @@ mod tests {
|
||||||
(0, 0).into(),
|
(0, 0).into(),
|
||||||
(0i16, 0i16).into(),
|
(0i16, 0i16).into(),
|
||||||
(1i16, 1i16).into(),
|
(1i16, 1i16).into(),
|
||||||
0.into(),
|
Default::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let matrix = aff.to_affine_matrix();
|
let matrix = aff.to_affine_matrix();
|
||||||
|
|
Loading…
Reference in a new issue