]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_cgetc.s
prepend soft80_ to some more internally used functions
[cc65] / libsrc / c64 / soft80_cgetc.s
1 ;
2 ; char cgetc (void);
3 ;
4
5         .export         soft80_cgetc
6         .import         cursor          ; FIX/CHECK
7         .import         soft80_putcolor
8
9         .include        "c64.inc"
10         .include        "soft80.inc"
11
12 soft80_cgetc:
13         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     cursor
19         jsr     setcursor       ; set cursor on or off accordingly
20
21 L1:     lda     KEY_COUNT       ; wait for key
22         beq     L1
23
24         ldx     #0
25         lda     CURS_FLAG
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 ; Switch the cursor on or off
36
37 ; A= 0: cursor off
38 ;    1: cursor on
39
40         .proc   setcursor
41
42         ; On or off?
43         cmp     CURS_STATE
44         bne     @set
45         rts
46 @set:
47         sta     CURS_STATE
48
49         sei
50         lda     $01
51         pha
52         lda     #$34
53         sta     $01
54
55         jsr     soft80_putcolor
56
57         ldy     #$00
58
59         lda     CURS_X
60         and     #$01
61         bne     @l1
62
63         .repeat 8,line
64         lda     (SCREEN_PTR),y
65         eor     #$f0
66         sta     (SCREEN_PTR),y
67         .if (line < 7)
68         iny
69         .endif
70         .endrepeat
71
72 @back:
73         pla
74         sta     $01
75         cli
76         rts
77
78 @l1:
79         .repeat 8,line
80         lda     (SCREEN_PTR),y
81         eor     #$0f
82         sta     (SCREEN_PTR),y
83         .if line < 7
84         iny
85         .endif
86         .endrepeat
87
88         jmp     @back
89
90         .endproc