Skip to content

Commit 4c56fa7

Browse files
committed
finish first decomp example
1 parent 9fc9632 commit 4c56fa7

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/decomp-guide/nothing.typ

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,35 @@ And that's that.
262262

263263
2. Why are functions that do nothing even in the game?
264264

265-
This is a commonly asked question
265+
This is a commonly asked question for a good reason and there are multiple answers.
266+
267+
A common reason might be that the original game code
268+
had certain debugging code that might have been stripped out
269+
during the release build.
270+
There are at least 35 empty functions that contain the word "debug" that do nothing.
271+
`zNPCBPlankton::render_debug()` for example.
272+
You can imagine that the actual source code for this probably looked something like this:
273+
```cpp
274+
void zNPCBPlankton::render_debug()
275+
{
276+
#ifdef DEBUG
277+
// ...
278+
// A bunch of code to debug the plankton boss...
279+
// ...
280+
#endif
281+
}
282+
```
283+
Naturally when releasing, none of that code would have been included,
284+
leaving us with empty functions.
285+
These functions are still included in the game
286+
and not optimized out by the compiler despite being empty in this case
287+
because they are called from other areas of the code.
288+
The compiler isn't smart enough to know that the function call itself
289+
wouldn't create side effects, so it keeps the function in the game
290+
despite it doing nothing in a release build.
291+
292+
Whew. This was a longer chapter than anticipated,
293+
but we have learned quite a lot.
294+
Whenever you're ready let's head on to the next example
295+
and start decompiling functions that have
296+
some actual code in them.

0 commit comments

Comments
 (0)