1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-30 16:29:58 +00:00
cc65/libsrc/pce/cputc.s

83 lines
2.0 KiB
ArmAsm
Raw Normal View History

;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
2015-08-29 13:58:57 +00:00
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.forceimport initconio ; force conio initiation
2015-10-02 14:50:22 +00:00
.import gotoxy
2015-08-29 13:58:57 +00:00
.import PLOT
.import xsize
2015-10-02 14:50:22 +00:00
.importzp tmp3, tmp4
2015-08-29 13:58:57 +00:00
.include "pce.inc"
2015-09-19 13:37:39 +00:00
.include "extzp.inc"
_cputcxy:
2015-08-29 13:58:57 +00:00
pha ; Save C
jsr gotoxy ; Set cursor, drop x and y
2015-08-29 13:58:57 +00:00
pla ; Restore C
; Plot a character - also used as internal function
2015-10-02 14:50:22 +00:00
_cputc: cmp #$0D ; CR?
2015-08-29 13:58:57 +00:00
bne L1
stz CURS_X
bra plot ; Recalculate pointer
2015-10-02 14:50:22 +00:00
L1: cmp #$0A ; LF?
2015-11-17 14:14:15 +00:00
beq newline ; Recalculate pointer
; Printable char of some sort
cputdirect:
2015-08-29 13:58:57 +00:00
jsr putchar ; Write the character to the screen
; Move the cursor (rightwards) to the next position.
advance:
2015-08-29 13:58:57 +00:00
ldy CURS_X
iny
cpy xsize
bne L3
inc CURS_Y ; new line
cly ; + CR
2015-08-29 13:58:57 +00:00
L3: sty CURS_X
2015-11-17 14:14:15 +00:00
; Set cursor position; calculate VRAM pointer.
2015-08-29 13:58:57 +00:00
plot: ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
newline:
inc CURS_Y
bra plot
2015-11-17 14:14:15 +00:00
; Write one character to the screen without doing anything else.
putchar:
ora RVS ; Set reverse bit
st0 #VDC_MAWR ; Memory-Address Write
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
st0 #VDC_VWR ; VRAM Write Register
sta VDC_DATA_LO ; character
lda CHARCOLOR ; palette number
2015-08-29 13:58:57 +00:00
asl a
asl a
asl a
asl a
ora #>$0200 ; high nybble of char. index
sta VDC_DATA_HI
2015-08-29 13:58:57 +00:00
rts