Permalink
Browse files

CPU: Stop any old timers on reset.

  • Loading branch information...
nelhage committed Jun 2, 2011
1 parent e778427 commit 83fa893411f36927851bc22eb175257a71106ed5
Showing with 4 additions and 4 deletions.
  1. +4 −4 CPU.js
View
8 CPU.js
@@ -198,15 +198,14 @@ var CPU = {
reset: function(config) {
var i;
+ CPU.pause();
CPU.config = config;
CPU.PC = ISR_RESET;
for (i = 0; i < 32; i ++)
CPU.regs[i] = 0;
CPU.halt = false;
CPU.pending_interrupts = 0;
CPU.callback = null;
- CPU.clock = null;
- CPU.run_timer = null;
CPU.key_buffer = [];
CPU.mouse = null;
},
@@ -251,10 +250,11 @@ var CPU = {
},
pause: function() {
- clearTimeout(CPU.run_timer);
+ if (CPU.run_timer)
+ clearTimeout(CPU.run_timer);
+ CPU.run_timer = null;
if (CPU.clock)
clearInterval(CPU.clock);
- CPU.run_timer = null;
CPU.clock = null;
},

0 comments on commit 83fa893

Please sign in to comment.