ref: 0c916aea3353ed1bf2750be403b0da9ea0b922d4
parent: 91793015e53dbed09576f825d39e71bc59bf90a5
author: YamaArashi <[email protected]>
date: Fri Sep 12 20:50:56 EDT 2014
Commented more sprite and map code
--- a/data/special_warps.asm
+++ b/data/special_warps.asm
@@ -1,3 +1,6 @@
+; Format: (size 2 bytes)
+; 00: target map ID
+; 01: which dungeon warp in the source map was used
DungeonWarpList: ; 63bf (1:63bf)
db SEAFOAM_ISLANDS_2,$01
db SEAFOAM_ISLANDS_2,$02
--- a/engine/battle/14.asm
+++ b/engine/battle/14.asm
@@ -15,7 +15,7 @@
ld [wPartyGainExpFlags], a
ld [wPlayerMonNumber], a ; wPlayerMonNumber
ld [wEscapedFromBattle], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld hl, wcf1d
ld [hli], a
ld [hl], a
--- a/engine/battle/1c.asm
+++ b/engine/battle/1c.asm
@@ -89,7 +89,7 @@
xor a
ld [hVBlankWY], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call DelayFrame
ld hl, wSpriteStateData1 + 2
ld a, [H_DOWNARROWBLINKCNT2]
--- a/engine/battle/4_2.asm
+++ b/engine/battle/4_2.asm
@@ -71,7 +71,7 @@
call WaitForSoundToFinish
call GBPalWhiteOut
ld a, $ff
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ret
YouWinText: ; 13853 (4:7853)
@@ -94,7 +94,7 @@
ld a, [wd736]
and a
ret nz
- callab Func_c49d
+ callab IsPlayerStandingOnDoorTileOrWarpTile
jr nc, .asm_13888
.asm_13884
ld a, $1
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -517,7 +517,7 @@
ret
Func_78e23: ; 78e23 (1e:4e23)
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, $e4
jr z, .asm_78e47
@@ -1091,7 +1091,7 @@
AnimationFlashScreenLong: ; 79165 (1e:5165)
ld a,3 ; cycle through the palettes 3 times
ld [wd08a],a
- ld a,[wcf1b] ; running on SGB?
+ ld a,[wOnSGB] ; running on SGB?
and a
ld hl,FlashScreenLongMonochrome
jr z,.loop
@@ -1211,7 +1211,7 @@
ld bc, $4040
Func_791fc: ; 791fc (1e:51fc)
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, b
jr z, .asm_79204
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -139,7 +139,7 @@
ld [$ffd7], a
ld [hVBlankSCY], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
@@ -6247,7 +6247,7 @@
ld [wMenuJoypadPollCount], a
callab DisplayLinkBattleVersusTextBox
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearScreen
.next
call DelayFrame
@@ -6256,7 +6256,7 @@
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearSprites
call ClearScreen
xor a
@@ -6729,16 +6729,16 @@
bit 1, a
jr z, .asm_3ef2f
ld a, [hJoyHeld]
- bit 1, a
+ bit 1, a ; B button pressed?
ret nz
.asm_3ef2f
- ld a, [wd13c]
+ ld a, [wNumberOfNoRandomBattleStepsLeft]
and a
ret nz
callab Func_13870
ret nz
asm_3ef3d: ; 3ef3d (f:6f3d)
- ld a, [wd35d]
+ ld a, [wMapPalOffset]
push af
ld hl, wd358
ld a, [hl]
@@ -6849,7 +6849,7 @@
pop af
ld [wd358], a
pop af
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld a, [wd0d4]
ld [$ffd7], a
scf
--- a/engine/battle/d.asm
+++ b/engine/battle/d.asm
@@ -17,7 +17,7 @@
ld [hli], a
ld [hl], $6a
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
callab SetupPlayerAndEnemyPokeballs
ld c, 150
jp DelayFrames
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -570,13 +570,13 @@
xor a
ld [wd72d], a
dec a
- ld [wd42f], a
+ ld [wDestinationWarpID], a
call LoadMapData
callba Func_c335
pop hl
pop af
ld [hl], a
- call GBFadeIn2
+ call GBFadeInFromWhite
ret
Func_57a2:
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -127,7 +127,7 @@
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearSprites
callab Func_7bde9
jp c, CancelledEvolution
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -43,7 +43,7 @@
call SetPokedexOwnedFlag
call AddPartyMon
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld [wccd3], a
scf
ret
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -18,7 +18,7 @@
ld bc, HOF_TEAM
call FillMemory
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [$ffd7], a
ld [W_SPRITEFLIPPED], a
ld [wd358], a
@@ -66,7 +66,7 @@
call PlaceString
ld c, 180
call DelayFrames
- call GBFadeOut2
+ call GBFadeOutToWhite
pop bc
pop hl
jr .asm_701fb
@@ -125,7 +125,7 @@
call Func_7036d
ld d, $a0
ld e, $4
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
jr z, .asm_702c7
sla e
@@ -282,4 +282,4 @@
ld [wcfc9], a
ld a, $ff
ld [wMusicHeaderPointer], a
- jp GBFadeOut2
+ jp GBFadeOutToWhite
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -1,7 +1,7 @@
PrintNotebookText: ; 52996 (14:6996)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wTrainerSpriteOffset]
jp PrintPredefTextID
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -89,7 +89,7 @@
PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade]
call PrintPredefTextID
ret
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -181,7 +181,7 @@
ret nz
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ld a, $1f ; PredefText1f
jp PrintPredefTextID
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -114,7 +114,7 @@
db $06
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd730
set 6, [hl]
call GBPalWhiteOutWithDelay3
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -83,7 +83,7 @@
ld a, $9c
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
ld a, $3
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ld a, $5
ld [W_SAFARIZONEENTRANCECURSCRIPT], a
ld hl, wd790
@@ -152,7 +152,7 @@
ld l, a
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call CinnabarGymQuiz_1ea92
jp TextScriptEnd
@@ -334,7 +334,7 @@
jp PrintPredefTextID
.asm_1eb8b
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $2e
call PrintPredefTextID
ld c, $20
@@ -363,7 +363,7 @@
ret
.asm_1ebd2
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $2f
call PrintPredefTextID
ret
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -88,7 +88,7 @@
xor a
ld [wd07d],a
dec a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
push af
call Func_71ca2
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -5,7 +5,7 @@
ld [H_AUTOBGTRANSFERENABLED], a
call PlayShootingStar
call PlayIntroScene
- call GBFadeOut2
+ call GBFadeOutToWhite
xor a
ld [$ffae], a
ld [H_AUTOBGTRANSFERENABLED], a
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -507,8 +507,8 @@
ld a,[W_ISINBATTLE]
and a
jp nz,ItemUseNotTime
- ld a,[wd700]
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState]
+ ld [wWalkBikeSurfStateCopy],a
cp a,2 ; is the player surfing?
jp z,ItemUseNotTime
dec a ; is player already bicycling?
@@ -516,7 +516,7 @@
.getOffBike
call ItemUseReloadOverworldData
xor a
- ld [wd700],a ; change player state to walking
+ ld [wWalkBikeSurfState],a ; change player state to walking
call PlayDefaultMusic ; play walking music
ld hl,GotOffBicycleText
jr .printText
@@ -527,7 +527,7 @@
xor a ; no keys pressed
ld [hJoyHeld],a ; current joypad state
inc a
- ld [wd700],a ; change player state to bicycling
+ ld [wWalkBikeSurfState],a ; change player state to bicycling
ld hl,GotOnBicycleText
call PlayDefaultMusic ; play bike riding music
.printText
@@ -535,8 +535,8 @@
; used for Surf out-of-battle effect
ItemUseSurfboard: ; d9b4 (3:59b4)
- ld a,[wd700]
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState]
+ ld [wWalkBikeSurfStateCopy],a
cp a,2 ; is the player already surfing?
jr z,.tryToStopSurfing
.tryToSurf
@@ -550,7 +550,7 @@
ld hl,wd730
set 7,[hl]
ld a,2
- ld [wd700],a ; change player state to surfing
+ ld [wWalkBikeSurfState],a ; change player state to surfing
call PlayDefaultMusic ; play surfing music
ld hl,SurfingGotOnText
jp PrintText
@@ -570,7 +570,7 @@
ld a,[hli]
ld h,[hl]
ld l,a ; hl now points to passable tiles
- ld a,[wcfc6] ; tile in front of the player
+ ld a,[wTileInFrontOfPlayer] ; tile in front of the player
ld b,a
.passableTileLoop
ld a,[hli]
@@ -586,7 +586,7 @@
ld hl,wd730
set 7,[hl]
xor a
- ld [wd700],a ; change player state to walking
+ ld [wWalkBikeSurfState],a ; change player state to walking
dec a
ld [wJoyIgnore],a
call PlayDefaultMusic ; play walking music
@@ -636,7 +636,7 @@
ld a,$05 ; evolution stone party menu
ld [wd07d],a
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
pop bc
jr c,.canceledItemUse
@@ -681,7 +681,7 @@
ld a,$01
ld [wd07d],a ; item use party menu
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,[wd152]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
@@ -1096,7 +1096,7 @@
ld [H_AUTOBGTRANSFERENABLED],a
call ClearScreen
dec a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call RedrawPartyMenu ; redraws the party menu and displays the message
ld a,1
ld [H_AUTOBGTRANSFERENABLED],a
@@ -1278,7 +1278,7 @@
ld [wccd4],a
callab TryEvolvingMon ; evolve pokemon, if appropriate
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
pop af
ld [wcf91],a
pop af
@@ -1424,8 +1424,8 @@
ItemUseCardKey: ; e022 (3:6022)
xor a
ld [wd71f],a
- call Func_c586
- ld a,[Func_c586] ; $4586
+ call GetTileAndCoordsInFrontOfPlayer
+ ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
cp a,$18
jr nz,.next0
ld hl,CardKeyTable1
@@ -1796,7 +1796,7 @@
ld [W_CUROPPONENT], a
.next
- ld hl, wd700
+ ld hl, wWalkBikeSurfState
ld a, [hl] ; store the value in a
push af
push hl
@@ -1818,7 +1818,7 @@
.notInBattle
call IsNextTileShoreOrWater
ret c
- ld a,[wd700]
+ ld a,[wWalkBikeSurfState]
cp a,2 ; Surfing?
jr z,.surfing
call ItemUseReloadOverworldData
@@ -1877,7 +1877,7 @@
ld [wWhichTrade],a
.chooseMon
xor a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,$01 ; item use party menu
ld [wd07d],a
call DisplayPartyMenu
@@ -2117,7 +2117,7 @@
ld bc,14
call CopyData
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,$03 ; teach TM/HM party menu
ld [wd07d],a
call DisplayPartyMenu
@@ -2744,7 +2744,7 @@
jr nc, .notShoreOrWater
ld a, [W_CURMAPTILESET]
cp SHIP_PORT ; Vermilion Dock tileset
- ld a, [wcfc6] ; tile in front of player
+ ld a, [wTileInFrontOfPlayer] ; tile in front of player
jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset
cp $48 ; eastern shore tile in Safari Zone
jr z, .shoreOrWater
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -3,7 +3,7 @@
call GBPalWhiteOutWithDelay3
call ClearScreen
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wd730
set 6, [hl]
call DisableLCD
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -4,7 +4,7 @@
ld hl, wd730
set 6, [hl]
push hl
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, [$ffD7]
push af
@@ -11,7 +11,7 @@
xor a
ld [$ffD7], a
ld [W_SPRITEFLIPPED], a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
ld [wcd42], a
ld a, [wd5a2]
@@ -40,7 +40,7 @@
pop af
ld [$ffD7], a
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
pop hl
res 6, [hl]
call GBPalWhiteOutWithDelay3
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -111,16 +111,16 @@
call DelayFrames
ld a,[wd5a2]
and a
- jp z,Func_5d5f
+ jp z,SpecialEnterMap
ld a,[W_CURMAP] ; map ID
cp a,HALL_OF_FAME
- jp nz,Func_5d5f
+ jp nz,SpecialEnterMap
xor a
- ld [wd71a],a
+ ld [wDestinationMap],a
ld hl,wd732
- set 2,[hl]
- call Func_62ce
- jp Func_5d5f
+ set 2,[hl] ; fly warp or dungeon warp
+ call SpecialWarpIn
+ jp SpecialEnterMap
Func_5bff: ; 5bff (1:5bff)
ld a,1
ld [wd358],a
@@ -247,7 +247,7 @@
cp $2
jr z, .asm_5d2d
xor a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
and a
ld a, TRADE_CENTER
@@ -262,8 +262,8 @@
ld hl, wd732
res 1, [hl]
ld a, [W_ANIMATIONID] ; W_ANIMATIONID
- ld [wd71a], a
- call Func_62ce
+ ld [wDestinationMap], a
+ call SpecialWarpIn
ld c, $14
call DelayFrames
xor a
@@ -272,7 +272,7 @@
inc a
ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE
ld [wcc47], a
- jr Func_5d5f
+ jr SpecialEnterMap
.asm_5d2d
xor a
ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount
@@ -303,7 +303,8 @@
ld c, $14
call DelayFrames
-Func_5d5f: ; 5d5f (1:5d5f)
+; enter map after using a special warp or loading the game from the main menu
+SpecialEnterMap: ; 5d5f (1:5d5f)
xor a
ld [hJoyPressed], a
ld [hJoyHeld], a
@@ -310,9 +311,9 @@
ld [$ffb5], a
ld [wd72d], a
ld hl, wd732
- set 0, [hl]
+ set 0, [hl] ; count play time
call ResetPlayerSpriteData
- ld c, $14
+ ld c, 20
call DelayFrames
ld a, [wcc47]
and a
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -22,10 +22,10 @@
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
and a
jr nz, .asm_654c
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
push hl
ld a, $2
ld [wd07d], a
@@ -38,7 +38,7 @@
call LoadScreenTilesFromBuffer1
pop hl
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, [wcf4b]
cp $50
ret nz
@@ -56,7 +56,7 @@
Func_655c: ; 655c (1:655c)
ld hl, wHPBarMaxHP
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, $2
ld [wd07d], a
call DisplayNamingScreen
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -86,7 +86,7 @@
callba BillsPC_
ReloadMainMenu: ; 17f06 (5:7f06)
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call ReloadMapData
call UpdateSprites ;XXX: moves sprites
jp PCMainMenu
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -78,7 +78,7 @@
ld hl, wd730
res 6, [hl]
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
Func_7995: ; 7995 (1:7995)
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -2,8 +2,8 @@
ld a,$04 ; hardcoded Bank, not sure what's it refers to
ld [H_LOADEDROMBANK],a
ld [$2000],a ; ROM bank 4
- ld a,[wd700] ; walking/biking/surfing
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState] ; walking/biking/surfing
+ ld [wWalkBikeSurfStateCopy],a
ld a, (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound
call PlaySound
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -13,7 +13,7 @@
xor a
ld [wMenuItemToSwap],a
ld [wd07d],a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
jr .checkIfPokemonChosen
.loop
@@ -184,7 +184,7 @@
bit 0,a ; does the player have the Boulder Badge?
jp z,.newBadgeRequired
xor a
- ld [wd35d],a
+ ld [wMapPalOffset],a
ld hl,.flashLightsAreaText
call PrintText
call GBPalWhiteOutWithDelay3
@@ -406,7 +406,7 @@
jp z,ItemMenuLoop
jp CloseStartMenu
.useItem_partyMenu
- ld a,[wcfcb]
+ ld a,[wUpdateSpritesEnabled]
push af
call UseItem
ld a,[wcd6a]
@@ -415,11 +415,11 @@
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
pop af
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
jp StartMenu_Item
.partyMenuNotDisplayed
pop af
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
jp ItemMenuLoop
.tossItem
call IsKeyItem
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -21,7 +21,7 @@
ld c, a
ld hl, PartyMonSpeeds
add hl, bc
- ld a, [wcf1b]
+ ld a, [wOnSGB]
xor $1
add [hl]
ld c, a
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -49,8 +49,8 @@
ld [wcf96],a
call AddItemToInventory ; give one potion
ld a,[W_ANIMATIONID]
- ld [wd71a],a
- call Func_62ce
+ ld [wDestinationMap],a
+ call SpecialWarpIn
xor a
ld [$FFD7],a
ld a,[wd732]
@@ -62,7 +62,7 @@
call FadeInIntroPic
ld hl,OakSpeechText1
call PrintText ; prints text box
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld a,NIDORINO
ld [wd0b5],a ; pic displayed is stored at this location
@@ -73,7 +73,7 @@
call MovePicLeft
ld hl,OakSpeechText2
call PrintText ; Prints text box
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,RedPicFront
ld bc,(Bank(RedPicFront) << 8) | $00
@@ -82,7 +82,7 @@
ld hl,IntroducePlayerText
call PrintText
call LoadDefaultNamesPlayer ; brings up NewName/Red/etc menu
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,Rival1Pic
ld bc,(Bank(Rival1Pic) << 8) | $00
@@ -93,12 +93,12 @@
call LoadDefaultNamesRival
Func_61bc: ; 61bc (1:61bc)
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,RedPicFront
ld bc,(Bank(RedPicFront) << 8) | $00
call IntroPredef3B
- call GBFadeIn2
+ call GBFadeInFromWhite
ld a,[wd72d]
and a
jr nz,.next
@@ -148,10 +148,10 @@
call ClearScreenArea
call LoadTextBoxTilePatterns
ld a,1
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld c,$32
call DelayFrames
- call GBFadeOut2
+ call GBFadeOutToWhite
jp ClearScreen
OakSpeechText1: ; 6253 (1:6253)
TX_FAR _OakSpeechText1
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -8,8 +8,8 @@
ret z
cp b
jr nz, .asm_5267a
- predef Func_c586
- ld a, [wcfc6]
+ predef GetTileAndCoordsInFrontOfPlayer
+ ld a, [wTileInFrontOfPlayer]
cp $18
jr z, .asm_5269c
cp $24
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -6,13 +6,13 @@
jr z, .asm_ef6b
cp GYM
jr nz, .asm_ef77
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
jr nz, .asm_ef77
jr asm_ef82
.asm_ef6b
dec a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
jr z, asm_ef82
cp $52 ; grass
@@ -52,7 +52,7 @@
ld hl, wd730
res 6, [hl]
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call AnimateCutTree
ld de, CutTreeBlockSwaps ; $7100
call Func_f09f
@@ -59,7 +59,7 @@
call Func_eedc
callba Func_79e96
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, (SFX_02_56 - SFX_Headers_02) / 3
call PlaySound
ld a, $90
@@ -178,7 +178,7 @@
ld c, a
ld b, $0
ld d, $0
- ld hl, wd35f
+ ld hl, wCurrentTileBlockMapViewPointer
ld a, [hli]
ld h, [hl]
ld l, a
--- a/engine/overworld/doors.asm
+++ b/engine/overworld/doors.asm
@@ -1,5 +1,5 @@
-; returns whether the player is standing on a door in carry
-IsPlayerStandingOnDoor: ; 1a609 (6:6609)
+; returns whether the player is standing on a door tile in carry
+IsPlayerStandingOnDoorTile: ; 1a609 (6:6609)
push de
ld hl, DoorTileIDPointers ; $662c
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -11,10 +11,10 @@
ld hl, vChars1 + $780
ld bc, (BANK(EmotionBubblesPointerTable) << 8) + $04
call CopyVideoData
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, [wd736]
bit 6, a
ld hl, wOAMBuffer + $8f
@@ -51,7 +51,7 @@
ld c, $3c
call DelayFrames
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call DelayFrame
jp UpdateSprites
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -3,7 +3,7 @@
ld hl, vChars0 + $7c0
ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03
call CopyVideoData
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -12,7 +12,7 @@
ret nz
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade] ; item ID
ld [wd11e], a
call GetItemName
@@ -42,7 +42,7 @@
.BagFull
call WaitForTextScrollButtonPress ; wait for button press
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, HiddenItemBagFullText
call PrintText
jp TextScriptEnd
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -1,6 +1,6 @@
Func_46981: ; 46981 (11:6981)
xor a
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld a, [wd72d]
bit 4, a
ret nz
@@ -7,7 +7,7 @@
call ArePlayerCoordsInArray
ret nc
ld a, [wWhichTrade] ; wWhichTrade
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
ld hl, wd732
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -34,7 +34,7 @@
ld [wcc4d], a
predef HideObject
ld a, 1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, FoundItemText
jr .print
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -1,41 +1,41 @@
HandleLedges: ; 1a672 (6:6672)
ld a, [wd736]
- bit 6, a
+ bit 6, a ; already jumping down ledge
ret nz
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
and a ; OVERWORLD
ret nz
- predef Func_c586
+ predef GetTileAndCoordsInFrontOfPlayer
ld a, [wSpriteStateData1 + 9]
ld b, a
aCoord 8, 9
ld c, a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
ld d, a
- ld hl, LedgeTiles ; $66cf
-.asm_1a691
+ ld hl, LedgeTiles
+.loop
ld a, [hli]
cp $ff
ret z
cp b
- jr nz, .asm_1a6a4
+ jr nz, .nextLedgeTile1
ld a, [hli]
cp c
- jr nz, .asm_1a6a5
+ jr nz, .nextLedgeTile2
ld a, [hli]
cp d
- jr nz, .asm_1a6a6
+ jr nz, .nextLedgeTile3
ld a, [hl]
ld e, a
- jr .asm_1a6a9
-.asm_1a6a4
+ jr .foundMatch
+.nextLedgeTile1
inc hl
-.asm_1a6a5
+.nextLedgeTile2
inc hl
-.asm_1a6a6
+.nextLedgeTile3
inc hl
- jr .asm_1a691
-.asm_1a6a9
+ jr .loop
+.foundMatch
ld a, [hJoyHeld]
and e
ret z
@@ -42,7 +42,7 @@
ld a, $ff
ld [wJoyIgnore], a
ld hl, wd736
- set 6, [hl]
+ set 6, [hl] ; jumping down ledge
call StartSimulatingJoypadStates
ld a, e
ld [wSimulatedJoypadStatesEnd], a
@@ -56,24 +56,24 @@
; (player direction) (tile player standing on) (ledge tile) (input required)
LedgeTiles: ; 1a6cf (6:66cf)
- db $00,$2C,$37,$80
- db $00,$39,$36,$80
- db $00,$39,$37,$80
- db $08,$2C,$27,$20
- db $08,$39,$27,$20
- db $0C,$2C,$0D,$10
- db $0C,$2C,$1D,$10
- db $0C,$39,$0D,$10
+ db SPRITE_FACING_DOWN, $2C,$37,D_DOWN
+ db SPRITE_FACING_DOWN, $39,$36,D_DOWN
+ db SPRITE_FACING_DOWN, $39,$37,D_DOWN
+ db SPRITE_FACING_LEFT, $2C,$27,D_LEFT
+ db SPRITE_FACING_LEFT, $39,$27,D_LEFT
+ db SPRITE_FACING_RIGHT,$2C,$0D,D_RIGHT
+ db SPRITE_FACING_RIGHT,$2C,$1D,D_RIGHT
+ db SPRITE_FACING_RIGHT,$39,$0D,D_RIGHT
db $FF
LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
ld hl, vChars1 + $7f0
- ld de, LedgeHoppingShadow ; $6708
+ ld de, LedgeHoppingShadow
ld bc, (BANK(LedgeHoppingShadow) << 8) + $01
call CopyVideoDataDouble
ld a, $9
ld bc, $5448 ; b, c = y, x coordinates of shadow
- ld de, LedgeHoppingShadowOAM ; $6710
+ ld de, LedgeHoppingShadowOAM
call WriteOAMBlock
ret
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,7 +1,7 @@
PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
ld hl, wd730
res 1, [hl]
- call IsPlayerStandingOnDoor
+ call IsPlayerStandingOnDoorTile
jr nc, .notStandingOnDoor
ld a, $fc
ld [wJoyIgnore], a
@@ -62,7 +62,7 @@
ld a, $80
call FillMemory
ld [hl], $ff
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
ld de, wNPCMovementDirections2
call MoveSprite
@@ -100,18 +100,18 @@
Func_1a4a6: ; 1a4a6 (6:64a6)
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
ld [wSpriteStateData2 + $06], a
ld hl, wSimulatedJoypadStatesEnd
- ld de, RLEList_1a4e9
+ ld de, RLEList_PlayerWalkToLab
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
ld hl, wNPCMovementDirections2
- ld de, RLEList_1a4dc
+ ld de, RLEList_ProfOakWalkToLab
call DecodeRLEList
ld hl, wd72e
res 7, [hl]
@@ -121,7 +121,7 @@
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_1a4dc: ; 1a4dc (6:64dc)
+RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
db $00, $05
db $80, $01
db $00, $05
@@ -130,7 +130,7 @@
db $E0, $01
db $FF
-RLEList_1a4e9: ; 1a4e9 (6:64e9)
+RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
db D_UP, $02
db D_RIGHT, $03
db D_DOWN, $05
@@ -162,7 +162,7 @@
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
call PlaySound
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
call StartSimulatingJoypadStates
@@ -218,7 +218,7 @@
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
call PlaySound
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
@@ -276,7 +276,7 @@
ret z
jr .loop
.notRival
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
jp SetSpriteMovementBytesToFF
--- a/engine/overworld/oam.asm
+++ b/engine/overworld/oam.asm
@@ -2,13 +2,13 @@
; Determine OAM data for currently visible
; sprites and write it to wOAMBuffer.
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
dec a
jr z, .asm_4b1e
cp 0 - 1
ret nz
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
jp HideSprites
.asm_4b1e
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -1,66 +1,67 @@
-Func_70510: ; 70510 (1c:4510)
- call Func_706ef
+EnterMapAnim: ; 70510 (1c:4510)
+ call InitFacingDirectionBuffer
ld a, $ec
- ld [wSpriteStateData1 + 4], a
+ ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position
call Delay3
push hl
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, W_FLAGS_D733
- bit 7, [hl]
+ bit 7, [hl] ; used fly out of battle?
res 7, [hl]
- jr nz, .asm_70568
+ jr nz, .flyAnimation
ld a, (SFX_02_4c - SFX_Headers_02) / 3
call PlaySound
ld hl, wd732
- bit 4, [hl]
+ bit 4, [hl] ; used dungeon warp?
res 4, [hl]
pop hl
- jr nz, .asm_7055e
- call Func_705aa
+ jr nz, .dungeonWarpAnimation
+ call PlayerSpinWhileMovingDown
ld a, (SFX_02_4f - SFX_Headers_02) / 3
call PlaySound
- call Func_70787
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
- jr nz, .asm_7055b
- ld hl, wWhichTrade ; wWhichTrade
+ jr nz, .done
+; if the player is not standing on a warp pad or hole
+ ld hl, wPlayerSpinInPlaceAnimFrameDelay
xor a
- ld [hli], a
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
inc a
- ld [hli], a
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
ld a, $8
- ld [hli], a
- ld [hl], $ff
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
+ ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
- call Func_70730
-.asm_70558
+ call PlayerSpinInPlace
+.restoreDefaultMusic
call PlayDefaultMusic
-.asm_7055b
- jp Func_70772
-.asm_7055e
- ld c, $32
+.done
+ jp RestoreFacingDirectionAndYScreenPos
+.dungeonWarpAnimation
+ ld c, 50
call DelayFrames
- call Func_705aa
- jr .asm_7055b
-.asm_70568
+ call PlayerSpinWhileMovingDown
+ jr .done
+.flyAnimation
pop hl
- ld de, BirdSprite ; $4d80
+ ld de, BirdSprite
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
- call Func_706d7
+ call LoadBirdSpriteGraphics
ld a, (SFX_02_50 - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- xor a
- ld [hli], a
- ld a, $c
- ld [hli], a
- ld [hl], $8
+ ld hl, wFlyAnimUsingCoordList
+ xor a ; is using coord list
+ ld [hli], a ; wFlyAnimUsingCoordList
+ ld a, 12
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationEnterScreenCoords ; $4592
- call Func_706ae
+ call DoFlyAnimation
call LoadPlayerSpriteGraphics
- jr .asm_70558
+ jr .restoreDefaultMusic
FlyAnimationEnterScreenCoords: ; 70592 (1c:4592)
; y, x pairs
@@ -79,90 +80,92 @@
db $3C, $48
db $3C, $40
-Func_705aa: ; 705aa (1c:45aa)
- ld hl, wWhichTrade ; wWhichTrade
+PlayerSpinWhileMovingDown: ; 705aa (1c:45aa)
+ ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $10
- ld [hli], a
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $3c
- ld [hli], a
- call Func_7077f
- ld [hl], a
- jp Func_70755
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
+ call GetPlayerTeleportAnimFrameDelay
+ ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
+ jp PlayerSpinWhileMovingUpOrDown
_LeaveMapAnim: ; 705ba (1c:45ba)
- call Func_706ef
- call Func_70787
+ call InitFacingDirectionBuffer
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
- jr z, .asm_705ef
+ jr z, .playerNotStandingOnWarpPadOrHole
dec a
- jp nz, Func_7067d
-.asm_705c8
+ jp nz, LeaveMapThroughHoleAnim
+.spinWhileMovingUp
ld a, (SFX_02_4b - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $f0
- ld [hli], a
+ ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY
+ ld a, -$10
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $ec
- ld [hli], a
- call Func_7077f
- ld [hl], a
- call Func_70755
- call Func_70787
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
+ call GetPlayerTeleportAnimFrameDelay
+ ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
+ call PlayerSpinWhileMovingUpOrDown
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
dec a
- jr z, .asm_705e9
- ld c, $a
+ jr z, .playerStandingOnWarpPad
+; if not standing on a warp pad, there is an extra delay
+ ld c, 10
call DelayFrames
-.asm_705e9
- call GBFadeOut2
- jp Func_70772
-.asm_705ef
+.playerStandingOnWarpPad
+ call GBFadeOutToWhite
+ jp RestoreFacingDirectionAndYScreenPos
+.playerNotStandingOnWarpPadOrHole
ld a, $4
call StopMusic
ld a, [wd732]
- bit 6, a
- jr z, .asm_70610
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $10
- ld [hli], a
- ld a, $ff
- ld [hli], a
+ bit 6, a ; is the last used pokemon center the destination?
+ jr z, .flyAnimation
+; if going to the last used pokemon center
+ ld hl, wPlayerSpinInPlaceAnimFrameDelay
+ ld a, 16
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
+ ld a, -1
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
xor a
- ld [hli], a
- ld [hl], $a1
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
+ ld [hl], $a1 ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
- call Func_70730
- jr .asm_705c8
-.asm_70610
- call Func_706d7
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $ff
- ld [hli], a
- ld a, $8
- ld [hli], a
- ld [hl], $c
- call Func_706ae
+ call PlayerSpinInPlace
+ jr .spinWhileMovingUp
+.flyAnimation
+ call LoadBirdSpriteGraphics
+ ld hl, wFlyAnimUsingCoordList
+ ld a, $ff ; is not using coord list (flap in place)
+ ld [hli], a ; wFlyAnimUsingCoordList
+ ld a, 8
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $c ; wFlyAnimBirdSpriteImageIndex
+ call DoFlyAnimation
ld a, (SFX_02_50 - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- xor a
- ld [hli], a
+ ld hl, wFlyAnimUsingCoordList
+ xor a ; is using coord list
+ ld [hli], a ; wFlyAnimUsingCoordList
ld a, $c
- ld [hli], a
- ld [hl], $c
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationScreenCoords1 ; $464f
- call Func_706ae
- ld c, $28
+ call DoFlyAnimation
+ ld c, 40
call DelayFrames
- ld hl, wTrainerEngageDistance
- ld a, $b
- ld [hli], a
- ld [hl], $8
+ ld hl, wFlyAnimCounter
+ ld a, 11
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left)
ld de, FlyAnimationScreenCoords2 ; $4667
- call Func_706ae
- call GBFadeOut2
- jp Func_70772
+ call DoFlyAnimation
+ call GBFadeOutToWhite
+ jp RestoreFacingDirectionAndYScreenPos
FlyAnimationScreenCoords1: ; 7064f (1c:464f)
; y, x pairs
@@ -198,33 +201,35 @@
db $F0, $00
-Func_7067d: ; 7067d (1c:467d)
+LeaveMapThroughHoleAnim: ; 7067d (1c:467d)
ld a, $ff
- ld [wcfcb], a
- ld a, [wOAMBuffer + $02]
- ld [wOAMBuffer + $0a], a
- ld a, [wOAMBuffer + $06]
- ld [wOAMBuffer + $0e], a
+ ld [wUpdateSpritesEnabled], a ; disable UpdateSprites
+ ; shift upper half of player's sprite down 8 pixels and hide lower half
+ ld a, [wOAMBuffer + 0 * 4 + 2]
+ ld [wOAMBuffer + 2 * 4 + 2], a
+ ld a, [wOAMBuffer + 1 * 4 + 2]
+ ld [wOAMBuffer + 3 * 4 + 2], a
ld a, $a0
- ld [wOAMBuffer], a
- ld [wOAMBuffer + $04], a
- ld c, $2
+ ld [wOAMBuffer + 0 * 4], a
+ ld [wOAMBuffer + 1 * 4], a
+ ld c, 2
call DelayFrames
+ ; hide lower half of player's sprite
ld a, $a0
- ld [wOAMBuffer + $08], a
- ld [wOAMBuffer + $0c], a
- call GBFadeOut2
+ ld [wOAMBuffer + 2 * 4], a
+ ld [wOAMBuffer + 3 * 4], a
+ call GBFadeOutToWhite
ld a, $1
- ld [wcfcb], a
- jp Func_70772
+ ld [wUpdateSpritesEnabled], a ; enable UpdateSprites
+ jp RestoreFacingDirectionAndYScreenPos
-Func_706ae: ; 706ae (1c:46ae)
- ld a, [wTrainerFacingDirection]
- xor $1
- ld [wTrainerFacingDirection], a
+DoFlyAnimation: ; 706ae (1c:46ae)
+ ld a, [wFlyAnimBirdSpriteImageIndex]
+ xor $1 ; make the bird flap its wings
+ ld [wFlyAnimBirdSpriteImageIndex], a
ld [wSpriteStateData1 + 2], a
call Delay3
- ld a, [wWhichTrade] ; wWhichTrade
+ ld a, [wFlyAnimUsingCoordList]
cp $ff
jr z, .asm_706cd
ld hl, wSpriteStateData1 + 4
@@ -236,13 +241,13 @@
inc de
ld [hl], a
.asm_706cd
- ld a, [wTrainerEngageDistance]
+ ld a, [wFlyAnimCounter]
dec a
- ld [wTrainerEngageDistance], a
- jr nz, Func_706ae
+ ld [wFlyAnimCounter], a
+ jr nz, DoFlyAnimation
ret
-Func_706d7: ; 706d7 (1c:46d7)
+LoadBirdSpriteGraphics: ; 706d7 (1c:46d7)
ld de, BirdSprite ; $4d80
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
@@ -252,21 +257,21 @@
ld bc, (BANK(BirdSprite) << 8) + $0c
jp CopyVideoData
-Func_706ef: ; 706ef (1c:46ef)
- ld a, [wSpriteStateData1 + 2]
+InitFacingDirectionBuffer: ; 706ef (1c:46ef)
+ ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld [wcd50], a
- ld a, [wSpriteStateData1 + 4]
+ ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
ld [wcd4f], a
- ld hl, PlayerSpinningFacingOrder ; $4713
+ ld hl, PlayerSpinningFacingOrder
ld de, wcd48
ld bc, $4
call CopyData
- ld a, [wSpriteStateData1 + 2]
+ ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld hl, wcd48
-.asm_7070d
+.loop
cp [hl]
inc hl
- jr nz, .asm_7070d
+ jr nz, .loop
dec hl
ret
@@ -273,11 +278,11 @@
PlayerSpinningFacingOrder: ; 70713 (1c:4713)
; The order of the direction the player's sprite is facing when teleporting
; away. Creates a spinning effect.
- db $00, $08, $04, $0C ; down, left, up, right
+ db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT
-Func_70717: ; 70717 (1c:4717)
+SpinPlayerSprite: ; 70717 (1c:4717)
ld a, [hl]
- ld [wSpriteStateData1 + 2], a
+ ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images)
push hl
ld hl, wcd48
ld de, wcd47
@@ -288,43 +293,43 @@
pop hl
ret
-Func_70730: ; 70730 (1c:4730)
- call Func_70717
- ld a, [wWhichTrade] ; wWhichTrade
+PlayerSpinInPlace: ; 70730 (1c:4730)
+ call SpinPlayerSprite
+ ld a, [wPlayerSpinInPlaceAnimFrameDelay]
ld c, a
and $3
jr nz, .asm_70743
- ld a, [wTrainerScreenY]
+ ld a, [wPlayerSpinInPlaceAnimSoundID]
cp $ff
call nz, PlaySound
.asm_70743
- ld a, [wTrainerEngageDistance]
+ ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta]
add c
- ld [wWhichTrade], a ; wWhichTrade
+ ld [wPlayerSpinInPlaceAnimFrameDelay], a
ld c, a
- ld a, [wTrainerFacingDirection]
+ ld a, [wPlayerSpinInPlaceAnimFrameDelayEndValue]
cp c
ret z
call DelayFrames
- jr Func_70730
+ jr PlayerSpinInPlace
-Func_70755: ; 70755 (1c:4755)
- call Func_70717
- ld a, [wWhichTrade] ; wWhichTrade
+PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755)
+ call SpinPlayerSprite
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimDeltaY]
ld c, a
- ld a, [wSpriteStateData1 + 4]
+ ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
add c
ld [wSpriteStateData1 + 4], a
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimMaxY]
cp c
ret z
- ld a, [wTrainerFacingDirection]
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimFrameDelay]
ld c, a
call DelayFrames
- jr Func_70755
+ jr PlayerSpinWhileMovingUpOrDown
-Func_70772: ; 70772 (1c:4772)
+RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772)
ld a, [wcd4f]
ld [wSpriteStateData1 + 4], a
ld a, [wcd50]
@@ -331,41 +336,42 @@
ld [wSpriteStateData1 + 2], a
ret
-Func_7077f: ; 7077f (1c:477f)
- ld a, [wcf1b]
+; if SGB, 2 frames, else 3 frames
+GetPlayerTeleportAnimFrameDelay: ; 7077f (1c:477f)
+ ld a, [wOnSGB]
xor $1
inc a
inc a
ret
-Func_70787: ; 70787 (1c:4787)
+IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
ld b, 0
- ld hl, DataTable_707a9 ; $47a9
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld hl, .warpPadAndHoleData
+ ld a, [W_CURMAPTILESET]
ld c, a
-.asm_70790
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_707a4
+ jr z, .done
cp c
- jr nz, .asm_7079e
+ jr nz, .nextEntry
aCoord 8, 9
cp [hl]
- jr z, .asm_707a2
-.asm_7079e
+ jr z, .foundMatch
+.nextEntry
inc hl
inc hl
- jr .asm_70790
-.asm_707a2
+ jr .loop
+.foundMatch
inc hl
ld b, [hl]
-.asm_707a4
+.done
ld a, b
ld [wcd5b], a
ret
; format: db tileset id, tile id, value to be put in wcd5b
-DataTable_707a9: ; 707a9 (1c:47a9)
+.warpPadAndHoleData: ; 707a9 (1c:47a9)
db FACILITY, $20, 1 ; warp pad
db FACILITY, $11, 2 ; hole
db CAVERN, $22, 2 ; hole
@@ -454,7 +460,7 @@
db "@"
FishingRodGfxProperties: ; 70856 (1c:4856)
-; specicies how the fishing rod should be drawn on the screen
+; specifies how the fishing rod should be drawn on the screen
; first byte = screen y coordinate
; second byte = screen x coordinate
; third byte = tile number
@@ -482,21 +488,21 @@
dw vNPCSprites2 + $7d0
_HandleMidJump: ; 7087e (1c:487e)
- ld a, [wd714]
+ ld a, [wPlayerJumpingYScreenCoordsIndex]
ld c, a
inc a
cp $10
- jr nc, .asm_70895
- ld [wd714], a
- ld b, $0
- ld hl, PlayerJumpingYScreenCoords ; $48ba
+ jr nc, .finishedJump
+ ld [wPlayerJumpingYScreenCoordsIndex], a
+ ld b, 0
+ ld hl, PlayerJumpingYScreenCoords
add hl, bc
ld a, [hl]
ld [wSpriteStateData1 + 4], a ; player's sprite y coordinate
ret
-.asm_70895
- ld a, [wWalkCounter] ; wcfc5
- cp $0
+.finishedJump
+ ld a, [wWalkCounter]
+ cp 0
ret nz
call UpdateSprites
call Delay3
@@ -504,11 +510,11 @@
ld [hJoyHeld], a
ld [hJoyPressed], a
ld [hJoyReleased], a
- ld [wd714], a
+ ld [wPlayerJumpingYScreenCoordsIndex], a
ld hl, wd736
- res 6, [hl]
+ res 6, [hl] ; not jumping down a ledge any more
ld hl, wd730
- res 7, [hl]
+ res 7, [hl] ; not simulating joypad states any more
xor a
ld [wJoyIgnore], a
ret
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -203,7 +203,7 @@
ld hl,PokemartThankYouText
call PrintText
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call UpdateSprites ; move sprites
ld a,[wd07e]
ld [wListScrollOffset],a
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -1,10 +1,10 @@
AnimateBoulderDust: ; 79f54 (1e:5f54)
ld a, $1
ld [wcd50], a ; select the boulder dust offsets
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, %11100100
ld [rOBP1], a
call LoadSmokeTileFourTimes
@@ -26,7 +26,7 @@
dec c
jr nz, .loop
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
jp LoadPlayerSpriteGraphics
GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92)
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -1,7 +1,7 @@
_GetSpritePosition1: ; 567f9 (15:67f9)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli]
@@ -20,7 +20,7 @@
_GetSpritePosition2: ; 56819 (15:6819)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
@@ -39,7 +39,7 @@
_SetSpritePosition1: ; 5683d (15:683d)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [$ffeb] ; c1x4 (screen Y pos)
@@ -58,7 +58,7 @@
_SetSpritePosition2: ; 5685d (15:685d)
ld hl, wSpriteStateData1
ld de, $0004
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [wd130]
@@ -75,7 +75,7 @@
ret
TrainerWalkUpToPlayer: ; 56881 (15:6881)
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a ; wWhichTrade
call ReadTrainerScreenPosition
@@ -143,7 +143,7 @@
ld de, wNPCMovementDirections2
call FillMemory ; write the necessary steps to reach player
ld [hl], $ff ; write end of list sentinel
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
jp MoveSprite_
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -380,11 +380,11 @@
LoadSGB: ; 7202b (1c:602b)
xor a
- ld [wcf1b], a
+ ld [wOnSGB], a
call Func_7209b
ret nc
ld a, $1
- ld [wcf1b], a
+ ld [wOnSGB], a
ld a, [wGBC]
and a
jr z, .asm_7203f
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -71,19 +71,19 @@
add_predef FlagActionPredef
add_predef HideObject
add_predef IsObjectHidden
- add_predef Func_c69c
+ add_predef ApplyOutOfBattlePoisonDamage
add_predef AnyPartyAlive
add_predef ShowObject
add_predef ShowObject2
add_predef Func_ee9e
add_predef InitPlayerData2
- add_predef Func_c754
+ add_predef LoadTilesetHeader
add_predef LearnMoveFromLevelUp
add_predef LearnMove
add_predef IsItemInBag_ ; 1C, used in Pokémon Tower
dbw $03,Func_3eb5 ; for these two, the bank number is actually 0
dbw $03,GiveItem
- add_predef Func_480eb
+ add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef Func_480ff
add_predef CalcPositionOfPlayerRelativeToNPC
@@ -105,7 +105,7 @@
add_predef PlayIntro
add_predef Func_79869
add_predef FlashScreen
- add_predef Func_c586
+ add_predef GetTileAndCoordsInFrontOfPlayer
add_predef StatusScreen
add_predef StatusScreen2
add_predef Func_410e2
@@ -140,9 +140,9 @@
add_predef HallOfFamePC
add_predef DisplayDexRating
dbw $1E, _LeaveMapAnim ; wrong bank
- dbw $1E, Func_70510 ; wrong bank
- add_predef Func_c5be
- add_predef Func_c60b
+ dbw $1E, EnterMapAnim ; wrong bank
+ add_predef GetTileTwoStepsInFrontOfPlayer
+ add_predef CheckForCollisionWhenPushingBoulder
add_predef PrintStrengthTxt
add_predef PickupItem
add_predef Func_27d98
--- a/engine/predefs12.asm
+++ b/engine/predefs12.asm
@@ -1,13 +1,14 @@
-Func_480eb: ; 480eb (12:40eb)
+; b = new colour for BG colour 0 (usually white) for 4 frames
+ChangeBGPalColor0_4Frames: ; 480eb (12:40eb)
call GetPredefRegisters
- ld a, [rBGP] ; $ff47
+ ld a, [rBGP]
or b
- ld [rBGP], a ; $ff47
+ ld [rBGP], a
ld c, $4
call DelayFrames
- ld a, [rBGP] ; $ff47
- and $fc
- ld [rBGP], a ; $ff47
+ ld a, [rBGP]
+ and %11111100
+ ld [rBGP], a
ret
Func_480ff: ; 480ff (12:40ff)
--- a/engine/predefs7.asm
+++ b/engine/predefs7.asm
@@ -31,7 +31,7 @@
ld b, a
ld a, [hl]
ld c, a
- ld hl, wd3af
+ ld hl, wWarpEntries
call Func_1ca0d
Func_1ca0d: ; 1ca0d (7:4a0d)
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -1,7 +1,7 @@
PromptUserToPlaySlots: ; 3730e (d:730e)
call SaveScreenTilesToBuffer2
ld a, BANK(DisplayTextIDInit)
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ld b, a
ld hl, DisplayTextIDInit
call Bankswitch
@@ -12,7 +12,7 @@
and a
jr nz, .skip
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wcd4f
xor a
ld [hli], a
@@ -40,7 +40,7 @@
ld [W_SUBANIMSUBENTRYADDR], a
call GBPalWhiteOutWithDelay3
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call GoPAL_SET_CF1C
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
@@ -221,7 +221,7 @@
call SlotMachine_374fb
call SlotMachine_37517
ret c
- ld a, [wcf1b]
+ ld a, [wOnSGB]
xor $1
inc a
ld c, a
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -1,6 +1,6 @@
DisplayTownMap: ; 70e3e (1c:4e3e)
call LoadTownMap
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -111,7 +111,7 @@
LoadTownMap_Nest: ; 70f60 (1c:4f60)
call LoadTownMap
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -148,7 +148,7 @@
ld bc, (BANK(TownMapUpArrow) << 8) + $01
call CopyVideoDataDouble
call Func_71070
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -206,7 +206,7 @@
ld a, (SFX_02_3e - SFX_Headers_02) / 3
call PlaySound
ld a, [hl]
- ld [wd71a], a
+ ld [wDestinationMap], a
ld hl, wd732
set 3, [hl]
inc hl
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -119,10 +119,10 @@
call FillMemory
call ClearSprites
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wd730
set 6, [hl]
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, $e4
jr z, .asm_411e5
--- a/home.asm
+++ b/home.asm
@@ -173,7 +173,7 @@
ld b,0
add hl,bc
ld bc,4
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call CopyData
pop af
ld [H_LOADEDROMBANK],a
@@ -1464,7 +1464,7 @@
UpdateSprites:: ; 2429 (0:2429)
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
dec a
ret nz
ld a, [H_LOADEDROMBANK]
@@ -1607,18 +1607,18 @@
ld l,a ; hl = map text pointer
ld d,$00
ld a,[$ff8c] ; text ID
- ld [wcf13],a
+ ld [wSpriteIndex],a
and a
jp z,DisplayStartMenu
- cp a,$d3 ; safari game over
+ cp a,$d3
jp z,DisplaySafariGameOverText
- cp a,$d0 ; fainted
+ cp a,$d0
jp z,DisplayPokemonFaintedText
- cp a,$d1 ; blacked out
+ cp a,$d1
jp z,DisplayPlayerBlackedOutText
- cp a,$d2 ; repel wore off
+ cp a,$d2
jp z,DisplayRepelWoreOffText
- ld a,[W_NUMSPRITES] ; number of sprites
+ ld a,[W_NUMSPRITES]
ld e,a
ld a,[$ff8c] ; sprite ID
cp e
@@ -1678,7 +1678,7 @@
jr AfterDisplayingTextID
.notSpecialCase
call Func_3c59 ; display the text
- ld a,[wcc3c]
+ ld a,[wDoNotWaitForButtonPressAfterDisplayingText]
and a
jr nz,HoldTextDisplayOpen
@@ -1723,13 +1723,13 @@
ld hl,wcfc4
res 0,[hl]
ld a,[wd732]
- bit 3,a
+ bit 3,a ; used fly warp
call z,LoadPlayerSpriteGraphics
call LoadCurrentMapView
pop af
ld [H_LOADEDROMBANK],a
ld [$2000],a
- jp UpdateSprites ; move sprites
+ jp UpdateSprites
DisplayPokemartDialogue:: ; 2a2e (0:2a2e)
push hl
@@ -1757,7 +1757,7 @@
LoadItemList:: ; 2a5a (0:2a5a)
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,h
ld [wd128],a
ld a,l
@@ -1805,7 +1805,7 @@
ld hl,PlayerBlackedOutText
call PrintText
ld a,[wd732]
- res 5,a
+ res 5,a ; reset forced to use bike bit
ld [wd732],a
jp HoldTextDisplayOpen
@@ -2616,7 +2616,7 @@
; causes the text box to close without waiting for a button press after displaying text
DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6)
ld a,$01
- ld [wcc3c],a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a
ret
; uses an item
@@ -2872,11 +2872,11 @@
; checks if any trainers are seeing the player and wanting to fight
CheckFightingMapTrainers:: ; 3219 (0:3219)
call CheckForEngagingTrainers
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $ff
jr nz, .trainerEngaging
xor a
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld [wTrainerHeaderFlagBit], a
ret
.trainerEngaging
@@ -2900,7 +2900,7 @@
and $1
ret nz
ld [wJoyIgnore], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
@@ -2939,7 +2939,7 @@
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld hl, W_MISSABLEOBJECTLIST
ld de, $2
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
@@ -3006,7 +3006,7 @@
.trainerLoop
call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer
ld a, [de]
- ld [wcf13], a ; store trainer flag's bit
+ ld [wSpriteIndex], a ; store trainer flag's bit
ld [wTrainerHeaderFlagBit], a
cp $ff
ret z
@@ -3028,7 +3028,7 @@
ld a, [hl] ; read trainer engage distance
pop hl
ld [wTrainerEngageDistance], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a ; wWhichTrade
predef TrainerEngage
@@ -3059,11 +3059,11 @@
ret
; loads data of some trainer on the current map and plays pre-battle music
-; [wcf13]: sprite ID of trainer who is engaged
+; [wSpriteIndex]: sprite ID of trainer who is engaged
EngageMapTrainer:: ; 336a (0:336a)
ld hl, W_MAPSPRITEEXTRADATA
ld d, $0
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
dec a
add a
ld e, a
@@ -4708,9 +4708,9 @@
ld a,$01
AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41)
- ld [wcf0c],a ; control text box drawing
+ ld [wAutoTextBoxDrawingControl],a
xor a
- ld [wcc3c],a ; make DisplayTextID wait for button press
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press
ret
PrintText:: ; 3c49 (0:3c49)
@@ -5015,7 +5015,7 @@
RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe)
call ClearSprites
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ReloadMapSpriteTilePatterns
call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
@@ -5052,7 +5052,7 @@
GoPAL_SET_CF1C:: ; 3ded (0:3ded)
ld b,$ff
GoPAL_SET:: ; 3def (0:3def)
- ld a,[wcf1b]
+ ld a,[wOnSGB]
and a
ret z
predef_jump Func_71ddf
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -17,7 +17,7 @@
ld c, $8
ld d, c
asm_2324:: ; 2324 (0:2324)
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_2343
cp $2
--- a/home/fade.asm
+++ b/home/fade.asm
@@ -1,7 +1,7 @@
; These routines manage gradual fading
; (e.g., entering a doorway)
LoadGBPal::
- ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?)
+ ld a, [wMapPalOffset] ;tells if cur.map is dark (requires HM5_FLASH?)
ld b, a
ld hl, FadePal4
ld a, l
@@ -18,16 +18,16 @@
ld [rOBP1], a
ret
-GBFadeOut1::
+GBFadeInFromBlack::
ld hl, FadePal1
ld b, 4
- jr GBFadeOutCommon
+ jr GBFadeIncCommon
-GBFadeOut2::
+GBFadeOutToWhite::
ld hl, FadePal6
ld b, 3
-GBFadeOutCommon::
+GBFadeIncCommon:
ld a, [hli]
ld [rBGP], a
ld a, [hli]
@@ -37,19 +37,19 @@
ld c, 8
call DelayFrames
dec b
- jr nz, GBFadeOutCommon
+ jr nz, GBFadeIncCommon
ret
-GBFadeIn1::
+GBFadeOutToBlack::
ld hl, FadePal4 + 2
ld b, 4
- jr GBFadeInCommon
+ jr GBFadeDecCommon
-GBFadeIn2::
+GBFadeInFromWhite::
ld hl, FadePal7 + 2
ld b, 3
-GBFadeInCommon::
+GBFadeDecCommon:
ld a, [hld]
ld [rOBP1], a
ld a, [hld]
@@ -59,7 +59,7 @@
ld c, 8
call DelayFrames
dec b
- jr nz, GBFadeInCommon
+ jr nz, GBFadeDecCommon
ret
FadePal1:: db %11111111, %11111111, %11111111
--- a/home/init.asm
+++ b/home/init.asm
@@ -105,7 +105,7 @@
xor a
ld [$ffbc], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
predef PlayIntro
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -12,11 +12,11 @@
call LoadMapData
callba Func_c335 ; initialize map variables
ld hl, wd72c
- bit 0, [hl]
- jr z, .doNotCountSteps
- ld a, 3
- ld [wd13c], a ; some kind of step counter (counts up to 3 steps?)
-.doNotCountSteps
+ bit 0, [hl] ; has the player already made 3 steps since the last battle?
+ jr z, .skipGivingThreeStepsOfNoRandomBattles
+ ld a, 3 ; minimum number of steps between battles
+ ld [wNumberOfNoRandomBattleStepsLeft], a
+.skipGivingThreeStepsOfNoRandomBattles
ld hl, wd72e
bit 5, [hl] ; did a battle happen immediately before this?
res 5, [hl] ; unset the "battle just happened" flag
@@ -24,12 +24,12 @@
call nz, MapEntryAfterBattle
ld hl, wd732
ld a, [hl]
- and 1 << 4 | 1 << 3
- jr z, .didNotFlyOrTeleportIn
+ and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ jr z, .didNotEnterUsingFlyWarpOrDungeonWarp
res 3, [hl]
- callba Func_70510 ; display fly/teleport in graphical effect
+ callba EnterMapAnim ; display fly/teleport in graphical effect
call UpdateSprites
-.didNotFlyOrTeleportIn
+.didNotEnterUsingFlyWarpOrDungeonWarp
callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road
ld hl, wd72d
res 5, [hl]
@@ -61,8 +61,8 @@
res 3,[hl]
jp nz,WarpFound2
ld a,[wd732]
- and a,$18
- jp nz,HandleFlyOrTeleportAway
+ and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ jp nz,HandleFlyWarpOrDungeonWarp
ld a,[W_CUROPPONENT]
and a
jp nz,.newBattle
@@ -98,8 +98,8 @@
and a
jp z,OverworldLoop
.displayDialogue
- predef Func_c586 ; check what is in front of the player
- call UpdateSprites ; move sprites
+ predef GetTileAndCoordsInFrontOfPlayer
+ call UpdateSprites
ld a,[wFlags_0xcd60]
bit 2,a
jr nz,.checkForOpponent
@@ -117,8 +117,8 @@
jr z,.changeMap
predef LoadSAV
ld a,[W_CURMAP]
- ld [wd71a],a
- call Func_62ce
+ ld [wDestinationMap],a
+ call SpecialWarpIn
ld a,[W_CURMAP]
call SwitchToMapRomBank ; switch to the ROM bank of the current map
ld hl,W_CURMAPTILESET
@@ -133,7 +133,7 @@
.noDirectionButtonsPressed
ld hl,wFlags_0xcd60
res 2,[hl]
- call UpdateSprites ; move sprites
+ call UpdateSprites
ld a,$01
ld [wcc4b],a
ld a,[wd528] ; the direction that was pressed last time
@@ -225,18 +225,20 @@
.noDirectionChange
ld a,[wd52a] ; current direction
ld [wd528],a ; save direction
- call UpdateSprites ; move sprites
- ld a,[wd700]
+ call UpdateSprites
+ ld a,[wWalkBikeSurfState]
cp a,$02 ; surfing
jr z,.surfing
; not surfing
call CollisionCheckOnLand
jr nc,.noCollision
+; collision occurred
push hl
ld hl,wd736
- bit 2,[hl]
+ bit 2,[hl] ; standing on warp flag
pop hl
jp z,OverworldLoop
+; collision occurred while standing on a warp
push hl
call ExtraWarpCheck ; sets carry if there is a potential to warp
pop hl
@@ -259,7 +261,7 @@
.moveAhead2
ld hl,wFlags_0xcd60
res 2,[hl]
- ld a,[wd700]
+ ld a,[wWalkBikeSurfState]
dec a ; riding a bike?
jr nz,.normalPlayerSpriteAdvancement
ld a,[wd736]
@@ -276,16 +278,16 @@
bit 7,a
jr nz,.doneStepCounting ; if button presses are being simulated, don't count steps
; step counting
- ld hl,wd13b ; step counter
+ ld hl,wStepCounter
dec [hl]
ld a,[wd72c]
bit 0,a
jr z,.doneStepCounting
- ld hl,wd13c
+ ld hl,wNumberOfNoRandomBattleStepsLeft
dec [hl]
jr nz,.doneStepCounting
ld hl,wd72c
- res 0,[hl]
+ res 0,[hl] ; indicate that the player has stepped thrice since the last battle
.doneStepCounting
ld a,[wd790]
bit 7,a ; in the safari zone?
@@ -298,7 +300,7 @@
ld a,[W_ISINBATTLE]
and a
jp nz,CheckWarpsNoCollision
- predef Func_c69c ; decrement HP of poisoned pokemon
+ predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp
ld a,[wd12d]
and a
jp nz,HandleBlackOut ; if all pokemon fainted
@@ -305,7 +307,7 @@
.newBattle
call NewBattle
ld hl,wd736
- res 2,[hl]
+ res 2,[hl] ; standing on warp flag
jp nc,CheckWarpsNoCollision ; check for warps if there was no battle
.battleOccurred
ld hl,wd72d
@@ -316,7 +318,7 @@
set 5,[hl]
set 6,[hl]
xor a
- ld [hJoyHeld],a ; clear joypad state
+ ld [hJoyHeld],a
ld a,[W_CURMAP]
cp a,CINNABAR_GYM
jr nz,.notCinnabarGym
@@ -327,8 +329,8 @@
set 5,[hl]
ld a,[W_CURMAP]
cp a,OAKS_LAB
- jp z,.noFaintCheck
- callab AnyPartyAlive ; check if all the player's pokemon fainted
+ jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
+ callab AnyPartyAlive
ld a,d
and a
jr z,.allPokemonFainted
@@ -355,7 +357,7 @@
jr nz,.noBattle
ld b, BANK(InitBattle)
ld hl, InitBattle
- jp Bankswitch ; determines if a battle will occur and runs the battle if so
+ jp Bankswitch
.noBattle
and a
ret
@@ -368,8 +370,8 @@
ld a,[W_CURMAP]
cp a,ROUTE_17 ; Cycling Road
jr nz,.goFaster
- ld a,[hJoyHeld] ; current joypad state
- and a,%01110000 ; bit mask for up, left, right buttons
+ ld a,[hJoyHeld]
+ and a,D_UP | D_LEFT | D_RIGHT
ret nz
.goFaster
jp AdvancePlayerSprite
@@ -376,17 +378,17 @@
; check if the player has stepped onto a warp after having not collided
CheckWarpsNoCollision:: ; 06b4 (0:06b4)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
and a
jp z,CheckMapConnections
- ld a,[wd3ae] ; number of warps
- ld b,$00
+ ld a,[wNumberOfWarps]
+ ld b,0
ld c,a
ld a,[W_YCOORD]
ld d,a
ld a,[W_XCOORD]
ld e,a
- ld hl,wd3af ; start of warp entries
+ ld hl,wWarpEntries
CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc)
ld a,[hli] ; check if the warp's Y position matches
cp d
@@ -398,14 +400,14 @@
push hl
push bc
ld hl,wd736
- set 2,[hl]
- callba Func_c49d ; check if the player sprite is standing on a "door" tile
+ set 2,[hl] ; standing on warp flag
+ callba IsPlayerStandingOnDoorTileOrWarpTile
pop bc
pop hl
- jr c,WarpFound1 ; if it is, go to 0735
+ jr c,WarpFound1 ; jump if standing on door or warp
push hl
push bc
- call ExtraWarpCheck ; sets carry if the warp is confirmed
+ call ExtraWarpCheck
pop bc
pop hl
jr nc,CheckWarpsNoCollisionRetry2
@@ -418,16 +420,16 @@
call Joypad
pop bc
pop de
- ld a,[hJoyHeld] ; current joypad state
- and a,%11110000 ; bit mask for directional buttons
+ ld a,[hJoyHeld]
+ and a,D_DOWN | D_UP | D_LEFT | D_RIGHT
jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp
jr WarpFound1
; check if the player has stepped onto a warp after having collided
CheckWarpsCollision:: ; 0706 (0:0706)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
ld c,a
- ld hl,wd3af ; start of warp entries
+ ld hl,wWarpEntries
.loop
ld a,[hli] ; Y coordinate of warp
ld b,a
@@ -440,7 +442,7 @@
cp b
jr nz,.retry2
ld a,[hli]
- ld [wd42f],a ; save target warp ID
+ ld [wDestinationWarpID],a
ld a,[hl]
ld [$ff8b],a ; save target map
jr WarpFound2
@@ -462,12 +464,12 @@
WarpFound1:: ; 0735 (0:0735)
ld a,[hli]
- ld [wd42f],a ; save target warp ID
+ ld [wDestinationWarpID],a
ld a,[hli]
ld [$ff8b],a ; save target map
WarpFound2:: ; 073c (0:073c)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
sub c
ld [wd73b],a ; save ID of used warp
ld a,[W_CURMAP]
@@ -484,8 +486,8 @@
cp a,ROCK_TUNNEL_1
jr nz,.notRockTunnel
ld a,$06
- ld [wd35d],a
- call GBFadeIn1
+ ld [wMapPalOffset],a
+ call GBFadeOutToBlack
.notRockTunnel
call PlayMapChangeSound
jr .done
@@ -496,16 +498,16 @@
jr z,.goBackOutside
; if not going back to the previous map
ld [W_CURMAP],a ; current map number
- callba Func_70787 ; check if the warp was a Silph Co. teleporter
+ callba IsPlayerStandingOnWarpPadOrHole
ld a,[wcd5b]
- dec a
- jr nz,.notTeleporter
-; if it's a Silph Co. teleporter
+ dec a ; is the player on a warp pad?
+ jr nz,.notWarpPad
+; if the player is on a warp pad
ld hl,wd732
set 3,[hl]
call LeaveMapAnim
jr .skipMapChangeSound
-.notTeleporter
+.notWarpPad
call PlayMapChangeSound
.skipMapChangeSound
ld hl,wd736
@@ -517,7 +519,7 @@
ld [W_CURMAP],a
call PlayMapChangeSound
xor a
- ld [wd35d],a
+ ld [wMapPalOffset],a
.done
ld hl,wd736
set 0,[hl] ; have the player's sprite step out from the door (if there is one)
@@ -562,9 +564,9 @@
jr nz,.pointerAdjustmentLoop1
.savePointer1
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkEastMap
ld b,a
@@ -598,9 +600,9 @@
jr nz,.pointerAdjustmentLoop2
.savePointer2
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkNorthMap
ld a,[W_YCOORD]
@@ -624,9 +626,9 @@
srl c
add hl,bc
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkSouthMap
ld b,a
@@ -651,9 +653,9 @@
srl c
add hl,bc
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
.loadNewMap ; load the connected map that was entered
call LoadMapHeader
call Func_2312 ; music
@@ -678,10 +680,10 @@
ld a,(SFX_02_5c - SFX_Headers_02) / 3
.playSound
call PlaySound
- ld a,[wd35d]
+ ld a,[wMapPalOffset]
and a
ret nz
- jp GBFadeIn1
+ jp GBFadeOutToBlack
CheckIfInOutsideMap:: ; 08e1 (0:08e1)
; If the player is in an outside map (a town or route), set the z flag
@@ -719,19 +721,19 @@
cp PLATEAU ; Indigo Plateau tileset
jr z, .useFunction2
.useFunction1
- ld hl, Func_c3ff
+ ld hl, IsPlayerFacingEdgeOfMap
jr .doBankswitch
.useFunction2
- ld hl, Func_c44e
+ ld hl, IsWarpTileInFrontOfPlayer
.doBankswitch
- ld b, BANK(Func_c44e)
+ ld b, BANK(IsWarpTileInFrontOfPlayer)
jp Bankswitch
MapEntryAfterBattle:: ; 091f (0:091f)
- callba Func_c35f ; function that appears to disable warp testing after collisions if the player is standing on a warp
- ld a,[wd35d]
+ callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions
+ ld a,[wMapPalOffset]
and a
- jp z,GBFadeIn2
+ jp z,GBFadeInFromWhite
jp LoadGBPal
HandleBlackOut::
@@ -738,18 +740,18 @@
; For when all the player's pokemon faint.
; Does not print the "blacked out" message.
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $08
call StopMusic
ld hl, wd72e
res 5, [hl]
- ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f)
+ ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap)
ld [H_LOADEDROMBANK], a
ld [MBC3RomBank], a
- call Func_40b0
- call Func_62ce
+ call ResetStatusAndHalveMoneyOnBlackout
+ call SpecialWarpIn
call Func_2312
- jp Func_5d5f
+ jp SpecialEnterMap
StopMusic::
ld [wMusicHeaderPointer], a
@@ -762,23 +764,23 @@
jr nz, .wait
jp StopAllSounds
-HandleFlyOrTeleportAway::
+HandleFlyWarpOrDungeonWarp::
call UpdateSprites
call Delay3
xor a
ld [wBattleResult], a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld [W_ISINBATTLE], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld hl, wd732
- set 2, [hl]
- res 5, [hl]
+ set 2, [hl] ; fly warp or dungeon warp
+ res 5, [hl] ; forced to ride bike
call LeaveMapAnim
- ld a, Bank(Func_62ce)
+ ld a, Bank(SpecialWarpIn)
ld [H_LOADEDROMBANK], a
ld [$2000], a
- call Func_62ce
- jp Func_5d5f
+ call SpecialWarpIn
+ jp SpecialEnterMap
LeaveMapAnim::
ld b, BANK(_LeaveMapAnim)
@@ -792,7 +794,7 @@
; 1: biking
; 2: surfing
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
dec a
jr z, .ridingBike
@@ -809,12 +811,12 @@
.startWalking
xor a
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp LoadWalkingPlayerSpriteGraphics
.determineGraphics
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jp z, LoadWalkingPlayerSpriteGraphics
dec a
@@ -1065,7 +1067,7 @@
and a
jr z,.extendRangeOverCounter
; if there are signs
- predef Func_c586 ; get the coordinates in front of the player in de
+ predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de
ld hl,wd4b1 ; start of sign coordinates
ld a,[wd4b0] ; number of signs in the map
ld b,a
@@ -1099,7 +1101,7 @@
jr nz,.signLoop
; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC
.extendRangeOverCounter
- predef Func_c586 ; get the tile in front of the player in c
+ predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c
ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles)
ld b,$03
ld d,$20 ; talking range in pixels (long range)
@@ -1239,8 +1241,8 @@
; function that checks if the tile in front of the player is passable
; clears carry if it is, sets carry if not
CheckTilePassable:: ; 0c10 (0:0c10)
- predef Func_c586 ; get tile in front of player
- ld a,[wcfc6] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
+ ld a,[wTileInFrontOfPlayer] ; tile in front of player
ld c,a
ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles
ld a,[hli]
@@ -1263,7 +1265,7 @@
; sets carry if there is a collision and unsets carry if not
CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a)
push hl
- predef Func_c586 ; get the tile in front of the player
+ predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player
push de
push bc
callba HandleLedges ; check if the player is trying to jump a ledge
@@ -1276,12 +1278,12 @@
ret nz
; if not jumping
-Func_c44:: ; 0c44 (0:0c44)
+CheckForTilePairCollisions2:: ; 0c44 (0:0c44)
aCoord 8, 9 ; tile the player is on
ld [wcf0e],a
CheckForTilePairCollisions:: ; 0c4a (0:0c4a)
- ld a,[wcfc6] ; tile in front of the player
+ ld a,[wTileInFrontOfPlayer]
ld c,a
.tilePairCollisionLoop
ld a,[W_CURMAPTILESET] ; tileset number
@@ -1357,9 +1359,9 @@
ld a,[W_TILESETBANK] ; tile data ROM bank
ld [H_LOADEDROMBANK],a
ld [$2000],a ; switch to ROM bank that contains tile data
- ld a,[wd35f] ; address of upper left corner of current map view
+ ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
ld e,a
- ld a,[wd360]
+ ld a,[wCurrentTileBlockMapViewPointer + 1]
ld d,a
ld hl,wTileMapBackup
ld b,$05
@@ -1531,9 +1533,9 @@
; moved into the tile block to the east
xor a
ld [hl],a
- ld hl,wd4e3
+ ld hl,wXOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerEast
jr .updateMapView
.checkForMoveToWestBlock
@@ -1542,9 +1544,9 @@
; moved into the tile block to the west
ld a,$01
ld [hl],a
- ld hl,wd4e3
+ ld hl,wXOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerWest
jr .updateMapView
.adjustYCoordWithinBlock
@@ -1557,9 +1559,9 @@
; moved into the tile block to the south
xor a
ld [hl],a
- ld hl,wd4e2
+ ld hl,wYOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
ld a,[W_CURMAPWIDTH]
call MoveTileBlockMapPointerSouth
jr .updateMapView
@@ -1569,9 +1571,9 @@
; moved into the tile block to the north
ld a,$01
ld [hl],a
- ld hl,wd4e2
+ ld hl,wYOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
ld a,[W_CURMAPWIDTH]
call MoveTileBlockMapPointerNorth
.updateMapView
@@ -1905,8 +1907,8 @@
ld hl,TilePairCollisionsWater
call CheckForJumpingAndTilePairCollisions
jr c,.collision
- predef Func_c586 ; get tile in front of player (puts it in c and [wcfc6])
- ld a,[wcfc6] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player (puts it in c and [wTileInFrontOfPlayer])
+ ld a,[wTileInFrontOfPlayer] ; tile in front of player
cp a,$14 ; water tile
jr z,.noCollision ; keep surfing if it's a water tile
cp a,$32 ; either the left tile of the S.S. Anne boarding platform or the tile on eastern coastlines (depending on the current tileset)
@@ -1941,7 +1943,7 @@
ret
.stopSurfing
xor a
- ld [wd700],a
+ ld [wWalkBikeSurfState],a
call LoadPlayerSpriteGraphics
call PlayDefaultMusic
jr .noCollision
@@ -2089,12 +2091,12 @@
ld a,[hli]
ld [de],a ; save background tile ID
.loadWarpData
- ld a,[hli] ; number of warps
- ld [wd3ae],a ; save the number of warps
- and a ; are there any warps?
- jr z,.loadSignData ; if not, skip this
+ ld a,[hli]
+ ld [wNumberOfWarps],a
+ and a
+ jr z,.loadSignData
ld c,a
- ld de,wd3af ; base address of warps
+ ld de,wWarpEntries
.warpLoop ; one warp per loop iteration
ld b,$04
.warpInnerLoop
@@ -2258,8 +2260,8 @@
dec b
jp nz,.loadSpriteLoop
.finishUp
- predef Func_c754 ; load tileset data
- callab LoadWildData ; load wild pokemon data
+ predef LoadTilesetHeader
+ callab LoadWildData
pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose)
ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks
add a ; double it
@@ -2312,7 +2314,7 @@
ld [$ffae],a
ld [wWalkCounter],a
ld [wd119],a
- ld [wd11a],a
+ ld [wWalkBikeSurfStateCopy],a
ld [W_SPRITESETID],a
call LoadTextBoxTilePatterns
call LoadMapHeader
@@ -2341,13 +2343,13 @@
dec b
jr nz,.vramCopyLoop
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call EnableLCD
ld b,$09
call GoPAL_SET
call LoadPlayerSpriteGraphics
ld a,[wd732]
- and a,$18 ; did the player fly or teleport in?
+ and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
jr nz,.restoreRomBank
ld a,[W_FLAGS_D733]
bit 1,a
--- a/home/predef.asm
+++ b/home/predef.asm
@@ -7,7 +7,7 @@
ld [wPredefID], a
; A hack for LoadDestinationWarpPosition.
- ; See Func_c754 (predef $19).
+ ; See LoadTilesetHeader (predef $19).
ld a, [H_LOADEDROMBANK]
ld [wPredefParentBank], a
--- a/main.asm
+++ b/main.asm
@@ -19,13 +19,13 @@
INCLUDE "data/facing.asm"
-Func_40b0::
+ResetStatusAndHalveMoneyOnBlackout::
; Reset player status on blackout.
xor a
ld [wBattleResult], a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld [W_ISINBATTLE], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld [wNPCMovementScriptFunctionNum], a
ld [hJoyHeld], a
ld [wNPCMovementScriptPointerTableNum], a
@@ -578,7 +578,7 @@
; When the battle ends,
; do it all again.
ld a, 1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [H_AUTOBGTRANSFERENABLED], a
jr .loop
@@ -597,19 +597,20 @@
INCLUDE "engine/oak_speech.asm"
-Func_62ce: ; 62ce (1:62ce)
- call Func_62ff
- predef Func_c754
+SpecialWarpIn: ; 62ce (1:62ce)
+ call LoadSpecialWarpData
+ predef LoadTilesetHeader
ld hl,wd732
- bit 2,[hl]
+ bit 2,[hl] ; dungeon warp or fly warp?
res 2,[hl]
jr z,.next
- ld a,[wd71a]
+; if dungeon warp or fly warp
+ ld a,[wDestinationMap]
jr .next2
.next
bit 1,[hl]
jr z,.next3
- call Func_64ea
+ call EmptyFunc
.next3
ld a,0
.next2
@@ -620,125 +621,128 @@
ld a,b
.next4
ld hl,wd732
- bit 4,[hl]
+ bit 4,[hl] ; dungeon warp?
ret nz
+; if not dungeon warp
ld [wLastMap],a
ret
-Func_62ff: ; 62ff (1:62ff)
+; gets the map ID, tile block map view pointer, tileset, and coordinates
+LoadSpecialWarpData: ; 62ff (1:62ff)
ld a, [wd72d]
cp BATTLE_CENTER
- jr nz, .asm_6314
- ld hl, BattleCenterSpec1 ; $6428
+ jr nz, .notBattleCenter
+ ld hl, BattleCenterSpec1
ld a, [$ffaa]
cp $2
- jr z, .asm_6334
- ld hl, BattleCenterSpec2 ; $6430
- jr .asm_6334
-.asm_6314
+ jr z, .copyWarpData
+ ld hl, BattleCenterSpec2
+ jr .copyWarpData
+.notBattleCenter
cp TRADE_CENTER
- jr nz, .asm_6326
- ld hl, TradeCenterSpec1 ; $6438
+ jr nz, .notTradeCenter
+ ld hl, TradeCenterSpec1
ld a, [$ffaa]
cp $2
- jr z, .asm_6334
- ld hl, TradeCenterSpec2 ; $6440
- jr .asm_6334
-.asm_6326
+ jr z, .copyWarpData
+ ld hl, TradeCenterSpec2
+ jr .copyWarpData
+.notTradeCenter
ld a, [wd732]
bit 1, a
- jr nz, .asm_6346
+ jr nz, .notFirstMap
bit 2, a
- jr nz, .asm_6346
- ld hl, FirstMapSpec ; $6420
-.asm_6334
- ld de, W_CURMAP ; W_CURMAP
+ jr nz, .notFirstMap
+ ld hl, FirstMapSpec
+.copyWarpData
+ ld de, W_CURMAP
ld c, $7
-.asm_6339
+.copyWarpDataLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_6339
+ jr nz, .copyWarpDataLoop
ld a, [hli]
- ld [W_CURMAPTILESET], a ; W_CURMAPTILESET
+ ld [W_CURMAPTILESET], a
xor a
- jr .asm_63b3
-.asm_6346
+ jr .done
+.notFirstMap
ld a, [wLastMap]
ld hl, wd732
- bit 4, [hl]
- jr nz, .asm_635b
- bit 6, [hl]
+ bit 4, [hl] ; used dungeon warp (jumped down hole/waterfall)?
+ jr nz, .usedDunegonWarp
+ bit 6, [hl] ; return to last pokemon center (or player's house)?
res 6, [hl]
- jr z, .asm_638e
+ jr z, .otherDestination
+; return to last pokemon center or player's house
ld a, [wLastBlackoutMap]
- jr .asm_6391
-.asm_635b
+ jr .usedFlyWarp
+.usedDunegonWarp
ld hl, wd72d
res 4, [hl]
- ld a, [wd71d]
+ ld a, [wDungeonWarpDestinationMap]
ld b, a
- ld [W_CURMAP], a ; W_CURMAP
- ld a, [wd71e]
+ ld [W_CURMAP], a
+ ld a, [wWhichDungeonWarp]
ld c, a
- ld hl, DungeonWarpList ; $63bf
+ ld hl, DungeonWarpList
ld de, $0
ld a, $6
ld [wd12f], a
-.asm_6376
+.dungeonWarpListLoop
ld a, [hli]
cp b
- jr z, .asm_637d
+ jr z, .matchedDungeonWarpDestinationMap
inc hl
- jr .asm_6381
-.asm_637d
+ jr .nextDungeonWarp
+.matchedDungeonWarpDestinationMap
ld a, [hli]
cp c
- jr z, .asm_6388
-.asm_6381
+ jr z, .matchedDungeonWarpID
+.nextDungeonWarp
ld a, [wd12f]
add e
ld e, a
- jr .asm_6376
-.asm_6388
- ld hl, DungeonWarpData ; $63d8
+ jr .dungeonWarpListLoop
+.matchedDungeonWarpID
+ ld hl, DungeonWarpData
add hl, de
- jr .asm_63a4
-.asm_638e
- ld a, [wd71a]
-.asm_6391
+ jr .copyWarpData2
+.otherDestination
+ ld a, [wDestinationMap]
+.usedFlyWarp
ld b, a
- ld [W_CURMAP], a ; W_CURMAP
- ld hl, FlyWarpDataPtr ; $6448
-.asm_6398
+ ld [W_CURMAP], a
+ ld hl, FlyWarpDataPtr
+.flyWarpDataPtrLoop
ld a, [hli]
inc hl
cp b
- jr z, .asm_63a1
+ jr z, .foundFlyWarpMatch
inc hl
inc hl
- jr .asm_6398
-.asm_63a1
+ jr .flyWarpDataPtrLoop
+.foundFlyWarpMatch
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_63a4
- ld de, wd35f
+.copyWarpData2
+ ld de, wCurrentTileBlockMapViewPointer
ld c, $6
-.asm_63a9
+.copyWarpDataLoop2
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_63a9
- xor a
- ld [W_CURMAPTILESET], a ; W_CURMAPTILESET
-.asm_63b3
- ld [wd4e2], a
- ld [wd4e3], a
- ld a, $ff
- ld [wd42f], a
+ jr nz, .copyWarpDataLoop2
+ xor a ; OVERWORLD
+ ld [W_CURMAPTILESET], a
+.done
+ ld [wYOffsetSinceLastSpecialWarp], a
+ ld [wXOffsetSinceLastSpecialWarp], a
+ ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps
+ ld [wDestinationWarpID], a
ret
INCLUDE "data/special_warps.asm"
@@ -774,7 +778,7 @@
db ARTICUNO,57
db $FF
-Func_64ea: ; 64ea (1:64ea)
+EmptyFunc: ; 64ea (1:64ea)
ret
INCLUDE "engine/menu/naming_screen.asm"
@@ -989,7 +993,7 @@
DisplayTextIDInit: ; 7096 (1:7096)
xor a
ld [wListMenuID],a
- ld a,[wcf0c]
+ ld a,[wAutoTextBoxDrawingControl]
bit 0,a
jr nz,.skipDrawingTextBoxBorder
ld a,[$ff8c] ; text ID (or sprite ID)
@@ -2005,7 +2009,7 @@
ld hl, wPokedexSeen
predef FlagActionPredef
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
@@ -2023,7 +2027,7 @@
ld [rWY], a ; $ff4a
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld [wd13b], a
+ ld [wStepCounter], a
ld [W_LONEATTACKNO], a ; W_GYMLEADERNO
ld [hJoyPressed], a
ld [hJoyReleased], a
@@ -2038,36 +2042,37 @@
call FillMemory
ret
-Func_c35f: ; c35f (3:435f)
- ld a, [wd3ae]
+; only used for setting bit 2 of wd736 upon entering a new map
+IsPlayerStandingOnWarp: ; c35f (3:435f)
+ ld a, [wNumberOfWarps]
and a
ret z
ld c, a
- ld hl, wd3af
-.asm_c368
- ld a, [W_YCOORD] ; wd361
+ ld hl, wWarpEntries
+.loop
+ ld a, [W_YCOORD]
cp [hl]
- jr nz, .asm_c383
+ jr nz, .nextWarp1
inc hl
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
cp [hl]
- jr nz, .asm_c384
+ jr nz, .nextWarp2
inc hl
- ld a, [hli]
- ld [wd42f], a
- ld a, [hl]
- ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
+ ld a, [hli] ; target warp
+ ld [wDestinationWarpID], a
+ ld a, [hl] ; target map
+ ld [$ff8b], a
ld hl, wd736
- set 2, [hl]
+ set 2, [hl] ; standing on warp flag
ret
-.asm_c383
+.nextWarp1
inc hl
-.asm_c384
+.nextWarp2
inc hl
inc hl
inc hl
dec c
- jr nz, .asm_c368
+ jr nz, .loop
ret
CheckForceBikeOrSurf: ; c38b (3:438b)
@@ -2107,8 +2112,8 @@
ld hl, wd732
set 5, [hl]
ld a, $1
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
.incorrectMap
inc hl
@@ -2117,30 +2122,30 @@
jr .loop
.forceSurfing
ld a, $2
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
INCLUDE "data/force_bike_surf.asm"
-Func_c3ff: ; c3ff (3:43ff)
+IsPlayerFacingEdgeOfMap: ; c3ff (3:43ff)
push hl
push de
push bc
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
srl a
ld c, a
ld b, $0
- ld hl, PointerTable_c422 ; $4422
+ ld hl, .functionPointerTable
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [W_YCOORD] ; wd361
+ ld a, [W_YCOORD]
ld b, a
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
ld c, a
- ld de, .asm_c41e ; $441e
+ ld de, .asm_c41e
push de
jp [hl]
.asm_c41e
@@ -2149,14 +2154,14 @@
pop hl
ret
-PointerTable_c422: ; c422 (3:4422)
- dw .asm_c42a
- dw .asm_4434
- dw .asm_443A
- dw .asm_4440
+.functionPointerTable
+ dw .facingDown
+ dw .facingUp
+ dw .facingLeft
+ dw .facingRight
-.asm_c42a
- ld a, [W_CURMAPHEIGHT] ; wd368
+.facingDown
+ ld a, [W_CURMAPHEIGHT]
add a
dec a
cp b
@@ -2163,20 +2168,20 @@
jr z, .setCarry
jr .resetCarry
-.asm_4434
+.facingUp
ld a, b
and a
jr z, .setCarry
jr .resetCarry
-.asm_443A
+.facingLeft
ld a, c
and a
jr z, .setCarry
jr .resetCarry
-.asm_4440
- ld a, [W_CURMAPWIDTH] ; wd369
+.facingRight
+ ld a, [W_CURMAPWIDTH]
add a
dec a
cp c
@@ -2189,71 +2194,71 @@
scf
ret
-Func_c44e: ; c44e (3:444e)
+IsWarpTileInFrontOfPlayer: ; c44e (3:444e)
push hl
push de
push bc
- call Func_c589
- ld a, [W_CURMAP] ; W_CURMAP
+ call _GetTileAndCoordsInFrontOfPlayer
+ ld a, [W_CURMAP]
cp SS_ANNE_5
jr z, .ssAnne5
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
srl a
ld c, a
- ld b, $0
- ld hl, .pointerTable_c477 ; $4477
+ ld b, 0
+ ld hl, .warpTileListPointers
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
ld de, $1
call IsInArray
-.asm_c473
+.done
pop bc
pop de
pop hl
ret
-.pointerTable_c477: ; c477 (3:4477)
- dw .arrayData_c47f
- dw .arrayData_c487
- dw .arrayData_c48a
- dw .arrayData_c48d
+.warpTileListPointers: ; c477 (3:4477)
+ dw .facingDownWarpTiles
+ dw .facingUpWarpTiles
+ dw .facingLeftWarpTiles
+ dw .facingRightWarpTiles
-.arrayData_c47f
+.facingDownWarpTiles
db $01,$12,$17,$3D,$04,$18,$33,$FF
-.arrayData_c487
+.facingUpWarpTiles
db $01,$5C,$FF
-.arrayData_c48a
+.facingLeftWarpTiles
db $1A,$4B,$FF
-.arrayData_c48d
+.facingRightWarpTiles
db $0F,$4E,$FF
.ssAnne5
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $15
- jr nz, .asm_c49a
+ jr nz, .notSSAnne5Warp
scf
- jr .asm_c473
-.asm_c49a
+ jr .done
+.notSSAnne5Warp
and a
- jr .asm_c473
+ jr .done
-Func_c49d: ; c49d (3:449d)
+IsPlayerStandingOnDoorTileOrWarpTile: ; c49d (3:449d)
push hl
push de
push bc
- callba IsPlayerStandingOnDoor
- jr c, .asm_c4c8
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ callba IsPlayerStandingOnDoorTile
+ jr c, .done
+ ld a, [W_CURMAPTILESET]
add a
ld c, a
ld b, $0
- ld hl, WarpTileIDPointers ; $44cc
+ ld hl, WarpTileIDPointers
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -2261,10 +2266,10 @@
ld de, $1
aCoord 8, 9
call IsInArray
- jr nc, .asm_c4c8
+ jr nc, .done
ld hl, wd736
res 2, [hl]
-.asm_c4c8
+.done
pop bc
pop de
pop hl
@@ -2310,204 +2315,215 @@
SafariBallText: ; c57e (3:457e)
db "BALL×× @"
-Func_c586: ; c586 (3:4586)
+GetTileAndCoordsInFrontOfPlayer: ; c586 (3:4586)
call GetPredefRegisters
-Func_c589: ; c589 (3:4589)
- ld a, [W_YCOORD] ; wd361
+_GetTileAndCoordsInFrontOfPlayer: ; c589 (3:4589)
+ ld a, [W_YCOORD]
ld d, a
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
ld e, a
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
and a
- jr nz, .asm_c59d
+ jr nz, .notFacingDown
+; facing down
aCoord 8, 11
inc d
- jr .asm_c5b9
-.asm_c59d
- cp $4
- jr nz, .asm_c5a7
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
aCoord 8, 7
dec d
- jr .asm_c5b9
-.asm_c5a7
- cp $8
- jr nz, .asm_c5b1
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
aCoord 6, 9
dec e
- jr .asm_c5b9
-.asm_c5b1
- cp $c
- jr nz, .asm_c5b9
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
aCoord 10, 9
inc e
-.asm_c5b9
+.storeTile
ld c, a
- ld [wcfc6], a
+ ld [wTileInFrontOfPlayer], a
ret
-Func_c5be: ; c5be (3:45be)
+GetTileTwoStepsInFrontOfPlayer: ; c5be (3:45be)
xor a
ld [$ffdb], a
- ld hl, W_YCOORD ; wd361
+ ld hl, W_YCOORD
ld a, [hli]
ld d, a
ld e, [hl]
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
and a
- jr nz, .asm_c5d8
+ jr nz, .notFacingDown
+; facing down
ld hl, $ffdb
set 0, [hl]
aCoord 8, 13
inc d
- jr .asm_c603
-.asm_c5d8
- cp $4
- jr nz, .asm_c5e7
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
ld hl, $ffdb
set 1, [hl]
aCoord 8, 5
dec d
- jr .asm_c603
-.asm_c5e7
- cp $8
- jr nz, .asm_c5f6
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
ld hl, $ffdb
set 2, [hl]
aCoord 4, 9
dec e
- jr .asm_c603
-.asm_c5f6
- cp $c
- jr nz, .asm_c603
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
ld hl, $ffdb
set 3, [hl]
aCoord 12, 9
inc e
-.asm_c603
+.storeTile
ld c, a
- ld [wd71c], a
- ld [wcfc6], a
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
+ ld [wTileInFrontOfPlayer], a
ret
-Func_c60b: ; c60b (3:460b)
- call Func_c5be
+CheckForCollisionWhenPushingBoulder: ; c60b (3:460b)
+ call GetTileTwoStepsInFrontOfPlayer
ld hl, W_TILESETCOLLISIONPTR
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_c614
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_c632
+ jr z, .done ; if the tile two steps ahead is not passable
cp c
- jr nz, .asm_c614
- ld hl, $c7e
- call Func_c44
+ jr nz, .loop
+ ld hl, TilePairCollisionsLand
+ call CheckForTilePairCollisions2
ld a, $ff
- jr c, .asm_c632
- ld a, [wd71c]
- cp $15
+ jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead
+ ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
+ cp $15 ; stairs tile
ld a, $ff
- jr z, .asm_c632
- call Func_c636
-.asm_c632
- ld [wd71c], a
+ jr z, .done ; if the tile two steps ahead is stairs
+ call CheckForBoulderCollisionWithSprites
+.done
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
ret
-Func_c636: ; c636 (3:4636)
- ld a, [wd718]
+; sets a to $ff if there is a collision and $00 if there is no collision
+CheckForBoulderCollisionWithSprites: ; c636 (3:4636)
+ ld a, [wBoulderSpriteIndex]
dec a
swap a
- ld d, $0
+ ld d, 0
ld e, a
ld hl, wSpriteStateData2 + $14
add hl, de
- ld a, [hli]
+ ld a, [hli] ; map Y position
ld [$ffdc], a
- ld a, [hl]
+ ld a, [hl] ; map X position
ld [$ffdd], a
- ld a, [W_NUMSPRITES] ; W_NUMSPRITES
+ ld a, [W_NUMSPRITES]
ld c, a
ld de, $f
ld hl, wSpriteStateData2 + $14
ld a, [$ffdb]
- and $3
- jr z, .asm_c678
-.asm_c659
+ and $3 ; facing up or down?
+ jr z, .pushingHorizontallyLoop
+.pushingVerticallyLoop
inc hl
ld a, [$ffdd]
cp [hl]
- jr nz, .asm_c672
+ jr nz, .nextSprite1 ; if X coordinates don't match
dec hl
ld a, [hli]
ld b, a
ld a, [$ffdb]
rrca
- jr c, .asm_c66c
+ jr c, .pushingDown
+; pushing up
ld a, [$ffdc]
dec a
- jr .asm_c66f
-.asm_c66c
+ jr .compareYCoords
+.pushingDown
ld a, [$ffdc]
inc a
-.asm_c66f
+.compareYCoords
cp b
- jr z, .asm_c697
-.asm_c672
+ jr z, .failure
+.nextSprite1
dec c
- jr z, .asm_c69a
+ jr z, .success
add hl, de
- jr .asm_c659
-.asm_c678
+ jr .pushingVerticallyLoop
+.pushingHorizontallyLoop
ld a, [hli]
ld b, a
ld a, [$ffdc]
cp b
- jr nz, .asm_c691
+ jr nz, .nextSprite2
ld b, [hl]
ld a, [$ffdb]
bit 2, a
- jr nz, .asm_c68b
+ jr nz, .pushingLeft
+; pushing right
ld a, [$ffdd]
inc a
- jr .asm_c68e
-.asm_c68b
+ jr .compareXCoords
+.pushingLeft
ld a, [$ffdd]
dec a
-.asm_c68e
+.compareXCoords
cp b
- jr z, .asm_c697
-.asm_c691
+ jr z, .failure
+.nextSprite2
dec c
- jr z, .asm_c69a
+ jr z, .success
add hl, de
- jr .asm_c678
-.asm_c697
+ jr .pushingHorizontallyLoop
+.failure
ld a, $ff
ret
-.asm_c69a
+.success
xor a
ret
-Func_c69c: ; c69c (3:469c)
+ApplyOutOfBattlePoisonDamage: ; c69c (3:469c)
ld a, [wd730]
add a
- jp c, .asm_c74f
- ld a, [wPartyCount] ; wPartyCount
+ jp c, .noBlackOut
+ ld a, [wPartyCount]
and a
- jp z, .asm_c74f
- call Func_c8de
- ld a, [wd13b]
- and $3
- jp nz, .asm_c74f
- ld [wWhichPokemon], a ; wWhichPokemon
- ld hl, wPartyMon1Status ; wPartyMon1Status
- ld de, wPartySpecies ; wPartySpecies
-.asm_c6be
+ jp z, .noBlackOut
+ call IncrementDayCareMonExp
+ ld a, [wStepCounter]
+ and $3 ; is the counter a multiple of 4?
+ jp nz, .noBlackOut ; only apply poison damage every fourth step
+ ld [wWhichPokemon], a
+ ld hl, wPartyMon1Status
+ ld de, wPartySpecies
+.applyDamageLoop
ld a, [hl]
- and $8
- jr z, .asm_c6fd
+ and (1 << PSN)
+ jr z, .nextMon2 ; not poisoned
dec hl
dec hl
ld a, [hld]
@@ -2514,19 +2530,22 @@
ld b, a
ld a, [hli]
or b
- jr z, .asm_c6fb
+ jr z, .nextMon ; already fainted
+; subtract 1 from HP
ld a, [hl]
dec a
ld [hld], a
inc a
- jr nz, .asm_c6d5
+ jr nz, .noBorrow
+; borrow 1 from upper byte of HP
dec [hl]
inc hl
- jr .asm_c6fb
-.asm_c6d5
+ jr .nextMon
+.noBorrow
ld a, [hli]
or [hl]
- jr nz, .asm_c6fb
+ jr nz, .nextMon ; didn't faint from damage
+; the mon fainted from the damage
push hl
inc hl
inc hl
@@ -2534,127 +2553,127 @@
ld a, [de]
ld [wd11e], a
push de
- ld a, [wWhichPokemon] ; wWhichPokemon
- ld hl, wPartyMonNicks ; wPartyMonNicks
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
xor a
ld [wJoyIgnore], a
call EnableAutoTextBoxDrawing
ld a, $d0
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [$ff8c], a
call DisplayTextID
pop de
pop hl
-.asm_c6fb
+.nextMon
inc hl
inc hl
-.asm_c6fd
+.nextMon2
inc de
ld a, [de]
inc a
- jr z, .asm_c70e
- ld bc, $2c
+ jr z, .applyDamageLoopDone
+ ld bc, wPartyMon2 - wPartyMon1
add hl, bc
push hl
- ld hl, wWhichPokemon ; wWhichPokemon
+ ld hl, wWhichPokemon
inc [hl]
pop hl
- jr .asm_c6be
-.asm_c70e
- ld hl, wPartyMon1Status ; wPartyMon1Status
- ld a, [wPartyCount] ; wPartyCount
+ jr .applyDamageLoop
+.applyDamageLoopDone
+ ld hl, wPartyMon1Status
+ ld a, [wPartyCount]
ld d, a
- ld e, $0
-.asm_c717
+ ld e, 0
+.countPoisonedLoop
ld a, [hl]
- and $8
+ and (1 << PSN)
or e
ld e, a
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
add hl, bc
dec d
- jr nz, .asm_c717
+ jr nz, .countPoisonedLoop
ld a, e
- and a
- jr z, .asm_c733
+ and a ; are any party members poisoned?
+ jr z, .skipPoisonEffectAndSound
ld b, $2
- predef Func_480eb
+ predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames
ld a, (SFX_02_43 - SFX_Headers_02) / 3
call PlaySound
-.asm_c733
+.skipPoisonEffectAndSound
predef AnyPartyAlive
ld a, d
and a
- jr nz, .asm_c74f
+ jr nz, .noBlackOut
call EnableAutoTextBoxDrawing
ld a, $d1
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [$ff8c], a
call DisplayTextID
ld hl, wd72e
set 5, [hl]
ld a, $ff
- jr .asm_c750
-.asm_c74f
+ jr .done
+.noBlackOut
xor a
-.asm_c750
+.done
ld [wd12d], a
ret
-Func_c754: ; c754 (3:4754)
+LoadTilesetHeader: ; c754 (3:4754)
call GetPredefRegisters
push hl
- ld d, $0
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld d, 0
+ ld a, [W_CURMAPTILESET]
add a
add a
ld b, a
add a
- add b
- jr nc, .asm_c765
+ add b ; a = tileset * 12
+ jr nc, .noCarry
inc d
-.asm_c765
+.noCarry
ld e, a
ld hl, Tilesets
add hl, de
ld de, W_TILESETBANK
ld c, $b
-.asm_c76f
+.copyTilesetHeaderLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_c76f
+ jr nz, .copyTilesetHeaderLoop
ld a, [hl]
ld [$ffd7], a
xor a
ld [$ffd8], a
pop hl
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld a, [W_CURMAPTILESET]
push hl
push de
- ld hl, DungeonTilesets ; $47b2
+ ld hl, DungeonTilesets
ld de, $1
call IsInArray
pop de
pop hl
jr c, .asm_c797
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld a, [W_CURMAPTILESET]
ld b, a
- ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b
+ ld a, [$ff8b]
cp b
- jr z, .asm_c7b1
+ jr z, .done
.asm_c797
- ld a, [wd42f]
+ ld a, [wDestinationWarpID]
cp $ff
- jr z, .asm_c7b1
+ jr z, .done
call LoadDestinationWarpPosition
- ld a, [W_YCOORD] ; wd361
+ ld a, [W_YCOORD]
and $1
- ld [W_YBLOCKCOORD], a ; wd363
- ld a, [W_XCOORD] ; wd362
+ ld [W_YBLOCKCOORD], a
+ ld a, [W_XCOORD]
and $1
- ld [W_XBLOCKCOORD], a ; wd364
-.asm_c7b1
+ ld [W_XBLOCKCOORD], a
+.done
ret
INCLUDE "data/dungeon_tilesets.asm"
@@ -2661,7 +2680,7 @@
INCLUDE "data/tileset_headers.asm"
-Func_c8de: ; c8de (3:48de)
+IncrementDayCareMonExp: ; c8de (3:48de)
ld a, [W_DAYCARE_IN_USE]
and a
ret z
@@ -3073,9 +3092,9 @@
add hl, bc
ld a, [wd09f]
ld [hl], a
- ld a, [wd35f]
+ ld a, [wCurrentTileBlockMapViewPointer]
ld c, a
- ld a, [wd360]
+ ld a, [wCurrentTileBlockMapViewPointer + 1]
ld b, a
call Func_ef4e
ret c
@@ -3399,7 +3418,7 @@
ld [$ff8c], a
call IsSpriteInFrontOfPlayer
ld a, [$ff8c]
- ld [wd718], a
+ ld [wBoulderSpriteIndex], a
and a
jp z, ResetBoulderPushFlags
ld hl, wSpriteStateData1 + 1
@@ -3420,9 +3439,9 @@
ld a, [hJoyHeld]
and $f0
ret z
- predef Func_c60b
- ld a, [wd71c]
- and a
+ predef CheckForCollisionWhenPushingBoulder
+ ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
+ and a ; was there a collision?
jp nz, ResetBoulderPushFlags
ld a, [hJoyHeld]
ld b, a
@@ -3481,8 +3500,8 @@
ld [wJoyIgnore], a
call ResetBoulderPushFlags
set 7, [hl]
- ld a, [wd718]
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld a, [wBoulderSpriteIndex]
+ ld [H_SPRITEINDEX], a
call GetSpriteMovementByte2Pointer
ld [hl], $10
ld a, (SFX_02_56 - SFX_Headers_02) / 3
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -57,7 +57,7 @@
ld a, $f0
ld [wJoyIgnore], a
ld a, $2
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld a, $c
ld [$ffeb], a
ld a, $40
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -236,7 +236,7 @@
ld hl, wd77e
set 2, [hl]
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, Received10CoinsText
jr .asm_c7d1a ; 0x48d87
.asm_d0957 ; 0x48d89
@@ -411,7 +411,7 @@
ld de, CeladonGameCornerText_48ed3
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
@@ -437,7 +437,7 @@
CeladonGameCornerText12: ; 48edd (12:4edd)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CeladonGameCornerText_48f09
call PrintText
call WaitForSoundToFinish
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -179,7 +179,7 @@
ld de, CeladonGymText_48a63
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $4
--- a/scripts/celadonmansion3.asm
+++ b/scripts/celadonmansion3.asm
@@ -51,7 +51,7 @@
db $8 ; asm
callab DisplayDiploma
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
jp TextScriptEnd
GameFreakPCText1: ; 487eb (12:47eb)
--- a/scripts/celadonmartelevator.asm
+++ b/scripts/celadonmartelevator.asm
@@ -9,13 +9,13 @@
res 7, [hl]
call nz, CeladonMartElevatorScript_48654
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
CeladonMartElevatorScript_4861c: ; 4861c (12:461c)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
--- a/scripts/celadonmartroof.asm
+++ b/scripts/celadonmartroof.asm
@@ -230,7 +230,7 @@
and a
jr z, .asm_914b9 ; 0x48574
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CeladonMartRoofText4
call PrintText
call YesNoChoice
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -64,7 +64,7 @@
ld hl, CeruleanCityCoords2
call ArePlayerCoordsInArray
ret nc
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_19512 ; 0x19508 $8
ld a, $ff
@@ -279,7 +279,7 @@
ld de, CeruleanCityText_196ee
call PreBattleSaveRegisters
ld a, [$ff8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $4
@@ -296,7 +296,7 @@
jr .Done
.Success
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, ReceivedTM28Text
call PrintText
callba Func_74872
--- a/scripts/ceruleancity2.asm
+++ b/scripts/ceruleancity2.asm
@@ -2,7 +2,7 @@
; code similar to this appears in a lot of banks; this particular
; one is called after you beat the Rocket that gives you TM28 DIG.
; the screen then fades out, he disappears, and fades back in
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $07
ld [wcc4d], a
predef ShowObject
@@ -12,5 +12,5 @@
ld a, $06
ld [wcc4d], a
predef HideObject
- call GBFadeOut1
+ call GBFadeInFromBlack
ret
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -128,7 +128,7 @@
ld de, CeruleanGymText_5c7d8
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $2
--- a/scripts/ceruleanhouse2.asm
+++ b/scripts/ceruleanhouse2.asm
@@ -1,8 +1,8 @@
CeruleanHouse2Script: ; 74e09 (1d:4e09)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
dec a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
CeruleanHouse2TextPointers: ; 74e13 (1d:4e13)
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -187,13 +187,13 @@
CinnabarGymScript_758b7: ; 758b7 (1d:58b7)
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld hl, wd72d
set 6, [hl]
set 7, [hl]
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $1
jr z, .asm_758d4
ld a, $2
--- a/scripts/copycatshouse2f.asm
+++ b/scripts/copycatshouse2f.asm
@@ -16,7 +16,7 @@
bit 0, a
jr nz, .asm_7ccf3 ; 0x5cc88
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CopycatsHouse2FText_5ccd4
call PrintText
ld b, POKE_DOLL
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -24,7 +24,7 @@
ld hl, DayCareMText_56414
call PrintText
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wd07d], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -149,7 +149,7 @@
ld de, FightingDojoText_5ce93
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -168,7 +168,7 @@
ld de, UnnamedText_75586
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $5
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -106,7 +106,7 @@
and a
jr nz, .asm_4438c ; 0x44368 $22
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd126
set 5, [hl]
ld hl, MansionSwitchPressedText
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -112,7 +112,7 @@
and a
jr nz, .asm_520b9 ; 0x52095 $22
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd126
set 5, [hl]
ld hl, Mansion2Text_520c7
--- a/scripts/mansion3.asm
+++ b/scripts/mansion3.asm
@@ -40,7 +40,7 @@
Mansion3Script0: ; 5223b (14:623b)
ld hl, CoordsData_52254
call Mansion3Script_5225b
- ld a, [wd71e]
+ ld a, [wWhichDungeonWarp]
and a
jp z, CheckFightingMapTrainers
cp $3
@@ -48,7 +48,7 @@
jr nz, .asm_52250
ld a, $d6
.asm_52250
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ret
CoordsData_52254: ; 52254 (14:6254)
@@ -59,7 +59,7 @@
Mansion3Script_5225b: ; 5225b (14:625b)
xor a
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld a, [wd72d]
bit 4, a
ret nz
@@ -66,7 +66,7 @@
call ArePlayerCoordsInArray
ret nc
ld a, [wWhichTrade] ; wWhichTrade
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
ld hl, wd732
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -138,7 +138,7 @@
ld a, $f0
ld [wJoyIgnore], a
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $a
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
@@ -230,7 +230,7 @@
ld de, MtMoon3Text_49f8a
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
@@ -270,7 +270,7 @@
MtMoon3Text6: ; 49ee9 (12:5ee9)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, MtMoon3Text_49f24
call PrintText
call YesNoChoice
@@ -299,7 +299,7 @@
MtMoon3Text7: ; 49f29 (12:5f29)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, MtMoon3Text_49f64
call PrintText
call YesNoChoice
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -1,8 +1,8 @@
Museum1FScript: ; 5c0f7 (17:40f7)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, Museum1FScriptPointers
ld a, [W_MUSEUM1FCURSCRIPT]
jp CallFunctionInTable
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -50,7 +50,7 @@
call PrintText
xor a
ld [wd07d], a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
push af
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -3,9 +3,9 @@
bit 6, a
call nz, OaksLabScript_1d076
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, OaksLabScriptPointers
ld a, [W_OAKSLABCURSCRIPT]
jp CallFunctionInTable
@@ -374,7 +374,7 @@
.done
ld [W_TRAINERNO], a
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition1
ld hl, OaksLabText_1d3be
ld de, OaksLabText_1d3c3
@@ -397,7 +397,7 @@
ld [wd528], a
call UpdateSprites
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $1
ld [H_SPRITEINDEX], a
@@ -680,7 +680,7 @@
ld a, b
ld [$ffed], a
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ret
@@ -801,7 +801,7 @@
ld [wcf91], a
ld [wd11e], a
ld a, b
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld a, [wd74b]
bit 2, a
jp nz, OaksLabScript_1d22d
@@ -837,7 +837,7 @@
call ReloadMapData
ld c, $a
call DelayFrames
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $2
jr z, OaksLabLookAtCharmander
cp $3
@@ -868,7 +868,7 @@
OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3)
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call YesNoChoice ; yes/no menu
ld a, [wCurrentMenuItem]
and a
@@ -877,7 +877,7 @@
ld [W_PLAYERSTARTER], a
ld [wd11e], a
call GetMonName
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $2
jr nz, asm_1d1db ; 0x1d1d5 $4
ld a, $2b
@@ -893,7 +893,7 @@
ld [wcc4d], a
predef HideObject
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, OaksLabMonEnergeticText
call PrintText
ld hl, OaksLabReceivedMonText
@@ -956,7 +956,7 @@
ld hl, OaksLabText_1d31d
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
predef DisplayDexRating
jp .asm_0f042
.asm_b28b0 ; 0x1d279
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -109,7 +109,7 @@
ld a,$FF
ld [wJoyIgnore],a
ld a,1
- ld [wcf13],a
+ ld [wSpriteIndex],a
xor a
ld [wNPCMovementScriptFunctionNum],a
ld a,1
@@ -171,7 +171,7 @@
and a
jr nz,.next
ld a,1
- ld [wcc3c],a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a
ld hl,OakAppearsText
jr .done
.next
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -68,7 +68,7 @@
ld a, $11
ld [$ffee], a
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $3
ld [$ff8c], a
@@ -94,7 +94,7 @@
PewterCityScript3: ; 192e9 (6:52e9)
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition2
ld a, $3
ld [wcc4d], a
@@ -132,7 +132,7 @@
ld a, $10
ld [$ffee], a
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $5
ld [$ff8c], a
@@ -158,7 +158,7 @@
PewterCityScript6: ; 1936f (6:536f)
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition2
ld a, $4
ld [wcc4d], a
@@ -216,7 +216,7 @@
ldh a, [$b8]
ld [wNPCMovementScriptBank], a
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition2
ld a, $1
ld [W_PEWTERCITYCURSCRIPT], a
@@ -280,7 +280,7 @@
ldh a, [$b8]
ld [wNPCMovementScriptBank], a
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition2
ld a, $4
ld [W_PEWTERCITYCURSCRIPT], a
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -128,7 +128,7 @@
ld de, PewterGymText_5c4bc
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $1
--- a/scripts/pewtermart.asm
+++ b/scripts/pewtermart.asm
@@ -1,7 +1,7 @@
PewterMartScript: ; 74cad (1d:4cad)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ret
PewterMartTextPointers: ; 74cb6 (1d:4cb6)
--- a/scripts/pewterpokecenter.asm
+++ b/scripts/pewterpokecenter.asm
@@ -18,7 +18,7 @@
PewterPokecenterText3: ; 5c59b (17:459b)
db $8
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, PewterPokecenterText5
call PrintText
ld a, $ff
--- a/scripts/pokemontower5.asm
+++ b/scripts/pokemontower5.asm
@@ -33,10 +33,10 @@
ld hl, wd72e
set 4, [hl]
predef HealParty
- call GBFadeOut2
+ call GBFadeOutToWhite
call Delay3
call Delay3
- call GBFadeIn2
+ call GBFadeInFromWhite
ld a, $7
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -30,7 +30,7 @@
call EndTrainerBattle
ld a, $f0
ld [wJoyIgnore], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
call PokemonTower7Script_60db6
@@ -44,7 +44,7 @@
bit 0, a
ret nz
ld hl, W_MISSABLEOBJECTLIST
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld b, a
.missableObjectsListLoop
ld a, [hli]
@@ -55,7 +55,7 @@
predef HideObject
xor a
ld [wJoyIgnore], a
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld [wTrainerHeaderFlagBit], a
ld [wda38], a
ld a, $0
@@ -74,7 +74,7 @@
ld a, $95
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
ld a, $1
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ld a, LAVENDER_TOWN
ld [wLastMap], a
ld hl, wd72d
@@ -86,7 +86,7 @@
PokemonTower7Script_60db6: ; 60db6 (18:4db6)
ld hl, CoordsData_60de3 ; $4de3
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
dec a
swap a
ld d, $0
@@ -106,7 +106,7 @@
ld a, [hli]
ld d, [hl]
ld e, a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
jp MoveSprite
.asm_60dde
--- a/scripts/redshouse1f.asm
+++ b/scripts/redshouse1f.asm
@@ -25,7 +25,7 @@
MomHealPokemon: ; 4818a (12:418a)
ld hl, MomHealText1
call PrintText
- call GBFadeOut2
+ call GBFadeOutToWhite
call ReloadMapData
predef HealParty
ld a, MUSIC_PKMN_HEALED
@@ -38,7 +38,7 @@
ld a, [wd35b]
ld [wc0ee], a
call PlaySound
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, MomHealText2
jp PrintText
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -58,7 +58,7 @@
ld a, $a
ld [H_SPRITEHEIGHT], a
call DisplayTextID
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $83
ld [wcc4d], a
predef HideObject
@@ -66,7 +66,7 @@
ld [wcc4d], a
predef ShowObject
call UpdateSprites
- call GBFadeOut1
+ call GBFadeInFromBlack
xor a
ld [wJoyIgnore], a
ld hl, wd126
@@ -132,7 +132,7 @@
ld de, RocketHideout4Text_4557f
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
--- a/scripts/rockethideoutelevator.asm
+++ b/scripts/rockethideoutelevator.asm
@@ -9,13 +9,13 @@
res 7, [hl]
call nz, RocketHideoutElevatorScript_4575f
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
RocketHideoutElevatorScript_4572c: ; 4572c (11:572c)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
--- a/scripts/route12gateupstairs.asm
+++ b/scripts/route12gateupstairs.asm
@@ -75,5 +75,5 @@
call PrintText
xor a
.asm_495d8
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
jp TextScriptEnd
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -83,7 +83,7 @@
xor a
ld [wcd50], a
predef EmotionBubble
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_50f4e ; 0x50f44 $8
ld a, $ff
@@ -222,7 +222,7 @@
xor a
ld [wcd50], a
predef EmotionBubble
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .skipYVisibilityTesta
ld a, $ff
--- a/scripts/route24.asm
+++ b/scripts/route24.asm
@@ -171,7 +171,7 @@
ld de, Route24Text_5152b
call PreBattleSaveRegisters
ld a, [$ff8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -180,7 +180,7 @@
ld de, SaffronGymText_5d167
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $6
--- a/scripts/seafoamislands1.asm
+++ b/scripts/seafoamislands1.asm
@@ -34,7 +34,7 @@
predef_jump ShowObject
.asm_4483b
ld a, $9f
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam1HolesCoords
jp Func_46981
--- a/scripts/seafoamislands2.asm
+++ b/scripts/seafoamislands2.asm
@@ -32,7 +32,7 @@
predef_jump ShowObject
.asm_46362
ld a, $a0
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam2HolesCoords
jp Func_46981
--- a/scripts/seafoamislands3.asm
+++ b/scripts/seafoamislands3.asm
@@ -32,7 +32,7 @@
predef_jump ShowObject
.asm_4649e
ld a, $a1
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam3HolesCoords
jp Func_46981
--- a/scripts/seafoamislands4.asm
+++ b/scripts/seafoamislands4.asm
@@ -33,7 +33,7 @@
jr .asm_465ed ; 0x465da $11
.asm_465dc
ld a, $a2
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam4HolesCoords
call Func_46981
ld a, [wd732]
--- a/scripts/seafoamislands5.asm
+++ b/scripts/seafoamislands5.asm
@@ -130,8 +130,8 @@
SeaFoamIslands5Script_46872: ; 46872 (11:6872)
xor a
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
SeafoamIslands5TextPointers: ; 4687c (11:687c)
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -182,11 +182,11 @@
ld a, $6
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
- call GBFadeIn1
+ call GBFadeOutToBlack
call SilphCo11Script_6216d
call UpdateSprites
call Delay3
- call GBFadeOut1
+ call GBFadeInFromBlack
ld hl, wd838
set 7, [hl]
xor a
@@ -223,7 +223,7 @@
ld de, SilphCo10Text_62330 ; $6330
call PreBattleSaveRegisters
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -164,9 +164,9 @@
ld hl, SilphCo9Text_5d8e5
call PrintText
predef HealParty
- call GBFadeOut2
+ call GBFadeOutToWhite
call Delay3
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, SilphCo9Text_5d8ea
call PrintText
jr .asm_b6e28 ; 0x5d8da
--- a/scripts/silphcoelevator.asm
+++ b/scripts/silphcoelevator.asm
@@ -9,13 +9,13 @@
res 7, [hl]
call nz, SilphCoElevatorScript_45827
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
SilphCoElevatorScript_457dc: ; 457dc (11:57dc)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
--- a/scripts/ssanne9.asm
+++ b/scripts/ssanne9.asm
@@ -1,8 +1,8 @@
SSAnne9Script: ; 61b4b (18:5b4b)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, SSAnne9TrainerHeaders
ld de, SSAnne9ScriptPointers
ld a, [W_SSANNE9CURSCRIPT]
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -5,7 +5,7 @@
jr nz, .asm_1db8d ; 0x1db5a $31
bit 0, [hl]
ret z
- ld a, [wd42f]
+ ld a, [wDestinationWarpID]
cp $1
ret nz
bit 2, [hl]
@@ -75,7 +75,7 @@
ld a, (SFX_02_54 - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld d, $0
ld e, $8
.asm_1dbfa
@@ -111,7 +111,7 @@
ld a, $90
ld [hVBlankWY], a
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
pop hl
pop bc
ld [hl], b
@@ -118,7 +118,7 @@
dec hl
ld [hl], c
call LoadPlayerSpriteGraphics
- ld hl, wd3ae
+ ld hl, wNumberOfWarps
dec [hl]
ret
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -158,7 +158,7 @@
ld de, ReceivedThunderbadgeText
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -61,7 +61,7 @@
.asm_449fe
ld a, $c2
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, .coordsData_449f9 ; $49f9
call Func_46981
ld a, [wWhichTrade] ; wWhichTrade
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -286,16 +286,16 @@
jr .asm_6dff7 ; 0x74a7b
.asm_9fc95 ; 0x74a7d
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, ViridianGymText_74ad9
call PrintText
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $32
ld [wcc4d], a
predef HideObject
call UpdateSprites
call Delay3
- call GBFadeOut1
+ call GBFadeInFromBlack
jr .asm_6dff7 ; 0x74a9e
.asm_6de66 ; 0x74aa0
ld hl, ViridianGymText_74ace
@@ -307,7 +307,7 @@
ld de, ViridianGymText_74ad3
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $8
--- a/wram.asm
+++ b/wram.asm
@@ -260,7 +260,11 @@
wcc38:: ds 2
wcc3a:: ds 1
wcc3b:: ds 1
-wcc3c:: ds 1
+
+wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c
+; if non-zero, skip waiting for a button press after displaying text in DisplayTextID
+ ds 1
+
wcc3d:: ds 1
wcc3e:: ds 4
wcc42:: ds 1
@@ -496,6 +500,12 @@
ds 1
+wFlyAnimUsingCoordList:: ; cd3d
+
+wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d
+
+wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d
+
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
; ds 1
@@ -502,11 +512,28 @@
wTrainerSpriteOffset:: ; cd3d
ds 1
+
+wFlyAnimCounter:: ; cd3e
+
+wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e
+
+wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e
+
wTrainerEngageDistance:: ; cd3e
ds 1
+
+wFlyAnimBirdSpriteImageIndex:: ; cd3f
+
+wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f
+
+wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f
+
wTrainerFacingDirection:: ; cd3f
wcd3f::
ds 1
+
+wPlayerSpinInPlaceAnimSoundID:: ; cd40
+
wTrainerScreenY:: ; cd40
ds 1
wTrainerScreenX:: ; cd41
@@ -593,7 +620,11 @@
; $01 - lose
; $02 - draw
ds 1
-wcf0c:: ds 1
+
+wAutoTextBoxDrawingControl:: ; cf0c
+; bit 0: if set, DisplayTextID automatically draws a text box
+ ds 1
+
wcf0d:: ds 1
wcf0e:: ds 1
wcf0f:: ds 1
@@ -608,7 +639,7 @@
wPredefParentBank:: ; cf12
ds 1
-wcf13:: ds 1
+wSpriteIndex:: ds 1
wCurSpriteMovement2:: ; cf14
; movement byte 2 of current sprite
@@ -625,7 +656,10 @@
wGBC:: ; cf1a
ds 1
-wcf1b:: ds 1
+wOnSGB:: ; cf1b
+; if running on SGB, it's 1, else it's 0
+ ds 1
+
wcf1c:: ds 1
wcf1d:: ds 1
wcf1e:: ds 1
@@ -692,7 +726,9 @@
; walk animation counter
ds 1
-wcfc6:: ds 1
+wTileInFrontOfPlayer:: ; cfc6
+; background tile number in front of the player (either 1 or 2 steps ahead)
+ ds 1
wMusicHeaderPointer:: ; cfc7
; (the current music channel address - $4000) / 3
@@ -701,8 +737,11 @@
wcfc8:: ds 1
wcfc9:: ds 1
wcfca:: ds 1
-wcfcb:: ds 1
+wUpdateSpritesEnabled:: ; cfcb
+; $01 enables UpdateSprites; anything else disables it
+ ds 1
+
W_ENEMYMOVENUM:: ; cfcc
ds 1
W_ENEMYMOVEEFFECT:: ; cfcd
@@ -1121,7 +1160,11 @@
wd0e0:: ds 1
wd0e1:: ds 56
wd119:: ds 1
-wd11a:: ds 1
+
+wWalkBikeSurfStateCopy:: ; d11a
+; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything
+ ds 1
+
wd11b:: ds 1
wd11c:: ds 1
wd11d:: ds 1
@@ -1158,9 +1201,15 @@
wd133:: ds 6
wd139:: ds 1
wd13a:: ds 1
-wd13b:: ds 1
-wd13c:: ds 1
+wStepCounter:: ; d13b
+; counts down once every step
+ ds 1
+
+wNumberOfNoRandomBattleStepsLeft:: ; d13c
+; after a battle, you have at least 3 steps before a random battle can occur
+ ds 1
+
W_PRIZE1:: ; d13d
ds 1
W_PRIZE2:: ; d13e
@@ -1246,13 +1295,18 @@
wd35b:: ds 1
wd35c:: ds 1
-wd35d:: ds 1
+wMapPalOffset:: ; d35d
+; offset subtracted from FadePal4 to get the background and object palettes for the current map
+; normally, it is 0. it is 6 when Flash is needed, causing FadePal2 to be used instead of FadePal4
+ ds 1
+
W_CURMAP:: ; d35e
ds 1
-wd35f:: ds 1
-wd360:: ds 1
+wCurrentTileBlockMapViewPointer:: ; d35f
+; pointer to the upper left corner of the current view in the tile block map
+ ds 2
W_YCOORD:: ; d361
; player’s position on the current map
@@ -1364,9 +1418,21 @@
wd3a9:: ds 1
wd3aa:: ds 3
wd3ad:: ds 1
-wd3ae:: ds 1
-wd3af:: ds 128
-wd42f:: ds 129
+
+wNumberOfWarps:: ; d3ae
+; number of warps in current map
+ ds 1
+
+wWarpEntries:: ; d3af
+; current map warp entries
+ ds 128
+
+wDestinationWarpID:: ; d42f
+; if $ff, the player's coordinates are not updated when entering the map
+ ds 1
+
+ ds 128
+
wd4b0:: ds 1
wd4b1:: ds 32
wd4d1:: ds 16
@@ -1373,17 +1439,21 @@
W_NUMSPRITES:: ; d4e1
; number of sprites on the current map
-; two bytes per sprite (movement byte 2 , text ID)
ds 1
-wd4e2:: ds 1
-wd4e3:: ds 1
+; these two variables track the X and Y offset in blocks from the last special warp used
+; they don't seem to be used for anything
+wYOffsetSinceLastSpecialWarp:: ; d4e2
+ ds 1
+wXOffsetSinceLastSpecialWarp:: ; d4e3
+ ds 1
W_MAPSPRITEDATA:: ; d4e4
-; two bytes per sprite (trainer class/item ID , trainer set ID)
+; two bytes per sprite (movement byte 2, text ID)
ds 32
W_MAPSPRITEEXTRADATA:: ; d504
+; two bytes per sprite (trainer class/item ID, trainer set ID)
ds 32
wd524:: ds 1
@@ -1661,8 +1731,15 @@
wd6f0:: ds 14
wd6fe:: ds 2
-wd700:: ds 11
+wWalkBikeSurfState:: ; d700
+; $00 = walking
+; $01 = biking
+; $02 = surfing
+ ds 1
+
+ ds 10
+
W_TOWNVISITEDFLAG:: ; d70b
flag_array 13
@@ -1684,7 +1761,8 @@
; trainer classes start at $c8
ds 1
-wd714:: ds 1
+wPlayerJumpingYScreenCoordsIndex:: ; d714
+ ds 1
W_RIVALSTARTER:: ; d715
ds 1
@@ -1694,16 +1772,32 @@
W_PLAYERSTARTER:: ; d717
ds 1
-wd718:: ds 1
+wBoulderSpriteIndex:: ; d718
+; sprite index of the boulder the player is trying to push
+ ds 1
wLastBlackoutMap:: ; d719
ds 1
-wd71a:: ds 1
+wDestinationMap:: ; d71a
+; destination map (for certain types of special warps, not ordinary walking)
+ ds 1
+
wd71b:: ds 1
-wd71c:: ds 1
-wd71d:: ds 1
-wd71e:: ds 1
+
+wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c
+; used to store the tile in front of the boulder when trying to push a boulder
+; also used to store the result of the collision check ($ff for a collision and $00 for no collision)
+ ds 1
+
+wDungeonWarpDestinationMap:: ; d71d
+; destination map for dungeon warps
+ ds 1
+
+wWhichDungeonWarp:: ; d71e
+; which dungeon warp within the source map was used
+ ds 1
+
wd71f:: ds 9
wd728::
@@ -1713,7 +1807,11 @@
ds 1
wd72a:: ds 2
-wd72c:: ds 1
+
+wd72c:: ; d72c
+; bit 0: if not set, the 3 minimum steps between random battles have passed
+ ds 1
+
wd72d:: ds 1
wd72e:: ds 2
@@ -1723,10 +1821,23 @@
ds 1
-wd732:: ds 1
+wd732:: ; d732
+; bit 0: play time being counted
+; bit 1: remnant of debug mode? not set by the game code.
+; if it is set
+; 1. skips most of Prof. Oak's speech, and uses NINTEN as the player's name and SONY as the rival's name
+; 2. does not have the player start in floor two of the playyer's house (instead sending them to [wLastMap])
+; 3. allows wild battles to be avoided by holding down B
+; bit 2: the target warp is a fly warp (bit 3 set or blacked out) or a dungeon warp (bit 4 set)
+; bit 3: used warp pad, escape rope, dig, teleport, or fly, so the target warp is a "fly warp"
+; bit 4: jumped into hole (Pokemon Mansion, Seafoam Islands, Victory Road) or went down waterfall (Seafoam Islands), so the target warp is a "dungeon warp"
+; bit 5: currently being forced to ride bike (cycling road)
+; bit 6: map destination is [wLastBlackoutMap] (usually the last used pokemon center, but could be the player's house)
+ ds 1
W_FLAGS_D733:: ; d733
; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers)
+; bit 7: used fly out of battle
ds 1
wd734:: ds 2
@@ -1733,6 +1844,8 @@
wd736:: ; d736
; bit 0: check if the player is standing on a door and make him walk down a step if so
+; bit 2: standing on a warp
+; bit 6: jumping down a ledge
ds 1
wd737:: ds 4