1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

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"
.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
lda #$00
sta BGCOLOR_CHANGE
lda BGCOLOR ; Return last color
ldy #$00
sty BGCOLOR_CHANGE
rts
out:
@ -24,5 +23,3 @@ out:
txa ; Return previous color
rts
.endproc

View File

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

View File

@ -5,7 +5,7 @@
; void gotoxy (unsigned char x, unsigned char y);
;
.export gotoxy, _gotoxy, _update_adscr
.export gotoxy, _gotoxy, update_adscr
.import popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE
@ -21,7 +21,7 @@ gotoxy: jsr popa ; Get Y
jsr popa
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
lda #$01
sta CHARCOLOR_CHANGE
@ -30,7 +30,7 @@ gotoxy: jsr popa ; Get Y
.endproc
.proc _update_adscr
.proc update_adscr
lda #<SCREEN
sta ADSCRL
@ -51,4 +51,4 @@ skip:
bne loop
out:
rts
.endproc
.endproc

View File

@ -4,13 +4,13 @@
.export _gotoy
.import CHARCOLOR_CHANGE, BGCOLOR_CHANGE
.import _update_adscr
.import update_adscr
.include "telestrat.inc"
.proc _gotoy
sta SCRY
jsr _update_adscr
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

View File

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