fix: improve types of heap allocated arrays
This commit is contained in:
parent
528b88eeb7
commit
06821bf880
|
@ -30,7 +30,7 @@ impl Cartridge {
|
|||
MBCKind::None => todo!("Handle no MBC Situation"),
|
||||
MBCKind::MBC1 => MBC1 {
|
||||
ram_size,
|
||||
ram: vec![0; ram_byte_count as usize].into_boxed_slice(),
|
||||
ram: vec![0; ram_byte_count as usize],
|
||||
bank_count,
|
||||
..Default::default()
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ struct MBC1 {
|
|||
current_ram_bank: u8, // 2-bit number
|
||||
mode: bool,
|
||||
ram_size: RamSize,
|
||||
ram: Box<[u8]>,
|
||||
ram: Vec<u8>,
|
||||
bank_count: BankCount,
|
||||
ram_enabled: bool,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct HighRam {
|
||||
buf: Box<[u8]>,
|
||||
buf: Box<[u8; 127]>,
|
||||
}
|
||||
|
||||
impl Default for HighRam {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
buf: vec![0u8; 128].into_boxed_slice(),
|
||||
buf: Box::new([0u8; 127]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ pub struct Ppu {
|
|||
pub lcd_control: LCDControl,
|
||||
pub monochrome: Monochrome,
|
||||
pub pos: ScreenPosition,
|
||||
pub vram: Box<[u8]>,
|
||||
pub oam: Box<[u8]>,
|
||||
pub vram: Box<[u8; 8192]>,
|
||||
pub oam: Box<[u8; 160]>,
|
||||
frame_buf: [u8; GB_WIDTH * GB_HEIGHT * 4],
|
||||
pub stat: LCDStatus,
|
||||
cycles: Cycles,
|
||||
|
@ -81,8 +81,8 @@ impl Default for Ppu {
|
|||
monochrome: Default::default(),
|
||||
pos: Default::default(),
|
||||
stat: Default::default(),
|
||||
vram: vec![0; 8192].into_boxed_slice(),
|
||||
oam: vec![0; 160].into_boxed_slice(),
|
||||
vram: Box::new([0u8; 8192]),
|
||||
oam: Box::new([0u8; 160]),
|
||||
cycles: 0.into(),
|
||||
frame_buf: [0; GB_WIDTH * GB_HEIGHT * 4],
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct WorkRam {
|
||||
bank: Box<[u8]>,
|
||||
bank: Box<[u8; 4096]>,
|
||||
}
|
||||
|
||||
impl WorkRam {
|
||||
|
@ -16,7 +16,7 @@ impl WorkRam {
|
|||
impl Default for WorkRam {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
bank: vec![0u8; 4096].into_boxed_slice(),
|
||||
bank: Box::new([0u8; 4096]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,14 +35,14 @@ pub enum BankNumber {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct VariableWorkRam {
|
||||
current: BankNumber,
|
||||
bank_n: Box<[[u8; 4096]]>, // 4K for Variable amount of Banks (Banks 1 -> 7) in Game Boy Colour
|
||||
bank_n: Box<[[u8; 4096]; 7]>, // 4K for Variable amount of Banks (Banks 1 -> 7) in Game Boy Colour
|
||||
}
|
||||
|
||||
impl Default for VariableWorkRam {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
current: BankNumber::One,
|
||||
bank_n: vec![[0u8; 4096]; 7].into_boxed_slice(),
|
||||
bank_n: Box::new([[0u8; 4096]; 7]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue