]> git.sur5r.net Git - cc65/blob - libsrc/cbm610/cputc.s
Use external symbols for the CBM kernal jump table functions. This allows
[cc65] / libsrc / cbm610 / 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, cputdirect, putchar
9         .export         newline, plot
10         .exportzp       CURS_X, CURS_Y
11
12         .import         PLOT
13         .import         _gotoxy
14         .import         popa
15         .import         xsize, revers
16
17         .include        "cbm610.inc"
18
19
20 _cputcxy:
21         pha                     ; Save C
22         jsr     popa            ; Get Y
23         jsr     _gotoxy         ; Set cursor, drop x
24         pla                     ; Restore C
25
26 ; Plot a character - also used as internal function
27
28 _cputc: cmp     #$0A            ; CR?
29         bne     L1
30         lda     #0
31         sta     CURS_X
32         beq     plot            ; Recalculate pointers
33
34 L1:     cmp     #$0D            ; LF?
35         beq     newline         ; Recalculate pointers
36
37 ; Printable char of some sort
38
39         cmp     #' '
40         bcc     cputdirect      ; Other control char
41         tay
42         bmi     L10
43         cmp     #$60
44         bcc     L2
45         and     #$DF
46         bne     cputdirect      ; Branch always
47 L2:     and     #$3F
48
49 cputdirect:
50         jsr     putchar         ; Write the character to the screen
51
52 ; Advance cursor position
53
54 advance:
55         iny
56         cpy     xsize
57         bne     L3
58         jsr     newline         ; new line
59         ldy     #0              ; + cr
60 L3:     sty     CURS_X
61         rts
62
63 newline:
64         clc
65         lda     xsize
66         adc     CharPtr
67         sta     CharPtr
68         bcc     L4
69         inc     CharPtr+1
70 L4:     inc     CURS_Y
71         rts
72
73 ; Handle character if high bit set
74
75 L10:    and     #$7F
76         cmp     #$7E            ; PI?
77         bne     L11
78         lda     #$5E            ; Load screen code for PI
79         bne     cputdirect
80 L11:    ora     #$40
81         bne     cputdirect      ; Branch always
82
83 ; Set cursor position, calculate RAM pointers
84
85 plot:   ldy     CURS_X
86         ldx     CURS_Y
87         clc
88         jmp     PLOT
89
90 ; Write one character to the screen without doing anything else, return X
91 ; position in Y
92
93 putchar:
94         ldx     IndReg
95         ldy     #$0F
96         sty     IndReg
97         ora     revers          ; Set revers bit
98         ldy     CURS_X
99         sta     (CharPtr),y     ; Set char
100         stx     IndReg
101         rts
102
103