[feat] init

This commit is contained in:
2024-02-29 11:55:14 +05:30
commit d1b0f03779
7 changed files with 484 additions and 0 deletions

8
src/args.rs Normal file
View File

@@ -0,0 +1,8 @@
use clap::Parser;
#[derive(Parser,Debug,Clone)]
#[command(version,about,author)]
pub struct Chip8ProgramArgs{
#[arg(short,long,help = "Filename of ROM to load.")]
pub filename:Option<String>
}

22
src/device.rs Normal file
View File

@@ -0,0 +1,22 @@
pub struct Device{
pub registers:RegisterFile,
pub memory: Box<[u8;Self::DEVICE_MEMORY_SIZE]>
}
impl Device{
pub const DEVICE_MEMORY_SIZE:usize = 1024;
pub fn new()->Device{
let memory = vec![0u8;Self::DEVICE_MEMORY_SIZE].into_boxed_slice().try_into().unwrap();
log::trace!("Successfully initiated device memory");
Device{
registers: RegisterFile{},
memory
}
}
}
pub struct RegisterFile{
}

12
src/main.rs Normal file
View File

@@ -0,0 +1,12 @@
use log::LevelFilter;
use simple_logger::SimpleLogger;
use crate::device::{Device};
mod args;
mod device;
fn main() {
SimpleLogger::new().with_level(LevelFilter::Info).env().init().unwrap();
log::info!("Started emulator");
let device = Device::new();
}