palettes and oam (#137)

This commit is contained in:
Lokathor 2021-04-16 15:01:38 -06:00 committed by GitHub
parent d93facbaf4
commit 9e8349c82e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 0 deletions

View file

@ -287,3 +287,21 @@ pub const INTR_WAIT_ACKNOWLEDGE: VolAddress<InterruptFlags, Safe, Unsafe> = unsa
// refer to that value instead.
VolAddress::new(0x0300_FFF8)
};
pub const BACKDROP_COLOR: VolAddress<Color, Safe, Safe> = unsafe { VolAddress::new(0x0500_0000) };
pub const BG_PALETTE: VolBlock<Color, Safe, Safe, 256> = unsafe { VolBlock::new(0x0500_0000) };
pub const OBJ_PALETTE: VolBlock<Color, Safe, Safe, 256> = unsafe { VolBlock::new(0x0500_0200) };
pub const OAM_ATTR0: VolSeries<ObjAttr0, Safe, Safe, 128, 8> =
unsafe { VolSeries::new(0x0700_0000) };
pub const OAM_ATTR1: VolSeries<ObjAttr1, Safe, Safe, 128, 8> =
unsafe { VolSeries::new(0x0700_0002) };
pub const OAM_ATTR2: VolSeries<ObjAttr2, Safe, Safe, 128, 8> =
unsafe { VolSeries::new(0x0700_0004) };
pub const OAM_PA: VolSeries<i16, Safe, Safe, 32, 0x20> = unsafe { VolSeries::new(0x0700_0006) };
pub const OAM_PB: VolSeries<i16, Safe, Safe, 32, 0x20> = unsafe { VolSeries::new(0x0700_000E) };
pub const OAM_PC: VolSeries<i16, Safe, Safe, 32, 0x20> = unsafe { VolSeries::new(0x0700_0016) };
pub const OAM_PD: VolSeries<i16, Safe, Safe, 32, 0x20> = unsafe { VolSeries::new(0x0700_001E) };

View file

@ -209,3 +209,12 @@ pub use noise_len_env::*;
mod noise_frequency_control;
pub use noise_frequency_control::*;
mod obj_attr0;
pub use obj_attr0::*;
mod obj_attr1;
pub use obj_attr1::*;
mod obj_attr2;
pub use obj_attr2::*;

View file

@ -0,0 +1,15 @@
use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(transparent)]
pub struct ObjAttr0(u16);
impl ObjAttr0 {
const_new!();
bitfield_int!(u16; 0..=7: u16, y_pos, with_y_pos, set_y_pos);
bitfield_bool!(u16; 8, affine, with_affine, set_affine);
bitfield_bool!(u16; 9, double_disabled, with_double_disabled, set_double_disabled);
bitfield_int!(u16; 10..=11: u16, obj_mode, with_obj_mode, set_obj_mode);
bitfield_bool!(u16; 12, mosaic, with_mosaic, set_mosaic);
bitfield_bool!(u16; 13, use_palbank, with_use_palbank, set_use_palbank);
bitfield_int!(u16; 14..=15: u16, obj_shape, with_obj_shape, set_obj_shape);
}

View file

@ -0,0 +1,13 @@
use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(transparent)]
pub struct ObjAttr1(u16);
impl ObjAttr1 {
const_new!();
bitfield_int!(u16; 0..=8: u16, x_pos, with_x_pos, set_x_pos);
bitfield_int!(u16; 9..=13: u16, affine_index, with_affine_index, set_affine_index);
bitfield_bool!(u16; 12, hflip, with_hflip, set_hflip);
bitfield_bool!(u16; 13, vflip, with_vflip, set_vflip);
bitfield_int!(u16; 14..=15: u16, obj_size, with_obj_size, set_obj_size);
}

View file

@ -0,0 +1,11 @@
use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(transparent)]
pub struct ObjAttr2(u16);
impl ObjAttr2 {
const_new!();
bitfield_int!(u16; 0..=9: u16, tile_index, with_tile_index, set_tile_index);
bitfield_int!(u16; 10..=11: u16, priority, with_priority, set_priority);
bitfield_int!(u16; 12..=15: u16, palbank_index, with_palbank_index, set_palbank_index);
}