ref: 47495e7d66177e1ecfcbe21809e2de79c2beb6d2
parent: fcca48f2a664b255adb21a7dbc5ffa0e2771bac2
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Feb 17 08:38:30 EST 2019
Avoid more redundant code and diffs
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -630,40 +630,36 @@
## `GetForestTreeFrame` works, but it's still bad
-In [engine/tilesets/tileset_anims.asm](/engine/tilesets/tileset_anims.asm):
+The routine `GetForestTreeFrame` in [engine/tilesets/tileset_anims.asm](/engine/tilesets/tileset_anims.asm) is hilariously inefficient.
-```asm
-GetForestTreeFrame:
-; Return 0 if a is even, or 2 if odd.
- and a
- jr z, .even
- cp 1
- jr z, .odd
- cp 2
- jr z, .even
- cp 3
- jr z, .odd
- cp 4
- jr z, .even
- cp 5
- jr z, .odd
- cp 6
- jr z, .even
-.odd
- ld a, 2
- scf
- ret
-.even
- xor a
- ret
-```
-
**Fix:**
+Edit `GetForestTreeFrame`:
+
```asm
-GetForestTreeFrame:
-; Return 0 if a is even, or 2 if odd.
- and 1
- add a
+ GetForestTreeFrame:
+ ; Return 0 if a is even, or 2 if odd.
+- and a
+- jr z, .even
+- cp 1
+- jr z, .odd
+- cp 2
+- jr z, .even
+- cp 3
+- jr z, .odd
+- cp 4
+- jr z, .even
+- cp 5
+- jr z, .odd
+- cp 6
+- jr z, .even
+-.odd
+- ld a, 2
+- scf
+- ret
+-.even
+- xor a
++ and 1
++ add a
ret
```