telnetd implementing more stuff.

This commit is contained in:
2025-05-22 13:14:33 -04:00
parent 67ca71ccb7
commit 8c22cf9308
34 changed files with 931 additions and 16 deletions
+5
View File
@@ -92,6 +92,11 @@ impl Chip8Computer {
self.registers.set_pc(offset);
}
pub fn execute_instruction(&mut self, instruction_to_execute: Chip8CpuInstructions) {
//
}
pub fn step_system(&mut self) -> &mut Chip8Computer {
println!("Stepping System 1 Step");
// read the next instruction
+18 -1
View File
@@ -13,7 +13,7 @@ pub enum ManagerDumpables {
}
pub struct Chip8ComputerManager {
core_should_run: bool,
pub core_should_run: bool,
one_step: bool,
core_last_cycle_start: Instant,
computer: Chip8Computer,
@@ -31,6 +31,23 @@ impl Default for Chip8ComputerManager {
}
impl Chip8ComputerManager {
/// Builds a string that can be displayed at a console giving the user
/// an idea of the internal state of the Chip-8 Computer
pub fn status_as_string(&self) -> String {
// build a string
format!("Should Run: {}\nLast Cycle Start: {:?}\nNum Cycles: {}\nRegisters\n{}\nTimers: {}/{}\nKeypad: \n{}\nVideo:\n{}",
self.core_should_run,
self.core_last_cycle_start,
self.computer.num_cycles,
self.computer.registers.format_as_string(),
self.computer.delay_timer.current(),
self.computer.sound_timer.current(),
self.computer.keypad.format_as_string(),
self.computer.video_memory.format_as_string()
)
}
pub fn quirks_mode(&self) -> QuirkMode {
self.computer.quirk_mode.clone()
}
+4 -5
View File
@@ -7,7 +7,6 @@ use crate::constants::*;
use log::debug;
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::ascii::AsciiExt;
use std::fmt::{Debug, Display, Formatter};
use std::ops::BitAnd;
use std::time::Instant;
@@ -760,7 +759,7 @@ impl Chip8CpuInstructions {
debug!("OrVxVy [0x{x:1x}] [0x{y:1x}]")
}
// 0x8xy2 Set Vx = Vx AND Vy
Chip8CpuInstructions::AND(x, y) => {
AND(x, y) => {
let lhs_16 = input.registers.peek(*x) as u16;
let rhs_16 = input.registers.peek(*y) as u16;
// reset of VF quirk
@@ -768,7 +767,7 @@ impl Chip8CpuInstructions {
input.registers.poke(*x, (lhs_16 & rhs_16) as u8);
}
// 0x8xy3 Set Vx = Vx XOR Vy
Chip8CpuInstructions::ORY(x, y) => {
ORY(x, y) => {
let lhs_16 = input.registers.peek(*x) as u16;
let rhs_16 = input.registers.peek(*y) as u16;
// reset of VF quirk
@@ -776,7 +775,7 @@ impl Chip8CpuInstructions {
input.registers.poke(*x, (lhs_16 ^ rhs_16) as u8);
}
// 0x8xy4 Set Vx = Vx + Vy (SET VF on Carry)
Chip8CpuInstructions::ADDR(x, y) => {
ADDR(x, y) => {
let lhs = input.registers.peek(*x) as i16;
let rhs = input.registers.peek(*y) as i16;
let working = lhs + rhs;
@@ -788,7 +787,7 @@ impl Chip8CpuInstructions {
input.registers.poke(0x0f, 0x00);
}
}
Chip8CpuInstructions::SUB(x, y) => {
SUB(x, y) => {
// 8xy5 - SUB Vx, Vy
// Set Vx = Vx - Vy, set VF = NOT borrow.
//
-1
View File
@@ -4,7 +4,6 @@ use crate::constants::*;
use serde::Deserialize;
use serde::Serialize;
use super::quirk_modes;
use super::quirk_modes::QuirkMode;
#[derive(Clone, Serialize, Deserialize, Debug)]
+3 -3
View File
@@ -49,7 +49,7 @@ impl Chip8Video {
LowRes => CHIP8_VIDEO_MEMORY,
HighRes => SCHIP_VIDE_MEMORY,
};
for i in 0..num_loops {
for _ in 0..num_loops {
self.memory.push(false);
}
}
@@ -115,7 +115,7 @@ impl Chip8Video {
pub fn format_as_string(&self) -> String {
let (width, height) = self.get_resolution();
println!("FORMATTING {width}x{height}");
// println!("FORMATTING {width}x{height}");
let mut output = String::new();
for row in 0..height {
for column in 0..width {
@@ -177,7 +177,7 @@ impl Chip8Video {
for current_row in 0..height {
let row_offset = current_row * width;
for current_column in (0..width - 4) {
for current_column in 0..width - 4 {
let target: usize = (row_offset + current_column) as usize;
let source: usize = target + 4;
self.memory[target] = self.memory[source];
+23
View File
@@ -0,0 +1,23 @@
use crate::chip8::instructions::Chip8CpuInstructions;
use crate::chip8::registers::Chip8Registers;
use crate::chip8_2::instructions::instruction_trait::InstructionTrait;
struct Add {
pub relative: bool,
pub source: Option<Chip8Registers>,
pub destination: Chip8Registers,
pub literal: Option<u8>
}
impl InstructionTrait for Add {
fn length(&self) -> u8 {
1
}
fn encoded(&self) -> Chip8CpuInstructions {
}
fn decode(from: Vec<u8>) -> &dyn InstructionTrait {
todo!()
}
}