]> git.sur5r.net Git - cc65/blob - libsrc/c128/cgetc.s
Copy TGI drivers into main lib dir
[cc65] / libsrc / c128 / cgetc.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
3 ;
4 ; char cgetc (void);
5 ;
6
7         .export         _cgetc
8         .import         cursor
9
10         .include        "c128.inc"
11
12 _cgetc: lda     KEY_COUNT       ; Get number of characters
13         bne     L2              ; Jump if there are already chars waiting
14
15 ; Switch on the cursor if needed
16
17         lda     cursor
18         beq     L1
19         jsr     CURS_ON
20         jmp     L2
21 L1:     lda     #$01
22         jsr     CURS_OFF
23 L2:     lda     KEY_COUNT       ; Check characters again
24         beq     L2
25         jsr     CURS_OFF        ; Switch cursor off, if characters available
26
27         jsr     KBDREAD         ; Read char and return in A
28         ldx     #0
29         rts
30
31