Add cursor in HRCG, not blinking yet
authorNick Downing <nick@ndcode.org>
Wed, 25 May 2022 12:31:12 +0000 (22:31 +1000)
committerNick Downing <nick@ndcode.org>
Wed, 25 May 2022 12:31:12 +0000 (22:31 +1000)
apple_io.py
hrcg/ribbit.sh
hrcg/terminal.asm
ribbit/ribbit.bas.patch

index bfd77ef..70b3d40 100644 (file)
@@ -258,8 +258,7 @@ def init():
     atexit.register(deinit)
     tty.setraw(fd_in)
     # auto wrap off, hide cursor, reset attributes
-    if not hrcg:
-      write('\x1b[?7l\x1b[?25l\x1b[0m')
+    write('\x1b[?7l\x1b[?25l\x1b[0m')
 
 def deinit():
   global termios_attr
@@ -268,9 +267,8 @@ def deinit():
     # reset to initial state, auto wrap on, show cursor, reset attributes
     # note: reset to initial state clears the screen which I do not like,
     # but it may be the only way to clear our change to the beep settings
-    if not hrcg:
-      #write('\x1bc\x1b[?7h\x1b[?25h\x1b[0m')
-      write('\x1b[?7h\x1b[?25h\x1b[0m')
+    #write('\x1bc\x1b[?7h\x1b[?25h\x1b[0m')
+    write('\x1b[?7h\x1b[?25h\x1b[0m')
 
     termios.tcsetattr(fd_in, termios.TCSADRAIN, termios_attr)
     atexit.unregister(deinit)
@@ -388,17 +386,27 @@ def get():
   global ch_in
 
   if len(ch_in) == 0:
+    write('\x1b[?25h') # show cursor
     get_internal()
+    write('\x1b[?25l') # hide cursor
   ch = ch_in
   ch_in = ''
   mem[HW_IOADR] &= 0x7f
   return ch
 
 def input():
+  global ch_in
+
   write('\x1b[?25h') # show cursor
   line = ''
   while True:
-    ch = get()
+    # taken from get(), but doesn't do cursor
+    if len(ch_in) == 0:
+      get_internal()
+    ch = ch_in
+    ch_in = ''
+    mem[HW_IOADR] &= 0x7f
+
     if ch == '\b':
       if len(line):
         _print('\b')
@@ -408,16 +416,16 @@ def input():
     else:
       _print(ch)
       if ch == '\r':
-        write('\x1b[?25l') # hide cursor
-        return line
-      else:
-        if len(line) >= 247:
-          _print('\a')
-          if len(line) >= 255:
-            _print('\r')
-            line = ''
-            continue
-        line += ch
+        break
+      if len(line) >= 247:
+        _print('\a')
+        if len(line) >= 255:
+          _print('\r')
+          line = ''
+          continue
+      line += ch
+  write('\x1b[?25l') # hide cursor
+  return line
 
 def htab(x):
   low_mem[ZP_CH] = (x - 1) & 0xff
index 5cabf07..f125f3e 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
-../applesoft_basic.py --hrcg --joystick=/dev/input/event19,flip_y,swap_buttons ../ribbit/ribbit_patched.tok |\
+../applesoft_basic.py --hrcg --joystick=/dev/input/by-id/usb-Madcatz_Mad_Catz_V.1_Stick-event-joystick,flip_y,swap_buttons ../ribbit/ribbit_patched.tok |\
 ./emu_65c02 monitor_rom.obj hrcg.obj terminal.obj
index 6e2e394..56127e5 100644 (file)
@@ -4,6 +4,9 @@ wndtop  equ     $22
 wndbtm equ     $23
 ch     equ     $24
 cv     equ     $25
+gbasl  equ     $26
+gbash  equ     $27
+cursor equ     $fb
 prevch equ     $fc
 state  equ     $fd
 prevnum        equ     $fe
