]> git.sur5r.net Git - cc65/blob - libsrc/vic20/cgetc.s
Separate header and trailers of Atari system_check chunk.
[cc65] / libsrc / vic20 / 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        "vic20.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         inc     CURS_FLAG       ; Mark it as off
45         lda     CURS_STATE      ; Cursor currently displayed?
46         beq     crs8            ; Jump if no
47         ldy     CURS_X          ; Get the character column
48         lda     (SCREEN_PTR),y  ; Get character
49         eor     #$80
50         sta     (SCREEN_PTR),y  ; Store character back
51         lda     CURS_COLOR
52         sta     (CRAM_PTR),y    ; Store color back
53 crs8:   lda     #0
54         sta     CURS_STATE      ; Cursor not displayed
55 crs9:   rts
56
57 seton:  lda     #0
58         sta     CURS_FLAG
59         rts
60
61 .endproc