small cleanups

This commit is contained in:
Lokathor 2018-12-27 11:51:53 -07:00
parent 147a2bc45c
commit e475253dcf
6 changed files with 18 additions and 20 deletions

View file

@ -7,10 +7,9 @@ use gba::{
display::{DisplayControlSetting, DISPCNT},
},
palram::index_palram_bg_4bpp,
vram::text::{TextScreenblockEntry},
vram::{text::TextScreenblockEntry, Tile4bpp, CHAR_BASE_BLOCKS, SCREEN_BASE_BLOCKS},
Color,
};
use gba::vram::{Tile4bpp, CHAR_BASE_BLOCKS, SCREEN_BASE_BLOCKS};
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
@ -34,7 +33,7 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
let dark_entry = TextScreenblockEntry::from_tile_index(1);
checker_screenblock(8, light_entry, dark_entry);
// bg0 control
BG0CNT.write(BackgroundControlSetting::from_screen_base_block(8));
BG0CNT.write(BackgroundControlSetting::new().with_screen_base_block(8));
// Display Control
DISPCNT.write(DisplayControlSetting::new().with_bg0(true));
loop {

View file

@ -25,12 +25,6 @@ newtype! {
BackgroundControlSetting, u16
}
impl BackgroundControlSetting {
pub const fn from_screen_base_block(screen_base_block: u16) -> Self {
BackgroundControlSetting((screen_base_block & 31) << 8)
}
//
bool_bits!(u16, [(6, mosaic), (7, is_8bpp), (13, display_overflow_wrapping)]);
multi_bits!(
@ -73,24 +67,24 @@ pub enum BGSize {
Three = 3,
}
// BG0 X-Offset. Write only. Text mode only. 9 bits.
/// BG0 X-Offset. Write only. Text mode only. 9 bits.
pub const BG0HOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0010) };
// BG0 Y-Offset. Write only. Text mode only. 9 bits.
/// BG0 Y-Offset. Write only. Text mode only. 9 bits.
pub const BG0VOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0012) };
// BG1 X-Offset. Write only. Text mode only. 9 bits.
/// BG1 X-Offset. Write only. Text mode only. 9 bits.
pub const BG1HOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0012) };
// BG1 Y-Offset. Write only. Text mode only. 9 bits.
/// BG1 Y-Offset. Write only. Text mode only. 9 bits.
pub const BG1VOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0012) };
// BG2 X-Offset. Write only. Text mode only. 9 bits.
/// BG2 X-Offset. Write only. Text mode only. 9 bits.
pub const BG2HOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0018) };
// BG2 Y-Offset. Write only. Text mode only. 9 bits.
/// BG2 Y-Offset. Write only. Text mode only. 9 bits.
pub const BG2VOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_001A) };
// BG3 X-Offset. Write only. Text mode only. 9 bits.
/// BG3 X-Offset. Write only. Text mode only. 9 bits.
pub const BG3HOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_001C) };
// BG3 Y-Offset. Write only. Text mode only. 9 bits.
/// BG3 Y-Offset. Write only. Text mode only. 9 bits.
pub const BG3VOFS: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_001E) };
// TODO: affine backgrounds

View file

@ -187,4 +187,4 @@ impl MosaicSetting {
(12, 4, obj_vertical_inc),
]
);
}
}

View file

@ -25,6 +25,8 @@
use super::*;
// TODO: striding blocks?
/// Timer 0 Counter/Reload. Special (see module).
pub const TM0CNT_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0100) };

View file

@ -1,3 +1,5 @@
//! Module for affine things.
use super::*;
newtype! {

View file

@ -8,13 +8,14 @@ newtype! {
TextScreenblockEntry, u16
}
impl TextScreenblockEntry {
/// Generates a default entry with the specified tile index.
pub const fn from_tile_index(index: u16) -> Self {
TextScreenblockEntry(index & Self::TILE_ID_MASK)
Self::new().with_tile_index(index)
}
bool_bits!(u16, [(10, hflip), (11, vflip)]);
multi_bits!(u16, [(0, 10, tile_id), (12, 4, palbank)]);
multi_bits!(u16, [(0, 10, tile_index), (12, 4, palbank)]);
}
newtype! {