Add sdl2 handlers and bunch of tests

First semi-working state, games can be loaded and they open
a sdl2 window \o/

TODOS:
+ Stacks offset is wrong somewhere
+ Input not working (maybe because of above reason?)
+ Add mising tests
This commit is contained in:
Marco Thomas
2021-03-12 16:13:25 +01:00
parent f61b3ed74d
commit 41d9e5dad0
6 changed files with 432 additions and 35 deletions

View File

@@ -5,12 +5,22 @@ use std::env;
mod processor;
mod fontset;
mod display;
mod input;
mod cartridge;
use crate::processor::Processor;
use crate::cartridge::Cartridge;
const MEMORY_SIZE: usize = 4096;
const GAME_ENTRY: usize = 0x200; // most games load into 0x200
const SCREEN_WIDTH: usize = 64;
const SCREEN_HEIGHT: usize = 32;
const SCREEN_SCALE: usize = 20;
fn main() {
let cartridge = env::args().nth(1);
match cartridge {
let game_file = env::args().nth(1);
match game_file {
Some(_) => println!("Found a cartridge file! Trying to load..."),
None => {
println!("No cartridge file found! Exiting!");
@@ -21,7 +31,8 @@ fn main() {
let mut processor = Processor::new();
// load cartridge file
let cartridge = Cartridge::new(&game_file.unwrap());
processor.start();
processor.start(&cartridge.rom);
}