2 ; Ullrich von Bassewitz, 14.09.2001
4 ; void cputcxy (unsigned char x, unsigned char y, char c);
8 .export _cputcxy, _cputc, cputdirect, putchar
12 .import __VIDRAM_START__
13 .import CURS_X: zp, CURS_Y: zp, CHARCOLOR: zp, RVS: zp
14 .import SCREEN_PTR: zp, CRAM_PTR: zp
20 ; ------------------------------------------------------------------------
26 jsr _gotoxy ; Set cursor, drop x
29 ; Plot a character - also used as internal function
31 _cputc: cmp #$0A ; CR?
35 beq plot ; Recalculate pointers
38 beq newline ; Recalculate pointers
40 ; Printable char of some sort
43 bcc cputdirect ; Other control char
49 bne cputdirect ; Branch always
53 jsr putchar ; Write the character to the screen
55 ; Advance cursor position
61 jsr newline ; new line
66 ; Handle character if high bit set
71 lda #$5E ; Load screen code for PI
74 bne cputdirect ; Branch always
76 ; Move the cursor into the next line
81 ; Set cursor position, calculate RAM pointers
89 add #.hibyte(COLOR_RAM - __VIDRAM_START__)
93 ; Write one character to the screen without doing anything else, return X
97 ora RVS ; Set revers bit
99 sta (SCREEN_PTR),y ; Set char
104 sta (CRAM_PTR),y ; Set color
108 ; -------------------------------------------------------------------------
109 ; Low bytes of the start address of the screen lines
115 .byte .lobyte(__VIDRAM_START__ + I * 40)
118 ; -------------------------------------------------------------------------
119 ; High bytes of the start address of the screen lines
123 .byte .hibyte(__VIDRAM_START__ + I * 40)