1
0
mirror of https://github.com/cc65/cc65.git synced 2024-10-01 00:57:11 +00:00
cc65/libsrc/pce/cputc.s

94 lines
2.3 KiB
ArmAsm
Raw Normal View History

;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
2015-07-12 12:27:24 +00:00
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import PLOT
2015-07-12 12:27:24 +00:00
.importzp tmp3,tmp4
2015-07-12 12:27:24 +00:00
.include "pce.inc"
_cputcxy:
2015-07-12 12:27:24 +00:00
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
pla ; Restore C
; Plot a character - also used as internal function
2015-07-12 12:27:24 +00:00
_cputc: cmp #$0d ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
2015-07-12 12:27:24 +00:00
L1: cmp #$0a ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
cputdirect:
2015-07-12 12:27:24 +00:00
jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
2015-07-12 12:27:24 +00:00
ldy CURS_X
iny
cpy #xsize
bne L3
jsr newline ; new line
ldy #0 ; + cr
L3: sty CURS_X
jmp plot
newline:
2015-07-12 12:27:24 +00:00
inc CURS_Y
; Set cursor position, calculate RAM pointers
2015-07-12 12:27:24 +00:00
plot: ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
2015-07-12 12:27:24 +00:00
ora RVS ; Set revers bit
tax
2015-07-12 12:27:24 +00:00
st0 #VDC_MAWR ; Memory Adress Write
2015-07-12 12:27:24 +00:00
lda SCREEN_PTR
staio VDC_DATA_LO
2015-07-12 12:27:24 +00:00
lda SCREEN_PTR+1
staio VDC_DATA_HI
2015-07-12 12:27:24 +00:00
st0 #VDC_VWR ; VWR
2015-07-12 12:27:24 +00:00
txa
staio VDC_DATA_LO ; character
2015-07-12 12:27:24 +00:00
lda CHARCOLOR
2015-07-12 12:27:24 +00:00
asl a
asl a
asl a
asl a
2015-07-12 12:27:24 +00:00
and #$f0
ora #$02
staio VDC_DATA_HI
2015-07-12 12:27:24 +00:00
rts