Skip to content

Commit

Permalink
easy to get pointers to offset components
Browse files Browse the repository at this point in the history
  • Loading branch information
corwinkuiper committed Dec 6, 2023
1 parent 706f429 commit 7472a31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions agb-reg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,21 @@ pub struct Offset {
pub vertical: u16,
}

trait OffsetDeref {
fn horizontal_ptr(self) -> *mut u16;
fn vertical_ptr(self) -> *mut u16;
}

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

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

#[bitsize(16)]
#[derive(TryFromBits, Clone, Copy, PartialEq, Eq, DebugBits)]
pub struct DisplayControl {
Expand Down

0 comments on commit 7472a31

Please sign in to comment.