]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_cgetc.s
remove some commented out code
[cc65] / libsrc / c64 / soft80_cgetc.s
1 ;
2 ; Groepaz/Hitmen, 11.10.2015
3 ;
4 ; char cgetc (void);
5 ;
6
7         .export         soft80_cgetc
8         .import         soft80_internal_cursorxlsb
9         .import         cursor
10         .importzp       tmp1
11
12         .include        "c64.inc"
13         .include        "soft80.inc"
14
15 soft80_cgetc:
16         lda     KEY_COUNT       ; Get number of characters
17         bne     L3              ; Jump if there are already chars waiting
18
19         sec
20         jsr     invertcursor    ; set cursor on or off accordingly
21
22 L1:     lda     KEY_COUNT       ; wait for key
23         beq     L1
24
25         clc
26         jsr     invertcursor    ; set cursor on or off accordingly
27
28 L3:     jsr     KBDREAD         ; Read char and return in A
29         ldx     #0
30         rts
31
32 ; Switch the cursor on or off (invert)
33
34 invertcursor:
35         lda     cursor
36         bne     @invert
37         rts
38 @invert:
39
40         sei
41         lda     $01             ; enable RAM under I/O
42         pha
43         lda     #$34
44         sta     $01
45
46         ldy     #$00
47         jsr     setcolor
48
49         ldx     soft80_internal_cursorxlsb
50 @lp1:
51         lda     (SCREEN_PTR),y
52         eor     nibble,x
53         sta     (SCREEN_PTR),y
54         iny
55         cpy     #8
56         bne     @lp1
57
58         pla
59         sta     $01             ; enable I/O
60         cli
61         rts
62
63         ; do not use soft80_putcolor here to make sure the cursor is always
64         ; shown using the current textcolor without disturbing the "color voodoo"
65         ; in soft80_cputc
66 setcolor:
67         ;ldy     #0              ; is 0
68         bcs     @set
69         ; restore old value
70         lda     tmp1
71         sta     (CRAM_PTR),y    ; vram
72         rts
73 @set:
74         ; save old value
75         lda     (CRAM_PTR),y    ; vram
76         sta     tmp1
77         lda     CHARCOLOR
78         sta     (CRAM_PTR),y    ; vram
79         rts
80
81         .rodata
82 nibble: .byte $f0, $0f
83
84 ;-------------------------------------------------------------------------------
85 ; force the init constructor to be imported
86
87         .import soft80_init
88 conio_init      = soft80_init