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