Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Try to perform RepeatPress
- ld a, l ; Get ptr to RepeatPressCounter (will be used even if RepeatPress is disabled)
- add a, Menu_RepeatPressCounter - Menu_EnableRepeatPress
- ld e, a
- adc a, h
- sub e
- ld d, a
- ld b, 0 ; Start by supposing no button will be RepeatPress'd
- ; If any (non-ignored) button is pressed, stop RepeatPress
- ldh a, [hPressedButtons]
- and c ; It's fine to do this, since a pressed button is held anyways
- jr z, .dontResetRepeatPress
- xor a
- ld [de], a
- .dontResetRepeatPress
- ld a, [hli] ; Read EnableRepeatPress
- and a
- jr z, .skipRepeatPress
- ld a, c ; Get held buttons
- and PADF_DOWN | PADF_UP | PADF_LEFT | PADF_RIGHT ; Get d-pad only
- ; Check if exactly 1 direction is being held
- jr z, .skipRepeatPress ; If 0, don't do anything
- .getFirstDirection
- add a, a
- jr nc, .getFirstDirection ; Keep going until the first bit is shifted out
- jr nz, .skipRepeatPress ; If more bits remain, more than 1 button is being held, so skip
- ; So, only 1 direction is being held, and if it has just been pressed, the state is currently zero
- ; Increment the counter
- ld a, [de]
- inc a
- ld [de], a
- cp 32
- jr c, .skipRepeatPress ; Unless the counter reaches 32, don't do anything
- ld a, 30
- ld [de], a ; Reset counter (to apply delay)
- ld a, c
- and PADF_DOWN | PADF_UP | PADF_LEFT | PADF_RIGHT
- ld b, a ; Mark this button as RepeatPress'd
- .skipRepeatPress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement