diff --git a/beneater/src/parts/display_matrix.rs b/beneater/src/parts/display_matrix.rs index 66a1bb0..672855e 100644 --- a/beneater/src/parts/display_matrix.rs +++ b/beneater/src/parts/display_matrix.rs @@ -13,7 +13,8 @@ pub enum MatrixEntryMode { pub struct DisplayMatrix { width: f32, height: f32, - text_buffer: String, + text_buffer: [u8; 80], + cgram: [u8; 64], data_bus: DataBus, rs: bool, rw: bool, @@ -21,7 +22,7 @@ pub struct DisplayMatrix { busy: bool, entry_mode: MatrixEntryMode, cursor: bool, - on: bool, + display_on: bool, blink: bool, cursor_shift: bool, display_shift: bool, @@ -69,7 +70,7 @@ impl DisplayMatrix { cursor_position: 0x00, busy: false, entry_mode: MatrixEntryMode::InsertShift, - on: false, + display_on: false, cursor: false, blink: false, cursor_shift: false, @@ -122,7 +123,7 @@ impl DisplayMatrix { } 0b0000_1000..=0b0000_1111 => { // display control - self.on = self.data_bus.data & 0b100 == 0b100; + self.display_on = self.data_bus.data & 0b100 == 0b100; self.cursor = self.data_bus.data & 0b10 == 0b10; self.blink = self.data_bus.data & 0b1 == 0b1; } diff --git a/core/src/mos6502cpu.rs b/core/src/mos6502cpu.rs index 7be3c70..90407e0 100644 --- a/core/src/mos6502cpu.rs +++ b/core/src/mos6502cpu.rs @@ -1,3 +1,4 @@ +use log::trace; use crate::address_mode::AddressMode; use crate::constants::constants_isa_op::ISA_OP_NOP; use crate::instruction::Instruction; @@ -218,7 +219,7 @@ impl Mos6502Cpu { } _ => { 0x00 } }; - println!("READING FROM MEMORY AT 0x{offset:04x}"); + trace!("READING FROM MEMORY AT 0x{offset:04x}"); self.memory[offset as usize] // self.peek(offset); } @@ -299,7 +300,10 @@ impl Mos6502Cpu { _ => {} } } - Operation::JSR => {} + Operation::JSR => { + // push pc to stack. + // jump to the subroutine. + } Operation::LDA => { match self.oi.mode { AddressMode::Immediate => { @@ -329,7 +333,6 @@ impl Mos6502Cpu { _ => {} } } - AddressMode::ZeroPageY => {} AddressMode::Absolute => { if let Operand::Word(offset) = self.ir.operand { println!("Loading from absolute address 0x{offset:04x}"); @@ -342,7 +345,11 @@ impl Mos6502Cpu { self.a = self.memory[(offset + self.x as u16) as usize]; } } - AddressMode::AbsoluteY => {} + AddressMode::AbsoluteY => { + if let Operand::Word(offset) = self.ir.operand { + self.a = self.memory[(offset + self.y as u16) as usize]; + } + } AddressMode::Indirect => {} AddressMode::IndirectX => {} AddressMode::IndirectY => {} @@ -430,7 +437,16 @@ impl Mos6502Cpu { } } } - AddressMode::AbsoluteY => {} + AddressMode::AbsoluteY => { + match self.ir.operand { + Operand::Word(offset) => { + self.memory[(offset + self.y as u16) as usize] = self.a; + } + _ => { + // Invalid Parameter + } + } + } AddressMode::IndirectX => {} AddressMode::IndirectY => {} _ => { @@ -600,7 +616,22 @@ mod test { cpu.memory[0xbef0] = 0xab; cpu.pc = 0x6000; - for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABS) { cpu.tick(); } + for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABSX) { cpu.tick(); } + + assert_eq!(cpu.a, 0xab); + } + + #[test] + fn lda_absolutey() { + let mut cpu = Mos6502Cpu::default(); + cpu.memory[0x6000] = ISA_OP_LDA_ABSY; + cpu.memory[0x6001] = 0xef; + cpu.memory[0x6002] = 0xbe; + cpu.poke_y(0x01); + cpu.memory[0xbef0] = 0xab; + cpu.pc = 0x6000; + + for _ in 0..=INSTRUCTION_CYCLES(ISA_OP_LDA_ABSY) { cpu.tick(); } assert_eq!(cpu.a, 0xab); }