Confirmed ROM read working

This commit is contained in:
FyloZ 2025-01-19 14:17:57 -05:00
parent dd3b198fd5
commit 8cfedc63d4
Signed by untrusted user who does not match committer: william
GPG Key ID: 835378AE9AF4AE97
8 changed files with 37 additions and 4 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
/roms

1
.idea/nesrust.iml generated
View File

@ -5,6 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/core/core/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/core/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/ui/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/core/core/target" />
<excludeFolder url="file://$MODULE_DIR$/core/target" />
<excludeFolder url="file://$MODULE_DIR$/target" />

8
Cargo.lock generated
View File

@ -208,6 +208,14 @@ dependencies = [
"time-core",
]
[[package]]
name = "ui"
version = "0.1.0"
dependencies = [
"core",
"simplelog",
]
[[package]]
name = "unicode-ident"
version = "1.0.14"

View File

@ -6,4 +6,4 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = ["core"]
members = ["core", "ui"]

View File

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

View File

@ -71,7 +71,7 @@ pub trait RomLoader {
}
impl Rom {
fn read(path: &str) -> Result<(), RomReadError> {
pub fn read(path: &str) -> Result<Rom, RomReadError> {
info!("ROM - Reading file from {}", path);
let content = match fs::read(path) {
@ -95,10 +95,11 @@ impl Rom {
debug!("ROM - PRG ROM: {} bytes, CHR ROM: {} bytes", rom.prg_rom_size, rom.chr_rom_size);
info!("ROM - Loading successful");
Ok(())
Ok(rom)
}
}
#[derive(Debug)]
pub enum RomReadError {
FormatNotSupported,
Io(std::io::Error),

10
ui/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "ui"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
core = { path = "../core" }
simplelog = { version = "^0.12.0", features = ["paris"] }

12
ui/src/main.rs Normal file
View File

@ -0,0 +1,12 @@
use core::rom::Rom;
use simplelog::*;
fn main() {
CombinedLogger::init(vec![
TermLogger::new(LevelFilter::Debug, Config::default(), TerminalMode::Mixed, ColorChoice::Auto),
]).unwrap();
let path = "./roms/dk.nes";
let rom = Rom::read(path).expect("Failed to read ROM file");
print!("Do stuff");
}