Identify remaining map object labels

This commit is contained in:
Rangi 2020-10-22 21:25:40 -04:00
parent d8310c166d
commit bd3f634049
7 changed files with 88 additions and 76 deletions

View File

@ -70,7 +70,7 @@ EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F
const OBJ_FLAGS2_2 ; 2 const OBJ_FLAGS2_2 ; 2
const OVERHEAD_F ; 3 const OVERHEAD_F ; 3
const USE_OBP1_F ; 4 const USE_OBP1_F ; 4
const OBJ_FLAGS2_5 ; 5 const FROZEN_F ; 5
const OBJ_FLAGS2_6 ; 6 const OBJ_FLAGS2_6 ; 6
const OBJ_FLAGS2_7 ; 7 const OBJ_FLAGS2_7 ; 7

View File

@ -310,7 +310,7 @@ StartTrainerBattle_Flash:
dc 0, 0, 0, 1 dc 0, 0, 0, 1
StartTrainerBattle_SetUpForWavyOutro: StartTrainerBattle_SetUpForWavyOutro:
farcall Function5602 farcall RespawnPlayerAndOpponent
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ldh [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
@ -367,7 +367,7 @@ StartTrainerBattle_SineWave:
ret ret
StartTrainerBattle_SetUpForSpinOutro: StartTrainerBattle_SetUpForSpinOutro:
farcall Function5602 farcall RespawnPlayerAndOpponent
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ldh [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
@ -509,7 +509,7 @@ ENDM
.wedge5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1 .wedge5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1
StartTrainerBattle_SetUpForRandomScatterOutro: StartTrainerBattle_SetUpForRandomScatterOutro:
farcall Function5602 farcall RespawnPlayerAndOpponent
ld a, BANK(wLYOverrides) ld a, BANK(wLYOverrides)
ldh [rSVBK], a ldh [rSVBK], a
call StartTrainerBattle_NextScene call StartTrainerBattle_NextScene
@ -763,7 +763,7 @@ StartTrainerBattle_DrawSineWave:
calc_sine_wave calc_sine_wave
StartTrainerBattle_ZoomToBlack: StartTrainerBattle_ZoomToBlack:
farcall Function5602 farcall RespawnPlayerAndOpponent
ld de, .boxes ld de, .boxes
.loop .loop

View File

@ -626,7 +626,7 @@ FlyFunction:
end end
.ReturnFromFly: .ReturnFromFly:
farcall Function561d farcall RespawnPlayer
call DelayFrame call DelayFrame
call UpdatePlayerSprite call UpdatePlayerSprite
farcall LoadOverworldFont farcall LoadOverworldFont

View File

@ -111,8 +111,8 @@ HandleStepType:
jr z, .zero jr z, .zero
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit OBJ_FLAGS2_5, [hl] bit FROZEN_F, [hl]
jr nz, .bit5 jr nz, .frozen
cp STEP_TYPE_FROM_MOVEMENT cp STEP_TYPE_FROM_MOVEMENT
jr z, .one jr z, .one
jr .ok3 jr .ok3
@ -121,8 +121,8 @@ HandleStepType:
call StepFunction_Reset call StepFunction_Reset
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
bit OBJ_FLAGS2_5, [hl] bit FROZEN_F, [hl]
jr nz, .bit5 jr nz, .frozen
.one .one
call StepFunction_FromMovement call StepFunction_FromMovement
ld hl, OBJECT_STEP_TYPE ld hl, OBJECT_STEP_TYPE
@ -137,7 +137,7 @@ HandleStepType:
rst JumpTable rst JumpTable
ret ret
.bit5 .frozen
ret ret
HandleObjectAction: HandleObjectAction:
@ -149,7 +149,7 @@ HandleObjectAction:
add hl, bc add hl, bc
bit OBJ_FLAGS2_6, [hl] bit OBJ_FLAGS2_6, [hl]
jr nz, SetFacingStanding jr nz, SetFacingStanding
bit OBJ_FLAGS2_5, [hl] bit FROZEN_F, [hl]
jr nz, _CallFrozenObjectAction jr nz, _CallFrozenObjectAction
; use first column (normal) ; use first column (normal)
ld de, ObjectActionPairPointers ld de, ObjectActionPairPointers
@ -161,6 +161,7 @@ HandleFrozenObjectAction:
bit INVISIBLE_F, [hl] bit INVISIBLE_F, [hl]
jr nz, SetFacingStanding jr nz, SetFacingStanding
_CallFrozenObjectAction: _CallFrozenObjectAction:
; use second column (frozen)
ld de, ObjectActionPairPointers + 2 ld de, ObjectActionPairPointers + 2
jr CallObjectAction ; pointless jr CallObjectAction ; pointless
@ -1879,7 +1880,7 @@ GetIndexedMovementByte2:
ld e, [hl] ld e, [hl]
inc [hl] inc [hl]
ld d, 0 ld d, 0
ld hl, wc2e6 ld hl, wIndexedMovement2Pointer
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
@ -2160,7 +2161,7 @@ CopyTempObjectData:
ld [hl], -1 ld [hl], -1
ret ret
Function55e0:: UpdateAllObjectsFrozen::
ld a, [wVramState] ld a, [wVramState]
bit 0, a bit 0, a
ret z ret z
@ -2170,7 +2171,7 @@ Function55e0::
ldh [hMapObjectIndexBuffer], a ldh [hMapObjectIndexBuffer], a
call DoesObjectHaveASprite call DoesObjectHaveASprite
jr z, .ok jr z, .ok
call Function565c call UpdateObjectFrozen
.ok .ok
ld hl, OBJECT_LENGTH ld hl, OBJECT_LENGTH
add hl, bc add hl, bc
@ -2182,30 +2183,30 @@ Function55e0::
jr nz, .loop jr nz, .loop
ret ret
Function5602: RespawnPlayerAndOpponent:
; called at battle start ; called at battle start
call Function5645 ; clear sprites call HideAllObjects
ld a, PLAYER ld a, PLAYER
call Function5629 ; respawn player call RespawnObject
ld a, [wBattleScriptFlags] ld a, [wBattleScriptFlags]
bit 7, a bit 7, a
jr z, .ok jr z, .skip_opponent
ldh a, [hLastTalked] ldh a, [hLastTalked]
and a and a
jr z, .ok jr z, .skip_opponent
call Function5629 ; respawn opponent call RespawnObject
.ok .skip_opponent
call _UpdateSprites call _UpdateSprites
ret ret
Function561d: RespawnPlayer:
call Function5645 ; clear sprites call HideAllObjects
ld a, PLAYER ld a, PLAYER
call Function5629 ; respawn player call RespawnObject
call _UpdateSprites call _UpdateSprites
ret ret
Function5629: RespawnObject:
cp NUM_OBJECTS cp NUM_OBJECTS
ret nc ret nc
call GetMapObject call GetMapObject
@ -2219,10 +2220,10 @@ Function5629:
call GetObjectStruct call GetObjectStruct
call DoesObjectHaveASprite call DoesObjectHaveASprite
ret z ret z
call Function5673 call UpdateRespawnedObjectFrozen
ret ret
Function5645: HideAllObjects:
xor a xor a
ld bc, wObjectStructs ld bc, wObjectStructs
.loop .loop
@ -2238,20 +2239,20 @@ Function5645:
jr nz, .loop jr nz, .loop
ret ret
Function565c: UpdateObjectFrozen:
push bc push bc
call Function56cd call CheckObjectCoveredByTextbox
pop bc pop bc
jr c, SetFacing_Standing jr c, SetFacing_Standing
call Function56a3 call CheckObjectOnScreen
jr c, SetFacing_Standing jr c, SetFacing_Standing
call Function5688 call UpdateObjectNextTile
farcall HandleFrozenObjectAction ; no need to farcall farcall HandleFrozenObjectAction ; no need to farcall
xor a xor a
ret ret
Function5673: UpdateRespawnedObjectFrozen:
call Function56a3 call CheckObjectOnScreen
jr c, SetFacing_Standing jr c, SetFacing_Standing
farcall HandleFrozenObjectAction ; no need to farcall farcall HandleFrozenObjectAction ; no need to farcall
xor a xor a
@ -2264,7 +2265,7 @@ SetFacing_Standing:
scf scf
ret ret
Function5688: UpdateObjectNextTile:
push bc push bc
ld hl, OBJECT_NEXT_MAP_X ld hl, OBJECT_NEXT_MAP_X
add hl, bc add hl, bc
@ -2280,7 +2281,7 @@ Function5688:
farcall UpdateTallGrassFlags ; no need to farcall farcall UpdateTallGrassFlags ; no need to farcall
ret ret
Function56a3: CheckObjectOnScreen:
ld hl, OBJECT_NEXT_MAP_X ld hl, OBJECT_NEXT_MAP_X
add hl, bc add hl, bc
ld d, [hl] ld d, [hl]
@ -2312,7 +2313,8 @@ Function56a3:
scf scf
ret ret
Function56cd: CheckObjectCoveredByTextbox:
; Check whether the object fits in the screen width.
ld a, [wPlayerBGMapOffsetX] ld a, [wPlayerBGMapOffsetX]
ld d, a ld d, a
ld hl, OBJECT_SPRITE_X_OFFSET ld hl, OBJECT_SPRITE_X_OFFSET
@ -2324,15 +2326,17 @@ Function56cd:
add d add d
cp $f0 cp $f0
jr nc, .ok1 jr nc, .ok1
cp $a0 cp SCREEN_WIDTH_PX
jp nc, .nope jp nc, .nope
.ok1 .ok1
; Account for objects currently moving left/right.
and %00000111 and %00000111
ld d, 2 ld d, 2
cp 4 cp TILE_WIDTH / 2
jr c, .ok2 jr c, .ok2
ld d, 3 ld d, 3
.ok2 .ok2
; Convert pixels to tiles.
ld a, [hl] ld a, [hl]
srl a srl a
srl a srl a
@ -2342,6 +2346,8 @@ Function56cd:
sub BG_MAP_WIDTH sub BG_MAP_WIDTH
.ok3 .ok3
ldh [hCurSpriteXCoord], a ldh [hCurSpriteXCoord], a
; Check whether the object fits in the screen height.
ld a, [wPlayerBGMapOffsetY] ld a, [wPlayerBGMapOffsetY]
ld e, a ld e, a
ld hl, OBJECT_SPRITE_Y_OFFSET ld hl, OBJECT_SPRITE_Y_OFFSET
@ -2353,15 +2359,17 @@ Function56cd:
add e add e
cp $f0 cp $f0
jr nc, .ok4 jr nc, .ok4
cp $90 cp SCREEN_HEIGHT_PX
jr nc, .nope jr nc, .nope
.ok4 .ok4
; Account for objects currently moving up/down.
and %00000111 and %00000111
ld e, 2 ld e, 2
cp 4 cp TILE_WIDTH / 2
jr c, .ok5 jr c, .ok5
ld e, 3 ld e, 3
.ok5 .ok5
; Convert pixels to tiles.
ld a, [hl] ld a, [hl]
srl a srl a
srl a srl a
@ -2371,6 +2379,8 @@ Function56cd:
sub BG_MAP_HEIGHT sub BG_MAP_HEIGHT
.ok6 .ok6
ldh [hCurSpriteYCoord], a ldh [hCurSpriteYCoord], a
; Account for big objects that are twice as wide and high.
ld hl, OBJECT_PALETTE ld hl, OBJECT_PALETTE
add hl, bc add hl, bc
bit BIG_OBJECT_F, [hl] bit BIG_OBJECT_F, [hl]
@ -2384,6 +2394,7 @@ Function56cd:
.ok7 .ok7
ld a, d ld a, d
ldh [hCurSpriteXPixel], a ldh [hCurSpriteXPixel], a
.loop .loop
ldh a, [hCurSpriteXPixel] ldh a, [hCurSpriteXPixel]
ld d, a ld d, a
@ -2414,6 +2425,7 @@ Function56cd:
.ok9 .ok9
dec e dec e
jr nz, .loop jr nz, .loop
and a and a
ret ret
@ -2422,11 +2434,11 @@ Function56cd:
ret ret
HandleNPCStep:: HandleNPCStep::
call .ResetStepVector call ResetStepVector
call .DoStepsForAllObjects call DoStepsForAllObjects
ret ret
.ResetStepVector: ResetStepVector:
xor a xor a
ld [wPlayerStepVectorX], a ld [wPlayerStepVectorX], a
ld [wPlayerStepVectorY], a ld [wPlayerStepVectorY], a
@ -2435,7 +2447,7 @@ HandleNPCStep::
ld [wPlayerStepDirection], a ld [wPlayerStepDirection], a
ret ret
.DoStepsForAllObjects: DoStepsForAllObjects:
ld bc, wObjectStructs ld bc, wObjectStructs
xor a xor a
.loop .loop
@ -2461,13 +2473,13 @@ RefreshPlayerSprite:
xor a xor a
ld [wPlayerTurningDirection], a ld [wPlayerTurningDirection], a
ld [wPlayerObjectStepFrame], a ld [wPlayerObjectStepFrame], a
call .TryResetPlayerAction call TryResetPlayerAction
farcall CheckWarpFacingDown farcall CheckWarpFacingDown
call c, SpawnInFacingDown call c, SpawnInFacingDown
call .SpawnInCustomFacing call SpawnInCustomFacing
ret ret
.TryResetPlayerAction: TryResetPlayerAction:
ld hl, wPlayerSpriteSetupFlags ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_RESET_ACTION_F, [hl] bit PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
jr nz, .ok jr nz, .ok
@ -2478,7 +2490,7 @@ RefreshPlayerSprite:
ld [wPlayerAction], a ld [wPlayerAction], a
ret ret
.SpawnInCustomFacing: SpawnInCustomFacing:
ld hl, wPlayerSpriteSetupFlags ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl] bit PLAYERSPRITESETUP_CUSTOM_FACING_F, [hl]
ret z ret z
@ -2486,11 +2498,11 @@ RefreshPlayerSprite:
and PLAYERSPRITESETUP_FACING_MASK and PLAYERSPRITESETUP_FACING_MASK
add a add a
add a add a
jr ContinueSpawnFacing jr _ContinueSpawnFacing
SpawnInFacingDown: SpawnInFacingDown:
ld a, DOWN ld a, DOWN
ContinueSpawnFacing: _ContinueSpawnFacing:
ld bc, wPlayerStruct ld bc, wPlayerStruct
call SetSpriteDirection call SetSpriteDirection
ret ret
@ -2567,34 +2579,34 @@ ResetFollower:
cp -1 cp -1
ret z ret z
call GetObjectStruct call GetObjectStruct
farcall Function58e3 ; no need to bankswitch farcall ResetObject ; no need to farcall
ld a, -1 ld a, -1
ld [wObjectFollow_Follower], a ld [wObjectFollow_Follower], a
ret ret
SetFlagsForMovement_1:: FreezeAllOtherObjects::
ld a, c ld a, c
call CheckObjectVisibility call CheckObjectVisibility
ret c ret c
push bc push bc
call Function587a call FreezeAllObjects
pop bc pop bc
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res OBJ_FLAGS2_5, [hl] res FROZEN_F, [hl]
xor a xor a
ret ret
Function586e: FreezeObject: ; unreferenced
call CheckObjectVisibility call CheckObjectVisibility
ret c ret c
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set OBJ_FLAGS2_5, [hl] set FROZEN_F, [hl]
xor a xor a
ret ret
Function587a: FreezeAllObjects:
ld bc, wObjectStructs ld bc, wObjectStructs
xor a xor a
.loop .loop
@ -2603,7 +2615,7 @@ Function587a:
jr z, .next jr z, .next
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
set OBJ_FLAGS2_5, [hl] set FROZEN_F, [hl]
.next .next
ld hl, OBJECT_LENGTH ld hl, OBJECT_LENGTH
add hl, bc add hl, bc
@ -2615,7 +2627,7 @@ Function587a:
jr nz, .loop jr nz, .loop
ret ret
_SetFlagsForMovement_2:: _UnfreezeFollowerObject::
ld a, [wObjectFollow_Leader] ld a, [wObjectFollow_Leader]
cp -1 cp -1
ret z ret z
@ -2633,10 +2645,10 @@ _SetFlagsForMovement_2::
call GetObjectStruct call GetObjectStruct
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res OBJ_FLAGS2_5, [hl] res FROZEN_F, [hl]
ret ret
Function58b9:: UnfreezeAllObjects::
push bc push bc
ld bc, wObjectStructs ld bc, wObjectStructs
xor a xor a
@ -2646,7 +2658,7 @@ Function58b9::
jr z, .next jr z, .next
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res OBJ_FLAGS2_5, [hl] res FROZEN_F, [hl]
.next .next
ld hl, OBJECT_LENGTH ld hl, OBJECT_LENGTH
add hl, bc add hl, bc
@ -2659,20 +2671,20 @@ Function58b9::
pop bc pop bc
ret ret
Function58d8: UnfreezeObject: ; unreferenced
call CheckObjectVisibility call CheckObjectVisibility
ret c ret c
ld hl, OBJECT_FLAGS2 ld hl, OBJECT_FLAGS2
add hl, bc add hl, bc
res OBJ_FLAGS2_5, [hl] res FROZEN_F, [hl]
ret ret
Function58e3: ResetObject:
ld hl, OBJECT_MAP_OBJECT_INDEX ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp -1 cp -1
jp z, Function5903 ; a jr would have been appropriate here jp z, .set_standing ; a jr would have been appropriate here
push bc push bc
call GetMapObject call GetMapObject
ld hl, MAPOBJECT_MOVEMENT ld hl, MAPOBJECT_MOVEMENT
@ -2687,7 +2699,7 @@ Function58e3:
ld [hl], STEP_TYPE_RESET ld [hl], STEP_TYPE_RESET
ret ret
Function5903: .set_standing:
call GetSpriteDirection call GetSpriteDirection
rrca rrca
rrca rrca

View File

@ -34,7 +34,7 @@ WaitScript:
dec [hl] dec [hl]
ret nz ret nz
farcall Function58b9 farcall UnfreezeAllObjects
ld a, SCRIPT_READ ld a, SCRIPT_READ
ld [wScriptMode], a ld [wScriptMode], a
@ -48,7 +48,7 @@ WaitScriptMovement:
bit 7, [hl] bit 7, [hl]
ret nz ret nz
farcall Function58b9 farcall UnfreezeAllObjects
ld a, SCRIPT_READ ld a, SCRIPT_READ
ld [wScriptMode], a ld [wScriptMode], a
@ -812,11 +812,11 @@ Script_applymovement:
ApplyMovement: ApplyMovement:
push bc push bc
ld a, c ld a, c
farcall SetFlagsForMovement_1 farcall FreezeAllOtherObjects
pop bc pop bc
push bc push bc
call SetFlagsForMovement_2 call UnfreezeFollowerObject
pop bc pop bc
call GetScriptByte call GetScriptByte
@ -833,8 +833,8 @@ ApplyMovement:
call StopScript call StopScript
ret ret
SetFlagsForMovement_2: UnfreezeFollowerObject:
farcall _SetFlagsForMovement_2 farcall _UnfreezeFollowerObject
ret ret
Script_applymovementlasttalked: Script_applymovementlasttalked:

View File

@ -589,7 +589,7 @@ UpdateSprites::
bit 0, a bit 0, a
ret z ret z
farcall Function55e0 farcall UpdateAllObjectsFrozen
farcall _UpdateSprites farcall _UpdateSprites
ret ret

View File

@ -174,7 +174,7 @@ wMovementObject::
db db
wMovementDataBank:: db wMovementDataBank:: db
wMovementDataAddress:: dw wMovementDataAddress:: dw
wc2e6:: dw wIndexedMovement2Pointer:: dw
ds 2 ds 2