]> git.sur5r.net Git - cc65/blob - libsrc/apple2/cputc.s
The constructor doesn't have any interaction with other constructors so there seems...
[cc65] / libsrc / apple2 / cputc.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
3 ;
4 ; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
5 ; void __fastcall__ cputc (char c);
6 ;
7
8         .ifdef  __APPLE2ENH__
9         .constructor    initconio
10         .endif
11         .export         _cputcxy, _cputc
12         .export         cputdirect, newline, putchar
13         .import         popa, _gotoxy, VTABZ
14
15         .include        "apple2.inc"
16
17         .segment        "INIT"
18
19         .ifdef  __APPLE2ENH__
20 initconio:
21         sta     SETALTCHAR      ; Switch in alternate charset
22         bit     LORES           ; Limit SET80COL-HISCR to text
23         rts
24         .endif
25
26         .code
27
28 ; Plot a character - also used as internal function
29
30 _cputcxy:
31         pha                     ; Save C
32         jsr     popa            ; Get Y
33         jsr     _gotoxy
34         pla                     ; Restore C
35
36 _cputc:
37         cmp     #$0D            ; Test for \r = carrage return
38         beq     left
39         cmp     #$0A            ; Test for \n = line feed
40         beq     newline
41         ora     #$80            ; Turn on high bit
42         .ifndef __APPLE2ENH__
43         cmp     #$E0            ; Test for lowercase
44         bcc     cputdirect
45         and     #$DF            ; Convert to uppercase
46         .endif
47
48 cputdirect:
49         jsr     putchar
50         inc     CH              ; Bump to next column
51         lda     CH
52         cmp     WNDWDTH
53         bcc     :+
54 left:   lda     #$00            ; Goto left edge of screen
55         sta     CH
56 :       rts
57
58 newline:
59         inc     CV              ; Bump to next line
60         lda     CV
61         cmp     WNDBTM
62         bcc     :+
63         lda     WNDTOP          ; Goto top of screen
64         sta     CV
65 :       jmp     VTABZ
66                 
67 putchar:
68         .ifdef  __APPLE2ENH__
69         ldy     INVFLG
70         cpy     #$FF            ; Normal character display mode?
71         beq     put
72         cmp     #$E0            ; Lowercase?
73         bcc     mask
74         and     #$7F            ; Inverse lowercase
75         bra     put
76         .endif
77 mask:   and     INVFLG          ; Apply normal, inverse, flash
78 put:    ldy     CH
79         .ifdef  __APPLE2ENH__
80         bit     RD80VID         ; In 80 column mode?
81         bpl     col40           ; No, in 40 cols
82         pha
83         tya
84         lsr                     ; Div by 2
85         tay
86         pla
87         bcs     col40           ; Odd cols go in 40 col memory
88         bit     HISCR           ; Assume SET80COL
89         sta     (BASL),Y
90         bit     LOWSCR          ; Assume SET80COL
91         rts
92         .endif
93 col40:  sta     (BASL),Y
94         rts