From 3bbd896e18eb6b3fb8cbda18f9576962dd88bfc1 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 15 Jul 2020 17:37:11 -0500 Subject: [PATCH] Fix Underflow bug, and require game path in arg --- src/main.rs | 3 ++- src/periph.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 982cafe..7b6496a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,8 @@ fn main() { let window = init_window(&event_loop); let mut pixels = init_pixels(&window); - let rom_path = Path::new("./games/c8games/INVADERS"); + let path = std::env::args().nth(1).expect("No Path Provided!"); + let rom_path = Path::new(&path); chip8.load_rom(rom_path).expect("Unable to load ROM"); TimerManager::start(); diff --git a/src/periph.rs b/src/periph.rs index 5e1f908..2cf8729 100644 --- a/src/periph.rs +++ b/src/periph.rs @@ -137,14 +137,14 @@ impl Timer { pub fn tick(&mut self) { if self.enabled { - self.remaining -= 1; - if self.remaining == 0 { self.enabled = false; if self.beep_enabled { Self::beep(); } + } else { + self.remaining -= 1; } } }