XXX4Fans
Cuyler from patreon
Cuyler

patreon


July 2019 Patch Release [Patch #16]

This month's patch brings some big changes behind the scenes through massive code rewrites. As I promised in June's patch release post, I dedicated most of my available time this month to fixing code bugs and localizing code where I could. I'm going to talk about the changes in depth, so feel free to skip that if it doesn't interest you.

Code changes in a pre-built binary tend to be annoying, especially when dealing with limited free space. I completely rewrote several functions, and modified a few others. When rewriting code for this translation, I usually just overwrite the original function that the developers wrote. The issue with that is that I have to try to keep the same complexity with the new code I wrote, otherwise it won't fit within the space left by the old one. Usually I can resolve that by turning on compiler optimizations, but in one case this month, I had to delve into the world of hand written assembly to fit a function in.

mED_get_single_line_width is the function responsible for calculating the text width for a single-line editor window. Examples of these windows are: player name entry, catchphrase entry, K.K. song request entry, etc. The function is fairly small, consisting of only 28 instructions. The logic behind my change isn't vastly different, but it did require calling another function, mFont_GetCodeWidthW. That function returns the width of a given character. Using it fixed the size calculation, as the original e+ developers left each character as a static size of 12. This call required two additional instructions over the original function's size of 28. These two instructions set up the argument registers for calling the function, so they cannot be removed. I tried to improve the size of the code for quite some time, but nothing worked. Eventually to forego the PowerPC assembler standard and do some weird optimizations. Usually in PowerPC assembly, the address of the instruction after the one which called the current function is stored on the stack. This is done by two instructions:

mflr r0
stw r0 0xXX(r1)

At the end of the function, the link register is restored to that address so program execution can be returned to the calling function:
lwz r0, 0xXX(r1)
// stack would be cleaned here
mtlr r0
blr

My solution was to remove the stw and lwz by storing the return address in a persistent register. This reduced the total instruction count by 2, bringing us back to exactly 28 instructions, and solving the size problem! It's worth noting that this should only be done in extreme cases, because it's not great to ignore the standard.

Now, let's get to the changes! There are about 500 newly translated dialogs this month, and a ton of code changes!

Changes

Plans for Next Month

I'm still working on the title screen. It's really hard to get everything working just right, but I hope to have some screenshots sometime around mid-August! I'll also be finishing up villager trade dialog and hopefully get to villager painting your house dialog as well! I'll also be making the e-reader+ exclusive K.K. songs requestable so they aren't restricted any longer!

Once again, thank you for your support! We're getting closer to the patch's completion every month!


Related Creators