diff options
Diffstat (limited to 'engine/overworld')
-rw-r--r-- | engine/overworld/decorations.asm | 5 | ||||
-rw-r--r-- | engine/overworld/events.asm | 613 | ||||
-rw-r--r-- | engine/overworld/events_2.asm | 617 | ||||
-rw-r--r-- | engine/overworld/landmarks.asm | 3 | ||||
-rw-r--r-- | engine/overworld/map_objects.asm | 2 | ||||
-rw-r--r-- | engine/overworld/map_setup.asm | 1 | ||||
-rw-r--r-- | engine/overworld/movement.asm | 7 | ||||
-rw-r--r-- | engine/overworld/npc_movement.asm | 11 | ||||
-rw-r--r-- | engine/overworld/overworld.asm | 17 | ||||
-rw-r--r-- | engine/overworld/player_movement.asm | 5 | ||||
-rw-r--r-- | engine/overworld/scripting.asm | 13 | ||||
-rw-r--r-- | engine/overworld/select_menu.asm | 8 | ||||
-rw-r--r-- | engine/overworld/spawn_points.asm | 2 | ||||
-rw-r--r-- | engine/overworld/time.asm | 2 | ||||
-rw-r--r-- | engine/overworld/warp_connection.asm | 2 | ||||
-rw-r--r-- | engine/overworld/wildmons.asm | 7 |
16 files changed, 613 insertions, 702 deletions
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm index a9e127b41..7ba177420 100644 --- a/engine/overworld/decorations.asm +++ b/engine/overworld/decorations.asm @@ -415,7 +415,6 @@ PopulateDecoCategoryMenu: dbw 0, 0 dbw 0, 0 - GetDecorationData: ld hl, DecorationAttributes ld bc, 6 @@ -466,7 +465,6 @@ DoDecorationAction2: dw DecoAction_setupornament dw DecoAction_putawayornament - GetDecorationFlag: call GetDecorationData ld de, 3 ; event flag @@ -515,7 +513,6 @@ GetDecoName: dw .doll dw .bigdoll - .invalid ret @@ -922,7 +919,6 @@ DecorationFlagAction_c: ld a, c jp DecorationFlagAction - GetDecorationName_c: ld a, c call GetDecorationID @@ -932,7 +928,6 @@ GetDecorationName_c: pop de ret - SetSpecificDecorationFlag: ld a, c call GetDecorationID diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index daa7b8414..707d31e66 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -485,7 +485,6 @@ CheckTimeEvents: ret OWPlayerInput: - call PlayerMovement ret c and a @@ -1026,4 +1025,614 @@ ChangeDirectionScript: ; 9 INCLUDE "engine/overworld/scripting.asm" -INCLUDE "engine/overworld/events_2.asm" +WarpToSpawnPoint:: + ld hl, wStatusFlags2 + res STATUSFLAGS2_SAFARI_GAME_F, [hl] + res STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl] + ret + +RunMemScript:: +; If there is no script here, we don't need to be here. + ld a, [wMapReentryScriptQueueFlag] + and a + ret z +; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress). + ld hl, wMapReentryScriptAddress + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wMapReentryScriptBank] + call CallScript + scf +; Clear the buffer for the next script. + push af + xor a + ld hl, wMapReentryScriptQueueFlag + ld bc, 8 + call ByteFill + pop af + ret + +LoadScriptBDE:: +; If there's already a script here, don't overwrite. + ld hl, wMapReentryScriptQueueFlag + ld a, [hl] + and a + ret nz +; Set the flag + ld [hl], 1 + inc hl +; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress) + ld [hl], b + inc hl + ld [hl], e + inc hl + ld [hl], d + scf + ret + +TryTileCollisionEvent:: + call GetFacingTileCoord + ld [wEngineBuffer1], a + ld c, a + farcall CheckFacingTileForStdScript + jr c, .done + + call CheckCutTreeTile + jr nz, .whirlpool + farcall TryCutOW + jr .done + +.whirlpool + ld a, [wEngineBuffer1] + call CheckWhirlpoolTile + jr nz, .waterfall + farcall TryWhirlpoolOW + jr .done + +.waterfall + ld a, [wEngineBuffer1] + call CheckWaterfallTile + jr nz, .headbutt + farcall TryWaterfallOW + jr .done + +.headbutt + ld a, [wEngineBuffer1] + call CheckHeadbuttTreeTile + jr nz, .surf + farcall TryHeadbuttOW + jr c, .done + jr .noevent + +.surf + farcall TrySurfOW + jr nc, .noevent + jr .done + +.noevent + xor a + ret + +.done + call PlayClickSFX + ld a, $ff + scf + ret + +RandomEncounter:: +; Random encounter + + call CheckWildEncounterCooldown + jr c, .nope + call CanUseSweetScent + jr nc, .nope + ld hl, wStatusFlags2 + bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl] + jr nz, .bug_contest + farcall TryWildEncounter + jr nz, .nope + jr .ok + +.bug_contest + call _TryWildEncounter_BugContest + jr nc, .nope + jr .ok_bug_contest + +.nope + ld a, 1 + and a + ret + +.ok + ld a, BANK(WildBattleScript) + ld hl, WildBattleScript + jr .done + +.ok_bug_contest + ld a, BANK(BugCatchingContestBattleScript) + ld hl, BugCatchingContestBattleScript + jr .done + +.done + call CallScript + scf + ret + +WildBattleScript: + randomwildmon + startbattle + reloadmapafterbattle + end + +CanUseSweetScent:: + ld hl, wStatusFlags + bit STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl] + jr nz, .no + ld a, [wEnvironment] + cp CAVE + jr z, .ice_check + cp DUNGEON + jr z, .ice_check + farcall CheckGrassCollision + jr nc, .no + +.ice_check + ld a, [wPlayerStandingTile] + call CheckIceTile + jr z, .no + scf + ret + +.no + and a + ret + +_TryWildEncounter_BugContest: + call TryWildEncounter_BugContest + ret nc + call ChooseWildEncounter_BugContest + farcall CheckRepelEffect + ret + +ChooseWildEncounter_BugContest:: +; Pick a random mon out of ContestMons. + +.loop + call Random + cp 100 << 1 + jr nc, .loop + srl a + + ld hl, ContestMons + ld de, 4 +.CheckMon: + sub [hl] + jr c, .GotMon + add hl, de + jr .CheckMon + +.GotMon: + inc hl + +; Species + ld a, [hli] + ld [wTempWildMonSpecies], a + +; Min level + ld a, [hli] + ld d, a + +; Max level + ld a, [hl] + + sub d + jr nz, .RandomLevel + +; If min and max are the same. + ld a, d + jr .GotLevel + +.RandomLevel: +; Get a random level between the min and max. + ld c, a + inc c + call Random + ld a, [hRandomAdd] + call SimpleDivide + add d + +.GotLevel: + ld [wCurPartyLevel], a + + xor a + ret + +TryWildEncounter_BugContest: + ld a, [wPlayerStandingTile] + call CheckSuperTallGrassTile + ld b, 40 percent + jr z, .ok + ld b, 20 percent + +.ok + farcall ApplyMusicEffectOnEncounterRate + farcall ApplyCleanseTagEffectOnEncounterRate + call Random + ld a, [hRandomAdd] + cp b + ret c + ld a, 1 + and a + ret + +INCLUDE "data/wild/bug_contest_mons.asm" + +DoBikeStep:: + nop + nop + ; If the bike shop owner doesn't have our number, or + ; if we've already gotten the call, we don't have to + ; be here. + ld hl, wStatusFlags2 + bit STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl] + jr z, .NoCall + + ; If we're not on the bike, we don't have to be here. + ld a, [wPlayerState] + cp PLAYER_BIKE + jr nz, .NoCall + + ; If we're not in an area of phone service, we don't + ; have to be here. + call GetMapPhoneService + and a + jr nz, .NoCall + + ; Check the bike step count and check whether we've + ; taken 65536 of them yet. + ld hl, wBikeStep + ld a, [hli] + ld d, a + ld e, [hl] + cp 255 + jr nz, .increment + ld a, e + cp 255 + jr z, .dont_increment + +.increment + inc de + ld [hl], e + dec hl + ld [hl], d + +.dont_increment + ; If we've taken at least 1024 steps, have the bike + ; shop owner try to call us. + ld a, d + cp HIGH(1024) + jr c, .NoCall + + ; If a call has already been queued, don't overwrite + ; that call. + ld a, [wSpecialPhoneCallID] + and a + jr nz, .NoCall + + ; Queue the call. + ld a, SPECIALCALL_BIKESHOP + ld [wSpecialPhoneCallID], a + xor a + ld [wSpecialPhoneCallID + 1], a + ld hl, wStatusFlags2 + res STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl] + scf + ret + +.NoCall: + xor a + ret + +ClearCmdQueue:: + ld hl, wCmdQueue + ld de, 6 + ld c, 4 + xor a +.loop + ld [hl], a + add hl, de + dec c + jr nz, .loop + ret + +HandleCmdQueue:: + ld hl, wCmdQueue + xor a +.loop + ld [hMapObjectIndexBuffer], a + ld a, [hl] + and a + jr z, .skip + push hl + ld b, h + ld c, l + call HandleQueuedCommand + pop hl + +.skip + ld de, CMDQUEUE_ENTRY_SIZE + add hl, de + ld a, [hMapObjectIndexBuffer] + inc a + cp CMDQUEUE_CAPACITY + jr nz, .loop + ret + +Unreferenced_GetNthCmdQueueEntry: + ld hl, wCmdQueue + ld bc, CMDQUEUE_ENTRY_SIZE + call AddNTimes + ld b, h + ld c, l + ret + +WriteCmdQueue:: + push bc + push de + call .GetNextEmptyEntry + ld d, h + ld e, l + pop hl + pop bc + ret c + ld a, b + ld bc, CMDQUEUE_ENTRY_SIZE - 1 + call FarCopyBytes + xor a + ld [hl], a + ret + +.GetNextEmptyEntry: + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY +.loop + ld a, [hl] + and a + jr z, .done + add hl, de + dec c + jr nz, .loop + scf + ret + +.done + ld a, CMDQUEUE_CAPACITY + sub c + and a + ret + +DelCmdQueue:: + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY +.loop + ld a, [hl] + cp b + jr z, .done + add hl, de + dec c + jr nz, .loop + and a + ret + +.done + xor a + ld [hl], a + scf + ret + +_DelCmdQueue: + ld hl, CMDQUEUE_TYPE + add hl, bc + ld [hl], 0 + ret + +HandleQueuedCommand: + ld hl, CMDQUEUE_TYPE + add hl, bc + ld a, [hl] + cp 5 + jr c, .okay + xor a + +.okay + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + add hl, de + ld a, [hli] + push af + ld a, [hli] + ld h, [hl] + ld l, a + pop af + rst FarCall + ret + +.Jumptable: + dba CmdQueue_Null + dba CmdQueue_Null2 + dba CmdQueue_StoneTable + dba CmdQueue_Type3 + dba CmdQueue_Type4 + +CmdQueueAnonymousJumptable: + ld hl, CMDQUEUE_05 + add hl, bc + ld a, [hl] + pop hl + rst JumpTable + ret + +CmdQueueAnonJT_Increment: + ld hl, CMDQUEUE_05 + add hl, bc + inc [hl] + ret + +CmdQueueAnonJT_Decrement: + ld hl, CMDQUEUE_05 + add hl, bc + dec [hl] + ret + +CmdQueue_Null: + ret + +CmdQueue_Null2: + call ret_2f3e + ret + +CmdQueue_Type4: + call CmdQueueAnonymousJumptable + ; anonymous dw + dw .zero + dw .one + +.zero + ld a, [hSCY] + ld hl, 4 + add hl, bc + ld [hl], a + call CmdQueueAnonJT_Increment +.one + ld hl, 1 + add hl, bc + ld a, [hl] + dec a + ld [hl], a + jr z, .finish + and $1 + jr z, .add + ld hl, 2 + add hl, bc + ld a, [hSCY] + sub [hl] + ld [hSCY], a + ret + +.add + ld hl, 2 + add hl, bc + ld a, [hSCY] + add [hl] + ld [hSCY], a + ret + +.finish + ld hl, 4 + add hl, bc + ld a, [hl] + ld [hSCY], a + call _DelCmdQueue + ret + +CmdQueue_Type3: + call CmdQueueAnonymousJumptable + ; anonymous dw + dw .zero + dw .one + dw .two + +.zero + call .IsPlayerFacingDown + jr z, .PlayerNotFacingDown + call CmdQueueAnonJT_Increment +.one + call .IsPlayerFacingDown + jr z, .PlayerNotFacingDown + call CmdQueueAnonJT_Increment + + ld hl, 2 + add hl, bc + ld a, [hl] + ld [wd173], a + ret + +.two + call .IsPlayerFacingDown + jr z, .PlayerNotFacingDown + call CmdQueueAnonJT_Decrement + + ld hl, 3 + add hl, bc + ld a, [hl] + ld [wd173], a + ret + +.PlayerNotFacingDown: + ld a, $7f + ld [wd173], a + ld hl, 5 + add hl, bc + ld [hl], 0 + ret + +.IsPlayerFacingDown: + push bc + ld bc, wPlayerStruct + call GetSpriteDirection + and a + pop bc + ret + +CmdQueue_StoneTable: + ld de, wPlayerStruct + ld a, NUM_OBJECT_STRUCTS +.loop + push af + + ld hl, OBJECT_SPRITE + add hl, de + ld a, [hl] + and a + jr z, .next + + ld hl, OBJECT_MOVEMENTTYPE + add hl, de + ld a, [hl] + cp SPRITEMOVEDATA_STRENGTH_BOULDER + jr nz, .next + + ld hl, OBJECT_NEXT_TILE + add hl, de + ld a, [hl] + call CheckPitTile + jr nz, .next + + ld hl, OBJECT_DIRECTION_WALKING + add hl, de + ld a, [hl] + cp STANDING + jr nz, .next + call HandleStoneQueue + jr c, .fall_down_hole + +.next + ld hl, OBJECT_STRUCT_LENGTH + add hl, de + ld d, h + ld e, l + + pop af + dec a + jr nz, .loop + ret + +.fall_down_hole + pop af + ret diff --git a/engine/overworld/events_2.asm b/engine/overworld/events_2.asm deleted file mode 100644 index b7376d48d..000000000 --- a/engine/overworld/events_2.asm +++ /dev/null @@ -1,617 +0,0 @@ -; More overworld event handling. - - -WarpToSpawnPoint:: - ld hl, wStatusFlags2 - res STATUSFLAGS2_SAFARI_GAME_F, [hl] - res STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl] - ret - -RunMemScript:: -; If there is no script here, we don't need to be here. - ld a, [wMapReentryScriptQueueFlag] - and a - ret z -; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress). - ld hl, wMapReentryScriptAddress - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wMapReentryScriptBank] - call CallScript - scf -; Clear the buffer for the next script. - push af - xor a - ld hl, wMapReentryScriptQueueFlag - ld bc, 8 - call ByteFill - pop af - ret - -LoadScriptBDE:: -; If there's already a script here, don't overwrite. - ld hl, wMapReentryScriptQueueFlag - ld a, [hl] - and a - ret nz -; Set the flag - ld [hl], 1 - inc hl -; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress) - ld [hl], b - inc hl - ld [hl], e - inc hl - ld [hl], d - scf - ret - -TryTileCollisionEvent:: - call GetFacingTileCoord - ld [wEngineBuffer1], a - ld c, a - farcall CheckFacingTileForStdScript - jr c, .done - - call CheckCutTreeTile - jr nz, .whirlpool - farcall TryCutOW - jr .done - -.whirlpool - ld a, [wEngineBuffer1] - call CheckWhirlpoolTile - jr nz, .waterfall - farcall TryWhirlpoolOW - jr .done - -.waterfall - ld a, [wEngineBuffer1] - call CheckWaterfallTile - jr nz, .headbutt - farcall TryWaterfallOW - jr .done - -.headbutt - ld a, [wEngineBuffer1] - call CheckHeadbuttTreeTile - jr nz, .surf - farcall TryHeadbuttOW - jr c, .done - jr .noevent - -.surf - farcall TrySurfOW - jr nc, .noevent - jr .done - -.noevent - xor a - ret - -.done - call PlayClickSFX - ld a, $ff - scf - ret - - -RandomEncounter:: -; Random encounter - - call CheckWildEncounterCooldown - jr c, .nope - call CanUseSweetScent - jr nc, .nope - ld hl, wStatusFlags2 - bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl] - jr nz, .bug_contest - farcall TryWildEncounter - jr nz, .nope - jr .ok - -.bug_contest - call _TryWildEncounter_BugContest - jr nc, .nope - jr .ok_bug_contest - -.nope - ld a, 1 - and a - ret - -.ok - ld a, BANK(WildBattleScript) - ld hl, WildBattleScript - jr .done - -.ok_bug_contest - ld a, BANK(BugCatchingContestBattleScript) - ld hl, BugCatchingContestBattleScript - jr .done - -.done - call CallScript - scf - ret - -WildBattleScript: - randomwildmon - startbattle - reloadmapafterbattle - end - -CanUseSweetScent:: - ld hl, wStatusFlags - bit STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl] - jr nz, .no - ld a, [wEnvironment] - cp CAVE - jr z, .ice_check - cp DUNGEON - jr z, .ice_check - farcall CheckGrassCollision - jr nc, .no - -.ice_check - ld a, [wPlayerStandingTile] - call CheckIceTile - jr z, .no - scf - ret - -.no - and a - ret - -_TryWildEncounter_BugContest: - call TryWildEncounter_BugContest - ret nc - call ChooseWildEncounter_BugContest - farcall CheckRepelEffect - ret - -ChooseWildEncounter_BugContest:: -; Pick a random mon out of ContestMons. - -.loop - call Random - cp 100 << 1 - jr nc, .loop - srl a - - ld hl, ContestMons - ld de, 4 -.CheckMon: - sub [hl] - jr c, .GotMon - add hl, de - jr .CheckMon - -.GotMon: - inc hl - -; Species - ld a, [hli] - ld [wTempWildMonSpecies], a - -; Min level - ld a, [hli] - ld d, a - -; Max level - ld a, [hl] - - sub d - jr nz, .RandomLevel - -; If min and max are the same. - ld a, d - jr .GotLevel - -.RandomLevel: -; Get a random level between the min and max. - ld c, a - inc c - call Random - ld a, [hRandomAdd] - call SimpleDivide - add d - -.GotLevel: - ld [wCurPartyLevel], a - - xor a - ret - -TryWildEncounter_BugContest: - ld a, [wPlayerStandingTile] - call CheckSuperTallGrassTile - ld b, 40 percent - jr z, .ok - ld b, 20 percent - -.ok - farcall ApplyMusicEffectOnEncounterRate - farcall ApplyCleanseTagEffectOnEncounterRate - call Random - ld a, [hRandomAdd] - cp b - ret c - ld a, 1 - and a - ret - - -INCLUDE "data/wild/bug_contest_mons.asm" - - -DoBikeStep:: - nop - nop - ; If the bike shop owner doesn't have our number, or - ; if we've already gotten the call, we don't have to - ; be here. - ld hl, wStatusFlags2 - bit STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl] - jr z, .NoCall - - ; If we're not on the bike, we don't have to be here. - ld a, [wPlayerState] - cp PLAYER_BIKE - jr nz, .NoCall - - ; If we're not in an area of phone service, we don't - ; have to be here. - call GetMapPhoneService - and a - jr nz, .NoCall - - ; Check the bike step count and check whether we've - ; taken 65536 of them yet. - ld hl, wBikeStep - ld a, [hli] - ld d, a - ld e, [hl] - cp 255 - jr nz, .increment - ld a, e - cp 255 - jr z, .dont_increment - -.increment - inc de - ld [hl], e - dec hl - ld [hl], d - -.dont_increment - ; If we've taken at least 1024 steps, have the bike - ; shop owner try to call us. - ld a, d - cp HIGH(1024) - jr c, .NoCall - - ; If a call has already been queued, don't overwrite - ; that call. - ld a, [wSpecialPhoneCallID] - and a - jr nz, .NoCall - - ; Queue the call. - ld a, SPECIALCALL_BIKESHOP - ld [wSpecialPhoneCallID], a - xor a - ld [wSpecialPhoneCallID + 1], a - ld hl, wStatusFlags2 - res STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl] - scf - ret - -.NoCall: - xor a - ret - -ClearCmdQueue:: - ld hl, wCmdQueue - ld de, 6 - ld c, 4 - xor a -.loop - ld [hl], a - add hl, de - dec c - jr nz, .loop - ret - -HandleCmdQueue:: - ld hl, wCmdQueue - xor a -.loop - ld [hMapObjectIndexBuffer], a - ld a, [hl] - and a - jr z, .skip - push hl - ld b, h - ld c, l - call HandleQueuedCommand - pop hl - -.skip - ld de, CMDQUEUE_ENTRY_SIZE - add hl, de - ld a, [hMapObjectIndexBuffer] - inc a - cp CMDQUEUE_CAPACITY - jr nz, .loop - ret - -Unreferenced_GetNthCmdQueueEntry: - ld hl, wCmdQueue - ld bc, CMDQUEUE_ENTRY_SIZE - call AddNTimes - ld b, h - ld c, l - ret - -WriteCmdQueue:: - push bc - push de - call .GetNextEmptyEntry - ld d, h - ld e, l - pop hl - pop bc - ret c - ld a, b - ld bc, CMDQUEUE_ENTRY_SIZE - 1 - call FarCopyBytes - xor a - ld [hl], a - ret - -.GetNextEmptyEntry: - ld hl, wCmdQueue - ld de, CMDQUEUE_ENTRY_SIZE - ld c, CMDQUEUE_CAPACITY -.loop - ld a, [hl] - and a - jr z, .done - add hl, de - dec c - jr nz, .loop - scf - ret - -.done - ld a, CMDQUEUE_CAPACITY - sub c - and a - ret - -DelCmdQueue:: - ld hl, wCmdQueue - ld de, CMDQUEUE_ENTRY_SIZE - ld c, CMDQUEUE_CAPACITY -.loop - ld a, [hl] - cp b - jr z, .done - add hl, de - dec c - jr nz, .loop - and a - ret - -.done - xor a - ld [hl], a - scf - ret - -_DelCmdQueue: - ld hl, CMDQUEUE_TYPE - add hl, bc - ld [hl], 0 - ret - -HandleQueuedCommand: - ld hl, CMDQUEUE_TYPE - add hl, bc - ld a, [hl] - cp 5 - jr c, .okay - xor a - -.okay - ld e, a - ld d, 0 - ld hl, .Jumptable - add hl, de - add hl, de - add hl, de - ld a, [hli] - push af - ld a, [hli] - ld h, [hl] - ld l, a - pop af - rst FarCall - ret - -.Jumptable: - dba CmdQueue_Null - dba CmdQueue_Null2 - dba CmdQueue_StoneTable - dba CmdQueue_Type3 - dba CmdQueue_Type4 - -CmdQueueAnonymousJumptable: - ld hl, CMDQUEUE_05 - add hl, bc - ld a, [hl] - pop hl - rst JumpTable - ret - -CmdQueueAnonJT_Increment: - ld hl, CMDQUEUE_05 - add hl, bc - inc [hl] - ret - -CmdQueueAnonJT_Decrement: - ld hl, CMDQUEUE_05 - add hl, bc - dec [hl] - ret - -CmdQueue_Null: - ret - -CmdQueue_Null2: - call ret_2f3e - ret - -CmdQueue_Type4: - call CmdQueueAnonymousJumptable - ; anonymous dw - dw .zero - dw .one - -.zero - ld a, [hSCY] - ld hl, 4 - add hl, bc - ld [hl], a - call CmdQueueAnonJT_Increment -.one - ld hl, 1 - add hl, bc - ld a, [hl] - dec a - ld [hl], a - jr z, .finish - and $1 - jr z, .add - ld hl, 2 - add hl, bc - ld a, [hSCY] - sub [hl] - ld [hSCY], a - ret - -.add - ld hl, 2 - add hl, bc - ld a, [hSCY] - add [hl] - ld [hSCY], a - ret - -.finish - ld hl, 4 - add hl, bc - ld a, [hl] - ld [hSCY], a - call _DelCmdQueue - ret - -CmdQueue_Type3: - call CmdQueueAnonymousJumptable - ; anonymous dw - dw .zero - dw .one - dw .two - -.zero - call .IsPlayerFacingDown - jr z, .PlayerNotFacingDown - call CmdQueueAnonJT_Increment -.one - call .IsPlayerFacingDown - jr z, .PlayerNotFacingDown - call CmdQueueAnonJT_Increment - - ld hl, 2 - add hl, bc - ld a, [hl] - ld [wd173], a - ret - -.two - call .IsPlayerFacingDown - jr z, .PlayerNotFacingDown - call CmdQueueAnonJT_Decrement - - ld hl, 3 - add hl, bc - ld a, [hl] - ld [wd173], a - ret - -.PlayerNotFacingDown: - ld a, $7f - ld [wd173], a - ld hl, 5 - add hl, bc - ld [hl], 0 - ret - -.IsPlayerFacingDown: - push bc - ld bc, wPlayerStruct - call GetSpriteDirection - and a - pop bc - ret - -CmdQueue_StoneTable: - ld de, wPlayerStruct - ld a, NUM_OBJECT_STRUCTS -.loop - push af - - ld hl, OBJECT_SPRITE - add hl, de - ld a, [hl] - and a - jr z, .next - - ld hl, OBJECT_MOVEMENTTYPE - add hl, de - ld a, [hl] - cp SPRITEMOVEDATA_STRENGTH_BOULDER - jr nz, .next - - ld hl, OBJECT_NEXT_TILE - add hl, de - ld a, [hl] - call CheckPitTile - jr nz, .next - - ld hl, OBJECT_DIRECTION_WALKING - add hl, de - ld a, [hl] - cp STANDING - jr nz, .next - call HandleStoneQueue - jr c, .fall_down_hole - -.next - ld hl, OBJECT_STRUCT_LENGTH - add hl, de - ld d, h - ld e, l - - pop af - dec a - jr nz, .loop - ret - -.fall_down_hole - pop af - ret diff --git a/engine/overworld/landmarks.asm b/engine/overworld/landmarks.asm index 9501b22cd..9deafb8e6 100644 --- a/engine/overworld/landmarks.asm +++ b/engine/overworld/landmarks.asm @@ -13,7 +13,6 @@ GetLandmarkCoords: pop hl ret - GetLandmarkName:: ; Copy the name of landmark e to wStringBuffer1. push hl @@ -44,10 +43,8 @@ GetLandmarkName:: pop hl ret - INCLUDE "data/maps/landmarks.asm" - RegionCheck: ; Checks if the player is in Kanto or Johto. ; If in Johto, returns 0 in e. diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index d0cfd8741..8c1171981 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2,7 +2,6 @@ INCLUDE "data/sprites/facings.asm" INCLUDE "data/sprites/map_objects.asm" - DeleteMapObject:: push bc ld hl, OBJECT_MAP_OBJECT_INDEX @@ -2765,7 +2764,6 @@ ApplyBGMapAnchorToObjects: pop hl ret - PRIORITY_LOW EQU $10 PRIORITY_NORM EQU $20 PRIORITY_HIGH EQU $30 diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm index 6cdccba71..b09404240 100644 --- a/engine/overworld/map_setup.asm +++ b/engine/overworld/map_setup.asm @@ -107,7 +107,6 @@ MapSetupCommands: dba DontScrollText ; 2c dba ReturnFromMapSetupScript ; 2d - DontScrollText: xor a ld [wDisableTextAcceleration], a diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index fac0b4ae8..f7054c680 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -91,7 +91,6 @@ MovementPointers: dw Movement_return_dig ; 58 dw Movement_skyfall_top ; 59 - Movement_teleport_from: ld hl, OBJECT_STEP_TYPE add hl, bc @@ -486,7 +485,6 @@ Movement_big_step_right: ld a, STEP_BIKE << 2 | RIGHT jp NormalStep - Movement_turn_away_down: ld a, STEP_SLOW << 2 | DOWN jp TurningStep @@ -535,7 +533,6 @@ Movement_turn_waterfall_right: ld a, STEP_BIKE << 2 | RIGHT jp TurningStep - Movement_slow_slide_step_down: ld a, STEP_SLOW << 2 | DOWN jp SlideStep @@ -584,7 +581,6 @@ Movement_fast_slide_step_right: ld a, STEP_BIKE << 2 | RIGHT jp SlideStep - Movement_slow_jump_step_down: ld a, STEP_SLOW << 2 | DOWN jp JumpStep @@ -633,7 +629,6 @@ Movement_fast_jump_step_right: ld a, STEP_BIKE << 2 | RIGHT jp JumpStep - Movement_turn_step_down: ld a, OW_DOWN jr TurnStep @@ -724,7 +719,6 @@ TurningStep: ld [hl], STEP_TYPE_PLAYER_WALK ret - SlideStep: call InitStep call UpdateTallGrassFlags @@ -749,7 +743,6 @@ SlideStep: ld [hl], STEP_TYPE_PLAYER_WALK ret - JumpStep: call InitStep ld hl, OBJECT_1F diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 07881a788..b4b5ef467 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,5 +1,4 @@ CanObjectMoveInDirection: - ld hl, OBJECT_PALETTE add hl, bc bit SWIMMING_F, [hl] @@ -58,7 +57,6 @@ CanObjectMoveInDirection: and a ret - WillObjectBumpIntoWater: call Function6f5f ret c @@ -144,9 +142,9 @@ Function6f5f: Function6f7f: ld d, a and $f0 - cp $b0 + cp HI_NYBBLE_SIDE_WALLS jr z, .done - cp $c0 + cp HI_NYBBLE_UNUSED_C0 jr z, .done xor a ret @@ -216,10 +214,7 @@ Function6fa1: scf ret - - CheckFacingObject:: - call GetFacingTileCoord ; Double the distance for counter tiles. @@ -258,7 +253,6 @@ CheckFacingObject:: scf ret - WillObjectBumpIntoSomeoneElse: ld hl, OBJECT_NEXT_MAP_X add hl, bc @@ -532,7 +526,6 @@ Unreferenced_Function7113: scf ret - Function7171: ld hl, OBJECT_NEXT_MAP_X add hl, bc diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 35a792921..f3dcb5b96 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -91,7 +91,6 @@ GetPlayerSprite: INCLUDE "data/sprites/player_sprites.asm" - AddMapSprites: call GetMapEnvironment call CheckOutdoorMap @@ -103,7 +102,6 @@ AddMapSprites: call AddOutdoorSprites ret - AddIndoorSprites: ld hl, wMap1ObjectSprite ld a, 1 @@ -119,7 +117,6 @@ AddIndoorSprites: jr nz, .loop ret - AddOutdoorSprites: ld a, [wMapGroup] dec a @@ -141,7 +138,6 @@ AddOutdoorSprites: jr nz, .loop ret - LoadUsedSpritesGFX: ld a, MAPCALLBACK_SPRITES call RunMapCallback @@ -165,8 +161,6 @@ LoadUsedSpritesGFX: farcall LoadEmote ret - - SafeGetSprite: push hl call GetSprite @@ -200,7 +194,6 @@ GetSprite: ld h, a ret - GetMonSprite: ; Return carry if a monster sprite was loaded. @@ -263,7 +256,6 @@ GetMonSprite: and a ret - _DoesSpriteHaveFacings:: ; Checks to see whether we can apply a facing to a sprite. ; Returns carry unless the sprite is a Pokemon or a Still Sprite. @@ -290,7 +282,6 @@ _DoesSpriteHaveFacings:: and a ret - _GetSpritePalette:: ld a, c call GetMonSprite @@ -310,14 +301,12 @@ _GetSpritePalette:: ld c, a ret - LoadAndSortSprites: call LoadSpriteGFX call SortUsedSprites call ArrangeUsedSprites ret - AddSpriteGFX: ; Add any new sprite ids to a list of graphics to be loaded. ; Return carry if the list is full. @@ -356,7 +345,6 @@ AddSpriteGFX: and a ret - LoadSpriteGFX: ; Bug: b is not preserved, so it's useless as a next count. ; Uncomment the lines below to fix. @@ -384,7 +372,6 @@ LoadSpriteGFX: ld a, l ret - SortUsedSprites: ; Bubble-sort sprites by type. @@ -455,7 +442,6 @@ SortUsedSprites: .quit ret - ArrangeUsedSprites: ; Get the length of each sprite and space them out in VRAM. ; Crystal introduces a second table in VRAM bank 0. @@ -514,7 +500,6 @@ ArrangeUsedSprites: .quit ret - GetSpriteLength: ; Return the length of sprite type a in tiles. @@ -536,7 +521,6 @@ GetSpriteLength: ld a, 4 ret - GetUsedSprites: ld hl, wUsedSprites ld c, SPRITE_GFX_LIST_CAPACITY @@ -678,7 +662,6 @@ LoadEmote:: call GetEmote2bpp ret - INCLUDE "data/sprites/emotes.asm" INCLUDE "data/sprites/sprite_mons.asm" diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm index 0a2674341..c70357f13 100644 --- a/engine/overworld/player_movement.asm +++ b/engine/overworld/player_movement.asm @@ -256,7 +256,6 @@ DoPlayerMovement:: ret .TryStep: - ; Surfing actually calls .TrySurf directly instead of passing through here. ld a, [wPlayerState] cp PLAYER_SURF @@ -321,7 +320,6 @@ DoPlayerMovement:: ret .TrySurf: - call .CheckSurfPerms ld [wd040], a jr c, .surf_bump @@ -395,7 +393,6 @@ DoPlayerMovement:: db FACE_UP | FACE_LEFT ; COLL_HOP_UP_LEFT .CheckWarp: - ; Bug: Since no case is made for STANDING here, it will check ; [.edgewarps + $ff]. This resolves to $3e at $8035a. ; This causes wd041 to be nonzero when standing on tile $3e, @@ -657,7 +654,6 @@ DoPlayerMovement:: ret .CheckStrengthBoulder: - ld hl, wBikeFlags bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl] jr z, .not_boulder @@ -779,7 +775,6 @@ DoPlayerMovement:: ret .BumpSound: - call CheckSFX ret c ld de, SFX_BUMP diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index a2315a541..f8e702eb9 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -1,6 +1,5 @@ ; Event scripting commands. - EnableScriptMode:: push af ld a, SCRIPT_READ @@ -62,7 +61,6 @@ RunScriptCommand: rst JumpTable ret - ScriptCommandTable: ; entries correspond to macros/scripts/events.asm enumeration dw Script_scall ; 00 @@ -332,7 +330,6 @@ JumpTextScript: closetext end - if _CRYSTAL Script_farjumptext: @@ -351,7 +348,6 @@ Script_farjumptext: endc - Script_writetext: ; script command 0x4c ; parameters: text_pointer @@ -521,7 +517,6 @@ Script_verbosegiveitem: ld de, GiveItemScript jp ScriptCall - ret_96f76: ret @@ -544,7 +539,6 @@ ReceivedItemText: text_jump UnknownText_0x1c4719 db "@" - Script_verbosegiveitem2: ; script command 0x9f ; parameters: item, var @@ -608,7 +602,6 @@ Script_specialsound: call WaitSFX ret - GetPocketName: farcall CheckItemPocket ld a, [wItemAttributeParamBuffer] @@ -634,7 +627,6 @@ CurItemName: call GetItemName ret - PutItemInPocketText: text_jump UnknownText_0x1c472c db "@" @@ -643,7 +635,6 @@ PocketIsFullText: text_jump UnknownText_0x1c474b db "@" - Script_pokemart: ; script command 0x94 ; parameters: dialog_id, mart_id @@ -1274,7 +1265,6 @@ ShowEmoteScript: step_sleep 1 step_end - Script_earthquake: ; script command 0x78 ; parameters: param @@ -1301,7 +1291,6 @@ EarthquakeMovement: step_end .End - Script_loadpikachudata: ; script command 0x5a @@ -2664,7 +2653,6 @@ Script_closetext: call CloseText ret - Script_passtoengine: ; script command 0x89 ; parameters: data_pointer @@ -2834,7 +2822,6 @@ Script_checksave: ld [wScriptVar], a ret - ; unused ld a, [.byte] ld [wScriptVar], a diff --git a/engine/overworld/select_menu.asm b/engine/overworld/select_menu.asm index 069d74f2d..9eba9de83 100644 --- a/engine/overworld/select_menu.asm +++ b/engine/overworld/select_menu.asm @@ -1,5 +1,4 @@ SelectMenu:: - call CheckRegisteredItem jr c, .NotRegistered jp UseRegisteredItem @@ -12,14 +11,11 @@ SelectMenu:: call WaitButton jp CloseText - ItemMayBeRegisteredText: text_jump UnknownText_0x1c1cf3 db "@" - CheckRegisteredItem: - ld a, [wWhichRegisteredItem] and a jr z, .NoRegisteredItem @@ -85,7 +81,6 @@ CheckRegisteredItem: scf ret - .CheckRegisteredNo: ld a, [wWhichRegisteredItem] and REGISTERED_NUMBER @@ -100,7 +95,6 @@ CheckRegisteredItem: scf ret - .IsSameItem: ld a, [wRegisteredItem] cp [hl] @@ -113,9 +107,7 @@ CheckRegisteredItem: scf ret - UseRegisteredItem: - farcall CheckItemMenu ld a, [wItemAttributeParamBuffer] ld hl, .SwitchTo diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm index 2c673d6b1..6b4476f2b 100644 --- a/engine/overworld/spawn_points.asm +++ b/engine/overworld/spawn_points.asm @@ -1,6 +1,5 @@ INCLUDE "data/maps/spawn_points.asm" - LoadSpawnPoint: ; loads the spawn point in wDefaultSpawnpoint push hl @@ -27,7 +26,6 @@ LoadSpawnPoint: pop hl ret - IsSpawnPoint: ; Checks if the map loaded in de is a spawn point. Returns carry if it's a spawn point. ld hl, SpawnPoints diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm index 136adb221..abb12d87d 100644 --- a/engine/overworld/time.asm +++ b/engine/overworld/time.asm @@ -137,7 +137,6 @@ StartBugContestTimer: call CopyDayHourMinSecToHL ret - CheckBugContestTimer:: ld hl, wBugContestStartTime call CalcSecsMinsHoursDaysSince @@ -172,7 +171,6 @@ CheckBugContestTimer:: scf ret - InitializeStartDay: call UpdateTime ld hl, wTimerEventStartDay diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm index 0ab9a6c2d..54df4a97f 100644 --- a/engine/overworld/warp_connection.asm +++ b/engine/overworld/warp_connection.asm @@ -15,7 +15,6 @@ InitCommandQueue: ld [wMapTimeOfDay], a ret - EnterMapConnection: ; Return carry if a connection has been entered. ld a, [wPlayerStepDirection] @@ -388,7 +387,6 @@ CheckMovingOffEdgeOfMap:: scf ret - GetCoordOfUpperLeftCorner:: ld hl, wOverworldMapBlocks ld a, [wXCoord] diff --git a/engine/overworld/wildmons.asm b/engine/overworld/wildmons.asm index ae611d4ca..d88e5908f 100644 --- a/engine/overworld/wildmons.asm +++ b/engine/overworld/wildmons.asm @@ -490,7 +490,6 @@ LookUpWildmonsForMapDE: scf ret - InitRoamMons: ; initialize wRoamMon structs @@ -524,7 +523,6 @@ InitRoamMons: ret - CheckEncounterRoamMon: push hl ; Don't trigger an encounter if we're on water. @@ -572,7 +570,6 @@ CheckEncounterRoamMon: and a ret - UpdateRoamMons: ld a, [wRoamMon1MapGroup] cp GROUP_N_A @@ -615,7 +612,6 @@ UpdateRoamMons: .Finished: jp _BackUpMapIndices - .Update: ld hl, RoamMaps .loop @@ -752,10 +748,8 @@ _BackUpMapIndices: ld [wRoamMons_CurrentMapGroup], a ret - INCLUDE "data/wild/roammon_maps.asm" - ValidateTempWildMonSpecies: ; Due to a development oversight, this function is called with the wild Pokemon's level, not its species, in a. and a @@ -965,7 +959,6 @@ RandomPhoneMon: ld bc, MON_NAME_LENGTH jp CopyBytes - INCLUDE "data/wild/johto_grass.asm" INCLUDE "data/wild/johto_water.asm" INCLUDE "data/wild/kanto_grass.asm" |