Fix typo and optimize

This commit is contained in:
jede 2019-07-07 22:02:48 +02:00 committed by greg-king5
parent 28eba8bff9
commit a0a6537bda
5 changed files with 21 additions and 22 deletions

View file

@ -7,12 +7,11 @@
.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 textcolor call with the same color 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 bne out ; Yes
lda #$00
sta BGCOLOR_CHANGE
lda BGCOLOR ; Return last color ldy #$00
sty BGCOLOR_CHANGE
rts rts
out: out:
@ -24,5 +23,3 @@ out:
txa ; Return previous color txa ; Return previous color
rts rts
.endproc .endproc

View file

@ -11,18 +11,20 @@
.proc _cputc .proc _cputc
ldx CHARCOLOR_CHANGE ldx CHARCOLOR_CHANGE
beq do_not_change_color_foreground beq do_not_change_color_foreground
dec SCRX
dec SCRX
pha pha
lda CHARCOLOR lda CHARCOLOR
BRK_TELEMON $4E ; Change color on the screen (foreground) BRK_TELEMON $4E ; Change color on the screen (foreground)
lda #$00 lda #$00
sta CHARCOLOR_CHANGE sta CHARCOLOR_CHANGE
inc SCRX
pla pla
do_not_change_color_foreground: do_not_change_color_foreground:
ldx BGCOLOR_CHANGE ldx BGCOLOR_CHANGE
beq do_not_change_color beq do_not_change_color
dec SCRX ; Dec SCRX in order to place attribute before the right position
pha pha
lda BGCOLOR lda BGCOLOR
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
@ -36,6 +38,7 @@ do_not_change_color:
BRK_TELEMON XFWR ; Macro send char to screen (channel 0) BRK_TELEMON XFWR ; Macro send char to screen (channel 0)
rts rts
.endproc .endproc
.bss
CHARCOLOR: CHARCOLOR:
.res 1 .res 1
CHARCOLOR_CHANGE: CHARCOLOR_CHANGE:

View file

@ -5,7 +5,7 @@
; void gotoxy (unsigned char x, unsigned char y); ; void gotoxy (unsigned char x, unsigned char y);
; ;
.export gotoxy, _gotoxy, _update_adscr .export gotoxy, _gotoxy, update_adscr
.import popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE .import popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE
@ -21,7 +21,7 @@ gotoxy: jsr popa ; Get Y
jsr popa jsr popa
sta SCRX sta SCRX
jsr _update_adscr ; Update adress video ram position when SCRY et SCRX are modified 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 ; Force to put again attribute when it moves on the screen
lda #$01 lda #$01
sta CHARCOLOR_CHANGE sta CHARCOLOR_CHANGE
@ -30,7 +30,7 @@ gotoxy: jsr popa ; Get Y
.endproc .endproc
.proc _update_adscr .proc update_adscr
lda #<SCREEN lda #<SCREEN
sta ADSCRL sta ADSCRL
@ -51,4 +51,4 @@ skip:
bne loop bne loop
out: out:
rts rts
.endproc .endproc

View file

@ -4,13 +4,13 @@
.export _gotoy .export _gotoy
.import CHARCOLOR_CHANGE, BGCOLOR_CHANGE .import CHARCOLOR_CHANGE, BGCOLOR_CHANGE
.import _update_adscr .import update_adscr
.include "telestrat.inc" .include "telestrat.inc"
.proc _gotoy .proc _gotoy
sta SCRY sta SCRY
jsr _update_adscr jsr update_adscr
; We change the current line, it means that we need to put color attributes again. ; 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 ; That is not the case with _gotox because, it's on the same line attribute are already set

View file

@ -7,22 +7,21 @@
.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 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 bne out ; yes
lda #$00
sta CHARCOLOR_CHANGE
lda CHARCOLOR ; return last color ldy #$00
sty CHARCOLOR_CHANGE
lda CHARCOLOR ; Return last color
rts rts
out: out:
ldx CHARCOLOR ; get last color in order to return it ldx CHARCOLOR ; Get last color in order to return it
sta CHARCOLOR sta CHARCOLOR
lda #$01 lda #$01
sta CHARCOLOR_CHANGE sta CHARCOLOR_CHANGE
txa ; return previous color txa ; Return previous color
rts rts
.endproc .endproc