summaryrefslogtreecommitdiff
path: root/home/overworld.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/overworld.asm')
-rw-r--r--home/overworld.asm280
1 files changed, 128 insertions, 152 deletions
diff --git a/home/overworld.asm b/home/overworld.asm
index e80b829c..d76fca98 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -1,9 +1,9 @@
-EnterMap:: ; 01d7 (0:01d7)
+EnterMap::
; Load a new map.
ld a, $ff
ld [wJoyIgnore], a
call LoadMapData
- callba ClearVariablesAfterLoadingMapData ; 3:407c
+ callba ClearVariablesAfterLoadingMapData
ld hl, wd72c
bit 0, [hl] ; has the player already made 3 steps since the last battle?
jr z, .skipGivingThreeStepsOfNoRandomBattles
@@ -40,9 +40,9 @@ EnterMap:: ; 01d7 (0:01d7)
xor a
ld [wJoyIgnore], a
-OverworldLoop:: ; 0242 (0:0242)
+OverworldLoop::
call DelayFrame
-OverworldLoopLessDelay:: ; 0245 (0:0245)
+OverworldLoopLessDelay::
call DelayFrame
call IsSurfingPikachuInParty
call LoadGBPal
@@ -51,7 +51,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
and a
jp nz, .moveAhead ; if the player sprite has not yet completed the walking animation
call JoypadOverworld ; get joypad state (which is possibly simulated)
- callba SafariZoneCheck ; 7:6321
+ callba SafariZoneCheck
ld a, [wSafariZoneGameOver]
and a
jp nz, WarpFound2
@@ -70,7 +70,6 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
jr z, .notSimulating
ld a, [hJoyHeld]
jr .checkIfStartIsPressed
-
.notSimulating
ld a, [hJoyPressed]
.checkIfStartIsPressed
@@ -80,7 +79,6 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
xor a
ld [hSpriteIndexOrTextID], a ; start menu text ID
jp .displayDialogue
-
.startButtonNotPressed
bit 0, a ; A button
jp z, .checkIfDownButtonIsPressed
@@ -118,15 +116,6 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
xor a
ld [wLinkTimeoutCounter], a
jp EnterMap
-
-; predef LoadSAV
-; ld a, [wCurMap]
-; ld [wDestinationMap], a
-; call SpecialWarpIn
-; ld a, [wCurMap]
-; call SwitchToMapRomBank ; switch to the ROM bank of the current map
-; ld hl, wCurMapTileset
-; set 7, [hl]
.checkForOpponent
ld a, [wCurOpponent]
and a
@@ -134,12 +123,12 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
jp OverworldLoop
.noDirectionButtonsPressed
- call UpdateSprites ; 231c
+ call UpdateSprites
ld hl, wFlags_0xcd60
res 2, [hl]
xor a
ld [wd435], a
- ld a, $1
+ ld a, 1
ld [wCheckFor180DegreeTurn], a
ld a, [wPlayerMovingDirection] ; the direction that was pressed last time
and a
@@ -179,9 +168,10 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
.checkIfRightButtonIsPressed
bit 4, a ; right button
jr z, .noDirectionButtonsPressed
- ld a, $1
- ld [wSpriteStateData1 + 5], a
- ld a, $1
+ ld a, 1
+ ld [wSpriteStateData1 + 5], a ; delta X
+ ld a, 1
+
.handleDirectionButtonPress
ld [wPlayerDirection], a ; new direction
ld a, [wd730]
@@ -234,6 +224,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
.surfing
call CollisionCheckOnWater
jp c, OverworldLoop
+
.noCollision
ld a, $08
ld [wWalkCounter], a
@@ -242,7 +233,8 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
.moveAhead
call IsSpinning
- call UpdateSprites ; move sprites
+ call UpdateSprites
+
.moveAhead2
ld hl, wFlags_0xcd60
res 2, [hl]
@@ -303,7 +295,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
call DelayFrames
jp EnterMap
-StepCountCheck:: ; 0457 (0:0457)
+StepCountCheck::
ld a, [wd730]
bit 7, a
jr nz, .doneStepCounting ; if button presses are being simulated, don't count steps
@@ -321,7 +313,7 @@ StepCountCheck:: ; 0457 (0:0457)
.doneStepCounting
ret
-AllPokemonFainted:: ; 0475 (0:0475)
+AllPokemonFainted::
ld a, $ff
ld [wIsInBattle], a
call RunMapScript
@@ -329,7 +321,7 @@ AllPokemonFainted:: ; 0475 (0:0475)
; function to determine if there will be a battle and execute it (either a trainer battle or wild battle)
; sets carry if a battle occurred and unsets carry if not
-NewBattle:: ; 0480 (0:0480)
+NewBattle::
ld a, [wd72d]
bit 4, a
jr nz, .noBattle
@@ -338,12 +330,13 @@ NewBattle:: ; 0480 (0:0480)
ld a, [wd72e]
bit 4, a
jr nz, .noBattle
- jpba InitBattle ; 3d:5ff2
+ jpba InitBattle
.noBattle
and a
ret
-DoBikeSpeedup:: ; 049d (0:049d)
+; function to make bikes twice as fast as walking
+DoBikeSpeedup::
ld a, [wWalkBikeSurfState]
dec a ; riding a bike?
ret nz
@@ -354,7 +347,7 @@ DoBikeSpeedup:: ; 049d (0:049d)
and a
ret nz
ld a, [wCurMap]
- cp ROUTE_17 ; cycling road
+ cp ROUTE_17 ; Cycling Road
jr nz, .goFaster
ld a, [hJoyHeld]
and D_UP | D_LEFT | D_RIGHT
@@ -364,7 +357,7 @@ DoBikeSpeedup:: ; 049d (0:049d)
ret
; check if the player has stepped onto a warp after having not collided
-CheckWarpsNoCollision:: ; 04bd (0:04bd)
+CheckWarpsNoCollision::
ld a, [wNumberOfWarps]
and a
jp z, CheckMapConnections
@@ -376,7 +369,7 @@ CheckWarpsNoCollision:: ; 04bd (0:04bd)
ld a, [wXCoord]
ld e, a
ld hl, wWarpEntries
-CheckWarpsNoCollisionLoop:: ; 04d5 (0:04d5)
+CheckWarpsNoCollisionLoop::
ld a, [hli] ; check if the warp's Y position matches
cp d
jr nz, CheckWarpsNoCollisionRetry1
@@ -412,19 +405,19 @@ CheckWarpsNoCollisionLoop:: ; 04d5 (0:04d5)
jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp
jr WarpFound1
-CheckWarpsNoCollisionRetry1:: ; 050f (0:050f)
+CheckWarpsNoCollisionRetry1::
inc hl
-CheckWarpsNoCollisionRetry2:: ; 0510 (0:0510)
+CheckWarpsNoCollisionRetry2::
inc hl
inc hl
-ContinueCheckWarpsNoCollisionLoop:: ; 0512 (0:0512)
+ContinueCheckWarpsNoCollisionLoop::
inc b ; increment warp number
dec c ; decrement number of warps
jp nz, CheckWarpsNoCollisionLoop
jp CheckMapConnections
; check if the player has stepped onto a warp after having collided
-CheckWarpsCollision:: ; 051a (0:051a)
+CheckWarpsCollision::
ld a, [wNumberOfWarps]
ld c, a
ld hl, wWarpEntries
@@ -444,7 +437,6 @@ CheckWarpsCollision:: ; 051a (0:051a)
ld a, [hl]
ld [hWarpDestinationMap], a
jr WarpFound2
-
.retry1
inc hl
.retry2
@@ -454,13 +446,13 @@ CheckWarpsCollision:: ; 051a (0:051a)
jr nz, .loop
jp OverworldLoop
-WarpFound1:: ; 0543 (0:0543)
+WarpFound1::
ld a, [hli]
ld [wDestinationWarpID], a
ld a, [hli]
ld [hWarpDestinationMap], a
-WarpFound2:: ; 054a (0:054a)
+WarpFound2::
ld a, [wNumberOfWarps]
sub c
ld [wWarpedFromWhichWarp], a ; save ID of used warp
@@ -502,18 +494,17 @@ WarpFound2:: ; 054a (0:054a)
ld hl, wd732
set 3, [hl]
jr .skipMapChangeSound
-
.notWarpPad
call PlayMapChangeSound
.skipMapChangeSound
ld hl, wd736
res 0, [hl]
res 1, [hl]
- callab CalculatePikachuSpawnState2 ; 3f:465b
+ callab CalculatePikachuSpawnState2
jr .done
.goBackOutside
- callab CalculatePikachuSpawnState3 ; 3f:469a
+ callab CalculatePikachuSpawnState3
ld a, [wLastMap]
ld [wCurMap], a
call PlayMapChangeSound
@@ -526,7 +517,7 @@ WarpFound2:: ; 054a (0:054a)
jp EnterMap
; if no matching warp was found
-CheckMapConnections:: ; 05db (0:05db)
+CheckMapConnections::
.checkWestMap
ld a, [wXCoord]
cp $ff
@@ -653,14 +644,13 @@ CheckMapConnections:: ; 05db (0:05db)
ld [wCurrentTileBlockMapViewPointer], a ; pointer to upper left corner of current tile block map section
ld a, h
ld [wCurrentTileBlockMapViewPointer + 1], a
-.loadNewMap ; 06ce (0:06ce)
-; load the connected map that was entered
+.loadNewMap ; load the connected map that was entered
ld hl, wPikachuOverworldStateFlags
set 4, [hl]
ld a, $2
ld [wPikachuSpawnState], a
- call LoadMapHeader ; 0dab (0:0dab)
- call PlayDefaultMusicFadeOutCurrent ; music
+ call LoadMapHeader
+ call PlayDefaultMusicFadeOutCurrent
ld b, SET_PAL_OVERWORLD
call RunPaletteCommand
; Since the sprite set shouldn't change, this will just update VRAM slots at
@@ -673,20 +663,19 @@ CheckMapConnections:: ; 05db (0:05db)
jp OverworldLoop
; function to play a sound when changing maps
-PlayMapChangeSound:: ; 06ef (0:06ef)
+PlayMapChangeSound::
ld a, [wCurMapTileset]
cp FACILITY
jr z, .didNotGoThroughDoor
cp CEMETERY
jr z, .didNotGoThroughDoor
aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on
- cp UNDERGROUND ; door tile in tileset 0
+ cp $0b ; door tile in tileset 0
jr nz, .didNotGoThroughDoor
- ld a, $ad ; SFX_GO_INSIDE
+ ld a, SFX_GO_INSIDE
jr .playSound
-
.didNotGoThroughDoor
- ld a, $b5 ; SFX_GO_OUTSIDE
+ ld a, SFX_GO_OUTSIDE
.playSound
call PlaySound
ld a, [wMapPalOffset]
@@ -694,7 +683,7 @@ PlayMapChangeSound:: ; 06ef (0:06ef)
ret nz
jp GBFadeOutToBlack
-CheckIfInOutsideMap:: ; 0712 (0:0712)
+CheckIfInOutsideMap::
; If the player is in an outside map (a town or route), set the z flag
ld a, [wCurMapTileset]
and a ; most towns/routes have tileset 0 (OVERWORLD)
@@ -708,7 +697,7 @@ CheckIfInOutsideMap:: ; 0712 (0:0712)
; "function 1" passes when the player is at the edge of the map and is facing towards the outside of the map
; "function 2" passes when the the tile in front of the player is among a certain set
; sets carry if the check passes, otherwise clears carry
-ExtraWarpCheck:: ; 071a (0:071a)
+ExtraWarpCheck::
ld a, [wCurMap]
cp SS_ANNE_3
jr z, .useFunction1
@@ -732,21 +721,20 @@ ExtraWarpCheck:: ; 071a (0:071a)
.useFunction1
ld hl, IsPlayerFacingEdgeOfMap
jr .doBankswitch
-
.useFunction2
ld hl, IsWarpTileInFrontOfPlayer
.doBankswitch
ld b, BANK(IsWarpTileInFrontOfPlayer)
jp Bankswitch
-MapEntryAfterBattle:: ; 0750 (0:0750)
+MapEntryAfterBattle::
callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions
ld a, [wMapPalOffset]
and a
jp z, GBFadeInFromWhite
jp LoadGBPal
-HandleBlackOut:: ; 0762 (0:0762)
+HandleBlackOut::
; For when all the player's pokemon faint.
; Does not print the "blacked out" message.
@@ -761,7 +749,7 @@ HandleBlackOut:: ; 0762 (0:0762)
call PlayDefaultMusicFadeOutCurrent
jp SpecialEnterMap
-StopMusic:: ; 0788 (0:0788)
+StopMusic::
ld [wAudioFadeOutControl], a
call StopAllMusic
.wait
@@ -770,7 +758,7 @@ StopMusic:: ; 0788 (0:0788)
jr nz, .wait
jp StopAllSounds
-HandleFlyWarpOrDungeonWarp:: ; 0794 (0:0794)
+HandleFlyWarpOrDungeonWarp::
call UpdateSprites
call Delay3
xor a
@@ -785,10 +773,10 @@ HandleFlyWarpOrDungeonWarp:: ; 0794 (0:0794)
callbs SpecialWarpIn
jp SpecialEnterMap
-LeaveMapAnim:: ; 07bc (0:07bc)
+LeaveMapAnim::
jpba _LeaveMapAnim
-Func_07c4:: ; 07c4 (0:07c4)
+Func_07c4::
ld a, [wWalkBikeSurfState]
and a
ret z
@@ -800,7 +788,7 @@ Func_07c4:: ; 07c4 (0:07c4)
call PlayDefaultMusic
ret
-LoadPlayerSpriteGraphics:: ; 07d7 (0:07d7)
+LoadPlayerSpriteGraphics::
; Load sprite graphics based on whether the player is standing, biking, or surfing.
; 0: standing
@@ -838,7 +826,7 @@ LoadPlayerSpriteGraphics:: ; 07d7 (0:07d7)
jp z, LoadSurfingPlayerSpriteGraphics2
jp LoadWalkingPlayerSpriteGraphics
-IsBikeRidingAllowed:: ; 0805 (0:0805)
+IsBikeRidingAllowed::
; The bike can be used on Route 23 and Indigo Plateau,
; or maps with tilesets in BikeRidingTilesets.
; Return carry if biking is allowed.
@@ -868,10 +856,10 @@ IsBikeRidingAllowed:: ; 0805 (0:0805)
INCLUDE "data/bike_riding_tilesets.asm"
; load the tile pattern data of the current tileset into VRAM
-LoadTilesetTilePatternData:: ; 0828 (0:0828)
- ld a, [wTilesetGFXPtr]
+LoadTilesetTilePatternData::
+ ld a, [wTilesetGfxPtr]
ld l, a
- ld a, [wTilesetGFXPtr + 1]
+ ld a, [wTilesetGfxPtr + 1]
ld h, a
ld de, vTileset
ld bc, $600
@@ -880,7 +868,7 @@ LoadTilesetTilePatternData:: ; 0828 (0:0828)
; this loads the current maps complete tile map (which references blocks, not individual tiles) to C6E8
; it can also load partial tile maps of connected maps into a border of length 3 around the current map
-LoadTileBlockMap:: ; 083c (0:083c)
+LoadTileBlockMap::
; fill C6E8-CBFB with the background tile
ld hl, wOverworldMap
ld bc, $0514
@@ -1002,7 +990,7 @@ LoadTileBlockMap:: ; 083c (0:083c)
.done
ret
-LoadNorthSouthConnectionsTileMap:: ; 0919 (0:0919)
+LoadNorthSouthConnectionsTileMap::
ld c, MAP_BORDER
.loop
push de
@@ -1034,7 +1022,7 @@ LoadNorthSouthConnectionsTileMap:: ; 0919 (0:0919)
jr nz, .loop
ret
-LoadEastWestConnectionsTileMap:: ; 093d (0:093d)
+LoadEastWestConnectionsTileMap::
push hl
push de
ld c, MAP_BORDER
@@ -1065,7 +1053,7 @@ LoadEastWestConnectionsTileMap:: ; 093d (0:093d)
; function to check if there is a sign or sprite in front of the player
; if so, carry is set. otherwise, carry is cleared
-IsSpriteOrSignInFrontOfPlayer:: ; 095e (0:095e)
+IsSpriteOrSignInFrontOfPlayer::
xor a
ld [hSpriteIndexOrTextID], a
ld a, [wNumSigns]
@@ -1078,7 +1066,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 095e (0:095e)
.extendRangeOverCounter
; 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
predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c
- ld hl, wTileSetTalkingOverTiles ; list of tiles that extend talking range (counter tiles)
+ ld hl, wTilesetTalkingOverTiles ; list of tiles that extend talking range (counter tiles)
ld b, 3
ld d, $20 ; talking range in pixels (long range)
.counterTilesLoop
@@ -1089,9 +1077,9 @@ IsSpriteOrSignInFrontOfPlayer:: ; 095e (0:095e)
jr nz, .counterTilesLoop
; sets carry flag if a sprite is in front of the player, resets if not
-IsSpriteInFrontOfPlayer:: ; 0983 (0:0983)
+IsSpriteInFrontOfPlayer::
ld d, $10 ; talking range in pixels (normal range)
-IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
+IsSpriteInFrontOfPlayer2::
lb bc, $3c, $40 ; Y and X position of player sprite
ld a, [wPlayerFacingDirection] ; direction the player is facing
.checkIfPlayerFacingUp
@@ -1182,7 +1170,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
scf
ret
-SignLoop:: ; 09f2 (0:09f2)
+SignLoop::
; search if a player is facing a sign
ld hl, wSignCoords ; start of sign coordinates
ld a, [wNumSigns] ; number of signs in the map
@@ -1223,7 +1211,7 @@ SignLoop:: ; 09f2 (0:09f2)
; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing)
; sets the carry flag if there is a collision, and unsets it if there isn't a collision
-CollisionCheckOnLand:: ; 0a1c (0:0a1c)
+CollisionCheckOnLand::
ld a, [wd736]
bit 6, a ; is the player jumping?
jr nz, .noCollision
@@ -1267,21 +1255,20 @@ CollisionCheckOnLand:: ; 0a1c (0:0a1c)
jr nc, .noCollision
.collision
ld a, [wChannelSoundIDs + CH4]
- cp $b4 ; SFX_COLLISION ; check if collision sound is already playing
+ cp SFX_COLLISION ; check if collision sound is already playing
jr z, .setCarry
- ld a, $b4 ; SFX_COLLISION
+ ld a, SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing)
.setCarry
scf
ret
-
.noCollision
and a
ret
; function that checks if the tile in front of the player is passable
; clears carry if it is, sets carry if not
-CheckTilePassable:: ; 0a79 (0:0a79)
+CheckTilePassable::
predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
ld a, [wTileInFrontOfPlayer] ; tile in front of player
ld c, a
@@ -1292,13 +1279,12 @@ CheckTilePassable:: ; 0a79 (0:0a79)
; and check for collisions that only occur between certain pairs of tiles
; Input: hl - address of directional collision data
; sets carry if there is a collision and unsets carry if not
-CheckForJumpingAndTilePairCollisions:: ; 0a86 (0:0a86)
+CheckForJumpingAndTilePairCollisions::
push hl
predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player
push de
push bc
- callba HandleLedges ; 6:67f4
- ; check if the player is trying to jump a ledge
+ callba HandleLedges ; check if the player is trying to jump a ledge
pop bc
pop de
pop hl
@@ -1308,11 +1294,11 @@ CheckForJumpingAndTilePairCollisions:: ; 0a86 (0:0a86)
ret nz
; if not jumping
-CheckForTilePairCollisions2:: ; 0aa0 (0:0aa0)
+CheckForTilePairCollisions2::
aCoord 8, 9 ; tile the player is on
ld [wTilePlayerStandingOn], a
-CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
+CheckForTilePairCollisions::
ld a, [wTileInFrontOfPlayer]
ld c, a
.tilePairCollisionLoop
@@ -1327,7 +1313,6 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
.retry
inc hl
jr .tilePairCollisionLoop
-
.tilesetMatches
ld a, [wTilePlayerStandingOn] ; tile the player is on
ld b, a
@@ -1339,14 +1324,12 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
cp b
jr z, .currentTileMatchesSecondInPair
jr .retry
-
.currentTileMatchesFirstInPair
inc hl
ld a, [hl]
cp c
jr z, .foundMatch
jr .tilePairCollisionLoop
-
.currentTileMatchesSecondInPair
dec hl
ld a, [hli]
@@ -1356,7 +1339,6 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
.foundMatch
scf
ret
-
.noMatch
and a
ret
@@ -1366,7 +1348,7 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
; these entries indicate that the player may not cross between tile 1 and tile 2
; it's mainly used to simulate differences in elevation
-TilePairCollisionsLand:: ; 0ada (0:0ada)
+TilePairCollisionsLand::
db CAVERN, $20, $05
db CAVERN, $41, $05
db FOREST, $30, $2E
@@ -1380,14 +1362,14 @@ TilePairCollisionsLand:: ; 0ada (0:0ada)
db FOREST, $5F, $2E
db $FF
-TilePairCollisionsWater:: ; 0afc (0:0afc)
+TilePairCollisionsWater::
db FOREST, $14, $2E
db FOREST, $48, $2E
db CAVERN, $14, $05
db $FF
; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character
-LoadCurrentMapView:: ; 0b06 (0:0b06)
+LoadCurrentMapView::
ld a, [H_LOADEDROMBANK]
push af
ld a, [wTilesetBank] ; tile data ROM bank
@@ -1475,12 +1457,12 @@ LoadCurrentMapView:: ; 0b06 (0:0b06)
call BankswitchCommon ; restore previous ROM bank
ret
-AdvancePlayerSprite:: ; 0b7f (0:0b7f)
+AdvancePlayerSprite::
ld a, [wUpdateSpritesEnabled]
push af
ld a, $FF
ld [wUpdateSpritesEnabled], a
- ld hl, _AdvancePlayerSprite ; 3c:410c
+ ld hl, _AdvancePlayerSprite
ld b, BANK(_AdvancePlayerSprite)
call Bankswitch
pop af
@@ -1490,7 +1472,7 @@ AdvancePlayerSprite:: ; 0b7f (0:0b7f)
; the following 6 functions are used to tell the V-blank handler to redraw
; the portion of the map that was newly exposed due to the player's movement
-ScheduleNorthRowRedraw:: ; 0b95 (0:0b95)
+ScheduleNorthRowRedraw::
coord hl, 0, 0
call CopyToRedrawRowOrColumnSrcTiles
ld a, [wMapViewVRAMPointer]
@@ -1501,7 +1483,7 @@ ScheduleNorthRowRedraw:: ; 0b95 (0:0b95)
ld [hRedrawRowOrColumnMode], a
ret
-CopyToRedrawRowOrColumnSrcTiles:: ; 0baa (0:0baa)
+CopyToRedrawRowOrColumnSrcTiles::
ld de, wRedrawRowOrColumnSrcTiles
ld c, 2 * SCREEN_WIDTH
.loop
@@ -1512,7 +1494,7 @@ CopyToRedrawRowOrColumnSrcTiles:: ; 0baa (0:0baa)
jr nz, .loop
ret
-ScheduleSouthRowRedraw:: ; 0bb6 (0:0bb6)
+ScheduleSouthRowRedraw::
coord hl, 0, 16
call CopyToRedrawRowOrColumnSrcTiles
ld a, [wMapViewVRAMPointer]
@@ -1531,7 +1513,7 @@ ScheduleSouthRowRedraw:: ; 0bb6 (0:0bb6)
ld [hRedrawRowOrColumnMode], a
ret
-ScheduleEastColumnRedraw:: ; 0bd6 (0:0bd7)
+ScheduleEastColumnRedraw::
coord hl, 18, 0
call ScheduleColumnRedrawHelper
ld a, [wMapViewVRAMPointer]
@@ -1549,7 +1531,7 @@ ScheduleEastColumnRedraw:: ; 0bd6 (0:0bd7)
ld [hRedrawRowOrColumnMode], a
ret
-ScheduleColumnRedrawHelper:: ; 0bf6 (0:0bf6)
+ScheduleColumnRedrawHelper::
ld de, wRedrawRowOrColumnSrcTiles
ld c, SCREEN_HEIGHT
.loop
@@ -1569,7 +1551,7 @@ ScheduleColumnRedrawHelper:: ; 0bf6 (0:0bf6)
jr nz, .loop
ret
-ScheduleWestColumnRedraw:: ; 0c0c (0:0c0c)
+ScheduleWestColumnRedraw::
coord hl, 0, 0
call ScheduleColumnRedrawHelper
ld a, [wMapViewVRAMPointer]
@@ -1582,11 +1564,11 @@ ScheduleWestColumnRedraw:: ; 0c0c (0:0c0c)
; function to write the tiles that make up a tile block to memory
; Input: c = tile block ID, hl = destination address
-DrawTileBlock:: ; 0c21 (0:0c21)
+DrawTileBlock::
push hl
- ld a, [wTileSetBlocksPtr] ; pointer to tiles
+ ld a, [wTilesetBlocksPtr] ; pointer to tiles
ld l, a
- ld a, [wTileSetBlocksPtr + 1]
+ ld a, [wTilesetBlocksPtr + 1]
ld h, a
ld a, c
swap a
@@ -1623,7 +1605,7 @@ DrawTileBlock:: ; 0c21 (0:0c21)
ret
; function to update joypad state and simulate button presses
-JoypadOverworld:: ; 0c51 (0:0c51)
+JoypadOverworld::
xor a
ld [wSpriteStateData1 + 3], a
ld [wSpriteStateData1 + 5], a
@@ -1633,7 +1615,7 @@ JoypadOverworld:: ; 0c51 (0:0c51)
call AreInputsSimulated
ret
-ForceBikeDown:: ; 0c65 (0:0c65)
+ForceBikeDown::
ld a, [wFlags_D733]
bit 3, a ; check if a trainer wants a challenge
ret nz
@@ -1647,7 +1629,7 @@ ForceBikeDown:: ; 0c65 (0:0c65)
ld [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press
ret
-AreInputsSimulated:: ; 0c7b (0:0c7b)
+AreInputsSimulated::
ld a, [wd730]
bit 7, a
ret z
@@ -1682,7 +1664,7 @@ AreInputsSimulated:: ; 0c7b (0:0c7b)
res 7, [hl]
ret
-GetSimulatedInput:: ; 0cb3 (0:0cb3)
+GetSimulatedInput::
ld hl, wSimulatedJoypadStatesIndex
dec [hl]
ld a, [hl]
@@ -1705,14 +1687,8 @@ GetSimulatedInput:: ; 0cb3 (0:0cb3)
; function to check the tile ahead to determine if the character should get on land or keep surfing
; sets carry if there is a collision and clears carry otherwise
-; It seems that this function has a bug in it, but due to luck, it doesn't
-; show up. After detecting a sprite collision, it jumps to the code that
-; checks if the next tile is passable instead of just directly jumping to the
-; "collision detected" code. However, it doesn't store the next tile in c,
-; so the old value of c is used. 2429 is always called before this function,
-; and 2429 always sets c to 0xF0. There is no 0xF0 background tile, so it
-; is considered impassable and it is detected as a collision.
-CollisionCheckOnWater:: ; 0cca (0:0cca)
+; This function had a bug in Red/Blue, but it was fixed in Yellow.
+CollisionCheckOnWater::
ld a, [wd730]
bit 7, a
jp nz, .noCollision ; return and clear carry if button presses are being simulated
@@ -1720,12 +1696,12 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
ld d, a
ld a, [wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code)
and d ; check if a sprite is in the direction the player is trying to go
- jr nz, .collision ; bug?
+ jr nz, .collision
ld hl, TilePairCollisionsWater
call CheckForJumpingAndTilePairCollisions
jr c, .collision
predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player (puts it in c and [wTileInFrontOfPlayer])
- callab IsNextTileShoreOrWater ; 3:6808
+ callab IsNextTileShoreOrWater
jr c, .noCollision
ld a, [wTileInFrontOfPlayer] ; tile in front of player
ld c, a
@@ -1733,9 +1709,9 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
jr nc, .stopSurfing
.collision
ld a, [wChannelSoundIDs + CH4]
- cp $b4 ; SFX_COLLISION
+ cp SFX_COLLISION ; check if collision sound is already playing
jr z, .setCarry
- ld a, $b4 ; SFX_COLLISION
+ ld a, SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing)
.setCarry
scf
@@ -1763,7 +1739,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
ret
; function to run the current map's script
-RunMapScript:: ; 0d2c (0:0d2c)
+RunMapScript::
push hl
push de
push bc
@@ -1789,7 +1765,7 @@ RunMapScript:: ; 0d2c (0:0d2c)
.return
ret
-LoadWalkingPlayerSpriteGraphics:: ; 0d5e (0:0d5e)
+LoadWalkingPlayerSpriteGraphics::
; new sprite copy stuff
xor a
ld [wd473], a
@@ -1797,7 +1773,7 @@ LoadWalkingPlayerSpriteGraphics:: ; 0d5e (0:0d5e)
ld de, RedSprite ; $4180
jr LoadPlayerSpriteGraphicsCommon
-LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
+LoadSurfingPlayerSpriteGraphics2::
ld a, [wd473]
and a
jr z, .asm_0d75
@@ -1814,15 +1790,15 @@ LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld de, SurfingPikachuSprite ; 3f:6def
jr LoadPlayerSpriteGraphicsCommon
-LoadSurfingPlayerSpriteGraphics:: ; 0d83 (0:0d83)
- ld b, BANK(RedSprite) ; not sure, but probably same bank (5)
+LoadSurfingPlayerSpriteGraphics::
+ ld b, BANK(SeelSprite)
ld de, SeelSprite
jr LoadPlayerSpriteGraphicsCommon
-LoadBikePlayerSpriteGraphics:: ; 0d8a (0:0d8a)
+LoadBikePlayerSpriteGraphics::
ld b, BANK(RedCyclingSprite)
ld de, RedCyclingSprite
-LoadPlayerSpriteGraphicsCommon:: ; 0d8f (0:0d8f)
+LoadPlayerSpriteGraphicsCommon::
ld hl, vNPCSprites
push de
push hl
@@ -1843,12 +1819,12 @@ LoadPlayerSpriteGraphicsCommon:: ; 0d8f (0:0d8f)
jp CopyVideoData
; function to load data from the map header
-LoadMapHeader:: ; 0dab (0:0dab)
+LoadMapHeader::
callba MarkTownVisitedAndLoadMissableObjects
jr asm_0dbd
Func_0db5:: ; XXX
- callba Func_f0a55 ; 3c:4a55
+ callba LoadUnusedBluesHouseMissableObjectData ; 3c:4a55
asm_0dbd
ld a, [wCurMapTileset]
ld [wUnusedD119], a
@@ -1945,9 +1921,9 @@ asm_0dbd
predef LoadTilesetHeader
ld a, [wd72e]
bit 5, a ; did a battle happen immediately before this?
- jr nz, .asm_0e73
- callab Func_fc4fa ; 3f:44fa
-.asm_0e73
+ jr nz, .skip_pika_spawn
+ callab SchedulePikachuSpawnForAfterText ; 3f:44fa
+.skip_pika_spawn
callab LoadWildData ; 3:4b62
pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose)
ld a, [wCurMapHeight] ; map height in 4x4 tile blocks
@@ -1975,7 +1951,7 @@ asm_0dbd
; function to copy map connection data from ROM to WRAM
; Input: hl = source, de = destination
-CopyMapConnectionHeader:: ; 0eaa (0:0eaa)
+CopyMapConnectionHeader::
ld c, $0b
.loop
ld a, [hli]
@@ -1985,7 +1961,7 @@ CopyMapConnectionHeader:: ; 0eaa (0:0eaa)
jr nz, .loop
ret
-CopySignData:: ; 0eb3 (0:0eb3)
+CopySignData::
ld de, wSignCoords ; start of sign coords
ld bc, wSignTextIDs ; start of sign text ids
ld a, [wNumSigns] ; number of signs
@@ -2006,7 +1982,7 @@ CopySignData:: ; 0eb3 (0:0eb3)
ret
; function to load map data
-LoadMapData:: ; 1241 (0:1241)
+LoadMapData::
ld a, [H_LOADEDROMBANK]
push af
call DisableLCD
@@ -2035,13 +2011,13 @@ LoadMapData:: ; 1241 (0:1241)
call BankswitchCommon
ret
-LoadScreenRelatedData:: ; 0f0c (0:0f0c)
+LoadScreenRelatedData::
call LoadTileBlockMap
call LoadTilesetTilePatternData
call LoadCurrentMapView
ret
-ReloadMapAfterSurfingMinigame:: ; 0f16 (0:0f16)
+ReloadMapAfterSurfingMinigame::
ld a, [H_LOADEDROMBANK]
push af
call DisableLCD
@@ -2058,7 +2034,7 @@ ReloadMapAfterSurfingMinigame:: ; 0f16 (0:0f16)
call BankswitchCommon
jr asm_0f4d
-ReloadMapAfterPrinter:: ; 0f3d (0:0f3d)
+ReloadMapAfterPrinter::
ld a, [H_LOADEDROMBANK]
push af
ld a, [wCurMap]
@@ -2066,11 +2042,11 @@ ReloadMapAfterPrinter:: ; 0f3d (0:0f3d)
call LoadTileBlockMap
pop af
call BankswitchCommon
-asm_0f4d: ; 0f4d (0:0f4d)
- jpab Func_f02da
+asm_0f4d:
+ jpab SetMapSpecificScriptFlagsOnMapReload
ret ; useless?
-ResetMapVariables:: ; 0f56 (0:0f56)
+ResetMapVariables::
ld a, $98
ld [wMapViewVRAMPointer + 1], a
xor a
@@ -2083,10 +2059,10 @@ ResetMapVariables:: ; 0f56 (0:0f56)
ld [wWalkBikeSurfStateCopy], a
ret
-CopyMapViewToVRAM:: ; 0f70 (0:0f70)
+CopyMapViewToVRAM::
; copy current map view to VRAM
ld de, vBGMap0
-CopyMapViewToVRAM2: ; 0f73 (0:0f73)
+CopyMapViewToVRAM2:
ld hl, wTileMap
ld b, 18
.vramCopyLoop
@@ -2109,7 +2085,7 @@ CopyMapViewToVRAM2: ; 0f73 (0:0f73)
; function to switch to the ROM bank that a map is stored in
; Input: a = map number
-SwitchToMapRomBank:: ; 0f8b (0:0f8b)
+SwitchToMapRomBank::
push hl
push bc
ld c, a
@@ -2127,7 +2103,7 @@ SwitchToMapRomBank:: ; 0f8b (0:0f8b)
pop hl
ret
-GetMapHeaderPointer:: ; 0fa7 (0:0fa7)
+GetMapHeaderPointer::
ld a, [H_LOADEDROMBANK]
push af
switchbank MapHeaderPointers ; 3f:41f2
@@ -2145,21 +2121,21 @@ GetMapHeaderPointer:: ; 0fa7 (0:0fa7)
pop af
jp BankswitchCommon
-IgnoreInputForHalfSecond: ; 0fc3 (0:0fc3)
+IgnoreInputForHalfSecond:
ld a, 30
ld [wIgnoreInputCounter], a
ld hl, wd730
ld a, [hl]
- or $26
+ or %00100110
ld [hl], a ; set ignore input bit
ret
-ResetUsingStrengthOutOfBattleBit: ; 0fd0 (0:0fd0)
+ResetUsingStrengthOutOfBattleBit:
ld hl, wd728
res 0, [hl]
ret
-ForceBikeOrSurf:: ; 0fd6 (0:0fd6)
+ForceBikeOrSurf::
ld b, BANK(RedSprite)
ld hl, LoadPlayerSpriteGraphics
call Bankswitch
@@ -2167,23 +2143,23 @@ ForceBikeOrSurf:: ; 0fd6 (0:0fd6)
; Handle the player jumping down
; a ledge in the overworld.
-HandleMidJump:: ; 0fe1 (0:0fe1)
+HandleMidJump::
ld a, [wd736]
bit 6, a ; jumping down a ledge?
ret z
callba _HandleMidJump
ret
-IsSpinning:: ; 0ff0 (0:0ff0)
+IsSpinning::
ld a, [wd736]
bit 7, a
ret z ; no spinning
jpba LoadSpinnerArrowTiles ; spin while moving
-Func_0ffe:: ; 0ffe (0:0ffe)
+Func_0ffe::
jpab IsPlayerTalkingToPikachu
-InitSprites:: ; 1006 (0:1006)
+InitSprites::
ld a, [hli]
ld [wNumSprites], a ; save the number of sprites
push hl
@@ -2237,7 +2213,7 @@ InitSprites:: ; 1006 (0:1006)
jr nz, .loadSpriteLoop
ret
-ZeroSpriteStateData:: ; 1050 (0:1050)
+ZeroSpriteStateData::
; zero C110-C1EF and C210-C2EF
; C1F0-C1FF and C2F0-C2FF is used for Pikachu
ld hl, wSpriteStateData1 + $10
@@ -2252,7 +2228,7 @@ ZeroSpriteStateData:: ; 1050 (0:1050)
jr nz, .loop
ret
-DisableRegularSprites:: ; 1060 (0:1060)
+DisableRegularSprites::
; initialize all C100-C1FF sprite entries to disabled (other than player's and pikachu)
ld hl, wSpriteStateData1 + 1 * $10 + 2
ld de, $10
@@ -2264,7 +2240,7 @@ DisableRegularSprites:: ; 1060 (0:1060)
jr nz, .loop
ret
-LoadSprite:: ; 106f (0:106f)
+LoadSprite::
push hl
ld b, $0
ld hl, wMapSpriteData