mirror of
https://github.com/arnaucube/chip8-rs.git
synced 2026-02-07 11:16:40 +01:00
Add main structure of Emulator & Chip8 crate
This commit is contained in:
59
src/main.rs
Normal file
59
src/main.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
use clap::{App, Arg};
|
||||
|
||||
use chip8::Chip8;
|
||||
|
||||
struct SdlEmulator {
|
||||
w: usize,
|
||||
h: usize,
|
||||
zoom: usize,
|
||||
chip8: Chip8,
|
||||
}
|
||||
|
||||
impl SdlEmulator {
|
||||
fn new(w: usize, h: usize, zoom: usize) -> SdlEmulator {
|
||||
let mut c = Chip8::new();
|
||||
|
||||
SdlEmulator {
|
||||
w,
|
||||
h,
|
||||
zoom,
|
||||
chip8: c,
|
||||
}
|
||||
}
|
||||
fn draw_graphics(&mut self) {
|
||||
// TODO
|
||||
}
|
||||
fn set_keys(&mut self) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let matches = App::new("chip8-rs")
|
||||
.version("0.0.1")
|
||||
.about("chip8 emulator")
|
||||
.arg(
|
||||
Arg::with_name("file")
|
||||
.short("f")
|
||||
.long("file")
|
||||
.takes_value(true)
|
||||
.help("File path of the rom to load"),
|
||||
)
|
||||
.get_matches();
|
||||
let file = matches.value_of("file");
|
||||
let file = match file {
|
||||
Some(file) => file,
|
||||
_ => panic!("Please specify file path of the rom to load"),
|
||||
};
|
||||
println!("{:?}", file);
|
||||
|
||||
let mut e = SdlEmulator::new(64, 32, 8);
|
||||
loop {
|
||||
e.chip8.emulate_cycle();
|
||||
if e.chip8.draw_flag {
|
||||
e.draw_graphics();
|
||||
}
|
||||
e.set_keys();
|
||||
// delay
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user