1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-02 18:06:48 +00:00
cc65/libsrc/pce/cputc.s

99 lines
2.1 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
.import gotoxy
2015-08-29 13:58:57 +00:00
.import PLOT
.import xsize
2015-08-29 13:58:57 +00:00
.importzp tmp3,tmp4
.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-08-29 13:58:57 +00:00
_cputc: cmp #$0d ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
2015-08-29 13:58:57 +00:00
L1: cmp #$0a ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
cputdirect:
2015-08-29 13:58:57 +00:00
jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
2015-08-29 13:58:57 +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-08-29 13:58:57 +00:00
inc CURS_Y
; Set cursor position, calculate RAM pointers
2015-08-29 13:58:57 +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-08-29 13:58:57 +00:00
ora RVS ; Set revers bit
2015-07-12 12:27:24 +00:00
2015-08-29 13:58:57 +00:00
tax
2015-08-29 13:58:57 +00:00
st0 #VDC_MAWR ; Memory Adress Write
2015-08-29 13:58:57 +00:00
lda SCREEN_PTR
sta a:VDC_DATA_LO
2015-08-29 13:58:57 +00:00
lda SCREEN_PTR + 1
sta a:VDC_DATA_HI
2015-08-29 13:58:57 +00:00
st0 #VDC_VWR ; VWR
2015-08-29 13:58:57 +00:00
txa
sta a:VDC_DATA_LO ; character
2015-08-29 13:58:57 +00:00
lda CHARCOLOR
2015-08-29 13:58:57 +00:00
asl a
asl a
asl a
asl a
2015-08-29 13:58:57 +00:00
ora #$02
sta a:VDC_DATA_HI
2015-08-29 13:58:57 +00:00
rts
;-------------------------------------------------------------------------------
; force the init constructor to be imported
2015-08-29 13:58:57 +00:00
.import initconio
conio_init = initconio