diff options
Diffstat (limited to 'engine')
27 files changed, 119 insertions, 110 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 3e077d2b..3ccbf7c4 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -114,13 +114,13 @@ DrawFrameBlock: ld [de], a ; store tile ID inc de ld a, [hli] - bit 5, a ; is horizontal flip enabled? + bit OAM_X_FLIP, a jr nz, .disableHorizontalFlip .enableHorizontalFlip - set 5, a + set OAM_X_FLIP, a jr .storeFlags2 .disableHorizontalFlip - res 5, a + res OAM_X_FLIP, a .storeFlags2 ld [de], a inc de diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 5956d875..85d2177e 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -64,6 +64,12 @@ BattleTransition: ld l, a jp hl + const_def + const BIT_TRAINER_BATTLE_TRANSITION ; 0 + const BIT_STRONGER_BATTLE_TRANSITION ; 1 + const BIT_DUNGEON_BATTLE_TRANSITION ; 2 +DEF NUM_BATTLE_TRANSITION_BITS EQU const_value + ; the three GetBattleTransitionID functions set the first ; three bits of c, which determines what transition animation ; to play at the beginning of a battle @@ -71,6 +77,7 @@ BattleTransition: ; bit 1: set if enemy is at least 3 levels higher than player ; bit 2: set if dungeon map BattleTransitions: + table_width 2, BattleTransitions dw BattleTransition_DoubleCircle ; %000 dw BattleTransition_Spiral ; %001 dw BattleTransition_Circle ; %010 @@ -79,15 +86,16 @@ BattleTransitions: dw BattleTransition_Shrink ; %101 dw BattleTransition_VerticalStripes ; %110 dw BattleTransition_Split ; %111 + assert_table_length 1 << NUM_BATTLE_TRANSITION_BITS GetBattleTransitionID_WildOrTrainer: ld a, [wCurOpponent] cp OPP_ID_OFFSET jr nc, .trainer - res 0, c + res BIT_TRAINER_BATTLE_TRANSITION, c ret .trainer - set 0, c + set BIT_TRAINER_BATTLE_TRANSITION, c ret GetBattleTransitionID_CompareLevels: @@ -108,12 +116,12 @@ GetBattleTransitionID_CompareLevels: ld a, [wCurEnemyLevel] sub e jr nc, .highLevelEnemy - res 1, c + res BIT_STRONGER_BATTLE_TRANSITION, c ld a, 1 ld [wBattleTransitionSpiralDirection], a ret .highLevelEnemy - set 1, c + set BIT_STRONGER_BATTLE_TRANSITION, c xor a ld [wBattleTransitionSpiralDirection], a ret @@ -129,7 +137,7 @@ GetBattleTransitionID_IsDungeonMap: cp e jr nz, .loop1 .match - set 2, c + set BIT_DUNGEON_BATTLE_TRANSITION, c ret .noMatch1 ld hl, DungeonMaps2 @@ -145,7 +153,7 @@ GetBattleTransitionID_IsDungeonMap: cp d jr nc, .match .noMatch2 - res 2, c + res BIT_DUNGEON_BATTLE_TRANSITION, c ret INCLUDE "data/maps/dungeon_maps.asm" diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 428bc78a..5e93393c 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1007,12 +1007,12 @@ RemoveFaintedPlayerMon: ld b, FLAG_RESET predef FlagActionPredef ; clear gain exp flag for fainted mon ld hl, wEnemyBattleStatus1 - res 2, [hl] ; reset "attacking multiple times" flag + res ATTACKING_MULTIPLE_TIMES, [hl] ld a, [wLowHealthAlarm] - bit 7, a ; skip sound flag (red bar (?)) + bit BIT_LOW_HEALTH_ALARM, a jr z, .skipWaitForSound - ld a, $ff - ld [wLowHealthAlarm], a ;disable low health alarm + ld a, DISABLE_LOW_HEALTH_ALARM + ld [wLowHealthAlarm], a call WaitForSoundToFinish .skipWaitForSound ; a is 0, so this zeroes the enemy's accumulated damage. @@ -1305,7 +1305,7 @@ EnemySendOutFirstMon: dec a ld [wAICount], a ld hl, wPlayerBattleStatus1 - res 5, [hl] + res USING_TRAPPING_MOVE, [hl] hlcoord 18, 0 ld a, 8 call SlideTrainerPicOffScreen @@ -1860,15 +1860,15 @@ DrawPlayerHUDAndHPBar: jr z, .setLowHealthAlarm .fainted ld hl, wLowHealthAlarm - bit 7, [hl] ;low health alarm enabled? - ld [hl], $0 + bit BIT_LOW_HEALTH_ALARM, [hl] + ld [hl], 0 ret z xor a ld [wChannelSoundIDs + CHAN5], a ret .setLowHealthAlarm ld hl, wLowHealthAlarm - set 7, [hl] ;enable low health alarm + set BIT_LOW_HEALTH_ALARM, [hl] ret DrawEnemyHUDAndHPBar: @@ -2121,7 +2121,7 @@ DisplayBattleMenu:: ld a, D_LEFT | A_BUTTON ld [hli], a ; wMenuWatchedKeys call HandleMenuInput - bit 5, a ; check if left was pressed + bit BIT_D_LEFT, a jr nz, .leftColumn ; if left was pressed, jump ld a, [wCurrentMenuItem] add $2 ; if we're in the right column, the actual id is +2 @@ -2473,11 +2473,11 @@ MoveSelectionMenu: .writemoves ld de, wMovesString ldh a, [hUILayoutFlags] - set 2, a + set BIT_SINGLE_SPACED_LINES, a ldh [hUILayoutFlags], a call PlaceString ldh a, [hUILayoutFlags] - res 2, a + res BIT_SINGLE_SPACED_LINES, a ldh [hUILayoutFlags], a ret @@ -2604,10 +2604,10 @@ SelectMenuItem: ld [hl], "▷" .select ld hl, hUILayoutFlags - set 1, [hl] + set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags - res 1, [hl] + res BIT_DOUBLE_SPACED_MENU, [hl] bit BIT_D_UP, a jp nz, SelectMenuItem_CursorUp bit BIT_D_DOWN, a @@ -2652,7 +2652,7 @@ SelectMenuItem: cp c jr z, .disabled ld a, [wPlayerBattleStatus3] - bit 3, a ; transformed + bit TRANSFORMED, a jr nz, .transformedMoveSelected .transformedMoveSelected ; pointless ; Allow moves copied by Transform to be used. @@ -3850,7 +3850,7 @@ PrintMoveFailureText: .playersTurn ld hl, DoesntAffectMonText ld a, [wDamageMultipliers] - and $7f + and EFFECTIVENESS_MASK jr z, .gotTextToPrint ld hl, AttackMissedText ld a, [wCriticalHitOrOHKO] @@ -5248,7 +5248,7 @@ AdjustDamageForMoveType: ld a, l ld [wDamage + 1], a ld hl, wDamageMultipliers - set 7, [hl] + set BIT_STAB_DAMAGE, [hl] .skipSameTypeAttackBonus ld a, [wMoveType] ld b, a @@ -5271,7 +5271,7 @@ AdjustDamageForMoveType: push bc inc hl ld a, [wDamageMultipliers] - and $80 + and 1 << BIT_STAB_DAMAGE ld b, a ld a, [hl] ; a = damage multiplier ldh [hMultiplier], a diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 6fba347f..95c8706f 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -194,7 +194,7 @@ ExplodeEffect: FreezeBurnParalyzeEffect: xor a ld [wAnimationType], a - call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] + call CheckTargetSubstitute ret nz ; return if they have a substitute, can't effect them ldh a, [hWhoseTurn] and a diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 57d37f01..a8ee6747 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -224,7 +224,7 @@ GainExperience: call CopyData pop hl ld a, [wPlayerBattleStatus3] - bit 3, a ; is the mon transformed? + bit TRANSFORMED, a jr nz, .recalcStatChanges ; the mon is not transformed, so update the unmodified stats ld de, wPlayerMonUnmodifiedLevel diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 5eed1ae5..ccd4e804 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -632,27 +632,27 @@ AICureStatus: ld [hl], a ; clear status in enemy team roster ld [wEnemyMonStatus], a ; clear status of active enemy ld hl, wEnemyBattleStatus3 - res 0, [hl] + res BADLY_POISONED, [hl] ret AIUseXAccuracy: ; unused call AIPlayRestoringSFX ld hl, wEnemyBattleStatus2 - set 0, [hl] + set USING_X_ACCURACY, [hl] ld a, X_ACCURACY jp AIPrintItemUse AIUseGuardSpec: call AIPlayRestoringSFX ld hl, wEnemyBattleStatus2 - set 1, [hl] + set PROTECTED_BY_MIST, [hl] ld a, GUARD_SPEC jp AIPrintItemUse AIUseDireHit: ; unused call AIPlayRestoringSFX ld hl, wEnemyBattleStatus2 - set 2, [hl] + set GETTING_PUMPED, [hl] ld a, DIRE_HIT jp AIPrintItemUse diff --git a/engine/events/hidden_objects/pokecenter_pc.asm b/engine/events/hidden_objects/pokecenter_pc.asm index f20f40ed..59867d1a 100644 --- a/engine/events/hidden_objects/pokecenter_pc.asm +++ b/engine/events/hidden_objects/pokecenter_pc.asm @@ -3,7 +3,7 @@ OpenPokemonCenterPC: cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a tx_pre_jump PokemonCenterPCText diff --git a/engine/events/poison.asm b/engine/events/poison.asm index 752899f7..5a7bed7c 100644 --- a/engine/events/poison.asm +++ b/engine/events/poison.asm @@ -1,7 +1,7 @@ ApplyOutOfBattlePoisonDamage: ld a, [wStatusFlags5] assert BIT_SCRIPTED_MOVEMENT_STATE == 7 - add a ; overflows bit 7 into carry flag + add a ; overflows scripted movement state bit into carry flag jp c, .noBlackOut ; no black out if joypad states are being simulated ld a, [wPartyCount] and a diff --git a/engine/gfx/hp_bar.asm b/engine/gfx/hp_bar.asm index d848a337..c1ae598e 100644 --- a/engine/gfx/hp_bar.asm +++ b/engine/gfx/hp_bar.asm @@ -214,7 +214,7 @@ UpdateHPBar_PrintHPNumber: ld [wHPBarTempHP], a push hl ldh a, [hUILayoutFlags] - bit 0, a + bit BIT_PARTY_MENU_HP_BAR, a jr z, .hpBelowBar ld de, $9 jr .next diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index 3916c0db..737443a6 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -124,7 +124,7 @@ PrepareOAMData:: inc hl inc e ld a, [hl] - bit 1, a ; is the tile allowed to set the sprite priority bit? + bit BIT_SPRITE_UNDER_GRASS, a jr z, .skipPriority ldh a, [hSpritePriority] or [hl] @@ -132,7 +132,7 @@ PrepareOAMData:: inc hl ld [de], a inc e - bit 0, a ; OAMFLAG_ENDOFDATA + bit BIT_END_OF_OAM_DATA, a jr z, .tileLoop ld a, e diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 91462478..9643412c 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -691,7 +691,7 @@ ItemUseSurfboard: ldh [hSpriteIndex], a ld d, 16 ; talking range in pixels (normal range) call IsSpriteInFrontOfPlayer2 - res 7, [hl] + res BIT_FACE_PLAYER, [hl] ldh a, [hSpriteIndex] and a ; is there a sprite in the way? jr nz, .cannotStopSurfing @@ -1052,13 +1052,13 @@ ItemUseMedicine: ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent ldh a, [hUILayoutFlags] - set 0, a + set BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled ldh a, [hUILayoutFlags] - res 0, a + res BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a pop af ld b, a ; store heal amount (1/5 of max HP) @@ -1202,13 +1202,13 @@ ItemUseMedicine: ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent ldh a, [hUILayoutFlags] - set 0, a + set BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar lengthening ldh a, [hUILayoutFlags] - res 0, a + res BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a ld a, REVIVE_MSG ld [wPartyMenuTypeOrMessageID], a diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm index a9840268..6f2c050c 100644 --- a/engine/items/town_map.asm +++ b/engine/items/town_map.asm @@ -75,9 +75,9 @@ DisplayTownMap: jr z, .inputLoop ld a, SFX_TINK call PlaySound - bit 6, b + bit BIT_D_UP, b jr nz, .pressedUp - bit 7, b + bit BIT_D_DOWN, b jr nz, .pressedDown xor a ld [wTownMapSpriteBlinkingEnabled], a @@ -196,13 +196,13 @@ LoadTownMap_Fly:: pop hl and A_BUTTON | B_BUTTON | D_UP | D_DOWN jr z, .inputLoop - bit 0, b + bit BIT_A_BUTTON, b jr nz, .pressedA ld a, SFX_TINK call PlaySound - bit 6, b + bit BIT_D_UP, b jr nz, .pressedUp - bit 7, b + bit BIT_D_DOWN, b jr nz, .pressedDown jr .pressedB .pressedA diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index cbb8a358..8ae192b8 100644 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -282,7 +282,7 @@ CableClub_DoBattleOrTradeAgain: call ClearScreen call Delay3 ld hl, wOptions - res 7, [hl] + res BIT_BATTLE_ANIMATION, [hl] predef InitOpponent predef HealParty jp ReturnToCableClubRoom @@ -342,10 +342,10 @@ TradeCenter_SelectMon: ld [wTopMenuItemX], a .enemyMonMenu_HandleInput ld hl, hUILayoutFlags - set 1, [hl] + set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags - res 1, [hl] + res BIT_DOUBLE_SPACED_MENU, [hl] and a jp z, .getNewInput bit BIT_A_BUTTON, a @@ -407,10 +407,10 @@ TradeCenter_SelectMon: call ClearScreenArea .playerMonMenu_HandleInput ld hl, hUILayoutFlags - set 1, [hl] + set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags - res 1, [hl] + res BIT_DOUBLE_SPACED_MENU, [hl] and a ; was anything pressed? jr nz, .playerMonMenu_SomethingPressed jp .getNewInput @@ -489,7 +489,7 @@ TradeCenter_SelectMon: ld a, 1 ld [wTopMenuItemX], a call HandleMenuInput - bit 4, a ; Right pressed? + bit BIT_D_RIGHT, a jr nz, .selectTradeMenuItem bit BIT_B_BUTTON, a jr z, .displayPlayerMonStats @@ -585,7 +585,7 @@ ReturnToCableClubRoom: ld a, [hl] push af push hl - res 0, [hl] + res BIT_FONT_LOADED, [hl] xor a ld [wStatusFlags3], a ; clears BIT_INIT_TRADE_CENTER_FACING dec a diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index a89696fb..2ef1cfb1 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -3,7 +3,7 @@ DisplayTextIDInit:: xor a ld [wListMenuID], a ld a, [wAutoTextBoxDrawingControl] - bit 0, a + bit BIT_NO_AUTO_TEXT_BOX, a jr nz, .skipDrawingTextBoxBorder ldh a, [hTextID] and a @@ -31,7 +31,7 @@ DisplayTextIDInit:: call TextBoxBorder .skipDrawingTextBoxBorder ld hl, wFontLoaded - set 0, [hl] + set BIT_FONT_LOADED, [hl] ld hl, wMiscFlags bit BIT_NO_SPRITE_UPDATES, [hl] res BIT_NO_SPRITE_UPDATES, [hl] diff --git a/engine/menus/league_pc.asm b/engine/menus/league_pc.asm index 17d58c55..03b1de6d 100644 --- a/engine/menus/league_pc.asm +++ b/engine/menus/league_pc.asm @@ -44,7 +44,7 @@ PKMNLeaguePC: pop af ld [wUpdateSpritesEnabled], a pop hl - res 6, [hl] + res BIT_NO_TEXT_DELAY, [hl] call GBPalWhiteOutWithDelay3 call ClearScreen call RunDefaultPaletteCommand @@ -57,7 +57,7 @@ LeaguePCShowTeam: call LeaguePCShowMon call WaitForTextScrollButtonPress ldh a, [hJoyHeld] - bit 1, a + bit BIT_B_BUTTON, a jr nz, .exit ld hl, wHallOfFame + HOF_MON ld de, wHallOfFame diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index 6c8cd6eb..e6388b5f 100644 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -70,12 +70,12 @@ RedrawPartyMenu_:: push hl ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column ldh a, [hUILayoutFlags] - set 0, a + set BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a add hl, bc predef DrawHP2 ; draw HP bar and prints current / max HP ldh a, [hUILayoutFlags] - res 0, a + res BIT_PARTY_MENU_HP_BAR, a ldh [hUILayoutFlags], a call SetPartyMenuHPBarColor ; color the HP bar (on SGB) pop hl diff --git a/engine/menus/players_pc.asm b/engine/menus/players_pc.asm index 9e1553dd..402275b5 100644 --- a/engine/menus/players_pc.asm +++ b/engine/menus/players_pc.asm @@ -50,7 +50,7 @@ PlayerPCMenu: ld hl, WhatDoYouWantText call PrintText call HandleMenuInput - bit 1, a + bit BIT_B_BUTTON, a jp nz, ExitPlayerPC call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 2f61b678..eeb4b9e8 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -66,7 +66,7 @@ LoadSAV0: ld bc, wMainDataEnd - wMainDataStart call CopyData ld hl, wCurMapTileset - set 7, [hl] + set BIT_NO_PREVIOUS_MAP, [hl] ld hl, sSpriteData ld de, wSpriteDataStart ld bc, wSpriteDataEnd - wSpriteDataStart @@ -349,15 +349,15 @@ ChangeBox:: and a ret nz ; return if No was chosen ld hl, wCurrentBoxNum - bit 7, [hl] ; is it the first time player is changing the box? + bit BIT_HAS_CHANGED_BOXES, [hl] ; is it the first time player is changing the box? call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM call DisplayChangeBoxMenu call UpdateSprites ld hl, hUILayoutFlags - set 1, [hl] + set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags - res 1, [hl] + res BIT_DOUBLE_SPACED_MENU, [hl] bit BIT_B_BUTTON, a ret nz call GetBoxSRAMLocation @@ -366,7 +366,7 @@ ChangeBox:: ld hl, wBoxDataStart call CopyBoxToOrFromSRAM ; copy old box from WRAM to SRAM ld a, [wCurrentMenuItem] - set 7, a + set BIT_HAS_CHANGED_BOXES, a ld [wCurrentBoxNum], a call GetBoxSRAMLocation ld de, wBoxDataStart @@ -448,12 +448,12 @@ DisplayChangeBoxMenu: ld c, 7 call TextBoxBorder ld hl, hUILayoutFlags - set 2, [hl] + set BIT_SINGLE_SPACED_LINES, [hl] ld de, BoxNames hlcoord 13, 1 call PlaceString ld hl, hUILayoutFlags - res 2, [hl] + res BIT_SINGLE_SPACED_LINES, [hl] ld a, [wCurrentBoxNum] and $7f cp 9 diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index 3c1b5233..1c078693 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -227,8 +227,8 @@ DisplayTwoOptionMenu: ld [wMenuWatchMovingOutOfBounds], a push hl ld hl, wTwoOptionMenuID - bit 7, [hl] ; select second menu item by default? - res 7, [hl] + bit BIT_SECOND_MENU_OPTION_DEFAULT, [hl] + res BIT_SECOND_MENU_OPTION_DEFAULT, [hl] jr z, .storeCurrentMenuItem inc a .storeCurrentMenuItem diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 8acbb04f..75c46474 100644 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -162,7 +162,7 @@ LoadMapSpriteTilePatterns: pop de ld b, a ld a, [wFontLoaded] - bit 0, a ; reloading upper half of tile patterns after displaying text? + bit BIT_FONT_LOADED, a ; reloading upper half of tile patterns after displaying text? jr nz, .skipFirstLoad ; if so, skip loading data into the lower half ld a, b ld b, 0 @@ -183,7 +183,7 @@ LoadMapSpriteTilePatterns: inc d .noCarry3 ld a, [wFontLoaded] - bit 0, a ; reloading upper half of tile patterns after displaying text? + bit BIT_FONT_LOADED, a ; reloading upper half of tile patterns after displaying text? jr nz, .loadWhileLCDOn pop af pop hl @@ -268,7 +268,7 @@ InitOutsideMapSprites: call nc, GetSplitMapSpriteSetID ; if so, choose the appropriate one ld b, a ; b = spriteSetID ld a, [wFontLoaded] - bit 0, a ; reloading upper half of tile patterns after displaying text? + bit BIT_FONT_LOADED, a ; reloading upper half of tile patterns after displaying text? jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set ld a, [wSpriteSetID] cp b ; has the sprite set ID changed? diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 1ca24f6a..5f95cf6c 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -57,7 +57,7 @@ UpdatePlayerSprite: .next ld [wSpritePlayerStateData1FacingDirection], a ld a, [wFontLoaded] - bit 0, a + bit BIT_FONT_LOADED, a jr nz, .notMoving .moving ld a, [wMovementFlags] @@ -135,11 +135,11 @@ UpdateNPCSprite: ld l, a inc l ld a, [hl] ; x#SPRITESTATEDATA1_MOVEMENTSTATUS - bit 7, a ; is the face player flag set? + bit BIT_FACE_PLAYER, a jp nz, MakeNPCFacePlayer ld b, a ld a, [wFontLoaded] - bit 0, a + bit BIT_FONT_LOADED, a jp nz, notYetMoving ld a, b cp $2 @@ -412,7 +412,7 @@ MakeNPCFacePlayer: ld a, [wStatusFlags3] bit BIT_NO_NPC_FACE_PLAYER, a jr nz, notYetMoving - res 7, [hl] + res BIT_FACE_PLAYER, [hl] ld a, [wPlayerDirection] bit PLAYER_DIR_BIT_UP, a jr z, .notFacingDown diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index d067345e..58fa1da9 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -16,7 +16,7 @@ FindPathToPlayer: and a jr nz, .stillHasYProgress ldh a, [hFindPathFlags] - set 0, a ; current end of path matches the player's Y coordinate + set BIT_PATH_FOUND_Y, a ldh [hFindPathFlags], a .stillHasYProgress ldh a, [hFindPathXProgress] @@ -27,11 +27,11 @@ FindPathToPlayer: and a jr nz, .stillHasXProgress ldh a, [hFindPathFlags] - set 1, a ; current end of path matches the player's X coordinate + set BIT_PATH_FOUND_X, a ldh [hFindPathFlags], a .stillHasXProgress ldh a, [hFindPathFlags] - cp $3 ; has the end of the path reached the player's position? + cp (1 << BIT_PATH_FOUND_X) | (1 << BIT_PATH_FOUND_Y) jr z, .done ; Compare whether the X distance between the player and the current of the path ; is greater or if the Y distance is. Then, try to reduce whichever is greater. @@ -40,7 +40,7 @@ FindPathToPlayer: jr c, .yDistanceGreater ; x distance is greater ldh a, [hNPCPlayerRelativePosFlags] - bit 1, a + bit BIT_PLAYER_LOWER_X, a jr nz, .playerIsLeftOfNPC ld d, NPC_MOVEMENT_RIGHT jr .next1 @@ -53,7 +53,7 @@ FindPathToPlayer: jr .storeDirection .yDistanceGreater ldh a, [hNPCPlayerRelativePosFlags] - bit 0, a + bit BIT_PLAYER_LOWER_Y, a jr nz, .playerIsAboveNPC ld d, NPC_MOVEMENT_DOWN jr .next2 @@ -97,15 +97,15 @@ CalcPositionOfPlayerRelativeToNPC: .NPCNorthOfPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - set 0, [hl] + bit BIT_PLAYER_LOWER_Y, [hl] + set BIT_PLAYER_LOWER_Y, [hl] pop hl jr .divideYDistance .NPCSouthOfOrAlignedWithPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - res 0, [hl] + bit BIT_PLAYER_LOWER_Y, [hl] + res BIT_PLAYER_LOWER_Y, [hl] pop hl .divideYDistance push hl @@ -125,15 +125,15 @@ CalcPositionOfPlayerRelativeToNPC: .NPCWestOfPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - set 1, [hl] + bit BIT_PLAYER_LOWER_X, [hl] + set BIT_PLAYER_LOWER_X, [hl] pop hl jr .divideXDistance .NPCEastOfOrAlignedWithPlayer push hl ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - res 1, [hl] + bit BIT_PLAYER_LOWER_X, [hl] + res BIT_PLAYER_LOWER_X, [hl] pop hl .divideXDistance ldh [hDividend2], a diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index ff481439..1773e818 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -18,7 +18,7 @@ TryPushingBoulder:: swap a ld e, a add hl, de - res 7, [hl] + res BIT_FACE_PLAYER, [hl] call GetSpriteMovementByte2Pointer ld a, [hl] cp BOULDER_MOVEMENT_BYTE_2 diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm index 303415c1..b20d490e 100644 --- a/engine/overworld/special_warps.asm +++ b/engine/overworld/special_warps.asm @@ -52,7 +52,7 @@ LoadSpecialWarpData: bit BIT_DEBUG_MODE, a ; warp to wLastMap (PALLET_TOWN) for StartNewGameDebug jr nz, .notNewGameWarp - bit 2, a + bit BIT_FLY_OR_DUNGEON_WARP, a jr nz, .notNewGameWarp ld hl, NewGameWarp .copyWarpData diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index 2df9964e..819466a5 100644 --- a/engine/pokemon/learn_move.asm +++ b/engine/pokemon/learn_move.asm @@ -127,11 +127,11 @@ TryingToLearn: hlcoord 6, 8 ld de, wMovesString ldh a, [hUILayoutFlags] - set 2, a + set BIT_SINGLE_SPACED_LINES, a ldh [hUILayoutFlags], a call PlaceString ldh a, [hUILayoutFlags] - res 2, a + res BIT_SINGLE_SPACED_LINES, a ldh [hUILayoutFlags], a ld hl, wTopMenuItemY ld a, 8 @@ -147,10 +147,10 @@ TryingToLearn: ld [hli], a ; wMenuWatchedKeys ld [hl], 0 ; wLastMenuItem ld hl, hUILayoutFlags - set 1, [hl] + set BIT_DOUBLE_SPACED_MENU, [hl] call HandleMenuInput ld hl, hUILayoutFlags - res 1, [hl] + res BIT_DOUBLE_SPACED_MENU, [hl] push af call LoadScreenTilesFromBuffer1 pop af diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 8d377f79..447db8fd 100644 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -41,7 +41,7 @@ DrawHP_: call DrawHPBar pop hl ldh a, [hUILayoutFlags] - bit 0, a + bit BIT_PARTY_MENU_HP_BAR, a jr z, .printFractionBelowBar ld bc, $9 ; right of bar jr .printFraction diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 649f634c..1ed24a1a 100644 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -1,8 +1,9 @@ PromptUserToPlaySlots: call SaveScreenTilesToBuffer2 - ld a, BANK(DisplayTextIDInit) ; TRUE - ld [wAutoTextBoxDrawingControl], a - ld b, a + ld a, BANK(DisplayTextIDInit) + assert BANK(DisplayTextIDInit) == 1 << BIT_NO_AUTO_TEXT_BOX + ld [wAutoTextBoxDrawingControl], a ; 1 << BIT_NO_AUTO_TEXT_BOX + ld b, a ; BANK(DisplayTextIDInit) ld hl, DisplayTextIDInit call Bankswitch ld hl, PlaySlotMachineText @@ -173,7 +174,7 @@ OneMoreGoSlotMachineText: SlotMachine_SetFlags: ld hl, wSlotMachineFlags - bit 7, [hl] + bit BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR, [hl] ret nz ld a, [wSlotMachineAllowMatchesCounter] and a @@ -191,14 +192,14 @@ SlotMachine_SetFlags: ld [hl], 0 ret .allowMatches - set 6, [hl] + set BIT_SLOTS_CAN_WIN, [hl] ret .setAllowMatchesCounter ld a, 60 ld [wSlotMachineAllowMatchesCounter], a ret .allowSevenAndBarMatches - set 7, [hl] + set BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR, [hl] ret SlotMachine_SpinWheels: @@ -289,7 +290,7 @@ SlotMachine_StopWheel1Early: call SlotMachine_GetWheel1Tiles ld hl, wSlotMachineWheel1BottomTile ld a, [wSlotMachineFlags] - and $80 + and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR jr nz, .sevenAndBarMode ; Stop early if the middle symbol is not a cherry. inc hl @@ -317,7 +318,7 @@ SlotMachine_StopWheel1Early: SlotMachine_StopWheel2Early: call SlotMachine_GetWheel2Tiles ld a, [wSlotMachineFlags] - and $80 + and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR jr nz, .sevenAndBarMode ; Stop early if any symbols are lined up in the first two wheels. call SlotMachine_FindWheel1Wheel2Matches @@ -401,7 +402,7 @@ SlotMachine_CheckForMatches: call SlotMachine_CheckForMatch jr z, .foundMatch ld a, [wSlotMachineFlags] - and $c0 + and (1 << BIT_SLOTS_CAN_WIN) | (1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR) jr z, .noMatch ld hl, wSlotMachineRerollCounter dec [hl] @@ -421,9 +422,9 @@ SlotMachine_CheckForMatches: jp SlotMachine_CheckForMatches .foundMatch ld a, [wSlotMachineFlags] - and $c0 + and (1 << BIT_SLOTS_CAN_WIN) | (1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR) jr z, .rollWheel3DownByOneSymbol ; roll wheel if player isn't allowed to win - and $80 + and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR jr nz, .acceptMatch ; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel ld a, [hl] @@ -599,7 +600,7 @@ SlotReward300Func: call PlaySound call Random cp $80 - ld a, $0 + ld a, 0 jr c, .skip ld [wSlotMachineFlags], a .skip @@ -654,7 +655,7 @@ SlotMachine_PrintPayoutCoins: jp PrintNumber SlotMachine_PayCoinsToPlayer: - ld a, $1 + ld a, TRUE ld [wMuteAudioAndPauseMusic], a call WaitForSoundToFinish |
