Improve emulator keyboard handling to make shift work, enable cursor by default
authorNick Downing <nick@ndcode.org>
Thu, 26 May 2022 01:46:10 +0000 (11:46 +1000)
committerNick Downing <nick@ndcode.org>
Thu, 26 May 2022 01:46:10 +0000 (11:46 +1000)
hrcg/emu_65c02.c
hrcg/terminal.asm

index ed2aecc..d35fbe8 100644 (file)
@@ -606,24 +606,26 @@ int main(int argc, char **argv) {
         {
           SDL_KeyboardEvent *e = (SDL_KeyboardEvent *)&event;
           int i = e->keysym.sym;
-          if (i < 0x80) {
-            //switch (i) {
-            //default:
-              if ((i >= 0x40 && i < 0x80) && (e->keysym.mod & KMOD_CTRL))
-                i &= 0x1f;
+          switch (i) {
+          case SDLK_LEFT:
+            key_waiting = 0x88;
+            break;
+          case SDLK_RIGHT:
+            key_waiting = 0x95;
+            break;
+          default:
+            if (i < 0x20)
               key_waiting = i | 0x80;
-            //  break;
-            //}
+            else if ((i >= 0x40 && i < 0x80) && (e->keysym.mod & KMOD_CTRL))
+              key_waiting = (i & 0x1f) | 0x80;
+            break;
           }
-          else
-            switch (i) {
-            case SDLK_LEFT:
-              key_waiting = 0x88;
-              break;
-            case SDLK_RIGHT:
-              key_waiting = 0x95;
-              break;
-            }
+        }
+        break;
+      case SDL_TEXTINPUT:
+        {
+          SDL_TextInputEvent *e = (SDL_TextInputEvent *)&event;
+          key_waiting = e->text[0] | 0x80;
         }
         break;
       }
index 9b5ea48..38f8e5e 100644 (file)
@@ -6,8 +6,8 @@ ch      equ     $24
 cv     equ     $25
 gbasl  equ     $26
 gbash  equ     $27
-csrblnk        equ     $fa                     blink countdown
-cursor equ     $fb                     bit 6 shown, bit 7 enabled
+cursor equ     $fa                     bit 6 shown, bit 7 enabled
+csrblnk        equ     $fb                     blink countdown
 prevch equ     $fc
 state  equ     $fd
 prevnum        equ     $fe
@@ -51,10 +51,13 @@ cout        equ     $fded
        lda     #<font
        sta     extfont+1
        jsr     hrcgent
-       ldx     #0
-       stx     cursor
+       lda     #$80
+       sta     cursor                  clear shown, set enable
+       lda     #250
+       sta     csrblnk                 set counter for .25s (units of 1ms)
        lda     #$d                     cr
        sta     prevch
+       ldx     #0
 newst  stx     state
 loop   lda     sout.s
        bpl     nosout