Skip to main content

set_mapper

Macro set_mapper 

Source
macro_rules! set_mapper {
    ($mapper:ty) => { ... };
}
Available on crate feature bank only.
Expand description

Name the Mapper this program’s cartridge uses.

Only a custom cartridge needs this; a stock one is picked from header.toml.

Write it once, anywhere in the program, and build with --cfg gb_custom_mapper so that gb-bank does not also name one.

struct MyCart;

unsafe impl gb_bank::Mapper for MyCart {
    unsafe fn select(bank: gb_bank::BankNumber) {
        unsafe { core::ptr::write_volatile(0x2100 as *mut u8, bank.get() as u8) };
    }
}

gb_bank::set_mapper!(MyCart);