more stuff
This commit is contained in:
@@ -3,4 +3,10 @@ pub const SIZE_32KB: usize = SIZE_1KB * 32;
|
||||
pub const SIZE_64KB: usize = SIZE_1KB * 64;
|
||||
|
||||
pub const OFFSET_RESET_VECTOR: u16 = 0xfffc;
|
||||
pub const OFFSET_INT_VECTOR: u16 = 0xfffe;
|
||||
pub const OFFSET_INT_VECTOR: u16 = 0xfffe;
|
||||
|
||||
|
||||
pub const VIA6522_ORB: u8 = 0;
|
||||
pub const VIA6522_ORA: u8 = 1;
|
||||
pub const VIA6522_DDRB: u8 = 2;
|
||||
pub const VIA6522_DDRA: u8 = 3;
|
||||
|
||||
+15
-3
@@ -21,7 +21,7 @@ pub struct Mos6502Cpu {
|
||||
/// cpu flags
|
||||
flags: Mos6502Flags,
|
||||
/// program counter
|
||||
pc: u16,
|
||||
pub pc: u16,
|
||||
/// stack offset
|
||||
s: u8,
|
||||
pub microcode_step: u8,
|
||||
@@ -104,14 +104,22 @@ impl Mos6502Cpu {
|
||||
// read the value at 0xfffc 0xfffd for our reset vector.
|
||||
// read the value at 0xfffe 0xffff for our int vector
|
||||
self.pc = self.read_word(&OFFSET_RESET_VECTOR);
|
||||
println!("READ FROM {OFFSET_RESET_VECTOR} AND GOT {}", self.pc);
|
||||
self.iv = self.read_word(&OFFSET_INT_VECTOR);
|
||||
println!("PC and IV are now set from ROM addresses");
|
||||
self.address_bus = self.pc;
|
||||
self.read_signal = true;
|
||||
println!("PC and IV are now set from ROM addresses / AB = {:016b}", self.address_bus);
|
||||
}
|
||||
|
||||
fn read_word(&self, offset: &u16) -> u16 {
|
||||
println!("READING OFFSET 0x{offset:04x} and 0x{:04x}", offset + 1);
|
||||
let low = self.memory[*offset as usize];
|
||||
let high = self.memory[*offset as usize + 1];
|
||||
(high as u16) << 8 | low as u16
|
||||
println!("LOW = 0x{low:02x} HIGH = 0x{high:02x}");
|
||||
let result = (high as u16) << 8 | low as u16;
|
||||
// println!("MEMORY: {:?}", self.memory);
|
||||
println!("READ {result:04x}");
|
||||
result
|
||||
}
|
||||
|
||||
pub fn peek_flag(&self, flag_to_read: Mos6502Flag) -> bool {
|
||||
@@ -513,6 +521,10 @@ impl Mos6502Cpu {
|
||||
self.pc, self.a, self.x, self.y, self.address_bus, self.data_bus, self.microcode_step, self.flags.dump());
|
||||
}
|
||||
|
||||
/// dump_data
|
||||
///
|
||||
/// returns
|
||||
/// PC, A, X, Y, Address_Bus, Data_Bus, Microcode_Step
|
||||
pub fn dump_data(&self) -> ( u16, u8, u8, u8, u16, u8, u8) {
|
||||
(self.pc, self.a, self.x, self.y, self.address_bus, self.data_bus, self.microcode_step)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod default;
|
||||
mod rom_chip;
|
||||
|
||||
use std::io::Read;
|
||||
use crate::constants::constants_system::SIZE_32KB;
|
||||
use crate::periph::rom_chip::RomChip;
|
||||
|
||||
@@ -15,8 +16,10 @@ pub struct At28C256 {
|
||||
}
|
||||
|
||||
impl At28C256 {
|
||||
pub fn program(&mut self, new_program: &[u8; 32768]) {
|
||||
self.data= new_program.into();
|
||||
pub fn program(&mut self, new_program: &[u8; SIZE_32KB]) {
|
||||
// panic!("FAIL. Cant program the chip.");
|
||||
// println!("PROGRAMMING {:?}", new_program);
|
||||
self.data = Box::new(*new_program);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user