Refactorize check button pressed (#340)

This commit is contained in:
Yoann Fievez 2021-11-05 20:40:15 +01:00 committed by GitHub
parent b44a10a43a
commit 8349bfd8e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 71 additions and 71 deletions

View file

@ -5,7 +5,7 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor::
ldh a, [hLoadedROMBank]
push af
ldh a, [hJoyHeld]
bit 0, a ; A button
bit BIT_A_BUTTON, a
jr z, .nothingFound
; A button is pressed
ld a, BANK(CheckForHiddenObject)

View file

@ -84,7 +84,7 @@ DisplayListMenuIDLoop::
push af
call PlaceMenuCursor
pop af
bit 0, a ; was the A button pressed?
bit BIT_A_BUTTON, a
jp z, .checkOtherKeys
.buttonAPressed
ld a, [wCurrentMenuItem]
@ -168,12 +168,12 @@ DisplayListMenuIDLoop::
res 6, [hl] ; turn on letter printing delay
jp BankswitchBack
.checkOtherKeys ; check B, SELECT, Up, and Down keys
bit 1, a ; was the B button pressed?
bit BIT_B_BUTTON, a
jp nz, ExitListMenu ; if so, exit the menu
bit 2, a ; was the select button pressed?
bit BIT_SELECT, a
jp nz, HandleItemListSwapping ; if so, allow the player to swap menu entries
ld b, a
bit 7, b ; was Down pressed?
bit BIT_D_DOWN, b
ld hl, wListScrollOffset
jr z, .upPressed
.downPressed
@ -220,13 +220,13 @@ DisplayChooseQuantityMenu::
.waitForKeyPressLoop
call JoypadLowSensitivity
ldh a, [hJoyPressed] ; newly pressed buttons
bit 0, a ; was the A button pressed?
bit BIT_A_BUTTON, a
jp nz, .buttonAPressed
bit 1, a ; was the B button pressed?
bit BIT_B_BUTTON, a
jp nz, .buttonBPressed
bit 6, a ; was Up pressed?
bit BIT_D_UP, a
jr nz, .incrementQuantity
bit 7, a ; was Down pressed?
bit BIT_D_DOWN, a
jr nz, .decrementQuantity
jr .waitForKeyPressLoop
.incrementQuantity

View file

@ -72,14 +72,14 @@ OverworldLoopLessDelay::
.notSimulating
ldh a, [hJoyPressed]
.checkIfStartIsPressed
bit 3, a ; start button
bit BIT_START, a
jr z, .startButtonNotPressed
; if START is pressed
xor a ; TEXT_START_MENU
ldh [hSpriteIndexOrTextID], a
jp .displayDialogue
.startButtonNotPressed
bit 0, a ; A button
bit BIT_A_BUTTON, a
jp z, .checkIfDownButtonIsPressed
; if A is pressed
ld a, [wd730]
@ -146,7 +146,7 @@ OverworldLoopLessDelay::
.checkIfDownButtonIsPressed
ldh a, [hJoyHeld] ; current joypad state
bit 7, a ; down button
bit BIT_D_DOWN, a
jr z, .checkIfUpButtonIsPressed
ld a, 1
ld [wSpritePlayerStateData1YStepVector], a
@ -154,7 +154,7 @@ OverworldLoopLessDelay::
jr .handleDirectionButtonPress
.checkIfUpButtonIsPressed
bit 6, a ; up button
bit BIT_D_UP, a
jr z, .checkIfLeftButtonIsPressed
ld a, -1
ld [wSpritePlayerStateData1YStepVector], a
@ -162,7 +162,7 @@ OverworldLoopLessDelay::
jr .handleDirectionButtonPress
.checkIfLeftButtonIsPressed
bit 5, a ; left button
bit BIT_D_LEFT, a
jr z, .checkIfRightButtonIsPressed
ld a, -1
ld [wSpritePlayerStateData1XStepVector], a
@ -170,7 +170,7 @@ OverworldLoopLessDelay::
jr .handleDirectionButtonPress
.checkIfRightButtonIsPressed
bit 4, a ; right button
bit BIT_D_RIGHT, a
jr z, .noDirectionButtonsPressed
ld a, 1
ld [wSpritePlayerStateData1XStepVector], a

View file

@ -274,7 +274,7 @@ HandlePartyMenuInput::
scf
ret
.swappingPokemon
bit 1, b ; was the B button pressed?
bit BIT_B_BUTTON, b
jr z, .handleSwap ; if not, handle swapping the pokemon
.cancelSwap ; if the B button was pressed
farcall ErasePartyMenuCursors

View file

@ -25,11 +25,11 @@ PrintLetterDelay::
call Joypad
ldh a, [hJoyHeld]
.checkAButton
bit 0, a ; is the A button pressed?
bit BIT_A_BUTTON, a
jr z, .checkBButton
jr .endWait
.checkBButton
bit 1, a ; is the B button pressed?
bit BIT_B_BUTTON, a
jr z, .buttonsNotPressed
.endWait
call DelayFrame

View file

@ -15,7 +15,7 @@ RedisplayStartMenu::
call HandleMenuInput
ld b, a
.checkIfUpPressed
bit 6, a ; was Up pressed?
bit BIT_D_UP, a
jr z, .checkIfDownPressed
ld a, [wCurrentMenuItem] ; menu selection
and a
@ -54,7 +54,7 @@ RedisplayStartMenu::
ld a, [wCurrentMenuItem]
ld [wBattleAndStartSavedMenuItem], a ; save current menu selection
ld a, b
and %00001010 ; was the Start button or B button pressed?
and B_BUTTON | START ; was the Start button or B button pressed?
jp nz, CloseStartMenu
call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2
CheckEvent EVENT_GOT_POKEDEX
@ -79,7 +79,7 @@ RedisplayStartMenu::
CloseStartMenu::
call Joypad
ldh a, [hJoyPressed]
bit 0, a ; was A button newly pressed?
bit BIT_A_BUTTON, a
jr nz, CloseStartMenu
call LoadTextBoxTilePatterns
jp CloseTextDisplay

View file

@ -98,7 +98,7 @@ AfterDisplayingTextID::
HoldTextDisplayOpen::
call Joypad
ldh a, [hJoyHeld]
bit 0, a ; is the A button being pressed?
bit BIT_A_BUTTON, a
jr nz, HoldTextDisplayOpen
CloseTextDisplay::

View file

@ -50,7 +50,7 @@ HandleMenuInput_::
ld [wCheckFor180DegreeTurn], a
ldh a, [hJoy5]
ld b, a
bit 6, a ; pressed Up key?
bit BIT_D_UP, a
jr z, .checkIfDownPressed
.upPressed
ld a, [wCurrentMenuItem] ; selected menu item