summaryrefslogtreecommitdiff
path: root/home/overworld.asm
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-06-12 11:51:59 -0700
committerGitHub <noreply@github.com>2016-06-12 11:51:59 -0700
commitbfaabd08be0a790dff961276d76af3e1af4e6e24 (patch)
tree60742e693805fd75031079e8d3b8a87847452d1e /home/overworld.asm
parent2b2c6fefd311101c87845c8c498746dc74bd725f (diff)
parent3ab3f4273b1288883a43b64cae4191dfa6d2313e (diff)
Merge pull request #135 from YamaArashi/master
sync tileset WRAM labels
Diffstat (limited to 'home/overworld.asm')
-rw-r--r--home/overworld.asm123
1 files changed, 72 insertions, 51 deletions
diff --git a/home/overworld.asm b/home/overworld.asm
index fad9f29d..f71bb68a 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -59,7 +59,7 @@ OverworldLoopLessDelay::
res 3,[hl]
jp nz,WarpFound2
ld a,[wd732]
- and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
jp nz,HandleFlyWarpOrDungeonWarp
ld a,[wCurOpponent]
and a
@@ -133,7 +133,7 @@ OverworldLoopLessDelay::
ld hl,wFlags_0xcd60
res 2,[hl]
call UpdateSprites
- ld a,1
+ ld a, 1
ld [wCheckFor180DegreeTurn],a
ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
and a
@@ -143,6 +143,7 @@ OverworldLoopLessDelay::
xor a
ld [wPlayerMovingDirection],a ; zero the direction
jp OverworldLoop
+
.checkIfDownButtonIsPressed
ld a,[hJoyHeld] ; current joypad state
bit 7,a ; down button
@@ -151,6 +152,7 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 3],a ; delta Y
ld a,PLAYER_DIR_DOWN
jr .handleDirectionButtonPress
+
.checkIfUpButtonIsPressed
bit 6,a ; up button
jr z,.checkIfLeftButtonIsPressed
@@ -158,6 +160,7 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 3],a ; delta Y
ld a,PLAYER_DIR_UP
jr .handleDirectionButtonPress
+
.checkIfLeftButtonIsPressed
bit 5,a ; left button
jr z,.checkIfRightButtonIsPressed
@@ -165,11 +168,14 @@ OverworldLoopLessDelay::
ld [wSpriteStateData1 + 5],a ; delta X
ld a,PLAYER_DIR_LEFT
jr .handleDirectionButtonPress
+
.checkIfRightButtonIsPressed
bit 4,a ; right button
jr z,.noDirectionButtonsPressed
- ld a,1 ; PLAYER_DIR_RIGHT
+ ld a, 1
ld [wSpriteStateData1 + 5],a ; delta X
+
+
.handleDirectionButtonPress
ld [wPlayerDirection],a ; new direction
ld a,[wd730]
@@ -226,12 +232,13 @@ OverworldLoopLessDelay::
call NewBattle
jp c,.battleOccurred
jp OverworldLoop
+
.noDirectionChange
ld a,[wPlayerDirection] ; current direction
ld [wPlayerMovingDirection],a ; save direction
call UpdateSprites
ld a,[wWalkBikeSurfState]
- cp a,$02 ; surfing
+ cp $02 ; surfing
jr z,.surfing
; not surfing
call CollisionCheckOnLand
@@ -248,20 +255,24 @@ OverworldLoopLessDelay::
pop hl
jp c,CheckWarpsCollision
jp OverworldLoop
+
.surfing
call CollisionCheckOnWater
jp c,OverworldLoop
+
.noCollision
ld a,$08
ld [wWalkCounter],a
jr .moveAhead2
+
.moveAhead
ld a,[wd736]
bit 7,a
jr z,.noSpinning
- callba LoadSpinnerArrowTiles ; spin while moving
+ callba LoadSpinnerArrowTiles
.noSpinning
call UpdateSprites
+
.moveAhead2
ld hl,wFlags_0xcd60
res 2,[hl]
@@ -271,7 +282,7 @@ OverworldLoopLessDelay::
ld a,[wd736]
bit 6,a ; jumping a ledge?
jr nz,.normalPlayerSpriteAdvancement
- call BikeSpeedup ; if riding a bike and not jumping a ledge
+ call DoBikeSpeedup
.normalPlayerSpriteAdvancement
call AdvancePlayerSprite
ld a,[wWalkCounter]
@@ -323,14 +334,14 @@ OverworldLoopLessDelay::
xor a
ld [hJoyHeld],a
ld a,[wCurMap]
- cp a,CINNABAR_GYM
+ cp CINNABAR_GYM
jr nz,.notCinnabarGym
SetEvent EVENT_2A7
.notCinnabarGym
ld hl,wd72e
set 5,[hl]
ld a,[wCurMap]
- cp a,OAKS_LAB
+ cp OAKS_LAB
jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
callab AnyPartyAlive
ld a,d
@@ -363,15 +374,15 @@ NewBattle::
ret
; function to make bikes twice as fast as walking
-BikeSpeedup::
+DoBikeSpeedup::
ld a,[wNPCMovementScriptPointerTableNum]
and a
ret nz
ld a,[wCurMap]
- cp a,ROUTE_17 ; Cycling Road
+ cp ROUTE_17 ; Cycling Road
jr nz,.goFaster
ld a,[hJoyHeld]
- and a,D_UP | D_LEFT | D_RIGHT
+ and D_UP | D_LEFT | D_RIGHT
ret nz
.goFaster
jp AdvancePlayerSprite
@@ -421,7 +432,7 @@ CheckWarpsNoCollisionLoop::
pop bc
pop de
ld a,[hJoyHeld]
- and a,D_DOWN | D_UP | D_LEFT | D_RIGHT
+ and 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
@@ -483,7 +494,7 @@ WarpFound2::
ld [wUnusedD366],a ; not read
ld a,[hWarpDestinationMap]
ld [wCurMap],a
- cp a,ROCK_TUNNEL_1
+ cp ROCK_TUNNEL_1
jr nz,.notRockTunnel
ld a,$06
ld [wMapPalOffset],a
@@ -491,10 +502,12 @@ WarpFound2::
.notRockTunnel
call PlayMapChangeSound
jr .done
-; for maps that can have the 0xFF destination map, which means to return to the outside map; not all these maps are necessarily indoors, though
+
+; for maps that can have the 0xFF destination map, which means to return to the outside map
+; not all these maps are necessarily indoors, though
.indoorMaps
ld a,[hWarpDestinationMap] ; destination map
- cp a,$ff
+ cp $ff
jr z,.goBackOutside
; if not going back to the previous map
ld [wCurMap],a
@@ -535,7 +548,7 @@ ContinueCheckWarpsNoCollisionLoop::
CheckMapConnections::
.checkWestMap
ld a,[wXCoord]
- cp a,$ff
+ cp $ff
jr nz,.checkEastMap
ld a,[wMapConn3Ptr]
ld [wCurMap],a
@@ -555,7 +568,7 @@ CheckMapConnections::
jr z,.savePointer1
.pointerAdjustmentLoop1
ld a,[wWestConnectedMapWidth] ; width of connected map
- add a,MAP_BORDER * 2
+ add MAP_BORDER * 2
ld e,a
ld d,0
ld b,0
@@ -568,6 +581,7 @@ CheckMapConnections::
ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
+
.checkEastMap
ld b,a
ld a,[wCurrentMapWidth2] ; map width
@@ -591,7 +605,7 @@ CheckMapConnections::
jr z,.savePointer2
.pointerAdjustmentLoop2
ld a,[wEastConnectedMapWidth]
- add a,MAP_BORDER * 2
+ add MAP_BORDER * 2
ld e,a
ld d,0
ld b,0
@@ -604,9 +618,10 @@ CheckMapConnections::
ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
+
.checkNorthMap
ld a,[wYCoord]
- cp a,$ff
+ cp $ff
jr nz,.checkSouthMap
ld a,[wMapConn1Ptr]
ld [wCurMap],a
@@ -630,6 +645,7 @@ CheckMapConnections::
ld a,h
ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
+
.checkSouthMap
ld b,a
ld a,[wCurrentMapHeight2]
@@ -666,13 +682,14 @@ CheckMapConnections::
callba InitMapSprites
call LoadTileBlockMap
jp OverworldLoopLessDelay
+
.didNotEnterConnectedMap
jp OverworldLoop
; function to play a sound when changing maps
PlayMapChangeSound::
aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on
- cp a,$0b ; door tile in tileset 0
+ cp $0b ; door tile in tileset 0
jr nz,.didNotGoThroughDoor
ld a,SFX_GO_INSIDE
jr .playSound
@@ -854,13 +871,13 @@ INCLUDE "data/bike_riding_tilesets.asm"
; load the tile pattern data of the current tileset into VRAM
LoadTilesetTilePatternData::
- ld a,[wTileSetGFXPtr]
+ ld a,[wTilesetGfxPtr]
ld l,a
- ld a,[wTileSetGFXPtr + 1]
+ ld a,[wTilesetGfxPtr + 1]
ld h,a
ld de,vTileset
ld bc,$600
- ld a,[wTileSetBank]
+ ld a,[wTilesetBank]
jp FarCopyData2
; this loads the current maps complete tile map (which references blocks, not individual tiles) to C6E8
@@ -883,7 +900,7 @@ LoadTileBlockMap::
ld hl,wOverworldMap
ld a,[wCurMapWidth]
ld [hMapWidth],a
- add a,MAP_BORDER * 2 ; east and west
+ add MAP_BORDER * 2 ; east and west
ld [hMapStride],a ; map width + border
ld b,0
ld c,a
@@ -921,7 +938,7 @@ LoadTileBlockMap::
jr nz,.rowLoop
.northConnection
ld a,[wMapConn1Ptr]
- cp a,$ff
+ cp $ff
jr z,.southConnection
call SwitchToMapRomBank
ld a,[wNorthConnectionStripSrc]
@@ -939,7 +956,7 @@ LoadTileBlockMap::
call LoadNorthSouthConnectionsTileMap
.southConnection
ld a,[wMapConn2Ptr]
- cp a,$ff
+ cp $ff
jr z,.westConnection
call SwitchToMapRomBank
ld a,[wSouthConnectionStripSrc]
@@ -957,7 +974,7 @@ LoadTileBlockMap::
call LoadNorthSouthConnectionsTileMap
.westConnection
ld a,[wMapConn3Ptr]
- cp a,$ff
+ cp $ff
jr z,.eastConnection
call SwitchToMapRomBank
ld a,[wWestConnectionStripSrc]
@@ -975,7 +992,7 @@ LoadTileBlockMap::
call LoadEastWestConnectionsTileMap
.eastConnection
ld a,[wMapConn4Ptr]
- cp a,$ff
+ cp $ff
jr z,.done
call SwitchToMapRomBank
ld a,[wEastConnectionStripSrc]
@@ -1016,7 +1033,7 @@ LoadNorthSouthConnectionsTileMap::
inc h
.noCarry1
ld a,[wCurMapWidth]
- add a,MAP_BORDER * 2
+ add MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry2
@@ -1045,7 +1062,7 @@ LoadEastWestConnectionsTileMap::
inc h
.noCarry1
ld a,[wCurMapWidth]
- add a,MAP_BORDER * 2
+ add MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry2
@@ -1100,7 +1117,7 @@ IsSpriteOrSignInFrontOfPlayer::
; 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 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
@@ -1126,6 +1143,7 @@ IsSpriteInFrontOfPlayer2::
ld b,a
ld a,PLAYER_DIR_UP
jr .doneCheckingDirection
+
.checkIfPlayerFacingDown
cp SPRITE_FACING_DOWN
jr nz,.checkIfPlayerFacingRight
@@ -1135,6 +1153,7 @@ IsSpriteInFrontOfPlayer2::
ld b,a
ld a,PLAYER_DIR_DOWN
jr .doneCheckingDirection
+
.checkIfPlayerFacingRight
cp SPRITE_FACING_RIGHT
jr nz,.playerFacingLeft
@@ -1144,6 +1163,7 @@ IsSpriteInFrontOfPlayer2::
ld c,a
ld a,PLAYER_DIR_RIGHT
jr .doneCheckingDirection
+
.playerFacingLeft
; facing left
ld a,c
@@ -1225,7 +1245,7 @@ CollisionCheckOnLand::
jr nc,.noCollision
.collision
ld a,[wChannelSoundIDs + CH4]
- cp a,SFX_COLLISION ; check if collision sound is already playing
+ cp SFX_COLLISION ; check if collision sound is already playing
jr z,.setCarry
ld a,SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing)
@@ -1242,7 +1262,7 @@ CheckTilePassable::
predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
ld a,[wTileInFrontOfPlayer] ; tile in front of player
ld c,a
- ld hl,wTileSetCollisionPtr ; pointer to list of passable tiles
+ ld hl,wTilesetCollisionPtr ; pointer to list of passable tiles
ld a,[hli]
ld h,[hl]
ld l,a ; hl now points to passable tiles
@@ -1287,7 +1307,7 @@ CheckForTilePairCollisions::
ld a,[wCurMapTileset] ; tileset number
ld b,a
ld a,[hli]
- cp a,$ff
+ cp $ff
jr z,.noMatch
cp b
jr z,.tilesetMatches
@@ -1354,7 +1374,7 @@ TilePairCollisionsWater::
LoadCurrentMapView::
ld a,[H_LOADEDROMBANK]
push af
- ld a,[wTileSetBank] ; tile data ROM bank
+ ld a,[wTilesetBank] ; tile data ROM bank
ld [H_LOADEDROMBANK],a
ld [MBC1RomBank],a ; switch to ROM bank that contains tile data
ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
@@ -1387,7 +1407,7 @@ LoadCurrentMapView::
; update tile block map pointer to next row's address
pop de
ld a,[wCurMapWidth]
- add a,MAP_BORDER * 2
+ add MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry
@@ -1722,8 +1742,8 @@ ScheduleSouthRowRedraw::
ld bc,$0200
add hl,bc
ld a,h
- and a,$03
- or a,$98
+ and $03
+ or $98
ld [hRedrawRowOrColumnDest + 1],a
ld a,l
ld [hRedrawRowOrColumnDest],a
@@ -1736,11 +1756,11 @@ ScheduleEastColumnRedraw::
call ScheduleColumnRedrawHelper
ld a,[wMapViewVRAMPointer]
ld c,a
- and a,$e0
+ and $e0
ld b,a
ld a,c
- add a,18
- and a,$1f
+ add 18
+ and $1f
or b
ld [hRedrawRowOrColumnDest],a
ld a,[wMapViewVRAMPointer + 1]
@@ -1784,17 +1804,17 @@ ScheduleWestColumnRedraw::
; Input: c = tile block ID, hl = destination address
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
ld b,a
- and a,$f0
+ and $f0
ld c,a
ld a,b
- and a,$0f
+ and $0f
ld b,a ; bc = tile block ID * 0x10
add hl,bc
ld d,h
@@ -1833,10 +1853,10 @@ JoypadOverworld::
bit 3,a ; check if a trainer wants a challenge
jr nz,.notForcedDownwards
ld a,[wCurMap]
- cp a,ROUTE_17 ; Cycling Road
+ cp ROUTE_17 ; Cycling Road
jr nz,.notForcedDownwards
ld a,[hJoyHeld]
- and a,D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
+ and D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
jr nz,.notForcedDownwards
ld a,D_DOWN
ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press
@@ -1868,6 +1888,7 @@ JoypadOverworld::
ld [hJoyPressed],a
ld [hJoyReleased],a
ret
+
; if done simulating button presses
.doneSimulating
xor a
@@ -1878,7 +1899,7 @@ JoypadOverworld::
ld [hJoyHeld],a
ld hl,wd736
ld a,[hl]
- and a,$f8
+ and $f8
ld [hl],a
ld hl,wd730
res 7,[hl]
@@ -1915,7 +1936,7 @@ CollisionCheckOnWater::
jr z,.noCollision ; keep surfing
; check if the [land] tile in front of the player is passable
.checkIfNextTileIsPassable
- ld hl,wTileSetCollisionPtr ; pointer to list of passable tiles
+ ld hl,wTilesetCollisionPtr ; pointer to list of passable tiles
ld a,[hli]
ld h,[hl]
ld l,a
@@ -1928,7 +1949,7 @@ CollisionCheckOnWater::
jr .loop
.collision
ld a,[wChannelSoundIDs + CH4]
- cp a,SFX_COLLISION ; check if collision sound is already playing
+ cp SFX_COLLISION ; check if collision sound is already playing
jr z,.setCarry
ld a,SFX_COLLISION
call PlaySound ; play collision sound (if it's not already playing)
@@ -2386,7 +2407,7 @@ IgnoreInputForHalfSecond:
ld [wIgnoreInputCounter], a
ld hl, wd730
ld a, [hl]
- or $26
+ or %00100110
ld [hl], a ; set ignore input bit
ret