]> git.sur5r.net Git - cc65/blob - libsrc/c64/cgetc.s
remove TABs
[cc65] / libsrc / c64 / cgetc.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
3 ;
4 ; char cgetc (void);
5 ;
6
7         .export         _cgetc
8         .import         cursor
9
10         .include        "cbm_kernal.inc"
11         .include        "c64.inc"
12
13 _cgetc: lda     KEY_COUNT       ; Get number of characters
14         bne     L3              ; Jump if there are already chars waiting
15
16 ; Switch on the cursor if needed
17
18         lda     CURS_FLAG
19         pha
20         lda     cursor
21         jsr     setcursor
22 L1:     lda     KEY_COUNT
23         beq     L1
24         ldx     #0
25         pla
26         bne     L2
27         inx
28 L2:     txa
29         jsr     setcursor
30
31 L3:     jsr     KBDREAD         ; Read char and return in A
32         ldx     #0
33         rts
34
35
36 ; Switch the cursor on or off
37
38 .proc   setcursor
39
40         tax                     ; On or off?
41         bne     seton           ; Go set it on
42         lda     CURS_FLAG       ; Is the cursor currently off?
43         bne     crs9            ; Jump if yes
44         lda     #1
45         sta     CURS_FLAG       ; Mark it as off
46         lda     CURS_STATE      ; Cursor currently displayed?
47         beq     crs8            ; Jump if no
48         ldy     CURS_X          ; Get the character column
49         lda     (SCREEN_PTR),y  ; Get character
50         eor     #$80
51         sta     (SCREEN_PTR),y  ; Store character back
52         lda     CURS_COLOR
53         sta     (CRAM_PTR),y    ; Store color back
54 crs8:   lda     #0
55         sta     CURS_STATE      ; Cursor not displayed
56 crs9:   rts
57
58 seton:  lda     #0
59         sta     CURS_FLAG
60         rts
61
62 .endproc