diff --git a/.gitignore b/.gitignore
index ea8c4bf..507b1e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/target
+/roms
diff --git a/.idea/nesrust.iml b/.idea/nesrust.iml
index 535f815..8632646 100644
--- a/.idea/nesrust.iml
+++ b/.idea/nesrust.iml
@@ -5,6 +5,7 @@
+
diff --git a/Cargo.lock b/Cargo.lock
index d2a7e56..9aa842b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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"
diff --git a/Cargo.toml b/Cargo.toml
index c4d96f4..a48ffd7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,4 +6,4 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
-members = ["core"]
\ No newline at end of file
+members = ["core", "ui"]
\ No newline at end of file
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 0f1763f..4b11368 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -1,6 +1,6 @@
mod cpu;
mod memory;
-mod rom;
+pub mod rom;
pub trait Clock {
/// Run a clock cycle
diff --git a/core/src/rom/mod.rs b/core/src/rom/mod.rs
index ecfda45..1b384ed 100644
--- a/core/src/rom/mod.rs
+++ b/core/src/rom/mod.rs
@@ -71,7 +71,7 @@ pub trait RomLoader {
}
impl Rom {
- fn read(path: &str) -> Result<(), RomReadError> {
+ pub fn read(path: &str) -> Result {
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),
diff --git a/ui/Cargo.toml b/ui/Cargo.toml
new file mode 100644
index 0000000..5450c55
--- /dev/null
+++ b/ui/Cargo.toml
@@ -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"] }
\ No newline at end of file
diff --git a/ui/src/main.rs b/ui/src/main.rs
new file mode 100644
index 0000000..9e68ea0
--- /dev/null
+++ b/ui/src/main.rs
@@ -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");
+}