2 ; cputc/cputcxy for Challenger 1P
3 ; Based on PET/CBM implementation
5 ; void cputcxy (unsigned char x, unsigned char y, char c);
8 .export _cputcxy, _cputc, cputdirect, putchar
18 jsr _gotoxy ; Set cursor, drop x
21 ; Plot a character - also used as internal function
23 _cputc: cmp #$0A ; CR?
27 beq plot ; Recalculate pointers
30 beq newline ; Recalculate pointers
33 jsr putchar ; Write the character to the screen
35 ; Advance cursor position
38 cpy SCR_LINELEN ; xsize-1
40 jsr newline ; new line
49 cmp #24 ; screen height 25 lines hardcoded
51 lda #0 ; wrap around to line 0
61 ; Write one character to the screen without doing anything else, return X
66 sta (SCREEN_PTR),y ; Set char
69 ; Screen address tables - offset to real screen
73 ScrLo: .byte $83, $A3, $C3, $E3, $03, $23, $43, $63
74 .byte $83, $A3, $C3, $E3, $03, $23, $43, $63
75 .byte $83, $A3, $C3, $E3, $03, $23, $43, $63
78 ScrHi: .byte $D0, $D0, $D0, $D0, $D1, $D1, $D1, $D1
79 .byte $D1, $D1, $D1, $D1, $D2, $D2, $D2, $D2
80 .byte $D2, $D2, $D2, $D2, $D3, $D3, $D3, $D3