]> git.sur5r.net Git - cc65/blob - libsrc/apple2/cputc.s
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / apple2 / cputc.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
3 ;
4 ; void cputcxy (unsigned char x, unsigned char y, char c);
5 ; void cputc (char c);
6 ;
7
8         .export         _cputcxy, _cputc
9         .export         _gotoxy, cputdirect
10         .export         newline, putchar
11
12         .import         popa
13
14         .include        "apple2.inc"
15
16 ; Plot a character - also used as internal function
17
18 _cputcxy:
19         pha                     ; Save C
20         jsr     popa            ; Get Y
21         jsr     _gotoxy
22         pla                     ; Restore C
23
24 _cputc:
25         cmp     #$0D            ; Test for \r = carrage return
26         bne     L1
27         lda     #$00            ; Goto left edge of screen
28         sta     CH
29         rts                     ; That's all we do
30 L1:
31         cmp     #$0A            ; Test for \n = line feed
32         beq     newline
33
34 cputdirect:
35         jsr     putchar
36         ;; Bump to next column
37         inc     CH
38         lda     CH
39         cmp     MAX_X
40         bne     return
41         lda     #$00
42         sta     CH
43 return: 
44         rts
45
46 putchar:        
47         ora     #$80            ; Turn on high bit
48         and     TEXTTYP         ; Apply normal, inverse, flash
49         ldy     CH
50         ldx     RD80COL         ; In 80 column mode?
51         bpl     col40           ; No, in 40 cols
52         pha
53         tya
54         lsr                     ; Div by 2
55         tay
56         pla
57         bcs     col40           ; odd cols go in 40 col memory
58         sta     PG2ON
59 col40:  sta     (BASL),Y
60         sta     PG2OFF
61         rts
62
63 newline:
64         lda     CH
65         pha
66         inc     CV
67         lda     CV
68         cmp     MAX_Y
69         bne     L2
70         lda     #$00
71         sta     CV
72 L2:
73         jsr     VTABZ
74         pla
75         sta     CH
76         rts
77                 
78 _gotoxy:
79         sta     CV              ; Store Y
80         jsr     VTABZ
81         jsr     popa            ; Get X
82         sta     CH              ; Store X
83         rts
84
85