Compare commits
No commits in common. "065be393570c8af03ec41dfd046582b5e475f705" and "56237065d473f33f8f644b7857cc06e1207c00a5" have entirely different histories.
065be39357
...
56237065d4
1 changed files with 6 additions and 10 deletions
16
src/main.rs
16
src/main.rs
|
@ -23,7 +23,6 @@ use sdl2::pixels::Color;
|
|||
use sdl2::event::Event;
|
||||
use sdl2::keyboard::Keycode;
|
||||
use sdl2::rect::Point;
|
||||
use sdl2::rect::Rect;
|
||||
|
||||
use machine::HEIGHT;
|
||||
use machine::WIDTH;
|
||||
|
@ -35,6 +34,8 @@ use std::env;
|
|||
|
||||
fn main() {
|
||||
let name_file = &env::args().collect::<Vec<String>>()[1];
|
||||
//read_file(Path::new("15PUZZLE"));
|
||||
//return;
|
||||
let mut t: Machine = Machine::new();
|
||||
t.init();
|
||||
match t.load_rom(Path::new(name_file)) {
|
||||
|
@ -47,7 +48,8 @@ fn main() {
|
|||
|
||||
let sdl_context = sdl2::init().unwrap();
|
||||
let video_subsystem = sdl_context.video().unwrap();
|
||||
let window = video_subsystem.window("Chip8 Emulator", 200 + 11 * WIDTH as u32, 11 * HEIGHT as u32)
|
||||
let window = video_subsystem.window("Chip8 Emulator", WIDTH as u32, HEIGHT as u32)
|
||||
//let window = video_subsystem.window("Chip8 Emulator", 100 + 10 * WIDTH as u32, 10 * HEIGHT as u32)
|
||||
.position_centered()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
@ -56,10 +58,6 @@ fn main() {
|
|||
canvas.set_draw_color(Color::RGB(0, 0, 0));
|
||||
canvas.clear();
|
||||
canvas.present();
|
||||
canvas.set_draw_color(Color::RGB(255, 255, 255));
|
||||
canvas.draw_line(Point::new(11 * WIDTH as i32, 0),
|
||||
Point::new(11 * WIDTH as i32, 11 * HEIGHT as i32)).unwrap();
|
||||
canvas.present();
|
||||
|
||||
let mut event_pump = sdl_context.event_pump().unwrap();
|
||||
|
||||
|
@ -68,14 +66,12 @@ fn main() {
|
|||
|
||||
for i in 0..t.display_buffer.len() {
|
||||
for j in 0..t.display_buffer[i].len() {
|
||||
let ti = i * 10 + 10;
|
||||
let tj = j * 10 + 10;
|
||||
if t.display_buffer[i][j] == 1 {
|
||||
canvas.set_draw_color(Color::RGB(255, 255, 255));
|
||||
canvas.fill_rect(Rect::new(tj as i32, ti as i32, 10, 10)).unwrap();
|
||||
canvas.draw_point(Point::new(j as i32, i as i32)).unwrap();
|
||||
} else {
|
||||
canvas.set_draw_color(Color::RGB(0, 0, 0));
|
||||
canvas.fill_rect(Rect::new(tj as i32, ti as i32, 10, 10)).unwrap();
|
||||
canvas.draw_point(Point::new(j as i32, i as i32)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue