|
@ -1,3 +1,8 @@ |
|
|
|
|
|
extern crate sdl2;
|
|
|
|
|
|
|
|
|
|
|
|
use sdl2::pixels::Color;
|
|
|
|
|
|
use sdl2::render::Canvas;
|
|
|
|
|
|
|
|
|
use clap::{App, Arg};
|
|
|
use clap::{App, Arg};
|
|
|
|
|
|
|
|
|
use chip8::Chip8;
|
|
|
use chip8::Chip8;
|
|
@ -6,6 +11,7 @@ struct SdlEmulator { |
|
|
w: usize,
|
|
|
w: usize,
|
|
|
h: usize,
|
|
|
h: usize,
|
|
|
zoom: usize,
|
|
|
zoom: usize,
|
|
|
|
|
|
canvas: Canvas<sdl2::video::Window>,
|
|
|
chip8: Chip8,
|
|
|
chip8: Chip8,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -13,10 +19,22 @@ impl SdlEmulator { |
|
|
fn new(w: usize, h: usize, zoom: usize) -> SdlEmulator {
|
|
|
fn new(w: usize, h: usize, zoom: usize) -> SdlEmulator {
|
|
|
let mut c = Chip8::new();
|
|
|
let mut c = Chip8::new();
|
|
|
|
|
|
|
|
|
|
|
|
let sdl_context = sdl2::init().unwrap();
|
|
|
|
|
|
let video_subsystem = sdl_context.video().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let window = video_subsystem
|
|
|
|
|
|
.window("rust-sdl2 demo", 800, 600)
|
|
|
|
|
|
.position_centered()
|
|
|
|
|
|
.build()
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let mut canvas = window.into_canvas().build().unwrap();
|
|
|
|
|
|
|
|
|
SdlEmulator {
|
|
|
SdlEmulator {
|
|
|
w,
|
|
|
w,
|
|
|
h,
|
|
|
h,
|
|
|
zoom,
|
|
|
zoom,
|
|
|
|
|
|
canvas,
|
|
|
chip8: c,
|
|
|
chip8: c,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|