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 ; ------------------------------------------------------------------------
25 jsr gotoxy ; Set cursor, drop x and y
28 ; Plot a character - also used as internal function
30 _cputc: cmp #$0A ; CR?
34 beq plot ; Recalculate pointers
37 beq newline ; Recalculate pointers
39 ; Printable char of some sort
42 bcc cputdirect ; Other control char
48 bne cputdirect ; Branch always
52 jsr putchar ; Write the character to the screen
54 ; Advance cursor position
60 jsr newline ; new line
65 ; Handle character if high bit set
70 lda #$5E ; Load screen code for PI
73 bne cputdirect ; Branch always
75 ; Move the cursor into the next line
80 ; Set cursor position, calculate RAM pointers
88 add #.hibyte(COLOR_RAM - __VIDRAM_START__)
92 ; Write one character to the screen without doing anything else, return X
96 ora RVS ; Set revers bit
98 sta (SCREEN_PTR),y ; Set char
103 sta (CRAM_PTR),y ; Set color
107 ; -------------------------------------------------------------------------
108 ; Low bytes of the start address of the screen lines
114 .byte .lobyte(__VIDRAM_START__ + I * 40)
117 ; -------------------------------------------------------------------------
118 ; High bytes of the start address of the screen lines
122 .byte .hibyte(__VIDRAM_START__ + I * 40)