aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvie <35663410+Rangi42@users.noreply.github.com>2024-09-23 23:51:44 -0400
committerGitHub <noreply@github.com>2024-09-23 23:51:44 -0400
commit8f1dcf07e598c6e3d34b5d255f04faff1667d83b (patch)
treefe962b2c23dd40ad3d69f7145a46a002c3285a76
parentRemove the Discord webhook and tools/unnamed.py (diff)
downloadpokeyellow-8f1dcf07e598c6e3d34b5d255f04faff1667d83b.tar.gz
pokeyellow-8f1dcf07e598c6e3d34b5d255f04faff1667d83b.tar.xz
pokeyellow-8f1dcf07e598c6e3d34b5d255f04faff1667d83b.zip
Identify more flag bits (#464)
-rw-r--r--audio/engine_1.asm10
-rw-r--r--audio/engine_2.asm16
-rw-r--r--audio/engine_3.asm10
-rw-r--r--audio/low_health_alarm.asm14
-rw-r--r--constants/audio_constants.asm8
-rw-r--r--constants/battle_constants.asm4
-rw-r--r--constants/gfx_constants.asm6
-rw-r--r--constants/map_object_constants.asm11
-rw-r--r--constants/menu_constants.asm3
-rw-r--r--constants/oam_constants.asm24
-rw-r--r--constants/ram_constants.asm30
-rw-r--r--data/sprites/facings.asm8
-rw-r--r--engine/battle/animations.asm6
-rw-r--r--engine/battle/battle_transitions.asm20
-rw-r--r--engine/battle/core.asm34
-rw-r--r--engine/battle/effects.asm2
-rw-r--r--engine/battle/experience.asm2
-rw-r--r--engine/battle/trainer_ai.asm8
-rw-r--r--engine/events/hidden_objects/pokecenter_pc.asm2
-rw-r--r--engine/events/poison.asm2
-rw-r--r--engine/gfx/hp_bar.asm2
-rw-r--r--engine/gfx/sprite_oam.asm4
-rw-r--r--engine/items/item_effects.asm10
-rw-r--r--engine/items/town_map.asm10
-rw-r--r--engine/link/cable_club.asm14
-rw-r--r--engine/menus/display_text_id_init.asm4
-rw-r--r--engine/menus/league_pc.asm4
-rw-r--r--engine/menus/party_menu.asm4
-rw-r--r--engine/menus/players_pc.asm2
-rw-r--r--engine/menus/save.asm14
-rw-r--r--engine/menus/text_box.asm4
-rw-r--r--engine/overworld/map_sprites.asm6
-rw-r--r--engine/overworld/movement.asm8
-rw-r--r--engine/overworld/pathfinding.asm26
-rw-r--r--engine/overworld/push_boulder.asm2
-rw-r--r--engine/overworld/special_warps.asm2
-rw-r--r--engine/pokemon/learn_move.asm8
-rw-r--r--engine/pokemon/status_screen.asm2
-rw-r--r--engine/slots/slot_machine.asm27
-rw-r--r--home/map_objects.asm2
-rw-r--r--home/overworld.asm20
-rw-r--r--home/predef_text.asm2
-rw-r--r--home/print_bcd.asm28
-rw-r--r--home/reload_sprites.asm2
-rw-r--r--home/text.asm2
-rw-r--r--home/text_script.asm6
-rw-r--r--home/window.asm14
-rw-r--r--ram/hram.asm1
-rw-r--r--scripts/CeruleanBadgeHouse.asm2
-rw-r--r--scripts/Museum1F.asm2
-rw-r--r--scripts/OaksLab.asm2
-rw-r--r--scripts/PewterMart.asm2
-rw-r--r--scripts/SSAnne2FRooms.asm2
53 files changed, 267 insertions, 193 deletions
diff --git a/audio/engine_1.asm b/audio/engine_1.asm
index 99d47f37..e9642b32 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 bcaab694..2f11c027 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 e5d285a3..f524875f 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 35fe1815..728f5f65 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 a8903052..99b899d1 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 9349bb75..cde50b4d 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 c6268208..79d9647f 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/map_object_constants.asm b/constants/map_object_constants.asm
index 377edcea..3b17c6ae 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 f1f0d417..a6e035e7 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 8c5e6be8..e87e54a0 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 42956cc6..8102cc7e 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,15 @@
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
+
; wOptions
DEF TEXT_DELAY_MASK EQU %111
const_def 6
@@ -24,6 +38,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 +137,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 eb583d53..54fd7ed0 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 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
diff --git a/home/map_objects.asm b/home/map_objects.asm
index 342139dd..e200238a 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 1595fdf0..e43ebc81 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -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
@@ -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
@@ -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/predef_text.asm b/home/predef_text.asm
index bdecd3cf..61e22fce 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 38aedd3c..57ec12a8 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 8a08d64d..5cf5d458 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/text.asm b/home/text.asm
index dc78b982..da884125 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 d367683d..c1606371 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/window.asm b/home/window.asm
index 01b52d41..48ab1d0e 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 e7c3ef3c..1be1dab6 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/scripts/CeruleanBadgeHouse.asm b/scripts/CeruleanBadgeHouse.asm
index b1f6db7f..54186523 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/Museum1F.asm b/scripts/Museum1F.asm
index 600c03c7..465c72f8 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 89d6ef80..71704c5b 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/PewterMart.asm b/scripts/PewterMart.asm
index 0a5baac2..49a91977 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/SSAnne2FRooms.asm b/scripts/SSAnne2FRooms.asm
index e7b88b3f..3358759d 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