Skip to main content

hram

Macro hram 

Source
macro_rules! hram {
    () => { ... };
    (
        $(#[$attr:meta])*
        $vis:vis static $name:ident $(as $sym:literal)?: HramArea<$n:tt>;
        $($rest:tt)*
    ) => { ... };
    (
        $(#[$attr:meta])*
        $vis:vis static $name:ident $(as $sym:literal)?: HramAtomicCell<$ty:ty>;
        $($rest:tt)*
    ) => { ... };
    (
        $(#[$attr:meta])*
        $vis:vis static $name:ident $(as $sym:literal)?: HramCell<$ty:ty>;
        $($rest:tt)*
    ) => { ... };
}
Expand description

Declare static HRAM cells and areas, each at a linker-assigned High RAM address.

The declared type selects the kind and must be written as one of the three names below, unqualified; the macro matches on it syntactically, so a path or an alias does not work.

hram! {
    pub static FRAME: HramAtomicCell<u8>;
    static SCROLL: HramCell<ScrollState>;
    static OAM_DMA: HramArea<13>;
    static CURRENT_BANK as "_current_bank": HramAtomicCell<u8>;
}

Each cell becomes a same-named constant carrying the accessors. See the crate docs for which kind to reach for.