Fix bug with bgcolor and textcolor

This commit is contained in:
jede
2019-07-17 21:48:53 +02:00
committed by greg-king5
parent 6f7f6b5119
commit ede64f68a9
7 changed files with 59 additions and 89 deletions

View File

@@ -4,34 +4,39 @@
; void cputc (char c);
;
.export _cputc, CHARCOLOR, CHARCOLOR_CHANGE, BGCOLOR, BGCOLOR_CHANGE
.export _cputc, CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR
.include "telestrat.inc"
.proc _cputc
ldx CHARCOLOR_CHANGE
ldx CHARCOLOR
cpx OLD_CHARCOLOR
beq do_not_change_color_foreground
stx OLD_CHARCOLOR ; Store CHARCOLOR into OLD_CHARCOLOR
dec SCRX
dec SCRX
pha
lda CHARCOLOR
txa ; Swap X to A because, X contains CHARCOLOR
BRK_TELEMON XFWR ; Change color on the screen (foreground)
lda #$00
sta CHARCOLOR_CHANGE
inc SCRX
pla
do_not_change_color_foreground:
ldx BGCOLOR_CHANGE
ldx BGCOLOR
cpx OLD_BGCOLOR
beq do_not_change_color
stx OLD_BGCOLOR
dec SCRX ; Dec SCRX in order to place attribute before the right position
pha
lda BGCOLOR
txa ; Swap X to A because, X contains CHARCOLOR
ORA #%00010000 ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
BRK_TELEMON XFWR ; Change color on the screen (background)
lda #$00
sta BGCOLOR_CHANGE
pla
do_not_change_color:
@@ -41,9 +46,9 @@ do_not_change_color:
.bss
CHARCOLOR:
.res 1
CHARCOLOR_CHANGE:
OLD_CHARCOLOR:
.res 1
BGCOLOR:
.res 1
BGCOLOR_CHANGE:
.res 1
OLD_BGCOLOR:
.res 1