aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle
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 /engine/battle
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)
Diffstat (limited to 'engine/battle')
-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
6 files changed, 40 insertions, 32 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 3e077d2b..3ccbf7c4 100644
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -114,13 +114,13 @@ DrawFrameBlock:
ld [de], a ; store tile ID
inc de
ld a, [hli]
- bit 5, a ; is horizontal flip enabled?
+ bit OAM_X_FLIP, a
jr nz, .disableHorizontalFlip
.enableHorizontalFlip
- set 5, a
+ set OAM_X_FLIP, a
jr .storeFlags2
.disableHorizontalFlip
- res 5, a
+ res OAM_X_FLIP, a
.storeFlags2
ld [de], a
inc de
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index 5956d875..85d2177e 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -64,6 +64,12 @@ BattleTransition:
ld l, a
jp hl
+ const_def
+ const BIT_TRAINER_BATTLE_TRANSITION ; 0
+ const BIT_STRONGER_BATTLE_TRANSITION ; 1
+ const BIT_DUNGEON_BATTLE_TRANSITION ; 2
+DEF NUM_BATTLE_TRANSITION_BITS EQU const_value
+
; the three GetBattleTransitionID functions set the first
; three bits of c, which determines what transition animation
; to play at the beginning of a battle
@@ -71,6 +77,7 @@ BattleTransition:
; bit 1: set if enemy is at least 3 levels higher than player
; bit 2: set if dungeon map
BattleTransitions:
+ table_width 2, BattleTransitions
dw BattleTransition_DoubleCircle ; %000
dw BattleTransition_Spiral ; %001
dw BattleTransition_Circle ; %010
@@ -79,15 +86,16 @@ BattleTransitions:
dw BattleTransition_Shrink ; %101
dw BattleTransition_VerticalStripes ; %110
dw BattleTransition_Split ; %111
+ assert_table_length 1 << NUM_BATTLE_TRANSITION_BITS
GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
cp OPP_ID_OFFSET
jr nc, .trainer
- res 0, c
+ res BIT_TRAINER_BATTLE_TRANSITION, c
ret
.trainer
- set 0, c
+ set BIT_TRAINER_BATTLE_TRANSITION, c
ret
GetBattleTransitionID_CompareLevels:
@@ -108,12 +116,12 @@ GetBattleTransitionID_CompareLevels:
ld a, [wCurEnemyLevel]
sub e
jr nc, .highLevelEnemy
- res 1, c
+ res BIT_STRONGER_BATTLE_TRANSITION, c
ld a, 1
ld [wBattleTransitionSpiralDirection], a
ret
.highLevelEnemy
- set 1, c
+ set BIT_STRONGER_BATTLE_TRANSITION, c
xor a
ld [wBattleTransitionSpiralDirection], a
ret
@@ -129,7 +137,7 @@ GetBattleTransitionID_IsDungeonMap:
cp e
jr nz, .loop1
.match
- set 2, c
+ set BIT_DUNGEON_BATTLE_TRANSITION, c
ret
.noMatch1
ld hl, DungeonMaps2
@@ -145,7 +153,7 @@ GetBattleTransitionID_IsDungeonMap:
cp d
jr nc, .match
.noMatch2
- res 2, c
+ res BIT_DUNGEON_BATTLE_TRANSITION, c
ret
INCLUDE "data/maps/dungeon_maps.asm"
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 428bc78a..5e93393c 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1007,12 +1007,12 @@ RemoveFaintedPlayerMon:
ld b, FLAG_RESET
predef FlagActionPredef ; clear gain exp flag for fainted mon
ld hl, wEnemyBattleStatus1
- res 2, [hl] ; reset "attacking multiple times" flag
+ res ATTACKING_MULTIPLE_TIMES, [hl]
ld a, [wLowHealthAlarm]
- bit 7, a ; skip sound flag (red bar (?))
+ bit BIT_LOW_HEALTH_ALARM, a
jr z, .skipWaitForSound
- ld a, $ff
- ld [wLowHealthAlarm], a ;disable low health alarm
+ ld a, DISABLE_LOW_HEALTH_ALARM
+ ld [wLowHealthAlarm], a
call WaitForSoundToFinish
.skipWaitForSound
; a is 0, so this zeroes the enemy's accumulated damage.
@@ -1305,7 +1305,7 @@ EnemySendOutFirstMon:
dec a
ld [wAICount], a
ld hl, wPlayerBattleStatus1
- res 5, [hl]
+ res USING_TRAPPING_MOVE, [hl]
hlcoord 18, 0
ld a, 8
call SlideTrainerPicOffScreen
@@ -1860,15 +1860,15 @@ DrawPlayerHUDAndHPBar:
jr z, .setLowHealthAlarm
.fainted
ld hl, wLowHealthAlarm
- bit 7, [hl] ;low health alarm enabled?
- ld [hl], $0
+ bit BIT_LOW_HEALTH_ALARM, [hl]
+ ld [hl], 0
ret z
xor a
ld [wChannelSoundIDs + CHAN5], a
ret
.setLowHealthAlarm
ld hl, wLowHealthAlarm
- set 7, [hl] ;enable low health alarm
+ set BIT_LOW_HEALTH_ALARM, [hl]
ret
DrawEnemyHUDAndHPBar:
@@ -2121,7 +2121,7 @@ DisplayBattleMenu::
ld a, D_LEFT | A_BUTTON
ld [hli], a ; wMenuWatchedKeys
call HandleMenuInput
- bit 5, a ; check if left was pressed
+ bit BIT_D_LEFT, a
jr nz, .leftColumn ; if left was pressed, jump
ld a, [wCurrentMenuItem]
add $2 ; if we're in the right column, the actual id is +2
@@ -2473,11 +2473,11 @@ MoveSelectionMenu:
.writemoves
ld de, wMovesString
ldh a, [hUILayoutFlags]
- set 2, a
+ set BIT_SINGLE_SPACED_LINES, a
ldh [hUILayoutFlags], a
call PlaceString
ldh a, [hUILayoutFlags]
- res 2, a
+ res BIT_SINGLE_SPACED_LINES, a
ldh [hUILayoutFlags], a
ret
@@ -2604,10 +2604,10 @@ SelectMenuItem:
ld [hl], "▷"
.select
ld hl, hUILayoutFlags
- set 1, [hl]
+ set BIT_DOUBLE_SPACED_MENU, [hl]
call HandleMenuInput
ld hl, hUILayoutFlags
- res 1, [hl]
+ res BIT_DOUBLE_SPACED_MENU, [hl]
bit BIT_D_UP, a
jp nz, SelectMenuItem_CursorUp
bit BIT_D_DOWN, a
@@ -2652,7 +2652,7 @@ SelectMenuItem:
cp c
jr z, .disabled
ld a, [wPlayerBattleStatus3]
- bit 3, a ; transformed
+ bit TRANSFORMED, a
jr nz, .transformedMoveSelected
.transformedMoveSelected ; pointless
; Allow moves copied by Transform to be used.
@@ -3850,7 +3850,7 @@ PrintMoveFailureText:
.playersTurn
ld hl, DoesntAffectMonText
ld a, [wDamageMultipliers]
- and $7f
+ and EFFECTIVENESS_MASK
jr z, .gotTextToPrint
ld hl, AttackMissedText
ld a, [wCriticalHitOrOHKO]
@@ -5248,7 +5248,7 @@ AdjustDamageForMoveType:
ld a, l
ld [wDamage + 1], a
ld hl, wDamageMultipliers
- set 7, [hl]
+ set BIT_STAB_DAMAGE, [hl]
.skipSameTypeAttackBonus
ld a, [wMoveType]
ld b, a
@@ -5271,7 +5271,7 @@ AdjustDamageForMoveType:
push bc
inc hl
ld a, [wDamageMultipliers]
- and $80
+ and 1 << BIT_STAB_DAMAGE
ld b, a
ld a, [hl] ; a = damage multiplier
ldh [hMultiplier], a
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index 6fba347f..95c8706f 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -194,7 +194,7 @@ ExplodeEffect:
FreezeBurnParalyzeEffect:
xor a
ld [wAnimationType], a
- call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag]
+ call CheckTargetSubstitute
ret nz ; return if they have a substitute, can't effect them
ldh a, [hWhoseTurn]
and a
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index 57d37f01..a8ee6747 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -224,7 +224,7 @@ GainExperience:
call CopyData
pop hl
ld a, [wPlayerBattleStatus3]
- bit 3, a ; is the mon transformed?
+ bit TRANSFORMED, a
jr nz, .recalcStatChanges
; the mon is not transformed, so update the unmodified stats
ld de, wPlayerMonUnmodifiedLevel
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 5eed1ae5..ccd4e804 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -632,27 +632,27 @@ AICureStatus:
ld [hl], a ; clear status in enemy team roster
ld [wEnemyMonStatus], a ; clear status of active enemy
ld hl, wEnemyBattleStatus3
- res 0, [hl]
+ res BADLY_POISONED, [hl]
ret
AIUseXAccuracy: ; unused
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 0, [hl]
+ set USING_X_ACCURACY, [hl]
ld a, X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec:
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 1, [hl]
+ set PROTECTED_BY_MIST, [hl]
ld a, GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; unused
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 2, [hl]
+ set GETTING_PUMPED, [hl]
ld a, DIRE_HIT
jp AIPrintItemUse