a4f04fe
From 411fe87f64f57dd3b2469214fdbca01a121b4569 Mon Sep 17 00:00:00 2001
a4f04fe
From: Oliver Schmidt <ol.sc@web.de>
a4f04fe
Date: Thu, 2 Apr 2020 22:14:22 +0200
a4f04fe
Subject: [PATCH 169/170] Fixed tolower() and toupper() to save high byte.
a4f04fe
a4f04fe
---
a4f04fe
 libsrc/common/tolower.s | 21 +++++++++++----------
a4f04fe
 libsrc/common/toupper.s | 21 +++++++++++----------
a4f04fe
 2 files changed, 22 insertions(+), 20 deletions(-)
a4f04fe
a4f04fe
diff --git a/libsrc/common/tolower.s b/libsrc/common/tolower.s
a4f04fe
index e672f077..bebac3c5 100644
a4f04fe
--- a/libsrc/common/tolower.s
a4f04fe
+++ b/libsrc/common/tolower.s
a4f04fe
@@ -12,16 +12,17 @@
a4f04fe
 
a4f04fe
         .export         _tolower
a4f04fe
         .include        "ctype.inc"
a4f04fe
-        .import         ctype_preprocessor
a4f04fe
+        .import         ctype_preprocessor_no_check
a4f04fe
 
a4f04fe
 _tolower:
a4f04fe
-        tay                             ; save char
a4f04fe
-        jsr     ctype_preprocessor      ; (always clears X)
a4f04fe
-        bcc     @L2                     ; out of range?
a4f04fe
-@L1:    tya                             ; if so, return the argument unchanged
a4f04fe
-        rts
a4f04fe
-@L2:    and     #CT_UPPER               ; upper case char?
a4f04fe
-        beq     @L1                     ; jump if no
a4f04fe
-        tya                             ; restore char
a4f04fe
-        adc     #<('a'-'A')             ; make lower case char (ctype_preprocessor ensures carry clear)
a4f04fe
+        cpx     #$00            ; out of range?
a4f04fe
+        bne     @L2             ; if so, return the argument unchanged
a4f04fe
+        tay                     ; save char
a4f04fe
+        jsr     ctype_preprocessor_no_check
a4f04fe
+        and     #CT_UPPER       ; upper case char?
a4f04fe
+        beq     @L1             ; jump if no
a4f04fe
+        tya                     ; restore char
a4f04fe
+        adc     #<('a'-'A')     ; make lower case char (ctype_preprocessor_no_check ensures carry clear)
a4f04fe
         rts
a4f04fe
+@L1:    tya                     ; restore char
a4f04fe
+@L2:    rts
a4f04fe
diff --git a/libsrc/common/toupper.s b/libsrc/common/toupper.s
a4f04fe
index 5b3a4c22..ed3dd9b0 100644
a4f04fe
--- a/libsrc/common/toupper.s
a4f04fe
+++ b/libsrc/common/toupper.s
a4f04fe
@@ -12,16 +12,17 @@
a4f04fe
 
a4f04fe
         .export         _toupper
a4f04fe
         .include        "ctype.inc"
a4f04fe
-        .import         ctype_preprocessor
a4f04fe
+        .import         ctype_preprocessor_no_check
a4f04fe
 
a4f04fe
 _toupper:
a4f04fe
-        tay                             ; save char
a4f04fe
-        jsr     ctype_preprocessor      ; (always clears X)
a4f04fe
-        bcc     @L2                     ; out of range?
a4f04fe
-@L1:    tya                             ; if so, return the argument unchanged
a4f04fe
-        rts
a4f04fe
-@L2:    and     #CT_LOWER               ; lower case char?
a4f04fe
-        beq     @L1                     ; jump if no
a4f04fe
-        tya                             ; restore char
a4f04fe
-        adc     #<('A'-'a')             ; make upper case char (ctype_preprocessor ensures carry clear)
a4f04fe
+        cpx     #$00            ; out of range?
a4f04fe
+        bne     @L2             ; if so, return the argument unchanged
a4f04fe
+        tay                     ; save char
a4f04fe
+        jsr     ctype_preprocessor_no_check
a4f04fe
+        and     #CT_LOWER       ; lower case char?
a4f04fe
+        beq     @L1             ; jump if no
a4f04fe
+        tya                     ; restore char
a4f04fe
+        adc     #<('A'-'a')     ; make upper case char (ctype_preprocessor_no_check ensures carry clear)
a4f04fe
         rts
a4f04fe
+@L1:    tya                     ; restore char
a4f04fe
+@L2:    rts
a4f04fe
-- 
a4f04fe
2.26.0
a4f04fe