Start documenting Distortion World and its camera (#464)
Some checks are pending
build / build (push) Waiting to run

This commit is contained in:
RavePossum
2025-06-30 17:00:30 -04:00
committed by GitHub
16 changed files with 1095 additions and 1064 deletions

View File

@@ -4537,7 +4537,7 @@
.short \arg1
.endm
.macro ScrCmd_31F
.macro ResetDistortionWorldPersistedCameraAngles
.short 799
.endm

View File

@@ -591,4 +591,5 @@ MAP_HEADER_MT_CORONET_ICEBERG_RUINS
MAP_HEADER_ICEBERG_RUINS
MAP_HEADER_ROUTE_228_ROCK_PEAK_RUINS
MAP_HEADER_ROCK_PEAK_RUINS
MAP_HEADER_COUNT
MAP_HEADER_DYNAMIC = 4095

10
include/constants/types.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef POKEPLATINUM_CONSTANTS_TYPES_H
#define POKEPLATINUM_CONSTANTS_TYPES_H
#define S16_INT_MASK 0x7FFF
#define S16_SIGN_MASK 0x8000
#define S32_INT_MASK 0x7FFFFFFF
#define S32_SIGN_MASK 0x80000000
#endif // POKEPLATINUM_CONSTANTS_TYPES_H

View File

@@ -0,0 +1,14 @@
#ifndef POKEPLATINUM_STRUCT_CAMERA_CONFIGURATION_H
#define POKEPLATINUM_STRUCT_CAMERA_CONFIGURATION_H
#include "camera.h"
typedef struct {
fx32 distance;
CameraAngle cameraAngle;
u8 projectionMtx;
u16 fovY;
u8 padding_0F;
} CameraConfiguration;
#endif // POKEPLATINUM_STRUCT_CAMERA_CONFIGURATION_H

View File

@@ -9,11 +9,24 @@
#include "field_task.h"
void DistortionWorld_DynamicMapFeaturesInit(FieldSystem *fieldSystem);
void DistortionWorld_DynamicMapFeaturesFree(FieldSystem *fieldSystem);
BOOL DistortionWorld_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding);
void ov9_02249F9C(FieldSystem *fieldSystem);
void ov9_02249FD0(FieldSystem *fieldSystem);
typedef struct DistWorldPersistedData {
u32 valid : 1;
u32 unk_00_1 : 24;
u32 unk_00_25 : 4;
u32 padding : 3;
u16 cameraAngleX;
u16 cameraAngleY;
u16 cameraAngleZ;
u16 unk_0A;
u32 unk_0C;
u8 reserved_10[16];
} DistWorldPersistedData;
void DistWorld_DynamicMapFeaturesInit(FieldSystem *fieldSystem);
void DistWorld_DynamicMapFeaturesFree(FieldSystem *fieldSystem);
BOOL DistWorld_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding);
void DistWorld_UpdateCameraAngle(FieldSystem *fieldSystem);
void DistWorld_ResetPersistedCameraAngles(FieldSystem *fieldSystem);
int ov9_0224A520(FieldSystem *fieldSystem, MapObject *param1);
void ov9_0224A558(FieldSystem *fieldSystem, UnkStruct_020216E0 *param1, int param2);
void ov9_0224A564(FieldSystem *fieldSystem, const UnkStruct_020216E0 *param1);

View File

@@ -1,14 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_OV9_02249FF4_H
#define POKEPLATINUM_STRUCT_OV9_02249FF4_H
#include "camera.h"
typedef struct {
fx32 unk_00;
CameraAngle cameraAngle;
u8 unk_0C;
u16 unk_0E;
u8 padding_0F;
} UnkStruct_ov9_02249FF4;
#endif // POKEPLATINUM_STRUCT_OV9_02249FF4_H

View File

