File: cgetc.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (54 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;
; 2003-04-13, Ullrich von Bassewitz
; 2014-09-04, Greg King
;
; char cgetc (void);
;

        .export         _cgetc

        .import         cursor
        .forceimport    disable_caps

        .include        "atmos.inc"


; ------------------------------------------------------------------------
;

.proc   _cgetc

        lda     KEYBUF          ; Do we have a character?
        bmi     @L2             ; Yes: Get it

; No character, enable cursor and wait

        lda     cursor          ; Should cursor be off?
        beq     @L1             ; Skip if so
        lsr     STATUS
        sec                     ; Cursor ON
        rol     STATUS
@L1:    lda     KEYBUF
        bpl     @L1

; If the cursor was enabled, disable it now

        ldx     cursor
        beq     @L2
        dec     STATUS          ; Clear bit zero

; 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:    rts

.endproc