Tip is Comment every line.
Ex)
while i < HARDCODED_LIMIT:
# Break when text index is out of range
if text_char_index >= text_len:
break
# Load text's ascii number
eax = ord(text[text_char_index])
# Increase text index
text_char_index += 1
# Load encode array's Nth data (if indexth text's ascii is 116, load 26)
eax = TEXT_ENCODE_ARRAY[eax]
# If Nth char is not a character(0~9a~zA~Z), then break
if eax < 0: # This code is wrong, (0xff < 0) is False
break
Then try to make code in high-level language
text: str = "Hello"
text.replace("t", "\x1a")
In this level, unusable code is snipped such as
esi = eax & 0xFF # eax is smaller than 0xff (eax is Nth data of ENCODE_ARRAY.bin), so this code is same as esi = eax
Change bitwise operator to human friendly operator
esi = esi << 0xB # This could be
esi = esi * 2048 # and, this could be
esi *= 2048
Try to change common function to def func1()
I think, it seems that the above is repeated
Just make a function code and fill in the changing part with parameters
Then you can read it easily, you can change it to asm code, make decode function, make decode asm code.
PS. If you don't understand bitwise operators, leave them as bitwise operator.