@@ -13,6 +16,7 @@ chario        equ     $3ea
 hrcg   equ     $8dff
 hrcgent        equ     hrcg+3                  avoids banner
 extfont        equ     hrcg+7
+hirespg        equ     hrcg+$62
 font   equ     hrcg-$600               hard coded 2 sets
 kbd    equ     $c000
 kbdstrb        equ     $c010
@@ -27,6 +31,7 @@ slp.hi        equ     $c0f7
 s.exit equ     $c0f8
 dos.lo equ     $c0f9
 dos.hi equ     $c0fa
+gbascalc equ   $f847
 cout   equ     $fded
        org     $800
        lda     #0
@@ -45,9 +50,10 @@ cout equ     $fded
        lda     #<font
        sta     extfont+1
        jsr     hrcgent
+       ldx     #0
+       stx     cursor
        lda     #$d                     cr
        sta     prevch
-       ldx     #0
 newst  stx     state
 loop   lda     sout.s
        bpl     nosout
@@ -72,9 +78,14 @@ issin        lda     sin.d
        dex
        beq     state2
        dex
-       bne     notst3
-       jmp     state3
-notst3 lda     #1
+       beq     state3
+       dex
+       bne     notst4
+       jmp     state4
+notst4 dex
+       bne     notst5
+       jmp     state5
+notst5 lda     #1
        sta     s.exit
 state0 cmp     #4                      ctrl-d
        bne     notctld
@@ -82,38 +93,36 @@ state0      cmp     #4                      ctrl-d
        cpy     #$d                     but only after cr
        bne     notctld
        stx     num                     use num as linebuf index
-       ldx     #3
+       ldx     #5
        jmp     newst
 notctld        cmp     #$1b                    esc
        bne     notesc
        inx
        jmp     newst
 notesc sta     prevch
+       jsr     togcsr
+       lda     prevch
        ora     #$80
        jsr     cout
+       jsr     togcsr
        jmp     loop
 state1 cmp     #$5b                    [
-       bne     newst                   invalid escape sequence
+       bne     newst0                  invalid escape sequence
        stx     prevnum
        stx     num
        ldx     #2
-       jmp     newst
-state2 cmp     #$30                    0
-       bcc     newst                   invalid escape sequence
+newst0 jmp     newst
+state2 cmp     #$3f                    ?
+       bne     notqm
+       ldx     #4
+       jmp     newst1
+notqm  ldy     #3
+       sty     state
+state3 cmp     #$30                    0
+       bcc     newst1                  invalid escape sequence
        cmp     #$3a
-       bcs     notdig
-       sec
-       sbc     #$30                    digit value
-       asl     num
-       clc
-       adc     num                     + num * 2
-       asl     num
-       asl     num
-       clc
-       adc     num                     + num * 8
-       sta     num                     to num
-       jmp     loop
-notdig cmp     #$3b                    ;
+       bcc     digit
+       cmp     #$3b                    ;
        bne     notscln
        lda     num
        sta     prevnum
@@ -122,24 +131,63 @@ notdig    cmp     #$3b                    ;
 notscln        cmp     #$47                    G
        bne     notch
        dec     num
+       jsr     togcsr
        lda     num
        sta     ch
-       jmp     newst
+       jsr     togcsr
+       ldx     #0
+newst1 jmp     newst
 notch  cmp     #$64                    d
        bne     notcv
        dec     num
+       jsr     togcsr
        lda     num
        sta     cv
+       jsr     togcsr
+       ldx     #0
        jmp     newst
 notcv  cmp     #$72                    r
-       bne     notwnd
+       bne     newst2
        dec     prevnum
        lda     prevnum
        sta     wndtop
        lda     num
        sta     wndbtm
