removes sccache
updates display of ben eater pc doesnt blow up when creating a rom chip anymore doesnt blow up when creating a pc anymore
This commit is contained in:
+25
-10
@@ -1,4 +1,4 @@
|
||||
use crate::mos6502cpu::SIZE_32KB;
|
||||
use crate::mos6502cpu::{SIZE_32KB, SIZE_64KB};
|
||||
use crate::periph::rom_chip::RomChip;
|
||||
|
||||
/// At28C256
|
||||
@@ -8,24 +8,37 @@ use crate::periph::rom_chip::RomChip;
|
||||
/// 256kbit storage
|
||||
/// 32kbyte storage
|
||||
pub struct At28C256 {
|
||||
data: [u8; SIZE_32KB]
|
||||
data: Box<[u8; SIZE_32KB]>,
|
||||
}
|
||||
|
||||
impl Default for At28C256 {
|
||||
fn default() -> Self {
|
||||
let vec = vec![0x00; SIZE_32KB];
|
||||
let boxed_slice: Box<[u8]> = vec.into_boxed_slice();
|
||||
let boxed_array: Box<[u8; SIZE_32KB]> = boxed_slice.try_into().expect("Failed to convert Vec to boxed array");
|
||||
At28C256 {
|
||||
data: boxed_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RomChip for At28C256 {
|
||||
|
||||
fn read(&self, offset: &u16) -> u8 {
|
||||
self.data[*offset as usize]
|
||||
}
|
||||
|
||||
fn program(new_data: &[u8; SIZE_32KB]) -> Self {
|
||||
fn program(new_data: Box<[u8; 33554432]>) -> Box<At28C256> {
|
||||
println!("Writing new chip.");
|
||||
At28C256 {
|
||||
data: *new_data
|
||||
}
|
||||
let mut working = At28C256::default();
|
||||
working.data = Box::new(*new_data);
|
||||
working.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::mos6502cpu::SIZE_1KB;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
@@ -36,16 +49,18 @@ mod test {
|
||||
#[test]
|
||||
fn programmed_data_reads_back_same() {
|
||||
print!("Starting test...");
|
||||
let data_to_write = [0xea; SIZE_32KB];
|
||||
let mut data = At28C256::default();
|
||||
for i in 0..SIZE_32KB {
|
||||
data.data[i] = 0xea;
|
||||
}
|
||||
print!("allocated data for rom...");
|
||||
let chip: At28C256 = At28C256::program(&data_to_write);
|
||||
println!("programmed chip...");
|
||||
print!("testing");
|
||||
for offset in 0..SIZE_32KB {
|
||||
if offset.is_multiple_of(1000) {
|
||||
if offset.is_multiple_of(SIZE_1KB) {
|
||||
print!(".");
|
||||
};
|
||||
assert_eq!(0xea, chip.read(&(offset as u16)));
|
||||
assert_eq!(0xea, data.read(&(offset as u16)));
|
||||
}
|
||||
println!("passed!");
|
||||
}
|
||||
|
||||
@@ -8,10 +8,9 @@ pub trait RomChip {
|
||||
/// Program
|
||||
///
|
||||
/// Replaces all data in the ROM chip
|
||||
fn program(new_data: &[u8; SIZE_32KB]) -> Self;
|
||||
fn program(new_data: Box<[u8; SIZE_32KB]>) -> Box<Self>;
|
||||
}
|
||||
|
||||
pub trait RamChip: RomChip {
|
||||
fn write(&mut self, offset: &u16, value: &u8);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user