diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-12-18 17:49:51 -0500 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-12-18 17:49:51 -0500 |
commit | c4a8131994a6ab13498d4932cd77129c2eda3f0d (patch) | |
tree | ed5fd776ff39278ffa2d428a4805483508f7b79f /Improve-the-event-initialization-system.md | |
parent | 6473ab02d5d5423f4bef6e8054b43385a27d7d9e (diff) |
Optimize
Diffstat (limited to 'Improve-the-event-initialization-system.md')
-rw-r--r-- | Improve-the-event-initialization-system.md | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Improve-the-event-initialization-system.md b/Improve-the-event-initialization-system.md index c55e6ed..5b7da03 100644 --- a/Improve-the-event-initialization-system.md +++ b/Improve-the-event-initialization-system.md @@ -194,16 +194,20 @@ $ tools/free_space.py pokecrystal.map Free space: 455295/2097152 (21.71%) ``` -That's 72 more ROM bytes than before. It's not a whole lot, but every bit helps. You can eke out a few more by applying the tricks from the [assembly optimization tutorial](Optimizing-assembly-code) to `InitializeEvents`: it was written more for clarity than to save space. For example, all three `cp -1` can become `inc a` to save three bytes *and* run a little faster. Or you can optimize the entire `.sprites_loop` using the "[Add `a` to an address](Optimizing-assembly-code#add-a-to-an-address)" technique: +That's 72 more ROM bytes than before. It's not a whole lot, but every bit helps. + +You can eke out a few more by applying the tricks from the [assembly optimization tutorial](Optimizing-assembly-code) to `InitializeEvents`: it was written more for clarity than to save space. For example, all three `cp -1` can become `inc a` (the "[Compare `a` to 255](Optimizing-assembly-code#compare-a-to-255)" technique) to save three bytes *and* run a little faster. And you can optimize the entire `.sprites_loop` using the "[Add `a` to an address](Optimizing-assembly-code#add-a-to-an-address)" technique: ```diff .sprites_loop ld a, [hli] - ld e, a - ld d, 0 - cp -1 +- cp -1 ++ inc a ret z -+ add LOW(wVariableSprites) ++ ; subtract 1 to balance the previous 'inc' ++ add LOW(wVariableSprites) - 1 + ld e, a + adc HIGH(wVariableSprites) + sub e |