mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-23 10:51:30 +11:00
jump to 120
Picking this because it makes the `hello_magic.rs` lines all stay on one line.
This commit is contained in:
parent
b67bdc80a1
commit
2929076e55
|
@ -10,15 +10,9 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|||
fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
unsafe {
|
||||
(0x400_0000 as *mut u16).write_volatile(0x0403);
|
||||
(0x600_0000 as *mut u16)
|
||||
.offset(120 + 80 * 240)
|
||||
.write_volatile(0x001F);
|
||||
(0x600_0000 as *mut u16)
|
||||
.offset(136 + 80 * 240)
|
||||
.write_volatile(0x03E0);
|
||||
(0x600_0000 as *mut u16)
|
||||
.offset(120 + 96 * 240)
|
||||
.write_volatile(0x7C00);
|
||||
(0x600_0000 as *mut u16).offset(120 + 80 * 240).write_volatile(0x001F);
|
||||
(0x600_0000 as *mut u16).offset(136 + 80 * 240).write_volatile(0x03E0);
|
||||
(0x600_0000 as *mut u16).offset(120 + 96 * 240).write_volatile(0x7C00);
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@ merge_imports = true
|
|||
reorder_imports = true
|
||||
use_try_shorthand = true
|
||||
tab_spaces = 2
|
||||
max_width = 100
|
||||
max_width = 120
|
||||
color = "Never"
|
||||
|
|
|
@ -60,8 +60,7 @@ pub const SOUND2CNT_L: VolAddress<DutyLenEnvelopeSetting> = unsafe { VolAddress:
|
|||
pub const SOUND2CNT_H: VolAddress<FrequencyControlSetting> = unsafe { VolAddress::new(0x400_006C) };
|
||||
|
||||
/// Sound Channel 3 Stop/Wave RAM select (`NR23`, `NR24`). Read/Write.
|
||||
pub const SOUND3CNT_L: VolAddress<StopWaveRAMSelectSetting> =
|
||||
unsafe { VolAddress::new(0x400_0070) };
|
||||
pub const SOUND3CNT_L: VolAddress<StopWaveRAMSelectSetting> = unsafe { VolAddress::new(0x400_0070) };
|
||||
|
||||
newtype! {
|
||||
StopWaveRAMSelectSetting, u16
|
||||
|
@ -159,8 +158,7 @@ pub const FIFO_B_L: VolAddress<u16> = unsafe { VolAddress::new(0x400_00A4) };
|
|||
pub const FIFO_B_H: VolAddress<u16> = unsafe { VolAddress::new(0x400_00A6) };
|
||||
|
||||
/// Channel L/R Volume/Enable (`NR50`, `NR51`). Read/Write.
|
||||
pub const SOUNDCNT_L: VolAddress<NonWaveVolumeEnableSetting> =
|
||||
unsafe { VolAddress::new(0x400_0080) };
|
||||
pub const SOUNDCNT_L: VolAddress<NonWaveVolumeEnableSetting> = unsafe { VolAddress::new(0x400_0080) };
|
||||
|
||||
newtype! {
|
||||
NonWaveVolumeEnableSetting, u16
|
||||
|
|
|
@ -157,11 +157,7 @@ pub fn read_obj_attributes(slot: usize) -> Option<ObjectAttributes> {
|
|||
let attr0 = va_u16.cast::<OBJAttr0>().read();
|
||||
let attr1 = va_u16.offset(1).cast::<OBJAttr1>().read();
|
||||
let attr2 = va_u16.offset(2).cast::<OBJAttr2>().read();
|
||||
ObjectAttributes {
|
||||
attr0,
|
||||
attr1,
|
||||
attr2,
|
||||
}
|
||||
ObjectAttributes { attr0, attr1, attr2 }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ pub const VRAM_BASE_USIZE: usize = 0x600_0000;
|
|||
pub const CHAR_BASE_BLOCKS: VolBlock<[u8; 0x4000], U6> = unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
|
||||
/// The screen entry base blocks.
|
||||
pub const SCREEN_BASE_BLOCKS: VolBlock<[u8; 0x800], U32> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
pub const SCREEN_BASE_BLOCKS: VolBlock<[u8; 0x800], U32> = unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
|
||||
newtype! {
|
||||
/// An 8x8 tile with 4bpp, packed as `u32` values for proper alignment.
|
||||
|
|
|
@ -30,8 +30,7 @@ impl Mode3 {
|
|||
///
|
||||
/// Use `col + row * SCREEN_WIDTH` to get the address of an individual pixel,
|
||||
/// or use the helpers provided in this module.
|
||||
pub const VRAM: VolBlock<Color, <U256 as Mul<U160>>::Output> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
pub const VRAM: VolBlock<Color, <U256 as Mul<U160>>::Output> = unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
|
||||
/// private iterator over the pixels, two at a time
|
||||
const VRAM_BULK: VolBlock<u32, <<U256 as Mul<U160>>::Output as Div<U2>>::Output> =
|
||||
|
@ -43,9 +42,7 @@ impl Mode3 {
|
|||
///
|
||||
/// Gives `None` if out of bounds.
|
||||
pub fn read_pixel(col: usize, row: usize) -> Option<Color> {
|
||||
Self::VRAM
|
||||
.get(col + row * Self::SCREEN_WIDTH)
|
||||
.map(VolAddress::read)
|
||||
Self::VRAM.get(col + row * Self::SCREEN_WIDTH).map(VolAddress::read)
|
||||
}
|
||||
|
||||
/// Writes the pixel at the given (col,row).
|
||||
|
@ -54,9 +51,7 @@ impl Mode3 {
|
|||
///
|
||||
/// Gives `None` if out of bounds.
|
||||
pub fn write_pixel(col: usize, row: usize, color: Color) -> Option<()> {
|
||||
Self::VRAM
|
||||
.get(col + row * Self::SCREEN_WIDTH)
|
||||
.map(|va| va.write(color))
|
||||
Self::VRAM.get(col + row * Self::SCREEN_WIDTH).map(|va| va.write(color))
|
||||
}
|
||||
|
||||
/// Clears the whole screen to the desired color.
|
||||
|
@ -114,12 +109,10 @@ impl Mode4 {
|
|||
const SCREEN_U32_COUNT: usize = Self::SCREEN_PIXEL_COUNT / 4;
|
||||
|
||||
// TODO: newtype this?
|
||||
const PAGE0_BLOCK8: VolBlock<u8, <U256 as Mul<U160>>::Output> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
const PAGE0_BLOCK8: VolBlock<u8, <U256 as Mul<U160>>::Output> = unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
|
||||
// TODO: newtype this?
|
||||
const PAGE1_BLOCK8: VolBlock<u8, <U256 as Mul<U160>>::Output> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE + 0xA000) };
|
||||
const PAGE1_BLOCK8: VolBlock<u8, <U256 as Mul<U160>>::Output> = unsafe { VolBlock::new(VRAM_BASE_USIZE + 0xA000) };
|
||||
|
||||
// TODO: newtype this?
|
||||
const PAGE0_BLOCK16: VolBlock<u16, <<U256 as Mul<U160>>::Output as Div<U2>>::Output> =
|
||||
|
@ -193,9 +186,7 @@ impl Mode4 {
|
|||
/// The page is imagined to be a series of `u16` values rather than `u8`
|
||||
/// values, allowing you to write two palette entries side by side as a single
|
||||
/// write operation.
|
||||
pub fn write_wide_pixel(
|
||||
page1: bool, wide_col: usize, row: usize, wide_pal8bpp: u16,
|
||||
) -> Option<()> {
|
||||
pub fn write_wide_pixel(page1: bool, wide_col: usize, row: usize, wide_pal8bpp: u16) -> Option<()> {
|
||||
if wide_col < Self::SCREEN_WIDTH / 2 && row < Self::SCREEN_HEIGHT {
|
||||
let wide_index = wide_col + row * Self::SCREEN_WIDTH / 2;
|
||||
let address: VolAddress<u16> = if page1 {
|
||||
|
@ -213,13 +204,7 @@ impl Mode4 {
|
|||
pub fn clear_page_to(page1: bool, pal8bpp: u8) {
|
||||
let pal8bpp_32 = pal8bpp as u32;
|
||||
let bulk_color = (pal8bpp_32 << 24) | (pal8bpp_32 << 16) | (pal8bpp_32 << 8) | pal8bpp_32;
|
||||
for va in (if page1 {
|
||||
Self::PAGE1_BULK32
|
||||
} else {
|
||||
Self::PAGE0_BULK32
|
||||
})
|
||||
.iter()
|
||||
{
|
||||
for va in (if page1 { Self::PAGE1_BULK32 } else { Self::PAGE0_BULK32 }).iter() {
|
||||
va.write(bulk_color)
|
||||
}
|
||||
}
|
||||
|
@ -267,12 +252,10 @@ impl Mode5 {
|
|||
const SCREEN_U32_COUNT: usize = Self::SCREEN_PIXEL_COUNT / 2;
|
||||
|
||||
// TODO: newtype this?
|
||||
const PAGE0_BLOCK: VolBlock<Color, <U160 as Mul<U128>>::Output> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
const PAGE0_BLOCK: VolBlock<Color, <U160 as Mul<U128>>::Output> = unsafe { VolBlock::new(VRAM_BASE_USIZE) };
|
||||
|
||||
// TODO: newtype this?
|
||||
const PAGE1_BLOCK: VolBlock<Color, <U160 as Mul<U128>>::Output> =
|
||||
unsafe { VolBlock::new(VRAM_BASE_USIZE + 0xA000) };
|
||||
const PAGE1_BLOCK: VolBlock<Color, <U160 as Mul<U128>>::Output> = unsafe { VolBlock::new(VRAM_BASE_USIZE + 0xA000) };
|
||||
|
||||
/// private iterator over the page0 pixels, four at a time
|
||||
const PAGE0_BULK32: VolBlock<u32, <<U160 as Mul<U128>>::Output as Div<U2>>::Output> =
|
||||
|
@ -320,13 +303,7 @@ impl Mode5 {
|
|||
pub fn clear_page_to(page1: bool, color: Color) {
|
||||
let color32 = color.0 as u32;
|
||||
let bulk_color = color32 << 16 | color32;
|
||||
for va in (if page1 {
|
||||
Self::PAGE1_BULK32
|
||||
} else {
|
||||
Self::PAGE0_BULK32
|
||||
})
|
||||
.iter()
|
||||
{
|
||||
for va in (if page1 { Self::PAGE1_BULK32 } else { Self::PAGE0_BULK32 }).iter() {
|
||||
va.write(bulk_color)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue