From 4118ca0c9af0e0b50ca4ad3ed414e4a5254e4e92 Mon Sep 17 00:00:00 2001
From: Ian C <ianc@noddybox.co.uk>
Date: Fri, 16 Mar 2007 00:52:01 +0000
Subject: Monitor now working properly.

---
 source/monitor.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

(limited to 'source')

diff --git a/source/monitor.c b/source/monitor.c
index 20c9722..14df3bb 100644
--- a/source/monitor.c
+++ b/source/monitor.c
@@ -28,6 +28,7 @@
 #include "textmode.h"
 #include "framebuffer.h"
 #include "zx81.h"
+#include "config.h"
 
 /* ---------------------------------------- PRIVATE DATA AND TYPES
 */
@@ -238,10 +239,16 @@ void MachineCodeMonitor(Z80 *cpu)
     int running = FALSE;
     int cpu_display = TRUE;
     int key;
+    SoftKey soft_key;
 
     SK_DisplayKeyboard();
     SK_SetDisplayBrightness(TRUE);
 
+    for(soft_key = SK_1; soft_key <= SK_SPACE; soft_key++)
+    {
+    	SK_SetSticky(soft_key,TRUE);
+    }
+
     while(!done)
     {
 	TM_Cls();
@@ -258,9 +265,23 @@ void MachineCodeMonitor(Z80 *cpu)
 
 	do
 	{
+	    SoftKeyEvent ev;
+
 	    swiWaitForVBlank();
-	    key = keysDownRepeat();
-	} while (!running && !key);
+
+	    while(SK_GetBareEvent(&ev))
+	    {
+	    	ZX81HandleKey(ev.key,ev.pressed);
+
+		if (ev.key == SK_CONFIG && ev.pressed)
+		{
+		    done = TRUE;
+		}
+	    }
+
+	    key = (keysDownRepeat() & ~KEY_TOUCH);
+
+	} while (!done && !running && !key);
 
 	if (key & KEY_START)
 	{
@@ -314,4 +335,13 @@ void MachineCodeMonitor(Z80 *cpu)
 
     SK_SetDisplayBrightness(FALSE);
     TM_Cls();
+
+    for(soft_key = SK_1; soft_key <= SK_SPACE; soft_key++)
+    {
+    	SK_SetSticky(soft_key,FALSE);
+	ZX81HandleKey(soft_key,FALSE);
+    }
+
+    SK_SetSticky(SK_SHIFT,DS81_Config[DS81_STICKY_SHIFT]);
+
 }
-- 
cgit v1.2.3