lower() and upper() now also return the lenght of the processed string.

This commit is contained in:
Irmen de Jong 2021-04-21 20:21:58 +02:00
parent dd379430d9
commit 1c2e6f9e4c
3 changed files with 20 additions and 9 deletions

View File

@ -190,8 +190,8 @@ _found sty P8ZP_SCRATCH_B1
}} }}
} }
asmsub lower(uword st @AY) { asmsub lower(uword st @AY) -> ubyte @Y {
; Lowercases the petscii string in-place. ; Lowercases the petscii string in-place. Returns length of the string.
; (for efficiency, non-letter characters > 128 will also not be left intact, ; (for efficiency, non-letter characters > 128 will also not be left intact,
; but regular text doesn't usually contain those characters anyway.) ; but regular text doesn't usually contain those characters anyway.)
%asm {{ %asm {{
@ -213,8 +213,8 @@ _done rts
}} }}
} }
asmsub upper(uword st @AY) { asmsub upper(uword st @AY) -> ubyte @Y {
; Uppercases the petscii string in-place. ; Uppercases the petscii string in-place. Returns length of the string.
%asm {{ %asm {{
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1 sty P8ZP_SCRATCH_W1+1

View File

@ -91,7 +91,7 @@ main {
txt.print("is it a ") txt.print("is it a ")
txt.print(animals[animal_number]) txt.print(animals[animal_number])
txt.print("? ") txt.print("? ")
txt.input_chars(userinput) void txt.input_chars(userinput)
if userinput[0] == 'y' { if userinput[0] == 'y' {
txt.print("\n\nsee, i knew it!\n") txt.print("\n\nsee, i knew it!\n")
return return
@ -99,18 +99,18 @@ main {
str name = "x"*30 str name = "x"*30
txt.print("\n\ni give up. what is it? ") txt.print("\n\ni give up. what is it? ")
txt.input_chars(name) void txt.input_chars(name)
txt.print("\nwhat yes-no question would best articulate the difference\nbetween a ") txt.print("\nwhat yes-no question would best articulate the difference\nbetween a ")
txt.print(animals[animal_number]) txt.print(animals[animal_number])
txt.print(" and a ") txt.print(" and a ")
txt.print(name) txt.print(name)
txt.print("? ") txt.print("? ")
txt.input_chars(userinput) void txt.input_chars(userinput)
txt.print("\nfor a ") txt.print("\nfor a ")
txt.print(name) txt.print(name)
txt.print(", what is the answer to that; yes or no? ") txt.print(", what is the answer to that; yes or no? ")
str answer = "x"*10 str answer = "x"*10
txt.input_chars(answer) void txt.input_chars(answer)
animals[new_animal_number] = animal_names_ptr animals[new_animal_number] = animal_names_ptr
questions[new_question_number] = questions_ptr questions[new_question_number] = questions_ptr

View File

@ -1,11 +1,22 @@
%import textio %import textio
%import string
%zeropage basicsafe %zeropage basicsafe
%import test_stack %import test_stack
%option no_sysinit
main { main {
sub start() { sub start() {
txt.print("♠♥♣♦π▚●○╳") ubyte xx=existing_entry(1,2)
}
; TODO FIX COMPILER ERROR ABOUT MISSING RETURN
sub existing_entry(ubyte hash, uword symbol) -> ubyte {
if hash>10
return 44
else
return false
} }
} }