Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
amydevs committed Aug 25, 2024
1 parent 6089982 commit 232e6df
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ impl WasmMainLoop {
let mut main_loop_options = WasmMainLoopOptions::from(options);
// setup cpu instance
let mut chip8_inst = Chip8::default();
let invert: bool = main_loop_options.invert_colors;
chip8_inst.display = [invert as u8; 2048];
let mut invert_colors: bool = main_loop_options.invert_colors;
chip8_inst.display = [invert_colors as u8; 2048];

// load rom/state into chip8inst
chip8_inst.load_program(rom);
Expand All @@ -232,6 +232,22 @@ impl WasmMainLoop {
if let Ok(beeper) = beeper.as_mut() {
beeper.set_vol(main_loop_options.vol).unwrap();
}
if main_loop_options.invert_colors != invert_colors {
invert_colors = main_loop_options.invert_colors;
let _ = main_loop_chip8
.write()
.unwrap()
.display
.iter_mut()
.map(|x| {
if *x > 0 {
*x = 0;
}
else {
*x = 1;
}
});
}

if let Ok(mesg) = rx.try_recv() {
match mesg {
Expand Down

0 comments on commit 232e6df

Please sign in to comment.