ref: 38cd2155df1953c065d8c66bcd44125afde75051
parent: 0d5cf5c8b9066b407f8dc1879dad56d53f5d0179
author: The Void <[email protected]>
date: Thu Aug 11 19:28:35 EDT 2022
Bug Doc: Options menu fails to clear joypad state on initialization (#984)
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -103,6 +103,7 @@
- [`ReadObjectEvents` overflows into `wObjectMasks`](#readobjectevents-overflows-into-wobjectmasks)
- [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1)
- [`BattleAnimCmd_ClearObjs` only clears the first 6⅔ objects](#battleanimcmd_clearobjs-only-clears-the-first-6-objects)
+ - [Options menu fails to clear joypad state on initialization](#options-menu-fails-to-clear-joypad-state-on-initialization)
## Multi-player battle engine
@@ -2628,4 +2629,22 @@
dec a
jr nz, .loop
ret
+```
+
+
+### Options menu fails to clear joypad state on initialization
+
+([Video](https://www.youtube.com/watch?v=uhDSIkXkl3g))
+
+This bug allows all the options to be updated at once if the left or right buttons are pressed on the same frame that the options menu is opened.
+
+**Fix:** Edit `_Option` in [engine/menus/options_menu.asm](https://github.com/pret/pokecrystal/blob/master/engine/menus/options_menu.asm):
+
+```diff
+ _Option:
+-; BUG: Options menu fails to clear joypad state on initialization (see docs/bugs_and_glitches.md)
++ call ClearJoypad
+ ld hl, hInMenu
+ ld a, [hl]
+ push af
```
--- a/engine/menus/options_menu.asm
+++ b/engine/menus/options_menu.asm
@@ -11,6 +11,7 @@
DEF NUM_OPTIONS EQU const_value ; 8
_Option:
+; BUG: Options menu fails to clear joypad state on initialization (see docs/bugs_and_glitches.md)
ld hl, hInMenu
ld a, [hl]
push af