Skip to content

Commit

Permalink
Identify various flag labels and bit constants (pret#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jul 16, 2024
1 parent 70228c2 commit 8fafca7
Show file tree
Hide file tree
Showing 143 changed files with 1,071 additions and 1,081 deletions.
9 changes: 3 additions & 6 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ DEF MOVE_ACC rb
DEF MOVE_PP rb
DEF MOVE_LENGTH EQU _RS

; D733 flags
DEF BIT_TEST_BATTLE EQU 0

; battle type constants (wBattleType values)
const_def
const BATTLE_TYPE_NORMAL ; 0
Expand Down Expand Up @@ -78,7 +75,7 @@ DEF SPDSPCDV_TRAINER EQU $88
; wPlayerBattleStatus1 or wEnemyBattleStatus1 bit flags
const_def
const STORING_ENERGY ; 0 ; Bide
const THRASHING_ABOUT ; 1 ; e.g. Thrash
const THRASHING_ABOUT ; 1 ; Thrash, Petal Dance
const ATTACKING_MULTIPLE_TIMES ; 2 ; e.g. Double Kick, Fury Attack
const FLINCHED ; 3
const CHARGING_UP ; 4 ; e.g. Solar Beam, Fly
Expand All @@ -95,11 +92,11 @@ DEF SPDSPCDV_TRAINER EQU $88
const HAS_SUBSTITUTE_UP ; 4
const NEEDS_TO_RECHARGE ; 5 ; Hyper Beam
const USING_RAGE ; 6
const SEEDED ; 7
const SEEDED ; 7 ; Leech Seed

; wPlayerBattleStatus3 or wEnemyBattleStatus3 bit flags
const_def
const BADLY_POISONED ; 0
const BADLY_POISONED ; 0 ; Toxic
const HAS_LIGHT_SCREEN_UP ; 1
const HAS_REFLECT_UP ; 2
const TRANSFORMED ; 3
16 changes: 8 additions & 8 deletions constants/input_constants.asm
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
; joypad buttons
const_def
const BIT_A_BUTTON
const BIT_B_BUTTON
const BIT_SELECT
const BIT_START
const BIT_D_RIGHT
const BIT_D_LEFT
const BIT_D_UP
const BIT_D_DOWN
const BIT_A_BUTTON ; 0
const BIT_B_BUTTON ; 1
const BIT_SELECT ; 2
const BIT_START ; 3
const BIT_D_RIGHT ; 4
const BIT_D_LEFT ; 5
const BIT_D_UP ; 6
const BIT_D_DOWN ; 7

DEF NO_INPUT EQU 0
DEF A_BUTTON EQU 1 << BIT_A_BUTTON
Expand Down
12 changes: 0 additions & 12 deletions constants/misc_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,3 @@ DEF TRUE EQU 1
const FLAG_RESET ; 0
const FLAG_SET ; 1
const FLAG_TEST ; 2

; wOptions
DEF TEXT_DELAY_FAST EQU %001 ; 1
DEF TEXT_DELAY_MEDIUM EQU %011 ; 3
DEF TEXT_DELAY_SLOW EQU %101 ; 5

const_def 6
const BIT_BATTLE_SHIFT ; 6
const BIT_BATTLE_ANIMATION ; 7

; wd732 flags
DEF BIT_DEBUG_MODE EQU 1
119 changes: 119 additions & 0 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
; wMiscFlags
const_def
const BIT_SEEN_BY_TRAINER ; 0
const BIT_BOULDER_DUST ; 1
const BIT_TURNING ; 2
const BIT_USING_GENERIC_PC ; 3
const BIT_NO_SPRITE_UPDATES ; 4
const BIT_NO_MENU_BUTTON_SOUND ; 5
const BIT_TRIED_PUSH_BOULDER ; 6
const BIT_PUSHED_BOULDER ; 7

; wOptions
DEF TEXT_DELAY_MASK EQU %111
const_def 6
const BIT_BATTLE_SHIFT ; 6
const BIT_BATTLE_ANIMATION ; 7

DEF TEXT_DELAY_FAST EQU %001 ; 1
DEF TEXT_DELAY_MEDIUM EQU %011 ; 3
DEF TEXT_DELAY_SLOW EQU %101 ; 5

; wLetterPrintingDelayFlags
const_def
const BIT_FAST_TEXT_DELAY ; 0
const BIT_TEXT_DELAY ; 1

; wObtainedBadges, wBeatGymFlags
const_def
const BIT_BOULDERBADGE ; 0
const BIT_CASCADEBADGE ; 1
const BIT_THUNDERBADGE ; 2
const BIT_RAINBOWBADGE ; 3
const BIT_SOULBADGE ; 4
const BIT_MARSHBADGE ; 5
const BIT_VOLCANOBADGE ; 6
const BIT_EARTHBADGE ; 7
DEF NUM_BADGES EQU const_value

; wStatusFlags1
const_def
const BIT_STRENGTH_ACTIVE ; 0
const BIT_SURF_ALLOWED ; 1
const_skip ; 2 ; unused
const BIT_GOT_OLD_ROD ; 3
const BIT_GOT_GOOD_ROD ; 4
const BIT_GOT_SUPER_ROD ; 5
const BIT_GAVE_SAFFRON_GUARDS_DRINK ; 6
const BIT_UNUSED_CARD_KEY ; 7

; wStatusFlags2
const_def
const BIT_WILD_ENCOUNTER_COOLDOWN ; 0
const BIT_NO_AUDIO_FADE_OUT ; 1

; wStatusFlags3
const_def
const BIT_INIT_TRADE_CENTER_FACING ; 0
const_skip 2 ; 1-2 ; unused
const BIT_WARP_FROM_CUR_SCRIPT ; 3
const BIT_ON_DUNGEON_WARP ; 4
const BIT_NO_NPC_FACE_PLAYER ; 5
const BIT_TALKED_TO_TRAINER ; 6
const BIT_PRINT_END_BATTLE_TEXT ; 7

; wStatusFlags4
const_def
const BIT_GOT_LAPRAS ; 0
const BIT_UNKNOWN_4_1 ; 1
const BIT_USED_POKECENTER ; 2
const BIT_GOT_STARTER ; 3
const BIT_NO_BATTLES ; 4
const BIT_BATTLE_OVER_OR_BLACKOUT ; 5
const BIT_LINK_CONNECTED ; 6
const BIT_INIT_SCRIPTED_MOVEMENT ; 7

; wStatusFlags5
const_def
const BIT_SCRIPTED_NPC_MOVEMENT ; 0
const BIT_UNKNOWN_5_1 ; 1
const BIT_UNKNOWN_5_2 ; 2
const_skip ; 3 ; unused
const BIT_UNKNOWN_5_4 ; 4
const BIT_DISABLE_JOYPAD ; 5
const BIT_NO_TEXT_DELAY ; 6
const BIT_SCRIPTED_MOVEMENT_STATE ; 7

; wStatusFlags6
const_def
const BIT_GAME_TIMER_COUNTING ; 0
const BIT_DEBUG_MODE ; 1
const BIT_FLY_OR_DUNGEON_WARP ; 2
const BIT_FLY_WARP ; 3
const BIT_DUNGEON_WARP ; 4
const BIT_ALWAYS_ON_BIKE ; 5
const BIT_ESCAPE_WARP ; 6

; wStatusFlags7
const_def
const BIT_TEST_BATTLE ; 0
const BIT_NO_MAP_MUSIC ; 1
const BIT_FORCED_WARP ; 2
const BIT_TRAINER_BATTLE ; 3
const BIT_USE_CUR_MAP_SCRIPT ; 4
const_skip 2 ; 5-6 ; unused
const BIT_USED_FLY ; 7

; wElite4Flags
const_def
const BIT_UNUSED_BEAT_ELITE_4 ; 0
const BIT_STARTED_ELITE_4 ; 1

; wMovementFlags
const_def
const BIT_STANDING_ON_DOOR ; 0
const BIT_EXITING_DOOR ; 1
const BIT_STANDING_ON_WARP ; 2
const_skip 3 ; 3-5 ; unused
const BIT_LEDGE_OR_FISHING ; 6
const BIT_SPINNING ; 7
13 changes: 0 additions & 13 deletions constants/script_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ DEF NUM_NPC_TRADES EQU const_value
const TRADE_DIALOGSET_EVOLUTION
const TRADE_DIALOGSET_HAPPY

; badges
; wObtainedBadges and wBeatGymFlags bits
const_def
const BIT_BOULDERBADGE ; 0
const BIT_CASCADEBADGE ; 1
const BIT_THUNDERBADGE ; 2
const BIT_RAINBOWBADGE ; 3
const BIT_SOULBADGE ; 4
const BIT_MARSHBADGE ; 5
const BIT_VOLCANOBADGE ; 6
const BIT_EARTHBADGE ; 7
DEF NUM_BADGES EQU const_value

; OaksAideScript results
DEF OAKS_AIDE_BAG_FULL EQU $00
DEF OAKS_AIDE_GOT_ITEM EQU $01
Expand Down
2 changes: 1 addition & 1 deletion data/predef_pointers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PredefPointers::
add_predef EnterMapAnim, $1E ; wrong bank
add_predef GetTileTwoStepsInFrontOfPlayer
add_predef CheckForCollisionWhenPushingBoulder
add_predef PrintStrengthTxt
add_predef PrintStrengthText
add_predef PickUpItem
add_predef PrintMoveType
add_predef LoadMovePPs
Expand Down
4 changes: 2 additions & 2 deletions data/text/text_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ _GrewLevelText::
text_ram wcd6d
text " grew"
line "to level @"
text_decimal wCurEnemyLVL, 1, 3
text_decimal wCurEnemyLevel, 1, 3
text "!@"
text_end

Expand Down Expand Up @@ -1435,7 +1435,7 @@ _RareCandyText::
text_ram wcd6d
text " grew"
line "to level @"
text_decimal wCurEnemyLVL, 1, 3
text_decimal wCurEnemyLevel, 1, 3
text "!@"
text_end

Expand Down
2 changes: 1 addition & 1 deletion engine/battle/battle_transitions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ GetBattleTransitionID_CompareLevels:
ld a, [hl]
add $3
ld e, a
ld a, [wCurEnemyLVL]
ld a, [wCurEnemyLevel]
sub e
jr nc, .highLevelEnemy
res 1, c
Expand Down
36 changes: 18 additions & 18 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ FaintEnemyPokemon:
; the player has exp all
; now, set the gain exp flag for every party member
; half of the total stat exp and normal exp will divided evenly amongst every party member
ld a, $1
ld a, TRUE
ld [wBoostExpByExpAll], a
ld a, [wPartyCount]
ld b, 0
Expand Down Expand Up @@ -924,8 +924,8 @@ TrainerBattleVictory:
cp RIVAL3 ; final battle against rival
jr nz, .notrival
ld b, MUSIC_DEFEATED_GYM_LEADER
ld hl, wFlags_D733
set 1, [hl]
ld hl, wStatusFlags7
set BIT_NO_MAP_MUSIC, [hl]
.notrival
ld a, [wLinkState]
cp LINK_STATE_BATTLING
Expand Down Expand Up @@ -1157,9 +1157,9 @@ HandlePlayerBlackOut:
ld hl, LinkBattleLostText
.noLinkBattle
call PrintText
ld a, [wd732]
res 5, a
ld [wd732], a
ld a, [wStatusFlags6]
res BIT_ALWAYS_ON_BIKE, a
ld [wStatusFlags6], a
call ClearScreen
scf
ret
Expand All @@ -1179,10 +1179,10 @@ LinkBattleLostText:
; slides pic of fainted mon downwards until it disappears
; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing
SlideDownFaintedMonPic:
ld a, [wd730]
ld a, [wStatusFlags5]
push af
set 6, a
ld [wd730], a
set BIT_NO_TEXT_DELAY, a
ld [wStatusFlags5], a
ld b, 7 ; number of times to slide
.slideStepLoop ; each iteration, the mon is slid down one row
push bc
Expand Down Expand Up @@ -1221,7 +1221,7 @@ SlideDownFaintedMonPic:
dec b
jr nz, .slideStepLoop
pop af
ld [wd730], a
ld [wStatusFlags5], a
ret

SevenSpacesText:
Expand Down Expand Up @@ -1344,7 +1344,7 @@ EnemySendOutFirstMon:
ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
ld a, [hl]
ld [wCurEnemyLVL], a
ld [wCurEnemyLevel], a
ld a, [wWhichPokemon]
inc a
ld hl, wEnemyPartyCount
Expand Down Expand Up @@ -2558,7 +2558,7 @@ MoveSelectionMenu:
cp LINK_STATE_BATTLING
jr z, .matchedkeyspicked
; Disable left, right, and START buttons in regular battles.
ld a, [wFlags_D733]
ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT
jr z, .matchedkeyspicked
Expand Down Expand Up @@ -2587,7 +2587,7 @@ SelectMenuItem:
jr .select
.battleselect
; Hide move swap cursor in TestBattle.
ld a, [wFlags_D733]
ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
; This causes PrintMenuItem to not run in TestBattle.
; MoveSelectionMenu still draws part of its window, an issue
Expand Down Expand Up @@ -4404,7 +4404,7 @@ GetEnemyMonStat:
ret
.notLinkBattle
ld a, [wEnemyMonLevel]
ld [wCurEnemyLVL], a
ld [wCurEnemyLevel], a
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
call GetMonHeader
Expand Down Expand Up @@ -6092,7 +6092,7 @@ GetCurrentMove:
.player
ld de, wPlayerMoveNum
; Apply InitBattleVariables to TestBattle.
ld a, [wFlags_D733]
ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
ld a, [wTestBattlePlayerSelectedMove]
jr nz, .selected
Expand Down Expand Up @@ -6143,7 +6143,7 @@ LoadEnemyMonData:
ld [hli], a
ld [hl], b
ld de, wEnemyMonLevel
ld a, [wCurEnemyLVL]
ld a, [wCurEnemyLevel]
ld [de], a
inc de
ld b, $0
Expand Down Expand Up @@ -6776,7 +6776,7 @@ InitOpponent:
jr InitBattleCommon

DetermineWildOpponent:
ld a, [wd732]
ld a, [wStatusFlags6]
bit BIT_DEBUG_MODE, a
jr z, .notDebugMode
ldh a, [hJoyHeld]
Expand All @@ -6794,7 +6794,7 @@ InitBattleCommon:
ld hl, wLetterPrintingDelayFlags
ld a, [hl]
push af
res 1, [hl]
res BIT_TEXT_DELAY, [hl] ; no delay
callfar InitBattleVariables
ld a, [wEnemyMonSpecies2]
sub OPP_ID_OFFSET
Expand Down
4 changes: 2 additions & 2 deletions engine/battle/effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ SwitchAndTeleportEffect:
ld a, [wIsInBattle]
dec a
jr nz, .notWildBattle1
ld a, [wCurEnemyLVL]
ld a, [wCurEnemyLevel]
ld b, a
ld a, [wBattleMonLevel]
cp b ; is the player's level greater than the enemy's level?
Expand Down Expand Up @@ -856,7 +856,7 @@ SwitchAndTeleportEffect:
jr nz, .notWildBattle2
ld a, [wBattleMonLevel]
ld b, a
ld a, [wCurEnemyLVL]
ld a, [wCurEnemyLevel]
cp b
jr nc, .enemyMoveWasSuccessful
add b
Expand Down
Loading

0 comments on commit 8fafca7

Please sign in to comment.