]> git.sur5r.net Git - cc65/blob - libsrc/atmos/cgetc.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / atmos / cgetc.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-13
3 ;
4 ; char cgetc (void);
5 ;
6
7         .export         _cgetc
8         .constructor    initcgetc
9         .import         cursor
10
11         .include        "atmos.inc"
12
13
14
15 ; ------------------------------------------------------------------------
16 ;
17
18 .proc   _cgetc
19
20         lda     KEYBUF          ; Do we have a character?
21         bmi     @L2             ; Yes: Get it
22
23 ; No character, enable cursor and wait
24
25         lda     cursor          ; Cursor currently off?
26         beq     @L1             ; Skip if so
27         lda     STATUS
28         ora     #%00000001      ; Cursor ON
29         sta     STATUS
30 @L1:    lda     KEYBUF
31         bpl     @L1
32
33 ; If the cursor was enabled, disable it now
34
35         ldx     cursor
36         beq     @L2
37         ldx     #$00            ; Zero high byte
38         dec     STATUS          ; Clear bit zero
39
40 ; We have the character, clear avail flag
41
42 @L2:    and     #$7F            ; Mask out avail flag
43         sta     KEYBUF
44         ldy     $209
45         cpy     #$A5
46         bne     @L3
47         ora     #$80            ; FUNCT pressed
48
49 ; Done
50
51 @L3:    rts
52
53 .endproc
54
55 ; ------------------------------------------------------------------------
56 ; Switch the cursor off, disable capslock. Code goes into the INIT segment
57 ; which may be reused after it is run.
58
59 .segment        "INIT"
60
61 initcgetc:
62         lda     STATUS
63         and     #%11111110
64         sta     STATUS
65         lda     #$7F
66         sta     CAPSLOCK
67         rts
68