Blame 0021-Fix-typo-and-optimize.patch

f26de6
From a0a6537bdaa29743ceea170ee4884ab018da7369 Mon Sep 17 00:00:00 2001
f26de6
From: jede <jede@oric.org>
f26de6
Date: Sun, 7 Jul 2019 22:02:48 +0200
f26de6
Subject: [PATCH 21/29] Fix typo and optimize
f26de6
f26de6
---
f26de6
 libsrc/telestrat/bgcolor.s   |  9 +++------
f26de6
 libsrc/telestrat/cputc.s     |  7 +++++--
f26de6
 libsrc/telestrat/gotoxy.s    |  8 ++++----
f26de6
 libsrc/telestrat/gotoy.s     |  4 ++--
f26de6
 libsrc/telestrat/textcolor.s | 15 +++++++--------
f26de6
 5 files changed, 21 insertions(+), 22 deletions(-)
f26de6
f26de6
diff --git a/libsrc/telestrat/bgcolor.s b/libsrc/telestrat/bgcolor.s
f26de6
index 4af0ef76..14ecf4bd 100644
f26de6
--- a/libsrc/telestrat/bgcolor.s
f26de6
+++ b/libsrc/telestrat/bgcolor.s
f26de6
@@ -7,12 +7,11 @@
f26de6
         .include        "telestrat.inc"
f26de6
 
f26de6
 .proc _bgcolor
f26de6
-    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
f26de6
+    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
f26de6
     bne     out           ; Yes
f26de6
-    lda     #$00
f26de6
-    sta     BGCOLOR_CHANGE
f26de6
     
f26de6
-    lda     BGCOLOR       ; Return last color
f26de6
+    ldy     #$00
f26de6
+    sty     BGCOLOR_CHANGE
f26de6
 
f26de6
     rts
f26de6
 out:
f26de6
@@ -24,5 +23,3 @@ out:
f26de6
     txa                   ; Return previous color
f26de6
     rts
f26de6
 .endproc
f26de6
-
f26de6
-
f26de6
diff --git a/libsrc/telestrat/cputc.s b/libsrc/telestrat/cputc.s
f26de6
index f38db8a1..96763caf 100644
f26de6
--- a/libsrc/telestrat/cputc.s
f26de6
+++ b/libsrc/telestrat/cputc.s
f26de6
@@ -11,18 +11,20 @@
f26de6
 .proc _cputc
f26de6
     ldx     CHARCOLOR_CHANGE
f26de6
     beq     do_not_change_color_foreground
f26de6
-
f26de6
+    dec     SCRX
f26de6
+    dec     SCRX
f26de6
     pha
f26de6
     lda     CHARCOLOR
f26de6
     BRK_TELEMON  $4E             ; Change color on the screen (foreground)
f26de6
     lda     #$00
f26de6
     sta     CHARCOLOR_CHANGE
f26de6
+    inc     SCRX
f26de6
     pla
f26de6
 
f26de6
 do_not_change_color_foreground:
f26de6
     ldx     BGCOLOR_CHANGE
f26de6
     beq     do_not_change_color
f26de6
-
f26de6
+    dec     SCRX                 ; Dec SCRX in order to place attribute before the right position
f26de6
     pha
f26de6
     lda     BGCOLOR
f26de6
     ORA     #%00010000           ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
f26de6
@@ -36,6 +38,7 @@ do_not_change_color:
f26de6
     BRK_TELEMON  XFWR            ; Macro send char to screen (channel 0)
f26de6
     rts
f26de6
 .endproc
f26de6
+.bss
f26de6
 CHARCOLOR:
f26de6
     .res 1
f26de6
 CHARCOLOR_CHANGE:
f26de6
diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s
f26de6
index 73e7d272..8dcb69e8 100644
f26de6
--- a/libsrc/telestrat/gotoxy.s
f26de6
+++ b/libsrc/telestrat/gotoxy.s
f26de6
@@ -5,7 +5,7 @@
f26de6
 ; void gotoxy (unsigned char x, unsigned char y);
