attempt chatgpt emulator for display
This commit is contained in:
parent
8509b20109
commit
e4405cc225
@ -13,7 +13,8 @@ pub enum MatrixEntryMode {
|
|||||||
pub struct DisplayMatrix {
|
pub struct DisplayMatrix {
|
||||||
width: f32,
|
width: f32,
|
||||||
height: f32,
|
height: f32,
|
||||||
text_buffer: String,
|
text_buffer: [u8; 80],
|
||||||
|
cgram: [u8; 64],
|
||||||
data_bus: DataBus,
|
data_bus: DataBus,
|
||||||
rs: bool,
|
rs: bool,
|
||||||
rw: bool,
|
rw: bool,
|
||||||
@ -21,7 +22,7 @@ pub struct DisplayMatrix {
|
|||||||
busy: bool,
|
busy: bool,
|
||||||
entry_mode: MatrixEntryMode,
|
entry_mode: MatrixEntryMode,
|
||||||
cursor: bool,
|
cursor: bool,
|
||||||
on: bool,
|
display_on: bool,
|
||||||
blink: bool,
|
blink: bool,
|
||||||
cursor_shift: bool,
|
cursor_shift: bool,
|
||||||
display_shift: bool,
|
display_shift: bool,
|
||||||
@ -69,7 +70,7 @@ impl DisplayMatrix {
|
|||||||
cursor_position: 0x00,
|
cursor_position: 0x00,
|
||||||
busy: false,
|
busy: false,
|
||||||
entry_mode: MatrixEntryMode::InsertShift,
|
entry_mode: MatrixEntryMode::InsertShift,
|
||||||
on: false,
|
display_on: false,
|
||||||
cursor: false,
|
cursor: false,
|
||||||
blink: false,
|
blink: false,
|
||||||
cursor_shift: false,
|
cursor_shift: false,
|
||||||
@ -122,7 +123,7 @@ impl DisplayMatrix {
|
|||||||
}
|
}
|
||||||
0b0000_1000..=0b0000_1111 => {
|
0b0000_1000..=0b0000_1111 => {
|
||||||
// display control
|
// 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.cursor = self.data_bus.data & 0b10 == 0b10;
|
||||||
self.blink = self.data_bus.data & 0b1 == 0b1;
|
self.blink = self.data_bus.data & 0b1 == 0b1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use log::trace;
|
||||||
use crate::address_mode::AddressMode;
|
use crate::address_mode::AddressMode;
|
||||||
use crate::constants::constants_isa_op::ISA_OP_NOP;
|
use crate::constants::constants_isa_op::ISA_OP_NOP;
|
||||||
use crate::instruction::Instruction;
|
use crate::instruction::Instruction;
|
||||||
@ -218,7 +219,7 @@ impl Mos6502Cpu {
|
|||||||
}
|
}
|
||||||
_ => { 0x00 }
|
_ => { 0x00 }
|
||||||
};
|
};
|
||||||
println!("READING FROM MEMORY AT 0x{offset:04x}");
|
trace!("READING FROM MEMORY AT 0x{offset:04x}");
|
||||||
self.memory[offset as usize]
|
self.memory[offset as usize]
|
||||||
// self.peek(offset);
|
// self.peek(offset);
|
||||||
}
|
}
|
||||||
@ -299,7 +300,10 @@ impl Mos6502Cpu {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Operation::JSR => {}
|
Operation::JSR => {
|
||||||
|
// push pc to stack.
|
||||||
|
// jump to the subroutine.
|
||||||
|
}
|
||||||
Operation::LDA => {
|
Operation::LDA => {
|
||||||
match self.oi.mode {
|
match self.oi.mode {
|
||||||
AddressMode::Immediate => {
|
AddressMode::Immediate => {
|
||||||
@ -329,7 +333,6 @@ impl Mos6502Cpu {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddressMode::ZeroPageY => {}
|
|
||||||
AddressMode::Absolute => {
|
AddressMode::Absolute => {
|
||||||
if let Operand::Word(offset) = self.ir.operand {
|
if let Operand::Word(offset) = self.ir.operand {
|
||||||
println!("Loading from absolute address 0x{offset:04x}");
|
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];
|
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::Indirect => {}
|
||||||
AddressMode::IndirectX => {}
|
AddressMode::IndirectX => {}
|
||||||
AddressMode::IndirectY => {}
|
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::IndirectX => {}
|
||||||
AddressMode::IndirectY => {}
|
AddressMode::IndirectY => {}
|
||||||
_ => {
|
_ => {
|
||||||
@ -600,7 +616,22 @@ mod test {
|
|||||||
cpu.memory[0xbef0] = 0xab;
|
cpu.memory[0xbef0] = 0xab;
|
||||||
cpu.pc = 0x6000;
|
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);
|
assert_eq!(cpu.a, 0xab);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user