diff --git a/audio/engine_1.asm b/audio/engine_1.asm index 99d47f37d..e9642b326 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -15,9 +15,9 @@ Audio1_UpdateMusic:: ld a, [wMuteAudioAndPauseMusic] and a jr z, .applyAffects - bit 7, a + bit BIT_MUTE_AUDIO, a jr nz, .nextChannel - set 7, a + set BIT_MUTE_AUDIO, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output ldh [rNR51], a @@ -197,7 +197,7 @@ Audio1_sound_ret: .dontDisable jr .afterDisable .returnFromCall - res 1, [hl] + res BIT_SOUND_CALL, [hl] ld d, $0 ld a, c add a @@ -377,8 +377,8 @@ Audio1_toggle_perfect_pitch: ld hl, wChannelFlags1 add hl, bc ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of wChannelFlags1 + xor 1 << BIT_PERFECT_PITCH + ld [hl], a jp Audio1_sound_ret Audio1_vibrato: diff --git a/audio/engine_2.asm b/audio/engine_2.asm index 93de99f3c..6c2c113ca 100644 --- a/audio/engine_2.asm +++ b/audio/engine_2.asm @@ -17,9 +17,9 @@ Audio2_UpdateMusic:: ld a, [wMuteAudioAndPauseMusic] and a jr z, .applyAffects - bit 7, a + bit BIT_MUTE_AUDIO, a jr nz, .nextChannel - set 7, a + set BIT_MUTE_AUDIO, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output ldh [rNR51], a @@ -163,8 +163,8 @@ Audio2_PlayNextNote: ld a, c cp CHAN5 jr nz, .beginChecks - ld a, [wLowHealthAlarm] ; low health alarm enabled? - bit 7, a + ld a, [wLowHealthAlarm] + bit BIT_LOW_HEALTH_ALARM, a ret nz .beginChecks ; --- @@ -208,7 +208,7 @@ Audio2_sound_ret: .dontDisable jr .afterDisable .returnFromCall - res 1, [hl] + res BIT_SOUND_CALL, [hl] ld d, $0 ld a, c add a @@ -388,8 +388,8 @@ Audio2_toggle_perfect_pitch: ld hl, wChannelFlags1 add hl, bc ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of wChannelFlags1 + xor 1 << BIT_PERFECT_PITCH + ld [hl], a jp Audio2_sound_ret Audio2_vibrato: @@ -978,7 +978,7 @@ Audio2_ResetCryModifiers: cp CHAN5 jr nz, .skip ld a, [wLowHealthAlarm] - bit 7, a + bit BIT_LOW_HEALTH_ALARM, a jr z, .skip xor a ld [wFrequencyModifier], a diff --git a/audio/engine_3.asm b/audio/engine_3.asm index e5d285a30..f524875f7 100644 --- a/audio/engine_3.asm +++ b/audio/engine_3.asm @@ -15,9 +15,9 @@ Audio3_UpdateMusic:: ld a, [wMuteAudioAndPauseMusic] and a jr z, .applyAffects - bit 7, a + bit BIT_MUTE_AUDIO, a jr nz, .nextChannel - set 7, a + set BIT_MUTE_AUDIO, a ld [wMuteAudioAndPauseMusic], a xor a ; disable all channels' output ldh [rNR51], a @@ -197,7 +197,7 @@ Audio3_sound_ret: .dontDisable jr .afterDisable .returnFromCall - res 1, [hl] + res BIT_SOUND_CALL, [hl] ld d, $0 ld a, c add a @@ -377,8 +377,8 @@ Audio3_toggle_perfect_pitch: ld hl, wChannelFlags1 add hl, bc ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of wChannelFlags1 + xor 1 << BIT_PERFECT_PITCH + ld [hl], a jp Audio3_sound_ret Audio3_vibrato: diff --git a/audio/low_health_alarm.asm b/audio/low_health_alarm.asm index 35fe18158..728f5f656 100644 --- a/audio/low_health_alarm.asm +++ b/audio/low_health_alarm.asm @@ -1,12 +1,12 @@ Music_DoLowHealthAlarm:: ld a, [wLowHealthAlarm] - cp $ff + cp DISABLE_LOW_HEALTH_ALARM jr z, .disableAlarm - bit 7, a ;alarm enabled? - ret z ;nope + bit BIT_LOW_HEALTH_ALARM, a + ret z - and $7f ;low 7 bits are the timer. + and LOW_HEALTH_TIMER_MASK jr nz, .notToneHi ;if timer > 0, play low tone. call .playToneHi @@ -19,15 +19,15 @@ Music_DoLowHealthAlarm:: call .playToneLo ;actually set the sound registers. .noTone - ld a, $86 + ld a, CRY_SFX_END ld [wChannelSoundIDs + CHAN5], a ;disable sound channel? ld a, [wLowHealthAlarm] - and $7f ;decrement alarm timer. + and LOW_HEALTH_TIMER_MASK dec a .resetTimer ; reset the timer and enable flag. - set 7, a + set BIT_LOW_HEALTH_ALARM, a ld [wLowHealthAlarm], a ret diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm index a89030526..99b899d1e 100644 --- a/constants/audio_constants.asm +++ b/constants/audio_constants.asm @@ -66,3 +66,11 @@ DEF HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff) ; wChannelFlags2 constant (only has one flag) DEF BIT_EXECUTE_MUSIC EQU 0 ; if in execute music + +; wMuteAudioAndPauseMusic +DEF BIT_MUTE_AUDIO EQU 7 + +; wLowHealthAlarm +DEF BIT_LOW_HEALTH_ALARM EQU 7 +DEF LOW_HEALTH_TIMER_MASK EQU %01111111 +DEF DISABLE_LOW_HEALTH_ALARM EQU $ff diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index 9349bb75c..cde50b4d6 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -72,6 +72,10 @@ DEF MAX_STAT_VALUE EQU 999 DEF ATKDEFDV_TRAINER EQU $98 DEF SPDSPCDV_TRAINER EQU $88 +; wDamageMultipliers +DEF BIT_STAB_DAMAGE EQU 7 +DEF EFFECTIVENESS_MASK EQU %01111111 + ; wPlayerBattleStatus1 or wEnemyBattleStatus1 bit flags const_def const STORING_ENERGY ; 0 ; Bide diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm index c62682088..79d9647fc 100644 --- a/constants/gfx_constants.asm +++ b/constants/gfx_constants.asm @@ -29,6 +29,12 @@ DEF TRANSFERBOTTOM EQU 2 DEF REDRAW_COL EQU 1 DEF REDRAW_ROW EQU 2 +; hUILayoutFlags + const_def + const BIT_PARTY_MENU_HP_BAR ; 0 + const BIT_DOUBLE_SPACED_MENU ; 1 + const BIT_SINGLE_SPACED_LINES ; 2 + ; tile list ids ; TileIDListPointerTable indexes (see data/tilemaps.asm) const_def diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 6f6d2df81..005a69345 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -81,8 +81,14 @@ DEF rWave_d EQU $ff3d DEF rWave_e EQU $ff3e DEF rWave_f EQU $ff3f DEF rLCDC EQU $ff40 ; LCD Control (R/W) -DEF rLCDC_ENABLE EQU 7 -DEF rLCDC_ENABLE_MASK EQU 1 << rLCDC_ENABLE +DEF rLCDC_BG_PRIORITY EQU 0 +DEF rLCDC_SPRITES_ENABLE EQU 1 +DEF rLCDC_SPRITE_SIZE EQU 2 +DEF rLCDC_BG_TILEMAP EQU 3 +DEF rLCDC_TILE_DATA EQU 4 +DEF rLCDC_WINDOW_ENABLE EQU 5 +DEF rLCDC_WINDOW_TILEMAP EQU 6 +DEF rLCDC_ENABLE EQU 7 DEF rSTAT EQU $ff41 ; LCDC Status (R/W) DEF rSCY EQU $ff42 ; Scroll Y (R/W) DEF rSCX EQU $ff43 ; Scroll X (R/W) @@ -111,3 +117,8 @@ DEF rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank DEF rPCM12 EQU $ff76 ; Channels 1 & 2 Amplitude (R) DEF rPCM34 EQU $ff77 ; Channels 3 & 4 Amplitude (R) DEF rIE EQU $ffff ; Interrupt Enable (R/W) +DEF rIE_VBLANK EQU 0 +DEF rIE_LCD EQU 1 +DEF rIE_TIMER EQU 2 +DEF rIE_SERIAL EQU 3 +DEF rIE_JOYPAD EQU 4 diff --git a/constants/icon_constants.asm b/constants/icon_constants.asm index 767e29c6d..6b9e21557 100644 --- a/constants/icon_constants.asm +++ b/constants/icon_constants.asm @@ -1,17 +1,17 @@ ; party menu icons ; used in MonPartySpritePointers (see data/icon_pointers.asm) const_def - const ICON_MON ; $0 - const ICON_BALL ; $1 - const ICON_HELIX ; $2 - const ICON_FAIRY ; $3 - const ICON_BIRD ; $4 - const ICON_WATER ; $5 - const ICON_BUG ; $6 - const ICON_GRASS ; $7 - const ICON_SNAKE ; $8 - const ICON_QUADRUPED ; $9 - -DEF ICON_TRADEBUBBLE EQU $e + const ICON_MON ; $0 + const ICON_BALL ; $1 + const ICON_HELIX ; $2 + const ICON_FAIRY ; $3 + const ICON_BIRD ; $4 + const ICON_WATER ; $5 + const ICON_BUG ; $6 + const ICON_GRASS ; $7 + const ICON_SNAKE ; $8 + const ICON_QUADRUPED ; $9 + const_skip 4 + const ICON_TRADEBUBBLE ; $e DEF ICONOFFSET EQU $40 ; difference between alternating icon frames' tile IDs diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 377edcea5..3b17c6ae6 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -40,9 +40,16 @@ DEF SPRITESTATEDATA2_LENGTH EQU const_value DEF NUM_SPRITESTATEDATA_STRUCTS EQU 16 + const_def 6 + const BIT_TRAINER ; 6 + const BIT_ITEM ; 7 + ; different kinds of people events -DEF ITEM EQU $80 -DEF TRAINER EQU $40 +DEF TRAINER EQU 1 << BIT_TRAINER +DEF ITEM EQU 1 << BIT_ITEM + +; movement status +DEF BIT_FACE_PLAYER EQU 7 DEF WALK EQU $FE DEF STAY EQU $FF diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index f1f0d4175..a6e035e70 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -44,6 +44,9 @@ DEF PC_ITEM_CAPACITY EQU 50 const NO_YES_MENU ; 7 DEF NUM_TWO_OPTION_MENUS EQU const_value +; wTwoOptionMenuID +DEF BIT_SECOND_MENU_OPTION_DEFAULT EQU 7 + ; menu exit method constants for list menus and the buy/sell/quit menu DEF CHOSE_MENU_ITEM EQU 1 ; pressed A DEF CANCELLED_MENU EQU 2 ; pressed B diff --git a/constants/oam_constants.asm b/constants/oam_constants.asm index 8c5e6be88..e87e54a00 100644 --- a/constants/oam_constants.asm +++ b/constants/oam_constants.asm @@ -1,14 +1,20 @@ -; OAM flags used by this game -DEF OAMFLAG_ENDOFDATA EQU %00000001 ; pseudo OAM flag, only used by game logic -DEF OAMFLAG_CANBEMASKED EQU %00000010 ; pseudo OAM flag, only used by game logic +; Pseudo-OAM flags used by game logic + const_def + const BIT_END_OF_OAM_DATA ; 0 + const BIT_SPRITE_UNDER_GRASS ; 1 + +; Used in SpriteFacingAndAnimationTable (see data/sprites/facings.asm) +DEF FACING_END EQU 1 << BIT_END_OF_OAM_DATA +DEF UNDER_GRASS EQU 1 << BIT_SPRITE_UNDER_GRASS ; OAM attribute flags -DEF OAM_PALETTE EQU %111 -DEF OAM_TILE_BANK EQU 3 -DEF OAM_OBP_NUM EQU 4 ; Non CGB Mode Only -DEF OAM_X_FLIP EQU 5 -DEF OAM_Y_FLIP EQU 6 -DEF OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) +DEF OAM_PALETTE EQU %111 + const_def 3 + const OAM_TILE_BANK ; 3 + const OAM_OBP_NUM ; 4 ; Non CGB Mode Only + const OAM_X_FLIP ; 5 + const OAM_Y_FLIP ; 6 + const OAM_PRIORITY ; 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3) ; OAM attribute masks DEF OAM_OBP1 EQU 1 << OAM_OBP_NUM ; OBJ palette 1 diff --git a/constants/ram_constants.asm b/constants/ram_constants.asm index 42956cc68..756aaa68f 100644 --- a/constants/ram_constants.asm +++ b/constants/ram_constants.asm @@ -1,3 +1,8 @@ +; wSlotMachineFlags + const_def 6 + const BIT_SLOTS_CAN_WIN ; 6 + const BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR ; 7 + ; wMiscFlags const_def const BIT_SEEN_BY_TRAINER ; 0 @@ -9,6 +14,21 @@ const BIT_TRIED_PUSH_BOULDER ; 6 const BIT_PUSHED_BOULDER ; 7 +; wAutoTextBoxDrawingControl +DEF BIT_NO_AUTO_TEXT_BOX EQU 0 + +; wTextPredefFlag +DEF BIT_TEXT_PREDEF EQU 0 + +; wFontLoaded +DEF BIT_FONT_LOADED EQU 0 + +; wCurrentMapScriptFlags + const_def 5 + const BIT_CUR_MAP_LOADED_1 ; 5 + const BIT_CUR_MAP_LOADED_2 ; 6 + const BIT_CUR_MAP_USED_ELEVATOR ; 7 + ; wOptions DEF TEXT_DELAY_MASK EQU %111 const_def 6 @@ -24,6 +44,12 @@ DEF TEXT_DELAY_SLOW EQU %101 ; 5 const BIT_FAST_TEXT_DELAY ; 0 const BIT_TEXT_DELAY ; 1 +; wCurMapTileset +DEF BIT_NO_PREVIOUS_MAP EQU 7 + +; wCurrentBoxNum +DEF BIT_HAS_CHANGED_BOXES EQU 7 + ; wObtainedBadges, wBeatGymFlags const_def const BIT_BOULDERBADGE ; 0 @@ -117,3 +143,13 @@ DEF NUM_BADGES EQU const_value const_skip 3 ; 3-5 ; unused const BIT_LEDGE_OR_FISHING ; 6 const BIT_SPINNING ; 7 + +; hFindPathFlags + const_def + const BIT_PATH_FOUND_Y ; 0 + const BIT_PATH_FOUND_X ; 1 + +; hNPCPlayerRelativePosFlags + const_def + const BIT_PLAYER_LOWER_Y ; 0 + const BIT_PLAYER_LOWER_X ; 1 diff --git a/data/sprites/facings.asm b/data/sprites/facings.asm index eb583d53d..54fd7ed08 100644 --- a/data/sprites/facings.asm +++ b/data/sprites/facings.asm @@ -48,12 +48,12 @@ SpriteFacingAndAnimationTable: ; y, x, attributes db 0, 0, $00 ; top left db 0, 8, $00 ; top right - db 8, 0, OAMFLAG_CANBEMASKED ; bottom left - db 8, 8, OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right + db 8, 0, UNDER_GRASS ; bottom left + db 8, 8, UNDER_GRASS | FACING_END ; bottom right .FlippedOAM: ; y, x, attributes db 0, 8, OAM_HFLIP ; top left db 0, 0, OAM_HFLIP ; top right - db 8, 8, OAM_HFLIP | OAMFLAG_CANBEMASKED ; bottom left - db 8, 0, OAM_HFLIP | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right + db 8, 8, OAM_HFLIP | UNDER_GRASS ; bottom left + db 8, 0, OAM_HFLIP | UNDER_GRASS | FACING_END ; bottom right diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 605cb1b31..25867c9e2 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 5956d875b..85d2177ee 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 9c2d177bc..8eb34c5f9 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -417,7 +417,7 @@ MainInBattleLoop: jr c, .AIActionUsedEnemyFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? + and a ; was Teleport, Roar, or Whirlwind used to escape from battle? ret nz ; if so, return ld a, b and a @@ -428,7 +428,7 @@ MainInBattleLoop: call DrawHUDsAndHPBars call ExecutePlayerMove ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? + and a ; was Teleport, Roar, or Whirlwind used to escape from battle? ret nz ; if so, return ld a, b and a @@ -441,7 +441,7 @@ MainInBattleLoop: .playerMovesFirst call ExecutePlayerMove ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? + and a ; was Teleport, Roar, or Whirlwind used to escape from battle? ret nz ; if so, return ld a, b and a @@ -455,7 +455,7 @@ MainInBattleLoop: jr c, .AIActionUsedPlayerFirst call ExecuteEnemyMove ld a, [wEscapedFromBattle] - and a ; was Teleport, Road, or Whirlwind used to escape from battle? + and a ; was Teleport, Roar, or Whirlwind used to escape from battle? ret nz ; if so, return ld a, b and a @@ -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. @@ -3851,7 +3851,7 @@ PrintMoveFailureText: .playersTurn ld hl, DoesntAffectMonText ld a, [wDamageMultipliers] - and $7f + and EFFECTIVENESS_MASK jr z, .gotTextToPrint ld hl, AttackMissedText ld a, [wCriticalHitOrOHKO] @@ -5249,7 +5249,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 @@ -5272,7 +5272,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 6fba347f2..95c8706f1 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 57d37f019..a8ee6747c 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 5eed1ae58..ccd4e804f 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/card_key.asm b/engine/events/card_key.asm index 1597e12be..f3fa17fe0 100644 --- a/engine/events/card_key.asm +++ b/engine/events/card_key.asm @@ -50,7 +50,7 @@ PrintCardKeyText: ld [wNewTileBlockID], a predef ReplaceTileBlock ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ld a, SFX_GO_INSIDE jp PlaySound .noCardKey diff --git a/engine/events/elevator.asm b/engine/events/elevator.asm index 8e871456e..9d9b712a9 100644 --- a/engine/events/elevator.asm +++ b/engine/events/elevator.asm @@ -20,7 +20,7 @@ DisplayElevatorFloorMenu: ld [wListScrollOffset], a ret c ld hl, wCurrentMapScriptFlags - set 7, [hl] + set BIT_CUR_MAP_USED_ELEVATOR, [hl] ld hl, wElevatorWarpMaps ld a, [wWhichPokemon] add a diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_objects/cinnabar_gym_quiz.asm index 69f03f2c3..a14bd1988 100644 --- a/engine/events/hidden_objects/cinnabar_gym_quiz.asm +++ b/engine/events/hidden_objects/cinnabar_gym_quiz.asm @@ -83,7 +83,7 @@ CinnabarGymQuiz_AskQuestion: cp c jr nz, .wrongAnswer ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ldh a, [hGymGateIndex] ldh [hBackupGymGateIndex], a ld hl, CinnabarGymQuizCorrectText diff --git a/engine/events/hidden_objects/indigo_plateau_statues.asm b/engine/events/hidden_objects/indigo_plateau_statues.asm index 23e94fcf2..f78a5a727 100644 --- a/engine/events/hidden_objects/indigo_plateau_statues.asm +++ b/engine/events/hidden_objects/indigo_plateau_statues.asm @@ -3,7 +3,7 @@ IndigoPlateauStatues:: ld hl, IndigoPlateauStatuesText1 call PrintText ld a, [wXCoord] - bit 0, a + bit 0, a ; even or odd? ld hl, IndigoPlateauStatuesText2 jr nz, .ok ld hl, IndigoPlateauStatuesText3 diff --git a/engine/events/hidden_objects/pokecenter_pc.asm b/engine/events/hidden_objects/pokecenter_pc.asm index f20f40ed4..59867d1a4 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/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_objects/vermilion_gym_trash.asm index c2bfed067..92fb1406b 100644 --- a/engine/events/hidden_objects/vermilion_gym_trash.asm +++ b/engine/events/hidden_objects/vermilion_gym_trash.asm @@ -97,7 +97,7 @@ GymTrashScript: ; Completed the trash can puzzle. SetEvent EVENT_2ND_LOCK_OPENED ld hl, wCurrentMapScriptFlags - set 6, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] tx_pre_id VermilionGymTrashSuccessText3 diff --git a/engine/events/poison.asm b/engine/events/poison.asm index 752899f72..5a7bed7c4 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 d848a337a..c1ae598ef 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/mon_icons.asm b/engine/gfx/mon_icons.asm index e7016a1da..24e9446e4 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -269,7 +269,7 @@ GetPartyMonSpriteID: ld d, 0 add hl, de ld a, [hl] - bit 0, c + bit 0, c ; even or odd? jr nz, .skipSwap swap a ; use lower nybble if pokedex num is even .skipSwap diff --git a/engine/gfx/screen_effects.asm b/engine/gfx/screen_effects.asm index c7a68734e..7d0ccf7ea 100644 --- a/engine/gfx/screen_effects.asm +++ b/engine/gfx/screen_effects.asm @@ -61,7 +61,7 @@ PredefShakeScreenHorizontally: ldh a, [hMutateWX] xor b ldh [hMutateWX], a - bit 7, a + bit 7, a ; negative? jr z, .skipZeroing xor a ; zero a if it's negative .skipZeroing diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index 3916c0dbe..737443a6d 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 b3f01d129..224fe0d55 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 0ebdbe6d5..e98a819c1 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 @@ -195,13 +195,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 a6631d484..b8fe569b7 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 a89696fbf..2ef1cfb18 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 91a44ba8c..5a6d563f8 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/main_menu.asm b/engine/menus/main_menu.asm index 6d45a7bb1..f5f926ede 100644 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -91,7 +91,7 @@ MainMenu: .choseContinue call DisplayContinueGameInfo ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] .inputLoop xor a ldh [hJoyPressed], a diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index a13926980..c9cc652e6 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 7f8bfc149..3e43cabfa 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 59847cbdf..6ae1f4e76 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, 9 call TextBoxBorder ld hl, hUILayoutFlags - set 2, [hl] + set BIT_SINGLE_SPACED_LINES, [hl] ld de, BoxNames hlcoord 11, 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 db5bc388f..fae53f4f8 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -230,8 +230,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/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index df1478d53..6915a63ce 100644 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -12,7 +12,7 @@ AnimateHallOfFame: call FillMemory call EnableLCD ld hl, rLCDC - set 3, [hl] + set rLCDC_BG_TILEMAP, [hl] xor a ld hl, wHallOfFame ld bc, HOF_TEAM @@ -88,7 +88,7 @@ AnimateHallOfFame: xor a ldh [hWY], a ld hl, rLCDC - res 3, [hl] + res rLCDC_BG_TILEMAP, [hl] ret HallOfFameText: diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index f489c60b6..552b13582 100644 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -319,8 +319,8 @@ PlayShootingStar: call LoadIntroGraphics call EnableLCD ld hl, rLCDC - res 5, [hl] - set 3, [hl] + res rLCDC_WINDOW_ENABLE, [hl] + set rLCDC_BG_TILEMAP, [hl] ld c, 64 call DelayFrames farcall AnimateShootingStar diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 44b236c88..5c3644356 100644 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -4,9 +4,9 @@ PrepareOakSpeech: ld a, [wOptions] push af ; Retrieve BIT_DEBUG_MODE set in DebugMenu for StartNewGameDebug. - ; BUG: StartNewGame carries over bit 5 from previous save files, + ; BUG: StartNewGame carries over BIT_ALWAYS_ON_BIKE from previous save files, ; which causes CheckForceBikeOrSurf to not return. - ; To fix this in debug builds, reset bit 5 here or in StartNewGame. + ; To fix this in debug builds, reset BIT_ALWAYS_ON_BIKE here or in StartNewGame. ; In non-debug builds, the instructions can be removed. ld a, [wStatusFlags6] push af diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 8acbb04fe..57c2d4db5 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,11 +183,11 @@ 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 - set 3, h ; add $80 tiles to hl + set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8) push hl ld h, d ld l, e @@ -200,7 +200,7 @@ LoadMapSpriteTilePatterns: .loadWhileLCDOn pop af pop hl - set 3, h ; add $80 tiles to hl + set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8) ld b, a swap c call CopyVideoData ; load tile pattern data for sprite when walking @@ -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 940a4ade7..2b883f4be 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 @@ -654,7 +654,7 @@ CanWalkOntoTile: add SPRITESTATEDATA2_YDISPLACEMENT ld l, a ld a, [hli] ; x#SPRITESTATEDATA2_YDISPLACEMENT (initialized at $8, keep track of where a sprite did go) - bit 7, d ; check if going upwards (d=$ff) + bit 7, d ; check if going upwards (d == -1) jr nz, .upwards add d ; bug: these tests against $5 probably were supposed to prevent @@ -671,7 +671,7 @@ CanWalkOntoTile: .checkHorizontal ld d, a ld a, [hl] ; x#SPRITESTATEDATA2_XDISPLACEMENT (initialized at $8, keep track of where a sprite did go) - bit 7, e ; check if going left (e=$ff) + bit 7, e ; check if going left (e == -1) jr nz, .left add e cp $5 ; compare, but no conditional jump like in the vertical check above (bug?) diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index d067345e2..58fa1da9b 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/player_state.asm b/engine/overworld/player_state.asm index 4711bb5c4..4da437da9 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -294,6 +294,13 @@ _GetTileAndCoordsInFrontOfPlayer: ld [wTileInFrontOfPlayer], a ret +; hPlayerFacing + const_def + const BIT_FACING_DOWN ; 0 + const BIT_FACING_UP ; 1 + const BIT_FACING_LEFT ; 2 + const BIT_FACING_RIGHT ; 3 + GetTileTwoStepsInFrontOfPlayer: xor a ldh [hPlayerFacing], a @@ -306,7 +313,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingDown ; facing down ld hl, hPlayerFacing - set 0, [hl] + set BIT_FACING_DOWN, [hl] lda_coord 8, 13 inc d jr .storeTile @@ -315,7 +322,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingUp ; facing up ld hl, hPlayerFacing - set 1, [hl] + set BIT_FACING_UP, [hl] lda_coord 8, 5 dec d jr .storeTile @@ -324,7 +331,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .notFacingLeft ; facing left ld hl, hPlayerFacing - set 2, [hl] + set BIT_FACING_LEFT, [hl] lda_coord 4, 9 dec e jr .storeTile @@ -333,7 +340,7 @@ GetTileTwoStepsInFrontOfPlayer: jr nz, .storeTile ; facing right ld hl, hPlayerFacing - set 3, [hl] + set BIT_FACING_RIGHT, [hl] lda_coord 12, 9 inc e .storeTile @@ -385,7 +392,7 @@ CheckForBoulderCollisionWithSprites: ld de, $f ld hl, wSprite01StateData2MapY ldh a, [hPlayerFacing] - and $3 ; facing up or down? + and (1 << BIT_FACING_UP) | (1 << BIT_FACING_DOWN) jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl @@ -396,6 +403,7 @@ CheckForBoulderCollisionWithSprites: ld a, [hli] ld b, a ldh a, [hPlayerFacing] + assert BIT_FACING_DOWN == 0 rrca jr c, .pushingDown ; pushing up @@ -421,7 +429,7 @@ CheckForBoulderCollisionWithSprites: jr nz, .nextSprite2 ld b, [hl] ldh a, [hPlayerFacing] - bit 2, a + bit BIT_FACING_LEFT, a jr nz, .pushingLeft ; pushing right ldh a, [hPlayerXCoord] diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index ff4814397..1773e818f 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 303415c15..b20d490e2 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/overworld/spinners.asm b/engine/overworld/spinners.asm index 98b478c4b..261a939e2 100644 --- a/engine/overworld/spinners.asm +++ b/engine/overworld/spinners.asm @@ -15,7 +15,7 @@ LoadSpinnerArrowTiles:: ld hl, GymSpinnerArrows .gotSpinnerArrows ld a, [wSimulatedJoypadStatesIndex] - bit 0, a + bit 0, a ; even or odd? jr nz, .alternateGraphics ld de, 6 * 4 add hl, de diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index 2df9964ef..819466a59 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 3f2065d6d..2e0b03178 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 b9d600a30..0710a7dad 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 diff --git a/home/init.asm b/home/init.asm index 619a24938..ab85192d6 100644 --- a/home/init.asm +++ b/home/init.asm @@ -8,7 +8,6 @@ SoftReset:: Init:: ; Program init. -DEF rLCDC_DEFAULT EQU %11100011 ; * LCD enabled ; * Window tile map at $9C00 ; * Window display enabled @@ -17,6 +16,7 @@ DEF rLCDC_DEFAULT EQU %11100011 ; * 8x8 OBJ size ; * OBJ display enabled ; * BG display enabled +DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << rLCDC_WINDOW_ENABLE) | (1 << rLCDC_SPRITES_ENABLE) | (1 << rLCDC_BG_PRIORITY) di @@ -35,7 +35,7 @@ DEF rLCDC_DEFAULT EQU %11100011 ldh [rOBP0], a ldh [rOBP1], a - ld a, rLCDC_ENABLE_MASK + ld a, 1 << rLCDC_ENABLE ldh [rLCDC], a call DisableLCD diff --git a/home/lcd.asm b/home/lcd.asm index 5c496824b..aef6d43fd 100644 --- a/home/lcd.asm +++ b/home/lcd.asm @@ -3,7 +3,7 @@ DisableLCD:: ldh [rIF], a ldh a, [rIE] ld b, a - res 0, a + res rIE_VBLANK, a ldh [rIE], a .wait @@ -12,7 +12,7 @@ DisableLCD:: jr nz, .wait ldh a, [rLCDC] - and ~rLCDC_ENABLE_MASK + and ~(1 << rLCDC_ENABLE) ldh [rLCDC], a ld a, b ldh [rIE], a diff --git a/home/load_font.asm b/home/load_font.asm index 3b56d3a88..0f48e84ca 100644 --- a/home/load_font.asm +++ b/home/load_font.asm @@ -1,6 +1,6 @@ LoadFontTilePatterns:: ldh a, [rLCDC] - bit 7, a ; is the LCD enabled? + bit rLCDC_ENABLE, a jr nz, .on .off ld hl, FontGraphics @@ -16,7 +16,7 @@ LoadFontTilePatterns:: LoadTextBoxTilePatterns:: ldh a, [rLCDC] - bit 7, a ; is the LCD enabled? + bit rLCDC_ENABLE, a jr nz, .on .off ld hl, TextBoxGraphics @@ -32,7 +32,7 @@ LoadTextBoxTilePatterns:: LoadHpBarAndStatusTilePatterns:: ldh a, [rLCDC] - bit 7, a ; is the LCD enabled? + bit rLCDC_ENABLE, a jr nz, .on .off ld hl, HpBarAndStatusGraphics diff --git a/home/map_objects.asm b/home/map_objects.asm index 342139dd6..e200238ad 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -227,7 +227,7 @@ SetSpriteMovementBytesToFF:: ; returns the sprite movement byte 1 pointer for sprite [hSpriteIndex] in hl GetSpriteMovementByte1Pointer:: - ld h, $C2 + ld h, HIGH(wSpriteStateData2) ldh a, [hSpriteIndex] swap a add 6 diff --git a/home/overworld.asm b/home/overworld.asm index 1595fdf0c..80638815e 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -33,8 +33,8 @@ EnterMap:: res BIT_NO_NPC_FACE_PLAYER, [hl] call UpdateSprites ld hl, wCurrentMapScriptFlags - set 5, [hl] - set 6, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] xor a ld [wJoyIgnore], a @@ -121,7 +121,7 @@ OverworldLoopLessDelay:: ld a, [wCurMap] call SwitchToMapRomBank ; switch to the ROM bank of the current map ld hl, wCurMapTileset - set 7, [hl] + set BIT_NO_PREVIOUS_MAP, [hl] .changeMap jp EnterMap .checkForOpponent @@ -329,8 +329,8 @@ OverworldLoopLessDelay:: ld hl, wStatusFlags7 res BIT_TRAINER_BATTLE, [hl] ld hl, wCurrentMapScriptFlags - set 5, [hl] - set 6, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] xor a ldh [hJoyHeld], a ld a, [wCurMap] @@ -879,10 +879,10 @@ LoadTilesetTilePatternData:: ld a, [wTilesetBank] jp FarCopyData2 -; this loads the current maps complete tile map (which references blocks, not individual tiles) to C6E8 +; this loads the current map's complete tile map (which references blocks, not individual tiles) to wOverworldMap ; it can also load partial tile maps of connected maps into a border of length 3 around the current map LoadTileBlockMap:: -; fill C6E8-CBFB with the background tile +; fill wOverworldMap-wOverworldMapEnd with the background tile ld hl, wOverworldMap ld a, [wMapBackgroundTile] ld d, a @@ -1210,7 +1210,7 @@ IsSpriteInFrontOfPlayer2:: and $f0 inc a ld l, a ; hl = x#SPRITESTATEDATA1_MOVEMENTSTATUS - set 7, [hl] ; set flag to make the sprite face the player + set BIT_FACE_PLAYER, [hl] ld a, e ldh [hTextID], a ret @@ -1303,7 +1303,7 @@ CheckForTilePairCollisions:: ld a, [wTileInFrontOfPlayer] ld c, a .tilePairCollisionLoop - ld a, [wCurMapTileset] ; tileset number + ld a, [wCurMapTileset] ld b, a ld a, [hli] cp $ff @@ -1943,7 +1943,7 @@ CollisionCheckOnWater:: call PlayDefaultMusic jr .noCollision .checkIfVermilionDockTileset - ld a, [wCurMapTileset] ; tileset + ld a, [wCurMapTileset] cp SHIP_PORT ; Vermilion Dock tileset jr nz, .noCollision ; keep surfing if it's not the boarding platform tile jr .stopSurfing ; if it is the boarding platform tile, stop surfing @@ -2002,7 +2002,7 @@ LoadPlayerSpriteGraphicsCommon:: jr nc, .noCarry inc d .noCarry - set 3, h + set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8) lb bc, BANK(RedSprite), $0c jp CopyVideoData @@ -2015,10 +2015,10 @@ LoadMapHeader:: call SwitchToMapRomBank ld a, [wCurMapTileset] ld b, a - res 7, a + res BIT_NO_PREVIOUS_MAP, a ld [wCurMapTileset], a ldh [hPreviousTileset], a - bit 7, b + bit BIT_NO_PREVIOUS_MAP, b ret nz ld hl, MapHeaderPointers ld a, [wCurMap] @@ -2203,9 +2203,9 @@ LoadMapHeader:: ld [hl], a ; store text ID in byte 1 of sprite entry pop hl ldh a, [hLoadSpriteTemp1] - bit 6, a + bit BIT_TRAINER, a jr nz, .trainerSprite - bit 7, a + bit BIT_ITEM, a jr nz, .itemBallSprite jr .regularSprite .trainerSprite diff --git a/home/pokemon.asm b/home/pokemon.asm index 39b7d0ec0..87fc4a23a 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -252,7 +252,7 @@ HandlePartyMenuInput:: jp nz, .swappingPokemon pop af ldh [hTileAnimations], a - bit 1, b + bit BIT_B_BUTTON, b jr nz, .noPokemonChosen ld a, [wPartyCount] and a diff --git a/home/predef_text.asm b/home/predef_text.asm index bdecd3cf1..61e22fce1 100644 --- a/home/predef_text.asm +++ b/home/predef_text.asm @@ -3,7 +3,7 @@ PrintPredefTextID:: ld hl, TextPredefs call SetMapTextPointer ld hl, wTextPredefFlag - set 0, [hl] + set BIT_TEXT_PREDEF, [hl] call DisplayTextID RestoreMapTextPointer:: diff --git a/home/print_bcd.asm b/home/print_bcd.asm index 38aedd3c8..57ec12a8a 100644 --- a/home/print_bcd.asm +++ b/home/print_bcd.asm @@ -13,12 +13,12 @@ ; their meaning at the beginning of the functions's execution. PrintBCDNumber:: ld b, c ; save flags in b - res 7, c - res 6, c - res 5, c ; c now holds the length - bit 5, b + res BIT_LEADING_ZEROES, c + res BIT_LEFT_ALIGN, c + res BIT_MONEY_SIGN, c ; c now holds the length + bit BIT_MONEY_SIGN, b jr z, .loop - bit 7, b + bit BIT_LEADING_ZEROES, b jr nz, .loop ld [hl], "¥" inc hl @@ -31,14 +31,14 @@ PrintBCDNumber:: inc de dec c jr nz, .loop - bit 7, b ; were any non-zero digits printed? + bit BIT_LEADING_ZEROES, b jr z, .done ; if so, we are done .numberEqualsZero ; if every digit of the BCD number is zero - bit 6, b ; left or right alignment? + bit BIT_LEFT_ALIGN, b jr nz, .skipRightAlignmentAdjustment dec hl ; if the string is right-aligned, it needs to be moved back one space .skipRightAlignmentAdjustment - bit 5, b + bit BIT_MONEY_SIGN, b jr z, .skipCurrencySymbol ld [hl], "¥" inc hl @@ -54,24 +54,24 @@ PrintBCDDigit:: and a jr z, .zeroDigit .nonzeroDigit - bit 7, b ; have any non-space characters been printed? + bit BIT_LEADING_ZEROES, b jr z, .outputDigit ; if bit 7 is set, then no numbers have been printed yet - bit 5, b ; print the currency symbol? + bit BIT_MONEY_SIGN, b jr z, .skipCurrencySymbol ld [hl], "¥" inc hl - res 5, b + res BIT_MONEY_SIGN, b .skipCurrencySymbol - res 7, b ; unset 7 to indicate that a nonzero digit has been reached + res BIT_LEADING_ZEROES, b .outputDigit add "0" ld [hli], a jp PrintLetterDelay .zeroDigit - bit 7, b ; either printing leading zeroes or already reached a nonzero digit? + bit BIT_LEADING_ZEROES, b jr z, .outputDigit ; if so, print a zero digit - bit 6, b ; left or right alignment? + bit BIT_LEFT_ALIGN, b ret nz inc hl ; if right-aligned, "print" a space by advancing the pointer ret diff --git a/home/reload_sprites.asm b/home/reload_sprites.asm index 8a08d64d8..5cf5d458b 100644 --- a/home/reload_sprites.asm +++ b/home/reload_sprites.asm @@ -4,7 +4,7 @@ ReloadMapSpriteTilePatterns:: ld hl, wFontLoaded ld a, [hl] push af - res 0, [hl] + res BIT_FONT_LOADED, [hl] push hl xor a ld [wSpriteSetID], a diff --git a/home/serial.asm b/home/serial.asm index f44772dfe..58111de6f 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -30,7 +30,7 @@ Serial:: ldh [rDIV], a .waitLoop ldh a, [rDIV] - bit 7, a + bit 7, a ; wait until rDIV has incremented from $3 to $80 or more jr nz, .waitLoop ld a, START_TRANSFER_EXTERNAL_CLOCK ldh [rSC], a diff --git a/home/text.asm b/home/text.asm index bdb7adb63..673242db8 100644 --- a/home/text.asm +++ b/home/text.asm @@ -63,7 +63,7 @@ PlaceNextChar:: jr nz, .NotNext ld bc, 2 * SCREEN_WIDTH ldh a, [hUILayoutFlags] - bit 2, a + bit BIT_SINGLE_SPACED_LINES, a jr z, .ok ld bc, SCREEN_WIDTH .ok diff --git a/home/text_script.asm b/home/text_script.asm index f83fced15..d9ea1843a 100644 --- a/home/text_script.asm +++ b/home/text_script.asm @@ -6,8 +6,8 @@ DisplayTextID:: push af farcall DisplayTextIDInit ; initialization ld hl, wTextPredefFlag - bit 0, [hl] - res 0, [hl] + bit BIT_TEXT_PREDEF, [hl] + res BIT_TEXT_PREDEF, [hl] jr nz, .skipSwitchToMapBank ld a, [wCurMap] call SwitchToMapRomBank @@ -128,7 +128,7 @@ CloseTextDisplay:: ld [MBC1RomBank], a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) ld hl, wFontLoaded - res 0, [hl] + res BIT_FONT_LOADED, [hl] ld a, [wStatusFlags6] bit BIT_FLY_WARP, a call z, LoadPlayerSpriteGraphics diff --git a/home/trainers.asm b/home/trainers.asm index 0a466cc1e..bcd158508 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -184,8 +184,8 @@ StartTrainerBattle:: EndTrainerBattle:: ld hl, wCurrentMapScriptFlags - set 5, [hl] - set 6, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] ld hl, wStatusFlags3 res BIT_PRINT_END_BATTLE_TEXT, [hl] ld hl, wMiscFlags diff --git a/home/uncompress.asm b/home/uncompress.asm index 0e609f1c1..9e4344975 100644 --- a/home/uncompress.asm +++ b/home/uncompress.asm @@ -1,3 +1,8 @@ +; wSpriteLoadFlags bits, streamed from compressed sprite data + const_def + const BIT_USE_SPRITE_BUFFER_2 ; 0 + const BIT_LAST_SPRITE_CHUNK ; 1 + ; bankswitches and runs _UncompressSpriteData ; bank is given in a, sprite input stream is pointed to in wSpriteInputPtr UncompressSpriteData:: @@ -47,7 +52,7 @@ _UncompressSpriteData:: add a ld [wSpriteWidth], a call ReadNextInputBit - ld [wSpriteLoadFlags], a ; initialite bit1 to 0 and bit0 to the first input bit + ld [wSpriteLoadFlags], a ; initialize bit1 to 0 and bit0 to the first input bit ; this will load two chunks of data to sSpriteBuffer1 and sSpriteBuffer2 ; bit 0 decides in which one the first chunk is placed ; fall through @@ -58,13 +63,13 @@ _UncompressSpriteData:: UncompressSpriteDataLoop:: ld hl, sSpriteBuffer1 ld a, [wSpriteLoadFlags] - bit 0, a + bit BIT_USE_SPRITE_BUFFER_2, a jr z, .useSpriteBuffer1 ; check which buffer to use ld hl, sSpriteBuffer2 .useSpriteBuffer1 call StoreSpriteOutputPointer ld a, [wSpriteLoadFlags] - bit 1, a + bit BIT_LAST_SPRITE_CHUNK, a jr z, .startDecompression ; check if last iteration call ReadNextInputBit ; if last chunk, read 1-2 bit unpacking mode and a @@ -196,10 +201,10 @@ MoveToNextBufferPosition:: xor a ld [wSpriteCurPosX], a ld a, [wSpriteLoadFlags] - bit 1, a + bit BIT_LAST_SPRITE_CHUNK, a jr nz, .done ; test if there is one more sprite to go - xor $1 - set 1, a + xor 1 << BIT_USE_SPRITE_BUFFER_2 + set BIT_LAST_SPRITE_CHUNK, a ld [wSpriteLoadFlags], a jp UncompressSpriteDataLoop .done @@ -540,7 +545,7 @@ ReverseNybble:: ; resets sprite buffer pointers to buffer 1 and 2, depending on wSpriteLoadFlags ResetSpriteBufferPointers:: ld a, [wSpriteLoadFlags] - bit 0, a + bit BIT_USE_SPRITE_BUFFER_2, a jr nz, .buffer2Selected ld de, sSpriteBuffer1 ld hl, sSpriteBuffer2 diff --git a/home/window.asm b/home/window.asm index 01b52d410..48ab1d0e0 100644 --- a/home/window.asm +++ b/home/window.asm @@ -137,12 +137,12 @@ PlaceMenuCursor:: jr z, .checkForArrow1 push af ldh a, [hUILayoutFlags] - bit 1, a ; is the menu double spaced? + bit BIT_DOUBLE_SPACED_MENU, a jr z, .doubleSpaced1 - ld bc, 20 + ld bc, SCREEN_WIDTH jr .getOldMenuItemScreenPosition .doubleSpaced1 - ld bc, 40 + ld bc, SCREEN_WIDTH * 2 .getOldMenuItemScreenPosition pop af .oldMenuItemLoop @@ -163,12 +163,12 @@ PlaceMenuCursor:: jr z, .checkForArrow2 push af ldh a, [hUILayoutFlags] - bit 1, a ; is the menu double spaced? + bit BIT_DOUBLE_SPACED_MENU, a jr z, .doubleSpaced2 - ld bc, 20 + ld bc, SCREEN_WIDTH jr .getCurrentMenuItemScreenPosition .doubleSpaced2 - ld bc, 40 + ld bc, SCREEN_WIDTH * 2 .getCurrentMenuItemScreenPosition pop af .currentMenuItemLoop @@ -272,7 +272,7 @@ EnableAutoTextBoxDrawing:: jr AutoTextBoxDrawingCommon DisableAutoTextBoxDrawing:: - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX AutoTextBoxDrawingCommon:: ld [wAutoTextBoxDrawingControl], a diff --git a/ram/hram.asm b/ram/hram.asm index e7c3ef3c8..1be1dab69 100644 --- a/ram/hram.asm +++ b/ram/hram.asm @@ -388,6 +388,7 @@ hClearLetterPrintingDelayFlags:: db ; bit 0: draw HP fraction to the right of bar instead of below (for party menu) ; bit 1: menu is double spaced +; bit 2: text is single spaced hUILayoutFlags:: db hFieldMoveMonMenuTopMenuItemX:: db diff --git a/ram/wram.asm b/ram/wram.asm index 4b49669f9..c247c5d4c 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -1599,7 +1599,10 @@ wIsKeyItem:: db wTextBoxID:: db -wCurrentMapScriptFlags:: db ; not exactly sure what this is used for, but it seems to be used as a multipurpose temp flag value +; bit 5: set when maps first load; can be reset to re-run a script +; bit 6: set when maps first load; can be reset to re-run a script (used less often than bit 5) +; bit 7: set when using an elevator map's menu; triggers the shaking animation +wCurrentMapScriptFlags:: db wCurEnemyLevel:: db diff --git a/scripts/AgathasRoom.asm b/scripts/AgathasRoom.asm index 0f3acc18c..2d0dca082 100644 --- a/scripts/AgathasRoom.asm +++ b/scripts/AgathasRoom.asm @@ -11,8 +11,8 @@ AgathasRoom_Script: AgathaShowOrHideExitBlock: ; Blocks or clears the exit to the next room. ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_BEAT_AGATHAS_ROOM_TRAINER_0 jr z, .blockExitToNextRoom diff --git a/scripts/BrunosRoom.asm b/scripts/BrunosRoom.asm index 94ec7d17e..6d7fde6e2 100644 --- a/scripts/BrunosRoom.asm +++ b/scripts/BrunosRoom.asm @@ -11,8 +11,8 @@ BrunosRoom_Script: BrunoShowOrHideExitBlock: ; Blocks or clears the exit to the next room. ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_BEAT_BRUNOS_ROOM_TRAINER_0 jr z, .blockExitToNextRoom diff --git a/scripts/CeladonGym.asm b/scripts/CeladonGym.asm index 8eee1c5aa..070d2408d 100644 --- a/scripts/CeladonGym.asm +++ b/scripts/CeladonGym.asm @@ -1,7 +1,7 @@ CeladonGym_Script: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, .LoadNames call EnableAutoTextBoxDrawing ld hl, CeladonGymTrainerHeaders diff --git a/scripts/CeladonMartElevator.asm b/scripts/CeladonMartElevator.asm index 9a2842f32..69686fa8c 100644 --- a/scripts/CeladonMartElevator.asm +++ b/scripts/CeladonMartElevator.asm @@ -1,12 +1,12 @@ CeladonMartElevator_Script: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] push hl call nz, CeladonMartElevatorStoreWarpEntriesScript pop hl - bit 7, [hl] - res 7, [hl] + bit BIT_CUR_MAP_USED_ELEVATOR, [hl] + res BIT_CUR_MAP_USED_ELEVATOR, [hl] call nz, CeladonMartElevatorShakeScript xor a ld [wAutoTextBoxDrawingControl], a diff --git a/scripts/CeruleanBadgeHouse.asm b/scripts/CeruleanBadgeHouse.asm index b1f6db7ff..541865236 100644 --- a/scripts/CeruleanBadgeHouse.asm +++ b/scripts/CeruleanBadgeHouse.asm @@ -1,5 +1,5 @@ CeruleanBadgeHouse_Script: - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a dec a ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/scripts/CeruleanGym.asm b/scripts/CeruleanGym.asm index d38df543e..13a61f7fe 100644 --- a/scripts/CeruleanGym.asm +++ b/scripts/CeruleanGym.asm @@ -1,7 +1,7 @@ CeruleanGym_Script: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, .LoadNames call EnableAutoTextBoxDrawing ld hl, CeruleanGymTrainerHeaders diff --git a/scripts/CinnabarGym.asm b/scripts/CinnabarGym.asm index c864a4b66..74fa58801 100644 --- a/scripts/CinnabarGym.asm +++ b/scripts/CinnabarGym.asm @@ -7,13 +7,13 @@ CinnabarGym_Script: CinnabarGymSetMapAndTiles: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] push hl call nz, .LoadNames pop hl - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] call nz, UpdateCinnabarGymGateTileBlocks ResetEvent EVENT_2A7 ret @@ -170,7 +170,7 @@ CinnabarGymReceiveTM38: SetEventRange EVENT_BEAT_CINNABAR_GYM_TRAINER_0, EVENT_BEAT_CINNABAR_GYM_TRAINER_6 ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] jp CinnabarGymResetScripts diff --git a/scripts/CinnabarIsland.asm b/scripts/CinnabarIsland.asm index ed38f6902..f2a36afb3 100644 --- a/scripts/CinnabarIsland.asm +++ b/scripts/CinnabarIsland.asm @@ -1,7 +1,7 @@ CinnabarIsland_Script: call EnableAutoTextBoxDrawing ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ResetEvent EVENT_MANSION_SWITCH_ON ResetEvent EVENT_LAB_STILL_REVIVING_FOSSIL ld hl, CinnabarIsland_ScriptPointers diff --git a/scripts/FuchsiaGym.asm b/scripts/FuchsiaGym.asm index def3530ff..c94a8faa9 100644 --- a/scripts/FuchsiaGym.asm +++ b/scripts/FuchsiaGym.asm @@ -10,8 +10,8 @@ FuchsiaGym_Script: .LoadNames: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] ret z ld hl, .CityName ld de, .LeaderName diff --git a/scripts/GameCorner.asm b/scripts/GameCorner.asm index 45f517643..b3dc25846 100644 --- a/scripts/GameCorner.asm +++ b/scripts/GameCorner.asm @@ -8,8 +8,8 @@ GameCorner_Script: GameCornerSelectLuckySlotMachine: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] ret z call Random ldh a, [hRandomAdd] @@ -25,8 +25,8 @@ GameCornerSelectLuckySlotMachine: GameCornerSetRocketHideoutDoorTile: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_FOUND_ROCKET_HIDEOUT ret nz @@ -111,8 +111,8 @@ GameCornerRocketExitScript: ld [wMissableObjectIndex], a predef HideObject ld hl, wCurrentMapScriptFlags - set 5, [hl] - set 6, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] + set BIT_CUR_MAP_LOADED_2, [hl] ld a, SCRIPT_GAMECORNER_DEFAULT ld [wGameCornerCurScript], a ret diff --git a/scripts/IndigoPlateauLobby.asm b/scripts/IndigoPlateauLobby.asm index fd8ecf3cc..8ac87030f 100644 --- a/scripts/IndigoPlateauLobby.asm +++ b/scripts/IndigoPlateauLobby.asm @@ -2,8 +2,8 @@ IndigoPlateauLobby_Script: call Serial_TryEstablishingExternallyClockedConnection call EnableAutoTextBoxDrawing ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] ret z ResetEvent EVENT_VICTORY_ROAD_1_BOULDER_ON_SWITCH ; Reset Elite Four events if the player started challenging them before diff --git a/scripts/LancesRoom.asm b/scripts/LancesRoom.asm index 31b0f2408..235deac1b 100644 --- a/scripts/LancesRoom.asm +++ b/scripts/LancesRoom.asm @@ -10,8 +10,8 @@ LancesRoom_Script: LanceShowOrHideEntranceBlocks: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_LANCES_ROOM_LOCK_DOOR jr nz, .closeEntrance @@ -71,7 +71,7 @@ LancesRoomDefaultScript: CheckAndSetEvent EVENT_LANCES_ROOM_LOCK_DOOR ret nz ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ld a, SFX_GO_INSIDE call PlaySound jp LanceShowOrHideEntranceBlocks diff --git a/scripts/LoreleisRoom.asm b/scripts/LoreleisRoom.asm index ec88f73e4..455561b80 100644 --- a/scripts/LoreleisRoom.asm +++ b/scripts/LoreleisRoom.asm @@ -11,8 +11,8 @@ LoreleisRoom_Script: LoreleiShowOrHideExitBlock: ; Blocks or clears the exit to the next room. ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, wElite4Flags set BIT_STARTED_ELITE_4, [hl] diff --git a/scripts/Museum1F.asm b/scripts/Museum1F.asm index 600c03c72..465c72f8a 100644 --- a/scripts/Museum1F.asm +++ b/scripts/Museum1F.asm @@ -1,5 +1,5 @@ Museum1F_Script: - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a xor a ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/scripts/OaksLab.asm b/scripts/OaksLab.asm index 89d6ef80f..71704c5b2 100644 --- a/scripts/OaksLab.asm +++ b/scripts/OaksLab.asm @@ -1,7 +1,7 @@ OaksLab_Script: CheckEvent EVENT_PALLET_AFTER_GETTING_POKEBALLS_2 call nz, OaksLabLoadTextPointers2Script - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a xor a ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/scripts/PewterGym.asm b/scripts/PewterGym.asm index 63f8806df..4fb6fac36 100644 --- a/scripts/PewterGym.asm +++ b/scripts/PewterGym.asm @@ -1,7 +1,7 @@ PewterGym_Script: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, .LoadNames call EnableAutoTextBoxDrawing ld hl, PewterGymTrainerHeaders diff --git a/scripts/PewterMart.asm b/scripts/PewterMart.asm index 0a5baac2b..49a91977e 100644 --- a/scripts/PewterMart.asm +++ b/scripts/PewterMart.asm @@ -1,6 +1,6 @@ PewterMart_Script: call EnableAutoTextBoxDrawing - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a ret diff --git a/scripts/PokemonMansion1F.asm b/scripts/PokemonMansion1F.asm index a93bd33b3..d06a234a9 100644 --- a/scripts/PokemonMansion1F.asm +++ b/scripts/PokemonMansion1F.asm @@ -10,8 +10,8 @@ PokemonMansion1F_Script: Mansion1CheckReplaceSwitchDoorBlocks: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_MANSION_SWITCH_ON jr nz, .switchTurnedOn @@ -103,7 +103,7 @@ PokemonMansion1FSwitchText: ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ld hl, .PressedText call PrintText ld a, SFX_GO_INSIDE diff --git a/scripts/PokemonMansion2F.asm b/scripts/PokemonMansion2F.asm index df424a199..7da9e50f0 100644 --- a/scripts/PokemonMansion2F.asm +++ b/scripts/PokemonMansion2F.asm @@ -10,8 +10,8 @@ PokemonMansion2F_Script: Mansion2CheckReplaceSwitchDoorBlocks: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_MANSION_SWITCH_ON jr nz, .switchTurnedOn @@ -108,7 +108,7 @@ PokemonMansion2FSwitchText: ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ld hl, .PressedText call PrintText ld a, SFX_GO_INSIDE diff --git a/scripts/PokemonMansion3F.asm b/scripts/PokemonMansion3F.asm index f53474467..de8bd1dd4 100644 --- a/scripts/PokemonMansion3F.asm +++ b/scripts/PokemonMansion3F.asm @@ -10,8 +10,8 @@ PokemonMansion3F_Script: Mansion3CheckReplaceSwitchDoorBlocks: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_MANSION_SWITCH_ON jr nz, .switchTurnedOn diff --git a/scripts/PokemonMansionB1F.asm b/scripts/PokemonMansionB1F.asm index e359621d6..e31bbd3eb 100644 --- a/scripts/PokemonMansionB1F.asm +++ b/scripts/PokemonMansionB1F.asm @@ -10,8 +10,8 @@ PokemonMansionB1F_Script: MansionB1FCheckReplaceSwitchDoorBlocks: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_MANSION_SWITCH_ON jr nz, .switchTurnedOn diff --git a/scripts/RocketHideoutB1F.asm b/scripts/RocketHideoutB1F.asm index f6c64bdaf..9354a0c72 100644 --- a/scripts/RocketHideoutB1F.asm +++ b/scripts/RocketHideoutB1F.asm @@ -10,8 +10,8 @@ RocketHideoutB1F_Script: RocketHideoutB1FDoorCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_677 jr nz, .door_open diff --git a/scripts/RocketHideoutB4F.asm b/scripts/RocketHideoutB4F.asm index 920aa0898..2c630067f 100644 --- a/scripts/RocketHideoutB4F.asm +++ b/scripts/RocketHideoutB4F.asm @@ -10,8 +10,8 @@ RocketHideoutB4F_Script: RocketHideoutB4FDoorCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEvent EVENT_ROCKET_HIDEOUT_4_DOOR_UNLOCKED jr nz, .door_already_unlocked @@ -67,7 +67,7 @@ RocketHideoutB4FBeatGiovanniScript: xor a ld [wJoyIgnore], a ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ld a, SCRIPT_ROCKETHIDEOUTB4F_DEFAULT ld [wRocketHideoutB4FCurScript], a ld [wCurMapScript], a diff --git a/scripts/RocketHideoutElevator.asm b/scripts/RocketHideoutElevator.asm index 71ff0758a..bd6fb4987 100644 --- a/scripts/RocketHideoutElevator.asm +++ b/scripts/RocketHideoutElevator.asm @@ -1,12 +1,12 @@ RocketHideoutElevator_Script: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] push hl call nz, RocketHideoutElevatorStoreWarpEntriesScript pop hl - bit 7, [hl] - res 7, [hl] + bit BIT_CUR_MAP_USED_ELEVATOR, [hl] + res BIT_CUR_MAP_USED_ELEVATOR, [hl] call nz, RocketHideoutElevatorShakeScript xor a ld [wAutoTextBoxDrawingControl], a diff --git a/scripts/Route23.asm b/scripts/Route23.asm index f5a4c3d7d..b9fea0293 100644 --- a/scripts/Route23.asm +++ b/scripts/Route23.asm @@ -7,8 +7,8 @@ Route23_Script: Route23SetVictoryRoadBoulders: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] ret z ResetEvents EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH2 ResetEvents EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH2 diff --git a/scripts/Route25.asm b/scripts/Route25.asm index ef0e8fd2d..a85144a87 100644 --- a/scripts/Route25.asm +++ b/scripts/Route25.asm @@ -10,8 +10,8 @@ Route25_Script: Route25ShowHideBillScript: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] ret z CheckEventHL EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING ret nz diff --git a/scripts/SSAnne2FRooms.asm b/scripts/SSAnne2FRooms.asm index e7b88b3f9..3358759d8 100644 --- a/scripts/SSAnne2FRooms.asm +++ b/scripts/SSAnne2FRooms.asm @@ -1,5 +1,5 @@ SSAnne2FRooms_Script: - ld a, TRUE + ld a, 1 << BIT_NO_AUTO_TEXT_BOX ld [wAutoTextBoxDrawingControl], a xor a ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/scripts/SaffronGym.asm b/scripts/SaffronGym.asm index 733da92c2..61c8d2da4 100644 --- a/scripts/SaffronGym.asm +++ b/scripts/SaffronGym.asm @@ -1,7 +1,7 @@ SaffronGym_Script: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, .LoadNames call EnableAutoTextBoxDrawing ld hl, SaffronGymTrainerHeaders diff --git a/scripts/SilphCo10F.asm b/scripts/SilphCo10F.asm index 7cc2c58e7..d9650bc82 100644 --- a/scripts/SilphCo10F.asm +++ b/scripts/SilphCo10F.asm @@ -10,8 +10,8 @@ SilphCo10F_Script: SilphCo10FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo2F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo11F.asm b/scripts/SilphCo11F.asm index d5e4cb08d..6953d37c9 100644 --- a/scripts/SilphCo11F.asm +++ b/scripts/SilphCo11F.asm @@ -10,8 +10,8 @@ SilphCo11F_Script: SilphCo11FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, SilphCo11GateCoords call SilphCo11F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo2F.asm b/scripts/SilphCo2F.asm index 52241b95f..7ca57c456 100644 --- a/scripts/SilphCo2F.asm +++ b/scripts/SilphCo2F.asm @@ -10,8 +10,8 @@ SilphCo2F_Script: SilphCo2FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo2F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo3F.asm b/scripts/SilphCo3F.asm index df9df9e8c..146cbb072 100644 --- a/scripts/SilphCo3F.asm +++ b/scripts/SilphCo3F.asm @@ -10,8 +10,8 @@ SilphCo3F_Script: SilphCo3FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo2F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo4F.asm b/scripts/SilphCo4F.asm index 91453d653..f84ef9958 100644 --- a/scripts/SilphCo4F.asm +++ b/scripts/SilphCo4F.asm @@ -10,8 +10,8 @@ SilphCo4F_Script: SilphCo4FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo4F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo5F.asm b/scripts/SilphCo5F.asm index 1834bfa84..599c17430 100644 --- a/scripts/SilphCo5F.asm +++ b/scripts/SilphCo5F.asm @@ -10,8 +10,8 @@ SilphCo5F_Script: SilphCo5FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo4F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo6F.asm b/scripts/SilphCo6F.asm index 0626ffdbd..ad8e83f43 100644 --- a/scripts/SilphCo6F.asm +++ b/scripts/SilphCo6F.asm @@ -10,8 +10,8 @@ SilphCo6F_Script: SilphCo6F_GateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo4F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo7F.asm b/scripts/SilphCo7F.asm index 381eff7a3..bf517d29c 100644 --- a/scripts/SilphCo7F.asm +++ b/scripts/SilphCo7F.asm @@ -10,8 +10,8 @@ SilphCo7F_Script: SilphCo7F_GateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo7F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo8F.asm b/scripts/SilphCo8F.asm index cdd7f486f..dcba85c03 100644 --- a/scripts/SilphCo8F.asm +++ b/scripts/SilphCo8F.asm @@ -10,8 +10,8 @@ SilphCo8F_Script: SilphCo8FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo8F_SetCardKeyDoorYScript diff --git a/scripts/SilphCo9F.asm b/scripts/SilphCo9F.asm index fe7f3da28..aec4dbf8f 100644 --- a/scripts/SilphCo9F.asm +++ b/scripts/SilphCo9F.asm @@ -10,8 +10,8 @@ SilphCo9F_Script: SilphCo9FGateCallbackScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z ld hl, .GateCoordinates call SilphCo9F_SetCardKeyDoorYScript diff --git a/scripts/SilphCoElevator.asm b/scripts/SilphCoElevator.asm index a2ed009e6..ffdf101ee 100644 --- a/scripts/SilphCoElevator.asm +++ b/scripts/SilphCoElevator.asm @@ -1,12 +1,12 @@ SilphCoElevator_Script: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] push hl call nz, SilphCoElevatorStoreWarpEntriesScript pop hl - bit 7, [hl] - res 7, [hl] + bit BIT_CUR_MAP_USED_ELEVATOR, [hl] + res BIT_CUR_MAP_USED_ELEVATOR, [hl] call nz, SilphCoElevatorShakeScript xor a ld [wAutoTextBoxDrawingControl], a diff --git a/scripts/VermilionCity.asm b/scripts/VermilionCity.asm index fd5905df3..40a08dbca 100644 --- a/scripts/VermilionCity.asm +++ b/scripts/VermilionCity.asm @@ -1,13 +1,13 @@ VermilionCity_Script: call EnableAutoTextBoxDrawing ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] push hl call nz, VermilionCityLeftSSAnneCallbackScript pop hl - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] call nz, .setFirstLockTrashCanIndex ld hl, VermilionCity_ScriptPointers ld a, [wVermilionCityCurScript] diff --git a/scripts/VermilionGym.asm b/scripts/VermilionGym.asm index a59a55e66..45646968a 100644 --- a/scripts/VermilionGym.asm +++ b/scripts/VermilionGym.asm @@ -1,12 +1,12 @@ VermilionGym_Script: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] push hl call nz, .LoadNames pop hl - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, VermilionGymSetDoorTile call EnableAutoTextBoxDrawing ld hl, VermilionGymTrainerHeaders diff --git a/scripts/VictoryRoad1F.asm b/scripts/VictoryRoad1F.asm index e80e17d51..554ae39fc 100644 --- a/scripts/VictoryRoad1F.asm +++ b/scripts/VictoryRoad1F.asm @@ -1,7 +1,7 @@ VictoryRoad1F_Script: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] call nz, .next call EnableAutoTextBoxDrawing ld hl, VictoryRoad1TrainerHeaders @@ -31,7 +31,7 @@ VictoryRoad1FDefaultScript: call CheckBoulderCoords jp nc, CheckFightingMapTrainers ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] SetEvent EVENT_VICTORY_ROAD_1_BOULDER_ON_SWITCH ret diff --git a/scripts/VictoryRoad2F.asm b/scripts/VictoryRoad2F.asm index 347d16a53..853562470 100644 --- a/scripts/VictoryRoad2F.asm +++ b/scripts/VictoryRoad2F.asm @@ -1,11 +1,11 @@ VictoryRoad2F_Script: ld hl, wCurrentMapScriptFlags - bit 6, [hl] - res 6, [hl] + bit BIT_CUR_MAP_LOADED_2, [hl] + res BIT_CUR_MAP_LOADED_2, [hl] call nz, VictoryRoad2FResetBoulderEventScript ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] call nz, VictoryRoad2FCheckBoulderEventScript call EnableAutoTextBoxDrawing ld hl, VictoryRoad2TrainerHeaders @@ -27,7 +27,7 @@ VictoryRoad2FCheckBoulderEventScript: call VictoryRoad2FReplaceTileBlockScript pop af .not_on_switch - bit 7, a + CheckEventReuseA EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH2 ret z ld a, $1d lb bc, 7, 11 @@ -60,7 +60,7 @@ VictoryRoad2FDefaultScript: ret nz .set_script_flag ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] ret .SwitchCoords: diff --git a/scripts/VictoryRoad3F.asm b/scripts/VictoryRoad3F.asm index e9295a153..2b1b11c02 100644 --- a/scripts/VictoryRoad3F.asm +++ b/scripts/VictoryRoad3F.asm @@ -10,8 +10,8 @@ VictoryRoad3F_Script: VictoryRoad3FCheckBoulderEventScript: ld hl, wCurrentMapScriptFlags - bit 5, [hl] - res 5, [hl] + bit BIT_CUR_MAP_LOADED_1, [hl] + res BIT_CUR_MAP_LOADED_1, [hl] ret z CheckEventHL EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1 ret z @@ -38,7 +38,7 @@ VictoryRoad3FDefaultScript: cp $1 jr nz, .handle_hole ld hl, wCurrentMapScriptFlags - set 5, [hl] + set BIT_CUR_MAP_LOADED_1, [hl] SetEvent EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1 ret .handle_hole