telnet now will load the IBM logo and run through it.

This commit is contained in:
2025-05-22 14:15:38 -04:00
parent 8c22cf9308
commit c9c9cf67da
3 changed files with 31 additions and 2 deletions
+25
View File
@@ -1,3 +1,6 @@
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::{Path, PathBuf};
use crate::chip8::computer::Chip8Computer;
use crate::chip8::cpu_states::Chip8CpuStates;
use crate::chip8::cpu_states::Chip8CpuStates::WaitingForInstruction;
@@ -142,4 +145,26 @@ impl Chip8ComputerManager {
ManagerDumpables::Keyboard => self.computer.keypad.format_as_string(),
}
}
pub fn load_new_program_from_disk_to_system_memory(&mut self, file_to_load: &Path) {
println!("ComputerManager: Preparing to load {}", file_to_load.display());
// load the file into bytes...
let file = File::open(file_to_load).unwrap();
let mut reader = BufReader::new(file);
let mut chunks = Vec::new();
loop {
let mut buffer = vec![0u8; 1];
let bytes_read = reader.read(&mut buffer).unwrap_or(0);
if bytes_read == 0 {
break;
}
buffer.truncate(bytes_read);
chunks.push(buffer[0]);
}
self.load_new_program_to_system_memory(chunks);
// ...then use the existing method
self.core_should_run = true;
}
}