diff options
Diffstat (limited to 'engine/overworld')
28 files changed, 704 insertions, 988 deletions
diff --git a/engine/overworld/boulders.asm b/engine/overworld/boulders.asm deleted file mode 100644 index 669b7b83..00000000 --- a/engine/overworld/boulders.asm +++ /dev/null @@ -1,94 +0,0 @@ -CheckForCollisionWhenPushingBoulder: - call GetTileTwoStepsInFrontOfPlayer - call IsTilePassable - jr c, .done - ld hl, TilePairCollisionsLand - call CheckForTilePairCollisions2 - ld a, $ff - 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, .done ; if the tile two steps ahead is stairs - call CheckForBoulderCollisionWithSprites -.done - ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a - ret - -; sets a to $ff if there is a collision and $00 if there is no collision -CheckForBoulderCollisionWithSprites: - ld a, [wBoulderSpriteIndex] - dec a - swap a - ld d, 0 - ld e, a - ld hl, wSpriteStateData2 + $14 - add hl, de - ld a, [hli] ; map Y position - ld [$ffdc], a - ld a, [hl] ; map X position - ld [$ffdd], a - ld a, [wNumSprites] - ld c, a - ld de, $f - ld hl, wSpriteStateData2 + $14 - ld a, [$ffdb] - and $3 ; facing up or down? - jr z, .pushingHorizontallyLoop -.pushingVerticallyLoop - inc hl - ld a, [$ffdd] - cp [hl] - jr nz, .nextSprite1 ; if X coordinates don't match - dec hl - ld a, [hli] - ld b, a - ld a, [$ffdb] - rrca - jr c, .pushingDown -; pushing up - ld a, [$ffdc] - dec a - jr .compareYCoords -.pushingDown - ld a, [$ffdc] - inc a -.compareYCoords - cp b - jr z, .failure -.nextSprite1 - dec c - jr z, .success - add hl, de - jr .pushingVerticallyLoop -.pushingHorizontallyLoop - ld a, [hli] - ld b, a - ld a, [$ffdc] - cp b - jr nz, .nextSprite2 - ld b, [hl] - ld a, [$ffdb] - bit 2, a - jr nz, .pushingLeft -; pushing right - ld a, [$ffdd] - inc a - jr .compareXCoords -.pushingLeft - ld a, [$ffdd] - dec a -.compareXCoords - cp b - jr z, .failure -.nextSprite2 - dec c - jr z, .success - add hl, de - jr .pushingHorizontallyLoop -.failure - ld a, $ff - ret -.success - xor a - ret diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm index e3ce8e8d..12ce64a4 100755 --- a/engine/overworld/cable_club_npc.asm +++ b/engine/overworld/cable_club_npc.asm @@ -180,7 +180,8 @@ CableClubNPCPleaseApplyHereHaveToSaveText: CableClubNPCPleaseWaitText: TX_FAR _CableClubNPCPleaseWaitText - db $a, "@" + TX_DELAY + db "@" CableClubNPCLinkClosedBecauseOfInactivityText: TX_FAR _CableClubNPCLinkClosedBecauseOfInactivityText diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index 9026960c..a4452b4a 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -74,7 +74,7 @@ SilphCoMapList: CardKeySuccessText: TX_FAR _CardKeySuccessText1 - TX_SFX_ITEM + TX_SFX_ITEM_1 TX_FAR _CardKeySuccessText2 db "@" diff --git a/engine/overworld/check_player_state.asm b/engine/overworld/check_player_state.asm deleted file mode 100644 index 2fcb5b9d..00000000 --- a/engine/overworld/check_player_state.asm +++ /dev/null @@ -1,236 +0,0 @@ -; only used for setting bit 2 of wd736 upon entering a new map -IsPlayerStandingOnWarp: - ld a, [wNumberOfWarps] - and a - ret z - ld c, a - ld hl, wWarpEntries -.loop - ld a, [wYCoord] - cp [hl] - jr nz, .nextWarp1 - inc hl - ld a, [wXCoord] - cp [hl] - jr nz, .nextWarp2 - inc hl - ld a, [hli] ; target warp - ld [wDestinationWarpID], a - ld a, [hl] ; target map - ld [$ff8b], a - ld hl, wd736 - set 2, [hl] ; standing on warp flag - ret -.nextWarp1 - inc hl -.nextWarp2 - inc hl - inc hl - inc hl - dec c - jr nz, .loop - ret - -CheckForceBikeOrSurf: - ld hl, wd732 - bit 5, [hl] - ret nz - ld hl, ForcedBikeOrSurfMaps - ld a, [wYCoord] - ld b, a - ld a, [wXCoord] - ld c, a - ld a, [wCurMap] - ld d, a -.loop - ld a, [hli] - cp $ff - ret z ;if we reach FF then it's not part of the list - cp d ;compare to current map - jr nz, .incorrectMap - ld a, [hli] - cp b ;compare y-coord - jr nz, .incorrectY - ld a, [hli] - cp c ;compare x-coord - jr nz, .loop ; incorrect x-coord, check next item - ld a, [wCurMap] - cp SEAFOAM_ISLANDS_4 - ld a, $2 - ld [wSeafoamIslands4CurScript], a - jr z, .forceSurfing - ld a, [wCurMap] - cp SEAFOAM_ISLANDS_5 - ld a, $2 - ld [wSeafoamIslands5CurScript], a - jr z, .forceSurfing - ;force bike riding - ld hl, wd732 - set 5, [hl] - ld a, $1 - ld [wWalkBikeSurfState], a - ld [wWalkBikeSurfStateCopy], a - call ForceBikeOrSurf - ret -.incorrectMap - inc hl -.incorrectY - inc hl - jr .loop -.forceSurfing - ld a, $2 - ld [wWalkBikeSurfState], a - ld [wWalkBikeSurfStateCopy], a - call ForceBikeOrSurf - ret - -INCLUDE "data/force_bike_surf.asm" - -IsPlayerFacingEdgeOfMap: - push hl - push de - push bc - ld a, [wSpritePlayerStateData1FacingDirection] ; player sprite's facing direction - srl a - ld c, a - ld b, $0 - ld hl, .functionPointerTable - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wYCoord] - ld b, a - ld a, [wXCoord] - ld c, a - ld de, .returnaddress - push de - jp hl -.returnaddress - pop bc - pop de - pop hl - ret - -.functionPointerTable - dw .facingDown - dw .facingUp - dw .facingLeft - dw .facingRight - -.facingDown - ld a, [wCurMapHeight] - add a - dec a - cp b - jr z, .setCarry - jr .resetCarry - -.facingUp - ld a, b - and a - jr z, .setCarry - jr .resetCarry - -.facingLeft - ld a, c - and a - jr z, .setCarry - jr .resetCarry - -.facingRight - ld a, [wCurMapWidth] - add a - dec a - cp c - jr z, .setCarry - jr .resetCarry -.resetCarry - and a - ret -.setCarry - scf - ret - -IsWarpTileInFrontOfPlayer: - push hl - push de - push bc - call _GetTileAndCoordsInFrontOfPlayer - ld a, [wCurMap] - cp SS_ANNE_5 - jr z, .ssAnne5 - ld a, [wSpritePlayerStateData1FacingDirection] ; player sprite's facing direction - srl a - ld c, a - ld b, 0 - ld hl, .warpTileListPointers - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wTileInFrontOfPlayer] - ld de, $1 - call IsInArray -.done - pop bc - pop de - pop hl - ret - -.warpTileListPointers: - dw .facingDownWarpTiles - dw .facingUpWarpTiles - dw .facingLeftWarpTiles - dw .facingRightWarpTiles - -.facingDownWarpTiles - db $01,$12,$17,$3D,$04,$18,$33,$FF - -.facingUpWarpTiles - db $01,$5C,$FF - -.facingLeftWarpTiles - db $1A,$4B,$FF - -.facingRightWarpTiles - db $0F,$4E,$FF - -.ssAnne5 - ld a, [wTileInFrontOfPlayer] - cp $15 - jr nz, .notSSAnne5Warp - scf - jr .done -.notSSAnne5Warp - and a - jr .done - -IsPlayerStandingOnDoorTileOrWarpTile: - push hl - push de - push bc - callba IsPlayerStandingOnDoorTile - jr c, .done - ld a, [wCurMapTileset] - add a - ld c, a - ld b, $0 - ld hl, WarpTileIDPointers - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - ld de, $1 - aCoord 8, 9 - call IsInArray - jr nc, .done - ld hl, wd736 - res 2, [hl] -.done - pop bc - pop de - pop hl - ret - -INCLUDE "data/warp_tile_ids.asm" diff --git a/engine/overworld/clear_loadmapdata_vars.asm b/engine/overworld/clear_variables.asm index c5dc21fa..9a59cc7c 100644 --- a/engine/overworld/clear_loadmapdata_vars.asm +++ b/engine/overworld/clear_variables.asm @@ -1,11 +1,11 @@ -ClearVariablesAfterLoadingMapData: - ld a, $90 +ClearVariablesOnEnterMap: + ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a ld [rWY], a xor a ld [H_AUTOBGTRANSFERENABLED], a ld [wStepCounter], a - ld [wLoneAttackNo], a ; wGymLeaderNo + ld [wLoneAttackNo], a ld [hJoyPressed], a ld [hJoyReleased], a ld [hJoyHeld], a @@ -14,7 +14,7 @@ ClearVariablesAfterLoadingMapData: ld hl, wCardKeyDoorY ld [hli], a ld [hl], a - ld hl, wUnusedCD3D - ld bc, wStandingOnWarpPadOrHole - wUnusedCD3D + ld hl, wWhichTrade + ld bc, wStandingOnWarpPadOrHole - wWhichTrade call FillMemory ret diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index cd7bf5ba..47ec78f9 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -31,7 +31,7 @@ ShakeElevator: ld a, SFX_SAFARI_ZONE_PA call PlayMusic .musicLoop - ld a, [wChannelSoundIDs + CH4] + ld a, [wChannelSoundIDs + Ch5] cp SFX_SAFARI_ZONE_PA jr z, .musicLoop call UpdateSprites diff --git a/engine/overworld/field_move_messages.asm b/engine/overworld/field_move_messages.asm new file mode 100644 index 00000000..1d111917 --- /dev/null +++ b/engine/overworld/field_move_messages.asm @@ -0,0 +1,57 @@ +PrintStrengthTxt: + ld hl, wd728 + set 0, [hl] + ld hl, UsedStrengthText + call PrintText + ld hl, CanMoveBouldersText + jp PrintText + +UsedStrengthText: + TX_FAR _UsedStrengthText + TX_ASM + ld a, [wcf91] + call PlayCry + call Delay3 + jp TextScriptEnd + +CanMoveBouldersText: + TX_FAR _CanMoveBouldersText + db "@" + +IsSurfingAllowed: +; Returns whether surfing is allowed in bit 1 of wd728. +; Surfing isn't allowed on the Cycling Road or in the lowest level of the +; Seafoam Islands before the current has been slowed with boulders. + ld hl, wd728 + set 1, [hl] + ld a, [wd732] + bit 5, a + jr nz, .forcedToRideBike + ld a, [wCurMap] + cp SEAFOAM_ISLANDS_B4F + ret nz + CheckBothEventsSet EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE, EVENT_SEAFOAM4_BOULDER2_DOWN_HOLE + ret z + ld hl, CoordsData_f5b64 + call ArePlayerCoordsInArray + ret nc + ld hl, wd728 + res 1, [hl] + ld hl, CurrentTooFastText + jp PrintText +.forcedToRideBike + ld hl, wd728 + res 1, [hl] + ld hl, CyclingIsFunText + jp PrintText + +CoordsData_f5b64: + db $0B,$07,$FF + +CurrentTooFastText: + TX_FAR _CurrentTooFastText + db "@" + +CyclingIsFunText: + TX_FAR _CyclingIsFunText + db "@" diff --git a/engine/overworld/get_coords_tile_in_front_of_player.asm b/engine/overworld/get_coords_tile_in_front_of_player.asm deleted file mode 100644 index 67f154bc..00000000 --- a/engine/overworld/get_coords_tile_in_front_of_player.asm +++ /dev/null @@ -1,87 +0,0 @@ -GetTileAndCoordsInFrontOfPlayer: - call GetPredefRegisters - -_GetTileAndCoordsInFrontOfPlayer: - ld a, [wYCoord] - ld d, a - ld a, [wXCoord] - ld e, a - ld a, [wSpritePlayerStateData1FacingDirection] ; player's sprite facing direction - and a ; cp SPRITE_FACING_DOWN - jr nz, .notFacingDown -; facing down - aCoord 8, 11 - inc d - jr .storeTile -.notFacingDown - cp SPRITE_FACING_UP - jr nz, .notFacingUp -; facing up - aCoord 8, 7 - dec d - jr .storeTile -.notFacingUp - cp SPRITE_FACING_LEFT - jr nz, .notFacingLeft -; facing left - aCoord 6, 9 - dec e - jr .storeTile -.notFacingLeft - cp SPRITE_FACING_RIGHT - jr nz, .storeTile -; facing right - aCoord 10, 9 - inc e -.storeTile - ld c, a - ld [wTileInFrontOfPlayer], a - ret - -GetTileTwoStepsInFrontOfPlayer: - xor a - ld [$ffdb], a - ld hl, wYCoord - ld a, [hli] - ld d, a - ld e, [hl] - ld a, [wSpritePlayerStateData1FacingDirection] ; player's sprite facing direction - and a ; cp SPRITE_FACING_DOWN - jr nz, .notFacingDown -; facing down - ld hl, $ffdb - set 0, [hl] - aCoord 8, 13 - inc d - jr .storeTile -.notFacingDown - cp SPRITE_FACING_UP - jr nz, .notFacingUp -; facing up - ld hl, $ffdb - set 1, [hl] - aCoord 8, 5 - dec d - jr .storeTile -.notFacingUp - cp SPRITE_FACING_LEFT - jr nz, .notFacingLeft -; facing left - ld hl, $ffdb - set 2, [hl] - aCoord 4, 9 - dec e - jr .storeTile -.notFacingLeft - cp SPRITE_FACING_RIGHT - jr nz, .storeTile -; facing right - ld hl, $ffdb - set 3, [hl] - aCoord 12, 9 - inc e -.storeTile - ld c, a - ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a - ld [wTileInFrontOfPlayer], a - ret diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index 15082847..b64411c7 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -133,11 +133,12 @@ INCLUDE "data/hidden_coins.asm" FoundHiddenCoinsText: TX_FAR _FoundHiddenCoinsText - db $10,"@" + TX_SFX_ITEM_2 + db "@" DroppedHiddenCoinsText: TX_FAR _FoundHiddenCoins2Text - db $10 + TX_SFX_ITEM_2 TX_FAR _DroppedHiddenCoinsText db "@" diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm index 63eecef9..9f19100a 100644 --- a/engine/overworld/item.asm +++ b/engine/overworld/item.asm @@ -46,7 +46,7 @@ PickUpItem: FoundItemText: TX_FAR _FoundItemText - db $0B + TX_SFX_ITEM_1 db "@" NoMoreRoomForItemText: diff --git a/engine/overworld/load_wild_data.asm b/engine/overworld/load_wild_data.asm deleted file mode 100644 index 6444ab7e..00000000 --- a/engine/overworld/load_wild_data.asm +++ /dev/null @@ -1,33 +0,0 @@ -LoadWildData: - ld hl,WildDataPointers - ld a,[wCurMap] - - ; get wild data for current map - ld c,a - ld b,0 - add hl,bc - add hl,bc - ld a,[hli] - ld h,[hl] - ld l,a ; hl now points to wild data for current map - ld a,[hli] - ld [wGrassRate],a - and a - jr z,.NoGrassData ; if no grass data, skip to surfing data - push hl - ld de,wGrassMons ; otherwise, load grass data - ld bc,$0014 - call CopyData - pop hl - ld bc,$0014 - add hl,bc -.NoGrassData - ld a,[hli] - ld [wWaterRate],a - and a - ret z ; if no water data, we're done - ld de,wWaterMons ; otherwise, load surfing data - ld bc,$0014 - jp CopyData - -INCLUDE "data/wild_mons.asm" diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 1a877b4a..3e2c3912 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -7,7 +7,7 @@ ; $C1X* and $C2X* are used to denote wSpriteStateData1-wSpriteStateData1 + $ff and wSpriteStateData2 + $00-wSpriteStateData2 + $ff sprite slot ; fields, respectively, within loops. The X is the loop index. ; If there is an inner loop, Y is the inner loop index, i.e. $C1Y* and $C2Y* -; denote fields of the sprite slots interated over in the inner loop. +; denote fields of the sprite slots iterated over in the inner loop. _InitMapSprites: call InitOutsideMapSprites ret c ; return if the map is an outside map (already handled by above call) @@ -308,10 +308,10 @@ GetSplitMapSpriteSetID: ret c ; Chooses the correct sprite set ID depending on the player's position within ; the map for maps with two sprite sets. - cp a, $f8 + cp $f8 jr z, .route20 ld hl, SplitMapSpriteSets - and a, $0f + and $0f dec a add a add a @@ -321,7 +321,7 @@ GetSplitMapSpriteSetID: inc h .noCarry ld a, [hli] ; determines whether the map is split East/West or North/South - cp a, $01 + cp $01 ld a, [hli] ; position of dividing line ld b, a jr z, .eastWestDivide @@ -344,15 +344,15 @@ GetSplitMapSpriteSetID: .route20 ld hl, wXCoord ld a, [hl] - cp a, $2b + cp $2b ld a, $01 ret c ld a, [hl] - cp a, $3e + cp $3e ld a, $0a ret nc ld a, [hl] - cp a, $37 + cp $37 ld b, $08 jr nc, .next ld b, $0d diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 6fb388fd..f2334479 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -1,3 +1,5 @@ +MAP_TILESET_SIZE EQU $60 + UpdatePlayerSprite: ld a, [wSpriteStateData2] and a @@ -13,7 +15,7 @@ UpdatePlayerSprite: .checkIfTextBoxInFrontOfSprite aCoord 8, 9 ld [hTilePlayerStandingOn], a - cp $60 + cp MAP_TILESET_SIZE jr c, .lowerLeftTileIsMapTile .disableSprite ld a, $ff @@ -112,7 +114,7 @@ UpdateNPCSprite: and a jp z, InitializeSpriteStatus call CheckSpriteAvailability - ret c ; if sprite is invisible, on tile >=$60, in grass or player is currently walking + ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking ld h, wSpriteStateData1 / $100 ld a, [H_CURRENTSPRITEOFFSET] ld l, a @@ -290,9 +292,9 @@ UpdateSpriteInWalkingAnimation: ld a, [H_CURRENTSPRITEOFFSET] ld l, a inc h - ld a, [hl] ; c2x0 (walk animantion counter) + ld a, [hl] ; c2x0 (walk animation counter) dec a - ld [hl], a ; update walk animantion counter + ld [hl], a ; update walk animation counter ret nz ld a, $6 ; walking finished, update state add l @@ -406,7 +408,7 @@ InitializeSpriteStatus: call InitializeSpriteScreenPosition ; could have done fallthrough here ret -; calculates the spprite's scrren position form its map position and the player position +; calculates the sprite's screen position form its map position and the player position InitializeSpriteScreenPosition: ld h, wSpriteStateData2 / $100 ld a, [H_CURRENTSPRITEOFFSET] @@ -480,21 +482,21 @@ CheckSpriteAvailability: ; make the sprite invisible if a text box is in front of it ; $5F is the maximum number for map tiles call GetTileSpriteStandsOn - ld d, $60 + ld d, MAP_TILESET_SIZE ld a, [hli] cp d - jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom left tile) + jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom left tile) ld a, [hld] cp d - jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom right tile) + jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom right tile) ld bc, -20 add hl, bc ; go back one row of tiles ld a, [hli] cp d - jr nc, .spriteInvisible ; standing on tile with ID >=$60 (top left tile) + jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (top left tile) ld a, [hl] cp d - jr c, .spriteVisible ; standing on tile with ID >=$60 (top right tile) + jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) .spriteInvisible ld h, wSpriteStateData1 / $100 ld a, [H_CURRENTSPRITEOFFSET] @@ -655,7 +657,7 @@ CanWalkOntoTile: scf ; set carry (marking failure to walk) ret -; calculates the tile pointer pointing to the tile the current sprite stancs on +; calculates the tile pointer pointing to the tile the current sprite stands on ; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to ; hl: output pointer GetTileSpriteStandsOn: diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 333779fa..670cb121 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -153,7 +153,7 @@ PalletMovementScript_Done: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, $0 + ld a, HS_PALLET_TOWN_OAK ld [wMissableObjectIndex], a predef HideObject ld hl, wd730 diff --git a/engine/overworld/npc_movement_2.asm b/engine/overworld/npc_movement_2.asm index 06ee9319..93d1afce 100755 --- a/engine/overworld/npc_movement_2.asm +++ b/engine/overworld/npc_movement_2.asm @@ -1,6 +1,6 @@ FreezeEnemyTrainerSprite: ld a, [wCurMap] - cp POKEMONTOWER_7 + cp POKEMON_TOWER_7F ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them ld hl, RivalIDs ld a, [wEngagedTrainerClass] diff --git a/engine/overworld/npc_pathfinding.asm b/engine/overworld/npc_pathfinding.asm deleted file mode 100644 index f3d23b7c..00000000 --- a/engine/overworld/npc_pathfinding.asm +++ /dev/null @@ -1,201 +0,0 @@ -FindPathToPlayer: - xor a - ld hl, hFindPathNumSteps - ld [hli], a ; hFindPathNumSteps - ld [hli], a ; hFindPathFlags - ld [hli], a ; hFindPathYProgress - ld [hl], a ; hFindPathXProgress - ld hl, wNPCMovementDirections2 - ld de, $0 -.loop - ld a, [hFindPathYProgress] - ld b, a - ld a, [hNPCPlayerYDistance] ; Y distance in steps - call CalcDifference - ld d, a - and a - jr nz, .asm_f76a - ld a, [hFindPathFlags] - set 0, a ; current end of path matches the player's Y coordinate - ld [hFindPathFlags], a -.asm_f76a - ld a, [hFindPathXProgress] - ld b, a - ld a, [hNPCPlayerXDistance] ; X distance in steps - call CalcDifference - ld e, a - and a - jr nz, .asm_f77c - ld a, [hFindPathFlags] - set 1, a ; current end of path matches the player's X coordinate - ld [hFindPathFlags], a -.asm_f77c - ld a, [hFindPathFlags] - cp $3 ; has the end of the path reached the player's position? - jr z, .done -; Compare whether the X distance between the player and the current of the path -; is greater or if the Y distance is. Then, try to reduce whichever is greater. - ld a, e - cp d - jr c, .yDistanceGreater -; x distance is greater - ld a, [hNPCPlayerRelativePosFlags] - bit 1, a - jr nz, .playerIsLeftOfNPC - ld d, NPC_MOVEMENT_RIGHT - jr .next1 -.playerIsLeftOfNPC - ld d, NPC_MOVEMENT_LEFT -.next1 - ld a, [hFindPathXProgress] - add 1 - ld [hFindPathXProgress], a - jr .storeDirection -.yDistanceGreater - ld a, [hNPCPlayerRelativePosFlags] - bit 0, a - jr nz, .playerIsAboveNPC - ld d, NPC_MOVEMENT_DOWN - jr .next2 -.playerIsAboveNPC - ld d, NPC_MOVEMENT_UP -.next2 - ld a, [hFindPathYProgress] - add 1 - ld [hFindPathYProgress], a -.storeDirection - ld a, d - ld [hli], a - ld a, [hFindPathNumSteps] - inc a - ld [hFindPathNumSteps], a - jp .loop -.done - ld [hl], $ff - ret - -CalcPositionOfPlayerRelativeToNPC: - xor a - ld [hNPCPlayerRelativePosFlags], a - ld a, [wSpriteStateData1 + 4] ; player's sprite screen Y position in pixels - ld d, a - ld a, [wSpriteStateData1 + 6] ; player's sprite screen X position in pixels - ld e, a - ld hl, wSpriteStateData1 - ld a, [hNPCSpriteOffset] - add l - add $4 - ld l, a - jr nc, .noCarry - inc h -.noCarry - ld a, d - ld b, a - ld a, [hli] ; NPC sprite screen Y position in pixels - call CalcDifference - jr nc, .NPCSouthOfOrAlignedWithPlayer -.NPCNorthOfPlayer - push hl - ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - set 0, [hl] - pop hl - jr .divideYDistance -.NPCSouthOfOrAlignedWithPlayer - push hl - ld hl, hNPCPlayerRelativePosFlags - bit 0, [hl] - res 0, [hl] - pop hl -.divideYDistance - push hl - ld hl, hDividend2 - ld [hli], a - ld a, 16 - ld [hli], a - call DivideBytes ; divide Y absolute distance by 16 - ld a, [hl] ; quotient - ld [hNPCPlayerYDistance], a - pop hl - inc hl - ld b, e - ld a, [hl] ; NPC sprite screen X position in pixels - call CalcDifference - jr nc, .NPCEastOfOrAlignedWithPlayer -.NPCWestOfPlayer - push hl - ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - set 1, [hl] - pop hl - jr .divideXDistance -.NPCEastOfOrAlignedWithPlayer - push hl - ld hl, hNPCPlayerRelativePosFlags - bit 1, [hl] - res 1, [hl] - pop hl -.divideXDistance - ld [hDividend2], a - ld a, 16 - ld [hDivisor2], a - call DivideBytes ; divide X absolute distance by 16 - ld a, [hQuotient2] - ld [hNPCPlayerXDistance], a - ld a, [hNPCPlayerRelativePosPerspective] - and a - ret z - ld a, [hNPCPlayerRelativePosFlags] - cpl - and $3 - ld [hNPCPlayerRelativePosFlags], a - ret - -ConvertNPCMovementDirectionsToJoypadMasks: - ld a, [hNPCMovementDirections2Index] - ld [wNPCMovementDirections2Index], a - dec a - ld de, wSimulatedJoypadStatesEnd - ld hl, wNPCMovementDirections2 - add l - ld l, a - jr nc, .loop - inc h -.loop - ld a, [hld] - call ConvertNPCMovementDirectionToJoypadMask - ld [de], a - inc de - ld a, [hNPCMovementDirections2Index] - dec a - ld [hNPCMovementDirections2Index], a - jr nz, .loop - ret - -ConvertNPCMovementDirectionToJoypadMask: - push hl - ld b, a - ld hl, NPCMovementDirectionsToJoypadMasksTable -.loop - ld a, [hli] - cp $ff - jr z, .done - cp b - jr z, .loadJoypadMask - inc hl - jr .loop -.loadJoypadMask - ld a, [hl] -.done - pop hl - ret - -NPCMovementDirectionsToJoypadMasksTable: - db NPC_MOVEMENT_UP, D_UP - db NPC_MOVEMENT_DOWN, D_DOWN - db NPC_MOVEMENT_LEFT, D_LEFT - db NPC_MOVEMENT_RIGHT, D_RIGHT - db $ff - -; unreferenced - ret diff --git a/engine/overworld/oaks_aide.asm b/engine/overworld/oaks_aide.asm index 54ba6b7a..f5068fda 100755 --- a/engine/overworld/oaks_aide.asm +++ b/engine/overworld/oaks_aide.asm @@ -63,7 +63,7 @@ OaksAideHereYouGoText: OaksAideGotItemText: TX_FAR _OaksAideGotItemText - db $0b + TX_SFX_ITEM_1 db "@" OaksAideNoRoomText: diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm new file mode 100644 index 00000000..8cbacc61 --- /dev/null +++ b/engine/overworld/player_state.asm @@ -0,0 +1,456 @@ +; only used for setting bit 2 of wd736 upon entering a new map +IsPlayerStandingOnWarp: + ld a, [wNumberOfWarps] + and a + ret z + ld c, a + ld hl, wWarpEntries +.loop + ld a, [wYCoord] + cp [hl] + jr nz, .nextWarp1 + inc hl + ld a, [wXCoord] + cp [hl] + jr nz, .nextWarp2 + inc hl + ld a, [hli] ; target warp + ld [wDestinationWarpID], a + ld a, [hl] ; target map + ld [hWarpDestinationMap], a + ld hl, wd736 + set 2, [hl] ; standing on warp flag + ret +.nextWarp1 + inc hl +.nextWarp2 + inc hl + inc hl + inc hl + dec c + jr nz, .loop + ret + +CheckForceBikeOrSurf: + ld hl, wd732 + bit 5, [hl] + ret nz + ld hl, ForcedBikeOrSurfMaps + ld a, [wYCoord] + ld b, a + ld a, [wXCoord] + ld c, a + ld a, [wCurMap] + ld d, a +.loop + ld a, [hli] + cp $ff + ret z ;if we reach FF then it's not part of the list + cp d ;compare to current map + jr nz, .incorrectMap + ld a, [hli] + cp b ;compare y-coord + jr nz, .incorrectY + ld a, [hli] + cp c ;compare x-coord + jr nz, .loop ; incorrect x-coord, check next item + ld a, [wCurMap] + cp SEAFOAM_ISLANDS_B3F + ld a, $2 + ld [wSeafoamIslandsB3FCurScript], a + jr z, .forceSurfing + ld a, [wCurMap] + cp SEAFOAM_ISLANDS_B4F + ld a, $2 + ld [wSeafoamIslandsB4FCurScript], a + jr z, .forceSurfing + ;force bike riding + ld hl, wd732 + set 5, [hl] + ld a, $1 + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a + call ForceBikeOrSurf + ret +.incorrectMap + inc hl +.incorrectY + inc hl + jr .loop +.forceSurfing + ld a, $2 + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a + call ForceBikeOrSurf + ret + +INCLUDE "data/force_bike_surf.asm" + +IsPlayerFacingEdgeOfMap: + push hl + push de + push bc + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction + srl a + ld c, a + ld b, $0 + ld hl, .functionPointerTable + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wYCoord] + ld b, a + ld a, [wXCoord] + ld c, a + ld de, .returnaddress + push de + jp hl +.returnaddress + pop bc + pop de + pop hl + ret + +.functionPointerTable + dw .facingDown + dw .facingUp + dw .facingLeft + dw .facingRight + +.facingDown + ld a, [wCurMapHeight] + add a + dec a + cp b + jr z, .setCarry + jr .resetCarry + +.facingUp + ld a, b + and a + jr z, .setCarry + jr .resetCarry + +.facingLeft + ld a, c + and a + jr z, .setCarry + jr .resetCarry + +.facingRight + ld a, [wCurMapWidth] + add a + dec a + cp c + jr z, .setCarry + jr .resetCarry +.resetCarry + and a + ret +.setCarry + scf + ret + +IsWarpTileInFrontOfPlayer: + push hl + push de + push bc + call _GetTileAndCoordsInFrontOfPlayer + ld a, [wCurMap] + cp SS_ANNE_BOW + jr z, .ssAnne5 + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction + srl a + ld c, a + ld b, 0 + ld hl, .warpTileListPointers + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wTileInFrontOfPlayer] + ld de, $1 + call IsInArray +.done + pop bc + pop de + pop hl + ret + +.warpTileListPointers: + dw .facingDownWarpTiles + dw .facingUpWarpTiles + dw .facingLeftWarpTiles + dw .facingRightWarpTiles + +.facingDownWarpTiles + db $01,$12,$17,$3D,$04,$18,$33,$FF + +.facingUpWarpTiles + db $01,$5C,$FF + +.facingLeftWarpTiles + db $1A,$4B,$FF + +.facingRightWarpTiles + db $0F,$4E,$FF + +.ssAnne5 + ld a, [wTileInFrontOfPlayer] + cp $15 + jr nz, .notSSAnne5Warp + scf + jr .done +.notSSAnne5Warp + and a + jr .done + +IsPlayerStandingOnDoorTileOrWarpTile: + push hl + push de + push bc + callba IsPlayerStandingOnDoorTile + jr c, .done + ld a, [wCurMapTileset] + add a + ld c, a + ld b, $0 + ld hl, WarpTileIDPointers + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld de, $1 + aCoord 8, 9 + call IsInArray + jr nc, .done + ld hl, wd736 + res 2, [hl] +.done + pop bc + pop de + pop hl + ret + +INCLUDE "data/warp_tile_ids.asm" + +PrintSafariZoneSteps: + ld a, [wCurMap] + cp SAFARI_ZONE_EAST + ret c + cp CERULEAN_CAVE_2F + ret nc + coord hl, 0, 0 + lb bc, 3, 7 + call TextBoxBorder + coord hl, 1, 1 + ld de, wSafariSteps + lb bc, 2, 3 + call PrintNumber + coord hl, 4, 1 + ld de, SafariSteps + call PlaceString + coord hl, 1, 3 + ld de, SafariBallText + call PlaceString + ld a, [wNumSafariBalls] + cp 10 + jr nc, .numSafariBallsTwoDigits + coord hl, 5, 3 + ld a, " " + ld [hl], a +.numSafariBallsTwoDigits + coord hl, 6, 3 + ld de, wNumSafariBalls + lb bc, 1, 2 + jp PrintNumber + +SafariSteps: + db "/500@" + +SafariBallText: + db "BALL×× @" + +GetTileAndCoordsInFrontOfPlayer: + call GetPredefRegisters + +_GetTileAndCoordsInFrontOfPlayer: + ld a, [wYCoord] + ld d, a + ld a, [wXCoord] + ld e, a + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + and a ; cp SPRITE_FACING_DOWN + jr nz, .notFacingDown +; facing down + aCoord 8, 11 + inc d + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up + aCoord 8, 7 + dec d + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left + aCoord 6, 9 + dec e + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right + aCoord 10, 9 + inc e +.storeTile + ld c, a + ld [wTileInFrontOfPlayer], a + ret + +GetTileTwoStepsInFrontOfPlayer: + xor a + ld [$ffdb], a + ld hl, wYCoord + ld a, [hli] + ld d, a + ld e, [hl] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + and a ; cp SPRITE_FACING_DOWN + jr nz, .notFacingDown +; facing down + ld hl, $ffdb + set 0, [hl] + aCoord 8, 13 + inc d + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up + ld hl, $ffdb + set 1, [hl] + aCoord 8, 5 + dec d + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left + ld hl, $ffdb + set 2, [hl] + aCoord 4, 9 + dec e + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right + ld hl, $ffdb + set 3, [hl] + aCoord 12, 9 + inc e +.storeTile + ld c, a + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a + ld [wTileInFrontOfPlayer], a + ret + +CheckForCollisionWhenPushingBoulder: + call GetTileTwoStepsInFrontOfPlayer + call IsTilePassable + jr c, .done + ld hl, TilePairCollisionsLand + call CheckForTilePairCollisions2 + ld a, $ff + 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, .done ; if the tile two steps ahead is stairs + call CheckForBoulderCollisionWithSprites +.done + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a + ret + +; sets a to $ff if there is a collision and $00 if there is no collision +CheckForBoulderCollisionWithSprites: + ld a, [wBoulderSpriteIndex] + dec a + swap a + ld d, 0 + ld e, a + ld hl, wSpriteStateData2 + $14 + add hl, de + ld a, [hli] ; map Y position + ld [$ffdc], a + ld a, [hl] ; map X position + ld [$ffdd], a + ld a, [wNumSprites] + ld c, a + ld de, $f + ld hl, wSpriteStateData2 + $14 + ld a, [$ffdb] + and $3 ; facing up or down? + jr z, .pushingHorizontallyLoop +.pushingVerticallyLoop + inc hl + ld a, [$ffdd] + cp [hl] + jr nz, .nextSprite1 ; if X coordinates don't match + dec hl + ld a, [hli] + ld b, a + ld a, [$ffdb] + rrca + jr c, .pushingDown +; pushing up + ld a, [$ffdc] + dec a + jr .compareYCoords +.pushingDown + ld a, [$ffdc] + inc a +.compareYCoords + cp b + jr z, .failure +.nextSprite1 + dec c + jr z, .success + add hl, de + jr .pushingVerticallyLoop +.pushingHorizontallyLoop + ld a, [hli] + ld b, a + ld a, [$ffdc] + cp b + jr nz, .nextSprite2 + ld b, [hl] + ld a, [$ffdb] + bit 2, a + jr nz, .pushingLeft +; pushing right + ld a, [$ffdd] + inc a + jr .compareXCoords +.pushingLeft + ld a, [$ffdd] + dec a +.compareXCoords + cp b + jr z, .failure +.nextSprite2 + dec c + jr z, .success + add hl, de + jr .pushingHorizontallyLoop +.failure + ld a, $ff + ret +.success + xor a + ret diff --git a/engine/overworld/step_functions.asm b/engine/overworld/poison.asm index 84b09291..03fb8a65 100644 --- a/engine/overworld/step_functions.asm +++ b/engine/overworld/poison.asm @@ -58,7 +58,7 @@ ApplyOutOfBattlePoisonDamage: xor a ld [wJoyIgnore], a call EnableAutoTextBoxDrawing - ld a, $d0 + ld a, TEXT_MON_FAINTED ld [hSpriteIndexOrTextID], a call DisplayTextID callab IsThisPartymonStarterPikachu_Party @@ -102,7 +102,7 @@ ApplyOutOfBattlePoisonDamage: and a ; are any party members poisoned? jr z, .skipPoisonEffectAndSound ld b, $2 - predef InvertBGPal_4Frames ; change BG white to dark grey for 4 frames + predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames ld a, SFX_POISONED call PlaySound .skipPoisonEffectAndSound @@ -111,7 +111,7 @@ ApplyOutOfBattlePoisonDamage: and a jr nz, .noBlackOut call EnableAutoTextBoxDrawing - ld a, $d1 + ld a, TEXT_BLACKED_OUT ld [hSpriteIndexOrTextID], a call DisplayTextID ld hl, wd72e diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm index 1801d9e9..cf0159f9 100755 --- a/engine/overworld/pokecenter.asm +++ b/engine/overworld/pokecenter.asm @@ -127,7 +127,7 @@ PokemonCenterWelcomeText: db "@" ShallWeHealYourPokemonText: - db $a + TX_DELAY TX_FAR _ShallWeHealYourPokemonText db "@" @@ -140,7 +140,7 @@ PokemonFightingFitText: db "@" PokemonCenterFarewellText: - db $a + TX_DELAY TX_FAR _PokemonCenterFarewellText db "@" diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 823939b1..dc5b29b5 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -1,230 +1,230 @@ DisplayPokemartDialogue_: - ld a,[wListScrollOffset] - ld [wSavedListScrollOffset],a + ld a, [wListScrollOffset] + ld [wSavedListScrollOffset], a call UpdateSprites xor a - ld [wBoughtOrSoldItemInMart],a + ld [wBoughtOrSoldItemInMart], a .loop xor a - ld [wListScrollOffset],a - ld [wCurrentMenuItem],a - ld [wPlayerMonNumber],a + ld [wListScrollOffset], a + ld [wCurrentMenuItem], a + ld [wPlayerMonNumber], a inc a - ld [wPrintItemPrices],a - ld a,MONEY_BOX - ld [wTextBoxID],a + ld [wPrintItemPrices], a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld a,BUY_SELL_QUIT_MENU - ld [wTextBoxID],a + ld a, BUY_SELL_QUIT_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; This code is useless. It copies the address of the pokemart's inventory to hl, ; but the address is never used. - ld hl,wItemListPointer - ld a,[hli] - ld l,[hl] - ld h,a + ld hl, wItemListPointer + ld a, [hli] + ld l, [hl] + ld h, a - ld a,[wMenuExitMethod] - cp a,CANCELLED_MENU - jp z,.done - ld a,[wChosenMenuItem] + ld a, [wMenuExitMethod] + cp CANCELLED_MENU + jp z, .done + ld a, [wChosenMenuItem] and a ; buying? - jp z,.buyMenu + jp z, .buyMenu dec a ; selling? - jp z,.sellMenu + jp z, .sellMenu dec a ; quitting? - jp z,.done + jp z, .done .sellMenu ; the same variables are set again below, so this code has no effect xor a - ld [wPrintItemPrices],a - ld a,INIT_BAG_ITEM_LIST - ld [wInitListType],a + ld [wPrintItemPrices], a + ld a, INIT_BAG_ITEM_LIST + ld [wInitListType], a callab InitList - ld a,[wNumBagItems] + ld a, [wNumBagItems] and a - jp z,.bagEmpty - ld hl,PokemonSellingGreetingText + jp z, .bagEmpty + ld hl, PokemonSellingGreetingText call PrintText call SaveScreenTilesToBuffer1 ; save screen .sellMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID ; draw money text box - ld hl,wNumBagItems - ld a,l - ld [wListPointer],a - ld a,h - ld [wListPointer + 1],a + ld hl, wNumBagItems + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a xor a - ld [wPrintItemPrices],a - ld [wCurrentMenuItem],a - ld a,ITEMLISTMENU - ld [wListMenuID],a + ld [wPrintItemPrices], a + ld [wCurrentMenuItem], a + ld a, ITEMLISTMENU + ld [wListMenuID], a call DisplayListMenuID - jp c,.returnToMainPokemartMenu ; if the player closed the menu + jp c, .returnToMainPokemartMenu ; if the player closed the menu .confirmItemSale ; if the player is trying to sell a specific item call IsKeyItem - ld a,[wIsKeyItem] + ld a, [wIsKeyItem] and a - jr nz,.unsellableItem - ld a,[wcf91] + jr nz, .unsellableItem + ld a, [wcf91] call IsItemHM - jr c,.unsellableItem - ld a,PRICEDITEMLISTMENU - ld [wListMenuID],a - ld [hHalveItemPrices],a ; halve prices when selling + jr c, .unsellableItem + ld a, PRICEDITEMLISTMENU + ld [wListMenuID], a + ld [hHalveItemPrices], a ; halve prices when selling call DisplayChooseQuantityMenu inc a - jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button - ld hl,PokemartTellSellPriceText + jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button + ld hl, PokemartTellSellPriceText lb bc, 14, 1 ; location that PrintText always prints to, this is useless call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wMenuExitMethod] - cp a,CHOSE_SECOND_ITEM - jr z,.sellMenuLoop ; if the player chose No or pressed the B button + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM + jr z, .sellMenuLoop ; if the player chose No or pressed the B button ; The following code is supposed to check if the player chose No, but the above ; check already catches it. - ld a,[wChosenMenuItem] + ld a, [wChosenMenuItem] dec a - jr z,.sellMenuLoop + jr z, .sellMenuLoop .sellItem - ld a,[wBoughtOrSoldItemInMart] + ld a, [wBoughtOrSoldItemInMart] and a - jr nz,.skipSettingFlag1 + jr nz, .skipSettingFlag1 inc a - ld [wBoughtOrSoldItemInMart],a + ld [wBoughtOrSoldItemInMart], a .skipSettingFlag1 call AddAmountSoldToMoney - ld hl,wNumBagItems + ld hl, wNumBagItems call RemoveItemFromInventory jp .sellMenuLoop .unsellableItem - ld hl,PokemartUnsellableItemText + ld hl, PokemartUnsellableItemText call PrintText jp .returnToMainPokemartMenu .bagEmpty - ld hl,PokemartItemBagEmptyText + ld hl, PokemartItemBagEmptyText call PrintText call SaveScreenTilesToBuffer1 jp .returnToMainPokemartMenu .buyMenu ; the same variables are set again below, so this code has no effect - ld a,1 - ld [wPrintItemPrices],a - ld a,INIT_OTHER_ITEM_LIST - ld [wInitListType],a + ld a, 1 + ld [wPrintItemPrices], a + ld a, INIT_OTHER_ITEM_LIST + ld [wInitListType], a callab InitList - ld hl,PokemartBuyingGreetingText + ld hl, PokemartBuyingGreetingText call PrintText call SaveScreenTilesToBuffer1 .buyMenuLoop call LoadScreenTilesFromBuffer1 - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld hl,wItemList - ld a,l - ld [wListPointer],a - ld a,h - ld [wListPointer + 1],a + ld hl, wItemList + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a xor a - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a inc a - ld [wPrintItemPrices],a + ld [wPrintItemPrices], a inc a ; a = 2 (PRICEDITEMLISTMENU) - ld [wListMenuID],a + ld [wListMenuID], a call DisplayListMenuID - jr c,.returnToMainPokemartMenu ; if the player closed the menu - ld a,99 - ld [wMaxItemQuantity],a + jr c, .returnToMainPokemartMenu ; if the player closed the menu + ld a, 99 + ld [wMaxItemQuantity], a xor a - ld [hHalveItemPrices],a ; don't halve item prices when buying + ld [hHalveItemPrices], a ; don't halve item prices when buying call DisplayChooseQuantityMenu inc a - jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button - ld a,[wcf91] ; item ID - ld [wd11e],a ; store item ID for GetItemName + jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button + ld a, [wcf91] ; item ID + ld [wd11e], a ; store item ID for GetItemName call GetItemName call CopyStringToCF4B ; copy name to wcf4b - ld hl,PokemartTellBuyPriceText + ld hl, PokemartTellBuyPriceText call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wMenuExitMethod] - cp a,CHOSE_SECOND_ITEM - jp z,.buyMenuLoop ; if the player chose No or pressed the B button + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM + jp z, .buyMenuLoop ; if the player chose No or pressed the B button ; The following code is supposed to check if the player chose No, but the above ; check already catches it. - ld a,[wChosenMenuItem] + ld a, [wChosenMenuItem] dec a - jr z,.buyMenuLoop + jr z, .buyMenuLoop .buyItem call .isThereEnoughMoney - jr c,.notEnoughMoney - ld hl,wNumBagItems + jr c, .notEnoughMoney + ld hl, wNumBagItems call AddItemToInventory - jr nc,.bagFull + jr nc, .bagFull call SubtractAmountPaidFromMoney - ld a,[wBoughtOrSoldItemInMart] + ld a, [wBoughtOrSoldItemInMart] and a - jr nz,.skipSettingFlag2 - ld a,1 - ld [wBoughtOrSoldItemInMart],a + jr nz, .skipSettingFlag2 + ld a, 1 + ld [wBoughtOrSoldItemInMart], a .skipSettingFlag2 - ld a,SFX_PURCHASE + ld a, SFX_PURCHASE call PlaySoundWaitForCurrent call WaitForSoundToFinish - ld hl,PokemartBoughtItemText + ld hl, PokemartBoughtItemText call PrintText jp .buyMenuLoop .returnToMainPokemartMenu call LoadScreenTilesFromBuffer1 - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld hl,PokemartAnythingElseText + ld hl, PokemartAnythingElseText call PrintText jp .loop .isThereEnoughMoney - ld de,wPlayerMoney - ld hl,hMoney - ld c,3 ; length of money in bytes + ld de, wPlayerMoney + ld hl, hMoney + ld c, 3 ; length of money in bytes jp StringCmp .notEnoughMoney - ld hl,PokemartNotEnoughMoneyText + ld hl, PokemartNotEnoughMoneyText call PrintText jr .returnToMainPokemartMenu .bagFull - ld hl,PokemartItemBagFullText + ld hl, PokemartItemBagFullText call PrintText jr .returnToMainPokemartMenu .done - ld hl,PokemartThankYouText + ld hl, PokemartThankYouText call PrintText - ld a,1 - ld [wUpdateSpritesEnabled],a + ld a, 1 + ld [wUpdateSpritesEnabled], a call UpdateSprites - ld a,[wSavedListScrollOffset] - ld [wListScrollOffset],a + ld a, [wSavedListScrollOffset] + ld [wListScrollOffset], a ret PokemartBuyingGreetingText: diff --git a/engine/overworld/print_safari_steps.asm b/engine/overworld/print_safari_steps.asm deleted file mode 100644 index 01dd34e0..00000000 --- a/engine/overworld/print_safari_steps.asm +++ /dev/null @@ -1,36 +0,0 @@ -PrintSafariZoneSteps: - ld a, [wCurMap] - cp SAFARI_ZONE_EAST - ret c - cp UNKNOWN_DUNGEON_2 - ret nc - coord hl, 0, 0 - lb bc, 3, 7 - call TextBoxBorder - coord hl, 1, 1 - ld de, wSafariSteps - lb bc, 2, 3 - call PrintNumber - coord hl, 4, 1 - ld de, SafariSteps - call PlaceString - coord hl, 1, 3 - ld de, SafariBallText - call PlaceString - ld a, [wNumSafariBalls] - cp 10 - jr nc, .numSafariBallsTwoDigits - coord hl, 5, 3 - ld a, " " - ld [hl], a -.numSafariBallsTwoDigits - coord hl, 6, 3 - ld de, wNumSafariBalls - lb bc, 1, 2 - jp PrintNumber - -SafariSteps: - db "/500@" - -SafariBallText: - db "BALL×× @" diff --git a/engine/overworld/try_pushing_boulder.asm b/engine/overworld/push_boulder.asm index 8a385345..8a385345 100644 --- a/engine/overworld/try_pushing_boulder.asm +++ b/engine/overworld/push_boulder.asm diff --git a/engine/overworld/set_blackout_map.asm b/engine/overworld/set_blackout_map.asm index 9bfe82bd..bac2f0ca 100644 --- a/engine/overworld/set_blackout_map.asm +++ b/engine/overworld/set_blackout_map.asm @@ -23,7 +23,7 @@ SetLastBlackoutMap: ret SafariZoneRestHouses: - db SAFARI_ZONE_REST_HOUSE_2 - db SAFARI_ZONE_REST_HOUSE_3 - db SAFARI_ZONE_REST_HOUSE_4 + db SAFARI_ZONE_WEST_REST_HOUSE + db SAFARI_ZONE_EAST_REST_HOUSE + db SAFARI_ZONE_NORTH_REST_HOUSE db -1 diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm deleted file mode 100644 index 4814e668..00000000 --- a/engine/overworld/special_warps.asm +++ /dev/null @@ -1,147 +0,0 @@ -SpecialWarpIn: - call LoadSpecialWarpData - predef LoadTilesetHeader - ld hl,wd732 - bit 2,[hl] ; dungeon warp or fly warp? - res 2,[hl] - jr z,.next -; if dungeon warp or fly warp - ld a,[wDestinationMap] - jr .next2 -.next - bit 1,[hl] - jr z,.next3 - call EmptyFunc -.next3 - ld a,0 -.next2 - ld b,a - ld a,[wd72d] - and a - jr nz,.next4 - ld a,b -.next4 - ld hl,wd732 - bit 4,[hl] ; dungeon warp? - ret nz -; if not dungeon warp - ld [wLastMap],a - ret - -; gets the map ID, tile block map view pointer, tileset, and coordinates -LoadSpecialWarpData: - ld a, [wd72d] - cp TRADE_CENTER - jr nz, .notTradeCenter - ld hl, TradeCenterSpec1 - ld a, [hSerialConnectionStatus] - cp USING_INTERNAL_CLOCK ; which gameboy is clocking determines who is on the left and who is on the right - jr z, .copyWarpData - ld hl, TradeCenterSpec2 - jr .copyWarpData -.notTradeCenter - cp COLOSSEUM - jr nz, .notColosseum - ld hl, ColosseumSpec1 - ld a, [hSerialConnectionStatus] - cp USING_INTERNAL_CLOCK - jr z, .copyWarpData - ld hl, ColosseumSpec2 - jr .copyWarpData -.notColosseum - ld a, [wd732] - bit 1, a - jr nz, .notFirstMap - bit 2, a - jr nz, .notFirstMap - ld hl, FirstMapSpec -.copyWarpData - ld de, wCurMap - ld c, $7 -.copyWarpDataLoop - ld a, [hli] - ld [de], a - inc de - dec c - jr nz, .copyWarpDataLoop - ld a, [hli] - ld [wCurMapTileset], a - xor a - jr .done -.notFirstMap - ld a, [wLastMap] ; this value is overwritten before it's ever read - ld hl, wd732 - 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, .otherDestination -; return to last pokemon center or player's house - ld a, [wLastBlackoutMap] - jr .usedFlyWarp -.usedDunegonWarp - ld hl, wd72d - res 4, [hl] - ld a, [wDungeonWarpDestinationMap] - ld b, a - ld [wCurMap], a - ld a, [wWhichDungeonWarp] - ld c, a - ld hl, DungeonWarpList - ld de, 0 - ld a, 6 - ld [wDungeonWarpDataEntrySize], a -.dungeonWarpListLoop - ld a, [hli] - cp b - jr z, .matchedDungeonWarpDestinationMap - inc hl - jr .nextDungeonWarp -.matchedDungeonWarpDestinationMap - ld a, [hli] - cp c - jr z, .matchedDungeonWarpID -.nextDungeonWarp - ld a, [wDungeonWarpDataEntrySize] - add e - ld e, a - jr .dungeonWarpListLoop -.matchedDungeonWarpID - ld hl, DungeonWarpData - add hl, de - jr .copyWarpData2 -.otherDestination - ld a, [wDestinationMap] -.usedFlyWarp - ld b, a - ld [wCurMap], a - ld hl, FlyWarpDataPtr -.flyWarpDataPtrLoop - ld a, [hli] - inc hl - cp b - jr z, .foundFlyWarpMatch - inc hl - inc hl - jr .flyWarpDataPtrLoop -.foundFlyWarpMatch - ld a, [hli] - ld h, [hl] - ld l, a -.copyWarpData2 - ld de, wCurrentTileBlockMapViewPointer - ld c, $6 -.copyWarpDataLoop2 - ld a, [hli] - ld [de], a - inc de - dec c - jr nz, .copyWarpDataLoop2 - xor a ; OVERWORLD - ld [wCurMapTileset], 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 diff --git a/engine/overworld/load_tileset_header.asm b/engine/overworld/tileset_header.asm index 05061651..05061651 100644 --- a/engine/overworld/load_tileset_header.asm +++ b/engine/overworld/tileset_header.asm diff --git a/engine/overworld/replace_tile_block.asm b/engine/overworld/update_map.asm index 8577b9e7..8577b9e7 100644 --- a/engine/overworld/replace_tile_block.asm +++ b/engine/overworld/update_map.asm diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm new file mode 100644 index 00000000..dae57f23 --- /dev/null +++ b/engine/overworld/wild_mons.asm @@ -0,0 +1,33 @@ +LoadWildData: + ld hl, WildDataPointers + ld a, [wCurMap] + + ; get wild data for current map + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a ; hl now points to wild data for current map + ld a, [hli] + ld [wGrassRate], a + and a + jr z, .NoGrassData ; if no grass data, skip to surfing data + push hl + ld de, wGrassMons ; otherwise, load grass data + ld bc, $0014 + call CopyData + pop hl + ld bc, $0014 + add hl, bc +.NoGrassData + ld a, [hli] + ld [wWaterRate], a + and a + ret z ; if no water data, we're done + ld de, wWaterMons ; otherwise, load surfing data + ld bc, $0014 + jp CopyData + +INCLUDE "data/wild_mons.asm" |