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