diff --git a/Improving-the-WaitForVBlank-function.md b/Improving-the-WaitForVBlank-function.md index 0e7c4d8..ef28091 100644 --- a/Improving-the-WaitForVBlank-function.md +++ b/Improving-the-WaitForVBlank-function.md @@ -19,9 +19,9 @@ static void WaitForVBlank(void) + VBlankIntrWait(); } ``` +One thing to note is that on agbcc's `-O2`, we still pay the price of a function call, as `VBlankIntrWait` fails to be inlined. In general, agbcc is very conservative on optimizations. Most other decent optimizing compilers (or if you `make modern`) will inline the function. -Alternatively, we can do what the `VBlankIntrWait` function does in a more direct manner, which is unnoticeably faster. - +A solution is to inline it ourselves, for a negligible performance benefit: ```diff static void WaitForVBlank(void) { @@ -32,4 +32,4 @@ static void WaitForVBlank(void) } ``` -Save, build a ROM, and so the game will utilize the full power of the GBA's CPU in order to draw things on screen. The easiest way to notice this is while running the game on a GBA emulator with a FastForward feature implemented, where implementing this fix will give you a 100-150% increase in speed. \ No newline at end of file +Save, build a ROM, and so the game will no longer waste CPU power while it is waiting for the next VBlank. The easiest way to notice this is while running the game on a GBA emulator with a FastForward feature implemented, where implementing this fix will give you a 100-150% increase in speed. \ No newline at end of file