]> git.sur5r.net Git - cc65/blob - libsrc/atari/cgetc.s
New module fileio-test.c
[cc65] / libsrc / atari / cgetc.s
1 ;
2 ; Christian Groessler, November-2002
3 ;
4 ; get a char from the keyboard
5 ; char cgetc(void)
6 ;
7
8         .include "atari.inc"
9         .export _cgetc
10         .import cursor
11         
12 _cgetc:
13         jsr     setcursor
14         jsr     @1
15         ldx     #0
16         rts
17
18 @1:     lda     KEYBDV+5
19         pha
20         lda     KEYBDV+4
21         pha
22         lda     #12
23         sta     ICAX1Z          ; fix problems with direct call to KEYBDV
24         rts
25
26
27 .proc   setcursor
28
29         lda     OLDCHR          ; get char at current cursor position
30         ldy     #0              ; needed later
31
32         ldx     cursor          ; current cursor setting as requested by the user
33         beq     off
34         ldx     #0
35         beq     cont
36
37 off:    inx
38 cont:   stx     CRSINH          ; update system variable
39
40         beq     turnon
41         and     #$7f            ; clear high bit / inverse flag
42 finish: sta     (OLDADR),y      ; update on-screen display
43         rts
44
45 turnon: ora     #$80            ; set high bit / inverse flag
46         bne     finish
47
48 .endproc