Match Segment 3 -> Matched code_80280650.c (#363)

* Match & doc code_80280650.c

* Update readme
This commit is contained in:
MegaMech
2023-08-10 20:54:11 -06:00
committed by GitHub
parent 04e9e00227
commit baaa2f930d
25 changed files with 656 additions and 1312 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
#include "math_util.h"
#include "ceremony_and_credits.h"
void setup_camera_ending_sequence(void) {
void setup_camera_podium_ceremony(void) {
Camera *camera;
f32 x_dist;
f32 y_dist;
@@ -23,7 +23,7 @@ void setup_camera_ending_sequence(void) {
camera->rot[2] = 0;
}
// GP Ending sequence camera settings?
// GP podium ceremony camera settings?
void func_802816B8(void) {
cameras[0].pos[0] = -3133.0f;
cameras[0].pos[1] = 19.0f;
+1 -1
View File
@@ -3,7 +3,7 @@
/* Function Prototypes */
void setup_camera_ending_sequence();
void setup_camera_podium_ceremony();
void func_802816B8();
// guPerspective params
+1 -1
View File
@@ -17,7 +17,7 @@
#include "camera.h"
#include "audio/external.h"
#include <sounds.h>
#include "code_80280650.h"
#include "podium_ceremony_actors.h"
#include "code_80091750.h"
extern f32 D_80150130[];
-479
View File
@@ -1,479 +0,0 @@
#include <ultra64.h>
#include <macros.h>
#include <types.h>
#include <debug.h>
#include <common_structs.h>
#include "main.h"
#include "memory.h"
#include "variables.h"
#include "common_textures.h"
#include "code_8001F980.h"
#include "hud_renderer.h"
#include "code_80280650.h"
#include "camera_junk.h"
#include "code_80027D00.h"
#include "code_80057C60.h"
#include "code_80005FD0.h"
#include "code_80281C40.h"
void func_80280650(void) {
}
void func_80280658(struct UnkStruct_80280658 *arg0) {
struct UnkStruct_80280658_2 *temp_v0 = arg0->unk28;
arg0->unk10 = temp_v0->unk2;
arg0->unk14 = temp_v0->unk4;
arg0->unk18 = temp_v0->unk6;
arg0->unkA = temp_v0->unk8 << 8;
arg0->unkC = temp_v0->unk9 << 8;
arg0->unkE = temp_v0->unkA << 8;
arg0->unk4 = temp_v0->unk0;
}
struct UnkStruct_80280658 *func_802806C8(void) {
UNUSED s32 pad[2];
struct UnkStruct_80280658 *phi_a0 = D_802874F8;
s32 i;
for (i = 0; i < 0xC8 ; i++) {
if ((phi_a0->unk0 & 1) == 0) {
bzero(phi_a0, 0x4C);
phi_a0->unk0 = 1;
phi_a0->unk24 = 1.0f;
return phi_a0;
}
phi_a0++;
}
return NULL;
}
struct UnkStruct_80280658 *func_80280734(struct UnkStruct_80280658 *arg0) {
struct UnkStruct_80280658 *temp_v0 = func_802806C8();
temp_v0->unk28 = (struct UnkStruct_80280658_2 *) arg0;
func_80280658(temp_v0);
return temp_v0;
}
extern u16 sRandomSeed16; // = 0; todo: import
u16 random_u16_credits(void) {
u16 temp1, temp2;
if (sRandomSeed16 == 22026) {
sRandomSeed16 = 0;
}
temp1 = (sRandomSeed16 & 0x00FF) << 8;
temp1 = temp1 ^ sRandomSeed16;
sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8);
temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16;
temp2 = (temp1 >> 1) ^ 0xFF80;
if ((temp1 & 1) == 0) {
if (temp2 == 43605) {
sRandomSeed16 = 0;
} else {
sRandomSeed16 = temp2 ^ 0x1FF4;
}
} else {
sRandomSeed16 = temp2 ^ 0x8180;
}
return sRandomSeed16;
}
f32 random_float_between_0_and_1(void) {
return random_u16_credits() / 65536.0f;
}
f32 func_80280850(f32 arg0) {
return (random_float_between_0_and_1() * arg0) - (arg0 * 0.5f);
}
void func_80280884(void) {
}
#ifdef NON_MATCHING
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
f32 sins(u16);
extern f32 D_80286B70;
extern s16 D_802874CA;
void func_8028088C(struct UnkStruct_8028088C *arg0) {
f32 temp_f0;
s32 temp_at;
s32 temp_t3;
func_8006BB34(arg0+1, 0x3F800000, arg0->unk2E, arg0->unk2C);
arg0->unk14 += D_80286B70;
temp_f0 = sins(arg0->unk30);
temp_t3 = arg0->unk3C + 1;
temp_at = temp_t3 < 0x321;
arg0->unk30 += arg0->unk32;
arg0->unk3C = temp_t3;
arg0->unk2E = temp_f0 * arg0->unk34;
if (temp_at == 0) {
arg0->unk0 = 0;
}
if (D_802874CA == 1) {
arg0->unk0 = 0;
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_8028088C.s")
#endif
s32 D_80284E40[] = {
0x00FF4080, 0x008040FF, 0x0040FF40, 0x00FFFF40
};
void func_8028093C(struct UnkStruct_80280658 *arg0) {
struct UnkStruct_80280658 *temp_v0;
if (arg0->unk44 < 0x1E) {
arg0->unk14 += 2.5f;
arg0->unk10 += func_80280850(0.2f);
arg0->unk18 += func_80280850(0.2f);
} else if (arg0->unk2C == 4) {
temp_v0 = func_80280734((struct UnkStruct_80280658 *)&D_80284E7C);
temp_v0->unk10 = arg0->unk10;
temp_v0->unk14 = arg0->unk14;
temp_v0->unk18 = arg0->unk18;
temp_v0->unk30 = D_80284E40[arg0->unk48];
temp_v0->unk3C = 0xFF;
temp_v0->unk40 = -0x11;
temp_v0->unk44 = 0x64;
temp_v0->unk34 = 1.8700001f;
temp_v0->unk38 = 1.8700001f;
}
}
void func_80280A28(Vec3f arg0, Vec3s arg1, f32 arg2) {
Mat4 sp20;
func_80021E10(sp20, arg0, arg1);
sp20[0][0] = D_80287500[0][0] * arg2;
sp20[0][1] = D_80287500[1][0] * arg2;
sp20[0][2] = D_80287500[2][0] * arg2;
sp20[1][0] = D_80287500[0][1] * arg2;
sp20[1][1] = D_80287500[1][1] * arg2;
sp20[1][2] = D_80287500[2][1] * arg2;
sp20[2][0] = D_80287500[0][2] * arg2;
sp20[2][1] = D_80287500[1][2] * arg2;
sp20[2][2] = D_80287500[2][2] * arg2;
func_80022180(&gGfxPool->mtxPool[D_80164AF0 + 0x3EB], sp20);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[D_80164AF0 + 0x3EB]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
void func_80280B50(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha) {
Vec3f sp4C;
Vec3s sp44;
s16 red;
s16 green;
s16 blue;
sp4C[0] = arg0[0];
sp4C[1] = arg0[1];
sp4C[2] = arg0[2];
sp44[0] = 0;
sp44[1] = camera1->rot[1];
sp44[2] = 0;
func_80280A28(sp4C, sp44, arg1);
gSPDisplayList(gDisplayListHead++, D_0D008DB8);
gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
// ???????????????????????????????????
red = ((rgb >> 0x10) & 0xFF) & 0xFF;
green = ((rgb >> 0x08) & 0xFF) & 0xFF;
blue = ((rgb >> 0x00) & 0xFF) & 0xFF;
// ???????????????????????????????????
func_8004B35C(red, green, blue, alpha);
gSPDisplayList(gDisplayListHead++, D_0D008E48);
D_80164AF0 += 1;
}
#ifdef MIPS_TO_C
//generated by m2c commit d9d3d6575355663122de59f6b2882d8f174e2355 on Dec-10-2022
static s32 D_80284E50[4] = { 0x007F2040, 0x0040207F, 0x00207F20, 0x007F7F20 };
void func_80280D1C(void *arg0) {
f32 sp60;
f32 sp5C;
f32 sp58;
f32 temp_f0;
s32 temp_v0;
s32 var_s0;
s32 var_s1;
s32 var_v1;
var_s0 = 0;
var_s1 = 0;
if (arg0->unk44 < 0x1E) {
do {
sp58 = arg0->unk10;
sp5C = arg0->unk14 - (f32) var_s1;
sp60 = arg0->unk18;
func_80280B50(&sp58, ((f32) (0xA - var_s0) / 10.0f) * 2.0f, D_80284E50[arg0->unk48], (s16) (s32) ((f32) ((0x1E - arg0->unk44) * 0x64) / 30.0f));
var_s0 += 1;
var_s1 += 2;
} while (var_s0 != 0xA);
} else {
temp_v0 = arg0->unk2C;
if (temp_v0 < 5) {
var_v1 = arg0->unk3C + (arg0->unk40 * 2);
arg0->unk3C = var_v1;
arg0->unk34 = (f32) (arg0->unk34 + (arg0->unk38 * 2.0f));
} else {
temp_f0 = 1.0f + ((f32) ((temp_v0 * 7) - 0x23) / 10.0f);
var_v1 = (s32) ((f32) arg0->unk3C + ((f32) arg0->unk40 / temp_f0));
arg0->unk3C = var_v1;
arg0->unk34 = (f32) (arg0->unk34 + (arg0->unk38 / temp_f0));
if (var_v1 < 0) {
arg0->unk3C = 0;
var_v1 = 0;
}
}
arg0->unk2C = (s32) (arg0->unk2C + 1);
if ((var_v1 <= 0) || !(arg0->unk34 > 0.0f)) {
if (arg0->unk2C < 0x1E) {
goto block_12;
}
arg0->unk0 = 0;
} else {
block_12:
func_80280B50(arg0 + 0x10, arg0->unk34, arg0->unk30, (s16) var_v1);
}
}
arg0->unk44 = (s32) (arg0->unk44 + 1);
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_80280D1C.s")
#endif
void func_80280FA0(UNUSED s32 arg0) {
}
void func_80280FA8(UNUSED s32 arg0) {
}
void func_80280FB0(void) {
D_802874E0 = 0;
D_802874F8 = (struct UnkStruct_80280658 *) get_next_available_memory_addr(0x3B60);
bzero(D_802874F8, 0x3B60);
func_80280734((struct UnkStruct_80280658 *)&D_80284E88);
}
void func_80280FFC(void) {
D_802874F4 = 1;
}
void func_8028100C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) {
}
#ifdef MIPS_TO_C
//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
static struct UnkStruct_80280658 D_80284E64; /* type too large by 0x40; unable to generate initializer */
static f32 D_80286B80 = 3000.0f;
void func_8028101C(s32 arg0, s32 arg1, s32 arg2) {
f32 sp64;
f32 sp60;
f32 sp5C;
s32 var_s1;
struct UnkStruct_80280658 *temp_s0;
var_s1 = 0;
sp5C = (f32) arg2;
sp60 = (f32) arg1;
sp64 = (f32) arg0;
do {
temp_s0 = func_80280734(&D_80284E64);
temp_s0->unk10 = func_80280850(200.0f) + sp64;
temp_s0->unk14 = func_80280850(380.0f) + sp60;
temp_s0->unk18 = func_80280850(600.0f) + sp5C;
temp_s0->unk2C = (s16) (s32) (random_float_between_0_and_1() * 7.0f);
temp_s0->unk30 = random_u16_credits();
temp_s0->unk32 = (s16) (s32) (func_80280850(400.0f) + 900.0f);
var_s1 += 1;
temp_s0->unk34 = (s16) (s32) (func_80280850(2000.0f) + D_80286B80);
} while (var_s1 != 0x64);
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_8028101C.s")
#endif
#ifdef MIPS_TO_C
//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
extern s16 D_802874BE;
extern s16 D_802874C6;
extern s16 D_802874C8;
extern s32 D_80287540;
static s32 D_80284E50[4] = { 0x007F2040, 0x0040207F, 0x00207F20, 0x007F7F20 };
static struct UnkStruct_80280658 D_80284E70; /* type too large by 0x40; unable to generate initializer */
static f32 D_80286B84 = 1.1f;
void func_8028118C(s32 arg0, s32 arg1, s32 arg2) {
f32 temp_f0;
f32 temp_f2;
s32 temp_v0;
s32 temp_v1;
struct UnkStruct_80280658 *temp_s0;
if (((f32) (D_802874BE + 0xD) * random_float_between_0_and_1()) < 1.0f) {
temp_s0 = func_80280734(&D_80284E70);
temp_s0->unk10 = func_80280850(0.0f) + (f32) arg0;
temp_s0->unk14 = func_80280850((f32) (D_802874C6 + 0x64)) + (f32) arg1;
temp_f0 = func_80280850((f32) (D_802874C8 + 0x2BC));
temp_v1 = D_80287540;
temp_f2 = D_80286B84;
temp_v0 = temp_v1 & 3;
temp_s0->unk48 = temp_v0;
temp_s0->unk18 = temp_f0 + (f32) arg2;
temp_s0->unk3C = 0x000000FF;
temp_s0->unk40 = -0x00000011;
temp_s0->unk34 = temp_f2;
temp_s0->unk38 = temp_f2;
temp_s0->unk30 = D_80284E50[temp_v0];
D_80287540 = temp_v1 + 1;
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_8028118C.s")
#endif
#ifdef MIPS_TO_C
//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de
void func_8028101C(?, s32, ?); /* extern */
void func_8028118C(?, s32, ?); /* extern */
void guLookAtF(? *, f32, f32, f32, f32, f32, f32, f32, f32, f32); /* extern */
extern s16 D_802874C4;
extern s32 D_802874E0;
extern Mat4 D_80287500;
void func_802812C8(void) {
f32 temp_f0;
s32 var_v0;
guLookAtF(&D_80287500, cameras->pos[0], cameras->pos[1], cameras->pos[2], cameras->lookAt[0], cameras->lookAt[1], cameras->lookAt[2], cameras->up[0], cameras->up[1], cameras->up[2]);
if (D_802874F5 < 3) {
var_v0 = D_802874E0;
if (var_v0 < 0x12C) {
temp_f0 = cameras->lookAt[1];
func_8028118C(-0xE0E, (s32) (((temp_f0 - cameras->pos[1]) * 1.5f) + temp_f0), -0x258);
var_v0 = D_802874E0;
}
if (var_v0 == 0x00000078) {
func_8028101C(-0xC6C, (s32) ((f32) D_802874C4 + 210.0f), -0x1EF);
goto block_7;
}
} else {
var_v0 = D_802874E0;
if (var_v0 == 2) {
func_8028101C(-0xC6C, (s32) ((f32) D_802874C4 + 210.0f), -0x1EF);
block_7:
var_v0 = D_802874E0;
}
}
D_802874E0 = var_v0 + 1;
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_802812C8.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
void func_802812C8(); // extern
extern ? D_80284E94;
extern s16 D_802874D0;
extern void *D_802874F8;
void func_80281438(void) {
? (*temp_v0)(void *);
s32 temp_s1;
s32 temp_s2;
void *phi_s0;
s32 phi_s2;
s32 phi_s1;
func_802812C8();
D_802874D0 = 0;
phi_s2 = 0;
do {
phi_s0 = D_802874F8;
phi_s1 = 0;
loop_2:
if ((phi_s0->unk0 & 1) != 0) {
temp_v0 = *(&D_80284E94 + (phi_s0->unk4 * 0xC) + (phi_s2 * 4));
if (temp_v0 != 0) {
temp_v0(phi_s0);
}
}
temp_s1 = phi_s1 + 1;
phi_s0 += 0x4C;
phi_s1 = temp_s1;
if (temp_s1 != 0xC8) {
goto loop_2;
}
temp_s2 = phi_s2 + 1;
phi_s2 = temp_s2;
} while (temp_s2 != 3);
}
#else
GLOBAL_ASM("asm/non_matchings/code_80280650/func_80281438.s")
#endif
void func_8028150C(void) {
D_802874D4 = gDisplayListHead;
}
void func_80281520(void) {
}
void func_80281528(void) {
}
void func_80281530(void) {
}
void func_80281538(void) {
}
void func_80281540(void) {
}
void ending_sequence_loop(void) {
D_80150112 = 0;
D_802874FC = 0;
setup_camera_ending_sequence();
func_80028F70();
func_80022744();
func_80059AC8();
func_80059AC8();
func_8005A070();
if (D_802874F4 != 0) {
func_8001C14C();
func_800097E0();
}
func_80281D00();
func_80281540();
#if VARIABLE_WATCH_DEBUG_LIST
display_dvdl();
#endif
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
}
-105
View File
@@ -1,105 +0,0 @@
#ifndef CODE_80280650_H
#define CODE_80280650_H
#include "common_structs.h"
struct UnkStruct_80280658 {
s32 unk0;
s16 unk4;
s16 unk6;
s8 unk8;
s8 unk9;
s16 unkA;
s16 unkC;
s16 unkE;
f32 unk10;
f32 unk14;
f32 unk18;
f32 unk1C;
f32 unk20;
f32 unk24;
struct UnkStruct_80280658_2 *unk28;
s32 unk2C;
s32 unk30;
f32 unk34;
f32 unk38;
s32 unk3C;
s32 unk40;
s32 unk44;
s32 unk48;
};
struct UnkStruct_80280658_2 {
s16 unk0;
s16 unk2;
s16 unk4;
s16 unk6;
s8 unk8;
s8 unk9;
s8 unkA;
f32 unkC;
};
struct UnkStruct_8028088C {
s32 unk0;
s16 unk4;
s16 unk6;
s8 unk8;
s8 unk9;
s16 unkA;
s16 unkC;
s16 unkE;
f32 unk10;
f32 unk14;
f32 unk18;
f32 unk1C;
f32 unk20;
f32 unk24;
struct UnkStruct_80280658_2 *unk28;
s16 unk2C;
s16 unk2E;
s16 unk30;
s16 unk32;
s16 unk34;
s16 unk36;
s32 unk38;
s32 unk3C;
};
void func_80281438(void);
void func_80280650();
void func_80280658(struct UnkStruct_80280658*);
struct UnkStruct_80280658 *func_802806C8();
struct UnkStruct_80280658 *func_80280734(struct UnkStruct_80280658*);
u16 random_u16_credits();
f32 random_float_between_0_and_1();
f32 func_80280850(f32);
void func_80280884();
void func_8028093C(struct UnkStruct_80280658*);
void func_80280A28(Vec3f, Vec3s, f32 );
void func_80280B50(Vec3f, f32, s32, s16);
void func_80280FA0(s32);
void func_80280FA8(s32);
void func_80280FB0();
void func_80280FFC();
void func_8028100C(s32, s32, s32);
void func_8028150C();
void func_80281520();
void func_80281528();
void func_80281530();
void func_80281538();
void func_80281540();
void ending_sequence_loop();
extern struct UnkStruct_80280658 *D_802874F8;
extern struct UnkStruct_80280658 *D_80284E7C;
extern struct UnkStruct_80280658 *D_80284E88;
extern s32 D_802874E0;
extern s8 D_802874F4;
extern Gfx *D_802874D4;
extern s32 D_802874FC;
extern Mat4 D_80287500;
extern s16 D_80164AF0;
#endif
+10 -4
View File
@@ -9,10 +9,15 @@
#include "spawn_players.h"
#include "skybox_and_splitscreen.h"
#include "code_8006E9C0.h"
#include "code_80280650.h"
#include "podium_ceremony_actors.h"
#include "code_80281780.h"
#include "code_80005FD0.h"
#include "code_802AAA70.h"
#include "code_80281C40.h"
u8 defaultCharacterIds[] = {
1, 2, 3, 4, 5, 6, 7, 0
};
void debug_switch_character_ceremony_cutscene(void) {
if (gEnableDebugMode) {
@@ -41,8 +46,9 @@ void debug_switch_character_ceremony_cutscene(void) {
} else {
gCharacterSelections[0] = MARIO;
}
// D_80284ED0 appears to be unused.
bcopy(&D_80284ED0, &gCharacterIdByGPOverallRank, 8);
// todo: confirm this.
// Resets gCharacterIdByGPOverallRank to default?
bcopy(&defaultCharacterIds, &gCharacterIdByGPOverallRank, 8);
}
}
}
@@ -137,7 +143,7 @@ void load_ceremony_cutscene(void) {
func_8003D080();
func_8006E9C0();
func_8001C05C();
func_80280FB0();
balloons_and_fireworks_init();
func_802816B8();
func_80093E60();
D_801625F8 = (s32) gHeapEndPtr - gNextFreeMemoryAddress;
+1 -2
View File
@@ -29,7 +29,6 @@ extern u16 D_800DC5BC;
extern u16 D_800DC5C8;
extern struct UnkStruct_800DC5EC *D_800DC5EC;
extern u32 gMenuSelectionFromEndingSequence; //D_80287550;
extern s32 D_80287554;
extern f32 D_801647A4;
extern f32 D_80150130[];
@@ -61,7 +60,7 @@ extern struct Controller *gControllerOne;
extern s8 gCharacterSelections[];
extern u16 gEnableDebugMode;
extern void *D_80284ED0;
extern u8 defaultCharacterIds[];
extern s8 gGPOverallRanks[8];
extern s8 D_8018EDF3;
+14 -1
View File
@@ -7,11 +7,24 @@
#include "hud_renderer.h"
#include "code_80057C60.h"
#include "code_80091750.h"
#include "code_80280650.h"
#include "podium_ceremony_actors.h"
#include "code_80281C40.h"
#include "ceremony_and_credits.h"
#include "code_8001F980.h"
struct UnkStruct80287560 {
s16 unk0;
s16 unk2;
s32 unk4;
s32 unk8;
}; // 0xC
/** bss **/
u32 gMenuSelectionFromEndingSequence;
s32 D_80287554;
s32 D_80281C40_pad[2];
struct UnkStruct80287560 D_80287560[30];
void func_80281C40(void) {
s32 i;
-9
View File
@@ -1,24 +1,15 @@
#ifndef CODE_80281C40_H
#define CODE_80281C40_h
struct UnkStruct80287560 {
s16 unk0;
s16 unk2;
s32 unk4;
s32 unk8;
}; // 0xC
/* Function Prototypes */
void func_80281C40();
void func_80281CB4(s32, s32, s32, s32);
void func_80281D00();
extern struct UnkStruct80287560 D_80287560[];
extern s32 D_802874FC;
extern u32 gMenuSelectionFromEndingSequence;
extern s32 D_80287554;
extern u16 gIsInQuitToMenuTransition;
extern Gfx D_00284F70[];
extern Gfx D_00284EE0[];
+1 -1
View File
@@ -26,7 +26,7 @@
#include <code_800AF9B0.h>
#include <code_800B45E0.h>
#include <code_80280000.h>
#include <code_80280650.h>
#include <podium_ceremony_actors.h>
#include <code_80281780.h>
#include <code_80281C40.h>
#include <code_802AAA70.h>
+2 -2
View File
@@ -23,7 +23,7 @@
#include "audio/external.h"
#include "code_800029B0.h"
#include "code_80280000.h"
#include "code_80280650.h"
#include "podium_ceremony_actors.h"
#include "code_80091750.h"
#include "code_80057C60.h"
#include "profiler.h"
@@ -872,7 +872,7 @@ void game_state_handler(void) {
race_logic_loop();
break;
case ENDING_SEQUENCE:
ending_sequence_loop();
podium_ceremony_loop();
break;
case CREDITS_SEQUENCE:
credits_loop();
+484
View File
@@ -0,0 +1,484 @@
#include <ultra64.h>
#include <macros.h>
#include <PR/gu.h>
#include <mk64.h>
#include <types.h>
#include <debug.h>
#include <common_structs.h>
#include "main.h"
#include "memory.h"
#include "variables.h"
#include "common_textures.h"
#include "code_8001F980.h"
#include "hud_renderer.h"
#include "podium_ceremony_actors.h"
#include "camera_junk.h"
#include "code_80027D00.h"
#include "code_80057C60.h"
#include "code_80005FD0.h"
#include "code_80281C40.h"
#include "math_util.h"
s32 fireworkConeColour[] = {
0x00FF4080, // pink
0x008040FF, // purple
0x0040FF40, // green
0x00FFFF40 // yellow
};
/**
* Mainly colours the explosion effect.
* Appears to colour the cones as well.
*/
s32 fireworkColour[] = {
0x007F2040, // red
0x0040207F, // purple
0x00207F20, // green
0x007F7F20 // gold/yellow
};
u16 sRandomSeed16 = 0;
UnkStruct_80284E64 D_80284E64 = {
1,
0xF3AF,
34,
0xFE2D,
0,
0,
0,
0,
};
UnkStruct_80284E64 D_80284E70 = {
3,
0xF3AF,
34,
0xFE2D,
0,
0,
0,
0,
};
UnkStruct_80284E64 D_80284E7C = {
2,
0xF3AF,
34,
0xFE2D,
0,
0,
0,
0,
};
UnkStruct_80284E64 D_80284E88 = {
0,
0xF2CC,
250,
0xFE11,
0,
0,
0,
0,
};
void func_80280650(void) {
}
void set_actor_with_next(struct UnkStruct_80280658 *arg0) {
UnkStruct_80284E64 *temp_v0 = arg0->unk28;
arg0->unk10[0] = temp_v0->unk2;
arg0->unk10[1] = temp_v0->unk4;
arg0->unk10[2] = temp_v0->unk6;
// Place value in the high bits of s16.
// Example: 85, 0b01010101 -> 0b0101010100000000
arg0->unkA = temp_v0->unk8 << 8;
arg0->unkC = temp_v0->unk9 << 8;
arg0->unkE = temp_v0->unkA << 8;
arg0->unk4 = temp_v0->unk0;
}
struct UnkStruct_80280658 *find_available_entry(void) {
UNUSED s32 pad[2];
struct UnkStruct_80280658 *phi_a0 = D_802874F8;
s32 i;
for (i = 0; i < 200 ; i++) {
// Find an unused actor, initialize and return it.
if ((phi_a0->unk0 & 1) == 0) {
bzero(phi_a0, 0x4C);
phi_a0->unk0 = 1;
phi_a0->unk24 = 1.0f;
return phi_a0;
}
phi_a0++;
}
return NULL;
}
struct UnkStruct_80280658 *new_actor(UnkStruct_80284E64 *arg0) {
struct UnkStruct_80280658 *actor = find_available_entry();
// @bug No null check.
// todo: What am I even supposed to return here?
// I guess the other funcs need checks too
#ifdef AVOID_UB
if (actor == NULL) {
// Something has gone terribly wrongg
while(1);
return NULL; // prevent warnings
}
#endif
// Linked list?
actor->unk28 = arg0;
set_actor_with_next(actor);
return actor;
}
u16 random_u16_credits(void) {
u16 temp1, temp2;
if (sRandomSeed16 == 22026) {
sRandomSeed16 = 0;
}
temp1 = (sRandomSeed16 & 0x00FF) << 8;
temp1 = temp1 ^ sRandomSeed16;
sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8);
temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16;
temp2 = (temp1 >> 1) ^ 0xFF80;
if ((temp1 & 1) == 0) {
if (temp2 == 43605) {
sRandomSeed16 = 0;
} else {
sRandomSeed16 = temp2 ^ 0x1FF4;
}
} else {
sRandomSeed16 = temp2 ^ 0x8180;
}
return sRandomSeed16;
}
f32 random_float_between_0_and_1(void) {
return random_u16_credits() / 65536.0f;
}
f32 random_who_knows(f32 arg0) {
return (random_float_between_0_and_1() * arg0) - (arg0 * 0.5f);
}
void func_80280884(void) {
}
extern s16 D_802874CA;
void func_8028088C(struct UnkStruct_80280658 *arg0) {
func_8006BB34(arg0->unk10, 1.0f, arg0->unk2E, arg0->unk2C);
arg0->unk10[1] += 0.8f;
arg0->unk2E = sins(arg0->unk30) * arg0->unk34;
arg0->unk30 += arg0->unk32;
arg0->unk3C++;
if (arg0->unk3C >= 0x321) {
arg0->unk0 = 0;
}
if (D_802874CA == 1) {
arg0->unk0 = 0;
}
}
/**
* Spawns an aerial shell that ascends into the sky.
* (note that the explode effect is a different actor)
*/
void spawn_firework_cone(Firework *cone) {
Firework *actor;
if (cone->unk44 < 0x1E) {
cone->unk10[1] += 2.5f;
cone->unk10[0] += random_who_knows(0.2f);
cone->unk10[2] += random_who_knows(0.2f);
} else if (cone->unk2C == 4) {
actor = (Firework *) new_actor(&D_80284E7C);
actor->unk10[0] = cone->unk10[0];
actor->unk10[1] = cone->unk10[1];
actor->unk10[2] = cone->unk10[2];
actor->unk30 = fireworkConeColour[cone->unk48];
actor->unk3C = 0xFF;
actor->unk40 = -0x11;
actor->unk44 = 0x64;
actor->unk34 = 1.8700001f;
actor->unk38 = 1.8700001f;
}
}
Mat4 D_80287500;
void func_80280A28(Vec3f arg0, Vec3s arg1, f32 arg2) {
Mat4 sp20;
func_80021E10(sp20, arg0, arg1);
sp20[0][0] = D_80287500[0][0] * arg2;
sp20[0][1] = D_80287500[1][0] * arg2;
sp20[0][2] = D_80287500[2][0] * arg2;
sp20[1][0] = D_80287500[0][1] * arg2;
sp20[1][1] = D_80287500[1][1] * arg2;
sp20[1][2] = D_80287500[2][1] * arg2;
sp20[2][0] = D_80287500[0][2] * arg2;
sp20[2][1] = D_80287500[1][2] * arg2;
sp20[2][2] = D_80287500[2][2] * arg2;
func_80022180(&gGfxPool->mtxPool[D_80164AF0 + 0x3EB], sp20);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[D_80164AF0 + 0x3EB]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
void render_fireworks(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha) {
Vec3f sp4C;
Vec3s sp44;
s16 red;
s16 green;
s16 blue;
sp4C[0] = arg0[0];
sp4C[1] = arg0[1];
sp4C[2] = arg0[2];
sp44[0] = 0;
sp44[1] = camera1->rot[1];
sp44[2] = 0;
func_80280A28(sp4C, sp44, arg1);
gSPDisplayList(gDisplayListHead++, D_0D008DB8);
gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
// ???????????????????????????????????
red = ((rgb >> 0x10) & 0xFF) & 0xFF;
green = ((rgb >> 0x08) & 0xFF) & 0xFF;
blue = ((rgb >> 0x00) & 0xFF) & 0xFF;
// ???????????????????????????????????
func_8004B35C(red, green, blue, alpha);
gSPDisplayList(gDisplayListHead++, D_0D008E48);
D_80164AF0 += 1;
}
void func_80280D1C(Firework *actor) {
s32 i;
Vec3f sp58;
if (actor->unk44 < 30) {
for (i = 0; i < 10; i++) {
sp58[0] = actor->unk10[0];
sp58[1] = actor->unk10[1] - i * 2;
sp58[2] = actor->unk10[2];
render_fireworks(sp58, ((10 - i) / 10.0f) * 2, fireworkColour[actor->unk48], ( ((((30 - actor->unk44) * 100)) / 30.0f)));
}
} else {
if (actor->unk2C < 5) {
actor->unk3C += actor->unk40 * 2;
actor->unk34 += actor->unk38 * 2;
} else {
actor->unk3C += actor->unk40 / ( 1.0f + ( ( (actor->unk2C * 7) - 0x23 ) / 10.0f ) );
actor->unk34 += actor->unk38 / ( 1.0f + ( ( (actor->unk2C * 7) - 0x23 ) / 10.0f ) );
if (actor->unk3C < 0) {
actor->unk3C = 0;
}
}
actor->unk2C += 1;
if (((actor->unk3C > 0) && ((actor->unk34 > 0.0f))) || (actor->unk2C < 30)) {
render_fireworks(actor->unk10, actor->unk34, actor->unk30, (s16) actor->unk3C);
} else {
actor->unk0 = 0;
}
}
actor->unk44 += 1;
}
void func_80280FA0(UNUSED s32 arg0) {
}
void func_80280FA8(UNUSED s32 arg0) {
}
void balloons_and_fireworks_init(void) {
D_802874E0 = 0;
D_802874F8 = (struct UnkStruct_80280658 *) get_next_available_memory_addr(0x3B60);
bzero(D_802874F8, 0x3B60);
new_actor(&D_80284E88);
}
void func_80280FFC(void) {
D_802874F4 = 1;
}
void func_8028100C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) {
}
/**
* Spawn balloons!
* The floats passed to random_who_knows appears to effect the spread of the balloons
*/
void spawn_balloons(s32 arg0, s32 arg1, s32 arg2) {
s32 i;
for (i = 0; i < 100; i++) {
struct UnkStruct_80280658 *balloon;
balloon = new_actor(&D_80284E64);
balloon->unk10[0] = random_who_knows(200.0f) + arg0;
balloon->unk10[1] = random_who_knows(380.0f) + arg1;
balloon->unk10[2] = random_who_knows(600.0f) + arg2;
balloon->unk2C = (s16) (s32) (random_float_between_0_and_1() * 7.0f);
balloon->unk30 = random_u16_credits();
balloon->unk32 = (s16) (s32) (random_who_knows(400.0f) + 900.0f);
balloon->unk34 = (s16) (s32) (random_who_knows(2000.0f) + 3000.0f);
}
}
extern s16 D_802874BE[];
extern s16 D_802874C6;
extern s16 D_802874C8;
extern s32 fireworkColour[];
/**
* The explosive effect when the firework's charge detonates
* resulting in a small variety of amusing colours.
*/
void spawn_firework_burst(s32 arg0, s32 arg1, s32 arg2) {
f32 num;
static u32 D_80287540;
if (((f32) random_float_between_0_and_1() * (D_802874BE[0] + 0xD)) < 1.0f) {
Firework *burst;
burst = (Firework *) new_actor(&D_80284E70);
burst->unk10[0] = random_who_knows(0.0f) + arg0;
burst->unk10[1] = random_who_knows((f32) (D_802874C6 + 100)) + (f32) arg1;
burst->unk10[2] = random_who_knows((f32) (D_802874C8 + 700)) + (f32) arg2;
num = 1.1f;
// Wrap the counter from zero to three
burst->unk48 = D_80287540 % 4U;
burst->unk30 = fireworkColour[D_80287540 % 4U];
burst->unk34 = num;
burst->unk38 = num;
D_80287540 += 1;
burst->unk3C = 0xFF;
burst->unk40 = -0x11;
}
}
extern s16 D_802874C4;
extern s32 D_802874E0;
extern Mat4 D_80287500;
extern s8 D_802874F5;
/**
* Allegedly controls fireworks movement.
*/
void fireworks_update(void) {
Camera *camera = &cameras[0];
f32 temp_f0;
guLookAtF(D_80287500, camera->pos[0], camera->pos[1], camera->pos[2], camera->lookAt[0], camera->lookAt[1], camera->lookAt[2], camera->up[0], camera->up[1], camera->up[2]);
if (D_802874F5 < 3) {
if (D_802874E0 < 300) {
temp_f0 = camera->lookAt[1];
spawn_firework_burst(-0xE0E, (s32) (((temp_f0 - camera->pos[1]) * 1.5f) + temp_f0), -0x258);
}
if (D_802874E0 == 120) {
spawn_balloons(-0xC6C, (s32) ((f32) D_802874C4 + 210.0f), -0x1EF);
}
} else if (D_802874E0 == 2) {
spawn_balloons(-0xC6C, (s32) ((f32) D_802874C4 + 210.0f), -0x1EF);
}
D_802874E0 += 1;
}
void *D_80284E94[][3] = {
{func_80280FA8, func_80280FA0, 0},
{func_80280FA8, func_8028088C, 0},
{func_80280FA8, func_80280D1C, 0},
{spawn_firework_cone, 0, func_80280D1C},
};
extern s16 D_802874D0;
void func_80281438(void) {
void (*func)(void *);
struct UnkStruct_80280658 *phi_s0;
s32 i;
s32 j;
fireworks_update();
D_802874D0 = 0;
for (i = 0; i < 3; i++) {
phi_s0 = D_802874F8;
for (j = 0; j < 200; j++) {
if ((phi_s0->unk0 & 1) != 0) {
func = D_80284E94[phi_s0->unk4][i];
if (func != 0) {
func(phi_s0);
}
}
phi_s0++;
}
}
}
void func_8028150C(void) {
D_802874D4 = gDisplayListHead;
}
void func_80281520(void) {
}
void func_80281528(void) {
}
void func_80281530(void) {
}
void func_80281538(void) {
}
void func_80281540(void) {
}
void podium_ceremony_loop(void) {
D_80150112 = 0;
D_802874FC = 0;
setup_camera_podium_ceremony();
func_80028F70();
func_80022744();
func_80059AC8();
func_80059AC8();
func_8005A070();
if (D_802874F4 != 0) {
func_8001C14C();
func_800097E0();
}
func_80281D00();
func_80281540();
#if VARIABLE_WATCH_DEBUG_LIST
display_dvdl();
#endif
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
}
+108
View File
@@ -0,0 +1,108 @@
#ifndef podium_ceremony_actors_H
#define podium_ceremony_actors_H
#include "common_structs.h"
typedef struct {
s16 unk0;
s16 unk2;
s16 unk4;
s16 unk6;
s8 unk8;
s8 unk9;
s8 unkA;
s8 unkB;
} UnkStruct_80284E64;
struct UnkStruct_80280658 {
/* 0x00 */ s32 unk0;
/* 0x04 */ s16 unk4;
/* 0x06 */ s16 unk6;
/* 0x08 */ s8 unk8;
/* 0x09 */ s8 unk9;
/* 0x0A */ s16 unkA;
/* 0x0C */ s16 unkC;
/* 0x0E */ s16 unkE;
/* 0x10 */ Vec3f unk10;
/* 0x1C */ f32 unk1C;
/* 0x20 */ f32 unk20;
/* 0x24 */ f32 unk24;
/* 0x28 */ UnkStruct_80284E64 *unk28;
/* 0x2C */ s16 unk2C;
/* 0x2E */ s16 unk2E;
/* 0x30 */ s16 unk30;
/* 0x32 */ s16 unk32;
/* 0x34 */ s16 unk34;
/* 0x36 */ s16 unk36;
/* 0x38 */ f32 unk38;
/* 0x3C */ s32 unk3C;
/* 0x40 */ s32 unk40;
/* 0x44 */ s32 unk44;
/* 0x48 */ s32 unk48;
};
typedef struct {
/* 0x00 */ s32 unk0;
/* 0x04 */ s16 unk4;
/* 0x06 */ s16 unk6;
/* 0x08 */ s8 unk8;
/* 0x09 */ s8 unk9;
/* 0x0A */ s16 unkA;
/* 0x0C */ s16 unkC;
/* 0x0E */ s16 unkE;
/* 0x10 */ Vec3f unk10;
/* 0x1C */ f32 unk1C;
/* 0x20 */ f32 unk20;
/* 0x24 */ f32 unk24;
/* 0x28 */ UnkStruct_80284E64 *unk28;
/* 0x2C */ s32 unk2C;
/* 0x30 */ s32 unk30; // s32 instead of s16
/* 0x34 */ f32 unk34; // f32 instead of s16
/* 0x38 */ f32 unk38;
/* 0x3C */ s32 unk3C;
/* 0x40 */ s32 unk40;
/* 0x44 */ s32 unk44;
/* 0x48 */ s32 unk48;
} Firework;
void func_80281438(void);
void func_80280650();
void set_actor_with_next(struct UnkStruct_80280658*);
struct UnkStruct_80280658 *find_available_entry();
struct UnkStruct_80280658 *new_actor(UnkStruct_80284E64*);
u16 random_u16_credits();
f32 random_float_between_0_and_1();
f32 random_who_knows(f32);
void func_80280884();
void spawn_firework_cone(Firework *);
void func_80280A28(Vec3f, Vec3s, f32 );
void render_fireworks(Vec3f, f32, s32, s16);
void func_80280FA0(s32);
void func_80280FA8(s32);
void balloons_and_fireworks_init();
void func_80280FFC();
void func_8028100C(s32, s32, s32);
void func_8028150C();
void func_80281520();
void func_80281528();
void func_80281530();
void func_80281538();
void func_80281540();
void podium_ceremony_loop();
extern struct UnkStruct_80280658 *D_802874F8;
extern UnkStruct_80284E64 D_80284E64;
extern UnkStruct_80284E64 D_80284E7C;
extern UnkStruct_80284E64 D_80284E88;
extern UnkStruct_80284E64 D_80284E70;
extern s32 D_802874E0;
extern s8 D_802874F4;
extern Gfx *D_802874D4;
extern s32 D_802874FC;
extern Mat4 D_80287500;
extern s16 D_80164AF0;
#endif