From 0cc5f0fb7b6234a3ffe22c22d1350a0b8aa9feb8 Mon Sep 17 00:00:00 2001
From: Steven Hugg <hugg@fasterlight.com>
Date: Sun, 17 Nov 2019 10:48:08 -0600
Subject: [PATCH] fixed NES infinite loop

---
 src/platform/nes.ts | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/platform/nes.ts b/src/platform/nes.ts
index 6a35d188..626eb8d9 100644
--- a/src/platform/nes.ts
+++ b/src/platform/nes.ts
@@ -131,8 +131,7 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
     //this.nes.ppu.showSpr0Hit = true;
     //this.nes.ppu.clipToTvSize = false;
     this.nes.stop = () => {
-      // TODO: trigger breakpoint
-      console.log(this.nes.cpu.toJSON());
+      this.breakpointHit(this.debugClock);
       throw new EmuHalt("CPU STOPPED");
     };
     // insert debug hook
@@ -142,7 +141,7 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
       var cycles = this.nes.cpu._emulate();
       this.evalDebugCondition();
       this.probe.logClocks(cycles);
-      return cycles;
+      return cycles > 0 ? cycles : 1;
     }
     this.timer = new AnimationTimer(60, this.nextFrame.bind(this));
     // set keyboard map