Fix wrong use of rust ranges in the lcd.rs module
Former-commit-id: 73d588299baed7f5206b904f40ecf4a4e5283ef6
This commit is contained in:
parent
a4925b7233
commit
9d8272b895
10
src/lcd.rs
10
src/lcd.rs
|
@ -33,7 +33,7 @@ pub struct DisplayControl {
|
||||||
impl From<u16> for DisplayControl {
|
impl From<u16> for DisplayControl {
|
||||||
fn from(v: u16) -> Self {
|
fn from(v: u16) -> Self {
|
||||||
DisplayControl {
|
DisplayControl {
|
||||||
bg_mode: BGMode::from_u8(v.bit_range(0..2) as u8).unwrap(),
|
bg_mode: BGMode::from_u8(v.bit_range(0..3) as u8).unwrap(),
|
||||||
// bit 3 is unused
|
// bit 3 is unused
|
||||||
display_frame: v.bit(4) as usize,
|
display_frame: v.bit(4) as usize,
|
||||||
hblank_interval_free: v.bit(5),
|
hblank_interval_free: v.bit(5),
|
||||||
|
@ -70,7 +70,7 @@ impl From<u16> for DisplayStatus {
|
||||||
hblank_irq_enable: v.bit(4),
|
hblank_irq_enable: v.bit(4),
|
||||||
vcount_irq_enable: v.bit(5),
|
vcount_irq_enable: v.bit(5),
|
||||||
// bits 6-7 are unused in GBA
|
// bits 6-7 are unused in GBA
|
||||||
vcount_setting: v.bit_range(8..15) as u8,
|
vcount_setting: v.bit_range(8..16) as u8,
|
||||||
raw_value: v,
|
raw_value: v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ pub struct BgControl {
|
||||||
|
|
||||||
impl From<u16> for BgControl {
|
impl From<u16> for BgControl {
|
||||||
fn from(v: u16) -> Self {
|
fn from(v: u16) -> Self {
|
||||||
let (width, height) = match v.bit_range(14..15) {
|
let (width, height) = match v.bit_range(14..16) {
|
||||||
0 => (256, 256),
|
0 => (256, 256),
|
||||||
1 => (512, 256),
|
1 => (512, 256),
|
||||||
2 => (256, 512),
|
2 => (256, 512),
|
||||||
|
@ -98,11 +98,11 @@ impl From<u16> for BgControl {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
BgControl {
|
BgControl {
|
||||||
bg_priority: v.bit_range(0..1) as u8,
|
bg_priority: v.bit_range(0..2) as u8,
|
||||||
character_base_block: v.bit_range(2..3) as u8,
|
character_base_block: v.bit_range(2..3) as u8,
|
||||||
moasic: v.bit(6),
|
moasic: v.bit(6),
|
||||||
colors_palettes: v.bit(7), // 0=16/16, 1=256/1)
|
colors_palettes: v.bit(7), // 0=16/16, 1=256/1)
|
||||||
screen_base_block: v.bit_range(8..12) as u8,
|
screen_base_block: v.bit_range(8..13) as u8,
|
||||||
wraparound: v.bit(13),
|
wraparound: v.bit(13),
|
||||||
screen_width: width,
|
screen_width: width,
|
||||||
screen_height: height,
|
screen_height: height,
|
||||||
|
|
Reference in a new issue