Skip to content

Commit

Permalink
bios fns should be consistent about on_gba_or_unimplemented usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Jun 3, 2024
1 parent ab424c8 commit 35018e6
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,30 @@ use crate::IrqBits;
#[inline]
#[cfg_attr(feature = "on_gba", instruction_set(arm::t32))]
pub fn IntrWait(ignore_existing: bool, target_irqs: IrqBits) {
on_gba_or_unimplemented!(
unsafe {
core::arch::asm! {
"swi #0x04",
inout("r0") ignore_existing as u32 => _,
inout("r1") target_irqs.0 => _,
out("r3") _,
options(preserves_flags),
}
};
);
on_gba_or_unimplemented!(unsafe {
core::arch::asm! {
"swi #0x04",
inout("r0") ignore_existing as u32 => _,
inout("r1") target_irqs.0 => _,
out("r3") _,
options(preserves_flags),
}
});
}

/// `0x05`: Builtin shorthand for [`IntrWait(true, IrqBits::VBLANK)`](IntrWait)
#[inline]
#[cfg_attr(feature = "on_gba", instruction_set(arm::t32))]
pub fn VBlankIntrWait() {
on_gba_or_unimplemented!(
unsafe {
core::arch::asm! {
"swi #0x05",
out("r0") _,
out("r1") _,
out("r3") _,
options(preserves_flags),
}
};
);
on_gba_or_unimplemented!(unsafe {
core::arch::asm! {
"swi #0x05",
out("r0") _,
out("r1") _,
out("r3") _,
options(preserves_flags),
}
});
}

/// `0x09`: Arc tangent.
Expand All @@ -72,15 +68,15 @@ pub fn VBlankIntrWait() {
#[instruction_set(arm::t32)]
pub fn ArcTan(theta: crate::i16fx14) -> crate::i16fx14 {
let mut i = theta.to_bits();
unsafe {
on_gba_or_unimplemented!(unsafe {
core::arch::asm! {
"swi #0x09",
inout("r0") i,
out("r1") _,
out("r3") _,
options(pure, nomem, preserves_flags),
}
};
});
crate::i16fx14::from_bits(i)
}

Expand All @@ -96,31 +92,29 @@ pub fn ArcTan2(x: crate::i16fx14, y: crate::i16fx14) -> u16 {
let x = x.to_bits();
let y = y.to_bits();
let output: u16;
unsafe {
on_gba_or_unimplemented!(unsafe {
core::arch::asm! {
"swi #0x0A",
inout("r0") x => output,
inout("r1") y => _,
out("r3") _,
options(pure, nomem, preserves_flags),
}
};
});
output
}

/// `0x12` TODO: document this more
#[inline]
#[cfg_attr(feature = "on_gba", instruction_set(arm::t32))]
pub unsafe fn LZ77UnCompReadNormalWrite16bit(src: *const u32, dst: *mut u16) {
on_gba_or_unimplemented!(
unsafe {
core::arch::asm! {
"swi #0x12",
inout("r0") src => _,
inout("r1") dst => _,
out("r3") _,
options(preserves_flags),
}
};
);
on_gba_or_unimplemented!(unsafe {
core::arch::asm! {
"swi #0x12",
inout("r0") src => _,
inout("r1") dst => _,
out("r3") _,
options(preserves_flags),
}
});
}

0 comments on commit 35018e6

Please sign in to comment.