summaryrefslogtreecommitdiff
path: root/home.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home.asm')
-rw-r--r--home.asm1478
1 files changed, 728 insertions, 750 deletions
diff --git a/home.asm b/home.asm
index ed5f4db9..bfd73b31 100644
--- a/home.asm
+++ b/home.asm
@@ -30,7 +30,7 @@ SECTION "joypad", ROM0 [$60]
reti
-SECTION "Home", ROM0
+SECTION "Home", ROM0 [$61]
DisableLCD::
xor a
@@ -99,7 +99,7 @@ SECTION "Header", ROM0 [$104]
-SECTION "Main", ROM0
+SECTION "Main", ROM0 [$150]
Start::
cp GBC
@@ -117,8 +117,7 @@ INCLUDE "home/joypad.asm"
INCLUDE "data/map_header_pointers.asm"
INCLUDE "home/overworld.asm"
-
-CheckForUserInterruption:: ; 12f8 (0:12f8)
+CheckForUserInterruption::
; Return carry if Up+Select+B, Start or A are pressed in c frames.
; Used only in the intro and title screen.
call DelayFrame
@@ -148,13 +147,13 @@ CheckForUserInterruption:: ; 12f8 (0:12f8)
; function to load position data for destination warp when switching maps
; INPUT:
; a = ID of destination warp within destination map
-LoadDestinationWarpPosition:: ; 1313 (0:1313)
+LoadDestinationWarpPosition::
ld b,a
ld a,[H_LOADEDROMBANK]
push af
ld a,[wPredefParentBank]
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ld a,b
add a
add a
@@ -166,11 +165,11 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313)
call CopyData
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
-DrawHPBar:: ; 1336 (0:1336)
+DrawHPBar::
; Draw an HP bar d tiles long, and fill it to e pixels.
; If c is nonzero, show at least a sliver regardless.
; The right end of the bar changes with [wHPBarType].
@@ -209,7 +208,7 @@ DrawHPBar:: ; 1336 (0:1336)
and a
jr nz, .fill
- ; If c iz nonzero, draw a pixel anyway.
+ ; If c is nonzero, draw a pixel anyway.
ld a, c
and a
jr z, .done
@@ -240,10 +239,10 @@ DrawHPBar:: ; 1336 (0:1336)
; loads pokemon data from one of multiple sources to wLoadedMon
-; loads base stats to W_MONHDEXNUM
+; loads base stats to wMonHeader
; INPUT:
; [wWhichPokemon] = index of pokemon within party/box
-; [wcc49] = source
+; [wMonDataLocation] = source
; 00: player's party
; 01: enemy's party
; 02: current box
@@ -251,14 +250,11 @@ DrawHPBar:: ; 1336 (0:1336)
; OUTPUT:
; [wcf91] = pokemon ID
; wLoadedMon = base address of pokemon data
-; W_MONHDEXNUM = base address of base stats
-LoadMonData:: ; 1372 (0:1372)
- ld hl, LoadMonData_
- ld b, BANK(LoadMonData_)
- jp Bankswitch
-
+; wMonHeader = base address of base stats
+LoadMonData::
+ jpab LoadMonData_
-Func_137a:: ; 137a (0:137a)
+OverwritewMoves::
; Write c to [wMoves + b]. Unused.
ld hl, wMoves
ld e, b
@@ -268,11 +264,11 @@ Func_137a:: ; 137a (0:137a)
ld [hl], a
ret
-LoadFlippedFrontSpriteByMonIndex:: ; 1384 (0:1384)
+LoadFlippedFrontSpriteByMonIndex::
ld a, 1
- ld [W_SPRITEFLIPPED], a
+ ld [wSpriteFlipped], a
-LoadFrontSpriteByMonIndex:: ; 1389 (0:1389)
+LoadFrontSpriteByMonIndex::
push hl
ld a, [wd11e]
push af
@@ -299,27 +295,27 @@ LoadFrontSpriteByMonIndex:: ; 1389 (0:1389)
pop hl
ld a, [H_LOADEDROMBANK]
push af
- ld a, Bank(asm_3f0d0)
+ ld a, Bank(CopyUncompressedPicToHL)
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
xor a
- ld [$ffe1], a
- call asm_3f0d0
+ ld [hStartTileID], a
+ call CopyUncompressedPicToHL
xor a
- ld [W_SPRITEFLIPPED], a
+ ld [wSpriteFlipped], a
pop af
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
-PlayCry:: ; 13d0 (0:13d0)
+PlayCry::
; Play monster a's cry.
call GetCryData
call PlaySound
jp WaitForSoundToFinish
-GetCryData:: ; 13d9 (0:13d9)
+GetCryData::
; Load cry data for monster a.
dec a
ld c, a
@@ -329,14 +325,14 @@ GetCryData:: ; 13d9 (0:13d9)
add hl, bc
add hl, bc
- ld a, Bank(CryData)
+ ld a, BANK(CryData)
call BankswitchHome
ld a, [hli]
ld b, a ; cry id
ld a, [hli]
- ld [wc0f1], a
+ ld [wFrequencyModifier], a
ld a, [hl]
- ld [wc0f2], a
+ ld [wTempoModifier], a
call BankswitchBack
; Cry headers have 3 channels,
@@ -349,8 +345,7 @@ GetCryData:: ; 13d9 (0:13d9)
add c
ret
-
-DisplayPartyMenu:: ; 13fc (0:13fc)
+DisplayPartyMenu::
ld a,[hTilesetType]
push af
xor a
@@ -361,7 +356,7 @@ DisplayPartyMenu:: ; 13fc (0:13fc)
call DrawPartyMenu
jp HandlePartyMenuInput
-GoBackToPartyMenu:: ; 1411 (0:1411)
+GoBackToPartyMenu::
ld a,[hTilesetType]
push af
xor a
@@ -370,21 +365,21 @@ GoBackToPartyMenu:: ; 1411 (0:1411)
call RedrawPartyMenu
jp HandlePartyMenuInput
-PartyMenuInit:: ; 1420 (0:1420)
+PartyMenuInit::
ld a, 1 ; hardcoded bank
call BankswitchHome
call LoadHpBarAndStatusTilePatterns
ld hl, wd730
set 6, [hl] ; turn off letter printing delay
- xor a
- ld [wcc49], a
- ld [wcc37], a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld hl, wTopMenuItemY
inc a
ld [hli], a ; top menu item Y
xor a
ld [hli], a ; top menu item X
- ld a, [wcc2b]
+ ld a, [wPartyAndBillsPCSavedMenuItem]
push af
ld [hli], a ; current menu item ID
inc hl
@@ -396,31 +391,31 @@ PartyMenuInit:: ; 1420 (0:1420)
; otherwise, it is 0
.storeMaxMenuItemID
ld [hli], a ; max menu item ID
- ld a, [wd11f]
+ ld a, [wForcePlayerToChooseMon]
and a
- ld a, A_BUTTON + B_BUTTON
+ ld a, A_BUTTON | B_BUTTON
jr z, .next
xor a
- ld [wd11f], a
- inc a
+ ld [wForcePlayerToChooseMon], a
+ inc a ; a = A_BUTTON
.next
ld [hli], a ; menu watched keys
pop af
ld [hl], a ; old menu item ID
ret
-HandlePartyMenuInput:: ; 145a (0:145a)
+HandlePartyMenuInput::
ld a,1
ld [wMenuWrappingEnabled],a
ld a,$40
- ld [wd09b],a
- call HandleMenuInputPokemonSelection
+ ld [wPartyMenuAnimMonEnabled],a
+ call HandleMenuInput_
call PlaceUnfilledArrowMenuCursor
ld b,a
xor a
- ld [wd09b],a
+ ld [wPartyMenuAnimMonEnabled],a
ld a,[wCurrentMenuItem]
- ld [wcc2b],a
+ ld [wPartyAndBillsPCSavedMenuItem],a
ld hl,wd730
res 6,[hl] ; turn on letter printing delay
ld a,[wMenuItemToSwap]
@@ -456,7 +451,7 @@ HandlePartyMenuInput:: ; 145a (0:145a)
callba ErasePartyMenuCursors
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
call RedrawPartyMenu
jr HandlePartyMenuInput
.handleSwap
@@ -465,14 +460,14 @@ HandlePartyMenuInput:: ; 145a (0:145a)
callba SwitchPartyMon
jr HandlePartyMenuInput
-DrawPartyMenu:: ; 14d4 (0:14d4)
+DrawPartyMenu::
ld hl, DrawPartyMenu_
jr DrawPartyMenuCommon
-RedrawPartyMenu:: ; 14d9 (0:14d9)
+RedrawPartyMenu::
ld hl, RedrawPartyMenu_
-DrawPartyMenuCommon:: ; 14dc (0:14dc)
+DrawPartyMenuCommon::
ld b, BANK(RedrawPartyMenu_)
jp Bankswitch
@@ -480,7 +475,7 @@ DrawPartyMenuCommon:: ; 14dc (0:14dc)
; INPUT:
; de = address of status condition
; hl = destination address
-PrintStatusCondition:: ; 14e1 (0:14e1)
+PrintStatusCondition::
push de
dec de
dec de ; de = address of current HP
@@ -499,29 +494,30 @@ PrintStatusCondition:: ; 14e1 (0:14e1)
ld [hl],"T"
and a
ret
-PrintStatusConditionNotFainted ; 14f6
+
+PrintStatusConditionNotFainted:
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(PrintStatusAilment)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call PrintStatusAilment ; print status condition
pop bc
ld a,b
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; function to print pokemon level, leaving off the ":L" if the level is at least 100
; INPUT:
; hl = destination address
; [wLoadedMonLevel] = level
-PrintLevel:: ; 150b (0:150b)
+PrintLevel::
ld a,$6e ; ":L" tile ID
ld [hli],a
ld c,2 ; number of digits
ld a,[wLoadedMonLevel] ; level
- cp a,100
+ cp 100
jr c,PrintLevelCommon
; if level at least 100, write over the ":L" tile
dec hl
@@ -532,20 +528,20 @@ PrintLevel:: ; 150b (0:150b)
; INPUT:
; hl = destination address
; [wLoadedMonLevel] = level
-PrintLevelFull:: ; 151b (0:151b)
+PrintLevelFull::
ld a,$6e ; ":L" tile ID
ld [hli],a
ld c,3 ; number of digits
ld a,[wLoadedMonLevel] ; level
-PrintLevelCommon:: ; 1523 (0:1523)
+PrintLevelCommon::
ld [wd11e],a
ld de,wd11e
- ld b,$41 ; no leading zeroes, left-aligned, one byte
+ ld b,LEFT_ALIGN | 1 ; 1 byte
jp PrintNumber
-Func_152e:: ; 152e (0:152e)
-; Unused.
+GetwMoves::
+; Unused. Returns the move at index a from wMoves in a
ld hl,wMoves
ld c,a
ld b,0
@@ -553,15 +549,15 @@ Func_152e:: ; 152e (0:152e)
ld a,[hl]
ret
-; copies the base stat data of a pokemon to W_MONHDEXNUM (W_MONHEADER)
+; copies the base stat data of a pokemon to wMonHeader
; INPUT:
; [wd0b5] = pokemon ID
-GetMonHeader:: ; 1537 (0:1537)
+GetMonHeader::
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(BaseStats)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
push bc
push de
push hl
@@ -571,29 +567,29 @@ GetMonHeader:: ; 1537 (0:1537)
ld [wd11e],a
ld de,FossilKabutopsPic
ld b,$66 ; size of Kabutops fossil and Ghost sprites
- cp a,FOSSIL_KABUTOPS ; Kabutops fossil
+ cp FOSSIL_KABUTOPS ; Kabutops fossil
jr z,.specialID
ld de,GhostPic
- cp a,MON_GHOST ; Ghost
+ cp MON_GHOST ; Ghost
jr z,.specialID
ld de,FossilAerodactylPic
ld b,$77 ; size of Aerodactyl fossil sprite
- cp a,FOSSIL_AERODACTYL ; Aerodactyl fossil
+ cp FOSSIL_AERODACTYL ; Aerodactyl fossil
jr z,.specialID
cp a,MEW
jr z,.mew
predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number
ld a,[wd11e]
dec a
- ld bc,28
+ ld bc, MonBaseStatsEnd - MonBaseStats
ld hl,BaseStats
call AddNTimes
- ld de,W_MONHEADER
- ld bc,28
+ ld de,wMonHeader
+ ld bc, MonBaseStatsEnd - MonBaseStats
call CopyData
jr .done
.specialID
- ld hl,W_MONHSPRITEDIM
+ ld hl,wMonHSpriteDim
ld [hl],b ; write sprite dimensions
inc hl
ld [hl],e ; write front sprite pointer
@@ -602,13 +598,13 @@ GetMonHeader:: ; 1537 (0:1537)
jr .done
.mew
ld hl,MewBaseStats
- ld de,W_MONHEADER
- ld bc,28
+ ld de,wMonHeader
+ ld bc,MonBaseStatsEnd - MonBaseStats
ld a,BANK(MewBaseStats)
call FarCopyData
.done
ld a,[wd0b5]
- ld [W_MONHDEXNUM],a
+ ld [wMonHIndex],a
pop af
ld [wd11e],a
pop hl
@@ -616,22 +612,22 @@ GetMonHeader:: ; 1537 (0:1537)
pop bc
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; copy party pokemon's name to wcd6d
-GetPartyMonName2:: ; 15b4 (0:15b4)
+GetPartyMonName2::
ld a,[wWhichPokemon] ; index within party
ld hl,wPartyMonNicks
; this is called more often
-GetPartyMonName:: ; 15ba (0:15ba)
+GetPartyMonName::
push hl
push bc
- call SkipFixedLengthTextEntries ; add 11 to hl, a times
+ call SkipFixedLengthTextEntries ; add NAME_LENGTH to hl, a times
ld de,wcd6d
push de
- ld bc,11
+ ld bc,NAME_LENGTH
call CopyData
pop de
pop bc
@@ -651,7 +647,7 @@ GetPartyMonName:: ; 15ba (0:15ba)
; bits 0-4: length of BCD number in bytes
; Note that bits 5 and 7 are modified during execution. The above reflects
; their meaning at the beginning of the functions's execution.
-PrintBCDNumber:: ; 15cd (0:15cd)
+PrintBCDNumber::
ld b,c ; save flags in b
res 7,c
res 6,c
@@ -689,7 +685,7 @@ PrintBCDNumber:: ; 15cd (0:15cd)
.done
ret
-PrintBCDDigit:: ; 1604 (0:1604)
+PrintBCDDigit::
and $f
and a
jr z,.zeroDigit
@@ -705,7 +701,7 @@ PrintBCDDigit:: ; 1604 (0:1604)
.skipCurrencySymbol
res 7,b ; unset 7 to indicate that a nonzero digit has been reached
.outputDigit
- add a,"0"
+ add "0"
ld [hli],a
jp PrintLetterDelay
.zeroDigit
@@ -719,17 +715,17 @@ PrintBCDDigit:: ; 1604 (0:1604)
; uncompresses the front or back sprite of the specified mon
; assumes the corresponding mon header is already loaded
; hl contains offset to sprite pointer ($b for front or $d for back)
-UncompressMonSprite:: ; 1627 (0:1627)
- ld bc,W_MONHEADER
+UncompressMonSprite::
+ ld bc,wMonHeader
add hl,bc
ld a,[hli]
- ld [W_SPRITEINPUTPTR],a ; fetch sprite input pointer
+ ld [wSpriteInputPtr],a ; fetch sprite input pointer
ld a,[hl]
- ld [W_SPRITEINPUTPTR+1],a
+ ld [wSpriteInputPtr+1],a
; define (by index number) the bank that a pokemon's image is in
; index = Mew, bank 1
; index = Kabutops fossil, bank $B
-; index < $1F, bank 9
+; index < $1F, bank 9
; $1F ≤ index < $4A, bank $A
; $4A ≤ index < $74, bank $B
; $74 ≤ index < $99, bank $C
@@ -764,11 +760,11 @@ UncompressMonSprite:: ; 1627 (0:1627)
jp UncompressSpriteData
; de: destination location
-LoadMonFrontSprite:: ; 1665 (0:1665)
+LoadMonFrontSprite::
push de
- ld hl, W_MONHFRONTSPRITE - W_MONHEADER
+ ld hl, wMonHFrontSprite - wMonHeader
call UncompressMonSprite
- ld hl, W_MONHSPRITEDIM
+ ld hl, wMonHSpriteDim
ld a, [hli]
ld c, a
pop de
@@ -778,7 +774,7 @@ LoadMonFrontSprite:: ; 1665 (0:1665)
; calculates alignment parameters to place both sprite chunks in the center of the 7*7 tile sprite buffers
; de: destination location
; a,c: sprite dimensions (in tiles of 8x8 each)
-LoadUncompressedSpriteData:: ; 1672 (0:1672)
+LoadUncompressedSpriteData::
push de
and $f
ld [H_SPRITEWIDTH], a ; each byte contains 8 pixels (in 1bpp), so tiles=bytes for width
@@ -800,7 +796,7 @@ LoadUncompressedSpriteData:: ; 1672 (0:1672)
add a
add a
add a ; 8*tiles is height in bytes
- ld [H_SPRITEHEIGHT], a ; $ff8c
+ ld [H_SPRITEHEIGHT], a
ld a, $7
sub b ; 7-h ; skip for vertical center (in tiles, relative to current column)
ld b, a
@@ -812,31 +808,31 @@ LoadUncompressedSpriteData:: ; 1672 (0:1672)
ld [H_SPRITEOFFSET], a
xor a
ld [$4000], a
- ld hl, S_SPRITEBUFFER0
+ ld hl, sSpriteBuffer0
call ZeroSpriteBuffer ; zero buffer 0
- ld de, S_SPRITEBUFFER1
- ld hl, S_SPRITEBUFFER0
+ ld de, sSpriteBuffer1
+ ld hl, sSpriteBuffer0
call AlignSpriteDataCentered ; copy and align buffer 1 to 0 (containing the MSB of the 2bpp sprite)
- ld hl, S_SPRITEBUFFER1
+ ld hl, sSpriteBuffer1
call ZeroSpriteBuffer ; zero buffer 1
- ld de, S_SPRITEBUFFER2
- ld hl, S_SPRITEBUFFER1
+ ld de, sSpriteBuffer2
+ ld hl, sSpriteBuffer1
call AlignSpriteDataCentered ; copy and align buffer 2 to 1 (containing the LSB of the 2bpp sprite)
pop de
jp InterlaceMergeSpriteBuffers
; copies and aligns the sprite data properly inside the sprite buffer
; sprite buffers are 7*7 tiles in size, the loaded sprite is centered within this area
-AlignSpriteDataCentered:: ; 16c2 (0:16c2)
+AlignSpriteDataCentered::
ld a, [H_SPRITEOFFSET]
ld b, $0
ld c, a
add hl, bc
- ld a, [H_SPRITEWIDTH] ; $ff8b
+ ld a, [H_SPRITEWIDTH]
.columnLoop
push af
push hl
- ld a, [H_SPRITEHEIGHT] ; $ff8c
+ ld a, [H_SPRITEHEIGHT]
ld c, a
.columnInnerLoop
ld a, [de]
@@ -853,7 +849,7 @@ AlignSpriteDataCentered:: ; 16c2 (0:16c2)
ret
; fills the sprite buffer (pointed to in hl) with zeros
-ZeroSpriteBuffer:: ; 16df (0:16df)
+ZeroSpriteBuffer::
ld bc, SPRITEBUFFERSIZE
.nextByteLoop
xor a
@@ -867,15 +863,15 @@ ZeroSpriteBuffer:: ; 16df (0:16df)
; combines the (7*7 tiles, 1bpp) sprite chunks in buffer 0 and 1 into a 2bpp sprite located in buffer 1 through 2
; in the resulting sprite, the rows of the two source sprites are interlaced
; de: output address
-InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea)
+InterlaceMergeSpriteBuffers::
xor a
ld [$4000], a
push de
- ld hl, S_SPRITEBUFFER2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2
- ld de, S_SPRITEBUFFER1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1
- ld bc, S_SPRITEBUFFER0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0
+ ld hl, sSpriteBuffer2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2
+ ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1
+ ld bc, sSpriteBuffer0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0
ld a, SPRITEBUFFERSIZE/2 ; $c4
- ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b
+ ld [H_SPRITEINTERLACECOUNTER], a
.interlaceLoop
ld a, [de]
dec de
@@ -889,15 +885,15 @@ InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea)
ld a, [bc]
dec bc
ld [hld], a ; write byte of source 1
- ld a, [H_SPRITEINTERLACECOUNTER] ; $ff8b
+ ld a, [H_SPRITEINTERLACECOUNTER]
dec a
- ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b
+ ld [H_SPRITEINTERLACECOUNTER], a
jr nz, .interlaceLoop
- ld a, [W_SPRITEFLIPPED]
+ ld a, [wSpriteFlipped]
and a
jr z, .notFlipped
ld bc, 2*SPRITEBUFFERSIZE
- ld hl, S_SPRITEBUFFER1
+ ld hl, sSpriteBuffer1
.swapLoop
swap [hl] ; if flipped swap nybbles in all bytes
inc hl
@@ -907,7 +903,7 @@ InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea)
jr nz, .swapLoop
.notFlipped
pop hl
- ld de, S_SPRITEBUFFER1
+ ld de, sSpriteBuffer1
ld c, (2*SPRITEBUFFERSIZE)/16 ; $31, number of 16 byte chunks to be copied
ld a, [H_LOADEDROMBANK]
ld b, a
@@ -926,7 +922,7 @@ INCLUDE "home/timer.asm"
INCLUDE "home/audio.asm"
-UpdateSprites:: ; 2429 (0:2429)
+UpdateSprites::
ld a, [wUpdateSpritesEnabled]
dec a
ret nz
@@ -934,52 +930,51 @@ UpdateSprites:: ; 2429 (0:2429)
push af
ld a, Bank(_UpdateSprites)
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
call _UpdateSprites
pop af
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
INCLUDE "data/mart_inventories.asm"
-TextScriptEndingChar:: ; 24d6 (0:24d6)
+TextScriptEndingChar::
db "@"
-TextScriptEnd:: ; 24d7 (0:24d7)
+TextScriptEnd::
ld hl,TextScriptEndingChar
ret
-ExclamationText:: ; 24db (0:24db)
+ExclamationText::
TX_FAR _ExclamationText
db "@"
-GroundRoseText:: ; 24e0 (0:24e0)
+GroundRoseText::
TX_FAR _GroundRoseText
db "@"
-BoulderText:: ; 24e5 (0:24e5)
+BoulderText::
TX_FAR _BoulderText
db "@"
-MartSignText:: ; 24ea (0:24ea)
+MartSignText::
TX_FAR _MartSignText
db "@"
-PokeCenterSignText:: ; 24ef (0:24ef)
+PokeCenterSignText::
TX_FAR _PokeCenterSignText
db "@"
-Predef5CText:: ; 24f4 (0:24f4)
-; XXX better label (what does predef $5C do?)
- db $08 ; asm
- predef PickupItem
+PickUpItemText::
+ TX_ASM
+ predef PickUpItem
jp TextScriptEnd
INCLUDE "home/pic.asm"
-ResetPlayerSpriteData:: ; 28a6 (0:28a6)
+ResetPlayerSpriteData::
ld hl, wSpriteStateData1
call ResetPlayerSpriteData_ClearSpriteData
ld hl, wSpriteStateData2
@@ -995,34 +990,34 @@ ResetPlayerSpriteData:: ; 28a6 (0:28a6)
ret
; overwrites sprite data with zeroes
-ResetPlayerSpriteData_ClearSpriteData:: ; 28c4 (0:28c4)
+ResetPlayerSpriteData_ClearSpriteData::
ld bc, $10
xor a
jp FillMemory
-Func_28cb:: ; 28cb (0:28cb)
- ld a, [wMusicHeaderPointer]
- and a
- jr nz, .asm_28dc
+FadeOutAudio::
+ ld a, [wAudioFadeOutControl]
+ and a ; currently fading out audio?
+ jr nz, .fadingOut
ld a, [wd72c]
bit 1, a
ret nz
ld a, $77
- ld [$ff24], a
+ ld [rNR50], a
ret
-.asm_28dc
- ld a, [wcfc9]
+.fadingOut
+ ld a, [wAudioFadeOutCounter]
and a
- jr z, .asm_28e7
+ jr z, .counterReachedZero
dec a
- ld [wcfc9], a
- ret
-.asm_28e7
- ld a, [wcfc8]
- ld [wcfc9], a
- ld a, [$ff24]
- and a
- jr z, .asm_2903
+ ld [wAudioFadeOutCounter], a
+ ret
+.counterReachedZero
+ ld a, [wAudioFadeOutCounterReloadValue]
+ ld [wAudioFadeOutCounter], a
+ ld a, [rNR50]
+ and a ; has the volume reached 0?
+ jr z, .fadeOutComplete
ld b, a
and $f
dec a
@@ -1033,57 +1028,57 @@ Func_28cb:: ; 28cb (0:28cb)
dec a
swap a
or c
- ld [$ff24], a
+ ld [rNR50], a
ret
-.asm_2903
- ld a, [wMusicHeaderPointer]
+.fadeOutComplete
+ ld a, [wAudioFadeOutControl]
ld b, a
xor a
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
- ld a, [wc0f0]
- ld [wc0ef], a
+ ld a, [wAudioSavedROMBank]
+ ld [wAudioROMBank], a
ld a, b
- ld [wc0ee], a
+ ld [wNewSoundID], a
jp PlaySound
; this function is used to display sign messages, sprite dialog, etc.
-; INPUT: [$ff8c] = sprite ID or text ID
-DisplayTextID:: ; 2920 (0:2920)
+; INPUT: [hSpriteIndexOrTextID] = sprite ID or text ID
+DisplayTextID::
ld a,[H_LOADEDROMBANK]
push af
callba DisplayTextIDInit ; initialization
- ld hl,wcf11
+ ld hl,wTextPredefFlag
bit 0,[hl]
res 0,[hl]
jr nz,.skipSwitchToMapBank
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
call SwitchToMapRomBank
.skipSwitchToMapBank
ld a,30 ; half a second
ld [H_FRAMECOUNTER],a ; used as joypad poll timer
- ld hl,W_MAPTEXTPTR
+ ld hl,wMapTextPtr
ld a,[hli]
ld h,[hl]
ld l,a ; hl = map text pointer
ld d,$00
- ld a,[$ff8c] ; text ID
+ ld a,[hSpriteIndexOrTextID] ; text ID
ld [wSpriteIndex],a
and a
jp z,DisplayStartMenu
- cp a,$d3
+ cp TEXT_SAFARI_GAME_OVER
jp z,DisplaySafariGameOverText
- cp a,$d0
+ cp TEXT_MON_FAINTED
jp z,DisplayPokemonFaintedText
- cp a,$d1
+ cp TEXT_BLACKED_OUT
jp z,DisplayPlayerBlackedOutText
- cp a,$d2
+ cp TEXT_REPEL_WORE_OFF
jp z,DisplayRepelWoreOffText
- ld a,[W_NUMSPRITES]
+ ld a,[wNumSprites]
ld e,a
- ld a,[$ff8c] ; sprite ID
+ ld a,[hSpriteIndexOrTextID] ; sprite ID
cp e
jr z,.spriteHandling
jr nc,.skipSpriteHandling
@@ -1095,8 +1090,8 @@ DisplayTextID:: ; 2920 (0:2920)
callba UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction)
pop bc
pop de
- ld hl,W_MAPSPRITEDATA ; NPC text entries
- ld a,[$ff8c]
+ ld hl,wMapSpriteData ; NPC text entries
+ ld a,[hSpriteIndexOrTextID]
dec a
add a
add l
@@ -1118,48 +1113,48 @@ DisplayTextID:: ; 2920 (0:2920)
ld l,a ; hl = address of the text
ld a,[hl] ; a = first byte of text
; check first byte of text for special cases
- cp a,$fe ; Pokemart NPC
+ cp $fe ; Pokemart NPC
jp z,DisplayPokemartDialogue
- cp a,$ff ; Pokemon Center NPC
+ cp $ff ; Pokemon Center NPC
jp z,DisplayPokemonCenterDialogue
- cp a,$fc ; Item Storage PC
+ cp $fc ; Item Storage PC
jp z,FuncTX_ItemStoragePC
- cp a,$fd ; Bill's PC
+ cp $fd ; Bill's PC
jp z,FuncTX_BillsPC
- cp a,$f9 ; Pokemon Center PC
+ cp $f9 ; Pokemon Center PC
jp z,FuncTX_PokemonCenterPC
- cp a,$f5 ; Vending Machine
+ cp $f5 ; Vending Machine
jr nz,.notVendingMachine
- callba VendingMachineMenu ; jump banks to vending machine routine
+ callba VendingMachineMenu ; jump banks to vending machine routine
jr AfterDisplayingTextID
.notVendingMachine
- cp a,$f7 ; slot machine
- jp z,FuncTX_SlotMachine
- cp a,$f6 ; cable connection NPC in Pokemon Center
+ cp $f7 ; prize menu
+ jp z, FuncTX_GameCornerPrizeMenu
+ cp $f6 ; cable connection NPC in Pokemon Center
jr nz,.notSpecialCase
callab CableClubNPC
jr AfterDisplayingTextID
.notSpecialCase
- call Func_3c59 ; display the text
+ call PrintText_NoCreatingTextBox ; display the text
ld a,[wDoNotWaitForButtonPressAfterDisplayingText]
and a
jr nz,HoldTextDisplayOpen
-AfterDisplayingTextID:: ; 29d6 (0:29d6)
- ld a,[wcc47]
+AfterDisplayingTextID::
+ ld a,[wEnteringCableClub]
and a
jr nz,HoldTextDisplayOpen
call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text
; loop to hold the dialogue box open as long as the player keeps holding down the A button
-HoldTextDisplayOpen:: ; 29df (0:29df)
+HoldTextDisplayOpen::
call Joypad
ld a,[hJoyHeld]
bit 0,a ; is the A button being pressed?
jr nz,HoldTextDisplayOpen
-CloseTextDisplay:: ; 29e8 (0:29e8)
- ld a,[W_CURMAP]
+CloseTextDisplay::
+ ld a,[wCurMap]
call SwitchToMapRomBank
ld a,$90
ld [hWY],a ; move the window off the screen
@@ -1181,7 +1176,7 @@ CloseTextDisplay:: ; 29e8 (0:29e8)
jr nz,.restoreSpriteFacingDirectionLoop
ld a,BANK(InitMapSprites)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ 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]
@@ -1191,80 +1186,82 @@ CloseTextDisplay:: ; 29e8 (0:29e8)
call LoadCurrentMapView
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
jp UpdateSprites
-DisplayPokemartDialogue:: ; 2a2e (0:2a2e)
+DisplayPokemartDialogue::
push hl
ld hl,PokemartGreetingText
call PrintText
pop hl
inc hl
call LoadItemList
- ld a,$02
- ld [wListMenuID],a ; selects between subtypes of menus
+ ld a,PRICEDITEMLISTMENU
+ ld [wListMenuID],a
ld a,[H_LOADEDROMBANK]
push af
ld a,Bank(DisplayPokemartDialogue_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call DisplayPokemartDialogue_
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
jp AfterDisplayingTextID
-PokemartGreetingText:: ; 2a55 (0:2a55)
+PokemartGreetingText::
TX_FAR _PokemartGreetingText
db "@"
-LoadItemList:: ; 2a5a (0:2a5a)
- ld a,$01
+LoadItemList::
+ ld a,1
ld [wUpdateSpritesEnabled],a
ld a,h
- ld [wd128],a
+ ld [wItemListPointer],a
ld a,l
- ld [wd129],a
- ld de,wStringBuffer2 + 11
+ ld [wItemListPointer + 1],a
+ ld de,wItemList
.loop
ld a,[hli]
ld [de],a
inc de
- cp a,$ff
+ cp $ff
jr nz,.loop
ret
-DisplayPokemonCenterDialogue:: ; 2a72 (0:2a72)
+DisplayPokemonCenterDialogue::
+; zeroing these doesn't appear to serve any purpose
xor a
ld [$ff8b],a
ld [$ff8c],a
ld [$ff8d],a
+
inc hl
ld a,[H_LOADEDROMBANK]
push af
ld a,Bank(DisplayPokemonCenterDialogue_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call DisplayPokemonCenterDialogue_
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
jp AfterDisplayingTextID
-DisplaySafariGameOverText:: ; 2a90 (0:2a90)
+DisplaySafariGameOverText::
callab PrintSafariGameOverText
jp AfterDisplayingTextID
-DisplayPokemonFaintedText:: ; 2a9b (0:2a9b)
+DisplayPokemonFaintedText::
ld hl,PokemonFaintedText
call PrintText
jp AfterDisplayingTextID
-PokemonFaintedText:: ; 2aa4 (0:2aa4)
+PokemonFaintedText::
TX_FAR _PokemonFaintedText
db "@"
-DisplayPlayerBlackedOutText:: ; 2aa9 (0:2aa9)
+DisplayPlayerBlackedOutText::
ld hl,PlayerBlackedOutText
call PrintText
ld a,[wd732]
@@ -1272,16 +1269,16 @@ DisplayPlayerBlackedOutText:: ; 2aa9 (0:2aa9)
ld [wd732],a
jp HoldTextDisplayOpen
-PlayerBlackedOutText:: ; 2aba (0:2aba)
+PlayerBlackedOutText::
TX_FAR _PlayerBlackedOutText
db "@"
-DisplayRepelWoreOffText:: ; 2abf (0:2abf)
+DisplayRepelWoreOffText::
ld hl,RepelWoreOffText
call PrintText
jp AfterDisplayingTextID
-RepelWoreOffText:: ; 2ac8 (0:2ac8)
+RepelWoreOffText::
TX_FAR _RepelWoreOffText
db "@"
@@ -1292,8 +1289,8 @@ INCLUDE "engine/menu/start_menu.asm"
; hl = address of string of bytes
; b = length of string of bytes
; OUTPUT:
-; [wd11e] = number of set bits
-CountSetBits:: ; 2b7f (0:2b7f)
+; [wNumSetBits] = number of set bits
+CountSetBits::
ld c,0
.loop
ld a,[hli]
@@ -1309,18 +1306,16 @@ CountSetBits:: ; 2b7f (0:2b7f)
dec b
jr nz,.loop
ld a,c
- ld [wd11e],a ; store number of set bits
+ ld [wNumSetBits],a
ret
; subtracts the amount the player paid from their money
; sets carry flag if there is enough money and unsets carry flag if not
-SubtractAmountPaidFromMoney:: ; 2b96 (0:2b96)
- ld b,BANK(SubtractAmountPaidFromMoney_)
- ld hl,SubtractAmountPaidFromMoney_
- jp Bankswitch
+SubtractAmountPaidFromMoney::
+ jpba SubtractAmountPaidFromMoney_
; adds the amount the player sold to their money
-AddAmountSoldToMoney:: ; 2b9e (0:2b9e)
+AddAmountSoldToMoney::
ld de,wPlayerMoney + 2
ld hl,$ffa1 ; total price of items
ld c,3 ; length of money in bytes
@@ -1328,92 +1323,92 @@ AddAmountSoldToMoney:: ; 2b9e (0:2b9e)
ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; redraw money text box
- ld a, (SFX_02_5a - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
- jp WaitForSoundToFinish ; wait until sound is done playing
+ ld a, SFX_PURCHASE
+ call PlaySoundWaitForCurrent
+ jp WaitForSoundToFinish
; function to remove an item (in varying quantities) from the player's bag or PC box
; INPUT:
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
; [wWhichPokemon] = index (within the inventory) of the item to remove
-; [wcf96] = quantity to remove
-RemoveItemFromInventory:: ; 2bbb (0:2bbb)
+; [wItemQuantity] = quantity to remove
+RemoveItemFromInventory::
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(RemoveItemFromInventory_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call RemoveItemFromInventory_
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; 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
-; [wcf96] = item quantity
+; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
-AddItemToInventory:: ; 2bcf (0:2bcf)
+AddItemToInventory::
push bc
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(AddItemToInventory_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call AddItemToInventory_
pop bc
ld a,b
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
pop bc
ret
; INPUT:
; [wListMenuID] = list menu ID
-; [wList] = address of the list (2 bytes)
-DisplayListMenuID:: ; 2be6 (0:2be6)
+; [wListPointer] = address of the list (2 bytes)
+DisplayListMenuID::
xor a
ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer
ld a,1
ld [hJoy7],a ; joypad state update flag
- ld a,[W_BATTLETYPE]
+ ld a,[wBattleType]
and a ; is it the Old Man battle?
jr nz,.specialBattleType
ld a,$01 ; hardcoded bank
jr .bankswitch
.specialBattleType ; Old Man battle
- ld a, Bank(DisplayBattleMenu)
+ ld a, BANK(DisplayBattleMenu)
.bankswitch
call BankswitchHome
ld hl,wd730
set 6,[hl] ; turn off letter printing delay
xor a
ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
- ld [wd12a],a
- ld a,[wList]
+ ld [wListCount],a
+ ld a,[wListPointer]
ld l,a
- ld a,[wList + 1]
+ ld a,[wListPointer + 1]
ld h,a ; hl = address of the list
- ld a,[hl]
- ld [wd12a],a ; [wd12a] = number of list entries
+ ld a,[hl] ; the first byte is the number of entries in the list
+ ld [wListCount],a
ld a,LIST_MENU_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; draw the menu text box
call UpdateSprites ; disable sprites behind the text box
; the code up to .skipMovingSprites appears to be useless
- hlCoord 4, 2 ; coordinates of upper left corner of menu text box
- ld de,$090e ; height and width of menu text box
+ coord hl, 4, 2 ; coordinates of upper left corner of menu text box
+ lb de, 9, 14 ; height and width of menu text box
ld a,[wListMenuID]
and a ; is it a PC pokemon list?
jr nz,.skipMovingSprites
- call UpdateSprites ; move sprites
+ call UpdateSprites
.skipMovingSprites
ld a,1 ; max menu item ID is 1 if the list has less than 2 entries
- ld [wcc37],a
- ld a,[wd12a]
- cp a,2 ; does the list have less than 2 entries?
+ ld [wMenuWatchMovingOutOfBounds],a
+ ld a,[wListCount]
+ cp 2 ; does the list have less than 2 entries?
jr c,.setMenuVariables
ld a,2 ; max menu item ID is 2 if the list has at least 2 entries
.setMenuVariables
@@ -1427,14 +1422,14 @@ DisplayListMenuID:: ; 2be6 (0:2be6)
ld c,10
call DelayFrames
-DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
+DisplayListMenuIDLoop::
xor a
ld [H_AUTOBGTRANSFERENABLED],a ; disable transfer
call PrintListMenuEntries
ld a,1
ld [H_AUTOBGTRANSFERENABLED],a ; enable transfer
call Delay3
- ld a,[W_BATTLETYPE]
+ ld a,[wBattleType]
and a ; is it the Old Man battle?
jr z,.notOldManBattle
.oldManBattle
@@ -1444,7 +1439,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
call DelayFrames
xor a
ld [wCurrentMenuItem],a
- hlCoord 5, 4
+ coord hl, 5, 4
ld a,l
ld [wMenuCursorLocation],a
ld a,h
@@ -1461,17 +1456,20 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
.buttonAPressed
ld a,[wCurrentMenuItem]
call PlaceUnfilledArrowMenuCursor
+
+; pointless because both values are overwritten before they are read
ld a,$01
- ld [wd12e],a
- ld [wd12d],a
+ ld [wMenuExitMethod],a
+ ld [wChosenMenuItem],a
+
xor a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
ld a,[wCurrentMenuItem]
ld c,a
ld a,[wListScrollOffset]
add c
ld c,a
- ld a,[wd12a] ; number of list entries
+ ld a,[wListCount]
and a ; is the list empty?
jp z,ExitListMenu ; if so, exit the menu
dec a
@@ -1480,14 +1478,14 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
ld a,c
ld [wWhichPokemon],a
ld a,[wListMenuID]
- cp a,ITEMLISTMENU
+ cp ITEMLISTMENU
jr nz,.skipMultiplying
; if it's an item menu
sla c ; item entries are 2 bytes long, so multiply by 2
.skipMultiplying
- ld a,[wList]
+ ld a,[wListPointer]
ld l,a
- ld a,[wList + 1]
+ ld a,[wListPointer + 1]
ld h,a
inc hl ; hl = beginning of list entries
ld b,0
@@ -1501,12 +1499,12 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
call GetItemPrice
pop hl
ld a,[wListMenuID]
- cp a,ITEMLISTMENU
+ cp ITEMLISTMENU
jr nz,.skipGettingQuantity
; if it's an item menu
inc hl
ld a,[hl] ; a = item quantity
- ld [wcf97],a
+ ld [wMaxItemQuantity],a
.skipGettingQuantity
ld a,[wcf91]
ld [wd0b5],a
@@ -1516,7 +1514,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
jr .storeChosenEntry
.pokemonList
ld hl,wPartyCount
- ld a,[wList]
+ ld a,[wListPointer]
cp l ; is it a list of party pokemon or box pokemon?
ld hl,wPartyMonNicks
jr z,.getPokemonName
@@ -1527,10 +1525,10 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
.storeChosenEntry ; store the menu entry that the player chose and return
ld de,wcd6d
call CopyStringToCF4B ; copy name to wcf4b
- ld a,$01
- ld [wd12e],a
+ ld a,CHOSE_MENU_ITEM
+ ld [wMenuExitMethod],a
ld a,[wCurrentMenuItem]
- ld [wd12d],a
+ ld [wChosenMenuItem],a
xor a
ld [hJoy7],a ; joypad state update flag
ld hl,wd730
@@ -1547,9 +1545,9 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
jr z,.upPressed
.downPressed
ld a,[hl]
- add a,3
+ add 3
ld b,a
- ld a,[wd12a] ; number of list entries
+ ld a,[wListCount]
cp b ; will going down scroll past the Cancel button?
jp c,DisplayListMenuIDLoop
inc [hl] ; if not, go down
@@ -1561,30 +1559,30 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
dec [hl]
jp DisplayListMenuIDLoop
-DisplayChooseQuantityMenu:: ; 2d57 (0:2d57)
+DisplayChooseQuantityMenu::
; text box dimensions/coordinates for just quantity
- hlCoord 15, 9
+ coord hl, 15, 9
ld b,1 ; height
ld c,3 ; width
ld a,[wListMenuID]
- cp a,PRICEDITEMLISTMENU
+ cp PRICEDITEMLISTMENU
jr nz,.drawTextBox
; text box dimensions/coordinates for quantity and price
- hlCoord 7, 9
+ coord hl, 7, 9
ld b,1 ; height
ld c,11 ; width
.drawTextBox
call TextBoxBorder
- hlCoord 16, 10
+ coord hl, 16, 10
ld a,[wListMenuID]
- cp a,PRICEDITEMLISTMENU
+ cp PRICEDITEMLISTMENU
jr nz,.printInitialQuantity
- hlCoord 8, 10
+ coord hl, 8, 10
.printInitialQuantity
ld de,InitialQuantityText
call PlaceString
xor a
- ld [wcf96],a ; initialize current quantity to 0
+ ld [wItemQuantity],a ; initialize current quantity to 0
jp .incrementQuantity
.waitForKeyPressLoop
call JoypadLowSensitivity
@@ -1599,10 +1597,10 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57)
jr nz,.decrementQuantity
jr .waitForKeyPressLoop
.incrementQuantity
- ld a,[wcf97] ; max quantity
+ ld a,[wMaxItemQuantity]
inc a
ld b,a
- ld hl,wcf96 ; current quantity
+ ld hl,wItemQuantity ; current quantity
inc [hl]
ld a,[hl]
cp b
@@ -1612,62 +1610,62 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57)
ld [hl],a
jr .handleNewQuantity
.decrementQuantity
- ld hl,wcf96 ; current quantity
+ ld hl,wItemQuantity ; current quantity
dec [hl]
jr nz,.handleNewQuantity
; wrap to the max quantity if the player goes below 1
- ld a,[wcf97] ; max quantity
+ ld a,[wMaxItemQuantity]
ld [hl],a
.handleNewQuantity
- hlCoord 17, 10
+ coord hl, 17, 10
ld a,[wListMenuID]
- cp a,PRICEDITEMLISTMENU
+ cp PRICEDITEMLISTMENU
jr nz,.printQuantity
.printPrice
ld c,$03
- ld a,[wcf96]
+ ld a,[wItemQuantity]
ld b,a
- ld hl,$ff9f ; total price
+ ld hl,hMoney ; total price
; initialize total price to 0
xor a
ld [hli],a
ld [hli],a
ld [hl],a
.addLoop ; loop to multiply the individual price by the quantity to get the total price
- ld de,$ffa1
- ld hl,$ff8d
+ ld de,hMoney + 2
+ ld hl,hItemPrice + 2
push bc
predef AddBCDPredef ; add the individual price to the current sum
pop bc
dec b
jr nz,.addLoop
- ld a,[$ff8e]
+ ld a,[hHalveItemPrices]
and a ; should the price be halved (for selling items)?
jr z,.skipHalvingPrice
xor a
- ld [$ffa2],a
- ld [$ffa3],a
+ ld [hDivideBCDDivisor],a
+ ld [hDivideBCDDivisor + 1],a
ld a,$02
- ld [$ffa4],a
+ ld [hDivideBCDDivisor + 2],a
predef DivideBCDPredef3 ; halves the price
; store the halved price
- ld a,[$ffa2]
- ld [$ff9f],a
- ld a,[$ffa3]
- ld [$ffa0],a
- ld a,[$ffa4]
- ld [$ffa1],a
+ ld a,[hDivideBCDQuotient]
+ ld [hMoney],a
+ ld a,[hDivideBCDQuotient + 1]
+ ld [hMoney + 1],a
+ ld a,[hDivideBCDQuotient + 2]
+ ld [hMoney + 2],a
.skipHalvingPrice
- hlCoord 12, 10
+ coord hl, 12, 10
ld de,SpacesBetweenQuantityAndPriceText
call PlaceString
- ld de,$ff9f ; total price
+ ld de,hMoney ; total price
ld c,$a3
call PrintBCDNumber
- hlCoord 9, 10
+ coord hl, 9, 10
.printQuantity
- ld de,wcf96 ; current quantity
- ld bc,$8102 ; print leading zeroes, 1 byte, 2 digits
+ ld de,wItemQuantity ; current quantity
+ lb bc, LEADING_ZEROES | 1, 2 ; 1 byte, 2 digits
call PrintNumber
jp .waitForKeyPressLoop
.buttonAPressed ; the player chose to make the transaction
@@ -1680,18 +1678,18 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57)
ld a,$ff
ret
-InitialQuantityText:: ; 2e30 (0:2e30)
+InitialQuantityText::
db "×01@"
-SpacesBetweenQuantityAndPriceText:: ; 2e34 (0:2e34)
+SpacesBetweenQuantityAndPriceText::
db " @"
-ExitListMenu:: ; 2e3b (0:2e3b)
+ExitListMenu::
ld a,[wCurrentMenuItem]
- ld [wd12d],a
- ld a,$02
- ld [wd12e],a
- ld [wcc37],a
+ ld [wChosenMenuItem],a
+ ld a,CANCELLED_MENU
+ ld [wMenuExitMethod],a
+ ld [wMenuWatchMovingOutOfBounds],a
xor a
ld [hJoy7],a
ld hl,wd730
@@ -1702,20 +1700,20 @@ ExitListMenu:: ; 2e3b (0:2e3b)
scf
ret
-PrintListMenuEntries:: ; 2e5a (0:2e5a)
- hlCoord 5, 3
- ld b,$09
- ld c,$0e
+PrintListMenuEntries::
+ coord hl, 5, 3
+ ld b,9
+ ld c,14
call ClearScreenArea
- ld a,[wList]
+ ld a,[wListPointer]
ld e,a
- ld a,[wList + 1]
+ ld a,[wListPointer + 1]
ld d,a
inc de ; de = beginning of list entries
ld a,[wListScrollOffset]
ld c,a
ld a,[wListMenuID]
- cp a,ITEMLISTMENU
+ cp ITEMLISTMENU
ld a,c
jr nz,.skipMultiplying
; if it's an item menu
@@ -1728,14 +1726,14 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
jr nc,.noCarry
inc d
.noCarry
- hlCoord 6, 4 ; coordinates of first list entry name
+ coord hl, 6, 4 ; coordinates of first list entry name
ld b,4 ; print 4 names
.loop
ld a,b
ld [wWhichPokemon],a
ld a,[de]
ld [wd11e],a
- cp a,$ff
+ cp $ff
jp z,.printCancelMenuItem
push bc
push de
@@ -1745,7 +1743,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
ld a,[wListMenuID]
and a
jr z,.pokemonPCMenu
- cp a,$01
+ cp MOVESLISTMENU
jr z,.movesMenu
.itemMenu
call GetItemName
@@ -1753,7 +1751,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
.pokemonPCMenu
push hl
ld hl,wPartyCount
- ld a,[wList]
+ ld a,[wListPointer]
cp l ; is it a list of party pokemon or box pokemon?
ld hl,wPartyMonNicks
jr z,.getPokemonName
@@ -1775,7 +1773,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
call PlaceString
pop de
pop hl
- ld a,[wcf93]
+ ld a,[wPrintItemPrices]
and a ; should prices be printed?
jr z,.skipPrintingItemPrice
.printItemPrice
@@ -1785,7 +1783,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
ld [wcf91],a
call GetItemPrice ; get price
pop hl
- ld bc,20 + 5 ; 1 row down and 5 columns right
+ ld bc, SCREEN_WIDTH + 5 ; 1 row down and 5 columns right
add hl,bc
ld c,$a3 ; no leading zeroes, right-aligned, print currency symbol, 3 bytes
call PrintBCDNumber
@@ -1798,13 +1796,13 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
push af
push hl
ld hl,wPartyCount
- ld a,[wList]
+ ld a,[wListPointer]
cp l ; is it a list of party pokemon or box pokemon?
- ld a,$00
+ ld a,PLAYER_PARTY_DATA
jr z,.next
- ld a,$02
+ ld a,BOX_DATA
.next
- ld [wcc49],a
+ ld [wMonDataLocation],a
ld hl,wWhichPokemon
ld a,[hl]
ld b,a
@@ -1814,8 +1812,8 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
ld a,[wListScrollOffset]
add b
ld [hl],a
- call LoadMonData ; load pokemon info
- ld a,[wcc49]
+ call LoadMonData
+ ld a,[wMonDataLocation]
and a ; is it a list of party pokemon or box pokemon?
jr z,.skipCopyingLevel
.copyLevel
@@ -1825,7 +1823,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
pop hl
ld bc,$001c
add hl,bc
- call PrintLevel ; print level
+ call PrintLevel
pop af
ld [wd11e],a
.skipPrintingPokemonLevel
@@ -1833,28 +1831,28 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
pop de
inc de
ld a,[wListMenuID]
- cp a,ITEMLISTMENU
+ cp ITEMLISTMENU
jr nz,.nextListEntry
.printItemQuantity
ld a,[wd11e]
ld [wcf91],a
call IsKeyItem ; check if item is unsellable
- ld a,[wd124]
+ ld a,[wIsKeyItem]
and a ; is the item unsellable?
jr nz,.skipPrintingItemQuantity ; if so, don't print the quantity
push hl
- ld bc,20 + 8 ; 1 row down and 8 columns right
+ ld bc, SCREEN_WIDTH + 8 ; 1 row down and 8 columns right
add hl,bc
ld a,"×"
ld [hli],a
ld a,[wd11e]
push af
ld a,[de]
- ld [wcf97],a
+ ld [wMaxItemQuantity],a
push de
ld de,wd11e
ld [de],a
- ld bc,$0102
+ lb bc, 1, 2
call PrintNumber
pop de
pop af
@@ -1876,7 +1874,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
ld a,$ec ; unfilled right arrow menu cursor to indicate an item being swapped
ld [hli],a
.nextListEntry
- ld bc,2 * 20 ; 2 rows
+ ld bc,2 * SCREEN_WIDTH ; 2 rows
add hl,bc
pop bc
inc c
@@ -1884,26 +1882,26 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a)
jp nz,.loop
ld bc,-8
add hl,bc
- ld a,$ee ; down arrow
+ ld a,"▼"
ld [hl],a
ret
.printCancelMenuItem
ld de,ListMenuCancelText
jp PlaceString
-ListMenuCancelText:: ; 2f97 (0:2f97)
+ListMenuCancelText::
db "CANCEL@"
-GetMonName:: ; 2f9e (0:2f9e)
+GetMonName::
push hl
ld a,[H_LOADEDROMBANK]
push af
- ld a,BANK(MonsterNames) ; 07
+ ld a,BANK(MonsterNames)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ld a,[wd11e]
dec a
- ld hl,MonsterNames ; 421E
+ ld hl,MonsterNames
ld c,10
ld b,0
call AddNTimes
@@ -1911,16 +1909,16 @@ GetMonName:: ; 2f9e (0:2f9e)
push de
ld bc,10
call CopyData
- ld hl,wcd77
+ ld hl,wcd6d + 10
ld [hl], "@"
pop de
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
pop hl
ret
-GetItemName:: ; 2fcf (0:2fcf)
+GetItemName::
; given an item ID at [wd11e], store the name of the item into a string
; starting at wcd6d
push hl
@@ -1945,7 +1943,7 @@ GetItemName:: ; 2fcf (0:2fcf)
pop hl
ret
-GetMachineName:: ; 2ff3 (0:2ff3)
+GetMachineName::
; copies the name of the TM/HM in [wd11e] to wcd6d
push hl
push de
@@ -1971,7 +1969,7 @@ GetMachineName:: ; 2ff3 (0:2ff3)
; now get the machine number and convert it to text
ld a,[wd11e]
sub TM_01 - 1
- ld b,$F6 ; "0"
+ ld b, "0"
.FirstDigit
sub 10
jr c,.SecondDigit
@@ -1984,13 +1982,12 @@ GetMachineName:: ; 2ff3 (0:2ff3)
ld [de],a
inc de
pop af
- ld b,$F6 ; "0"
+ ld b, "0"
add b
ld [de],a
inc de
ld a,"@"
ld [de],a
-
pop af
ld [wd11e],a
pop bc
@@ -1998,17 +1995,17 @@ GetMachineName:: ; 2ff3 (0:2ff3)
pop hl
ret
-TechnicalPrefix:: ; 303c (0:303c)
+TechnicalPrefix::
db "TM"
-HiddenPrefix:: ; 303e (0:303e)
+HiddenPrefix::
db "HM"
; sets carry if item is HM, clears carry if item is not HM
; Input: a = item ID
-IsItemHM:: ; 3040 (0:3040)
- cp a,HM_01
+IsItemHM::
+ cp HM_01
jr c,.notHM
- cp a,TM_01
+ cp TM_01
ret
.notHM
and a
@@ -2016,16 +2013,16 @@ IsItemHM:: ; 3040 (0:3040)
; sets carry if move is an HM, clears carry if move is not an HM
; Input: a = move ID
-IsMoveHM:: ; 3049 (0:3049)
+IsMoveHM::
ld hl,HMMoves
ld de,1
jp IsInArray
-HMMoves:: ; 3052 (0:3052)
+HMMoves::
db CUT,FLY,SURF,STRENGTH,FLASH
db $ff ; terminator
-GetMoveName:: ; 3058 (0:3058)
+GetMoveName::
push hl
ld a,MOVE_NAME
ld [wNameListType],a
@@ -2039,10 +2036,10 @@ GetMoveName:: ; 3058 (0:3058)
ret
; reloads text box tile patterns, current map view, and tileset tile patterns
-ReloadMapData:: ; 3071 (0:3071)
+ReloadMapData::
ld a,[H_LOADEDROMBANK]
push af
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
call SwitchToMapRomBank
call DisableLCD
call LoadTextBoxTilePatterns
@@ -2051,33 +2048,31 @@ ReloadMapData:: ; 3071 (0:3071)
call EnableLCD
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; reloads tileset tile patterns
-ReloadTilesetTilePatterns:: ; 3090 (0:3090)
+ReloadTilesetTilePatterns::
ld a,[H_LOADEDROMBANK]
push af
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
call SwitchToMapRomBank
call DisableLCD
call LoadTilesetTilePatternData
call EnableLCD
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; shows the town map and lets the player choose a destination to fly to
-ChooseFlyDestination:: ; 30a9 (0:30a9)
+ChooseFlyDestination::
ld hl,wd72e
res 4,[hl]
- ld b, BANK(LoadTownMap_Fly)
- ld hl, LoadTownMap_Fly
- jp Bankswitch
+ jpba LoadTownMap_Fly
; causes the text box to close without waiting for a button press after displaying text
-DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6)
+DisableWaitingAfterTextDisplay::
ld a,$01
ld [wDoNotWaitForButtonPressAfterDisplayingText],a
ret
@@ -2087,44 +2082,42 @@ DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6)
; INPUT:
; [wcf91] = item ID
; OUTPUT:
-; [wcd6a] = success
+; [wActionResultOrTookBattleTurn] = success
; 00: unsucessful
; 01: successful
; 02: not able to be used right now, no extra menu displayed (only certain items use this)
-UseItem:: ; 30bc (0:30bc)
- ld b,BANK(UseItem_)
- ld hl,UseItem_
- jp Bankswitch
+UseItem::
+ jpba UseItem_
; confirms the item toss and then tosses the item
; INPUT:
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wWhichPokemon] = index of item within inventory
-; [wcf96] = quantity to toss
+; [wItemQuantity] = quantity to toss
; OUTPUT:
; clears carry flag if the item is tossed, sets carry flag if not
-TossItem:: ; 30c4 (0:30c4)
+TossItem::
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(TossItem_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call TossItem_
pop de
ld a,d
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; checks if an item is a key item
; INPUT:
; [wcf91] = item ID
; OUTPUT:
-; [wd124] = result
+; [wIsKeyItem] = result
; 00: item is not key item
; 01: item is key item
-IsKeyItem:: ; 30d9 (0:30d9)
+IsKeyItem::
push hl
push de
push bc
@@ -2137,22 +2130,23 @@ IsKeyItem:: ; 30d9 (0:30d9)
; function to draw various text boxes
; INPUT:
; [wTextBoxID] = text box ID
-DisplayTextBoxID:: ; 30e8 (0:30e8)
+; b, c = y, x cursor position (TWO_OPTION_MENU only)
+DisplayTextBoxID::
ld a,[H_LOADEDROMBANK]
push af
ld a,BANK(DisplayTextBoxID_)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call DisplayTextBoxID_
pop bc
ld a,b
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; not zero if an NPC movement script is running, the player character is
; automatically stepping down from a door, or joypad states are being simulated
-IsPlayerCharacterBeingControlledByGame:: ; 30fd (0:30fd)
+IsPlayerCharacterBeingControlledByGame::
ld a, [wNPCMovementScriptPointerTableNum]
and a
ret nz
@@ -2163,7 +2157,7 @@ IsPlayerCharacterBeingControlledByGame:: ; 30fd (0:30fd)
and $80
ret
-RunNPCMovementScript:: ; 310e (0:310e)
+RunNPCMovementScript::
ld hl, wd736
bit 0, [hl]
res 0, [hl]
@@ -2184,82 +2178,79 @@ RunNPCMovementScript:: ; 310e (0:310e)
push af
ld a, [wNPCMovementScriptBank]
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ld a, [wNPCMovementScriptFunctionNum]
call CallFunctionInTable
pop af
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
+
.NPCMovementScriptPointerTables
- dw ProfOakMovementScriptPointerTable
+ dw PalletMovementScriptPointerTable
dw PewterMuseumGuyMovementScriptPointerTable
dw PewterGymGuyMovementScriptPointerTable
.playerStepOutFromDoor
- ld b, BANK(PlayerStepOutFromDoor)
- ld hl, PlayerStepOutFromDoor
- jp Bankswitch
+ jpba PlayerStepOutFromDoor
-EndNPCMovementScript:: ; 314e (0:314e)
- ld b, BANK(_EndNPCMovementScript)
- ld hl, _EndNPCMovementScript
- jp Bankswitch
+EndNPCMovementScript::
+ jpba _EndNPCMovementScript
-EmptyFunc2:: ; 3156 (0:3156)
+EmptyFunc2::
ret
-; stores hl in [W_TRAINERHEADERPTR]
-StoreTrainerHeaderPointer:: ; 3157 (0:3157)
+; stores hl in [wTrainerHeaderPtr]
+StoreTrainerHeaderPointer::
ld a, h
- ld [W_TRAINERHEADERPTR], a
+ ld [wTrainerHeaderPtr], a
ld a, l
- ld [W_TRAINERHEADERPTR+1], a
+ ld [wTrainerHeaderPtr+1], a
ret
; executes the current map script from the function pointer array provided in hl.
; a: map script index to execute (unless overridden by [wd733] bit 4)
-ExecuteCurMapScriptInTable:: ; 3160 (0:3160)
+ExecuteCurMapScriptInTable::
push af
push de
call StoreTrainerHeaderPointer
pop hl
pop af
push hl
- ld hl, W_FLAGS_D733
+ ld hl, wFlags_D733
bit 4, [hl]
res 4, [hl]
jr z, .useProvidedIndex ; test if map script index was overridden manually
- ld a, [W_CURMAPSCRIPT]
+ ld a, [wCurMapScript]
.useProvidedIndex
pop hl
- ld [W_CURMAPSCRIPT], a
+ ld [wCurMapScript], a
call CallFunctionInTable
- ld a, [W_CURMAPSCRIPT]
+ ld a, [wCurMapScript]
ret
-LoadGymLeaderAndCityName:: ; 317f (0:317f)
+LoadGymLeaderAndCityName::
push de
ld de, wGymCityName
ld bc, $11
call CopyData ; load city name
pop hl
ld de, wGymLeaderName
- ld bc, $b
+ ld bc, NAME_LENGTH
jp CopyData ; load gym leader name
-; reads specific information from trainer header (pointed to at W_TRAINERHEADERPTR)
+; reads specific information from trainer header (pointed to at wTrainerHeaderPtr)
; a: offset in header data
; 0 -> flag's bit (into wTrainerHeaderFlagBit)
; 2 -> flag's byte ptr (into hl)
; 4 -> before battle text (into hl)
; 6 -> after battle text (into hl)
; 8 -> end battle text (into hl)
-ReadTrainerHeaderInfo:: ; 3193 (0:3193)
+ReadTrainerHeaderInfo::
push de
push af
ld d, $0
ld e, a
- ld hl, W_TRAINERHEADERPTR
+ ld hl, wTrainerHeaderPtr
ld a, [hli]
ld l, [hl]
ld h, a
@@ -2296,7 +2287,7 @@ ReadTrainerHeaderInfo:: ; 3193 (0:3193)
TrainerFlagAction::
predef_jump FlagActionPredef
-TalkToTrainer:: ; 31cc (0:31cc)
+TalkToTrainer::
call StoreTrainerHeaderPointer
xor a
call ReadTrainerHeaderInfo ; read flag's bit
@@ -2304,7 +2295,7 @@ TalkToTrainer:: ; 31cc (0:31cc)
call ReadTrainerHeaderInfo ; read flag's byte ptr
ld a, [wTrainerHeaderFlagBit]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
call TrainerFlagAction ; read trainer's flag
ld a, c
and a
@@ -2312,7 +2303,7 @@ TalkToTrainer:: ; 31cc (0:31cc)
ld a, $6
call ReadTrainerHeaderInfo ; print after battle text
jp PrintText
-.trainerNotYetFought ; 0x31ed
+.trainerNotYetFought
ld a, $4
call ReadTrainerHeaderInfo ; print before battle text
call PrintText
@@ -2323,19 +2314,19 @@ TalkToTrainer:: ; 31cc (0:31cc)
call ReadTrainerHeaderInfo ; read end battle text
pop de
call SaveEndBattleTextPointers
- ld hl, W_FLAGS_D733
+ 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)
ret nz
; if the player talked to the trainer of his own volition
call EngageMapTrainer
- ld hl, W_CURMAPSCRIPT
+ ld hl, wCurMapScript
inc [hl] ; increment map script index before StartTrainerBattle increments it again (next script function is usually EndTrainerBattle)
jp StartTrainerBattle
; checks if any trainers are seeing the player and wanting to fight
-CheckFightingMapTrainers:: ; 3219 (0:3219)
+CheckFightingMapTrainers::
call CheckForEngagingTrainers
ld a, [wSpriteIndex]
cp $ff
@@ -2345,23 +2336,23 @@ CheckFightingMapTrainers:: ; 3219 (0:3219)
ld [wTrainerHeaderFlagBit], a
ret
.trainerEngaging
- ld hl, W_FLAGS_D733
+ ld hl, wFlags_D733
set 3, [hl]
- ld [wcd4f], a
- xor a
- ld [wcd50], a
+ ld [wEmotionBubbleSpriteIndex], a
+ xor a ; EXCLAMATION_BUBBLE
+ ld [wWhichEmotionBubble], a
predef EmotionBubble
ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a
xor a
- ldh [$b4], a
+ ld [hJoyHeld], a
call TrainerWalkUpToPlayer_Bank0
- ld hl, W_CURMAPSCRIPT
+ ld hl, wCurMapScript
inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle)
ret
; display the before battle text after the enemy trainer has walked up to the player's sprite
-DisplayEnemyTrainerTextAndStartBattle:: ; 324c (0:324c)
+DisplayEnemyTrainerTextAndStartBattle::
ld a, [wd730]
and $1
ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite
@@ -2371,7 +2362,7 @@ DisplayEnemyTrainerTextAndStartBattle:: ; 324c (0:324c)
call DisplayTextID
; fall through
-StartTrainerBattle:: ; 325d (0:325d)
+StartTrainerBattle::
xor a
ld [wJoyIgnore], a
call InitBattleEnemyParameters
@@ -2380,37 +2371,37 @@ StartTrainerBattle:: ; 325d (0:325d)
set 7, [hl]
ld hl, wd72e
set 1, [hl]
- ld hl, W_CURMAPSCRIPT
+ ld hl, wCurMapScript
inc [hl] ; increment map script index (next script function is usually EndTrainerBattle)
ret
-EndTrainerBattle:: ; 3275 (0:3275)
- ld hl, wd126
+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
- ld a, [W_ISINBATTLE] ; W_ISINBATTLE
+ ld a, [wIsInBattle]
cp $ff
jp z, ResetButtonPressedAndMapScript
ld a, $2
call ReadTrainerHeaderInfo
ld a, [wTrainerHeaderFlagBit]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
call TrainerFlagAction ; flag trainer as fought
- ld a, [W_ENEMYMONORTRAINERCLASS]
- cp $c8
+ ld a, [wEnemyMonOrTrainerClass]
+ cp 200
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
- ld hl, W_MISSABLEOBJECTLIST
+ ld hl, wMissableObjectList
ld de, $2
ld a, [wSpriteIndex]
call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
- ld [wcc4d], a ; load corresponding missable object index and remove it
+ ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
ld hl, wd730
@@ -2418,54 +2409,52 @@ EndTrainerBattle:: ; 3275 (0:3275)
res 4, [hl]
ret nz
-ResetButtonPressedAndMapScript:: ; 32c1 (0:32c1)
+ResetButtonPressedAndMapScript::
xor a
ld [wJoyIgnore], a
ld [hJoyHeld], a
ld [hJoyPressed], a
ld [hJoyReleased], a
- ld [W_CURMAPSCRIPT], a ; reset battle status
+ ld [wCurMapScript], a ; reset battle status
ret
; calls TrainerWalkUpToPlayer
-TrainerWalkUpToPlayer_Bank0:: ; 32cf (0:32cf)
- ld b, BANK(TrainerWalkUpToPlayer)
- ld hl, TrainerWalkUpToPlayer
- jp Bankswitch
+TrainerWalkUpToPlayer_Bank0::
+ jpba TrainerWalkUpToPlayer
; sets opponent type and mon set/lvl based on the engaging trainer data
-InitBattleEnemyParameters:: ; 32d7 (0:32d7)
+InitBattleEnemyParameters::
ld a, [wEngagedTrainerClass]
- ld [W_CUROPPONENT], a ; wd059
- ld [W_ENEMYMONORTRAINERCLASS], a
- cp $c8
- ld a, [wEngagedTrainerSet] ; wcd2e
+ ld [wCurOpponent], a
+ ld [wEnemyMonOrTrainerClass], a
+ cp 200
+ ld a, [wEngagedTrainerSet]
jr c, .noTrainer
- ld [W_TRAINERNO], a ; wd05d
+ ld [wTrainerNo], a
ret
.noTrainer
- ld [W_CURENEMYLVL], a ; W_CURENEMYLVL
+ ld [wCurEnemyLVL], a
ret
-GetSpritePosition1:: ; 32ef (0:32ef)
+GetSpritePosition1::
ld hl, _GetSpritePosition1
- jr asm_3301
+ jr SpritePositionBankswitch
-GetSpritePosition2:: ; 32f4 (0:32f4)
+GetSpritePosition2::
ld hl, _GetSpritePosition2
- jr asm_3301 ; 0x32f7 $8
+ jr SpritePositionBankswitch
-SetSpritePosition1:: ; 32f9 (0:32f9)
+SetSpritePosition1::
ld hl, _SetSpritePosition1
- jr asm_3301
+ jr SpritePositionBankswitch
-SetSpritePosition2:: ; 32fe (0:32fe)
+SetSpritePosition2::
ld hl, _SetSpritePosition2
-asm_3301:: ; 3301 (0:3301)
+SpritePositionBankswitch::
ld b, BANK(_GetSpritePosition1) ; BANK(_GetSpritePosition2), BANK(_SetSpritePosition1), BANK(_SetSpritePosition2)
jp Bankswitch ; indirect jump to one of the four functions
-CheckForEngagingTrainers:: ; 3306 (0:3306)
+CheckForEngagingTrainers::
xor a
call ReadTrainerHeaderInfo ; read trainer flag's bit (unused)
ld d, h ; store trainer header address in de
@@ -2479,13 +2468,13 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
ret z
ld a, $2
call ReadTrainerHeaderInfo ; read trainer flag's byte ptr
- ld b, $2
+ ld b, FLAG_TEST
ld a, [wTrainerHeaderFlagBit]
ld c, a
call TrainerFlagAction ; read trainer flag
ld a, c
- and a
- jr nz, .trainerAlreadyFought
+ and a ; has the trainer already been defeated?
+ jr nz, .continue
push hl
push de
push hl
@@ -2497,14 +2486,14 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
ld [wTrainerEngageDistance], a
ld a, [wSpriteIndex]
swap a
- ld [wTrainerSpriteOffset], a ; wWhichTrade
+ ld [wTrainerSpriteOffset], a
predef TrainerEngage
pop de
pop hl
- ld a, [wTrainerSpriteOffset] ; wWhichTrade
+ ld a, [wTrainerSpriteOffset]
and a
ret nz ; break if the trainer is engaging
-.trainerAlreadyFought
+.continue
ld hl, $c
add hl, de
ld d, h
@@ -2513,7 +2502,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
; hl = text if the player wins
; de = text if the player loses
-SaveEndBattleTextPointers:: ; 3354 (0:3354)
+SaveEndBattleTextPointers::
ld a, [H_LOADEDROMBANK]
ld [wEndBattleTextRomBank], a
ld a, h
@@ -2528,8 +2517,8 @@ SaveEndBattleTextPointers:: ; 3354 (0:3354)
; loads data of some trainer on the current map and plays pre-battle music
; [wSpriteIndex]: sprite ID of trainer who is engaged
-EngageMapTrainer:: ; 336a (0:336a)
- ld hl, W_MAPSPRITEEXTRADATA
+EngageMapTrainer::
+ ld hl, wMapSpriteExtraData
ld d, $0
ld a, [wSpriteIndex]
dec a
@@ -2539,10 +2528,10 @@ EngageMapTrainer:: ; 336a (0:336a)
ld a, [hli] ; load trainer class
ld [wEngagedTrainerClass], a
ld a, [hl] ; load trainer mon set
- ld [wEnemyMonAttackMod], a ; wcd2e
+ ld [wEnemyMonAttackMod], a
jp PlayTrainerMusic
-PrintEndBattleText:: ; 3381 (0:3381)
+PrintEndBattleText::
push hl
ld hl, wd72d
bit 7, [hl]
@@ -2565,7 +2554,7 @@ PrintEndBattleText:: ; 3381 (0:3381)
callba FreezeEnemyTrainerSprite
jp WaitForSoundToFinish
-GetSavedEndBattleTextPointer:: ; 33b7 (0:33b7)
+GetSavedEndBattleTextPointer::
ld a, [wBattleResult]
and a
; won battle
@@ -2582,15 +2571,17 @@ GetSavedEndBattleTextPointer:: ; 33b7 (0:33b7)
ld l, a
ret
-TrainerEndBattleText:: ; 33cf (0:33cf)
+TrainerEndBattleText::
TX_FAR _TrainerNameText
- db $08
+ TX_ASM
call GetSavedEndBattleTextPointer
call TextCommandProcessor
jp TextScriptEnd
+; only engage withe trainer if the player is not already
+; engaged with another trainer
; XXX unused?
-Func_33dd:: ; 33dd (0:33dd)
+CheckIfAlreadyEngaged::
ld a, [wFlags_0xcd60]
bit 0, a
ret nz
@@ -2598,24 +2589,24 @@ Func_33dd:: ; 33dd (0:33dd)
xor a
ret
-PlayTrainerMusic:: ; 33e8 (0:33e8)
+PlayTrainerMusic::
ld a, [wEngagedTrainerClass]
- cp $c8 + SONY1
+ cp OPP_SONY1
ret z
- cp $c8 + SONY2
+ cp OPP_SONY2
ret z
- cp $c8 + SONY3
+ cp OPP_SONY3
ret z
- ld a, [W_GYMLEADERNO] ; W_GYMLEADERNO
+ ld a, [wGymLeaderNo]
and a
ret nz
xor a
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
ld a, $ff
- call PlaySound ; stop music
+ call PlaySound
ld a, BANK(Music_MeetEvilTrainer)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, [wEngagedTrainerClass]
ld b, a
ld hl, EvilTrainerList
@@ -2640,7 +2631,7 @@ PlayTrainerMusic:: ; 33e8 (0:33e8)
.maleTrainer
ld a, MUSIC_MEET_MALE_TRAINER
.PlaySound
- ld [wc0ee], a
+ ld [wNewSoundID], a
jp PlaySound
INCLUDE "data/trainer_types.asm"
@@ -2649,7 +2640,7 @@ INCLUDE "data/trainer_types.asm"
; and if so, decodes the RLE movement data
; b = player Y
; c = player X
-DecodeArrowMovementRLE:: ; 3442 (0:3442)
+DecodeArrowMovementRLE::
ld a, [hli]
cp $ff
ret z ; no match in the list
@@ -2673,33 +2664,33 @@ DecodeArrowMovementRLE:: ; 3442 (0:3442)
inc hl
jr DecodeArrowMovementRLE
-FuncTX_ItemStoragePC:: ; 3460 (0:3460)
+FuncTX_ItemStoragePC::
call SaveScreenTilesToBuffer2
ld b, BANK(PlayerPC)
ld hl, PlayerPC
jr bankswitchAndContinue
-FuncTX_BillsPC:: ; 346a (0:346a)
+FuncTX_BillsPC::
call SaveScreenTilesToBuffer2
ld b, BANK(BillsPC_)
ld hl, BillsPC_
jr bankswitchAndContinue
-FuncTX_SlotMachine:: ; 3474 (0:3474)
+FuncTX_GameCornerPrizeMenu::
; XXX find a better name for this function
; special_F7
ld b,BANK(CeladonPrizeMenu)
ld hl,CeladonPrizeMenu
-bankswitchAndContinue:: ; 3479 (0:3479)
+bankswitchAndContinue::
call Bankswitch
jp HoldTextDisplayOpen ; continue to main text-engine function
-FuncTX_PokemonCenterPC:: ; 347f (0:347f)
+FuncTX_PokemonCenterPC::
ld b, BANK(ActivatePC)
ld hl, ActivatePC
jr bankswitchAndContinue
-StartSimulatingJoypadStates:: ; 3486 (0:3486)
+StartSimulatingJoypadStates::
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld [wSpriteStateData2 + $06], a ; player's sprite movement byte 1
@@ -2707,36 +2698,34 @@ StartSimulatingJoypadStates:: ; 3486 (0:3486)
set 7, [hl]
ret
-IsItemInBag:: ; 3493 (0:3493)
+IsItemInBag::
; given an item_id in b
; set zero flag if item isn't in player's bag
; else reset zero flag
; related to Pokémon Tower and ghosts
- predef IsItemInBag_
+ predef GetQuantityOfItemInBag
ld a,b
and a
ret
-DisplayPokedex:: ; 349b (0:349b)
+DisplayPokedex::
ld [wd11e], a
- ld b, BANK(Func_7c18)
- ld hl, Func_7c18
- jp Bankswitch
+ jpba _DisplayPokedex
-SetSpriteFacingDirectionAndDelay:: ; 34a6 (0:34a6)
+SetSpriteFacingDirectionAndDelay::
call SetSpriteFacingDirection
- ld c, $6
+ ld c, 6
jp DelayFrames
-SetSpriteFacingDirection:: ; 34ae (0:34ae)
+SetSpriteFacingDirection::
ld a, $9
ld [H_SPRITEDATAOFFSET], a
call GetPointerWithinSpriteStateData1
- ld a, [$ff8d]
+ ld a, [hSpriteFacingDirection]
ld [hl], a
ret
-SetSpriteImageIndexAfterSettingFacingDirection:: ; 34b9 (0:34b9)
+SetSpriteImageIndexAfterSettingFacingDirection::
ld de, -7
add hl, de
ld [hl], a
@@ -2746,24 +2735,24 @@ SetSpriteImageIndexAfterSettingFacingDirection:: ; 34b9 (0:34b9)
; INPUT:
; hl = address of array
; OUTPUT:
-; [wWhichTrade] = if there is match, the matching array index
+; [wCoordIndex] = if there is match, the matching array index
; sets carry if the coordinates are in the array, clears carry if not
-ArePlayerCoordsInArray:: ; 34bf (0:34bf)
- ld a,[W_YCOORD]
+ArePlayerCoordsInArray::
+ ld a,[wYCoord]
ld b,a
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
ld c,a
; fallthrough
-CheckCoords:: ; 34c7 (0:34c7)
+CheckCoords::
xor a
- ld [wWhichTrade],a
+ ld [wCoordIndex],a
.loop
ld a,[hli]
- cp a,$ff ; reached terminator?
+ cp $ff ; reached terminator?
jr z,.notInArray
push hl
- ld hl,wWhichTrade
+ ld hl,wCoordIndex
inc [hl]
pop hl
.compareYCoord
@@ -2787,9 +2776,9 @@ CheckCoords:: ; 34c7 (0:34c7)
; hl = address of array
; [H_SPRITEINDEX] = index of boulder sprite
; OUTPUT:
-; [wWhichTrade] = if there is match, the matching array index
+; [wCoordIndex] = if there is match, the matching array index
; sets carry if the coordinates are in the array, clears carry if not
-CheckBoulderCoords:: ; 34e4 (0:34e4)
+CheckBoulderCoords::
push hl
ld hl, wSpriteStateData2 + $04
ld a, [H_SPRITEINDEX]
@@ -2806,11 +2795,11 @@ CheckBoulderCoords:: ; 34e4 (0:34e4)
pop hl
jp CheckCoords
-GetPointerWithinSpriteStateData1:: ; 34fc (0:34fc)
+GetPointerWithinSpriteStateData1::
ld h, $c1
jr _GetPointerWithinSpriteStateData
-GetPointerWithinSpriteStateData2:: ; 3500 (0:3500)
+GetPointerWithinSpriteStateData2::
ld h, $c2
_GetPointerWithinSpriteStateData:
@@ -2827,14 +2816,14 @@ _GetPointerWithinSpriteStateData:
; the final $ff will be replicated in the output list and a contains the number of bytes written
; de: input list
; hl: output list
-DecodeRLEList:: ; 350c (0:350c)
+DecodeRLEList::
xor a
ld [wRLEByteCount], a ; count written bytes here
.listLoop
ld a, [de]
cp $ff
jr z, .endOfList
- ld [H_DOWNARROWBLINKCNT1], a ; store byte value to be written
+ ld [hRLEByteValue], a ; store byte value to be written
inc de
ld a, [de]
ld b, $0
@@ -2842,7 +2831,7 @@ DecodeRLEList:: ; 350c (0:350c)
ld a, [wRLEByteCount]
add c
ld [wRLEByteCount], a ; update total number of written bytes
- ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b
+ ld a, [hRLEByteValue]
call FillMemory ; write a c-times to output
inc de
jr .listLoop
@@ -2853,19 +2842,19 @@ DecodeRLEList:: ; 350c (0:350c)
inc a ; include sentinel in counting
ret
-; sets movement byte 1 for sprite [$FF8C] to $FE and byte 2 to [$FF8D]
-SetSpriteMovementBytesToFE:: ; 3533 (0:3533)
+; sets movement byte 1 for sprite [H_SPRITEINDEX] to $FE and byte 2 to [hSpriteMovementByte2]
+SetSpriteMovementBytesToFE::
push hl
call GetSpriteMovementByte1Pointer
ld [hl], $fe
call GetSpriteMovementByte2Pointer
- ld a, [$ff8d]
+ ld a, [hSpriteMovementByte2]
ld [hl], a
pop hl
ret
-; sets both movement bytes for sprite [$FF8C] to $FF
-SetSpriteMovementBytesToFF:: ; 3541 (0:3541)
+; sets both movement bytes for sprite [H_SPRITEINDEX] to $FF
+SetSpriteMovementBytesToFF::
push hl
call GetSpriteMovementByte1Pointer
ld [hl],$FF
@@ -2874,20 +2863,20 @@ SetSpriteMovementBytesToFF:: ; 3541 (0:3541)
pop hl
ret
-; returns the sprite movement byte 1 pointer for sprite [$FF8C] in hl
-GetSpriteMovementByte1Pointer:: ; 354e (0:354e)
+; returns the sprite movement byte 1 pointer for sprite [H_SPRITEINDEX] in hl
+GetSpriteMovementByte1Pointer::
ld h,$C2
- ld a,[H_SPRITEINDEX] ; the sprite to move
+ ld a,[H_SPRITEINDEX]
swap a
- add a,6
+ add 6
ld l,a
ret
-; returns the sprite movement byte 2 pointer for sprite [$FF8C] in hl
-GetSpriteMovementByte2Pointer:: ; 3558 (0:3558)
+; returns the sprite movement byte 2 pointer for sprite [H_SPRITEINDEX] in hl
+GetSpriteMovementByte2Pointer::
push de
- ld hl,W_MAPSPRITEDATA
- ld a,[$FF8C] ; the sprite to move
+ ld hl,wMapSpriteData
+ ld a,[H_SPRITEINDEX]
dec a
add a
ld d,0
@@ -2896,25 +2885,25 @@ GetSpriteMovementByte2Pointer:: ; 3558 (0:3558)
pop de
ret
-GetTrainerInformation:: ; 3566 (0:3566)
+GetTrainerInformation::
call GetTrainerName
ld a, [wLinkState]
and a
jr nz, .linkBattle
ld a, Bank(TrainerPicAndMoneyPointers)
call BankswitchHome
- ld a, [W_TRAINERCLASS] ; wd031
+ ld a, [wTrainerClass]
dec a
ld hl, TrainerPicAndMoneyPointers
ld bc, $5
call AddNTimes
- ld de, wd033
+ ld de, wTrainerPicPointer
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
- ld de, wd046
+ ld de, wTrainerBaseMoney
ld a, [hli]
ld [de], a
inc de
@@ -2922,62 +2911,59 @@ GetTrainerInformation:: ; 3566 (0:3566)
ld [de], a
jp BankswitchBack
.linkBattle
- ld hl, wd033
+ ld hl, wTrainerPicPointer
ld de, RedPicFront
ld [hl], e
inc hl
ld [hl], d
ret
-GetTrainerName:: ; 359e (0:359e)
- ld b, BANK(GetTrainerName_)
- ld hl, GetTrainerName_
- jp Bankswitch
-
+GetTrainerName::
+ jpba GetTrainerName_
HasEnoughMoney::
; Check if the player has at least as much
-; money as the 3-byte BCD value at $ff9f.
+; money as the 3-byte BCD value at hMoney.
ld de, wPlayerMoney
- ld hl, $ff9f
+ ld hl, hMoney
ld c, 3
jp StringCmp
HasEnoughCoins::
; Check if the player has at least as many
-; coins as the 2-byte BCD value at $ffa0.
+; coins as the 2-byte BCD value at hCoins.
ld de, wPlayerCoins
- ld hl, $ffa0
+ ld hl, hCoins
ld c, 2
jp StringCmp
-BankswitchHome:: ; 35bc (0:35bc)
+BankswitchHome::
; switches to bank # in a
; Only use this when in the home bank!
- ld [wcf09],a
+ ld [wBankswitchHomeTemp],a
ld a,[H_LOADEDROMBANK]
- ld [wcf08],a
- ld a,[wcf09]
+ ld [wBankswitchHomeSavedROMBank],a
+ ld a,[wBankswitchHomeTemp]
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
-BankswitchBack:: ; 35cd (0:35cd)
+BankswitchBack::
; returns from BankswitchHome
- ld a,[wcf08]
+ ld a,[wBankswitchHomeSavedROMBank]
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
-Bankswitch:: ; 35d6 (0:35d6)
+Bankswitch::
; self-contained bankswitch, use this when not in the home bank
; switches to the bank in b
ld a,[H_LOADEDROMBANK]
push af
ld a,b
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ld bc,.Return
push bc
jp [hl]
@@ -2985,51 +2971,52 @@ Bankswitch:: ; 35d6 (0:35d6)
pop bc
ld a,b
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
; displays yes/no choice
; yes -> set carry
-YesNoChoice:: ; 35ec (0:35ec)
+YesNoChoice::
call SaveScreenTilesToBuffer1
call InitYesNoTextBoxParameters
jr DisplayYesNoChoice
-Func_35f4:: ; 35f4 (0:35f4)
+Func_35f4::
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call InitYesNoTextBoxParameters
jp DisplayTextBoxID
-InitYesNoTextBoxParameters:: ; 35ff (0:35ff)
+InitYesNoTextBoxParameters::
xor a ; YES_NO_MENU
ld [wTwoOptionMenuID], a
- hlCoord 14, 7
+ coord hl, 14, 7
ld bc, $80f
ret
-YesNoChoicePokeCenter:: ; 360a (0:360a)
+YesNoChoicePokeCenter::
call SaveScreenTilesToBuffer1
ld a, HEAL_CANCEL_MENU
ld [wTwoOptionMenuID], a
- hlCoord 11, 6
- ld bc, $80c
+ coord hl, 11, 6
+ lb bc, 8, 12
jr DisplayYesNoChoice
-Func_361a:: ; 361a (0:361a)
+WideYesNoChoice:: ; unused
call SaveScreenTilesToBuffer1
ld a, WIDE_YES_NO_MENU
ld [wTwoOptionMenuID], a
- hlCoord 12, 7
- ld bc, $080d
-DisplayYesNoChoice:: ; 3628 (0:3628)
+ coord hl, 12, 7
+ lb bc, 8, 13
+
+DisplayYesNoChoice::
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
jp LoadScreenTilesFromBuffer1
; calculates the difference |a-b|, setting carry flag if a<b
-CalcDifference:: ; 3633 (0:3633)
+CalcDifference::
sub b
ret nc
cpl
@@ -3037,17 +3024,17 @@ CalcDifference:: ; 3633 (0:3633)
scf
ret
-MoveSprite:: ; 363a (0:363a)
-; move the sprite [$FF8C] with the movement pointed to by de
-; actually only copies the movement data to wcc5b for later
+MoveSprite::
+; move the sprite [H_SPRITEINDEX] with the movement pointed to by de
+; actually only copies the movement data to wNPCMovementDirections for later
call SetSpriteMovementBytesToFF
-MoveSprite_:: ; 363d (0:363d)
+MoveSprite_::
push hl
push bc
call GetSpriteMovementByte1Pointer
xor a
ld [hl],a
- ld hl,wcc5b
+ ld hl,wNPCMovementDirections
ld c,0
.loop
@@ -3055,11 +3042,11 @@ MoveSprite_:: ; 363d (0:363d)
ld [hli],a
inc de
inc c
- cp a,$FF ; have we reached the end of the movement data?
+ cp $FF ; have we reached the end of the movement data?
jr nz,.loop
ld a,c
- ld [wcf0f],a ; number of steps taken
+ ld [wNPCNumScriptedSteps],a ; number of steps taken
pop bc
ld hl,wd730
@@ -3073,10 +3060,10 @@ MoveSprite_:: ; 363d (0:363d)
ld [wWastedByteCD3A],a
ret
-; divides [$ffe5] by [$ffe6] and stores the quotient in [$ffe7]
-DivideBytes:: ; 366b (0:366b)
+; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2]
+DivideBytes::
push hl
- ld hl, $ffe7
+ ld hl, hQuotient2
xor a
ld [hld], a
ld a, [hld]
@@ -3102,13 +3089,13 @@ LoadFontTilePatterns::
.off
ld hl, FontGraphics
ld de, vFont
- ld bc, $400
+ ld bc, FontGraphicsEnd - FontGraphics
ld a, BANK(FontGraphics)
jp FarCopyDataDouble ; if LCD is off, transfer all at once
.on
ld de, FontGraphics
ld hl, vFont
- ld bc, BANK(FontGraphics) << 8 | $80
+ lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8
jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank
LoadTextBoxTilePatterns::
@@ -3118,13 +3105,13 @@ LoadTextBoxTilePatterns::
.off
ld hl, TextBoxGraphics
ld de, vChars2 + $600
- ld bc, $200
+ ld bc, TextBoxGraphicsEnd - TextBoxGraphics
ld a, BANK(TextBoxGraphics)
jp FarCopyData2 ; if LCD is off, transfer all at once
.on
ld de, TextBoxGraphics
ld hl, vChars2 + $600
- ld bc, BANK(TextBoxGraphics) << 8 | $20
+ lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10
jp CopyVideoData ; if LCD is on, transfer during V-blank
LoadHpBarAndStatusTilePatterns::
@@ -3134,13 +3121,13 @@ LoadHpBarAndStatusTilePatterns::
.off
ld hl, HpBarAndStatusGraphics
ld de, vChars2 + $620
- ld bc, $1e0
+ ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics
ld a, BANK(HpBarAndStatusGraphics)
jp FarCopyData2 ; if LCD is off, transfer all at once
.on
ld de, HpBarAndStatusGraphics
ld hl, vChars2 + $620
- ld bc, BANK(HpBarAndStatusGraphics) << 8 | $1e
+ lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10
jp CopyVideoData ; if LCD is on, transfer during V-blank
@@ -3159,76 +3146,75 @@ FillMemory::
ret
-UncompressSpriteFromDE:: ; 36eb (0:36eb)
+UncompressSpriteFromDE::
; Decompress pic at a:de.
- ld hl, W_SPRITEINPUTPTR
+ ld hl, wSpriteInputPtr
ld [hl], e
inc hl
ld [hl], d
jp UncompressSpriteData
-
-SaveScreenTilesToBuffer2:: ; 36f4 (0:36f4)
- ld hl, wTileMap
+SaveScreenTilesToBuffer2::
+ coord hl, 0, 0
ld de, wTileMapBackup2
- ld bc, $168
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyData
ret
-LoadScreenTilesFromBuffer2:: ; 3701 (0:3701)
+LoadScreenTilesFromBuffer2::
call LoadScreenTilesFromBuffer2DisableBGTransfer
- ld a, $1
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
ret
; loads screen tiles stored in wTileMapBackup2 but leaves H_AUTOBGTRANSFERENABLED disabled
-LoadScreenTilesFromBuffer2DisableBGTransfer:: ; 3709 (0:3709)
+LoadScreenTilesFromBuffer2DisableBGTransfer::
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld [H_AUTOBGTRANSFERENABLED], a
ld hl, wTileMapBackup2
- ld de, wTileMap
- ld bc, $168
+ coord de, 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyData
ret
-SaveScreenTilesToBuffer1:: ; 3719 (0:3719)
- ld hl, wTileMap
+SaveScreenTilesToBuffer1::
+ coord hl, 0, 0
ld de, wTileMapBackup
- ld bc, $168
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
jp CopyData
-LoadScreenTilesFromBuffer1:: ; 3725 (0:3725)
+LoadScreenTilesFromBuffer1::
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld [H_AUTOBGTRANSFERENABLED], a
ld hl, wTileMapBackup
- ld de, wTileMap
- ld bc, $168
+ coord de, 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyData
- ld a, $1
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
ret
-DelayFrames:: ; 3739 (0:3739)
-; wait n frames, where n is the value in c
+DelayFrames::
+; wait c frames
call DelayFrame
dec c
jr nz,DelayFrames
ret
-PlaySoundWaitForCurrent:: ; 3740 (0:3740)
+PlaySoundWaitForCurrent::
push af
call WaitForSoundToFinish
pop af
jp PlaySound
; Wait for sound to finish playing
-WaitForSoundToFinish:: ; 3748 (0:3748)
+WaitForSoundToFinish::
ld a, [wLowHealthAlarm]
and $80
ret nz
push hl
-.asm_374f
- ld hl, wc02a
+.waitLoop
+ ld hl, wChannelSoundIDs + Ch4
xor a
or [hl]
inc hl
@@ -3236,11 +3222,11 @@ WaitForSoundToFinish:: ; 3748 (0:3748)
inc hl
inc hl
or [hl]
- jr nz, .asm_374f
+ jr nz, .waitLoop
pop hl
ret
-NamePointers:: ; 375d (0:375d)
+NamePointers::
dw MonsterNames
dw MoveNames
dw UnusedNames
@@ -3249,7 +3235,7 @@ NamePointers:: ; 375d (0:375d)
dw wEnemyMonOT ; enemy's OT names list
dw TrainerNames
-GetName:: ; 376b (0:376b)
+GetName::
; arguments:
; [wd0b5] = which name
; [wNameListType] = which list
@@ -3274,16 +3260,16 @@ GetName:: ; 376b (0:376b)
jr nz,.otherEntries
;1 = MON_NAMES
call GetMonName
- ld hl,11
+ ld hl,NAME_LENGTH
add hl,de
ld e,l
ld d,h
jr .gotPtr
-.otherEntries ; $378d
+.otherEntries
;2-7 = OTHER ENTRIES
ld a,[wPredefBank]
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ld a,[wNameListType] ;VariousNames' entryID
dec a
add a
@@ -3291,7 +3277,7 @@ GetName:: ; 376b (0:376b)
ld e,a
jr nc,.skip
inc d
-.skip ; $37a0
+.skip
ld hl,NamePointers
add hl,de
ld a,[hli]
@@ -3310,7 +3296,7 @@ GetName:: ; 376b (0:376b)
ld e,l
.nextChar
ld a,[hli]
- cp a, "@"
+ cp "@"
jr nz,.nextChar
inc c ;entry counter
ld a,b ;wanted entry
@@ -3321,20 +3307,20 @@ GetName:: ; 376b (0:376b)
ld de,wcd6d
ld bc,$0014
call CopyData
-.gotPtr ; $37cd
+.gotPtr
ld a,e
- ld [wcf8d],a
+ ld [wUnusedCF8D],a
ld a,d
- ld [wcf8e],a
+ ld [wUnusedCF8D + 1],a
pop de
pop bc
pop hl
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
ret
-GetItemPrice:: ; 37df (0:37df)
+GetItemPrice::
; Stores item's price as BCD at hItemPrice (3 bytes)
; Input: [wcf91] = item id
ld a, [H_LOADEDROMBANK]
@@ -3342,11 +3328,11 @@ GetItemPrice:: ; 37df (0:37df)
ld a, [wListMenuID]
cp MOVESLISTMENU
ld a, BANK(ItemPrices)
- jr nz, .asm_37ed
+ jr nz, .ok
ld a, $f ; hardcoded Bank
-.asm_37ed
+.ok
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ld hl, wItemPrices
ld a, [hli]
ld h, [hl]
@@ -3355,10 +3341,10 @@ GetItemPrice:: ; 37df (0:37df)
cp HM_01
jr nc, .getTMPrice
ld bc, $3
-.asm_3802
+.loop
add hl, bc
dec a
- jr nz, .asm_3802
+ jr nz, .loop
dec hl
ld a, [hld]
ld [hItemPrice + 2], a
@@ -3366,26 +3352,26 @@ GetItemPrice:: ; 37df (0:37df)
ld [hItemPrice + 1], a
ld a, [hl]
ld [hItemPrice], a
- jr .asm_381c
+ jr .done
.getTMPrice
ld a, Bank(GetMachinePrice)
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
call GetMachinePrice
-.asm_381c
+.done
ld de, hItemPrice
pop af
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
; copies a string from [de] to [wcf4b]
-CopyStringToCF4B:: ; 3826 (0:3826)
+CopyStringToCF4B::
ld hl, wcf4b
; fall through
; copies a string from [de] to [hl]
-CopyString:: ; 3829 (0:3829)
+CopyString::
ld a, [de]
inc de
ld [hli], a
@@ -3408,7 +3394,7 @@ CopyString:: ; 3829 (0:3829)
; report only one button press.
; 3. Same as 2, but report no buttons as pressed if A or B is held down.
; ([hJoy7] == 1, [hJoy6] == 0)
-JoypadLowSensitivity:: ; 3831 (0:3831)
+JoypadLowSensitivity::
call Joypad
ld a,[hJoy7] ; flag
and a ; get all currently pressed buttons or only newly pressed buttons?
@@ -3447,7 +3433,7 @@ JoypadLowSensitivity:: ; 3831 (0:3831)
ld [H_FRAMECOUNTER],a
ret
-WaitForTextScrollButtonPress:: ; 3865 (0:3865)
+WaitForTextScrollButtonPress::
ld a, [H_DOWNARROWBLINKCNT1]
push af
ld a, [H_DOWNARROWBLINKCNT2]
@@ -3463,7 +3449,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865)
jr z, .skipAnimation
call TownMapSpriteBlinkingAnimation
.skipAnimation
- hlCoord 18, 16
+ coord hl, 18, 16
call HandleDownArrowBlinkTiming
pop hl
call JoypadLowSensitivity
@@ -3478,15 +3464,15 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865)
ret
; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect
-ManualTextScroll:: ; 3898 (0:3898)
+ManualTextScroll::
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .inLinkBattle
call WaitForTextScrollButtonPress
- ld a, (SFX_02_40 - SFX_Headers_02) / 3
+ ld a, SFX_PRESS_AB
jp PlaySound
.inLinkBattle
- ld c, $41
+ ld c, 65
jp DelayFrames
; function to do multiplication
@@ -3496,7 +3482,7 @@ ManualTextScroll:: ; 3898 (0:3898)
; FF99 = multiplier
; OUTPUT
; FF95-FF98 = product
-Multiply:: ; 38ac (0:38ac)
+Multiply::
push hl
push bc
callab _Multiply
@@ -3513,7 +3499,7 @@ Multiply:: ; 38ac (0:38ac)
; OUTPUT
; FF95-FF98 = quotient
; FF99 = remainder
-Divide:: ; 38b9 (0:38b9)
+Divide::
push hl
push de
push bc
@@ -3521,11 +3507,11 @@ Divide:: ; 38b9 (0:38b9)
push af
ld a,Bank(_Divide)
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
call _Divide
pop af
ld [H_LOADEDROMBANK],a
- ld [$2000],a
+ ld [MBC1RomBank],a
pop bc
pop de
pop hl
@@ -3533,21 +3519,21 @@ Divide:: ; 38b9 (0:38b9)
; 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 [wd358] flags.
-PrintLetterDelay:: ; 38d3 (0:38d3)
+; through the [wd730] or [wLetterPrintingDelayFlags] flags.
+PrintLetterDelay::
ld a,[wd730]
bit 6,a
ret nz
- ld a,[wd358]
+ ld a,[wLetterPrintingDelayFlags]
bit 1,a
ret z
push hl
push de
push bc
- ld a,[wd358]
+ ld a,[wLetterPrintingDelayFlags]
bit 0,a
jr z,.waitOneFrame
- ld a,[W_OPTIONS]
+ ld a,[wOptions]
and $f
ld [H_FRAMECOUNTER],a
jr .checkButtons
@@ -3580,7 +3566,7 @@ PrintLetterDelay:: ; 38d3 (0:38d3)
; Copies [hl, bc) to [de, bc - hl).
; In other words, the source data is from hl up to but not including bc,
; and the destination is de.
-CopyDataUntil:: ; 3913 (0:3913)
+CopyDataUntil::
ld a,[hli]
ld [de],a
inc de
@@ -3594,14 +3580,12 @@ CopyDataUntil:: ; 3913 (0:3913)
; Function to remove a pokemon from the party or the current box.
; wWhichPokemon determines the pokemon.
-; [wcf95] == 0 specifies the party.
-; [wcf95] != 0 specifies the current box.
-RemovePokemon:: ; 391f (0:391f)
- ld hl, _RemovePokemon
- ld b, BANK(_RemovePokemon)
- jp Bankswitch
+; [wRemoveMonFromBox] == 0 specifies the party.
+; [wRemoveMonFromBox] != 0 specifies the current box.
+RemovePokemon::
+ jpab _RemovePokemon
-AddPartyMon:: ; 3927 (0:3927)
+AddPartyMon::
push hl
push de
push bc
@@ -3612,7 +3596,7 @@ AddPartyMon:: ; 3927 (0:3927)
ret
; calculates all 5 stats of current mon and writes them to [de]
-CalcStats:: ; 3936 (0:3936)
+CalcStats::
ld c, $0
.statsLoop
inc c
@@ -3624,7 +3608,7 @@ CalcStats:: ; 3936 (0:3936)
ld [de], a
inc de
ld a, c
- cp $5
+ cp NUM_STATS
jr nz, .statsLoop
ret
@@ -3632,14 +3616,14 @@ CalcStats:: ; 3936 (0:3936)
; c: stat to calc (HP=1,Atk=2,Def=3,Spd=4,Spc=5)
; b: consider stat exp?
; hl: base ptr to stat exp values ([hl + 2*c - 1] and [hl + 2*c])
-CalcStat:: ; 394a (0:394a)
+CalcStat::
push hl
push de
push bc
ld a, b
ld d, a
push hl
- ld hl, W_MONHEADER
+ ld hl, wMonHeader
ld b, $0
add hl, bc
ld a, [hl] ; read base value of stat
@@ -3675,7 +3659,7 @@ CalcStat:: ; 394a (0:394a)
srl c
pop hl
push bc
- ld bc, $b ; skip to stat IV values
+ ld bc, wPartyMon1DVs - (wPartyMon1HPExp - 1) ; also wEnemyMonDVs - wEnemyMonHP
add hl, bc
pop bc
ld a, c
@@ -3753,7 +3737,7 @@ CalcStat:: ; 394a (0:394a)
ld [H_MULTIPLICAND+1], a
xor a
ld [H_MULTIPLICAND], a
- ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL
+ ld a, [wCurEnemyLVL]
ld [H_MULTIPLIER], a
call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level
ld a, [H_MULTIPLICAND]
@@ -3769,9 +3753,9 @@ CalcStat:: ; 394a (0:394a)
call Divide ; (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100
ld a, c
cp $1
- ld a, $5
+ ld a, 5 ; + 5 for non-HP stat
jr nz, .notHPStat
- ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL
+ ld a, [wCurEnemyLVL]
ld b, a
ld a, [H_MULTIPLICAND+2]
add b
@@ -3781,7 +3765,7 @@ CalcStat:: ; 394a (0:394a)
inc a
ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level
.noCarry3
- ld a, $a
+ ld a, 10 ; +10 for HP stat
.notHPStat
ld b, a
ld a, [H_MULTIPLICAND+2]
@@ -3793,17 +3777,17 @@ CalcStat:: ; 394a (0:394a)
ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10
.noCarry4
ld a, [H_MULTIPLICAND+1] ; check for overflow (>999)
- cp $4
+ cp 999 / $100 + 1
jr nc, .overflow
- cp $3
+ cp 999 / $100
jr c, .noOverflow
ld a, [H_MULTIPLICAND+2]
- cp $e8
+ cp 999 % $100 + 1
jr c, .noOverflow
.overflow
- ld a, $3 ; overflow: cap at 999
+ ld a, 999 / $100 ; overflow: cap at 999
ld [H_MULTIPLICAND+1], a
- ld a, $e7
+ ld a, 999 % $100
ld [H_MULTIPLICAND+2], a
.noOverflow
pop bc
@@ -3811,45 +3795,45 @@ CalcStat:: ; 394a (0:394a)
pop hl
ret
-AddEnemyMonToPlayerParty:: ; 3a53 (0:3a53)
+AddEnemyMonToPlayerParty::
ld a, [H_LOADEDROMBANK]
push af
ld a, BANK(_AddEnemyMonToPlayerParty)
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
call _AddEnemyMonToPlayerParty
pop bc
ld a, b
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
-Func_3a68:: ; 3a68 (0:3a68)
+MoveMon::
ld a, [H_LOADEDROMBANK]
push af
- ld a, BANK(Func_f51e)
+ ld a, BANK(_MoveMon)
ld [H_LOADEDROMBANK], a
- ld [$2000], a
- call Func_f51e
+ ld [MBC1RomBank], a
+ call _MoveMon
pop bc
ld a, b
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
ret
-; skips a text entries, each of size $b (like trainer name, OT name, rival name, ...)
-; hl: base pointer, will be incremented by $b * a
-SkipFixedLengthTextEntries:: ; 3a7d (0:3a7d)
+; skips a text entries, each of size NAME_LENGTH (like trainer name, OT name, rival name, ...)
+; hl: base pointer, will be incremented by NAME_LENGTH * a
+SkipFixedLengthTextEntries::
and a
ret z
- ld bc, $b
+ ld bc, NAME_LENGTH
.skipLoop
add hl, bc
dec a
jr nz, .skipLoop
ret
-AddNTimes:: ; 3a87 (0:3a87)
+AddNTimes::
; add bc to hl a times
and a
ret z
@@ -3861,7 +3845,7 @@ AddNTimes:: ; 3a87 (0:3a87)
; Compare strings, c bytes in length, at de and hl.
; Often used to compare big endian numbers in battle calculations.
-StringCmp:: ; 3a8e (0:3a8e)
+StringCmp::
ld a,[de]
cp [hl]
ret nz
@@ -3876,7 +3860,7 @@ StringCmp:: ; 3a8e (0:3a8e)
; b = Y coordinate of upper left corner of sprite
; c = X coordinate of upper left corner of sprite
; de = base address of 4 tile number and attribute pairs
-WriteOAMBlock:: ; 3a97 (0:3a97)
+WriteOAMBlock::
ld h,wOAMBuffer / $100
swap a ; multiply by 16
ld l,a
@@ -3908,27 +3892,27 @@ WriteOAMBlock:: ; 3a97 (0:3a97)
ld [hli],a
ret
-HandleMenuInput:: ; 3abe (0:3abe)
+HandleMenuInput::
xor a
- ld [wd09b],a
+ ld [wPartyMenuAnimMonEnabled],a
-HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
+HandleMenuInput_::
ld a,[H_DOWNARROWBLINKCNT1]
push af
ld a,[H_DOWNARROWBLINKCNT2]
push af ; save existing values on stack
xor a
ld [H_DOWNARROWBLINKCNT1],a ; blinking down arrow timing value 1
- ld a,$06
+ ld a,6
ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2
.loop1
xor a
- ld [wPartyMonAnimCounter],a ; counter for pokemon shaking animation
+ ld [wAnimCounter],a ; counter for pokemon shaking animation
call PlaceMenuCursor
call Delay3
.loop2
push hl
- ld a,[wd09b]
+ ld a,[wPartyMenuAnimMonEnabled]
and a ; is it a pokemon selection menu?
jr z,.getJoypadState
callba AnimatePartyMon ; shake mini sprite of selected pokemon
@@ -3939,7 +3923,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
and a ; was a key pressed?
jr nz,.keyPressed
push hl
- hlCoord 18, 11 ; coordinates of blinking down arrow in some menus
+ coord hl, 18, 11 ; coordinates of blinking down arrow in some menus
call HandleDownArrowBlinkTiming ; blink down arrow (if any)
pop hl
ld a,[wMenuJoypadPollCount]
@@ -3957,7 +3941,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
ret
.keyPressed
xor a
- ld [wcc4b],a
+ ld [wCheckFor180DegreeTurn],a
ld a,[hJoy5]
ld b,a
bit 6,a ; pressed Up key?
@@ -4009,8 +3993,8 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
bit 5,[hl]
pop hl
jr nz,.skipPlayingSound
- ld a,(SFX_02_40 - SFX_Headers_02) / 3
- call PlaySound ; play sound
+ ld a,SFX_PRESS_AB
+ call PlaySound
.skipPlayingSound
pop af
ld [H_DOWNARROWBLINKCNT2],a
@@ -4021,16 +4005,16 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
ld a,[hJoy5]
ret
.noWrappingAround
- ld a,[wcc37]
+ ld a,[wMenuWatchMovingOutOfBounds]
and a ; should we return if the user tried to go past the top or bottom?
jr z,.checkOtherKeys
jr .checkIfAButtonOrBButtonPressed
-PlaceMenuCursor:: ; 3b7c (0:3b7c)
+PlaceMenuCursor::
ld a,[wTopMenuItemY]
and a ; is the y coordinate 0?
jr z,.adjustForXCoord
- ld hl,wTileMap
+ coord hl, 0, 0
ld bc,SCREEN_WIDTH
.topMenuItemLoop
add hl,bc
@@ -4087,7 +4071,7 @@ PlaceMenuCursor:: ; 3b7c (0:3b7c)
jr nz,.currentMenuItemLoop
.checkForArrow2
ld a,[hl]
- cp a,"▶" ; has the right arrow already been placed?
+ cp "▶" ; has the right arrow already been placed?
jr z,.skipSavingTile ; if so, don't lose the saved tile
ld [wTileBehindCursor],a ; save tile before overwriting with right arrow
.skipSavingTile
@@ -4105,7 +4089,7 @@ PlaceMenuCursor:: ; 3b7c (0:3b7c)
; manipulated. In the case of submenus, this is used to show the location of
; the menu cursor in the parent menu. In the case of swapping items in list,
; this is used to mark the item that was first chosen to be swapped.
-PlaceUnfilledArrowMenuCursor:: ; 3bec (0:3bec)
+PlaceUnfilledArrowMenuCursor::
ld b,a
ld a,[wMenuCursorLocation]
ld l,a
@@ -4116,7 +4100,7 @@ PlaceUnfilledArrowMenuCursor:: ; 3bec (0:3bec)
ret
; Replaces the menu cursor with a blank space.
-EraseMenuCursor:: ; 3bf9 (0:3bf9)
+EraseMenuCursor::
ld a,[wMenuCursorLocation]
ld l,a
ld a,[wMenuCursorLocation + 1]
@@ -4129,13 +4113,13 @@ EraseMenuCursor:: ; 3bf9 (0:3bf9)
; The reason is that most functions that call this initialize H_DOWNARROWBLINKCNT1 to 0.
; The effect is that if the tile at hl is initialized with a down arrow,
; this function will toggle that down arrow on and off, but if the tile isn't
-; initliazed with a down arrow, this function does nothing.
+; initialized with a down arrow, this function does nothing.
; That allows this to be called without worrying about if a down arrow should
; be blinking.
-HandleDownArrowBlinkTiming:: ; 3c04 (0:3c04)
+HandleDownArrowBlinkTiming::
ld a,[hl]
ld b,a
- ld a,$ee ; down arrow
+ ld a,"▼"
cp b
jr nz,.downArrowOff
.downArrowOn
@@ -4169,28 +4153,28 @@ HandleDownArrowBlinkTiming:: ; 3c04 (0:3c04)
ret nz
ld a,$06
ld [H_DOWNARROWBLINKCNT2],a
- ld a,$ee ; down arrow
+ ld a,"▼"
ld [hl],a
ret
; The following code either enables or disables the automatic drawing of
; text boxes by DisplayTextID. Both functions cause DisplayTextID to wait
-; for a button press after displaying text (unless [wcc47] is set).
+; for a button press after displaying text (unless [wEnteringCableClub] is set).
-EnableAutoTextBoxDrawing:: ; 3c3c (0:3c3c)
+EnableAutoTextBoxDrawing::
xor a
jr AutoTextBoxDrawingCommon
-DisableAutoTextBoxDrawing:: ; 3c3f (0:3c3f)
+DisableAutoTextBoxDrawing::
ld a,$01
-AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41)
+AutoTextBoxDrawingCommon::
ld [wAutoTextBoxDrawingControl],a
xor a
ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press
ret
-PrintText:: ; 3c49 (0:3c49)
+PrintText::
; Print text hl at (1, 14).
push hl
ld a,MESSAGE_BOX
@@ -4199,20 +4183,17 @@ PrintText:: ; 3c49 (0:3c49)
call UpdateSprites
call Delay3
pop hl
-Func_3c59:: ; 3c59 (0:3c59)
- bcCoord 1, 14
+PrintText_NoCreatingTextBox::
+ coord bc, 1, 14
jp TextCommandProcessor
-PrintNumber:: ; 3c5f
+PrintNumber::
; Print the c-digit, b-byte value at de.
; Allows 2 to 7 digits. For 1-digit numbers, add
; the value to char "0" instead of calling PrintNumber.
; Flags LEADING_ZEROES and LEFT_ALIGN can be given
; in bits 7 and 6 of b respectively.
-LEADING_ZEROES EQU 7
-LEFT_ALIGN EQU 6
-
push bc
xor a
ld [H_PASTLEADINGZEROES], a
@@ -4405,7 +4386,7 @@ endm
ret
.PrintLeadingZero:
- bit LEADING_ZEROES, d
+ bit BIT_LEADING_ZEROES, d
ret z
ld [hl], "0"
ret
@@ -4414,9 +4395,9 @@ endm
; Increment unless the number is left-aligned,
; leading zeroes are not printed, and no digits
; have been printed yet.
- bit LEADING_ZEROES, d
+ bit BIT_LEADING_ZEROES, d
jr nz, .inc
- bit LEFT_ALIGN, d
+ bit BIT_LEFT_ALIGN, d
jr z, .inc
ld a, [H_PASTLEADINGZEROES]
and a
@@ -4427,7 +4408,6 @@ endm
CallFunctionInTable::
-JumpTable::
; Call function a in jumptable hl.
; de is not preserved.
push hl
@@ -4477,14 +4457,14 @@ IsInRestOfArray::
ret
-RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe)
+RestoreScreenTilesAndReloadTilePatterns::
call ClearSprites
ld a, $1
ld [wUpdateSpritesEnabled], a
call ReloadMapSpriteTilePatterns
call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jr Delay3
@@ -4514,13 +4494,13 @@ GBPalWhiteOut::
ret
-GoPAL_SET_CF1C:: ; 3ded (0:3ded)
+RunDefaultPaletteCommand::
ld b,$ff
-GoPAL_SET:: ; 3def (0:3def)
+RunPaletteCommand::
ld a,[wOnSGB]
and a
ret z
- predef_jump Func_71ddf
+ predef_jump _RunPaletteCommand
GetHealthBarColor::
; Return at hl the palette of
@@ -4539,14 +4519,14 @@ GetHealthBarColor::
; Copy the current map's sprites' tile patterns to VRAM again after they have
; been overwritten by other tile patterns.
-ReloadMapSpriteTilePatterns:: ; 3e08 (0:3e08)
+ReloadMapSpriteTilePatterns::
ld hl, wFontLoaded
ld a, [hl]
push af
res 0, [hl]
push hl
xor a
- ld [W_SPRITESETID], a
+ ld [wSpriteSetID], a
call DisableLCD
callba InitMapSprites
call EnableLCD
@@ -4566,7 +4546,7 @@ GiveItem::
ld [wd11e], a
ld [wcf91], a
ld a, c
- ld [wcf96], a
+ ld [wItemQuantity], a
ld hl,wNumBagItems
call AddItemToInventory
ret nc
@@ -4580,12 +4560,10 @@ GivePokemon::
ld a, b
ld [wcf91], a
ld a, c
- ld [W_CURENEMYLVL], a
- xor a
- ld [wcc49], a
- ld b, BANK(_GivePokemon)
- ld hl, _GivePokemon
- jp Bankswitch
+ ld [wCurEnemyLVL], a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation], a
+ jpba _GivePokemon
Random::
@@ -4605,12 +4583,10 @@ Random::
INCLUDE "home/predef.asm"
-Func_3ead:: ; 3ead (0:3ead)
- ld b, BANK(CinnabarGymQuiz_1eb0a)
- ld hl, CinnabarGymQuiz_1eb0a
- jp Bankswitch
+UpdateCinnabarGymGateTileBlocks::
+ jpba UpdateCinnabarGymGateTileBlocks_
-CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
+CheckForHiddenObjectOrBookshelfOrCardKeyDoor::
ld a, [H_LOADEDROMBANK]
push af
ld a, [hJoyHeld]
@@ -4647,37 +4623,39 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
ld [H_LOADEDROMBANK], a
ret
-PrintPredefTextID:: ; 3ef5 (0:3ef5)
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+PrintPredefTextID::
+ ld [hSpriteIndexOrTextID], a
ld hl, TextPredefs
call SetMapTextPointer
- ld hl, wcf11
+ ld hl, wTextPredefFlag
set 0, [hl]
call DisplayTextID
-RestoreMapTextPointer:: ; 3f05 (0:3f05)
- ld hl, W_MAPTEXTPTR
+RestoreMapTextPointer::
+ ld hl, wMapTextPtr
ld a, [$ffec]
ld [hli], a
ld a, [$ffec + 1]
ld [hl], a
ret
-SetMapTextPointer:: ; 3f0f (0:3f0f)
- ld a, [W_MAPTEXTPTR]
+SetMapTextPointer::
+ ld a, [wMapTextPtr]
ld [$ffec], a
- ld a, [W_MAPTEXTPTR + 1]
+ ld a, [wMapTextPtr + 1]
ld [$ffec + 1], a
ld a, l
- ld [W_MAPTEXTPTR], a
+ ld [wMapTextPtr], a
ld a, h
- ld [W_MAPTEXTPTR + 1], a
+ ld [wMapTextPtr + 1], a
ret
TextPredefs::
+const_value = 1
+
add_tx_pre CardKeySuccessText ; 01
add_tx_pre CardKeyFailText ; 02
- add_tx_pre RedBedroomPC ; 03
+ add_tx_pre RedBedroomPCText ; 03
add_tx_pre RedBedroomSNESText ; 04
add_tx_pre PushStartText ; 05
add_tx_pre SaveOptionText ; 06
@@ -4701,17 +4679,17 @@ TextPredefs::
add_tx_pre SaffronCityPokecenterBenchGuyText ; 18
add_tx_pre MtMoonPokecenterBenchGuyText ; 19
add_tx_pre RockTunnelPokecenterBenchGuyText ; 1A
- add_tx_pre UnusedBenchGuyText1 ; 1B
- add_tx_pre UnusedBenchGuyText2 ; 1C
- add_tx_pre UnusedBenchGuyText3 ; 1D
- add_tx_pre TerminatorText_62508 ; 1E
- add_tx_pre PredefText1f ; 1F
+ add_tx_pre UnusedBenchGuyText1 ; 1B XXX unused
+ add_tx_pre UnusedBenchGuyText2 ; 1C XXX unused
+ add_tx_pre UnusedBenchGuyText3 ; 1D XXX unused
+ add_tx_pre UnusedPredefText ; 1E XXX unused
+ add_tx_pre PokemonCenterPCText ; 1F
add_tx_pre ViridianSchoolNotebook ; 20
add_tx_pre ViridianSchoolBlackboard ; 21
add_tx_pre JustAMomentText ; 22
- add_tx_pre PredefText23 ; 23
+ add_tx_pre OpenBillsPCText ; 23
add_tx_pre FoundHiddenItemText ; 24
- add_tx_pre HiddenItemBagFullText ; 25
+ add_tx_pre HiddenItemBagFullText ; 25 XXX unused
add_tx_pre VermilionGymTrashText ; 26
add_tx_pre IndigoPlateauHQText ; 27
add_tx_pre GameCornerOutOfOrderText ; 28
@@ -4729,13 +4707,13 @@ TextPredefs::
add_tx_pre LinkCableHelp ; 34
add_tx_pre TMNotebook ; 35
add_tx_pre FightingDojoText ; 36
- add_tx_pre FightingDojoText_52a10 ; 37
- add_tx_pre FightingDojoText_52a1d ; 38
+ add_tx_pre EnemiesOnEverySideText ; 37
+ add_tx_pre WhatGoesAroundComesAroundText ; 38
add_tx_pre NewBicycleText ; 39
add_tx_pre IndigoPlateauStatues ; 3A
- add_tx_pre VermilionGymTrashSuccesText1 ; 3B
- add_tx_pre VermilionGymTrashSuccesText2 ; 3C
- add_tx_pre VermilionGymTrashSuccesText3 ; 3D
+ add_tx_pre VermilionGymTrashSuccessText1 ; 3B
+ add_tx_pre VermilionGymTrashSuccessText2 ; 3C XXX unused
+ add_tx_pre VermilionGymTrashSuccessText3 ; 3D
add_tx_pre VermilionGymTrashFailText ; 3E
add_tx_pre TownMapText ; 3F
add_tx_pre BookOrSculptureText ; 40