Confirmed ROM read working
This commit is contained in:
parent
dd3b198fd5
commit
8cfedc63d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/target
|
||||
/roms
|
||||
|
1
.idea/nesrust.iml
generated
1
.idea/nesrust.iml
generated
@ -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
8
Cargo.lock
generated
@ -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"
|
||||
|
@ -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"]
|
@ -1,6 +1,6 @@
|
||||
mod cpu;
|
||||
mod memory;
|
||||
mod rom;
|
||||
pub mod rom;
|
||||
|
||||
pub trait Clock {
|
||||
/// Run a clock cycle
|
||||
|
@ -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
10
ui/Cargo.toml
Normal 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
12
ui/src/main.rs
Normal 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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user