1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00
cc65/libsrc/telestrat/cputc.s

101 lines
1.8 KiB
ArmAsm
Raw Normal View History

2018-04-14 19:52:11 +00:00
; 2018-04-13, Jede (jede@oric.org)
;
; void cputc (char c);
;
.export _cputc, _cputcxy, cputdirect, display_conio
.export CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR
2022-04-17 14:06:22 +00:00
2021-03-01 21:33:12 +00:00
.import update_adscr
.import popax
2018-04-14 19:52:11 +00:00
.include "telestrat.inc"
2021-03-08 20:16:44 +00:00
2021-03-01 21:33:12 +00:00
_cputcxy:
pha ; Save C
jsr popax ; Get X and Y
sta SCRY ; Store Y
stx SCRX ; Store X
2021-03-01 21:33:12 +00:00
jsr update_adscr
2022-04-17 14:06:22 +00:00
pla
2021-03-01 21:33:12 +00:00
2021-03-08 20:16:44 +00:00
_cputc:
2021-03-01 21:33:12 +00:00
cmp #$0D
bne @not_CR
ldy #$00
2022-04-17 14:06:22 +00:00
sty SCRX
2021-03-01 21:33:12 +00:00
rts
@not_CR:
cmp #$0A
2021-03-08 20:16:44 +00:00
bne not_LF
2021-03-01 21:33:12 +00:00
inc SCRY
jmp update_adscr
2021-03-08 20:16:44 +00:00
cputdirect:
not_LF:
2019-07-17 19:48:53 +00:00
ldx CHARCOLOR
cpx OLD_CHARCOLOR
2019-07-06 08:16:57 +00:00
beq do_not_change_color_foreground
2019-07-17 19:48:53 +00:00
stx OLD_CHARCOLOR ; Store CHARCOLOR into OLD_CHARCOLOR
2019-07-06 08:16:57 +00:00
pha
2019-07-17 19:48:53 +00:00
txa ; Swap X to A because, X contains CHARCOLOR
2021-03-01 21:33:12 +00:00
jsr display_conio
2019-07-06 08:16:57 +00:00
pla
do_not_change_color_foreground:
2019-07-17 19:48:53 +00:00
ldx BGCOLOR
cpx OLD_BGCOLOR
2019-07-06 08:16:57 +00:00
beq do_not_change_color
2019-07-17 19:48:53 +00:00
stx OLD_BGCOLOR
2019-07-06 08:16:57 +00:00
pha
txa ; Swap X to A because, X contains BGCOLOR
2021-03-01 21:33:12 +00:00
ora #%00010000 ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
jsr display_conio
2019-07-06 08:16:57 +00:00
pla
do_not_change_color:
2021-03-01 21:33:12 +00:00
; it continues to display_conio
2021-03-08 20:16:44 +00:00
2021-03-01 21:33:12 +00:00
.proc display_conio
2021-03-01 22:19:30 +00:00
; This routine is used to displays char on screen
2021-03-01 21:33:12 +00:00
ldy SCRX
sta (ADSCR),y
iny
cpy #SCREEN_XSIZE
bne @no_inc
ldy #$00
sty SCRX
2021-03-09 21:02:26 +00:00
inc SCRY
2022-04-17 14:06:22 +00:00
2021-03-01 21:33:12 +00:00
jmp update_adscr
2022-04-17 14:06:22 +00:00
@no_inc:
2021-03-01 21:33:12 +00:00
sty SCRX
2018-04-14 19:52:11 +00:00
rts
.endproc
2021-03-01 21:33:12 +00:00
2019-07-07 20:02:48 +00:00
.bss
2019-07-06 08:16:57 +00:00
CHARCOLOR:
.res 1
2019-07-17 19:48:53 +00:00
OLD_CHARCOLOR:
.res 1
2019-07-06 08:16:57 +00:00
BGCOLOR:
.res 1
2019-07-17 19:48:53 +00:00
OLD_BGCOLOR:
.res 1
2021-03-01 21:33:12 +00:00