Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions config/us/pilotwings64.us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ segments:
- [0xD7AF0, data]
- [0xD7B80, data]
- [0xD7BC0, data]
- [0xD7D20, data]
- [0xD7D20, .data, app/thermals]
- [0xD7D30, data]
- [0xD7E10, data]
- [0xD7EF0, data]
- [0xD7F40, .rodata, app/code_51E30]
Expand Down Expand Up @@ -611,7 +612,9 @@ segments:
- [0xDE640, .rodata, app/code_D4290]
- [0xDE6B0, .rodata, app/wind_objects]

- { type: bss, start: 0xDE720, vram: 0x803571F0, name: app_bss }
- { type: bss, vram: 0x803571F0, name: app_bss_803571F0 }
- { type: .bss, vram: 0x8037AB50, name: app/thermals }
- { type: bss, vram: 0x8037ACE0, name: app_bss_8037ACD8 }

- name: bin_DE720
type: bin
Expand Down
7 changes: 7 additions & 0 deletions config/us/sym/symbol_addrs_app.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ levelDataGetPHTS = 0x80345C3C; // type:func
levelDataGetFALC = 0x80345C5C; // type:func
levelDataGetHOPD = 0x80346474; // type:func

thermInit = 0x803465F0; // type:func
therm_8034662C = 0x8034662C; // type:func
therm_8034695C = 0x8034695C; // type:func
therm_80346B84 = 0x80346B84; // type:func
therm_80346C08 = 0x80346C08; // type:func
therm_80346E04 = 0x80346E04; // type:func

windObjectsInit = 0x8034E080; // type:func

mem_get = 0x80312740; // type:func
Expand Down
3 changes: 3 additions & 0 deletions config/us/sym/symbol_addrs_kernel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ gLevelClassU8 = 0x80350790;
gLevelVehicleU8 = 0x80350794;
gLevelTestU8 = 0x80350798;
gMapLookup = 0x803507A8;
gThermShouldDisable = 0x803507F0;

gTitleMenuDelay = 0x80356A68;

Expand All @@ -510,8 +511,10 @@ gLevelClass = 0x8037AA78;
gLevelTest = 0x8037AA7C;
gLevelVehicle = 0x8037AA80;

gLevelTHER = 0x8037AB50;
gThermalCount = 0x8037AB54;
gThermals = 0x8037AB58; // size:0x180
gThermReady = 0x8037ACD8;

gLevelCurMap = 0x8034F40C;
gLevelObjHeapPtr = 0x8034F840;
Expand Down
5 changes: 4 additions & 1 deletion docs/pilotwings64_file_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,11 @@ Offset | Type | Description
0x8 | f32 | Z position
0xC | f32 | scale
0x10 | f32 | height
0x14 | ?? | TBD
0x14 | s32 | TBD
0x18 | f32 | TBD
0x1C | f32 | TBD
0x20 | f32 | TBD
0x24 | f32 | TBD
0x28 | | **Total length**

### TPAD / takeoff pad
Expand Down
27 changes: 24 additions & 3 deletions include/uv_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,34 @@ typedef struct {
u8 pad1C[4];
} LevelHOPD;

typedef struct {
u8 countESND;
u8 countWOBJ;
u8 countLPAD;
u8 countTOYS;
u8 countTPTS;
u8 countAPTS;
u8 countBNUS;
} LevelLEVL;

typedef struct {
f32 x;
f32 y;
f32 z;
f32 unkC;
} LevelOBSV;

typedef struct {
Vec3F pos;
f32 scale;
f32 height;
s32 unk14;
f32 unk18;
f32 unk1C;
f32 unk20;
f32 unk24;
} LevelTHER;

