2 ; 2003-04-13, Ullrich von Bassewitz
3 ; 2013-07-16, Greg King
5 ; void cputcxy (unsigned char x, unsigned char y, char c);
9 .export _cputcxy, _cputc
10 .export setscrptr, putchar
11 .constructor initcputc
21 jsr popax ; Get X and Y
26 ; Plot a character - also used as internal function
28 _cputc: cmp #$0D ; CR?
31 sta CURS_X ; Carriage return
39 ; Output the character, then advance the cursor position
53 ; ------------------------------------------------------------------------
54 ; Set ptr2 to the screen, load the X offset into Y
59 ldy CURS_Y ; Get line number into Y
60 lda ScrTabLo,y ; Get low byte of line address
62 lda ScrTabHi,y ; Get high byte of line address
64 ldy CURS_X ; Get X offset
69 ; ------------------------------------------------------------------------
70 ; Write one character to the screen without doing anything else, return X
76 ora rvs ; Set revers bit
78 jsr setscrptr ; Set ptr2 to the screen
79 pla ; Restore the character
80 sta (ptr2),y ; Set char
85 ; ------------------------------------------------------------------------
86 ; Screen address table
90 .repeat SCREEN_YSIZE, Line
91 .byte <(SCREEN + Line * SCREEN_XSIZE)
95 .repeat SCREEN_YSIZE, Line
96 .byte >(SCREEN + Line * SCREEN_XSIZE)
99 ; ------------------------------------------------------------------------
100 ; Switch the cursor off. Code goes into the ONCE segment,
101 ; which will be reused after it is run.
107 asl STATUS ; Clear bit zero