mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Fix bug with bgcolor and textcolor
This commit is contained in:
parent
6f7f6b5119
commit
ede64f68a9
@ -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 CHARCOLOR_CHANGE, CHARCOLOR, BGCOLOR, BGCOLOR_CHANGE
|
||||
.import OLD_CHARCOLOR, OLD_BGCOLOR, CHARCOLOR, BGCOLOR
|
||||
|
||||
.include "telestrat.inc"
|
||||
|
||||
.proc _clrscr
|
||||
@ -34,13 +33,14 @@
|
||||
stx SCRY
|
||||
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:
|
||||
.res 1
|
||||
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,41 +17,43 @@ 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 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
|
||||
sta SCRY
|
||||
jsr update_adscr ; Update adress video ram position when SCRY is modified
|
||||
|
||||
jsr popa
|
||||
sta SCRX
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc update_adscr
|
||||
; 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 #$01
|
||||
sta CHARCOLOR_CHANGE
|
||||
sta BGCOLOR_CHANGE
|
||||
lda #<SCREEN
|
||||
sta ADSCRL
|
||||
|
||||
lda #<SCREEN
|
||||
sta ADSCRL
|
||||
lda #>SCREEN
|
||||
sta ADSCRH
|
||||
|
||||
lda #>SCREEN
|
||||
sta ADSCRH
|
||||
|
||||
ldy SCRY
|
||||
beq out
|
||||
ldy SCRY
|
||||
beq out
|
||||
loop:
|
||||
lda ADSCRL
|
||||
clc
|
||||
adc #$28
|
||||
bcc skip
|
||||
inc ADSCRH
|
||||
lda ADSCRL
|
||||
clc
|
||||
adc #$28
|
||||
bcc skip
|
||||
inc ADSCRH
|
||||
skip:
|
||||
sta ADSCRL
|
||||
dey
|
||||
bne loop
|
||||
sta ADSCRL
|
||||
dey
|
||||
bne loop
|
||||
out:
|
||||
rts
|
||||
rts
|
||||
.endproc
|
||||
|
@ -8,10 +8,7 @@
|
||||
.include "telestrat.inc"
|
||||
|
||||
.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
|
||||
sta SCRY
|
||||
jsr update_adscr
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user