Main system WIP

This commit is contained in:
FyloZ 2025-01-20 12:03:59 -05:00
parent 8cfedc63d4
commit 8d5192ff43
Signed by untrusted user who does not match committer: william
GPG Key ID: 835378AE9AF4AE97
4 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,7 @@
mod cpu; mod cpu;
mod memory; mod memory;
pub mod rom; pub mod rom;
mod system;
pub trait Clock { pub trait Clock {
/// Run a clock cycle /// Run a clock cycle

View File

@ -5,6 +5,11 @@ pub struct MemoryBus {
} }
impl MemoryBus { impl MemoryBus {
pub fn new() -> Self {
let ram = [0; MEMORY_SIZE];
Self { ram }
}
/// Gets a byte from memory. /// Gets a byte from memory.
/// ///
/// # Arguments /// # Arguments

View File

@ -1,7 +1,6 @@
//! INes 2.0 Format implementation //! INes 2.0 Format implementation
use crate::rom::{CpuTiming, NametableMirroring, Rom, RomLoader, RomReadError}; use crate::rom::{CpuTiming, NametableMirroring, Rom, RomLoader, RomReadError};
use bitflags::bitflags;
pub struct INesHeader { pub struct INesHeader {
prg_rom_size_lsb: u8, prg_rom_size_lsb: u8,

21
core/src/system.rs Normal file
View File

@ -0,0 +1,21 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::cpu::Cpu;
use crate::memory::MemoryBus;
pub struct System {
cpu: Cpu,
memory_bus: Rc<RefCell<MemoryBus>>,
}
impl System {
pub fn new() -> Self {
let memory_bus = Rc::new(RefCell::new(MemoryBus::new()));
let cpu = Cpu::new(memory_bus);
Self {
cpu,
memory_bus
}
}
}