Skip to main content

edit_attrs

Function edit_attrs 

Source
pub fn edit_attrs<R>(f: impl FnOnce(AttrAccess<'_>) -> R) -> R
Available on crate feature cgb only.
Expand description

Map the attribute plane and leave it mapped for f.

with_vram_bank nested inside f puts the mapping back as it leaves, so the token is good again after it. During it the token is not: a write through it then lands in whatever that scope mapped. So does one made after a handler switched the bank and left it switched.

There is no plane to map on an original Game Boy, and nothing refuses the attempt: f writes attribute bytes over the tile indices instead. A cartridge that runs on both machines has to ask is_cgb first.

map::edit_attrs(|a| {
    a.set(d, Map::Zero, 3, 3, highlight);
    a.set(d, Map::Zero, 4, 3, highlight);
});