f26de6
 ;
f26de6
 
f26de6
-        .export         gotoxy, _gotoxy, _update_adscr
f26de6
+        .export         gotoxy, _gotoxy, update_adscr
f26de6
 
f26de6
         .import         popa, CHARCOLOR_CHANGE, BGCOLOR_CHANGE
f26de6
 
f26de6
@@ -21,7 +21,7 @@ gotoxy: jsr     popa            ; Get Y
f26de6
         jsr     popa
f26de6
         sta     SCRX
f26de6
         
f26de6
-        jsr     _update_adscr          ; Update adress video ram position when SCRY et SCRX are modified
f26de6
+        jsr     update_adscr          ; Update adress video ram position when SCRY et SCRX are modified
f26de6
         ;       Force to put again attribute when it moves on the screen
f26de6
         lda     #$01
f26de6
         sta     CHARCOLOR_CHANGE
f26de6
@@ -30,7 +30,7 @@ gotoxy: jsr     popa            ; Get Y
f26de6
 .endproc
f26de6
 
f26de6
 
f26de6
-.proc _update_adscr
f26de6
+.proc update_adscr
f26de6
         lda     #
f26de6
         sta     ADSCRL
f26de6
 
f26de6
@@ -51,4 +51,4 @@ skip:
f26de6
         bne     loop
f26de6
 out:        
f26de6
         rts
f26de6
-.endproc
f26de6
\ No newline at end of file
f26de6
+.endproc
f26de6
diff --git a/libsrc/telestrat/gotoy.s b/libsrc/telestrat/gotoy.s
f26de6
index ee437f00..ae6a0bcf 100644
f26de6
--- a/libsrc/telestrat/gotoy.s
f26de6
+++ b/libsrc/telestrat/gotoy.s
f26de6
@@ -4,13 +4,13 @@
f26de6
     .export    _gotoy
f26de6
     .import    CHARCOLOR_CHANGE, BGCOLOR_CHANGE
f26de6
 
f26de6
-    .import    _update_adscr
f26de6
+    .import    update_adscr
f26de6
 
f26de6
     .include   "telestrat.inc"
f26de6
 
f26de6
 .proc _gotoy
f26de6
    sta     SCRY
f26de6
-   jsr     _update_adscr
f26de6
+   jsr     update_adscr
f26de6
 
f26de6
    ; We change the current line, it means that we need to put color attributes again.
f26de6
    ; That is not the case with _gotox because, it's on the same line attribute are already set
f26de6
diff --git a/libsrc/telestrat/textcolor.s b/libsrc/telestrat/textcolor.s
f26de6
index 6c635268..b5584902 100644
f26de6
--- a/libsrc/telestrat/textcolor.s
f26de6
+++ b/libsrc/telestrat/textcolor.s
f26de6
@@ -7,22 +7,21 @@
f26de6
         .include        "telestrat.inc"
f26de6
 
f26de6
 .proc _textcolor
f26de6
-    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
f26de6
+    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
f26de6
     bne     out             ; yes
f26de6
-    lda     #$00
f26de6
-    sta     CHARCOLOR_CHANGE
f26de6
     
f26de6
-    lda     CHARCOLOR       ; return last color
f26de6
+    ldy     #$00
f26de6
+    sty     CHARCOLOR_CHANGE
f26de6
+    
f26de6
+    lda     CHARCOLOR       ; Return last color
f26de6
 
f26de6
     rts
f26de6
 out:
f26de6
-    ldx     CHARCOLOR       ; get last color in order to return it
f26de6
+    ldx     CHARCOLOR       ; Get last color in order to return it
f26de6
     sta     CHARCOLOR
f26de6
 
f26de6
     lda     #$01
f26de6
     sta     CHARCOLOR_CHANGE
f26de6
-    txa                     ; return previous color
f26de6
+    txa                     ; Return previous color
f26de6
     rts
f26de6
 .endproc
f26de6
-
f26de6
-
f26de6
-- 
f26de6
2.21.0
f26de6