]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_cgetc.s
some more rework, second attempt on fixing the color issues. added ifdefs to disable...
[cc65] / libsrc / c64 / soft80_cgetc.s
1 ;
2 ; char cgetc (void);
3 ;
4
5         .export         soft80_cgetc
6         .import         cursor
7
8         .include        "c64.inc"
9         .include        "soft80.inc"
10
11 .if SOFT80COLORVOODOO = 1
12         .import         soft80_putcolor
13 .endif
14
15 soft80_cgetc:
16         lda     KEY_COUNT       ; Get number of characters
17         bne     L3              ; Jump if there are already chars waiting
18
19         jsr     invertcursor    ; set cursor on or off accordingly
20
21 L1:     lda     KEY_COUNT       ; wait for key
22         beq     L1
23
24         jsr     invertcursor    ; set cursor on or off accordingly
25
26 L3:     jsr     KBDREAD         ; Read char and return in A
27         ldx     #0
28         rts
29
30 ; Switch the cursor on or off (invert)
31
32 invertcursor:
33         lda     cursor
34         bne     @invert
35         rts
36 @invert:
37
38         sei
39         lda     $01
40         pha
41         lda     #$34            ; enable RAM under I/O
42         sta     $01
43
44         ldy     #$00
45 .if SOFT80COLORVOODOO = 1
46         jsr     soft80_putcolor
47 .else
48         lda     CHARCOLOR
49         sta     (CRAM_PTR),y    ; vram
50 .endif
51
52         lda     CURS_X
53         and     #$01
54         tax
55 @lp1:
56         lda     (SCREEN_PTR),y
57         eor     nibble,x
58         sta     (SCREEN_PTR),y
59         iny
60         cpy     #8
61         bne     @lp1
62
63         pla
64         sta     $01
65         cli
66         rts
67
68         .rodata
69 nibble: .byte $f0, $0f