]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80mono_cgetc.s
8d8dc940db12ae767b931e0bf2d5506ff38d2513
[cc65] / libsrc / c64 / soft80mono_cgetc.s
1 ;
2 ; Groepaz/Hitmen, 19.10.2015
3 ;
4 ; high level implementation for the monochrome soft80 implementation
5 ;
6 ; char cgetc (void);
7 ;
8
9         .export         soft80mono_cgetc
10         .import         soft80mono_internal_cellcolor, soft80mono_internal_cursorxlsb
11         .import         soft80mono_internal_nibble
12         .import         cursor
13         .importzp       tmp1
14
15         .include        "cbm_kernal.inc"
16         .include        "c64.inc"
17         .include        "soft80.inc"
18
19 soft80mono_cgetc:
20         lda     KEY_COUNT       ; Get number of characters
21         bne     @L3             ; Jump if there are already chars waiting
22
23         jsr     invertcursor    ; set cursor on or off accordingly
24
25 @L1:    lda     KEY_COUNT       ; wait for key
26         beq     @L1
27
28         jsr     invertcursor    ; set cursor on or off accordingly
29
30 @L3:    jsr     KBDREAD         ; Read char and return in A
31         ldx     #0
32         rts
33
34 ; Switch the cursor on or off (invert)
35
36 invertcursor:
37         lda     cursor
38         bne     @invert
39         rts
40 @invert:
41
42         sei
43         lda     $01             ; enable RAM under I/O
44         pha
45         lda     #$34
46         sta     $01
47
48         ldy     #$00
49         ldx     soft80mono_internal_cursorxlsb
50 @lp1:
51         lda     (SCREEN_PTR),y
52         eor     soft80mono_internal_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 ;-------------------------------------------------------------------------------
64 ; force the init constructor to be imported
65
66         .import soft80mono_init
67 conio_init      = soft80mono_init