aboutsummaryrefslogtreecommitdiffstats
path: root/home
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
committerdannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
commita02a98ee7ada1a658e28698484058be2796dc0df (patch)
tree945986054565bd8b5212fc755415096050d1d3a8 /home
parentUse long option flags for rgbgfx, same as tools/gfx (diff)
parentUse `const_skip` (diff)
downloadpokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.gz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.xz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'home')
-rw-r--r--home/audio.asm4
-rw-r--r--home/copy.asm4
-rw-r--r--home/fade_audio.asm4
-rw-r--r--home/give.asm8
-rw-r--r--home/init.asm4
-rw-r--r--home/inventory.asm2
-rw-r--r--home/item.asm6
-rw-r--r--home/item_price.asm4
-rw-r--r--home/lcd.asm4
-rw-r--r--home/list_menu.asm44
-rw-r--r--home/load_font.asm6
-rw-r--r--home/map_objects.asm8
-rw-r--r--home/move_mon.asm4
-rw-r--r--home/names.asm37
-rw-r--r--home/names2.asm14
-rw-r--r--home/npc_movement.asm14
-rw-r--r--home/overworld.asm277
-rw-r--r--home/pathfinding.asm6
-rw-r--r--home/pics.asm2
-rw-r--r--home/play_time.asm16
-rw-r--r--home/pokemon.asm50
-rw-r--r--home/predef_text.asm4
-rw-r--r--home/print_bcd.asm28
-rw-r--r--home/print_text.asm10
-rw-r--r--home/reload_sprites.asm2
-rw-r--r--home/reload_tiles.asm4
-rw-r--r--home/serial.asm2
-rw-r--r--home/text.asm8
-rw-r--r--home/text_script.asm25
-rw-r--r--home/trainers.asm62
-rw-r--r--home/uncompress.asm21
-rw-r--r--home/window.asm14
32 files changed, 353 insertions, 345 deletions
diff --git a/home/audio.asm b/home/audio.asm
index 48e00f67..6e891e9a 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -10,8 +10,8 @@ PlayDefaultMusicFadeOutCurrent::
; Fade out the current music and then play the default music.
ld c, 10
ld d, 0
- ld a, [wd72e]
- bit 5, a ; has a battle just ended?
+ ld a, [wStatusFlags4]
+ bit BIT_BATTLE_OVER_OR_BLACKOUT, a
jr z, PlayDefaultMusicCommon
xor a
ld [wLastMusicSoundID], a
diff --git a/home/copy.asm b/home/copy.asm
index b239d951..2d07945c 100644
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -35,7 +35,7 @@ CopyData::
CopyVideoDataAlternate::
ldh a, [rLCDC]
- bit 7, a ; LCD enabled?
+ bit rLCDC_ENABLE, a ; LCD enabled?
jp nz, CopyVideoData ; if yes, then copy video data
push hl
ld h, d
@@ -55,7 +55,7 @@ CopyVideoDataAlternate::
CopyVideoDataDoubleAlternate::
ldh a, [rLCDC]
- bit 7, a ; LCD enabled?
+ bit rLCDC_ENABLE, a ; LCD enabled?
jp nz, CopyVideoDataDouble ; if yes, then copy video data
push de
ld d, h
diff --git a/home/fade_audio.asm b/home/fade_audio.asm
index f4e77c3f..373b9bf8 100644
--- a/home/fade_audio.asm
+++ b/home/fade_audio.asm
@@ -2,8 +2,8 @@ FadeOutAudio::
ld a, [wAudioFadeOutControl]
and a ; currently fading out audio?
jr nz, .fadingOut
- ld a, [wd72c]
- bit 1, a
+ ld a, [wStatusFlags2]
+ bit BIT_NO_AUDIO_FADE_OUT, a
ret nz
ld a, $77
ldh [rNR50], a
diff --git a/home/give.asm b/home/give.asm
index f446cf36..9f51450a 100644
--- a/home/give.asm
+++ b/home/give.asm
@@ -3,8 +3,8 @@ GiveItem::
; and copy the item's name to wStringBuffer.
; Return carry on success.
ld a, b
- ld [wd11e], a
- ld [wcf91], a
+ ld [wNamedObjectIndex], a
+ ld [wCurItem], a
ld a, c
ld [wItemQuantity], a
ld hl, wNumBagItems
@@ -18,9 +18,9 @@ GiveItem::
GivePokemon::
; Give the player monster b at level c.
ld a, b
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld a, c
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
farjp _GivePokemon
diff --git a/home/init.asm b/home/init.asm
index f6d6d372..d555e598 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/inventory.asm b/home/inventory.asm
index 1100666f..e4f9a261 100644
--- a/home/inventory.asm
+++ b/home/inventory.asm
@@ -28,7 +28,7 @@ RemoveItemFromInventory::
; function to add an item (in varying quantities) to the player's bag or PC box
; INPUT:
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
-; [wcf91] = item ID
+; [wCurItem] = item ID
; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory::
diff --git a/home/item.asm b/home/item.asm
index f27d46f4..9e7f02f9 100644
--- a/home/item.asm
+++ b/home/item.asm
@@ -1,7 +1,7 @@
; uses an item
; UseItem is used with dummy items to perform certain other functions as well
; INPUT:
-; [wcf91] = item ID
+; [wCurItem] = item ID
; OUTPUT:
; [wActionResultOrTookBattleTurn] = success
; 00: unsuccessful
@@ -13,7 +13,7 @@ UseItem::
; confirms the item toss and then tosses the item
; INPUT:
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
-; [wcf91] = item ID
+; [wCurItem] = item ID
; [wWhichPokemon] = index of item within inventory
; [wItemQuantity] = quantity to toss
; OUTPUT:
@@ -33,7 +33,7 @@ TossItem::
; checks if an item is a key item
; INPUT:
-; [wcf91] = item ID
+; [wCurItem] = item ID
; OUTPUT:
; [wIsKeyItem] = result
; 00: item is not key item
diff --git a/home/item_price.asm b/home/item_price.asm
index 39749ee9..fa47693a 100644
--- a/home/item_price.asm
+++ b/home/item_price.asm
@@ -1,6 +1,6 @@
GetItemPrice::
; Stores item's price as BCD at hItemPrice (3 bytes)
-; Input: [wcf91] = item id
+; Input: [wCurItem] = item id
ldh a, [hLoadedROMBank]
push af
ld a, [wListMenuID]
@@ -14,7 +14,7 @@ GetItemPrice::
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wcf91] ; a contains item id
+ ld a, [wCurItem]
cp HM01
jr nc, .getTMPrice
ld bc, $3
diff --git a/home/lcd.asm b/home/lcd.asm
index 5c496824..aef6d43f 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/list_menu.asm b/home/list_menu.asm
index 13bcec59..095cae27 100644
--- a/home/list_menu.asm
+++ b/home/list_menu.asm
@@ -15,8 +15,8 @@ DisplayListMenuID::
ld a, BANK(DisplayBattleMenu)
.bankswitch
call BankswitchHome
- ld hl, wd730
- set 6, [hl] ; turn off letter printing delay
+ ld hl, wStatusFlags5
+ set BIT_NO_TEXT_DELAY, [hl]
xor a
ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
ld [wListCount], a
@@ -124,28 +124,30 @@ DisplayListMenuIDLoop::
ld b, 0
add hl, bc
ld a, [hl]
- ld [wcf91], a
+ ld [wCurListMenuItem], a
ld a, [wListMenuID]
and a ; PCPOKEMONLISTMENU?
jr z, .pokemonList
+; if it's an item menu
+ assert wCurListMenuItem == wCurItem
push hl
call GetItemPrice
pop hl
ld a, [wListMenuID]
cp ITEMLISTMENU
jr nz, .skipGettingQuantity
-; if it's an item menu
inc hl
ld a, [hl] ; a = item quantity
ld [wMaxItemQuantity], a
.skipGettingQuantity
- ld a, [wcf91]
- ld [wd0b5], a
+ ld a, [wCurItem]
+ ld [wNameListIndex], a
ld a, BANK(ItemNames)
ld [wPredefBank], a
call GetName
jr .storeChosenEntry
.pokemonList
+ assert wCurListMenuItem == wCurPartySpecies
ld hl, wPartyCount
ld a, [wListPointer]
cp l ; is it a list of party pokemon or box pokemon?
@@ -156,7 +158,7 @@ DisplayListMenuIDLoop::
ld a, [wWhichPokemon]
call GetPartyMonName
.storeChosenEntry ; store the menu entry that the player chose and return
- ld de, wcd6d
+ ld de, wNameBuffer
call CopyToStringBuffer
ld a, CHOSE_MENU_ITEM
ld [wMenuExitMethod], a
@@ -164,8 +166,8 @@ DisplayListMenuIDLoop::
ld [wChosenMenuItem], a
xor a
ldh [hJoy7], a ; joypad state update flag
- ld hl, wd730
- res 6, [hl] ; turn on letter printing delay
+ ld hl, wStatusFlags5
+ res BIT_NO_TEXT_DELAY, [hl]
jp BankswitchBack
.checkOtherKeys ; check B, SELECT, Up, and Down keys
bit BIT_B_BUTTON, a
@@ -323,8 +325,8 @@ ExitListMenu::
ld [wMenuWatchMovingOutOfBounds], a
xor a
ldh [hJoy7], a
- ld hl, wd730
- res 6, [hl]
+ ld hl, wStatusFlags5
+ res BIT_NO_TEXT_DELAY, [hl]
call BankswitchBack
xor a
ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
@@ -362,7 +364,7 @@ PrintListMenuEntries::
ld a, b
ld [wWhichPokemon], a
ld a, [de]
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
cp $ff
jp z, .printCancelMenuItem
push bc
@@ -410,8 +412,8 @@ PrintListMenuEntries::
push hl
ld a, [de]
ld de, ItemPrices
- ld [wcf91], a
- call GetItemPrice ; get price
+ ld [wCurItem], a
+ call GetItemPrice
pop hl
ld bc, SCREEN_WIDTH + 5 ; 1 row down and 5 columns right
add hl, bc
@@ -422,7 +424,7 @@ PrintListMenuEntries::
and a ; PCPOKEMONLISTMENU?
jr nz, .skipPrintingPokemonLevel
.printPokemonLevel
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
push af
push hl
ld hl, wPartyCount
@@ -455,7 +457,7 @@ PrintListMenuEntries::
add hl, bc
call PrintLevel
pop af
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
.skipPrintingPokemonLevel
pop hl
pop de
@@ -464,8 +466,8 @@ PrintListMenuEntries::
cp ITEMLISTMENU
jr nz, .nextListEntry
.printItemQuantity
- ld a, [wd11e]
- ld [wcf91], a
+ ld a, [wNamedObjectIndex]
+ ld [wCurItem], a
call IsKeyItem ; check if item is unsellable
ld a, [wIsKeyItem]
and a ; is the item unsellable?
@@ -475,18 +477,18 @@ PrintListMenuEntries::
add hl, bc
ld a, "×"
ld [hli], a
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
push af
ld a, [de]
ld [wMaxItemQuantity], a
push de
- ld de, wd11e
+ ld de, wTempByteValue
ld [de], a
lb bc, 1, 2
call PrintNumber
pop de
pop af
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
pop hl
.skipPrintingItemQuantity
inc de
diff --git a/home/load_font.asm b/home/load_font.asm
index 8ed0f0a7..be54a287 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 a54e8f31..2359c7ca 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -56,8 +56,8 @@ StartSimulatingJoypadStates::
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld [wSpritePlayerStateData2MovementByte1], a
- ld hl, wd730
- set 7, [hl]
+ ld hl, wStatusFlags5
+ set BIT_SCRIPTED_MOVEMENT_STATE, [hl]
ret
IsItemInBag::
@@ -125,7 +125,7 @@ Func_3467::
ret
DisplayPokedex::
- ld [wd11e], a
+ ld [wPokedexNum], a
farjp _DisplayPokedex
SetSpriteFacingDirectionAndDelay::
@@ -301,7 +301,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/move_mon.asm b/home/move_mon.asm
index c766fbd5..45b10322 100644
--- a/home/move_mon.asm
+++ b/home/move_mon.asm
@@ -172,7 +172,7 @@ CalcStat::
ldh [hMultiplicand+1], a
xor a
ldh [hMultiplicand], a
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
ldh [hMultiplier], a
call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level
ldh a, [hMultiplicand]
@@ -190,7 +190,7 @@ CalcStat::
cp $1
ld a, 5 ; + 5 for non-HP stat
jr nz, .notHPStat
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
ld b, a
ldh a, [hMultiplicand+2]
add b
diff --git a/home/names.asm b/home/names.asm
index f7751fa0..7330a065 100644
--- a/home/names.asm
+++ b/home/names.asm
@@ -5,17 +5,17 @@ GetMonName::
ld a, BANK(MonsterNames)
ldh [hLoadedROMBank], a
ld [MBC1RomBank], a
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
dec a
ld hl, MonsterNames
- ld c, 10
+ ld c, NAME_LENGTH - 1
ld b, 0
call AddNTimes
- ld de, wcd6d
+ ld de, wNameBuffer
push de
- ld bc, 10
+ ld bc, NAME_LENGTH - 1
call CopyData
- ld hl, wcd6d + 10
+ ld hl, wNameBuffer + NAME_LENGTH - 1
ld [hl], "@"
pop de
pop af
@@ -25,15 +25,14 @@ GetMonName::
ret
GetItemName::
-; given an item ID at [wd11e], store the name of the item into a string
-; starting at wcd6d
+; given an item ID at [wNamedObjectIndex], store the name of the item in wNameBuffer
push hl
push bc
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
cp HM01 ; is this a TM/HM?
jr nc, .Machine
- ld [wd0b5], a
+ ld [wNameListIndex], a
ld a, ITEM_NAME
ld [wNameListType], a
ld a, BANK(ItemNames)
@@ -44,24 +43,24 @@ GetItemName::
.Machine
call GetMachineName
.Finish
- ld de, wcd6d ; pointer to where item name is stored in RAM
+ ld de, wNameBuffer
pop bc
pop hl
ret
GetMachineName::
-; copies the name of the TM/HM in [wd11e] to wcd6d
+; copies the name of the TM/HM in [wNamedObjectIndex] to wNameBuffer
push hl
push de
push bc
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
push af
cp TM01 ; is this a TM? [not HM]
jr nc, .WriteTM
; if HM, then write "HM" and add NUM_HMS to the item ID, so we can reuse the
; TM printing code
add NUM_HMS
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
ld hl, HiddenPrefix ; points to "HM"
ld bc, 2
jr .WriteMachinePrefix
@@ -69,11 +68,11 @@ GetMachineName::
ld hl, TechnicalPrefix ; points to "TM"
ld bc, 2
.WriteMachinePrefix
- ld de, wcd6d
+ ld de, wNameBuffer
call CopyData
; now get the machine number and convert it to text
- ld a, [wd11e]
+ ld a, [wNamedObjectIndex]
sub TM01 - 1
ld b, "0"
.FirstDigit
@@ -95,7 +94,7 @@ GetMachineName::
ld a, "@"
ld [de], a
pop af
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
pop bc
pop de
pop hl
@@ -131,11 +130,11 @@ GetMoveName::
push hl
ld a, MOVE_NAME
ld [wNameListType], a
- ld a, [wd11e]
- ld [wd0b5], a
+ ld a, [wNamedObjectIndex]
+ ld [wNameListIndex], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
call GetName
- ld de, wcd6d ; pointer to where move name is stored in RAM
+ ld de, wNameBuffer
pop hl
ret
diff --git a/home/names2.asm b/home/names2.asm
index b0be05df..d7a95e5c 100644
--- a/home/names2.asm
+++ b/home/names2.asm
@@ -10,13 +10,13 @@ NamePointers::
GetName::
; arguments:
-; [wd0b5] = which name
+; [wNameListIndex] = which name
; [wNameListType] = which list
; [wPredefBank] = bank of list
;
; returns pointer to name in de
- ld a, [wd0b5]
- ld [wd11e], a
+ ld a, [wNameListIndex]
+ ld [wNamedObjectIndex], a
; TM names are separate from item names.
; BUG: This applies to all names instead of just items.
@@ -66,7 +66,7 @@ GetName::
ld h, a
ldh a, [hSwapTemp + 1]
ld l, a
- ld a, [wd0b5]
+ ld a, [wNameListIndex]
ld b, a ; wanted entry
ld c, 0 ; entry counter
.nextName
@@ -82,14 +82,14 @@ GetName::
jr nz, .nextName
ld h, d
ld l, e
- ld de, wcd6d
+ ld de, wNameBuffer
ld bc, NAME_BUFFER_LENGTH
call CopyData
.gotPtr
ld a, e
- ld [wUnusedCF8D], a
+ ld [wUnusedNamePointer], a
ld a, d
- ld [wUnusedCF8D + 1], a
+ ld [wUnusedNamePointer + 1], a
pop de
pop bc
pop hl
diff --git a/home/npc_movement.asm b/home/npc_movement.asm
index cc40b1af..83c837a8 100644
--- a/home/npc_movement.asm
+++ b/home/npc_movement.asm
@@ -4,17 +4,17 @@ IsPlayerCharacterBeingControlledByGame::
ld a, [wNPCMovementScriptPointerTableNum]
and a
ret nz
- ld a, [wd736]
- bit 1, a ; currently stepping down from door bit
+ ld a, [wMovementFlags]
+ bit BIT_EXITING_DOOR, a
ret nz
- ld a, [wd730]
- and $80
+ ld a, [wStatusFlags5]
+ and 1 << BIT_SCRIPTED_MOVEMENT_STATE
ret
RunNPCMovementScript::
- ld hl, wd736
- bit 0, [hl]
- res 0, [hl]
+ ld hl, wMovementFlags
+ bit BIT_STANDING_ON_DOOR, [hl]
+ res BIT_STANDING_ON_DOOR, [hl]
jr nz, .playerStepOutFromDoor
ld a, [wNPCMovementScriptPointerTableNum]
and a
diff --git a/home/overworld.asm b/home/overworld.asm
index 819f1b72..f9aaa089 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -4,39 +4,39 @@ EnterMap::
ld [wJoyIgnore], a
call LoadMapData
farcall ClearVariablesOnEnterMap
- ld hl, wd72c
- bit 0, [hl] ; has the player already made 3 steps since the last battle?
+ ld hl, wStatusFlags2
+ bit BIT_WILD_ENCOUNTER_COOLDOWN, [hl]
jr z, .skipGivingThreeStepsOfNoRandomBattles
ld a, 3 ; minimum number of steps between battles
ld [wNumberOfNoRandomBattleStepsLeft], a
.skipGivingThreeStepsOfNoRandomBattles
- ld hl, wd72e
- bit 5, [hl] ; did a battle happen immediately before this?
- res 5, [hl] ; unset the "battle just happened" flag
+ ld hl, wStatusFlags4
+ bit BIT_BATTLE_OVER_OR_BLACKOUT, [hl]
+ res BIT_BATTLE_OVER_OR_BLACKOUT, [hl]
call z, ResetUsingStrengthOutOfBattleBit
call nz, MapEntryAfterBattle
- ld hl, wd732
+ ld hl, wStatusFlags6
ld a, [hl]
- and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ and (1 << BIT_FLY_WARP) | (1 << BIT_DUNGEON_WARP)
jr z, .didNotEnterUsingFlyWarpOrDungeonWarp
farcall EnterMapAnim
call UpdateSprites
- ld hl, wd732
- res 3, [hl]
- ld hl, wd72e
- res 4, [hl]
+ ld hl, wStatusFlags6
+ res BIT_FLY_WARP, [hl]
+ ld hl, wStatusFlags4
+ res BIT_NO_BATTLES, [hl]
.didNotEnterUsingFlyWarpOrDungeonWarp
call IsSurfingPikachuInParty
farcall CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road
- ld hl, wd732
- bit 4, [hl]
- res 4, [hl]
- ld hl, wd72d
- res 5, [hl]
+ ld hl, wStatusFlags6
+ bit BIT_DUNGEON_WARP, [hl]
+ res BIT_DUNGEON_WARP, [hl]
+ ld hl, wStatusFlags3
+ 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
@@ -55,18 +55,18 @@ OverworldLoopLessDelay::
ld a, [wSafariZoneGameOver]
and a
jp nz, WarpFound2
- ld hl, wd72d
- bit 3, [hl]
- res 3, [hl]
+ ld hl, wStatusFlags3
+ bit BIT_WARP_FROM_CUR_SCRIPT, [hl]
+ res BIT_WARP_FROM_CUR_SCRIPT, [hl]
jp nz, WarpFound2
- ld a, [wd732]
- and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ ld a, [wStatusFlags6]
+ and (1 << BIT_FLY_WARP) | (1 << BIT_DUNGEON_WARP)
jp nz, HandleFlyWarpOrDungeonWarp
ld a, [wCurOpponent]
and a
jp nz, .newBattle
- ld a, [wd730]
- bit 7, a ; are we simulating button presses?
+ ld a, [wStatusFlags5]
+ bit BIT_SCRIPTED_MOVEMENT_STATE, a
jr z, .notSimulating
ldh a, [hJoyHeld]
jr .checkIfStartIsPressed
@@ -77,14 +77,14 @@ OverworldLoopLessDelay::
jr z, .startButtonNotPressed
; if START is pressed
xor a ; TEXT_START_MENU
- ldh [hSpriteIndexOrTextID], a
+ ldh [hTextID], a
jp .displayDialogue
.startButtonNotPressed
bit BIT_A_BUTTON, a
jp z, .checkIfDownButtonIsPressed
; if A is pressed
- ld a, [wd730]
- bit 2, a
+ ld a, [wStatusFlags5]
+ bit BIT_UNKNOWN_5_2, a
jp nz, .noDirectionButtonsPressed
call IsPlayerCharacterBeingControlledByGame
jr nz, .checkForOpponent
@@ -96,16 +96,16 @@ OverworldLoopLessDelay::
ld [wd436], a ; new yellow address
call IsSpriteOrSignInFrontOfPlayer
call Func_0ffe
- ldh a, [hSpriteIndexOrTextID]
+ ldh a, [hTextID]
and a
jp z, OverworldLoop
.displayDialogue
predef GetTileAndCoordsInFrontOfPlayer
call UpdateSprites
- ld a, [wFlags_0xcd60]
- bit 2, a
+ ld a, [wMiscFlags]
+ bit BIT_TURNING, a
jr nz, .checkForOpponent
- bit 0, a
+ bit BIT_SEEN_BY_TRAINER, a
jr nz, .checkForOpponent
lda_coord 8, 9
ld [wTilePlayerStandingOn], a ; checked when using Surf for forbidden tile pairs
@@ -124,8 +124,8 @@ OverworldLoopLessDelay::
.noDirectionButtonsPressed
call UpdateSprites
- ld hl, wFlags_0xcd60
- res 2, [hl]
+ ld hl, wMiscFlags
+ res BIT_TURNING, [hl]
xor a
ld [wd435], a
ld a, 1
@@ -174,8 +174,8 @@ OverworldLoopLessDelay::
.handleDirectionButtonPress
ld [wPlayerDirection], a ; new direction
- ld a, [wd730]
- bit 7, a ; are we simulating button presses?
+ ld a, [wStatusFlags5]
+ bit BIT_SCRIPTED_MOVEMENT_STATE, a
jr nz, .noDirectionChange ; ignore direction changes if we are
ld a, [wCheckFor180DegreeTurn]
and a
@@ -188,8 +188,8 @@ OverworldLoopLessDelay::
ld a, $8
ld [wd435], a
; unlike in red/blue, yellow does not have the 180 degrees odd code
- ld hl, wFlags_0xcd60
- set 2, [hl]
+ ld hl, wMiscFlags
+ set BIT_TURNING, [hl]
xor a
ld [wCheckFor180DegreeTurn], a
ld a, [wPlayerDirection]
@@ -210,8 +210,8 @@ OverworldLoopLessDelay::
jr nc, .noCollision
; collision occurred
push hl
- ld hl, wd736
- bit 2, [hl] ; standing on warp flag
+ ld hl, wMovementFlags
+ bit BIT_STANDING_ON_WARP, [hl]
pop hl
jp z, OverworldLoop
; collision occurred while standing on a warp
@@ -236,8 +236,8 @@ OverworldLoopLessDelay::
call UpdateSprites
.moveAhead2
- ld hl, wFlags_0xcd60
- res 2, [hl]
+ ld hl, wMiscFlags
+ res BIT_TURNING, [hl]
xor a
ld [wd435], a
call DoBikeSpeedup
@@ -247,7 +247,7 @@ OverworldLoopLessDelay::
jp nz, CheckMapConnections ; it seems like this check will never succeed (the other place where CheckMapConnections is run works)
; walking animation finished
call StepCountCheck
- CheckEvent EVENT_IN_SAFARI_ZONE ; in the safari zone?
+ CheckEvent EVENT_IN_SAFARI_ZONE
jr z, .notSafariZone
farcall SafariZoneCheckSteps
ld a, [wSafariZoneGameOver]
@@ -263,17 +263,17 @@ OverworldLoopLessDelay::
jp nz, HandleBlackOut ; if all pokemon fainted
.newBattle
call NewBattle
- ld hl, wd736
- res 2, [hl] ; standing on warp flag
+ ld hl, wMovementFlags
+ res BIT_STANDING_ON_WARP, [hl]
jp nc, CheckWarpsNoCollision ; check for warps if there was no battle
.battleOccurred
- ld hl, wd72d
- res 6, [hl]
- ld hl, wFlags_D733
- res 3, [hl]
+ ld hl, wStatusFlags3
+ res BIT_TALKED_TO_TRAINER, [hl]
+ 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]
@@ -281,8 +281,8 @@ OverworldLoopLessDelay::
jr nz, .notCinnabarGym
SetEvent EVENT_2A7
.notCinnabarGym
- ld hl, wd72e
- set 5, [hl]
+ ld hl, wStatusFlags4
+ set BIT_BATTLE_OVER_OR_BLACKOUT, [hl]
ld a, [wCurMap]
cp OAKS_LAB
jp z, .noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
@@ -296,20 +296,20 @@ OverworldLoopLessDelay::
jp EnterMap
StepCountCheck::
- ld a, [wd730]
- bit 7, a
+ ld a, [wStatusFlags5]
+ bit BIT_SCRIPTED_MOVEMENT_STATE, a
jr nz, .doneStepCounting ; if button presses are being simulated, don't count steps
; step counting
ld hl, wStepCounter
dec [hl]
- ld a, [wd72c]
- bit 0, a
+ ld a, [wStatusFlags2]
+ bit BIT_WILD_ENCOUNTER_COOLDOWN, a
jr z, .doneStepCounting
ld hl, wNumberOfNoRandomBattleStepsLeft
dec [hl]
jr nz, .doneStepCounting
- ld hl, wd72c
- res 0, [hl] ; indicate that the player has stepped thrice since the last battle
+ ld hl, wStatusFlags2
+ res BIT_WILD_ENCOUNTER_COOLDOWN, [hl] ; indicate that the player has stepped thrice since the last battle
.doneStepCounting
ret
@@ -322,13 +322,13 @@ AllPokemonFainted::
; function to determine if there will be a battle and execute it (either a trainer battle or wild battle)
; sets carry if a battle occurred and unsets carry if not
NewBattle::
- ld a, [wd72d]
- bit 4, a
+ ld a, [wStatusFlags3]
+ bit BIT_ON_DUNGEON_WARP, a
jr nz, .noBattle
call IsPlayerCharacterBeingControlledByGame
jr nz, .noBattle ; no battle if the player character is under the game's control
- ld a, [wd72e]
- bit 4, a
+ ld a, [wStatusFlags4]
+ bit BIT_NO_BATTLES, a
jr nz, .noBattle
farjp InitBattle
.noBattle
@@ -340,8 +340,8 @@ DoBikeSpeedup::
ld a, [wWalkBikeSurfState]
dec a ; riding a bike?
ret nz
- ld a, [wd736]
- bit 6, a
+ ld a, [wMovementFlags]
+ bit BIT_LEDGE_OR_FISHING, a
ret nz
ld a, [wNPCMovementScriptPointerTableNum]
and a
@@ -379,8 +379,8 @@ CheckWarpsNoCollisionLoop::
; if a match was found
push hl
push bc
- ld hl, wd736
- set 2, [hl] ; standing on warp flag
+ ld hl, wMovementFlags
+ set BIT_STANDING_ON_WARP, [hl]
farcall IsPlayerStandingOnDoorTileOrWarpTile
pop bc
pop hl
@@ -392,8 +392,8 @@ CheckWarpsNoCollisionLoop::
pop hl
jr nc, CheckWarpsNoCollisionRetry2
; if the extra check passed
- ld a, [wFlags_D733]
- bit 2, a
+ ld a, [wStatusFlags7]
+ bit BIT_FORCED_WARP, a
jr nz, WarpFound1
push de
push bc
@@ -464,7 +464,7 @@ WarpFound2::
ld a, [wCurMap]
ld [wLastMap], a
ld a, [wCurMapWidth]
- ld [wUnusedD366], a ; not read
+ ld [wUnusedLastMapWidth], a
ldh a, [hWarpDestinationMap]
ld [wCurMap], a
cp ROCK_TUNNEL_1F
@@ -491,15 +491,15 @@ WarpFound2::
jr nz, .notWarpPad
; if the player is on a warp pad
call LeaveMapAnim
- ld hl, wd732
- set 3, [hl]
+ ld hl, wStatusFlags6
+ set BIT_FLY_WARP, [hl]
jr .skipMapChangeSound
.notWarpPad
call PlayMapChangeSound
.skipMapChangeSound
- ld hl, wd736
- res 0, [hl]
- res 1, [hl]
+ ld hl, wMovementFlags
+ res BIT_STANDING_ON_DOOR, [hl]
+ res BIT_EXITING_DOOR, [hl]
callfar SetPikachuSpawnWarpPad
jr .done
@@ -511,8 +511,8 @@ WarpFound2::
xor a
ld [wMapPalOffset], a
.done
- ld hl, wd736
- set 0, [hl] ; have the player's sprite step out from the door (if there is one)
+ ld hl, wMovementFlags
+ set BIT_STANDING_ON_DOOR, [hl] ; have the player's sprite step out from the door (if there is one)
call IgnoreInputForHalfSecond
jp EnterMap
@@ -737,12 +737,11 @@ MapEntryAfterBattle::
HandleBlackOut::
; For when all the player's pokemon faint.
; Does not print the "blacked out" message.
-
call GBFadeOutToBlack
ld a, $08
call StopMusic
- ld hl, wd72e
- res 5, [hl]
+ ld hl, wStatusFlags4
+ res BIT_BATTLE_OVER_OR_BLACKOUT, [hl]
ld a, BANK(PrepareForSpecialWarp) ; also BANK(SpecialEnterMap)
call BankswitchCommon
callfar ResetStatusAndHalveMoneyOnBlackout
@@ -766,9 +765,9 @@ HandleFlyWarpOrDungeonWarp::
ld [wBattleResult], a
ld [wIsInBattle], a
ld [wMapPalOffset], a
- ld hl, wd732
- set 2, [hl] ; fly warp or dungeon warp
- res 5, [hl] ; forced to ride bike
+ ld hl, wStatusFlags6
+ set BIT_FLY_OR_DUNGEON_WARP, [hl]
+ res BIT_ALWAYS_ON_BIKE, [hl]
call LeaveMapAnim
call Func_07c4
ld a, BANK(PrepareForSpecialWarp)
@@ -785,8 +784,8 @@ Func_07c4::
ret z
xor a
ld [wWalkBikeSurfState], a
- ld hl, wd732
- bit 4, [hl]
+ ld hl, wStatusFlags6
+ bit BIT_DUNGEON_WARP, [hl]
ret z
call PlayDefaultMusic
ret
@@ -869,10 +868,10 @@ LoadTilesetTilePatternData::
ld a, [wTilesetBank]
jp FarCopyData
-; 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 bc, wOverworldMapEnd - wOverworldMap
ld a, [wMapBackgroundTile] ; background tile number
@@ -1055,10 +1054,11 @@ LoadEastWestConnectionsTileMap::
ret
; function to check if there is a sign or sprite in front of the player
-; if so, carry is set. otherwise, carry is cleared
+; if so, it is stored in [hTextID]
+; if not, [hTextID] is set to 0
IsSpriteOrSignInFrontOfPlayer::
xor a
- ldh [hSpriteIndexOrTextID], a
+ ldh [hTextID], a
ld a, [wNumSigns]
and a
jr z, .extendRangeOverCounter
@@ -1079,7 +1079,8 @@ IsSpriteOrSignInFrontOfPlayer::
dec b
jr nz, .counterTilesLoop
-; sets carry flag if a sprite is in front of the player, resets if not
+; part of the above function, but sometimes its called on its own, when signs are irrelevant
+; the caller must zero [hTextID]
IsSpriteInFrontOfPlayer::
ld d, $10 ; talking range in pixels (normal range)
IsSpriteInFrontOfPlayer2::
@@ -1161,10 +1162,10 @@ 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 [hSpriteIndexOrTextID], a
- ldh a, [hSpriteIndexOrTextID] ; possible useless read because a already has the value of the read address
+ ldh [hSpriteIndex], a
+ ldh a, [hSpriteIndex] ; possible useless read because a already has the value of the read address
cp $f
jr nz, .dontwritetowd436
ld a, $FF
@@ -1200,7 +1201,7 @@ SignLoop::
dec c
add hl, bc
ld a, [hl]
- ldh [hSpriteIndexOrTextID], a ; store sign text ID
+ ldh [hTextID], a ; store sign text ID
pop bc
pop hl
scf
@@ -1215,8 +1216,8 @@ SignLoop::
; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing)
; sets the carry flag if there is a collision, and unsets it if there isn't a collision
CollisionCheckOnLand::
- ld a, [wd736]
- bit 6, a ; is the player jumping?
+ ld a, [wMovementFlags]
+ bit BIT_LEDGE_OR_FISHING, a
jr nz, .noCollision
; if not jumping a ledge
ld a, [wSimulatedJoypadStatesIndex]
@@ -1229,11 +1230,11 @@ CollisionCheckOnLand::
nop ; ??? why is this in the code
jr nz, .collision
xor a
- ldh [hSpriteIndexOrTextID], a
+ ldh [hTextID], a
call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision?
jr nc, .asm_0a5c
res 7, [hl]
- ldh a, [hSpriteIndexOrTextID]
+ ldh a, [hTextID]
and a ; was there a sprite collision?
jr z, .asm_0a5c
; if no sprite collision
@@ -1292,8 +1293,8 @@ CheckForJumpingAndTilePairCollisions::
pop de
pop hl
and a
- ld a, [wd736]
- bit 6, a ; is the player jumping?
+ ld a, [wMovementFlags]
+ bit BIT_LEDGE_OR_FISHING, a
ret nz
; if not jumping
@@ -1305,7 +1306,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
@@ -1594,8 +1595,8 @@ JoypadOverworld::
ret
ForceBikeDown::
- ld a, [wFlags_D733]
- bit 3, a ; check if a trainer wants a challenge
+ ld a, [wStatusFlags7]
+ bit BIT_TRAINER_BATTLE, a
ret nz
ld a, [wCurMap]
cp ROUTE_17 ; Cycling Road
@@ -1608,8 +1609,8 @@ ForceBikeDown::
ret
AreInputsSimulated::
- ld a, [wd730]
- bit 7, a
+ ld a, [wStatusFlags5]
+ bit BIT_SCRIPTED_MOVEMENT_STATE, a
ret z
; if simulating button presses
ldh a, [hJoyHeld]
@@ -1629,17 +1630,17 @@ AreInputsSimulated::
; if done simulating button presses
.doneSimulating
xor a
- ld [wUnusedCD3A], a
+ ld [wUnusedOverrideSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
ld [wJoyIgnore], a
ldh [hJoyHeld], a
- ld hl, wd736
+ ld hl, wMovementFlags
ld a, [hl]
- and $f8
+ and (1 << BIT_SPINNING) | (1 << BIT_LEDGE_OR_FISHING) | (1 << 5) | (1 << 4) | (1 << 3)
ld [hl], a
- ld hl, wd730
- res 7, [hl]
+ ld hl, wStatusFlags5
+ res BIT_SCRIPTED_MOVEMENT_STATE, [hl]
ret
GetSimulatedInput::
@@ -1667,8 +1668,8 @@ GetSimulatedInput::
; sets carry if there is a collision and clears carry otherwise
; This function had a bug in Red/Blue, but it was fixed in Yellow.
CollisionCheckOnWater::
- ld a, [wd730]
- bit 7, a
+ ld a, [wStatusFlags5]
+ bit BIT_SCRIPTED_MOVEMENT_STATE, a
jp nz, .noCollision ; return and clear carry if button presses are being simulated
ld a, [wPlayerDirection] ; the direction that the player is trying to go in
ld d, a
@@ -1695,7 +1696,7 @@ CollisionCheckOnWater::
scf
jr .done
.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
@@ -1721,8 +1722,8 @@ RunMapScript::
push de
push bc
farcall TryPushingBoulder
- ld a, [wFlags_0xcd60]
- bit 1, a ; play boulder dust animation
+ ld a, [wMiscFlags]
+ bit BIT_BOULDER_DUST, a
jr z, .afterBoulderEffect
farcall DoBoulderDustAnimation
.afterBoulderEffect
@@ -1792,7 +1793,7 @@ LoadPlayerSpriteGraphicsCommon::
jr nc, .noCarry
inc d
.noCarry
- set 3, h
+ set 3, h ; add $800 ($80 tiles) to hl (1 << 3 == $8)
ld c, $c
jp CopyVideoData
@@ -1805,15 +1806,15 @@ Func_0db5:: ; XXX
farcall LoadMissableObjectData
asm_0dbd:
ld a, [wCurMapTileset]
- ld [wUnusedD119], a
+ ld [wUnusedCurMapTilesetCopy], a
ld a, [wCurMap]
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
call GetMapHeaderPointer
ld de, wCurMapHeader
@@ -1890,14 +1891,14 @@ asm_0dbd:
jr z, .loadSpriteData ; if not, skip this
call CopySignData
.loadSpriteData
- ld a, [wd72e]
- bit 5, a ; did a battle happen immediately before this?
+ ld a, [wStatusFlags4]
+ bit BIT_BATTLE_OVER_OR_BLACKOUT, a
jr nz, .finishUp ; if so, skip this because battles don't destroy this data
call InitSprites
.finishUp
predef LoadTilesetHeader
- ld a, [wd72e]
- bit 5, a ; did a battle happen immediately before this?
+ ld a, [wStatusFlags4]
+ bit BIT_BATTLE_OVER_OR_BLACKOUT, a ; did a battle happen immediately before this?
jr nz, .skip_pika_spawn
callfar SchedulePikachuSpawnForAfterText
.skip_pika_spawn
@@ -1976,11 +1977,11 @@ LoadMapData::
ld b, SET_PAL_OVERWORLD
call RunPaletteCommand
call LoadPlayerSpriteGraphics
- ld a, [wd732]
- and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ ld a, [wStatusFlags6]
+ and 1 << BIT_DUNGEON_WARP | 1 << BIT_FLY_WARP
jr nz, .restoreRomBank
- ld a, [wFlags_D733]
- bit 1, a
+ ld a, [wStatusFlags7]
+ bit BIT_NO_MAP_MUSIC, a
jr nz, .restoreRomBank
call UpdateMusic6Times ; music related
call PlayDefaultMusicFadeOutCurrent ; music related
@@ -2032,7 +2033,7 @@ ResetMapVariables::
ldh [hSCY], a
ldh [hSCX], a
ld [wWalkCounter], a
- ld [wUnusedD119], a
+ ld [wUnusedCurMapTilesetCopy], a
ld [wSpriteSetID], a
ld [wWalkBikeSurfStateCopy], a
ret
@@ -2103,15 +2104,15 @@ GetMapHeaderPointer::
IgnoreInputForHalfSecond:
ld a, 30
ld [wIgnoreInputCounter], a
- ld hl, wd730
+ ld hl, wStatusFlags5
ld a, [hl]
- or %00100110
+ or (1 << BIT_DISABLE_JOYPAD) | (1 << BIT_UNKNOWN_5_2) | (1 << BIT_UNKNOWN_5_1)
ld [hl], a ; set ignore input bit
ret
ResetUsingStrengthOutOfBattleBit:
- ld hl, wd728
- res 0, [hl]
+ ld hl, wStatusFlags1
+ res BIT_STRENGTH_ACTIVE, [hl]
ret
ForceBikeOrSurf::
@@ -2123,15 +2124,15 @@ ForceBikeOrSurf::
; Handle the player jumping down
; a ledge in the overworld.
HandleMidJump::
- ld a, [wd736]
- bit 6, a ; jumping down a ledge?
+ ld a, [wMovementFlags]
+ bit BIT_LEDGE_OR_FISHING, a
ret z
farcall _HandleMidJump
ret
IsSpinning::
- ld a, [wd736]
- bit 7, a
+ ld a, [wMovementFlags]
+ bit BIT_SPINNING, a
ret z ; no spinning
farjp LoadSpinnerArrowTiles ; spin while moving
@@ -2234,9 +2235,9 @@ LoadSprite::
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
; for regular sprites
push hl
diff --git a/home/pathfinding.asm b/home/pathfinding.asm
index 77cb5c4b..12128f68 100644
--- a/home/pathfinding.asm
+++ b/home/pathfinding.asm
@@ -32,15 +32,15 @@ MoveSprite_::
ld [wNPCNumScriptedSteps], a ; number of steps taken
pop bc
- ld hl, wd730
- set 0, [hl]
+ ld hl, wStatusFlags5
+ set BIT_SCRIPTED_NPC_MOVEMENT, [hl]
pop hl
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld [wSimulatedJoypadStatesEnd], a
dec a
ld [wJoyIgnore], a
- ld [wUnusedCD3A], a
+ ld [wUnusedOverrideSimulatedJoypadStatesIndex], a
ret
; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2]
diff --git a/home/pics.asm b/home/pics.asm
index d02cf1b5..966f5ad4 100644
--- a/home/pics.asm
+++ b/home/pics.asm
@@ -16,7 +16,7 @@ UncompressMonSprite::
; $4A ≤ index < $74: bank $B ("Pics 3")
; $74 ≤ index < $99: bank $C ("Pics 4")
; $99 ≤ index: bank $D ("Pics 5")
- ld a, [wcf91]
+ ld a, [wCurPartySpecies]
ld b, a
cp FOSSIL_KABUTOPS
ld a, BANK(FossilKabutopsPic)
diff --git a/home/play_time.asm b/home/play_time.asm
index 25fb7a9a..b7f4b4c5 100644
--- a/home/play_time.asm
+++ b/home/play_time.asm
@@ -3,8 +3,8 @@ TrackPlayTime::
ld hl, wd47a
bit 0, [hl]
jr nz, .maxIGT
- ld a, [wd732]
- bit 0, a
+ ld a, [wStatusFlags6]
+ bit BIT_GAME_TIMER_COUNTING, a
ret z
ld a, [wPlayTimeMaxed]
and a
@@ -58,12 +58,12 @@ CountDownIgnoreInputBitReset:
ld [wIgnoreInputCounter], a
and a
ret nz
- ld a, [wd730]
- res 1, a
- res 2, a
- bit 5, a
- res 5, a
- ld [wd730], a
+ ld a, [wStatusFlags5]
+ res BIT_UNKNOWN_5_1, a
+ res BIT_UNKNOWN_5_2, a
+ bit BIT_DISABLE_JOYPAD, a
+ res BIT_DISABLE_JOYPAD, a
+ ld [wStatusFlags5], a
ret z
xor a
ldh [hJoyPressed], a
diff --git a/home/pokemon.asm b/home/pokemon.asm
index 0e28df50..5d2c1a24 100644
--- a/home/pokemon.asm
+++ b/home/pokemon.asm
@@ -75,7 +75,7 @@ DrawHPBar::
; 02: current box
; 03: daycare
; OUTPUT:
-; [wcf91] = pokemon ID
+; [wCurPartySpecies] = pokemon ID
; wLoadedMon = base address of pokemon data
; wMonHeader = base address of base stats
LoadMonData::
@@ -97,12 +97,12 @@ LoadFlippedFrontSpriteByMonIndex::
LoadFrontSpriteByMonIndex::
push hl
- ld a, [wd11e]
+ ld a, [wPokedexNum]
push af
- ld a, [wcf91]
- ld [wd11e], a
+ ld a, [wCurPartySpecies]
+ ld [wPokedexNum], a
predef IndexToPokedex
- ld hl, wd11e
+ ld hl, wPokedexNum
ld a, [hl]
pop bc
ld [hl], b
@@ -113,7 +113,7 @@ LoadFrontSpriteByMonIndex::
jr c, .validDexNumber ; dex >#151 invalid
.invalidDexNumber
ld a, RHYDON ; $1
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ret
.validDexNumber
push hl
@@ -204,8 +204,8 @@ PartyMenuInit::
ld a, 1 ; hardcoded bank
call BankswitchHome
call LoadHpBarAndStatusTilePatterns
- ld hl, wd730
- set 6, [hl] ; turn off letter printing delay
+ ld hl, wStatusFlags5
+ set BIT_NO_TEXT_DELAY, [hl]
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
ld [wMenuWatchMovingOutOfBounds], a
@@ -246,7 +246,7 @@ HandlePartyMenuInput::
ld [wPartyMenuAnimMonEnabled], a
call HandleMenuInput_
push af ; save hJoy5 OR wMenuWrapping enabled, if no inputs were selected within a certain period of time
- bit 1, a ; was B button pressed?
+ bit BIT_B_BUTTON, a ; was B button pressed?
ld a, $0
ld [wPartyMenuAnimMonEnabled], a
ld a, [wCurrentMenuItem]
@@ -262,14 +262,14 @@ HandlePartyMenuInput::
pop af
call PlaceUnfilledArrowMenuCursor
ld b, a
- ld hl, wd730
- res 6, [hl] ; turn on letter printing delay
+ ld hl, wStatusFlags5
+ res BIT_NO_TEXT_DELAY, [hl]
ld a, [wMenuItemToSwap]
and a
jp nz, .swappingPokemon
pop af
ldh [hTileAnimations], a
- bit 1, b
+ bit BIT_B_BUTTON, b
jr nz, .noPokemonChosen
ld a, [wPartyCount]
and a
@@ -281,7 +281,7 @@ HandlePartyMenuInput::
ld c, a
add hl, bc
ld a, [hl]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld [wBattleMonSpecies2], a
call BankswitchBack
and a
@@ -383,8 +383,8 @@ PrintLevelFull::
ld a, [wLoadedMonLevel] ; level
PrintLevelCommon::
- ld [wd11e], a
- ld de, wd11e
+ ld [wTempByteValue], a
+ ld de, wTempByteValue
ld b, LEFT_ALIGN | 1 ; 1 byte
jp PrintNumber
@@ -399,7 +399,7 @@ GetwMoves::
; copies the base stat data of a pokemon to wMonHeader
; INPUT:
-; [wd0b5] = pokemon ID
+; [wCurSpecies] = pokemon ID
GetMonHeader::
ldh a, [hLoadedROMBank]
push af
@@ -408,10 +408,10 @@ GetMonHeader::
push bc
push de
push hl
- ld a, [wd11e]
+ ld a, [wPokedexNum]
push af
- ld a, [wd0b5]
- ld [wd11e], a
+ ld a, [wCurSpecies]
+ ld [wPokedexNum], a
ld de, FossilKabutopsPic
ld b, $66 ; size of Kabutops fossil and Ghost sprites
cp FOSSIL_KABUTOPS ; Kabutops fossil
@@ -423,8 +423,8 @@ GetMonHeader::
ld b, $77 ; size of Aerodactyl fossil sprite
cp FOSSIL_AERODACTYL ; Aerodactyl fossil
jr z, .specialID
- predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number
- ld a, [wd11e]
+ predef IndexToPokedex
+ ld a, [wPokedexNum]
dec a
ld bc, BASE_DATA_SIZE
ld hl, BaseStats
@@ -441,10 +441,10 @@ GetMonHeader::
inc hl
ld [hl], d
.done
- ld a, [wd0b5]
+ ld a, [wCurSpecies]
ld [wMonHIndex], a
pop af
- ld [wd11e], a
+ ld [wPokedexNum], a
pop hl
pop de
pop bc
@@ -452,7 +452,7 @@ GetMonHeader::
call BankswitchCommon
ret
-; copy party pokemon's name to wcd6d
+; copy party pokemon's name to wNameBuffer
GetPartyMonName2::
ld a, [wWhichPokemon] ; index within party
ld hl, wPartyMonNicks
@@ -462,7 +462,7 @@ GetPartyMonName::
push hl
push bc
call SkipFixedLengthTextEntries ; add NAME_LENGTH to hl, a times
- ld de, wcd6d
+ ld de, wNameBuffer
push de
ld bc, NAME_LENGTH
call CopyData
diff --git a/home/predef_text.asm b/home/predef_text.asm
index 1537ad5b..61e22fce 100644
--- a/home/predef_text.asm
+++ b/home/predef_text.asm
@@ -1,9 +1,9 @@
PrintPredefTextID::
- ldh [hSpriteIndexOrTextID], a
+ ldh [hTextID], a
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/print_text.asm b/home/print_text.asm
index 962ae519..65d418a3 100644
--- a/home/print_text.asm
+++ b/home/print_text.asm
@@ -1,18 +1,18 @@
; This function is used to wait a short period after printing a letter to the
; screen unless the player presses the A/B button or the delay is turned off
-; through the [wd730] or [wLetterPrintingDelayFlags] flags.
+; through the [wStatusFlags5] or [wLetterPrintingDelayFlags] flags.
PrintLetterDelay::
- ld a, [wd730]
- bit 6, a
+ ld a, [wStatusFlags5]
+ bit BIT_NO_TEXT_DELAY, a
ret nz
ld a, [wLetterPrintingDelayFlags]
- bit 1, a
+ bit BIT_TEXT_DELAY, a
ret z
push hl
push de
push bc
ld a, [wLetterPrintingDelayFlags]
- bit 0, a
+ bit BIT_FAST_TEXT_DELAY, a
jr z, .waitOneFrame
ld a, [wOptions]
and $f
diff --git a/home/reload_sprites.asm b/home/reload_sprites.asm
index 63a71d26..6d199600 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/reload_tiles.asm b/home/reload_tiles.asm
index b596263a..d59f7c0a 100644
--- a/home/reload_tiles.asm
+++ b/home/reload_tiles.asm
@@ -28,6 +28,6 @@ ReloadTilesetTilePatterns::
; shows the town map and lets the player choose a destination to fly to
ChooseFlyDestination::
- ld hl, wd72e
- res 4, [hl]
+ ld hl, wStatusFlags4
+ res BIT_NO_BATTLES, [hl]
farjp LoadTownMap_Fly
diff --git a/home/serial.asm b/home/serial.asm
index aa67654f..7edba241 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -33,7 +33,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 25233e05..d6baf35c 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
@@ -117,13 +117,13 @@ NullChar:: ; unused
pop hl
; A "<NULL>" character in a printed string
; displays an error message with the current value
- ; of hSpriteIndexOrTextID in decimal format.
+ ; of hTextID in decimal format.
; This is a debugging leftover.
ld de, TextIDErrorText
dec de
ret
-TextIDErrorText:: ; "[hSpriteIndexOrTextID] ERROR."
+TextIDErrorText:: ; "[hTextID] ERROR."
text_far _TextIDErrorText
text_end
@@ -322,7 +322,7 @@ ProtectedDelay3::
TextCommandProcessor::
ld a, [wLetterPrintingDelayFlags]
push af
- set 1, a
+ set BIT_TEXT_DELAY, a
ld e, a
ldh a, [hClearLetterPrintingDelayFlags]
xor e
diff --git a/home/text_script.asm b/home/text_script.asm
index a70e0f9c..af89a043 100644
--- a/home/text_script.asm
+++ b/home/text_script.asm
@@ -3,14 +3,15 @@ UnknownText_2812:: ; unreferenced
text_end
; this function is used to display sign messages, sprite dialog, etc.
-; INPUT: [hSpriteIndexOrTextID] = sprite ID or text ID
+; INPUT: [hSpriteIndex] = sprite ID or [hTextID] = text ID
DisplayTextID::
+ assert hSpriteIndex == hTextID ; these are at the same memory location
ldh a, [hLoadedROMBank]
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
@@ -22,7 +23,7 @@ DisplayTextID::
ld h, [hl]
ld l, a ; hl = map text pointer
ld d, $00
- ldh a, [hSpriteIndexOrTextID] ; text ID
+ ldh a, [hTextID]
ld [wSpriteIndex], a
dict TEXT_START_MENU, DisplayStartMenu
@@ -34,7 +35,7 @@ DisplayTextID::
ld a, [wNumSprites]
ld e, a
- ldh a, [hSpriteIndexOrTextID] ; sprite ID
+ ldh a, [hSpriteIndex] ; sprite ID
cp e
jr z, .spriteHandling
jr nc, .skipSpriteHandling
@@ -42,7 +43,7 @@ DisplayTextID::
; get the text ID of the sprite
push hl
ld hl, wMapSpriteData ; NPC text entries
- ldh a, [hSpriteIndexOrTextID]
+ ldh a, [hSpriteIndex]
dec a
add a
ld e, a
@@ -123,9 +124,9 @@ CloseTextDisplay::
jr nz, .restoreSpriteFacingDirectionLoop
call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns)
ld hl, wFontLoaded
- res 0, [hl]
- ld a, [wd732]
- bit 3, a ; used fly warp
+ res BIT_FONT_LOADED, [hl]
+ ld a, [wStatusFlags6]
+ bit BIT_FLY_WARP, a
call z, LoadPlayerSpriteGraphics
call LoadCurrentMapView
pop af
@@ -191,9 +192,9 @@ PokemonFaintedText::
DisplayPlayerBlackedOutText::
ld hl, PlayerBlackedOutText
call PrintText
- ld a, [wd732]
- res 5, a ; reset forced to use bike bit
- ld [wd732], a
+ ld a, [wStatusFlags6]
+ res BIT_ALWAYS_ON_BIKE, a
+ ld [wStatusFlags6], a
CheckEvent EVENT_IN_SAFARI_ZONE
jr z, .didnotblackoutinsafari
xor a
diff --git a/home/trainers.asm b/home/trainers.asm
index 4166a4db..09a69ae1 100644
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -7,7 +7,7 @@ StoreTrainerHeaderPointer::
ret
; executes the current map script from the function pointer array provided in de.
-; a: map script index to execute (unless overridden by [wd733] bit 4)
+; a: map script index to execute (unless overridden by [wStatusFlags7] BIT_USE_CUR_MAP_SCRIPT)
; hl: trainer header pointer
ExecuteCurMapScriptInTable::
push af
@@ -16,9 +16,9 @@ ExecuteCurMapScriptInTable::
pop hl
pop af
push hl
- ld hl, wFlags_D733
- bit 4, [hl]
- res 4, [hl]
+ ld hl, wStatusFlags7
+ bit BIT_USE_CUR_MAP_SCRIPT, [hl]
+ res BIT_USE_CUR_MAP_SCRIPT, [hl]
jr z, .useProvidedIndex ; test if map script index was overridden manually
ld a, [wCurMapScript]
.useProvidedIndex
@@ -114,10 +114,10 @@ TalkToTrainer::
call ReadTrainerHeaderInfo ; read end battle text
pop de
call SaveEndBattleTextPointers
- ld hl, wFlags_D733
- set 4, [hl] ; activate map script index override (index is set below)
- ld hl, wFlags_0xcd60
- bit 0, [hl] ; test if player is already engaging the trainer (because the trainer saw the player)
+ ld hl, wStatusFlags7
+ set BIT_USE_CUR_MAP_SCRIPT, [hl] ; activate map script index override (index is set below)
+ ld hl, wMiscFlags
+ bit BIT_SEEN_BY_TRAINER, [hl] ; test if player is already engaging the trainer (because the trainer saw the player)
ret nz
; if the player talked to the trainer of his own volition
call EngageMapTrainer
@@ -143,8 +143,8 @@ ENDC
ld [wTrainerHeaderFlagBit], a
ret
.trainerEngaging
- ld hl, wFlags_D733
- set 3, [hl]
+ ld hl, wStatusFlags7
+ set BIT_TRAINER_BATTLE, [hl]
ld [wEmotionBubbleSpriteIndex], a
xor a ; EXCLAMATION_BUBBLE
ld [wWhichEmotionBubble], a
@@ -160,12 +160,12 @@ ENDC
; display the before battle text after the enemy trainer has walked up to the player's sprite
DisplayEnemyTrainerTextAndStartBattle::
- ld a, [wd730]
- and $1
+ ld a, [wStatusFlags5]
+ and 1 << BIT_SCRIPTED_NPC_MOVEMENT
ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite
ld [wJoyIgnore], a
ld a, [wSpriteIndex]
- ldh [hSpriteIndexOrTextID], a
+ ldh [hSpriteIndex], a
call DisplayTextID
; fall through
@@ -173,23 +173,23 @@ StartTrainerBattle::
xor a
ld [wJoyIgnore], a
call InitBattleEnemyParameters
- ld hl, wd72d
- set 6, [hl]
- set 7, [hl]
- ld hl, wd72e
- set 1, [hl]
+ ld hl, wStatusFlags3
+ set BIT_TALKED_TO_TRAINER, [hl]
+ set BIT_PRINT_END_BATTLE_TEXT, [hl]
+ ld hl, wStatusFlags4
+ set BIT_UNKNOWN_4_1, [hl]
ld hl, wCurMapScript
inc [hl] ; increment map script index (next script function is usually EndTrainerBattle)
ret
EndTrainerBattle::
ld hl, wCurrentMapScriptFlags
- set 5, [hl]
- set 6, [hl]
- ld hl, wd72d
- res 7, [hl]
- ld hl, wFlags_0xcd60
- res 0, [hl] ; player is no longer engaged by any trainer
+ 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
+ res BIT_SEEN_BY_TRAINER, [hl] ; player is no longer engaged by any trainer
ld a, [wIsInBattle]
cp $ff
jp z, ResetButtonPressedAndMapScript
@@ -211,9 +211,9 @@ EndTrainerBattle::
ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
- ld hl, wd730
- bit 4, [hl]
- res 4, [hl]
+ ld hl, wStatusFlags5
+ bit BIT_UNKNOWN_5_4, [hl]
+ res BIT_UNKNOWN_5_4, [hl]
ret nz
ResetButtonPressedAndMapScript::
@@ -240,7 +240,7 @@ InitBattleEnemyParameters::
ld [wTrainerNo], a
ret
.noTrainer
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ret
GetSpritePosition1::
@@ -340,9 +340,9 @@ EngageMapTrainer::
PrintEndBattleText::
push hl
- ld hl, wd72d
- bit 7, [hl]
- res 7, [hl]
+ ld hl, wStatusFlags3
+ bit BIT_PRINT_END_BATTLE_TEXT, [hl]
+ res BIT_PRINT_END_BATTLE_TEXT, [hl]
pop hl
ret z
ldh a, [hLoadedROMBank]
diff --git a/home/uncompress.asm b/home/uncompress.asm
index 87264888..19d87f94 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::
@@ -44,24 +49,24 @@ _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
-; uncompresses a chunk from the sprite input data stream (pointed to at wd0da) into sSpriteBuffer1 or sSpriteBuffer2
+; uncompresses a chunk from the sprite input data stream (pointed to by wSpriteInputPtr) into sSpriteBuffer1 or sSpriteBuffer2
; each chunk is a 1bpp sprite. A 2bpp sprite consist of two chunks which are merged afterwards
; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack
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
@@ -193,10 +198,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
@@ -537,7 +542,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 f8cc4589..713699e6 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -97,8 +97,8 @@ HandleMenuInput_::
jr z, .skipPlayingSound
.AButtonOrBButtonPressed
push hl
- ld hl, wFlags_0xcd60
- bit 5, [hl]
+ ld hl, wMiscFlags
+ bit BIT_NO_MENU_BUTTON_SOUND, [hl]
pop hl
jr nz, .skipPlayingSound
ld a, SFX_PRESS_AB
@@ -140,9 +140,9 @@ PlaceMenuCursor::
ld bc, 40
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
.doubleSpaced1
pop af
.oldMenuItemLoop
@@ -164,9 +164,9 @@ PlaceMenuCursor::
ld bc, 40
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
.doubleSpaced2
pop af
.currentMenuItemLoop
@@ -270,7 +270,7 @@ EnableAutoTextBoxDrawing::
jr AutoTextBoxDrawingCommon
DisableAutoTextBoxDrawing::
- ld a, TRUE
+ ld a, 1 << BIT_NO_AUTO_TEXT_BOX
AutoTextBoxDrawingCommon::
ld [wAutoTextBoxDrawingControl], a