From cdce753a09ea815d55936b78e6a1d57849a9a175 Mon Sep 17 00:00:00 2001
From: Stefan <stefan.haubenthal@gmail.com>
Date: Wed, 9 May 2018 23:31:42 +0000
Subject: [PATCH 1/3] NMI friendly c64-hi

Don't clear all vectors, see #639.
---
 libsrc/c64/tgi/c64-hi.s | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s
index aeb334404..fd7a25478 100644
--- a/libsrc/c64/tgi/c64-hi.s
+++ b/libsrc/c64/tgi/c64-hi.s
@@ -131,7 +131,7 @@ VBASE           := $E000                ; Video memory base address
 ;
 
 INSTALL:
-        rts
+;       rts                     ; fall through
 
 
 ; ------------------------------------------------------------------------
@@ -272,9 +272,12 @@ CLEAR:  ldy     #$00
         sta     VBASE+$1C00,y
         sta     VBASE+$1D00,y
         sta     VBASE+$1E00,y
-        sta     VBASE+$1F00,y
         iny
         bne     @L1
+@L2:    sta     VBASE+$1F00,y
+        iny
+        cpy     #$40
+        bne     @L2
         rts
 
 ; ------------------------------------------------------------------------
@@ -285,7 +288,7 @@ CLEAR:  ldy     #$00
 ;
 
 SETVIEWPAGE:
-        rts
+;       rts                     ; fall through
 
 ; ------------------------------------------------------------------------
 ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).

From b81a04f157975ac117866473f5cecdf7d6015801 Mon Sep 17 00:00:00 2001
From: Stefan <stefan.haubenthal@gmail.com>
Date: Wed, 9 May 2018 23:52:52 +0000
Subject: [PATCH 2/3] Update c64-hi.s

---
 libsrc/c64/tgi/c64-hi.s | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s
index fd7a25478..ad453fd5a 100644
--- a/libsrc/c64/tgi/c64-hi.s
+++ b/libsrc/c64/tgi/c64-hi.s
@@ -272,12 +272,9 @@ CLEAR:  ldy     #$00
         sta     VBASE+$1C00,y
         sta     VBASE+$1D00,y
         sta     VBASE+$1E00,y
+        sta     VBASE+$1F40,y   ; preserve vectors
         iny
         bne     @L1
-@L2:    sta     VBASE+$1F00,y
-        iny
-        cpy     #$40
-        bne     @L2
         rts
 
 ; ------------------------------------------------------------------------

From b449ded1764c134ed1a103adf5ec4f5ba1486814 Mon Sep 17 00:00:00 2001
From: Stefan <stefan.haubenthal@gmail.com>
Date: Wed, 9 May 2018 23:56:35 +0000
Subject: [PATCH 3/3] Update c64-hi.s

---
 libsrc/c64/tgi/c64-hi.s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s
index ad453fd5a..e2c3bca9f 100644
--- a/libsrc/c64/tgi/c64-hi.s
+++ b/libsrc/c64/tgi/c64-hi.s
@@ -272,7 +272,7 @@ CLEAR:  ldy     #$00
         sta     VBASE+$1C00,y
         sta     VBASE+$1D00,y
         sta     VBASE+$1E00,y
-        sta     VBASE+$1F40,y   ; preserve vectors
+        sta     VBASE+$1E40,y   ; preserve vectors
         iny
         bne     @L1
         rts