typedef struct {
u8 unk0;
u8 unk1[3];
Expand All @@ -136,7 +157,7 @@ typedef struct {
} LevelTOYS;

typedef struct {
u8 unk0;
u8 countESND;
u8 countWOBJ;
u8 countLPAD;
u8 countTOYS;
Expand Down Expand Up @@ -192,7 +213,7 @@ typedef struct {
void* dataNAME; // ptr NAME
void* dataINFO; // ptr INFO
void* dataJPTX; // ptr JPTX
void* dataTHER; // ptr THER
LevelTHER* dataTHER; // ptr THER
void* dataLWIN; // ptr LWIN
void* dataTPAD; // ptr TPAD
void* dataLPAD; // ptr LPAD
Expand Down Expand Up @@ -251,7 +272,7 @@ u8 levelGet_80346364(void);
s32 level_80346370(s32 terra);
void level_8034528C(void);
u8 levelGet_80346468(void);
s32 levelDataGetTHER(void** data);
s32 levelDataGetTHER(LevelTHER** data);
s32 levelDataGetLWIN(void** data);
s32 levelDataGetTPAD(void** data);
s32 levelDataGetCNTG(void** data);
Expand Down
18 changes: 17 additions & 1 deletion src/app/code_69BF0.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@

#include <uv_level.h>

void func_802E27A8(void*);
typedef struct {
Mtx4F unk0;
Vec3F unk40;
Vec3F unk4C;
s8 unk58;
u8 pad59[3];
f32 unk5C;
f32 unk60;
s32 unk64;
f32 unk68;
f32 unk6C;
s8 unk70;
u8 pad71[3];
s32 unk74;
} Unk802E27A8_Arg0;

void func_802E27A8(Unk802E27A8_Arg0*);
void func_802E344C(Unk80345464_Arg0*);

#endif // APP_CODE_69BF0_H
93 changes: 30 additions & 63 deletions src/app/code_D4290.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@
#include <uv_dobj.h>
#include <uv_math.h>

// This is probably part of another struct but unsure which one it is
typedef struct {
s8 unk0;
f32 unk4;
f32 unk8;
s32 unkC;
f32 unk10;
f32 unk14;
s8 unk18;
s32 unk1C;
} WindRenderSPStruct;

// size: 0xA8
typedef struct {
u16 unk0;
Expand Down Expand Up @@ -60,23 +48,11 @@ static f32 func_8034DFC4(u8, f32);
void func_8034CD60(void) {
}

// wind_render has sp120/sp114 which are just assigned but never used
// this is probably related to WindRenderSPStruct assignments and will be resolved once
// the actual struct this is part of is resolved
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
void wind_render(void) {
s32 i;
Unk8037F518* var_s1;
Unk8037F510* temp_s0;
WindRenderSPStruct sp148;
Vec3F sp120;
Vec3F sp114;
Mtx4F spD4;
Unk802E27A8_Arg0 spD4;
f32 temp_fs0;
f32 var_fv1;
Vec3F spC0;
Expand All @@ -96,28 +72,24 @@ void wind_render(void) {
return;
}
for (i = 0; i < D_8037F514; i++) {
// @fake to force correct s registers
if (&spA8) { }
if (&spC0) { }
if (&spB4) { }
var_s1 = &D_8037F518[i];
temp_s0 = &D_8037F510[i];
uvMat4SetIdentity(&var_s1->unk4);
uvMat4SetIdentity(&spD4);
spD4.m[3][0] = temp_s0->unk0.f[0];
spD4.m[3][1] = temp_s0->unk0.f[1];
spD4.m[3][2] = temp_s0->unk0.f[2];
sp148.unk0 = 0xB;
sp148.unk4 = 1.0f;
sp148.unkC = 0;
sp148.unk10 = temp_s0->unk4C;
sp148.unk14 = sp148.unk10;
sp148.unk18 = temp_s0->unk3C;
sp148.unk8 = uvSqrtF(SQ(temp_s0->unk40.x) + SQ(temp_s0->unk40.y) + SQ(temp_s0->unk40.z)) + 0.9f;
if (sp148.unk8 < 0.0f) {
sp148.unk8 = 0.0f;
} else if (sp148.unk8 > 1.0f) {
sp148.unk8 = 1.0f;
uvMat4SetIdentity(&spD4.unk0);
spD4.unk0.m[3][0] = temp_s0->unk0.f[0];
spD4.unk0.m[3][1] = temp_s0->unk0.f[1];
spD4.unk0.m[3][2] = temp_s0->unk0.f[2];
spD4.unk58 = 0xB;
spD4.unk5C = 1.0f;
spD4.unk64 = 0;
spD4.unk68 = temp_s0->unk4C;
spD4.unk6C = spD4.unk68;
spD4.unk70 = temp_s0->unk3C;
spD4.unk60 = uvSqrtF(SQ(temp_s0->unk40.x) + SQ(temp_s0->unk40.y) + SQ(temp_s0->unk40.z)) + 0.9f;
if (spD4.unk60 < 0.0f) {
spD4.unk60 = 0.0f;
} else if (spD4.unk60 > 1.0f) {
spD4.unk60 = 1.0f;
}
s2 = &temp_s0->unkC;
if (temp_s0->unk50 == 0) {
Expand All @@ -130,9 +102,9 @@ void wind_render(void) {
uvDobjPosm(var_s1->unk0, 0, &var_s1->unk4);
uvDobjState(var_s1->unk0, 2U);
uvDobjProps(var_s1->unk0, 3, temp_s0->unk4C, 0);
sp148.unk1C = 8;
sp114 = temp_s0->unk0;
sp120 = temp_s0->unkC;
spD4.unk74 = 8;
spD4.unk40 = temp_s0->unk0;
spD4.unk4C = temp_s0->unkC;
} else if (temp_s0->unk50 == 1) {
spB4.f[0] = s2->f[0] - temp_s0->unk0.f[0];
spB4.f[1] = s2->f[1] - temp_s0->unk0.f[1];
Expand Down Expand Up @@ -176,9 +148,9 @@ void wind_render(void) {
var_fv1 = temp_fs0;
}
uvDobjProps(var_s1->unk0, 3, var_fv1, 0);
sp148.unk1C = 0xA;
sp114 = temp_s0->unk0;
sp120 = temp_s0->unkC;
spD4.unk74 = 0xA;
spD4.unk40 = temp_s0->unk0;
spD4.unk4C = temp_s0->unkC;
} else if (temp_s0->unk50 == 2) {
uvMat4RotateAxis(&var_s1->unk4, temp_s0->unk24.f[0] * 0.0174533f, 'z'); // almost DEG_TO_RAD(1)
uvMat4RotateAxis(&var_s1->unk4, temp_s0->unk24.f[1] * 0.0174533f, 'x'); // almost DEG_TO_RAD(1)
Expand Down Expand Up @@ -207,27 +179,22 @@ void wind_render(void) {
var_fv1 = temp_s0->unk30.f[1];
}
uvDobjProps(var_s1->unk0, 3, var_fv1, 0);
sp148.unk1C = 0xA;
sp114.f[0] = temp_s0->unk18.f[0];
sp114.f[1] = temp_s0->unk18.f[1];
sp114.f[2] = temp_s0->unk18.f[2];
sp120.f[0] = temp_s0->unk30.f[0];
sp120.f[1] = temp_s0->unk30.f[1];
sp120.f[2] = temp_s0->unk30.f[2];
sp148.unk14 = sp148.unk10 = uvSqrtF(SQ(temp_s0->unk30.x) + SQ(temp_s0->unk30.y) + SQ(temp_s0->unk30.z)) * 0.50;
spD4.unk74 = 0xA;
spD4.unk40.f[0] = temp_s0->unk18.f[0];
spD4.unk40.f[1] = temp_s0->unk18.f[1];
spD4.unk40.f[2] = temp_s0->unk18.f[2];
spD4.unk4C.f[0] = temp_s0->unk30.f[0];
spD4.unk4C.f[1] = temp_s0->unk30.f[1];
spD4.unk4C.f[2] = temp_s0->unk30.f[2];
spD4.unk6C = spD4.unk68 = uvSqrtF(SQ(temp_s0->unk30.x) + SQ(temp_s0->unk30.y) + SQ(temp_s0->unk30.z)) * 0.50;
} else {
_uvDebugPrintf("wind : unknown wind shape [%d]\n", temp_s0->unk50);
return;
}
// @fake to force stuff in this struct to be stored
if (&sp148) { }
func_8034D6D4(temp_s0, var_s1);
func_802E27A8(&spD4);
}
}
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

void func_8034D4AC(void) {
Unk8037F518* var_s0;
Expand Down
34 changes: 14 additions & 20 deletions src/app/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ typedef struct {
s32 unk0;
} Unk8034F410;

typedef struct {
u8 unk0[7];
u8 pad7;
u8 pad8[0x70];
} Unk8030BDC8;

extern s32 D_8034F400;
extern s32 D_8034F404;
extern LevelObjects* D_8034F408;
Expand Down Expand Up @@ -279,8 +273,8 @@ LevelObjects* levelLoadMapObjects(u8 mapIdx) {
u32 size; // spBC
u32 tag;
u8* srcPtr; // spB4
Unk8030BDC8 sp3C;
Unk8030BDC8* ptr;
Unk802E27A8_Arg0 sp3C;
LevelLEVL* ptr;
LevelObjects* temp;
u8 tmp8;

Expand All @@ -297,7 +291,7 @@ LevelObjects* levelLoadMapObjects(u8 mapIdx) {
while ((tag = uvFileReadBlock(idx, &size, (void**)&srcPtr, 1)) != 0) {
switch (tag) {
case 'ESND': // 0x45534E44
for (i = 0; i < temp->unk0; i++) {
for (i = 0; i < temp->countESND; i++) {
_uvMediaCopy(&sp3C, srcPtr, sizeof(sp3C));
srcPtr += sizeof(sp3C);
func_802E27A8(&sp3C);
Expand All @@ -322,46 +316,46 @@ LevelObjects* levelLoadMapObjects(u8 mapIdx) {
_uvMediaCopy(temp->dataBNUS, srcPtr, size);
break;
case 'LEVL': // 0x4C45564C
ptr = (Unk8030BDC8*)srcPtr;
temp->unk0 = ptr->unk0[0];
if (temp->unk0 >= 255) {
_uvAssertMsg("dst_level -> level . nenvsnds < NENV_SNDS", "level.c", 0x27F);
ptr = (LevelLEVL*)srcPtr;
temp->countESND = ptr->countESND;
if (temp->countESND >= 255) {
_uvAssertMsg("dst_level -> level . nenvsnds < NENV_SNDS", "level.c", 639);
}

temp->countWOBJ = ptr->unk0[1];
temp->countWOBJ = ptr->countWOBJ;
if (temp->countWOBJ >= 16) {
_uvAssertMsg("dst_level -> level . nwobjs < LEVEL_NWOBJS", "level.c", 0x282);
_uvAssertMsg("dst_level -> level . nwobjs < LEVEL_NWOBJS", "level.c", 642);
}
if (temp->countWOBJ >= 17) {
_uvDebugPrintf("level : too many wind objects defined in level [%d]\n", temp->countWOBJ);
temp->countWOBJ = 0;
}

temp->countLPAD = ptr->unk0[2];
temp->countLPAD = ptr->countLPAD;
if (temp->countLPAD >= 15) {
_uvDebugPrintf("level : too many potential landing pads defined in level [%d]\n", temp->countLPAD);
temp->countLPAD = 0;
}

temp->countTOYS = ptr->unk0[3];
temp->countTOYS = ptr->countTOYS;
if (temp->countTOYS >= 17) {
_uvDebugPrintf("level : too many toys in level [%d]\n", temp->countTOYS);
temp->countTOYS = 0;
}

temp->countTPTS = ptr->unk0[4];
temp->countTPTS = ptr->countTPTS;
if (temp->countTPTS >= 17) {
_uvDebugPrintf("level : too many terra switch points in level [%d]\n", temp->countTPTS);
temp->countTPTS = 0;
}

temp->countAPTS = ptr->unk0[5];
temp->countAPTS = ptr->countAPTS;
if (temp->countAPTS >= 21) {
_uvDebugPrintf("level : too many audio switch points in level [%d]\n", temp->countAPTS);
temp->countAPTS = 0;
}

temp->countBNUS = ptr->unk0[6];
temp->countBNUS = ptr->countBNUS;
if (temp->countBNUS >= 3) {
_uvDebugPrintf("level : too many bonus objects level [%d]\n", temp->countBNUS);
temp->countBNUS = 0;
Expand Down
Loading