-notwnd jmp     newst                   invalid escape sequence
-state3 ldy     num
+newst2 jmp     newst                   invalid escape sequence
+state4 cmp     #$30                    0
+       bcc     newst3                  invalid escape sequence
+       cmp     #$3a
+       bcs     notdig
+digit  sec
+       sbc     #$30                    digit value
+       asl     num
+       clc
+       adc     num                     + num * 2
+       asl     num
+       asl     num
+       clc
+       adc     num                     + num * 8
+       sta     num                     to num
+       jmp     loop
+notdig cmp     #$6c                    l
+       beq     setprv
+       cmp     #$68                    h
+       bne     newst3                  invalid escape sequence
+setprv ldy     num
+       cpy     #25                     esc [?25l or esc [?25h
+       bne     newst3
+       pha
+       jsr     togcsr
+       pla
+       ldy     #0
+       cmp     #$6c                    l
+       beq     setcur
+       ldy     #$80
+setcur sty     cursor
+       jsr     togcsr
+       ldx     #0
+newst3 jmp     newst
+state5 ldy     num
        cmp     #$d
        bne     notcr
        txa
@@ -153,3 +201,16 @@ notcr      sta     linebuf,y
        iny
        sty     num
        jmp     loop
+togcsr bit     cursor
+       bpl     rts0
+       lda     cv
+       jsr     gbascalc
+       lda     gbash
+       ora     #$1c                    7th line of the cell
+       ora     hirespg                 inside hrcg, $20 or $40
+       sta     gbash
+       ldy     ch
+       lda     (gbasl),y
+       eor     #$7f
+       sta     (gbasl),y
+rts0   rts
index e50b107..db33bc0 100644 (file)
@@ -1,5 +1,5 @@
 --- ribbit.bas 2022-05-25 17:46:21.340258050 +1000
-+++ ribbit_patched.bas 2022-05-25 18:05:19.116303909 +1000
++++ ribbit_patched.bas 2022-05-25 21:41:23.001127447 +1000
 @@ -1,6 +1,7 @@
  10GOTO10000:REM INITIALIZE
  20GOSUB900:GOTO1000
  1340IF(FY=BY-1ORFY=BY-2)ANDFX>BX-12ANDFX<BX-5THENVTABBY:HTABBX:PRINTBUG$(0,0):BC=1:BX=1:FS=FS+1:GOSUB2000:GOSUB800
  1350RETURN
  2000REM SCORE
-@@ -138,9 +139,10 @@
+@@ -92,6 +93,7 @@
+ 10090POKEADRS+7,CL:POKEADRS+8,CH:CALLADRS+3:REM INIT HRCG
+ 10100PRINTCHR$(16):REM CLEAR SCREEN
+ 10200REM PICTURES
++10210DIMBUG$(1,2),FROG$(1,4),RBT$(1,5)
+ 10300BUG$(0,0)="\ 2   \ 3   \ 4"
+ 10310BUG$(0,1)="\ 2\ 11&'*\ 3():\ 4"
+ 10320BUG$(0,2)="\ 2\ 11 !#\ 3 $%\ 4"
+@@ -138,9 +140,10 @@
  20100PRINTIB$;IC$;IP$;"\13HI!  \13WELCOME TO...\v"
  20110VTAB10:PRINT"\13DO YOU KNOW HOW TO PLAY THIS GAME?\v"
  20120PRINTIA$;IT$;:VTAB1:HTAB1:PRINT"   ";
@@ -40,7 +48,7 @@
  20230VTABFY:HTABFX+2:PRINTFROG$(1,1)
  20240FORI=1TO100:NEXT:NEXT
  20250FORI=1TO1000:NEXT:VTABFY:HTABFX:PRINTIP$;FROG$(0,1)
-@@ -160,6 +162,7 @@
+@@ -160,6 +163,7 @@
  20410FX=FX-1:VTABFY:HTABFX:PRINTFROG$(0,3);
  20420I=FY:FORFY=ITO18
  20430FX=FX-1:VTABFY:HTABFX:PRINTFROG$(0,4);