Lets Build Ocarina of Time Part 3
Hover Boot Data Analysis
In our ongoing journey to explore the inner workings of Ocarina of Time using Rust, we've arrived at a crucial juncture: understanding the Hover Boots. In this technical article, we'll delve into the specifics without the thrill but with a focus on clarity.
Recall that in the previous article, we examined the Kokiri boots and deciphered three out of their 17 values. Now, we turn our attention to the Hover Boots, which exhibit more differences when compared to the Kokiri boots. Our goal is to shed light on these differences and comprehend their significance.
Let's start by examining the data for the Hover Boots:
The analysis yields the following insights:
- The first difference corresponds to a faster animation speed.
- The second difference pertains to a slightly slower movement speed.
- The remaining values remain unknown to us.
Our immediate objective is to decipher these four unknown values. However, before diving into the technical details, let's pause and consider the time and effort required to test each value. It involves compiling, loading, saving, and booting up the game, which can be tedious.
Instead of this time-consuming approach, we can leverage our intuition to glean insights from the code itself.
Leveraging Intuition for Code Analysis
First, let's revisit the setBootsData function, which plays a pivotal role in boot-related behavior:
From our previous analysis, we know that bootRegs[7] influences animation speed, and REG(38) is related to it. Similarly, REG(45) = bootRegs[9] affects movement speed.
Now, consider which of these two values—animation speed or movement speed—is likely to have a more significant impact on the game's calculations. We lean towards movement speed.
With this assumption in mind, we search for instances in the codebase where REG(45) is employed.
Following the Code Trail
Our investigation leads us to a file called regs.h:
This is the only location where REG(45) is defined in regs.h. Unfortunately, we don't find additional definitions there.
However, we discover that regs.h is also the only file where REG(45) appears. This prompts us to search for places in the code where R_RUN_SPEED_LIMIT is used.
Our search brings us to a file called z_player.c, where we find references to R_RUN_SPEED_LIMIT. Looking over this file,
we see a LOT of code, structs, and references to the player, game, and save contexts. It's fair to assume that this file
must do a lot of the actual heavy-lifting for Link's behavior.
Deciphering the Boot Value's Significance
In summary, our investigation yields the following insights into this boot value:
- Different boots possess varying quantities of this value.
- The code checks Link's boots at every game step, using this value.
- The code loads the value into
REG(45)and assigns it toR_RUN_SPEED_LIMIT. - The game leverages
R_RUN_SPEED_LIMITto perform calculations related to Link's behavior.
In our next installment, we'll dig deeper into the code inside z_player.c that utilizes R_RUN_SPEED_LIMIT.
This next article will be far more complicated, but even more fun! See you soon.
The Ocarina of Time code comes from https://github.com/zeldaret/oot and is thanks to the hard work of many open-source developers. Please consider supporting their awesome work.