@@ -1,17 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_02071C5C_H
#define POKEPLATINUM_STRUCT_02071C5C_H
typedef struct {
u32 unk_00_0 : 1;
u32 unk_00_1 : 24;
u32 unk_00_25 : 4;
u32 : 3;
u16 unk_04;
u16 unk_06;
u16 unk_08;
u16 unk_0A;
u32 unk_0C;
u8 reserved_10[16];
} UnkStruct_02071C5C;
#endif // POKEPLATINUM_STRUCT_02071C5C_H

View File

@@ -23,7 +23,7 @@ _0026:
End
_0033:
ScrCmd_31F
ResetDistortionWorldPersistedCameraAngles
SetVar VAR_DISTORTION_WORLD_PROGRESS, 14
RemoveObject 128
End

View File

@@ -27,7 +27,7 @@ const static DynamicMapFeaturesInitFunc sInitFuncs[DYNAMIC_MAP_FEATURES_COUNT] =
GreatMarsh_DynamicMapFeaturesInit,
PlatformLift_DynamicMapFeaturesInit,
EternaGym_DynamicMapFeaturesInit,
DistortionWorld_DynamicMapFeaturesInit,
DistWorld_DynamicMapFeaturesInit,
Villa_DynamicMapFeaturesInit
};
@@ -41,7 +41,7 @@ const static DynamicMapFeaturesFreeFunc sFreeFuncs[DYNAMIC_MAP_FEATURES_COUNT] =
NULL,
NULL,
EternaGym_DynamicMapFeaturesFree,
DistortionWorld_DynamicMapFeaturesFree,
DistWorld_DynamicMapFeaturesFree,
Villa_DynamicMapFeaturesFree
};
@@ -55,7 +55,7 @@ const static DynamicMapFeaturesCheckCollisionFunc sCheckCollisionFuncs[DYNAMIC_M
NULL,
NULL,
EternaGym_DynamicMapFeaturesCheckCollision,
DistortionWorld_DynamicMapFeaturesCheckCollision,
DistWorld_DynamicMapFeaturesCheckCollision,
Villa_DynamicMapFeaturesCheckCollision
};

View File

