Skip to content

Commit

Permalink
Merge pull request #1 from Amjad50/master
Browse files Browse the repository at this point in the history
Bugs and error fixes
  • Loading branch information
ablakey committed Jun 2, 2020
2 parents c8a35ff + 32e7364 commit f50c399
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/chip8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ impl Chip8 {
// If it is 1, do collision detection and set the pixel.
if pixels & 0x80 >> col > 0 {
// Get current pixel.
let idx = vx + col + ((vy + row) * 64);
let col = (vx + col) % 64;
let row = (vy + row) % 32;

let idx = col + (row * 64);
let current_pixel = self.graphics_buffer[idx];

// If collision, set VF to 1, else 0.
Expand Down
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ impl Debugger {

fn main() {
let args: Vec<String> = env::args().collect();

// mostly redundant
assert_eq!(args.len() > 0, true);

if args.len() < 2 {
println!("USAGE: {} <rom-file>", args[0]);
return;
}

let filename = &args[1];

let emulator = Emulator::init(filename);
Expand Down

0 comments on commit f50c399

Please sign in to comment.