diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..c5dc472 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "salt-n-vinegar" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..765d473 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "salt-n-vinegar" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..47ecd97 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# saltnvinegar + +A chip8 emulator written in Rust \ No newline at end of file diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..c76debe --- /dev/null +++ b/notes.txt @@ -0,0 +1,18 @@ +00E0 Clear screen +00EE RET + Sets the PC to the top of the stack, then subtracts 1 from the stack pointer +1nnn JMP, address +2nnn CALL address + Increments the stack pointer then puts the current PC on the top of the stack, the PC is then set to xxx +3xkk SE Vx, byte + Skip next instruction if Vx register == kk + Increments PC by 2 +4xkk SNE Vx, byte + Skip next instruction if Vx register != kk + Increments PC by 2 +5xy0 SE Vx, Vy + Skip next instruction if Vx register == Vy register + Increments PC by 2 +6xkk Ld Vx, Vy + Skip next instruction if Vx register == Vy register + Increments PC by 2 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..eb6161e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,42 @@ +use std::path; +use std::env; +use std::fs; +use std::process::exit; + +// Module imports +mod util; + +fn main() +{ + // Collect our execution args + let args: Vec = env::args().collect(); + // let mut inject_mode: bool = false; + // let mut patch_file_path: &String = &"".to_string(); + + // Grab our filepath from our options + if &args.len() < &2 + { + // No file given, terminate + util::print_help(); + exit(0); + } + + let file_path: &String = &args[1]; + + if path::Path::new(file_path).exists() + { + println!("File exists, reading '{}'...", file_path); + + let contents: Result, std::io::Error> = fs::read(file_path); + + if contents.is_ok() + { + let _bytes: &Vec = &contents.expect(""); + // let magic_num: &[u8] = &bytes[0..4]; + } + } else + { + println!("[Error] File '{}' does not exist", file_path); + exit(-1); + } +} diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..1504663 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,3 @@ +pub fn print_help() { + print!("Usage: saltnvinegar [CHIP8_FILE]\n"); +} \ No newline at end of file