@@ -694,7 +694,7 @@ static void ov5_021D15F4(FieldSystem *fieldSystem)
if (fieldSystem->unk_20 == 1) {
if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) {
ov9_02249F9C(fieldSystem);
DistWorld_UpdateCameraAngle(fieldSystem);
}
Camera_ComputeViewMatrixWithRoll();

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
#include "struct_defs/struct_0207C690.h"
#include "struct_defs/struct_02099F80.h"
#include "overlay009/struct_ov9_02249FF4.h"
#include "overlay009/camera_configuration.h"
#include "overlay077/ov77_021D54B0.h"
#include "overlay077/ov77_021D6670.h"
#include "overlay077/ov77_021D6C70.h"
@@ -199,7 +199,7 @@ const int Unk_ov77_021D779C[][6] = {
{ 0x6E, 0x6F, 0x0, 0x0, 0x0, 0x0 }
};
static const UnkStruct_ov9_02249FF4 Unk_ov77_021D74FC = {
static const CameraConfiguration Unk_ov77_021D74FC = {
0x29AEC1,
{ -0x29fe, 0x0, 0x0 },
0x0,
@@ -1734,7 +1734,7 @@ static void ov77_021D4044(UnkStruct_ov77_021D37C0 *param0, int param1)
{
VecFx32 v0 = { 0, 0, FX32_ONE * 16 * 6 };
Camera_InitWithTarget(&v0, Unk_ov77_021D74FC.unk_00, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.unk_0E, Unk_ov77_021D74FC.unk_0C, 0, param0->unk_20.camera);
Camera_InitWithTarget(&v0, Unk_ov77_021D74FC.distance, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.fovY, Unk_ov77_021D74FC.projectionMtx, 0, param0->unk_20.camera);
Camera_SetFOV(0x981, param0->unk_20.camera);
{
@@ -2370,7 +2370,7 @@ static void ov77_021D4F38(UnkStruct_ov77_021D37C0 *param0, const int param1)
Camera_Move(&v0, param0->unk_20.camera);
} else if (param1 == ((40 * 30 - 15) + 6)) {
VecFx32 v2 = { -(FX32_ONE * 16 * 4), 0, -FX32_ONE * 16 * 3 };
Camera_InitWithTarget(&v2, Unk_ov77_021D74FC.unk_00, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.unk_0E, Unk_ov77_021D74FC.unk_0C, 0, param0->unk_20.camera);
Camera_InitWithTarget(&v2, Unk_ov77_021D74FC.distance, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.fovY, Unk_ov77_021D74FC.projectionMtx, 0, param0->unk_20.camera);
{
VecFx32 v3 = { 0, (FX32_ONE * 16 * 5), 0 };
@@ -2406,7 +2406,7 @@ static void ov77_021D4F38(UnkStruct_ov77_021D37C0 *param0, const int param1)
Bg_ScheduleScroll(param0->unk_10, 1, 1, 4);
} else if (param1 == ((47 * 30 - 15) + 6)) {
VecFx32 v6 = { FX32_ONE * 16 * 30, 0, FX32_ONE * 0 - 0x70000 };
Camera_InitWithTarget(&v6, Unk_ov77_021D74FC.unk_00, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.unk_0E, Unk_ov77_021D74FC.unk_0C, 0, param0->unk_20.camera);
Camera_InitWithTarget(&v6, Unk_ov77_021D74FC.distance, &Unk_ov77_021D74FC.cameraAngle, Unk_ov77_021D74FC.fovY, Unk_ov77_021D74FC.projectionMtx, 0, param0->unk_20.camera);
{
VecFx32 v7 = { 0, (FX32_ONE * 16 * 5), 0 };
Camera_Move(&v7, param0->unk_20.camera);

View File

@@ -6,7 +6,7 @@
#include "struct_defs/struct_0206C8D4.h"
#include "struct_defs/struct_02099F80.h"
#include "overlay009/struct_ov9_02249FF4.h"
#include "overlay009/camera_configuration.h"
#include "camera.h"
#include "easy3d.h"
@@ -42,7 +42,7 @@ static void ov93_021D0FA8(void);
static void ov93_021D100C(void);
static void ov93_021D102C(UnkStruct_ov93_021D102C *param0);
static const UnkStruct_ov9_02249FF4 Unk_ov93_021D14B8 = {
static const CameraConfiguration Unk_ov93_021D14B8 = {
0x29AEC1,
{ -0x29fe, 0x0, 0x0 },
0x0,
@@ -102,7 +102,7 @@ int ov93_021D0D80(ApplicationManager *appMan, int *param1)
{
VecFx32 v3 = { 0, 0, 0 };
Camera_InitWithTarget(&v3, Unk_ov93_021D14B8.unk_00, &Unk_ov93_021D14B8.cameraAngle, Unk_ov93_021D14B8.unk_0E, Unk_ov93_021D14B8.unk_0C, 0, v1->camera);
Camera_InitWithTarget(&v3, Unk_ov93_021D14B8.distance, &Unk_ov93_021D14B8.cameraAngle, Unk_ov93_021D14B8.fovY, Unk_ov93_021D14B8.projectionMtx, 0, v1->camera);
Camera_SetAsActive(v1->camera);
}

View File

@@ -6,7 +6,7 @@
#include "struct_defs/struct_0206C8D4.h"
#include "struct_defs/struct_02099F80.h"
#include "overlay009/struct_ov9_02249FF4.h"
#include "overlay009/camera_configuration.h"
#include "camera.h"
#include "easy3d.h"
@@ -42,7 +42,7 @@ static void ov93_021D133C(void);
static void ov93_021D13A0(void);
static void ov93_021D13C0(UnkStruct_ov93_021D13C0 *param0);
static const UnkStruct_ov9_02249FF4 Unk_ov93_021D1534 = {
static const CameraConfiguration Unk_ov93_021D1534 = {
0x29AEC1,
{ -0x29fe, 0x0, 0x0 },
0x0,
@@ -103,7 +103,7 @@ int ov93_021D111C(ApplicationManager *appMan, int *param1)
{
VecFx32 v3 = { 0, 0, 0 };
Camera_InitWithTarget(&v3, Unk_ov93_021D1534.unk_00, &Unk_ov93_021D1534.cameraAngle, Unk_ov93_021D1534.unk_0E, Unk_ov93_021D1534.unk_0C, 0, v1->camera);
Camera_InitWithTarget(&v3, Unk_ov93_021D1534.distance, &Unk_ov93_021D1534.cameraAngle, Unk_ov93_021D1534.fovY, Unk_ov93_021D1534.projectionMtx, 0, v1->camera);
Camera_SetAsActive(v1->camera);
}

View File

@@ -12,11 +12,11 @@
#include "struct_defs/struct_02071BF8.h"
#include "struct_defs/struct_02071C18.h"
#include "struct_defs/struct_02071C34.h"
#include "struct_defs/struct_02071C5C.h"
#include "field/field_system.h"
#include "field/field_system_sub2_t.h"
#include "overlay006/struct_ov6_02242AF0.h"
#include "overlay009/ov9_02249960.h"
#include "field_system.h"
#include "persisted_map_features.h"
@@ -146,8 +146,8 @@ void PersistedMapFeatures_InitForDistortionWorld(FieldSystem *fieldSystem)
PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem));
PersistedMapFeatures_InitWithID(persistedMapFeatures, DYNAMIC_MAP_FEATURES_DISTORTION_WORLD);
UnkStruct_02071C5C *data = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_DISTORTION_WORLD);
memset(data, 0, sizeof(UnkStruct_02071C5C));
DistWorldPersistedData *data = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_DISTORTION_WORLD);
memset(data, 0, sizeof(DistWorldPersistedData));
}
static void sub_02071C80(const u8 param0, const u8 param1, int *param2)

View File

@@ -732,7 +732,7 @@ static BOOL ScrCmd_GetRotomFormsInSave(ScriptContext *ctx);
static BOOL ScrCmd_IncrementTrainerScore(ScriptContext *ctx);
static BOOL ScrCmd_311(ScriptContext *ctx);
static BOOL ScrCmd_312(ScriptContext *ctx);
static BOOL ScrCmd_31F(ScriptContext *ctx);
static BOOL ScrCmd_ResetDistortionWorldPersistedCameraAngles(ScriptContext *ctx);
static BOOL ScrCmd_313(ScriptContext *ctx);
static BOOL ScrCmd_StartGiratinaOriginBattle(ScriptContext *ctx);
static BOOL ScrCmd_WriteSpeciesSeen(ScriptContext *ctx);
@@ -1567,7 +1567,7 @@ const ScrCmdFunc Unk_020EAC58[] = {
ScrCmd_CheckPartyHasFatefulEncounter,
ScrCmd_31D,
ScrCmd_31E,
ScrCmd_31F,
ScrCmd_ResetDistortionWorldPersistedCameraAngles,
ScrCmd_320,
ScrCmd_321,
ScrCmd_322,
@@ -7869,11 +7869,11 @@ static BOOL ScrCmd_312(ScriptContext *ctx)
return FALSE;
}
static BOOL ScrCmd_31F(ScriptContext *ctx)
static BOOL ScrCmd_ResetDistortionWorldPersistedCameraAngles(ScriptContext *ctx)
{
FieldSystem *fieldSystem = ctx->fieldSystem;
ov9_02249FD0(fieldSystem);
DistWorld_ResetPersistedCameraAngles(fieldSystem);
return FALSE;
}