]> git.sur5r.net Git - cc65/blobdiff - libsrc/atmos/cgetc.s
Enhancements for cursor calculation
[cc65] / libsrc / atmos / cgetc.s
index b927af6c69f77f031cab3d98b2896bbe3a87afc7..e4ea15ac659d7741a5e1d5d853ffa692427663d8 100644 (file)
@@ -1,16 +1,17 @@
 ;
-; Ullrich von Bassewitz, 2003-04-13
+; 2003-04-13, Ullrich von Bassewitz
+; 2014-09-04, Greg King
 ;
 ; char cgetc (void);
 ;
 
-       .export         _cgetc
-        .constructor    cursoroff
-        .destructor     cursoron
-       .import         cursor
+        .export         _cgetc
+        .constructor    initcgetc
 
-       .include        "atmos.inc"
+        .import         cursor
+        .forceimport    disable_caps
 
+        .include        "atmos.inc"
 
 
 ; ------------------------------------------------------------------------
 
 ; No character, enable cursor and wait
 
-        lda     cursor          ; Cursor currently off?
+        lda     cursor          ; Should cursor be off?
         beq     @L1             ; Skip if so
-        jsr     cursoron
+        lsr     STATUS
+        sec                     ; Cursor ON
+        rol     STATUS
 @L1:    lda     KEYBUF
         bpl     @L1
 
 ; If the cursor was enabled, disable it now
 
         ldx     cursor
-        beq     @L3
+        beq     @L2
         dec     STATUS          ; Clear bit zero
 
-; We have the character, clear avail flag
+; We have the character, clear the "available" flag
 
 @L2:    and     #$7F            ; Mask out avail flag
         sta     KEYBUF
+        ldx     #>$0000
+        ldy     MODEKEY
+        cpy     #FUNCTKEY
+        bne     @L3
+        ora     #$80            ; FUNCT-key pressed
 
 ; Done
 
-@L3:    ldx     #$00
-        rts
+@L3:    rts
 
 .endproc
 
 ; ------------------------------------------------------------------------
-; Switch the cursor on
+; Switch the cursor off. Code goes into the INIT segment
+; which may be reused after it is run.
 
-cursoron:
-        lda     STATUS
-        ora     #%00000001
-        sta     STATUS
-        rts
+.segment        "INIT"
 
-; ------------------------------------------------------------------------
-; Switch the cursor off
-
-cursoroff:
-        lda     STATUS
-        and     #%11111110
-        sta     STATUS
+initcgetc:
+        lsr     STATUS
+        asl     STATUS          ; Clear bit zero
         rts
-