diff --git a/include/overlay006/ov6_02242AF0.h b/include/overlay006/great_marsh_tram.h similarity index 52% rename from include/overlay006/ov6_02242AF0.h rename to include/overlay006/great_marsh_tram.h index dab21c0415..c0a86b240a 100644 --- a/include/overlay006/ov6_02242AF0.h +++ b/include/overlay006/great_marsh_tram.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_OV6_02242AF0_H -#define POKEPLATINUM_OV6_02242AF0_H +#ifndef POKEPLATINUM_GREAT_MARSH_TRAM_H +#define POKEPLATINUM_GREAT_MARSH_TRAM_H #include "field/field_system_decl.h" @@ -8,7 +8,7 @@ typedef struct GreatMarshTramState { } GreatMarshTramState; void GreatMarshTram_DynamicMapFeaturesInit(FieldSystem *fieldSystem); -void GreatMarshTram_MoveToLocation(FieldSystem *fieldSystem, u16 param1, u16 param2); -u32 GreatMarshTram_CheckLocation(FieldSystem *fieldSystem, u16 param1); +void GreatMarshTram_MoveToLocation(FieldSystem *fieldSystem, u16 destination, u16 movementType); +u32 GreatMarshTram_CheckLocation(FieldSystem *fieldSystem, u16 location); -#endif // POKEPLATINUM_OV6_02242AF0_H +#endif // POKEPLATINUM_GREAT_MARSH_TRAM_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index b2f8019ebf..ff42d233e1 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -563,7 +563,7 @@ Overlay overlay6 Object main.nef.p/src_overlay006_wild_encounters.c.o Object main.nef.p/src_overlay006_ov6_022426AC.c.o Object main.nef.p/src_overlay006_great_marsh_binoculars.c.o - Object main.nef.p/src_overlay006_ov6_02242AF0.c.o + Object main.nef.p/src_overlay006_great_marsh_tram.c.o Object main.nef.p/src_overlay006_great_marsh_daily_encounters.c.o Object main.nef.p/src_overlay006_ov6_02243004.c.o Object main.nef.p/src_overlay006_radar_chain_records.c.o diff --git a/src/dynamic_map_features.c b/src/dynamic_map_features.c index 7993b34dee..3da79f66e6 100644 --- a/src/dynamic_map_features.c +++ b/src/dynamic_map_features.c @@ -8,7 +8,7 @@ #include "field/field_system.h" #include "overlay005/ov5_021F8370.h" -#include "overlay006/ov6_02242AF0.h" +#include "overlay006/great_marsh_tram.h" #include "overlay008/ov8_02249960.h" #include "overlay009/ov9_02249960.h" diff --git a/src/meson.build b/src/meson.build index ed9f10ce64..b0329dcf38 100644 --- a/src/meson.build +++ b/src/meson.build @@ -451,7 +451,7 @@ pokeplatinum_c = files( 'overlay006/wild_encounters.c', 'overlay006/ov6_022426AC.c', 'overlay006/great_marsh_binoculars.c', - 'overlay006/ov6_02242AF0.c', + 'overlay006/great_marsh_tram.c', 'overlay006/great_marsh_daily_encounters.c', 'overlay006/ov6_02243004.c', 'overlay006/radar_chain_records.c', diff --git a/src/overlay006/great_marsh_tram.c b/src/overlay006/great_marsh_tram.c new file mode 100644 index 0000000000..2965cb194d --- /dev/null +++ b/src/overlay006/great_marsh_tram.c @@ -0,0 +1,329 @@ +#include "overlay006/great_marsh_tram.h" + +#include +#include + +#include "constants/field/dynamic_map_features.h" +#include "constants/great_marsh_tram.h" + +#include "struct_decls/struct_02061AB4_decl.h" + +#include "field/field_system.h" +#include "overlay005/area_data.h" +#include "overlay005/map_prop.h" +#include "overlay005/map_prop_animation.h" + +#include "field_system.h" +#include "field_task.h" +#include "heap.h" +#include "persisted_map_features.h" +#include "player_avatar.h" +#include "savedata_misc.h" +#include "sound_playback.h" +#include "unk_020655F4.h" + +#include "res/field/props/models/prop_models.naix" + +#define GREAT_MARSH_TRAM_ANIMATION_TAG 16 + +#define TRAM_POSITION_AREA_1_2 (FX32_CONST(16) * (32 * 1 + 8)) +#define TRAM_POSITION_AREA_3_4 (FX32_CONST(16) * (32 * 2 + 18)) +#define TRAM_POSITION_AREA_5_6 (FX32_CONST(16) * (32 * 3 + 12)) + +#define TRAM_AREA_1_2_SLOW_DOWN_POINT (32 * 1 + 14) +#define TRAM_AREA_3_4_SLOW_DOWN_POINT_NORTH (32 * 2 + 10) +#define TRAM_AREA_3_4_SLOW_DOWN_POINT_SOUTH (32 * 2 + 24) +#define TRAM_AREA_5_6_SLOW_DOWN_POINT (32 * 3 + 4) + +typedef struct GreatMarshTramMovementTask GreatMarshTramMovementTask; + +typedef BOOL (*GreatMarshTramMovementFunc)(FieldSystem *, GreatMarshTramMovementTask *, const fx32 *, VecFx32 *); + +struct GreatMarshTramMovementTask { + GreatMarshTramMovementFunc movementFunc; + u8 isMovingSouth; + u8 state; + u8 speedLevel; + u8 calledTramElapsedFrames; + int movementType; + fx32 destPos; + int slowDownZ; +}; + +static BOOL MoveTram(FieldTask *taskMan); +static BOOL CallTramToPlayer(FieldSystem *fieldSystem, GreatMarshTramMovementTask *task, const fx32 *destZ, VecFx32 *tramPosition); +static BOOL RideTramToArea(FieldSystem *fieldSystem, GreatMarshTramMovementTask *task, const fx32 *destZ, VecFx32 *tramPosition); + +static const int sRidingTramNorthMovements[] = { + MOVEMENT_ACTION_WALK_SLOWER_NORTH, + MOVEMENT_ACTION_WALK_SLOW_NORTH, + MOVEMENT_ACTION_WALK_NORMAL_NORTH, + MOVEMENT_ACTION_WALK_NORMAL_NORTH, + MOVEMENT_ACTION_WALK_FAST_NORTH, + MOVEMENT_ACTION_WALK_FAST_NORTH, + MOVEMENT_ACTION_WALK_FASTER_NORTH +}; + +static const int sRidingTramSouthMovements[] = { + MOVEMENT_ACTION_WALK_SLOWER_SOUTH, + MOVEMENT_ACTION_WALK_SLOW_SOUTH, + MOVEMENT_ACTION_WALK_NORMAL_SOUTH, + MOVEMENT_ACTION_WALK_NORMAL_SOUTH, + MOVEMENT_ACTION_WALK_FAST_SOUTH, + MOVEMENT_ACTION_WALK_FAST_SOUTH, + MOVEMENT_ACTION_WALK_FASTER_SOUTH +}; + +static const u8 sCalledTramFramesPerSpeedLevel[] = { + 2, 4, 4, 8, 8, 16, 32 +}; + +static const fx32 sCalledTramSpeeds[] = { + FX32_CONST(8), + FX32_CONST(4), + FX32_CONST(4), + FX32_CONST(2), + FX32_CONST(2), + FX32_CONST(1), + FX32_CONST(0.5), +}; + +void GreatMarshTram_DynamicMapFeaturesInit(FieldSystem *fieldSystem) +{ + PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); + GreatMarshTramState *tramState = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); + + VecFx32 position; + position.x = FX32_CONST(1056); + position.y = FX32_CONST(16); + + switch (tramState->location) { + case GREAT_MARSH_TRAM_LOCATION_AREA_1_2: + position.z = TRAM_POSITION_AREA_1_2; + break; + case GREAT_MARSH_TRAM_LOCATION_AREA_3_4: + position.z = TRAM_POSITION_AREA_3_4; + break; + case GREAT_MARSH_TRAM_LOCATION_AREA_5_6: + position.z = TRAM_POSITION_AREA_5_6; + break; + } + + MapPropManager_LoadOne(fieldSystem->mapPropManager, fieldSystem->areaDataManager, great_marsh_train_nsbmd, &position, NULL, fieldSystem->mapPropAnimMan); +} + +void GreatMarshTram_MoveToLocation(FieldSystem *fieldSystem, u16 destination, u16 movementType) +{ + PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); + GreatMarshTramState *tramState = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); + GreatMarshTramMovementTask *task = Heap_AllocAtEnd(HEAP_ID_FIELD1, sizeof(GreatMarshTramMovementTask)); + + memset(task, 0, sizeof(GreatMarshTramMovementTask)); + + task->state = 0; + + switch (tramState->location) { + case GREAT_MARSH_TRAM_LOCATION_AREA_1_2: + task->isMovingSouth = TRUE; + + if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_3_4) { + task->destPos = TRAM_POSITION_AREA_3_4; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_3_4; + task->slowDownZ = TRAM_AREA_3_4_SLOW_DOWN_POINT_NORTH; + } else { + task->destPos = TRAM_POSITION_AREA_5_6; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_5_6; + task->slowDownZ = TRAM_AREA_5_6_SLOW_DOWN_POINT; + } + break; + case GREAT_MARSH_TRAM_LOCATION_AREA_3_4: + if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_1_2) { + task->isMovingSouth = FALSE; + task->destPos = TRAM_POSITION_AREA_1_2; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_1_2; + task->slowDownZ = TRAM_AREA_1_2_SLOW_DOWN_POINT; + } else { + task->isMovingSouth = TRUE; + task->destPos = TRAM_POSITION_AREA_5_6; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_5_6; + task->slowDownZ = TRAM_AREA_5_6_SLOW_DOWN_POINT; + } + break; + case GREAT_MARSH_TRAM_LOCATION_AREA_5_6: + task->isMovingSouth = FALSE; + + if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_1_2) { + task->destPos = TRAM_POSITION_AREA_1_2; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_1_2; + task->slowDownZ = TRAM_AREA_1_2_SLOW_DOWN_POINT; + } else { + task->destPos = TRAM_POSITION_AREA_3_4; + tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_3_4; + task->slowDownZ = TRAM_AREA_3_4_SLOW_DOWN_POINT_SOUTH; + } + break; + default: + GF_ASSERT(FALSE); + break; + } + + task->movementType = movementType; + + if (movementType == GREAT_MARSH_TRAM_MOVEMENT_CALL) { + task->movementFunc = CallTramToPlayer; + } else { + task->movementFunc = RideTramToArea; + } + + FieldTask_InitCall(fieldSystem->task, MoveTram, task); +} + +u32 GreatMarshTram_CheckLocation(FieldSystem *fieldSystem, u16 location) +{ + PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); + GreatMarshTramState *tramState = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); + + if (tramState->location == location) { + return GREAT_MARSH_TRAM_AT_LOCATION; + } else { + return GREAT_MARSH_TRAM_NOT_AT_LOCATION; + } +} + +static BOOL MoveTram(FieldTask *taskMan) +{ + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + GreatMarshTramMovementTask *task = FieldTask_GetEnv(taskMan); + + switch (task->state) { + case 0: { + MapProp *mapProp = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, great_marsh_train_nsbmd); + NNSG3dRenderObj *renderObj = MapProp_GetRenderObj(mapProp); + NNSG3dResFileHeader **modelFile = AreaDataManager_GetMapPropModelFile(great_marsh_train_nsbmd, fieldSystem->areaDataManager); + NNSG3dResMdl *model = NNS_G3dGetMdlByIdx(NNS_G3dGetMdlSet(*modelFile), 0); + + MapPropOneShotAnimationManager_LoadPropAnimations(fieldSystem->mapPropAnimMan, fieldSystem->mapPropOneShotAnimMan, GREAT_MARSH_TRAM_ANIMATION_TAG, great_marsh_train_nsbmd, renderObj, model, AreaDataManager_GetMapPropTexture(fieldSystem->areaDataManager), 1, -1, FALSE); + MapPropOneShotAnimationManager_PlayAnimation(fieldSystem->mapPropOneShotAnimMan, GREAT_MARSH_TRAM_ANIMATION_TAG, 0); + task->state++; + break; + } + case 1: + if (task->movementType == GREAT_MARSH_TRAM_MOVEMENT_RIDE) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN04); + } + + task->state++; + case 2: + if (!Sound_IsEffectPlaying(SEQ_SE_DP_TRAIN04)) { + task->state++; + } + break; + case 3: { + MapProp *tram = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, great_marsh_train_nsbmd); + VecFx32 tramPosition; + tramPosition = MapProp_GetPosition(tram); + + if (task->movementFunc(fieldSystem, task, &task->destPos, &tramPosition)) { + task->state++; + } + + MapProp_SetPosition(tram, &tramPosition); + break; + } + case 4: + MapPropOneShotAnimationManager_UnloadAnimation(fieldSystem->mapPropAnimMan, fieldSystem->mapPropOneShotAnimMan, GREAT_MARSH_TRAM_ANIMATION_TAG); + task->state++; + break; + case 5: + Heap_Free(task); + return TRUE; + } + + return FALSE; +} + +static BOOL CallTramToPlayer(FieldSystem *fieldSystem, GreatMarshTramMovementTask *task, const fx32 *destZ, VecFx32 *tramPosition) +{ + if (!task->isMovingSouth) { + tramPosition->z -= sCalledTramSpeeds[task->speedLevel]; + + if (task->speedLevel < NELEMS(sCalledTramFramesPerSpeedLevel) - 1 && (tramPosition->z - FX32_CONST(8)) / FX32_CONST(16) <= task->slowDownZ) { + if (++task->calledTramElapsedFrames >= sCalledTramFramesPerSpeedLevel[task->speedLevel]) { + if (task->speedLevel == 0) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN03); + } + + task->speedLevel++; + task->calledTramElapsedFrames = 0; + } + } + } else { + tramPosition->z += sCalledTramSpeeds[task->speedLevel]; + + if (task->speedLevel < NELEMS(sCalledTramFramesPerSpeedLevel) - 1 && (tramPosition->z - FX32_CONST(8)) / FX32_CONST(16) >= task->slowDownZ) { + if (++task->calledTramElapsedFrames >= sCalledTramFramesPerSpeedLevel[task->speedLevel]) { + if (task->speedLevel == 0) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN03); + } + + task->speedLevel++; + task->calledTramElapsedFrames = 0; + } + } + } + + return tramPosition->z == *destZ; +} + +static BOOL RideTramToArea(FieldSystem *fieldSystem, GreatMarshTramMovementTask *task, const fx32 *destZ, VecFx32 *tramPosition) +{ + VecFx32 playerPos; + MapObject *playerObj = Player_MapObject(fieldSystem->playerAvatar); + PlayerAvatar_PosVectorOut(fieldSystem->playerAvatar, &playerPos); + + tramPosition->z = playerPos.z + FX32_CONST(8); + + if (tramPosition->z == *destZ) { + return TRUE; + } else if (!task->isMovingSouth) { + if (LocalMapObj_IsAnimationSet(playerObj) == TRUE) { + LocalMapObj_SetAnimationCode(playerObj, sRidingTramNorthMovements[task->speedLevel]); + + if (task->speedLevel < NELEMS(sRidingTramNorthMovements) - 1 && Player_GetZPos(fieldSystem->playerAvatar) > task->slowDownZ) { + if (task->speedLevel == 0) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN02); + } + + task->speedLevel++; + } else if (Player_GetZPos(fieldSystem->playerAvatar) <= task->slowDownZ) { + if (task->speedLevel != 0) { + if (task->speedLevel == NELEMS(sRidingTramNorthMovements) - 1) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN03); + } + + task->speedLevel--; + } + } + } + } else if (LocalMapObj_IsAnimationSet(playerObj) == TRUE) { + LocalMapObj_SetAnimationCode(playerObj, sRidingTramSouthMovements[task->speedLevel]); + + if (task->speedLevel < NELEMS(sRidingTramSouthMovements) - 1 && Player_GetZPos(fieldSystem->playerAvatar) < task->slowDownZ) { + if (task->speedLevel == 0) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN02); + } + + task->speedLevel++; + } else if (Player_GetZPos(fieldSystem->playerAvatar) >= task->slowDownZ) { + if (task->speedLevel != 0) { + if (task->speedLevel == NELEMS(sRidingTramSouthMovements) - 1) { + Sound_PlayEffect(SEQ_SE_DP_TRAIN03); + } + + task->speedLevel--; + } + } + } + + return FALSE; +} diff --git a/src/overlay006/ov6_02242AF0.c b/src/overlay006/ov6_02242AF0.c deleted file mode 100644 index 5402a224b2..0000000000 --- a/src/overlay006/ov6_02242AF0.c +++ /dev/null @@ -1,344 +0,0 @@ -#include "overlay006/ov6_02242AF0.h" - -#include -#include - -#include "constants/field/dynamic_map_features.h" -#include "constants/great_marsh_tram.h" - -#include "struct_decls/struct_02061AB4_decl.h" - -#include "field/field_system.h" -#include "overlay005/area_data.h" -#include "overlay005/map_prop.h" -#include "overlay005/map_prop_animation.h" - -#include "field_system.h" -#include "field_task.h" -#include "heap.h" -#include "persisted_map_features.h" -#include "player_avatar.h" -#include "savedata_misc.h" -#include "sound_playback.h" -#include "unk_020655F4.h" - -#include "res/field/props/models/prop_models.naix" - -typedef struct UnkStruct_ov6_02242B58_t UnkStruct_ov6_02242B58; - -typedef BOOL (*UnkFuncPtr_ov6_02242B58)(FieldSystem *, UnkStruct_ov6_02242B58 *, const fx32 *, VecFx32 *); - -typedef struct UnkStruct_ov6_02242B58_t { - UnkFuncPtr_ov6_02242B58 unk_00; - u8 unk_04; - u8 unk_05; - u8 unk_06; - u8 unk_07; - int unk_08; - fx32 unk_0C; - int unk_10; -} UnkStruct_ov6_02242B58; - -static BOOL ov6_02242C5C(FieldTask *taskMan); -static BOOL ov6_02242D94(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3); -static BOOL ov6_02242E60(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3); - -static const int Unk_ov6_02249058[7] = { - 0x4, - 0x8, - 0xC, - 0xC, - 0x10, - 0x10, - 0x14 -}; - -static const int Unk_ov6_0224903C[7] = { - 0x5, - 0x9, - 0xD, - 0xD, - 0x11, - 0x11, - 0x15 -}; - -static const u8 Unk_ov6_02249034[] = { - 0x2, - 0x4, - 0x4, - 0x8, - 0x8, - 0x10, - 0x20 -}; - -static const fx32 Unk_ov6_02249074[] = { - FX32_ONE * 8, - FX32_ONE * 4, - FX32_ONE * 4, - FX32_ONE * 2, - FX32_ONE * 2, - FX32_ONE * 1, - FX32_ONE / 2, -}; - -void GreatMarshTram_DynamicMapFeaturesInit(FieldSystem *fieldSystem) -{ - PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); - GreatMarshTramState *tramState = (GreatMarshTramState *)PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); - - VecFx32 position; - position.x = (FX32_ONE * 16) * (32 * 2 + 2); - position.y = FX32_ONE * 16; - - switch (tramState->location) { - case GREAT_MARSH_TRAM_LOCATION_AREA_1_2: - position.z = (FX32_ONE * 16) * (32 * 1 + 8); - break; - case GREAT_MARSH_TRAM_LOCATION_AREA_3_4: - position.z = (FX32_ONE * 16) * (32 * 2 + 18); - break; - case GREAT_MARSH_TRAM_LOCATION_AREA_5_6: - position.z = (FX32_ONE * 16) * (32 * 3 + 12); - break; - } - - MapPropManager_LoadOne(fieldSystem->mapPropManager, fieldSystem->areaDataManager, 475, &position, NULL, fieldSystem->mapPropAnimMan); -} - -void GreatMarshTram_MoveToLocation(FieldSystem *fieldSystem, u16 destination, u16 movementType) -{ - PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); - GreatMarshTramState *tramState = (GreatMarshTramState *)PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); - UnkStruct_ov6_02242B58 *v2 = Heap_AllocAtEnd(HEAP_ID_FIELD1, sizeof(UnkStruct_ov6_02242B58)); - - memset(v2, 0, sizeof(UnkStruct_ov6_02242B58)); - - v2->unk_05 = 0; - - switch (tramState->location) { - case GREAT_MARSH_TRAM_LOCATION_AREA_1_2: - v2->unk_04 = 1; - - if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_3_4) { - v2->unk_0C = (FX32_ONE * 16) * (32 * 2 + 18); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_3_4; - v2->unk_10 = 32 * 2 + 10; - } else { - v2->unk_0C = (FX32_ONE * 16) * (32 * 3 + 12); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_5_6; - v2->unk_10 = 32 * 3 + 4; - } - break; - case GREAT_MARSH_TRAM_LOCATION_AREA_3_4: - if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_1_2) { - v2->unk_04 = 0; - v2->unk_0C = (FX32_ONE * 16) * (32 * 1 + 8); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_1_2; - v2->unk_10 = 32 * 1 + 14; - } else { - v2->unk_04 = 1; - v2->unk_0C = (FX32_ONE * 16) * (32 * 3 + 12); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_5_6; - v2->unk_10 = 32 * 3 + 4; - } - break; - case GREAT_MARSH_TRAM_LOCATION_AREA_5_6: - v2->unk_04 = 0; - - if (destination == GREAT_MARSH_TRAM_LOCATION_AREA_1_2) { - v2->unk_0C = (FX32_ONE * 16) * (32 * 1 + 8); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_1_2; - v2->unk_10 = 32 * 1 + 14; - } else { - v2->unk_0C = (FX32_ONE * 16) * (32 * 2 + 18); - tramState->location = GREAT_MARSH_TRAM_LOCATION_AREA_3_4; - v2->unk_10 = 32 * 2 + 24; - } - break; - default: - GF_ASSERT(FALSE); - break; - } - - v2->unk_08 = movementType; - - if (movementType == GREAT_MARSH_TRAM_MOVEMENT_CALL) { - v2->unk_00 = ov6_02242D94; - } else { - v2->unk_00 = ov6_02242E60; - } - - FieldTask_InitCall(fieldSystem->task, ov6_02242C5C, v2); -} - -u32 GreatMarshTram_CheckLocation(FieldSystem *fieldSystem, u16 location) -{ - PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); - GreatMarshTramState *tramState = (GreatMarshTramState *)PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_GREAT_MARSH); - - if (tramState->location == location) { - return GREAT_MARSH_TRAM_AT_LOCATION; - } else { - return GREAT_MARSH_TRAM_NOT_AT_LOCATION; - } -} - -static BOOL ov6_02242C5C(FieldTask *taskMan) -{ - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_ov6_02242B58 *v1 = FieldTask_GetEnv(taskMan); - - switch (v1->unk_05) { - case 0: - - { - NNSG3dResMdl *v2; - NNSG3dResFileHeader **v3; - MapProp *v4; - NNSG3dRenderObj *v5; - - v4 = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, great_marsh_train_nsbmd); - v5 = MapProp_GetRenderObj(v4); - v3 = AreaDataManager_GetMapPropModelFile(great_marsh_train_nsbmd, fieldSystem->areaDataManager); - v2 = NNS_G3dGetMdlByIdx(NNS_G3dGetMdlSet(*v3), 0); - - MapPropOneShotAnimationManager_LoadPropAnimations(fieldSystem->mapPropAnimMan, fieldSystem->mapPropOneShotAnimMan, 16, great_marsh_train_nsbmd, v5, v2, AreaDataManager_GetMapPropTexture(fieldSystem->areaDataManager), 1, -1, 0); - MapPropOneShotAnimationManager_PlayAnimation(fieldSystem->mapPropOneShotAnimMan, 16, 0); - } - (v1->unk_05)++; - break; - case 1: - if (v1->unk_08 == 4) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN04); - } - - (v1->unk_05)++; - case 2: - if (!Sound_IsEffectPlaying(1755)) { - (v1->unk_05)++; - } - break; - case 3: - - { - MapProp *v6; - VecFx32 v7; - - v6 = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, great_marsh_train_nsbmd); - v7 = MapProp_GetPosition(v6); - - if (v1->unk_00(fieldSystem, v1, &v1->unk_0C, &v7)) { - (v1->unk_05)++; - } - - MapProp_SetPosition(v6, &v7); - } break; - case 4: - MapPropOneShotAnimationManager_UnloadAnimation(fieldSystem->mapPropAnimMan, fieldSystem->mapPropOneShotAnimMan, 16); - (v1->unk_05)++; - break; - case 5: - Heap_Free(v1); - return 1; - } - - return 0; -} - -static BOOL ov6_02242D94(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3) -{ - if (param1->unk_04 == 0) { - param3->z -= Unk_ov6_02249074[param1->unk_06]; - - if ((param1->unk_06 < 7 - 1) && ((param3->z - ((FX32_ONE * 16) / 2)) / (FX32_ONE * 16) <= param1->unk_10)) { - if (++(param1->unk_07) >= Unk_ov6_02249034[param1->unk_06]) { - if (param1->unk_06 == 0) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN03); - } - - param1->unk_06++; - param1->unk_07 = 0; - } - } - } else { - param3->z += Unk_ov6_02249074[param1->unk_06]; - - if ((param1->unk_06 < 7 - 1) && ((param3->z - ((FX32_ONE * 16) / 2)) / (FX32_ONE * 16) >= param1->unk_10)) { - if (++(param1->unk_07) >= Unk_ov6_02249034[param1->unk_06]) { - if (param1->unk_06 == 0) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN03); - } - - param1->unk_06++; - param1->unk_07 = 0; - } - } - } - - if (param3->z == (*param2)) { - return 1; - } else { - return 0; - } -} - -static BOOL ov6_02242E60(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3) -{ - MapObject *v0; - VecFx32 v1; - - v0 = Player_MapObject(fieldSystem->playerAvatar); - PlayerAvatar_PosVectorOut(fieldSystem->playerAvatar, &v1); - - param3->z = v1.z + ((FX32_ONE * 16) / 2); - - if (param3->z == (*param2)) { - return 1; - } else { - if (param1->unk_04 == 0) { - if (LocalMapObj_IsAnimationSet(v0) == 1) { - LocalMapObj_SetAnimationCode(v0, Unk_ov6_02249058[param1->unk_06]); - - if ((param1->unk_06 < 7 - 1) && (Player_GetZPos(fieldSystem->playerAvatar) > param1->unk_10)) { - if (param1->unk_06 == 0) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN02); - } - - param1->unk_06++; - } else if (Player_GetZPos(fieldSystem->playerAvatar) <= param1->unk_10) { - if (param1->unk_06 != 0) { - if (param1->unk_06 == 7 - 1) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN03); - } - - param1->unk_06--; - } - } - } - } else { - if (LocalMapObj_IsAnimationSet(v0) == 1) { - LocalMapObj_SetAnimationCode(v0, Unk_ov6_0224903C[param1->unk_06]); - - if ((param1->unk_06 < 7 - 1) && (Player_GetZPos(fieldSystem->playerAvatar) < param1->unk_10)) { - if (param1->unk_06 == 0) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN02); - } - - param1->unk_06++; - } else if (Player_GetZPos(fieldSystem->playerAvatar) >= param1->unk_10) { - if (param1->unk_06 != 0) { - if (param1->unk_06 == 7 - 1) { - Sound_PlayEffect(SEQ_SE_DP_TRAIN03); - } - - param1->unk_06--; - } - } - } - } - } - - return 0; -} diff --git a/src/persisted_map_features_init.c b/src/persisted_map_features_init.c index a87d50eab8..7d8b2b6f45 100644 --- a/src/persisted_map_features_init.c +++ b/src/persisted_map_features_init.c @@ -16,7 +16,7 @@ #include "field/field_system.h" #include "field/field_system_sub2_t.h" -#include "overlay006/ov6_02242AF0.h" +#include "overlay006/great_marsh_tram.h" #include "overlay009/ov9_02249960.h" #include "field_system.h" diff --git a/src/scrcmd.c b/src/scrcmd.c index d413585d6c..52790f181f 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -68,11 +68,11 @@ #include "overlay005/size_contest.h" #include "overlay005/vs_seeker.h" #include "overlay006/elevator_animation.h" +#include "overlay006/great_marsh_tram.h" #include "overlay006/healing_machine_animation.h" #include "overlay006/hm_cut_in.h" #include "overlay006/npc_trade.h" #include "overlay006/ov6_0223E140.h" -#include "overlay006/ov6_02242AF0.h" #include "overlay006/ov6_02243004.h" #include "overlay006/ov6_02247830.h" #include "overlay006/ov6_02247F5C.h"