mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Fix bug with bgcolor and textcolor
This commit is contained in:
parent
6f7f6b5119
commit
ede64f68a9
@ -3,23 +3,10 @@
|
|||||||
|
|
||||||
.export _bgcolor
|
.export _bgcolor
|
||||||
.import BGCOLOR
|
.import BGCOLOR
|
||||||
.import BGCOLOR_CHANGE
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _bgcolor
|
.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
|
sta BGCOLOR
|
||||||
|
|
||||||
lda #$01 ; Notify the change color
|
|
||||||
sta BGCOLOR_CHANGE
|
|
||||||
txa ; Return previous color
|
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export _clrscr
|
.export _clrscr
|
||||||
|
.import OLD_CHARCOLOR, OLD_BGCOLOR, CHARCOLOR, BGCOLOR
|
||||||
|
|
||||||
.import CHARCOLOR_CHANGE, CHARCOLOR, BGCOLOR, BGCOLOR_CHANGE
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _clrscr
|
.proc _clrscr
|
||||||
@ -34,13 +33,14 @@
|
|||||||
stx SCRY
|
stx SCRY
|
||||||
dex
|
dex
|
||||||
stx SCRX
|
stx SCRX
|
||||||
|
|
||||||
stx CHARCOLOR_CHANGE
|
; X is equal to 0
|
||||||
stx BGCOLOR_CHANGE
|
stx BGCOLOR
|
||||||
|
stx OLD_BGCOLOR
|
||||||
|
|
||||||
lda #$07
|
lda #$07
|
||||||
sta CHARCOLOR
|
sta CHARCOLOR
|
||||||
sta BGCOLOR
|
sta OLD_CHARCOLOR
|
||||||
|
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -4,34 +4,39 @@
|
|||||||
; void cputc (char c);
|
; void cputc (char c);
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _cputc, CHARCOLOR, CHARCOLOR_CHANGE, BGCOLOR, BGCOLOR_CHANGE
|
.export _cputc, CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR
|
||||||
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _cputc
|
.proc _cputc
|
||||||
ldx CHARCOLOR_CHANGE
|
ldx CHARCOLOR
|
||||||
|
cpx OLD_CHARCOLOR
|
||||||
beq do_not_change_color_foreground
|
beq do_not_change_color_foreground
|
||||||
|
|
||||||
|
stx OLD_CHARCOLOR ; Store CHARCOLOR into OLD_CHARCOLOR
|
||||||
|
|
||||||
dec SCRX
|
dec SCRX
|
||||||
dec SCRX
|
dec SCRX
|
||||||
|
|
||||||
pha
|
pha
|
||||||
lda CHARCOLOR
|
txa ; Swap X to A because, X contains CHARCOLOR
|
||||||
BRK_TELEMON XFWR ; Change color on the screen (foreground)
|
BRK_TELEMON XFWR ; Change color on the screen (foreground)
|
||||||
lda #$00
|
|
||||||
sta CHARCOLOR_CHANGE
|
|
||||||
inc SCRX
|
inc SCRX
|
||||||
pla
|
pla
|
||||||
|
|
||||||
do_not_change_color_foreground:
|
do_not_change_color_foreground:
|
||||||
ldx BGCOLOR_CHANGE
|
ldx BGCOLOR
|
||||||
|
cpx OLD_BGCOLOR
|
||||||
beq do_not_change_color
|
beq do_not_change_color
|
||||||
|
|
||||||
|
stx OLD_BGCOLOR
|
||||||
|
|
||||||
dec SCRX ; Dec SCRX in order to place attribute before the right position
|
dec SCRX ; Dec SCRX in order to place attribute before the right position
|
||||||
|
|
||||||
pha
|
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
|
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)
|
BRK_TELEMON XFWR ; Change color on the screen (background)
|
||||||
lda #$00
|
|
||||||
sta BGCOLOR_CHANGE
|
|
||||||
|
|
||||||
pla
|
pla
|
||||||
|
|
||||||
do_not_change_color:
|
do_not_change_color:
|
||||||
@ -41,9 +46,9 @@ do_not_change_color:
|
|||||||
.bss
|
.bss
|
||||||
CHARCOLOR:
|
CHARCOLOR:
|
||||||
.res 1
|
.res 1
|
||||||
CHARCOLOR_CHANGE:
|
OLD_CHARCOLOR:
|
||||||
.res 1
|
.res 1
|
||||||
BGCOLOR:
|
BGCOLOR:
|
||||||
.res 1
|
|
||||||
BGCOLOR_CHANGE:
|
|
||||||
.res 1
|
.res 1
|
||||||
|
OLD_BGCOLOR:
|
||||||
|
.res 1
|
||||||
|
@ -3,13 +3,8 @@
|
|||||||
;
|
;
|
||||||
.export _gotox
|
.export _gotox
|
||||||
|
|
||||||
.import popa
|
|
||||||
|
|
||||||
.importzp sp
|
|
||||||
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
|
|
||||||
.proc _gotox
|
.proc _gotox
|
||||||
sta SCRX
|
sta SCRX
|
||||||
rts
|
rts
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
.export gotoxy, _gotoxy, update_adscr
|
.export gotoxy, _gotoxy, update_adscr
|
||||||
|
|
||||||
.import popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE
|
.import popa, OLD_CHARCOLOR, OLD_BGCOLOR
|
||||||
|
|
||||||
.include "telestrat.inc"
|
.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.
|
; 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.
|
; 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
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
.proc update_adscr
|
.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
|
lda #<SCREEN
|
||||||
sta CHARCOLOR_CHANGE
|
sta ADSCRL
|
||||||
sta BGCOLOR_CHANGE
|
|
||||||
|
|
||||||
lda #<SCREEN
|
lda #>SCREEN
|
||||||
sta ADSCRL
|
sta ADSCRH
|
||||||
|
|
||||||
lda #>SCREEN
|
ldy SCRY
|
||||||
sta ADSCRH
|
beq out
|
||||||
|
|
||||||
ldy SCRY
|
|
||||||
beq out
|
|
||||||
loop:
|
loop:
|
||||||
lda ADSCRL
|
lda ADSCRL
|
||||||
clc
|
clc
|
||||||
adc #$28
|
adc #$28
|
||||||
bcc skip
|
bcc skip
|
||||||
inc ADSCRH
|
inc ADSCRH
|
||||||
skip:
|
skip:
|
||||||
sta ADSCRL
|
sta ADSCRL
|
||||||
dey
|
dey
|
||||||
bne loop
|
bne loop
|
||||||
out:
|
out:
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _gotoy
|
.proc _gotoy
|
||||||
sta SCRY
|
sta SCRY
|
||||||
jsr update_adscr
|
jsr update_adscr
|
||||||
|
rts
|
||||||
; 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
|
.endproc
|
||||||
|
@ -3,25 +3,9 @@
|
|||||||
|
|
||||||
.export _textcolor
|
.export _textcolor
|
||||||
.import CHARCOLOR
|
.import CHARCOLOR
|
||||||
.import CHARCOLOR_CHANGE
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _textcolor
|
.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
|
sta CHARCOLOR
|
||||||
|
|
||||||
lda #$01
|
|
||||||
sta CHARCOLOR_CHANGE
|
|
||||||
txa ; Return previous color
|
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user