decodes all instructions i think.

start of a beneater pc
This commit is contained in:
2025-06-27 12:14:54 -04:00
parent 57544589b3
commit d89fc1cd2b
22 changed files with 311 additions and 35 deletions
+16
View File
@@ -0,0 +1,16 @@
// This is the GUI for the BenEater PC
use macroquad::prelude::*;
#[macroquad::main("Ben Eaters PC")]
async fn main() {
println!("Taxation is Theft");
let computer = BenEaterPC::new();
loop {
clear_background(BLUE);
draw_text("Ben Eater", 20.0, 20.0, 30.0, BLACK);
next_frame().await
}
}
+1
View File
@@ -0,0 +1 @@
pub mod parts;
+25
View File
@@ -0,0 +1,25 @@
use crate::parts::clock::Clock;
use core::mos6502cpu::Mos6502Cpu;
struct BenEaterPC {
clock: Clock,
cpu: Mos6502Cpu,
}
impl BenEaterPC {
pub fn new() -> Self {
BenEaterPC {
clock: Clock::new(),
cpu: Mos6502Cpu::default()
}
}
pub fn tick_system(&mut self) {
let (address, data, rw) = self.cpu.tick();
if self.cpu.microcode_step == 0 {
// tick the clock.
// tick the memory
// tick the VIA
}
}
}
+24
View File
@@ -0,0 +1,24 @@
pub struct Clock {
ticks: u32
}
impl Clock {
pub fn new() -> Self {
Clock {
ticks: 0
}
}
pub fn tick(&mut self) {
self.ticks += 1;
}
pub fn ticks(&self) -> u32 {
self.ticks
}
pub fn reset(&mut self) {
self.ticks = 0;
}
}
+3
View File
@@ -0,0 +1,3 @@
pub mod clock;
mod ben_eater_pc;
mod via6522;
+31
View File
@@ -0,0 +1,31 @@
#[derive(Default)]
pub struct Via6522 {
port_a_state: u8,
port_b_data: u8,
port_a_direction: u8,
port_b_direction: u8,
memory_offset: u16,
}
impl Via6522 {
pub fn new(offset: u16) -> Self {
Via6522 {
memory_offset: offset,
..Default::default()
}
}
pub fn set_a_direction(&mut self, new_direction: u8) {
}
// check for output pins and see what they say
pub fn update_pins(&mut self) {
}
// check for input mode pins and see what they say
pub fn read_pins(&self) {
}
}