ref: 7748b20c271d1802afce53ad6dc87d5d0e1c14b8
parent: 370839cad72da50d6ef4024d9e9ad601755fb0b3
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Tue Dec 12 16:16:15 EST 2017
GetForestTreeFrame is not technically a bug or glitch, but it's exceptional
--- a/docs/bugs.md
+++ b/docs/bugs.md
@@ -687,3 +687,46 @@
```
**Fix:** Change `jr nc, .bank_loop` to `jr c, .bank_loop`.
+
+
+## `GetForestTreeFrame` works, but it's still bad
+
+[tilesets/animations.asm](tilesets/animations.asm):
+
+```
+GetForestTreeFrame: ; fc54c
+; 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
+; fc56d
+```
+
+**Fix:**
+
+```
+GetForestTreeFrame: ; fc54c
+; Return 0 if a is even, or 2 if odd.
+ and 1
+ add a
+ ret
+; fc56d
+```