This commit is contained in:
2024-09-11 13:39:20 -04:00
parent 1a59524f02
commit 95d4e6c32c
10 changed files with 132 additions and 51 deletions
+19 -7
View File
@@ -178,18 +178,30 @@ struct Chip8Cpu {}
struct Chip8System {
registers: Chip8Registers,
screen: Chip8Display,
system_memory: [u8; 2048]
}
impl Chip8System {
pub fn tick(self: Self) {
pub fn tick(mut self) {
println!(" Ticking Chip8System");
// Fetch...
// ...Decode...
// ...Execute
let next_instruction = self.system_memory[self.registers.ProgramCounter as usize] as u16;
println!("READ INSTRUCTION {next_instruction}");
self.registers.ProgramCounter += 0x2;
&self.delay_timer_tick();
&self.sound_timer_tick();
// self.screen.tick();
}
fn delay_timer_tick(&mut self) {
self.registers.DelayTimer = self.registers.DelayTimer - 1;
}
fn sound_timer_tick(&mut self) {
self.registers.SoundTimer = self.registers.SoundTimer - 1;
// self.registers.tick();
self.screen.tick();
}
}
+2 -2
View File
@@ -15,13 +15,13 @@ impl Chip8Display {
// ...64 columns
for index_col in 0..=64 {
let offset = (index_row * 64) + index_col;
if (to_render.memory[offset]) {
if to_render.memory[offset] {
print!("*")
} else {
print!(" ")
};
}
println!("");
println!();
}
}
}