Skip to content

Commit

Permalink
CPU: Stop any old timers on reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelhage committed Jun 2, 2011
1 parent e778427 commit 83fa893
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CPU.js
Expand Up @@ -198,15 +198,14 @@ var CPU = {


reset: function(config) { reset: function(config) {
var i; var i;
CPU.pause();
CPU.config = config; CPU.config = config;
CPU.PC = ISR_RESET; CPU.PC = ISR_RESET;
for (i = 0; i < 32; i ++) for (i = 0; i < 32; i ++)
CPU.regs[i] = 0; CPU.regs[i] = 0;
CPU.halt = false; CPU.halt = false;
CPU.pending_interrupts = 0; CPU.pending_interrupts = 0;
CPU.callback = null; CPU.callback = null;
CPU.clock = null;
CPU.run_timer = null;
CPU.key_buffer = []; CPU.key_buffer = [];
CPU.mouse = null; CPU.mouse = null;
}, },
Expand Down Expand Up @@ -251,10 +250,11 @@ var CPU = {
}, },


pause: function() { pause: function() {
clearTimeout(CPU.run_timer); if (CPU.run_timer)
clearTimeout(CPU.run_timer);
CPU.run_timer = null;
if (CPU.clock) if (CPU.clock)
clearInterval(CPU.clock); clearInterval(CPU.clock);
CPU.run_timer = null;
CPU.clock = null; CPU.clock = null;
}, },


Expand Down

0 comments on commit 83fa893

Please sign in to comment.