closer to ticking.
has microsteps in the UI decodes from a NOP only binary some basic instructions are starting to move data around
This commit is contained in:
@@ -10,8 +10,8 @@ use beneater::parts::display_matrix::DisplayMatrix;
|
||||
async fn main() {
|
||||
println!("Taxation is Theft");
|
||||
|
||||
let computer = BenEaterPC::new();
|
||||
|
||||
let mut computer = BenEaterPC::new();
|
||||
computer.load_rom("resources/beneater/roms/ror.bin");
|
||||
|
||||
let mut dm = DisplayMatrix::new(200.0, 50.0);
|
||||
let message_to_show = "Taxation is theft";
|
||||
@@ -31,6 +31,7 @@ async fn main() {
|
||||
|
||||
if frame_number.is_multiple_of(60) {
|
||||
dm.push_letter('X');
|
||||
computer.tick_system();
|
||||
}
|
||||
|
||||
if frame_number.is_multiple_of(60 * 6) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
use std::fs;
|
||||
use core::constants::constants_system::SIZE_32KB;
|
||||
|
||||
fn main() {
|
||||
// make the rom data in memory.
|
||||
// Fill with 0x6a -> ROR, A
|
||||
let vec = vec![0x6a; SIZE_32KB];
|
||||
let slice: Box<[u8]> = vec.into_boxed_slice();
|
||||
let mut array: Box<[u8; SIZE_32KB]> = slice.try_into().expect("Unable to make rom in ram");
|
||||
|
||||
array[0] = 0xa9; // LDA #$ab
|
||||
array[1] = 0xab;
|
||||
|
||||
// write the rom to disk
|
||||
fs::write("outputfile.bin", array.as_slice());
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::path::Path;
|
||||
use crate::parts::clock::Clock;
|
||||
use core::mos6502cpu::Mos6502Cpu;
|
||||
|
||||
@@ -28,4 +32,24 @@ impl BenEaterPC {
|
||||
self.cpu.tick();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_rom(&mut self, rom_to_load: &str) {
|
||||
println!("Preparing to load {rom_to_load}");
|
||||
|
||||
let file = File::open(rom_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]);
|
||||
}
|
||||
println!("Loaded {}b of data.", chunks.len());
|
||||
self.cpu.memory = chunks.into();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ pub struct CpuDisplay {}
|
||||
impl CpuDisplay {
|
||||
pub fn render(cpu: &Mos6502Cpu, x_offset: f32, y_offset: f32) {
|
||||
// get the data to display...
|
||||
let (pc, a, x, y, address_bus, data_bus) = cpu.dump_data();
|
||||
let (pc, a, x, y, address_bus, data_bus, microsteps_remaining) = cpu.dump_data();
|
||||
|
||||
// ...build the interface
|
||||
Self::draw_square(x_offset, y_offset, x_offset + 300.0, y_offset + 85.0, BLACK);
|
||||
@@ -16,6 +16,7 @@ impl CpuDisplay {
|
||||
draw_text(format!("A: 0x{:02x} X: 0x{:02x} Y: 0x{:02x}", a, x, y).as_str(), x_offset + 5.0, y_offset + 35.0, 15.0, BLACK);
|
||||
draw_text(format!("Address: {:016b} | {:04x}", address_bus, address_bus).as_str(), x_offset + 5.0, y_offset + 55.0, 15.0, BLACK);
|
||||
draw_text(format!("Data: {:08b} | {:02x}", data_bus, data_bus).as_str(), x_offset + 5.0, y_offset + 75.0, 15.0, BLACK);
|
||||
draw_text(format!("MS: {:02x}", microsteps_remaining).as_str(), x_offset + 5.0, y_offset + 95.0, 15.0, BLACK);
|
||||
}
|
||||
|
||||
fn draw_square(x1: f32, y1: f32, x2: f32, y2: f32, color: Color) {
|
||||
|
||||
@@ -5,4 +5,4 @@ pub mod display_matrix;
|
||||
pub mod address_bus;
|
||||
pub mod data_bus;
|
||||
pub mod cpu_display;
|
||||
mod ram_display;
|
||||
pub mod ram_display;
|
||||
|
||||
Reference in New Issue
Block a user