Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
corwinkuiper committed Jun 28, 2024
1 parent 964e29b commit 3daf183
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"agb-image-converter",
"agb-macros",
"agb-sound-converter",
"agb-reg",

"tracker/agb-midi",
"tracker/agb-midi-core",
Expand Down
16 changes: 10 additions & 6 deletions agb-reg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

//! This crate contains definitions of the hardware registers used in the Game
//! Boy Advance. It contains bitfields that define the registers as well as
//! pointers too them.
//! pointers to them.
//!
//! This crate may only be used on the GBA, use elsewhere is a very quick way to
//! get UB.
Expand Down Expand Up @@ -288,17 +288,21 @@ pub struct Offset {
pub vertical: u16,
}

trait OffsetDeref {
fn horizontal_ptr(self) -> *mut u16;
fn vertical_ptr(self) -> *mut u16;
pub trait OffsetDeref {
/// # Safety
/// Pointer must be valid
unsafe fn horizontal_ptr(self) -> *mut u16;
/// # Safety
/// Pointer must be valid
unsafe fn vertical_ptr(self) -> *mut u16;
}

impl OffsetDeref for *mut Offset {
fn horizontal_ptr(self) -> *mut u16 {
unsafe fn horizontal_ptr(self) -> *mut u16 {
unsafe { core::ptr::addr_of_mut!((*self).horizontal) }
}

fn vertical_ptr(self) -> *mut u16 {
unsafe fn vertical_ptr(self) -> *mut u16 {
unsafe { core::ptr::addr_of_mut!((*self).vertical) }
}
}
Expand Down

0 comments on commit 3daf183

Please sign in to comment.