prep for trait code
This commit is contained in:
@@ -24,7 +24,9 @@ pub struct Chip8Computer {
|
||||
pub keypad: Keypad,
|
||||
pub stack: Chip8Stack,
|
||||
pub quirk_mode: QuirkMode,
|
||||
pub target_ips: u16,
|
||||
}
|
||||
|
||||
impl Default for Chip8Computer {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -38,6 +40,7 @@ impl Default for Chip8Computer {
|
||||
keypad: Keypad::default(),
|
||||
stack: Chip8Stack::default(),
|
||||
quirk_mode: QuirkMode::default(),
|
||||
target_ips: 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ impl Default for Chip8ComputerManager {
|
||||
}
|
||||
|
||||
impl Chip8ComputerManager {
|
||||
pub fn target_ips(&self) -> u16 {
|
||||
self.computer.target_ips
|
||||
}
|
||||
pub fn quirks_mode(&self) -> QuirkMode {
|
||||
self.computer.quirk_mode.clone()
|
||||
}
|
||||
@@ -118,7 +121,7 @@ impl Chip8ComputerManager {
|
||||
self.computer.load_bytes_to_memory(0x200, &bytes_to_load);
|
||||
}
|
||||
|
||||
pub fn dump_to_string(&self, dump_type: ManagerDumpables) -> String{
|
||||
pub fn dump_to_string(&self, dump_type: ManagerDumpables) -> String {
|
||||
match dump_type {
|
||||
ManagerDumpables::Video => self.computer.video_memory.format_as_string(),
|
||||
ManagerDumpables::Registers => self.computer.registers.format_as_string(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::chip8::computer::Chip8Computer;
|
||||
use crate::chip8::cpu_states::Chip8CpuStates;
|
||||
use crate::chip8::cpu_states::Chip8CpuStates::WaitingForKey;
|
||||
use crate::chip8::instructions::Chip8CpuInstructions::*;
|
||||
use crate::chip8::quirk_modes::QuirkMode;
|
||||
@@ -11,7 +12,6 @@ use std::ascii::AsciiExt;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::ops::BitAnd;
|
||||
use std::time::Instant;
|
||||
use crate::chip8::cpu_states::Chip8CpuStates;
|
||||
/*
|
||||
nnn or addr - A 12-bit value, the lowest 12 bits of the instruction
|
||||
n or nibble - A 4-bit value, the lowest 4 bits of the instruction
|
||||
@@ -680,6 +680,7 @@ impl Chip8CpuInstructions {
|
||||
_ => DW(addr_param),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute(&self, input: &mut Chip8Computer) -> Chip8Computer {
|
||||
println!("INSTRUCTION {}", self);
|
||||
let start_time = Instant::now();
|
||||
@@ -1088,7 +1089,8 @@ impl Chip8CpuInstructions {
|
||||
.memory
|
||||
.poke(offset + i as u16, input.registers.peek(i));
|
||||
}
|
||||
input.registers.poke_i(offset + 1);
|
||||
println!("OFFSET: {offset:04x} / X : {x:04x}");
|
||||
input.registers.poke_i(offset + *x as u16);
|
||||
}
|
||||
Chip8CpuInstructions::LDRI(x) => {
|
||||
// Read registers V0 through Vx from memory starting at location I.
|
||||
|
||||
Reference in New Issue
Block a user