mirror of
https://github.com/cc65/cc65.git
synced 2025-08-12 02:25:03 +00:00
Fix bug with bgcolor and textcolor
This commit is contained in:
@@ -3,23 +3,10 @@
|
||||
|
||||
.export _bgcolor
|
||||
.import BGCOLOR
|
||||
.import BGCOLOR_CHANGE
|
||||
|
||||
.include "telestrat.inc"
|
||||
|
||||
.proc _bgcolor
|
||||
cmp BGCOLOR ; Do we set the same color? If we don't detect it, we loose one char on the screen for each bgcolor call with the same color
|
||||
bne out ; Yes
|
||||
|
||||
ldy #$00
|
||||
sty BGCOLOR_CHANGE
|
||||
|
||||
rts
|
||||
out:
|
||||
ldx BGCOLOR ; Get last color in order to return it
|
||||
sta BGCOLOR
|
||||
|
||||
lda #$01 ; Notify the change color
|
||||
sta BGCOLOR_CHANGE
|
||||
txa ; Return previous color
|
||||
rts
|
||||
.endproc
|
||||
|
@@ -3,9 +3,8 @@
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.import OLD_CHARCOLOR, OLD_BGCOLOR, CHARCOLOR, BGCOLOR
|
||||
|
||||
|
||||
.import CHARCOLOR_CHANGE, CHARCOLOR, BGCOLOR, BGCOLOR_CHANGE
|
||||
.include "telestrat.inc"
|
||||
|
||||
.proc _clrscr
|
||||
@@ -35,12 +34,13 @@
|
||||
dex
|
||||
stx SCRX
|
||||
|
||||
stx CHARCOLOR_CHANGE
|
||||
stx BGCOLOR_CHANGE
|
||||
; X is equal to 0
|
||||
stx BGCOLOR
|
||||
stx OLD_BGCOLOR
|
||||
|
||||
lda #$07
|
||||
sta CHARCOLOR
|
||||
sta BGCOLOR
|
||||
sta OLD_CHARCOLOR
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
@@ -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:
|
||||
OLD_BGCOLOR:
|
||||
.res 1
|
||||
|
@@ -3,13 +3,8 @@
|
||||
;
|
||||
.export _gotox
|
||||
|
||||
.import popa
|
||||
|
||||
.importzp sp
|
||||
|
||||
.include "telestrat.inc"
|
||||
|
||||
|
||||
.proc _gotox
|
||||
sta SCRX
|
||||
rts
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
.export gotoxy, _gotoxy, update_adscr
|
||||
|
||||
.import popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE
|
||||
.import popa, OLD_CHARCOLOR, OLD_BGCOLOR
|
||||
|
||||
.include "telestrat.inc"
|
||||
|
||||
@@ -17,22 +17,24 @@ gotoxy: jsr popa ; Get Y
|
||||
|
||||
; This function moves only the display cursor; it does not move the prompt position.
|
||||
; In telemon, there is a position for the prompt, and another for the cursor.
|
||||
|
||||
sta SCRY
|
||||
jsr update_adscr ; Update adress video ram position when SCRY is modified
|
||||
|
||||
jsr popa
|
||||
sta SCRX
|
||||
|
||||
jsr update_adscr ; Update adress video ram position when SCRY et SCRX are modified
|
||||
; Force to put again attribute when it moves on the screen
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc update_adscr
|
||||
|
||||
lda #$01
|
||||
sta CHARCOLOR_CHANGE
|
||||
sta BGCOLOR_CHANGE
|
||||
; Force to set again color if cursor moves
|
||||
; $FF is used because we know that it's impossible to have this value with a color
|
||||
; It prevents a bug : If bgcolor or textcolor is set to black for example with no char displays,
|
||||
; next cputsxy will not set the attribute if y coordinate changes
|
||||
lda #$FF
|
||||
sta OLD_CHARCOLOR
|
||||
sta OLD_BGCOLOR
|
||||
|
||||
lda #<SCREEN
|
||||
sta ADSCRL
|
||||
|
@@ -10,8 +10,5 @@
|
||||
.proc _gotoy
|
||||
sta SCRY
|
||||
jsr update_adscr
|
||||
|
||||
; We change the current line, it means that we need to put color attributes again.
|
||||
; That is not the case with _gotox because, it's on the same line attribute are already set
|
||||
rts
|
||||
.endproc
|
||||
|
@@ -3,25 +3,9 @@
|
||||
|
||||
.export _textcolor
|
||||
.import CHARCOLOR
|
||||
.import CHARCOLOR_CHANGE
|
||||
.include "telestrat.inc"
|
||||
|
||||
.proc _textcolor
|
||||
cmp CHARCOLOR ; Do we set the same color? If we don't detect it, we loose one char on the screen for each textcolor call with the same color
|
||||
bne out ; yes
|
||||
|
||||
ldy #$00
|
||||
sty CHARCOLOR_CHANGE
|
||||
|
||||
; Return last color
|
||||
|
||||
rts
|
||||
out:
|
||||
ldx CHARCOLOR ; Get last color in order to return it
|
||||
sta CHARCOLOR
|
||||
|
||||
lda #$01
|
||||
sta CHARCOLOR_CHANGE
|
||||
txa ; Return previous color
|
||||
rts
|
||||
.endproc
|
||||
|
Reference in New Issue
Block a user