]> git.sur5r.net Git - cc65/blob - libsrc/cbm610/cgetc.s
Replace hard returns with an "else", add an error for non-IDENT tokens, and test...
[cc65] / libsrc / cbm610 / cgetc.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
3 ;
4 ; char cgetc (void);
5 ;
6
7         .export         _cgetc
8         .import         plot, write_crtc
9         .import         cursor
10
11         .import         keyidx: zp, keybuf: zp, config: zp
12
13
14
15 _cgetc: lda     keyidx          ; Get number of characters
16         bne     L2              ; Jump if there are already chars waiting
17
18 ; Switch on the cursor if needed
19
20         lda     cursor
21         beq     L1              ; Jump if no cursor
22
23         jsr     plot            ; Set the current cursor position
24         ldy     #10
25         lda     config          ; Cursor format
26         jsr     write_crtc      ; Set the cursor formar
27
28 L1:     lda     keyidx
29         beq     L1
30
31         ldy     #10
32         lda     #$20            ; Cursor off
33         jsr     write_crtc
34
35 L2:     ldx     #$00            ; Get index
36         ldy     keybuf          ; Get first character in the buffer
37         sei
38 L3:     lda     keybuf+1,x      ; Move up the remaining chars
39         sta     keybuf,x
40         inx
41         cpx     keyidx
42         bne     L3
43         dec     keyidx
44         cli
45
46         ldx     #$00            ; High byte
47         tya                     ; First char from buffer
48         rts
49
50