Skip to content

Commit

Permalink
Identify various flag labels and bit constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jun 24, 2024
1 parent fc23e72 commit f7fa11f
Show file tree
Hide file tree
Showing 127 changed files with 990 additions and 952 deletions.
3 changes: 0 additions & 3 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
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
102 changes: 102 additions & 0 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
; wStrengthFlags::
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

; wStatusFlags::
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_UNKNOWN_3_6 ; 6
const BIT_UNKNOWN_3_7 ; 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_JOYPAD ; 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

; wBeatLorelei::
const_def
const BIT_UNKNOWN_LORELEI_0 ; 0
const BIT_BEAT_LORELEI ; 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
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
26 changes: 13 additions & 13 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
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 @@ -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 @@ -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 @@ -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 Down
4 changes: 2 additions & 2 deletions engine/battle/end_of_battle.asm
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ EndOfBattle:
ld [hli], a
dec b
jr nz, .loop
ld hl, wd72c
set 0, [hl]
ld hl, wStatusFlags2
set BIT_WILD_ENCOUNTER_COOLDOWN, [hl]
call WaitForSoundToFinish
call GBPalWhiteOut
ld a, $ff
Expand Down
4 changes: 2 additions & 2 deletions engine/battle/wild_encounters.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ TryDoWildEncounter:
ld a, [wNPCMovementScriptPointerTableNum]
and a
ret nz
ld a, [wd736]
and a
ld a, [wMovementFlags]
and a ; is player exiting a door, jumping over a ledge, or fishing?
ret nz
callfar IsPlayerStandingOnDoorTileOrWarpTile
jr nc, .notStandingOnDoorOrWarpTile
Expand Down
4 changes: 2 additions & 2 deletions engine/debug/debug_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ IF DEF(_DEBUG)
jp z, TestBattle

; DEBUG
ld hl, wd732
ld hl, wStatusFlags6
set BIT_DEBUG_MODE, [hl]
jp StartNewGameDebug

Expand All @@ -80,7 +80,7 @@ TestBattle: ; unreferenced except in _DEBUG
ld a, 1 << BIT_EARTHBADGE
ld [wObtainedBadges], a

ld hl, wFlags_D733
ld hl, wStatusFlags7
set BIT_TEST_BATTLE, [hl]

; wNumBagItems and wBagItems are not initialized here,
Expand Down
12 changes: 6 additions & 6 deletions engine/events/black_out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ResetStatusAndHalveMoneyOnBlackout::
ld [wNPCMovementScriptFunctionNum], a
ldh [hJoyHeld], a
ld [wNPCMovementScriptPointerTableNum], a
ld [wFlags_0xcd60], a
ld [wStrengthFlags], a

ldh [hMoney], a
ldh [hMoney + 1], a
Expand Down Expand Up @@ -37,10 +37,10 @@ ResetStatusAndHalveMoneyOnBlackout::
ld [wPlayerMoney + 2], a

.lostmoney
ld hl, wd732
set 2, [hl]
res 3, [hl]
set 6, [hl]
ld a, %11111111
ld hl, wStatusFlags6
set BIT_FLY_OR_DUNGEON_WARP, [hl]
res BIT_FLY_WARP, [hl]
set BIT_ESCAPE_WARP, [hl]
ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a
predef_jump HealParty
8 changes: 4 additions & 4 deletions engine/events/cinnabar_lab.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GiveFossilToCinnabarLab::
ld hl, wd730
set 6, [hl]
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
xor a
ld [wCurrentMenuItem], a
ld a, A_BUTTON | B_BUTTON
Expand All @@ -24,8 +24,8 @@ GiveFossilToCinnabarLab::
call TextBoxBorder
call UpdateSprites
call PrintFossilsInBag
ld hl, wd730
res 6, [hl]
ld hl, wStatusFlags5
res BIT_NO_TEXT_DELAY, [hl]
call HandleMenuInput
bit BIT_B_BUTTON, a
jr nz, .cancelledGivingFossil
Expand Down
8 changes: 4 additions & 4 deletions engine/events/diploma.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ DisplayDiploma::
call ClearScreen
xor a
ld [wUpdateSpritesEnabled], a
ld hl, wd730
set 6, [hl]
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
call DisableLCD
ld hl, CircleTile
ld de, vChars2 tile CIRCLE_TILE_ID
Expand Down Expand Up @@ -65,8 +65,8 @@ DisplayDiploma::
ld a, $90
ldh [rOBP0], a
call WaitForTextScrollButtonPress
ld hl, wd730
res 6, [hl]
ld hl, wStatusFlags5
res BIT_NO_TEXT_DELAY, [hl]
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
call Delay3
Expand Down
8 changes: 4 additions & 4 deletions engine/events/display_pokedex.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
_DisplayPokedex::
ld hl, wd730
set 6, [hl]
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
predef ShowPokedexData
ld hl, wd730
res 6, [hl]
ld hl, wStatusFlags5
res BIT_NO_TEXT_DELAY, [hl]
call ReloadMapData
ld c, 10
call DelayFrames
Expand Down
8 changes: 4 additions & 4 deletions engine/events/hidden_objects/bills_house_pc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ BillsHousePokemonList::
ld a, 1
ld [wTopMenuItemX], a
.billsPokemonLoop
ld hl, wd730
set 6, [hl]
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
hlcoord 0, 0
ld b, 10
ld c, 9
Expand Down Expand Up @@ -113,8 +113,8 @@ BillsHousePokemonList::
call LoadScreenTilesFromBuffer2
jr .billsPokemonLoop
.cancel
ld hl, wd730
res 6, [hl]
ld hl, wStatusFlags5
res BIT_NO_TEXT_DELAY, [hl]
call LoadScreenTilesFromBuffer2
jp TextScriptEnd

Expand Down
Loading

0 comments on commit f7fa11f

Please sign in to comment.