Decompiled staff_ghosts.c (Plus lots more) (#39)

* Decompiled staff_ghosts.c

* started on 80296A50.c

* Matched some of main.c

* Added framebuffers.c

* Added structs such as Camera
This commit is contained in:
CoderStig
2021-10-26 11:55:42 -06:00
committed by GitHub
parent caaea76c42
commit f3788f7ac4
40 changed files with 6358 additions and 2665 deletions
+40 -40
View File
@@ -47,18 +47,18 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg
break;
}
player->unk_014 = arg2;
player->posX = arg2;
ret = func_802AE1C0(arg2, arg4 + 50.0f, arg3) + player->unk_070;
player->unk_01C = arg3;
player->unk_018 = ret;
player->unk_020 = arg2;
player->unk_024 = ret;
player->posZ = arg3;
player->posY = ret;
player->rotX = arg2;
player->rotY = ret;
D_80164510[arg1] = ret;
player->unk_02C = 0;
player->unk_028 = arg3;
player->rotZ = arg3;
player->unk_05C = 1.0f;
player->unk_058 = 0.0f;
player->unk_060 = 0.0f;
@@ -114,9 +114,9 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg
player->unk_042 = 0;
player->unk_078 = 0;
player->posY = 0;
player->unk_0A8 = 0;
player->unk_0AA = 0;
player->posZ = 0;
player->unk_0AC = 0;
player->unk_0AE = 0;
player->unk_0B0 = 0;
player->unk_0B2 = 0;
@@ -166,7 +166,7 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg
player->unk_098 = 0.0f;
player->unk_09C = 0.0f;
player->unk_0A0 = 0.0f;
player->posX = 0.0f;
player->unk_0A4 = 0.0f;
player->unk_0B8 = 0.0f;
player->unk_0E4 = 0.0f;
player->unk_0E8 = 0.0f;
@@ -473,12 +473,12 @@ void func_8003A59C(f32 *arg0, f32 *arg1, f32 arg2) {
spawn_player(D_800DC4E4, 2, arg0[1], arg1[1], arg2, 32768.0f, D_800E86A8[0], 0x3000);
} else if (D_8015F890 != 1) {
spawn_player(D_800DC4FC, 0, arg0[0], arg1[0], arg2, 32768.0f, D_800E86A8[0], -0x2000);
if (D_80162DD4 == 0) {
if (D_80162DD4[0] == 0) {
spawn_player(D_800DC4E0, 1, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE0, -0x1F00);
} else {
spawn_player(D_800DC4E0, 1, arg0[0], arg1[0], arg2, 32768.0f, D_800E86A8[0], 0x3000);
}
if (D_80162DD6 == 0) {
if (D_80162DD4[1] == 0) {
spawn_player(D_800DC4E4, 2, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE4, -0x1F00);
} else {
spawn_player(D_800DC4E4, 2, arg0[1], arg1[1], arg2, 32768.0f, D_800E86A8[0], 0x3000);
@@ -490,7 +490,7 @@ void func_8003A59C(f32 *arg0, f32 *arg1, f32 arg2) {
} else {
spawn_player(D_800DC4E0, 1, arg0[0], arg1[0], arg2, 32768.0f, D_800E86A8[0], 0x3000);
}
if (D_80162DD6 == 0) {
if (D_80162DD4[1] == 0) {
spawn_player(D_800DC4E4, 2, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE4, -0x1F00);
} else {
spawn_player(D_800DC4E4, 2, arg0[1], arg1[1], arg2, 32768.0f, D_800E86A8[0], 0x3000);
@@ -1057,7 +1057,7 @@ void func_8003CD98(Player *player, s32 arg1, s8 arg2, s8 arg3) {
D_801650D0[arg3][arg2] = player->unk_244[arg3];
D_80165110[arg3][arg2] = player->unk_24C[arg3];
D_80165150[arg3][arg2] = player->posY;
D_80165150[arg3][arg2] = player->unk_0A8;
D_801651D0[arg3][arg2] = 0;
func_800267AC(player, arg2, arg3);
}
@@ -1082,18 +1082,18 @@ void func_8003D080(void) {
switch (gModeSelection) {
case 0:
if (gCurrentCourseId == COURSE_TOADS_TURNPIKE) {
func_8001C4D0(0.0f, D_800DC4DC->posY, D_8016524C, D_800DC4DC->unk_0BC, 8, 0);
func_8001C4D0(0.0f, D_800DC4DC->unk_0A8, D_8016524C, D_800DC4DC->unk_0BC, 8, 0);
} else {
func_8001C4D0((D_80165210[6] + D_80165210[7]) / 2, D_800DC4DC->posY, D_8016524C, D_800DC4DC->unk_0BC, 8, 0);
func_8001C4D0((D_80165210[6] + D_80165210[7]) / 2, D_800DC4DC->unk_0A8, D_8016524C, D_800DC4DC->unk_0BC, 8, 0);
}
break;
case 1:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_8016524C, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_8016524C, D_800DC4DC->unk_0BC, 1, 0);
break;
default:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 10, 0);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 10, 0);
break;
}
break;
@@ -1102,18 +1102,18 @@ void func_8003D080(void) {
case 2:
switch (gModeSelection) {
case 0:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 1, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 1, 1);
break;
case 3:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 9, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 9, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 9, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 9, 1);
break;
default:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 1, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 1, 1);
break;
}
break;
@@ -1121,23 +1121,23 @@ void func_8003D080(void) {
case 3:
if (gModeSelection == 3) {
ptr = &D_800DC4E4;
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 9, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 9, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 9, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 9, 1);
ptr++;
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 9, 2);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 9, 2);
ptr++;
if (gPlayerCountSelection1 == 4) {
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 9, 3);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 9, 3);
}
} else {
ptr = &D_800DC4E4;
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 1, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 1, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 1, 1);
ptr++;
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 1, 2);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 1, 2);
ptr++;
if (gPlayerCountSelection1 == 4) {
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 1, 3);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 1, 3);
}
}
break;
@@ -1145,23 +1145,23 @@ void func_8003D080(void) {
} else {
switch (D_800DC52C) {
case 0:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 3, 0);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 3, 0);
break;
case 1:
case 2:
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 3, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 3, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 3, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 3, 1);
break;
case 3:
ptr = &D_800DC4E4;
func_8001C4D0(D_800DC4DC->posX, D_800DC4DC->posY, D_800DC4DC->posZ, D_800DC4DC->unk_0BC, 3, 0);
func_8001C4D0(D_800DC4E0->unk_014, D_800DC4E0->unk_018, D_800DC4E0->unk_01C, D_800DC4E0->unk_02E, 3, 1);
func_8001C4D0(D_800DC4DC->unk_0A4, D_800DC4DC->unk_0A8, D_800DC4DC->unk_0AC, D_800DC4DC->unk_0BC, 3, 0);
func_8001C4D0(D_800DC4E0->posX, D_800DC4E0->posY, D_800DC4E0->posZ, D_800DC4E0->unk_02E, 3, 1);
ptr++;
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 3, 2);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 3, 2);
ptr++;
func_8001C4D0(ptr->unk_014, ptr->unk_018, ptr->unk_01C, ptr->unk_02E, 3, 3);
func_8001C4D0(ptr->posX, ptr->posY, ptr->posZ, ptr->unk_02E, 3, 3);
break;
}
}
@@ -1230,8 +1230,8 @@ void func_8003DB5C(void) {
Player *player = D_800DC4DC;
s32 i;
func_8001C4D0(player->unk_014, player->unk_018, player->unk_01C, player->unk_02E, 3, 0);
func_8001C4D0(player->unk_014, player->unk_018, player->unk_01C, player->unk_02E, 3, 1);
func_8001C4D0(player->posX, player->posY, player->posZ, player->unk_02E, 3, 0);
func_8001C4D0(player->posX, player->posY, player->posZ, player->unk_02E, 3, 1);
for (i = 0; i < 8; i++, player++) {
func_80027A20(player, i, 1, 0);
+7 -7
View File
@@ -263,7 +263,7 @@ void func_8008C528(Player *player, s8 arg1) {
player->unk_0F4 = 0.0f;
player->unk_0EC = D_800E3790[temp_v1];
player->posY = 0;
player->unk_0A8 = 0;
player->unk_0BC = player->unk_0BC | 0x400;
player->unk_0BC = player->unk_0BC & ~0x10;
player->unk_0C0 = 0;
@@ -281,13 +281,13 @@ void func_8008C528(Player *player, s8 arg1) {
void func_8008C62C(Player *player, s8 arg1) {
func_80031F48(player, 5.0f);
player->posY += (s16)0xA0;
player->unk_0A8 += (s16)0xA0;
player->unk_042 += (s16)0x71C;
if (player->posY >= 0x2000) {
player->posY = 0;
if (player->unk_0A8 >= 0x2000) {
player->unk_0A8 = 0;
player->unk_236 = (s16) (player->unk_236 - 1);
if (player->unk_236 == 0) {
player->posY = 0x2000;
player->unk_0A8 = 0x2000;
func_8008C6D0(player, arg1);
if (gModeSelection == 3) {
func_8006B8B4(player, arg1);
@@ -301,7 +301,7 @@ void func_8008C6D0(Player *player, s8 arg1) {
player->unk_206 = 0;
player->unk_0C4 = 0;
player->unk_0BC = (s32) (player->unk_0BC & ~0x400);
player->posY = 0;
player->unk_0A8 = 0;
player->unk_0C0 = 0;
player->unk_07C = 0;
player->unk_236 = 0;
@@ -364,7 +364,7 @@ void func_8008C8C4(Player *player, s8 arg1) {
player->unk_02E = player->unk_0AE;
player->posY = 0;
player->unk_0A8 = 0;
player->unk_07C = 0;
player->unk_0C0 = 0;
player->unk_0BC &= ~0x800;
+2 -6
View File
@@ -36,8 +36,6 @@ extern u16 D_800DC5B0;
extern u16 D_800DC5B8;
extern s32 D_800E86A0;
extern struct Controller *D_800DC4CC;
extern s32 D_8018EE08;
extern u16 D_800DC51C;
extern s32 D_80150118;
@@ -49,7 +47,7 @@ extern s32 D_800DC530;
extern s32 D_8018D2AC;
extern s32 D_800DC52C;
extern s16 gCurrentCourseId;
extern u16 D_80162DD6;
extern u16 D_80162DD4[];
extern u16 D_8015F890;
extern u32 D_800DC5AC;
extern u16 gEnableDebugMode;
@@ -107,8 +105,6 @@ UNUSED s32 D_802BA03C;
s16 D_802BA040[4];
u16 D_802BA048;
// Likely bss memed need to declare controllers likely in main.c
void func_8028DF00(void) {
struct Controller *controllers = &gControllers[0];
s32 i;
@@ -622,7 +618,7 @@ GLOBAL_ASM("asm/non_matchings/code_8028DF00/func_8028EDA8.s")
f32 func_8028EE8C(s32 i) {
f32 temp_f14;
temp_f14 = D_8015F8D8 - gPlayers[i].unk_01C;
return gCourseTimer - ((D_802B9254 * temp_f14) / (temp_f14 + (gPlayers[i].unk_028 - D_8015F8D8)));
return gCourseTimer - ((D_802B9254 * temp_f14) / (temp_f14 + (gPlayers[i].rotZ - D_8015F8D8)));
}
*/
+261
View File
@@ -0,0 +1,261 @@
#include <ultra64.h>
#include <PR/os.h>
#include <macros.h>
#include "types.h"
#include <common_structs.h>
extern s32 D_800DDB40;
/*
void func_80296A50(s32 arg0, s32 arg3) {
void *sp1C;
s16 temp_t3;
s16 temp_t7;
s16 temp_v0;
s32 temp_a2;
s32 temp_a2_2;
s32 temp_a2_3;
s32 temp_a2_4;
u16 temp_t1;
void *phi_a1;
u16 phi_a2;
void *phi_a1_2;
u16 phi_a2_2;
s32 phi_a2_3;
void *phi_a1_3;
u16 phi_a2_4;
s32 phi_a2_5;
void *phi_a1_4;
u16 phi_a2_6;
s32 phi_a3;
temp_t1 = D_8015F900;
if ((s32) temp_t1 < 0x64) {
phi_a1 = (temp_t1 * 0x70) + &D_8015F9B8;
phi_a2 = temp_t1;
loop_2:
if ((arg0 != phi_a1) && ((phi_a1->unk2 & 0xF) == 0) && (phi_a1->unk0 == 7)) {
if (phi_a1->unk6 == 2) {
sp1C = phi_a1;
func_8000EE58(phi_a2, phi_a1, phi_a2, 2);
}
D_8015F6FE = (u16) (D_8015F6FE - 1);
func_8029E854(phi_a1, phi_a1);
return;
}
temp_a2 = phi_a2 + 1;
phi_a1 += 0x70;
phi_a2 = (u16) temp_a2;
if (temp_a2 >= 0x64) {
goto block_10;
}
goto loop_2;
}
block_10:
phi_a2_3 = (s32) D_8015F900;
if ((s32) D_8015F900 < 0x64) {
phi_a1_2 = ((s32) D_8015F900 * 0x70) + &D_8015F9B8;
phi_a2_2 = (u16) (s32) D_8015F900;
loop_12:
if ((arg0 != phi_a1_2) && ((phi_a1_2->unk2 & 0xF) == 0) && (phi_a1_2->unk0 == 8) && (temp_t3 = phi_a1_2->unk6, (((u32) (temp_t3 - 2) < 8U) != 0))) {
switch (temp_t3) { // switch 1
case 2: // switch 1
case 3: // switch 1
case 4: // switch 1
case 5: // switch 1
case 8: // switch 1
case 9: // switch 1
sp1C = phi_a1_2;
func_8000EE58(phi_a2_2, phi_a1_2, phi_a2_2);
// fallthrough
case 7: // switch 1
D_8015F6FE = (u16) (D_8015F6FE - 1);
func_8029E854(phi_a1_2, phi_a1_2);
return;
}
} else {
default: // switch 1
temp_a2_2 = phi_a2_2 + 1;
phi_a1_2 += 0x70;
phi_a2_2 = (u16) temp_a2_2;
if (temp_a2_2 >= 0x64) {
phi_a2_3 = (s32) temp_t1;
goto block_21;
}
goto loop_12;
}
} else {
block_21:
phi_a2_5 = phi_a2_3;
phi_a3 = arg3;
if (phi_a2_3 < 0x64) {
phi_a1_3 = (phi_a2_3 * 0x70) + &D_8015F9B8;
phi_a2_4 = (u16) phi_a2_3;
loop_23:
if ((arg0 != phi_a1_3) && (phi_a1_3->unk0 == 7)) {
temp_v0 = phi_a1_3->unk6;
if (temp_v0 != 2) {
if (temp_v0 != 7) {
goto block_30;
}
goto block_29;
}
sp1C = phi_a1_3;
func_8000EE58(phi_a2_4, phi_a1_3, phi_a2_4, 2);
block_29:
D_8015F6FE = (u16) (D_8015F6FE - 1);
func_8029E854(phi_a1_3, phi_a1_3);
return;
}
block_30:
temp_a2_3 = phi_a2_4 + 1;
phi_a1_3 += 0x70;
phi_a2_4 = (u16) temp_a2_3;
if (temp_a2_3 >= 0x64) {
phi_a2_5 = (s32) temp_t1;
phi_a3 = 2;
goto block_32;
}
goto loop_23;
}
block_32:
if (phi_a2_5 < 0x64) {
phi_a1_4 = (phi_a2_5 * 0x70) + &D_8015F9B8;
phi_a2_6 = (u16) phi_a2_5;
loop_34:
if ((arg0 != phi_a1_4) && (phi_a1_4->unk0 == 8) && (temp_t7 = phi_a1_4->unk6, (((u32) (temp_t7 - 2) < 8U) != 0))) {
switch (temp_t7) { // switch 2
case 2: // switch 2
case 3: // switch 2
case 4: // switch 2
case 5: // switch 2
case 8: // switch 2
case 9: // switch 2
sp1C = phi_a1_4;
func_8000EE58(phi_a2_6, phi_a1_4, phi_a2_6, phi_a3);
// fallthrough
case 7: // switch 2
D_8015F6FE = (u16) (D_8015F6FE - 1);
func_8029E854(phi_a1_4, phi_a1_4);
return;
}
} else {
default: // switch 2
temp_a2_4 = phi_a2_6 + 1;
phi_a1_4 += 0x70;
phi_a2_6 = (u16) temp_a2_4;
if (temp_a2_4 >= 0x64) {
// Duplicate return node #41. Try simplifying control flow for better match
return;
}
goto loop_34;
}
}
}
}
*/
GLOBAL_ASM("asm/non_matchings/code_80296A50/func_80296A50.s")
GLOBAL_ASM("asm/non_matchings/code_80296A50/func_80296D10.s")
// 801646F0 // 80161B68
// Actor leave screen
/*
void func_80297230(Camera *arg0, Item *arg1) {
switch((arg0 - D_800DDB40) / 0xB8) { // / 0xB8
case 0:
arg1->unk2 = (s16) (arg1->unk2 & 0xFFFE);
break;
case 1:
arg1->unk2 = (s16) (arg1->unk2 & 0xFFFD);
break;
case 2:
arg1->unk2 = (s16) (arg1->unk2 & 0xFFFB);
break;
case 3:
arg1->unk2 = (s16) (arg1->unk2 & 0xFFF7);
break;
}
}
*/
GLOBAL_ASM("asm/non_matchings/code_80296A50/func_80297230.s")
/*
void func_802972B8(Camera *arg0, Item *arg1) {
switch((arg0 - D_800DDB40) / 0xB8) {
case 0:
arg1->unk2 = (s16) (arg1->unk2 | 1);
break;
case 1:
arg1->unk2 = (s16) (arg1->unk2 | 2);
break;
case 2:
arg1->unk2 = (s16) (arg1->unk2 | 4);
break;
case 3:
arg1->unk2 = (s16) (arg1->unk2 | 8);
break;
}
}
*/
GLOBAL_ASM("asm/non_matchings/code_80296A50/func_802972B8.s")
/*
void func_80297340(void *arg0) {
? sp38;
s16 sp36;
void *temp_v0;
void *temp_v0_2;
void *temp_v0_3;
void *temp_v0_4;
void *temp_v0_5;
void *temp_v0_6;
sp36 = (s16) (s32) D_8015F8D0.unk8;
if ((D_800DC50C != 9) && (func_802B5520(&sp38, &D_8015F8D0), (func_802B4FF8(&sp38, 0) != 0))) {
if ((f32) sp36 < arg0->unk8) {
if (D_800DC5BC != 0) {
temp_v0 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0 + 8);
temp_v0->unk0 = 0xF8000000;
temp_v0->unk4 = (s32) ((D_801625EC << 0x18) | ((D_801625F4 & 0xFF) << 0x10) | ((D_801625F0 & 0xFF) << 8) | 0xFF);
temp_v0_2 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0_2 + 8);
temp_v0_2->unk0 = 0x6000000;
temp_v0_2->unk4 = &D_0D001C20;
return;
}
temp_v0_3 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0_3 + 8);
temp_v0_3->unk4 = 0xD001B90;
temp_v0_3->unk0 = 0x6000000;
return;
}
if (D_800DC5BC != 0) {
temp_v0_4 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0_4 + 8);
temp_v0_4->unk0 = 0xF8000000;
temp_v0_4->unk4 = (s32) ((D_801625EC << 0x18) | ((D_801625F4 & 0xFF) << 0x10) | ((D_801625F0 & 0xFF) << 8) | 0xFF);
temp_v0_5 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0_5 + 8);
temp_v0_5->unk0 = 0x6000000;
temp_v0_5->unk4 = &D_0D001C88;
return;
}
temp_v0_6 = gDisplayListHead;
gDisplayListHead = (void *) (temp_v0_6 + 8);
temp_v0_6->unk4 = 0xD001BD8;
temp_v0_6->unk0 = 0x6000000;
// Duplicate return node #9. Try simplifying control flow for better match
}
}
void func_802976D8(void *arg0) {
arg0->unk0 = 0x4000;
arg0->unk2 = 0;
arg0->unk4 = 0;
}
*/
GLOBAL_ASM("asm/non_matchings/code_80296A50/func_80297340.s")
GLOBAL_ASM("asm/non_matchings/code_80296A50/code_80296A50.s")
+18 -52
View File
@@ -33,70 +33,36 @@ extern void *D_80162D64;
u32 D_800DC670 = 0;
u32 crashScreenFont[34] = {
u8 crashScreenFont[][8] = {
#include "textures/crash_screen/crash_screen_font.ia1.inc.c"
};
u16 D_800DC6FC[10] = {
32, 2048, 512, 1024, 256, 16, 32, 16384, 32768, 65535
// 0x0020, 0x0800, 0x0200, 0x0400, 0x0100, 0x0010, 0x0020, 0x4000, 0x8000, 0xffff
};
/*
// similar to sm64's crash_screen_draw_glyph
void func_800040C0(uintptr_t framebuffer, s32 x, s32 y, u32 glyph) {
s32 temp_v0;
u32 *data;
u16 *ptr;
s32 temp_a0;
s32 phi_v1;
s32 phi_v0;
s32 phi_a0;
//phi_v0 = frameBuffer;
//temp_v0 = glyph * 7;
ptr = framebuffer; //+ y * 320 + x;
data = crashScreenFont[glyph * 8];
temp_v0 = 0;
while(temp_v0 != 8) {
phi_v1 = (s32)*data;
phi_a0 = 5;
for (temp_a0 = 0; temp_a0 >= 0; temp_a0++) {
if (phi_v1 & 1) {
framebuffer += ((((y +phi_v0) * 320) + x + phi_a0) * 2);
}
//ptr++;
phi_a0--;
*data += *data >> 1;
//phi_a0 = temp_a0;
}
//phi_v0++;
//phi_v0 = temp_v0;
data += 1;
}
}
*/
/*
void func_800040C0(s32 x, s32 y, s32 w, s32 h) {
u16 *ptr;
void crash_screen_draw_glyph(u16 *framebuffer, s32 x, s32 y, s32 glyph) {
s32 data;
s32 ptr;
s32 i, j;
ptr = gCrashScreen.framebuffer + gCrashScreen.width * y + x;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
// 0xe738 = 0b1110011100111000
*ptr = ((*ptr & 0xe738) >> 2) | 1;
ptr++;
for(i = 0; i < 8; i++) {
data = crashScreenFont[glyph][i];
for (j = 5; j >= 0; j--) {
ptr = (y + i) * 320 + (x + j);
if (data & 1) {
framebuffer[ptr] = 0xffff;
}
data = data >> 1;
}
ptr += gCrashScreen.width - w;
}
}
*/
GLOBAL_ASM("asm/non_matchings/crash_screen/func_800040C0.s")
GLOBAL_ASM("asm/non_matchings/crash_screen/crash_screen.s")
/*
@@ -399,4 +365,4 @@ void start_debug_thread(void) {
osStartThread(&D_80162790);
}
*/
*/
+22
View File
@@ -0,0 +1,22 @@
#include <ultra64.h>
#include "config.h"
u8 D_802BA290[22768];
u8 D_802BFB80[77824];
u8 D_802D2B80[32768]; // Luigi raceway course path ghost
u8 D_802DAB80[20480];
u16 D_802DFB80[37376];
u16 D_802F1F80[16382];
u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
#ifdef AVOID_UB
u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
#else
u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT];
u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT];
u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT];
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef FRAMEBUFFERS_H
#define FRAMEBUFFERS_H
#include <PR/ultratypes.h>
#include "config.h"
extern u8 D_802BA290[22768];
extern u8 D_802BFB80[77824];
extern u8 D_802D2B80[32768];
extern u8 D_802DAB80[20480];
extern u16 D_802DFB80[37376];
extern u16 D_802F1F80[16382];
extern u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
// NOTE: This UB fix from sm64 implemented in mk64,
// in-case it has the same issue.
// untested. Unconfirmed if this applies to mk64.
// level_script.c assumes that the frame buffers are adjacent, while game.c's
// -g codegen implies that they are separate variables. This is impossible to
// reconcile without undefined behavior. Avoid that when possible.
#ifdef AVOID_UB
extern u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
#define gFramebuffer0 gFramebuffers[0]
#define gFramebuffer1 gFramebuffers[1]
#define gFramebuffer2 gFramebuffers[2]
#else
extern u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT];
extern u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT];
extern u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT];
#endif
#endif // FRAMEBUFFERS_H
+82 -133
View File
@@ -25,8 +25,14 @@ void profiler_log_vblank_time(void);
void create_thread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri pri);
void create_debug_thread(void);
void start_debug_thread(void);
struct SPTask *create_next_audio_frame_task(void);
extern void dma_copy(u8 *dest, u8 *arg1, u32 size);
extern s32 func_802A7D70(u8 *arg0, u8 *arg1);
extern void func_802A7CF0(u32 arg0, u32 arg1);
extern s32 D_800DC524;
extern s32 D_800DC52C;
extern OSThread gIdleThread;
@@ -137,21 +143,23 @@ extern u8 _data_segment2SegmentRomEnd[];
extern u8 _common_texturesSegmentRomStart[];
extern u8 _common_texturesSegmentRomEnd[];
extern u8 _data_802BA370SegmentRomStart[];
extern OSMesg *D_8014F098;
extern OSIoMesg *D_8014F0A0;
extern OSMesg D_8014F098;
extern OSIoMesg D_8014F0A0;
extern u32 gHeapEndPtr;
extern u32 *D_801978D0;
extern OSContPad *gControllerPads[4];
extern OSMesgQueue gSIEventMesgQueue;
extern OSMesg gSIEventMesgBuf[3];
extern u32 D_801502B4;
extern u32 D_802F9F80;
extern u32 gZBuffer;
extern s32 D_8031F780;
extern s32 D_80344F80[];
extern s32 D_8036A780;
extern s32 gFramebuffer0;
extern s32 gFramebuffer1;
extern s32 gFramebuffer2;
extern s32 D_8015AB80;
extern s32 D_801589D0;
@@ -273,65 +281,48 @@ void init_controllers(void) {
}
#ifdef MIPS_TO_C
//generated by mips_to_c commit ffee479fae41a1cdc3e454e9b9d75bbd226a160f
void func_80000934(s32 arg0) {
s32 temp_a2;
u16 temp_a1;
u16 temp_t4;
void *temp_v0;
void *temp_v1;
u16 phi_a1;
struct Controller *controller = &gControllers[arg0];
u16 phi_a0;
u16 phi_a0_2;
u16 phi_a0_3;
u16 phi_a0_4;
if (sController1Unplugged == 0) {
// potantial sizeof structs?
temp_v1 = (arg0 * 6) + &gControllerPads;
temp_v0 = (arg0 * 0x10) + &gControllers;
temp_v0->unk0 = (s16) temp_v1->unk2;
temp_v0->unk2 = (s16) temp_v1->unk3;
temp_t4 = temp_v1->unk0 | 0x2000;
phi_a1 = temp_v1->unk0;
if ((temp_v1->unk0 & 4) != 0) {
temp_v1->unk0 = temp_t4;
phi_a1 = temp_t4 & 0xFFFF;
}
temp_v0->unk6 = (s16) ((phi_a1 ^ temp_v0->unk4) & phi_a1);
temp_v0->unk8 = (s16) ((temp_v1->unk0 ^ temp_v0->unk4) & temp_v0->unk4);
temp_v0->unk4 = (u16) temp_v1->unk0;
phi_a0_4 = (u16)0U;
if ((s32) temp_v0->unk0 < -0x32) {
phi_a0_4 = (u16)0x200U;
}
phi_a0_3 = phi_a0_4;
if ((s32) temp_v0->unk0 >= 0x33) {
phi_a0_3 = (phi_a0_4 | 0x100) & 0xFFFF;
}
phi_a0_2 = phi_a0_3;
if ((s32) temp_v0->unk2 < -0x32) {
phi_a0_2 = (phi_a0_3 | 0x400) & 0xFFFF;
}
phi_a0 = phi_a0_2;
if ((s32) temp_v0->unk2 >= 0x33) {
phi_a0 = (phi_a0_2 | 0x800) & 0xFFFF;
}
temp_a1 = temp_v0->unkA;
temp_v0->unkA = phi_a0;
temp_a2 = phi_a0 ^ temp_a1;
temp_v0->unkC = (s16) (phi_a0 & temp_a2);
temp_v0->unkE = (s16) (temp_a1 & temp_a2);
if (sController1Unplugged != 0) {
return;
}
controller->rawStickX = gControllerPads[arg0]->stick_x;
controller->rawStickY = gControllerPads[arg0]->stick_y;
if ((gControllerPads[arg0]->button & 4) != 0) {
gControllerPads[arg0]->button |= Z_TRIG;
gControllerPads[arg0]->button |= Z_TRIG;
}
controller->buttonPressed = ((gControllerPads[arg0]->button ^ controller->button) & gControllerPads[arg0]->button);
controller->buttonDepressed = ((gControllerPads[arg0]->button ^ controller->button) & controller->button);
controller->button = &gControllerPads[arg0]->button;
phi_a0 = 0;
if (controller->rawStickX < -50) {
phi_a0 |= L_JPAD;
}
if (controller->rawStickX > 50) {
phi_a0 |= R_JPAD;
}
if (controller->rawStickY < -50) {
phi_a0 |= D_JPAD;
}
if (controller->rawStickY > 50) {
phi_a0 |= U_JPAD;
}
controller->stickPressed = phi_a0 & (phi_a0 ^ controller->stickDirection);
controller->stickDepressed = controller->stickDirection & (phi_a0 ^ controller->stickDirection);
controller->stickDirection = phi_a0;
}
#else
GLOBAL_ASM("asm/non_matchings/main/func_80000934.s")
#endif
#ifdef MIPS_TO_C
// generated by mips_to_c commit cae1414eb1bf34873a831a523692fe29870a6f3b
void *read_controllers(void) {
? sp1C;
void read_controllers(void) {
OSMesg sp1C;
osContStartReadData(&gSIEventMesgQueue);
osRecvMesg(&gSIEventMesgQueue, &sp1C, 1);
@@ -340,20 +331,16 @@ void *read_controllers(void) {
func_80000934(1);
func_80000934(2);
func_80000934(3);
D_800DC4CC->unk4 = (s16) (((D_800DC4BC->unk4 | D_800DC4C0->unk4) | D_800DC4C4->unk4) | D_800DC4C8->unk4);
D_800DC4CC->unk6 = (s16) (((D_800DC4BC->unk6 | D_800DC4C0->unk6) | D_800DC4C4->unk6) | D_800DC4C8->unk6);
D_800DC4CC->unk8 = (s16) (((D_800DC4BC->unk8 | D_800DC4C0->unk8) | D_800DC4C4->unk8) | D_800DC4C8->unk8);
D_800DC4CC->unkA = (s16) (((D_800DC4BC->unkA | D_800DC4C0->unkA) | D_800DC4C4->unkA) | D_800DC4C8->unkA);
D_800DC4CC->unkC = (s16) (((D_800DC4BC->unkC | D_800DC4C0->unkC) | D_800DC4C4->unkC) | D_800DC4C8->unkC);
D_800DC4CC->unkE = (s16) (((D_800DC4BC->unkE | D_800DC4C0->unkE) | D_800DC4C4->unkE) | D_800DC4C8->unkE);
return &D_800DC4CC;
D_800DC4CC->button = (s16) (((D_800DC4BC->button | D_800DC4C0->button) | D_800DC4C4->button) | D_800DC4C8->button);
D_800DC4CC->buttonPressed = (s16) (((D_800DC4BC->buttonPressed | D_800DC4C0->buttonPressed) | D_800DC4C4->buttonPressed) | D_800DC4C8->buttonPressed);
D_800DC4CC->buttonDepressed = (s16) (((D_800DC4BC->buttonDepressed | D_800DC4C0->buttonDepressed) | D_800DC4C4->buttonDepressed) | D_800DC4C8->buttonDepressed);
D_800DC4CC->stickDirection = (s16) (((D_800DC4BC->stickDirection | D_800DC4C0->stickDirection) | D_800DC4C4->stickDirection) | D_800DC4C8->stickDirection);
D_800DC4CC->stickPressed = (s16) (((D_800DC4BC->stickPressed | D_800DC4C0->stickPressed) | D_800DC4C4->stickPressed) | D_800DC4C8->stickPressed);
D_800DC4CC->stickDepressed = (s16) (((D_800DC4BC->stickDepressed | D_800DC4C0->stickDepressed) | D_800DC4C4->stickDepressed) | D_800DC4C8->stickDepressed);
}
#else
GLOBAL_ASM("asm/non_matchings/main/read_controllers.s")
#endif
void func_80000BEC(void) {
D_801502B4 = VIRTUAL_TO_PHYSICAL(&D_802F9F80);
D_801502B4 = VIRTUAL_TO_PHYSICAL(&gZBuffer);
}
// send_sp_task_message from SM64
@@ -464,64 +451,31 @@ void func_800010CC(void) {
osInvalDCache(SEG_8028DF00, 0x2C470);
}
// Similar to dma_read in SM64
#ifdef MIPS_TO_C
//generated by mips_to_c commit ffee479fae41a1cdc3e454e9b9d75bbd226a160f
void dma_copy(s32 arg0, s32 arg1, u32 arg2) {
s32 temp_s1;
s32 temp_s2;
u32 temp_s0;
s32 phi_s2;
s32 phi_s1;
u32 phi_s0;
u32 phi_s0_2;
s32 phi_s2_2;
s32 phi_s1_2;
void dma_copy(u8 *dest, u8 *arg1, u32 size) {
osInvalDCache(arg2);
phi_s0_2 = arg2;
phi_s2_2 = arg1;
phi_s1_2 = arg0;
if (arg2 >= 0x101U) {
phi_s2 = arg1;
phi_s1 = arg0;
phi_s0 = arg2;
loop_2:
osPiStartDma(&D_8014F0A0, 0, 0, phi_s2, phi_s1, 0x100, &D_8014EF58);
osInvalDCache(dest, size);
while(size > 0x100) {
osPiStartDma(&D_8014F0A0, 0, 0, (unsigned long)arg1, dest, 0x100, &D_8014EF58);
osRecvMesg(&D_8014EF58, &D_8014F098, 1);
temp_s0 = phi_s0 - 0x100;
temp_s2 = phi_s2 + 0x100;
temp_s1 = phi_s1 + 0x100;
phi_s2 = temp_s2;
phi_s1 = temp_s1;
phi_s0 = temp_s0;
phi_s0_2 = temp_s0;
phi_s2_2 = temp_s2;
phi_s1_2 = temp_s1;
if (temp_s0 >= 0x101U) {
goto loop_2;
}
size -= 0x100;
arg1 += 0x100;
dest += 0x100;
}
if (phi_s0_2 != 0) {
osPiStartDma(&D_8014F0A0, 0, 0, phi_s2_2, phi_s1_2, phi_s0_2, &D_8014EF58);
if (size != 0) {
osPiStartDma(&D_8014F0A0, 0, 0, (unsigned long)arg1, dest, size, &D_8014EF58);
osRecvMesg(&D_8014EF58, &D_8014F098, 1);
}
}
#else
GLOBAL_ASM("asm/non_matchings/main/dma_copy.s")
#endif
// Resembles setup_game_memory from SM64
#ifdef NON_MATCHING
void init_game(void) {
s32 sp38;//0x38(sp)
u32 *sp2C;
s32 temp_t7;
s32 sp40;
UNUSED u32 pad[2];
u32 sp2C;
u32 sp40;
s32 texture_seg;
//u32 temp_a1;
UNUSED s16 unknown_padding;
s32 sp38;
UNUSED s32 unknown_padding;
func_800010CC();
gHeapEndPtr = SEG_8028DF00;
set_segment_base_addr(0, 0x80000000);
@@ -531,16 +485,14 @@ void init_game(void) {
osPiStartDma(&D_8014F0A0, 0, 0, &_data_802BA370SegmentRomStart, SEG_802BA370, 0x5810, &D_8014EF58);
osRecvMesg(&D_8014EF58, &D_8014F098, 1);
set_segment_base_addr(2, func_802A7D70(&_data_segment2SegmentRomStart, &_data_segment2SegmentRomEnd));
texture_seg = ALIGN16((u32)&_common_texturesSegmentRomEnd - (u32)&_common_texturesSegmentRomStart);
sp2C = SEG_8028DF00 - texture_seg;
osPiStartDma(&D_8014F0A0, 0, 0, &_common_texturesSegmentRomStart, SEG_8028DF00 - texture_seg, texture_seg, &D_8014EF58);
sp2C = (u32)&_common_texturesSegmentRomEnd - (u32)&_common_texturesSegmentRomStart;
sp2C = ALIGN16(sp2C);
texture_seg = SEG_8028DF00-sp2C;
osPiStartDma(&D_8014F0A0, 0, 0, &_common_texturesSegmentRomStart, texture_seg, sp2C, &D_8014EF58);
osRecvMesg(&D_8014EF58, &D_8014F098, 1);
//need to match this
sp40 = texture_seg + 4;
sp40 = ALIGN16(sp2C[1]);
sp40 = *(u32 *)(texture_seg + 4);
sp40 = ALIGN16(sp40);
sp38 = gPrevLoadedAddress;
mio0decode(texture_seg, sp38);
set_segment_base_addr(0xD, sp38);
@@ -548,9 +500,6 @@ void init_game(void) {
gPrevLoadedAddress += sp40;
D_8015F734 = gPrevLoadedAddress;
}
#else
GLOBAL_ASM("asm/non_matchings/main/init_game.s")
#endif
void func_80001404(void) {
D_800DC524 = 0;
@@ -1134,18 +1083,18 @@ GLOBAL_ASM("asm/non_matchings/main/func_800022DC.s")
void thread3_video(void *arg0) {
u64 *temp_v0;
s32 i;
gPhysicalFramebuffers[0] = (uintptr_t *) &D_8031F780;
gPhysicalFramebuffers[1] = (uintptr_t *) &D_80344F80;
gPhysicalFramebuffers[2] = (uintptr_t *) &D_8036A780;
//phi_v0 = &D_80344F80;
gPhysicalFramebuffers[0] = (uintptr_t *) &gFramebuffer0;
gPhysicalFramebuffers[1] = (uintptr_t *) &gFramebuffer1;
gPhysicalFramebuffers[2] = (uintptr_t *) &gFramebuffer2;
//phi_v0 = &gFramebuffer1;
//loop_1:
// potential unrolled loop?
temp_v0 = &D_80344F80[0];
for (i = 0; i < D_8036A780; i++) {
temp_v0 = &gFramebuffer1;
for (i = 0; i < gFramebuffer2; i++) {
temp_v0[i] = 0;
}
//if (D_80344F80 != &D_8036A780) {
//if (gFramebuffer1 != &gFramebuffer2) {
// goto loop_1;
//}
setup_mesg_queues();
+595
View File
@@ -0,0 +1,595 @@
#include <ultra64.h>
#include <macros.h>
#include <types.h>
#include <common_structs.h>
extern s32 mio0encode(s32 input, s32, s32);
extern s32 func_80040174(void *, s32, s32);
extern s32 func_800B4E24(s32 arg0);
extern void func_80005AE8(Player *ply);
u32 *D_80162D80;
s16 D_80162D84;
s16 D_80162D86;
u16 D_80162D88;
u32 D_80162D8C;
s16 D_80162D90;
u32 *D_80162D94;
u16 D_80162D98;
u32 D_80162D9C;
s16 D_80162DA0;
u32 *D_80162DA4;
u16 D_80162DA8;
s32 D_80162DAC;
s16 D_80162DB0;
u32 *D_80162DB4;
s16 D_80162DB8;
u32 *D_80162DBC;
u16 D_80162DC0;
u32 D_80162DC4;
s32 D_80162DC8;
s32 D_80162DCC;
s32 D_80162DD0;
u16 D_80162DD4;
u16 D_80162DD6;
u16 D_80162DD8;
s32 D_80162DDC;
s32 D_80162DE0;
s32 D_80162DE4;
s32 D_80162DE8;
s32 D_80162DEC;
s32 D_80162DF0;
s32 D_80162DF4;
s32 D_80162DF8;
s32 D_80162DFC;
s32 D_80162E00;
extern u8 D_802BFB80[77824];
extern u8 D_802D2B80[32768];
extern u8 D_802DAB80[20480];
u32 *D_800DC710 = &D_802D2B80[0];
u32 *D_800DC714 = &D_802DAB80[0];
extern OSIoMesg *D_8014F0A0;
extern u8 _kart_texturesSegmentRomStart;
extern OSMesgQueue D_8014EF58;
extern OSMesg D_8014F098;
extern s16 gCurrentCourseId;
extern s32 gModeSelection;
extern s32 D_800DC52C;
extern u16 D_8015F890;
extern s32 lapCount[];
extern s32 D_8018CA78;
extern Player *D_800DC4DC;
extern Player* D_800DC4E0;
extern Player *D_800DC4E4;
extern struct Controller *D_800DC4D0;
extern struct Controller *D_800DC4D4;
extern struct Controller *D_800DC4D8;
extern struct Controller *D_800DC4BC;
extern StaffGhost *d_mario_raceway_staff_ghost;
extern StaffGhost *d_royal_raceway_staff_ghost;
extern StaffGhost *d_luigi_raceway_staff_ghost;
extern s32 D_80164394;
extern s32 D_80164398;
void func_80004EF0(void) {
D_80162DA4 = &D_802D2B80[0];
osInvalDCache(&D_80162DA4[0], 0x4000);
osPiStartDma(&D_8014F0A0, 0, 0, (D_80162DC4 & 0xFFFFFF) + &_kart_texturesSegmentRomStart, D_80162DA4, 0x4000, &D_8014EF58);
osRecvMesg(&D_8014EF58, &D_8014F098, 1);
D_80162D9C = (*D_80162DA4 & 0xFF0000);
D_80162DA0 = 0;
}
void func_80004FB0(void) {
D_80162DB4 = &D_802BFB80[(D_80162DD0 << 0xf) + 0x3000];
D_80162DAC = *D_80162DB4 & 0xFF0000;
D_80162DB0 = 0;
}
void func_80004FF8(void) {
D_80162D94 = &D_802BFB80[(D_80162DC8 << 0xF) + 0x3000];
D_80162D8C = (s32) *D_80162D94 & 0xFF0000;
D_80162D90 = 0;
}
/**
* Activates staff ghost if time trial lap time is lower enough
*
*/
void set_staff_ghost(void) {
u32 temp_v0; // Appears to be player total lap time.
switch(gCurrentCourseId) {
case COURSE_MARIO_RACEWAY:
temp_v0 = func_800B4E24(0) & 0xfffff;
if (temp_v0 <= 9000) {
D_80162DD6 = 0;
D_80162DF4 = 0;
} else {
D_80162DD6 = 1;
D_80162DF4 = 1;
}
D_80162DC4 = &d_mario_raceway_staff_ghost;
D_80162DE4 = 0;
break;
case COURSE_ROYAL_RACEWAY:
temp_v0 = func_800B4E24(0) & 0xfffff;
if (temp_v0 <= 16000) {
D_80162DD6 = 0;
D_80162DF4 = 0;
} else {
D_80162DD6 = 1;
D_80162DF4 = 1;
}
D_80162DC4 = &d_royal_raceway_staff_ghost;
D_80162DE4 = 6;
break;
case COURSE_LUIGI_RACEWAY:
temp_v0 = func_800B4E24(0) & 0xfffff;
if (temp_v0 <= 11200) {
D_80162DD6 = 0;
D_80162DF4 = 0;
} else {
D_80162DD6 = 1;
D_80162DF4 = 1;
}
D_80162DC4 = &d_luigi_raceway_staff_ghost;
D_80162DE4 = 1;
break;
default:
D_80162DD6 = 1;
D_80162DF4 = 1;
}
}
s32 func_800051C4(void) {
s32 phi_v0;
if (D_80162D84 != 0) {
// func_80040174 in mio0_decode.s
func_80040174(D_80162D80, (D_80162D84 * 4) + 0x20, D_800DC710);
phi_v0 = mio0encode(D_800DC710, (D_80162D84 * 4) + 0x20, D_800DC714);
return phi_v0 + 0x1e;
}
}
void func_8000522C(void) {
D_80162D94 = &D_802BFB80[(D_80162DC8 << 0xF) + 0x3000];
mio0decode(D_800DC714, D_80162D94);
D_80162D8C = (s32) (*D_80162D94 & 0xFF0000);
D_80162D90 = 0;
D_80162E00 = 1;
}
void func_800052A4(void) {
s16 temp_v0;
if (D_80162DC8 == 1) {
D_80162DC8 = 0;
D_80162DCC = 1;
} else {
D_80162DC8 = 1;
D_80162DCC = 0;
}
temp_v0 = D_80162DB8;
D_80162D80 = (void *) &D_802BFB80[(D_80162DC8 << 0xF) + 0x3000];
D_80162D84 = temp_v0;
D_80162D86 = temp_v0;
}
void func_80005310(void) {
// if time trials
if (gModeSelection == 1) {
set_staff_ghost();
if (D_80162DC0 != gCurrentCourseId) {
D_80162DD4 = 1;
}
D_80162DC0 = (u16) gCurrentCourseId;
D_80162DF0 = 0;
D_80162DEC = 0;
D_80162DF8 = 0;
if (gModeSelection == 1 && D_800DC52C == 0) {
if (D_8015F890 == 1) {
func_80004FB0();
if (D_80162DD8 == 0) {
func_80004FF8();
}
if (D_80162DD6 == 0) {
func_80004EF0();
}
} else {
D_80162DD8 = 1U;
D_80162DBC = &D_802BFB80[(D_80162DCC << 0xF) + 0x3000];
D_80162DBC[0] = -1;
D_80162DB8 = 0;
D_80162DDC = 0;
func_80091EE4(&D_80162DC0);
if (D_80162DD4 == 0) {
func_80004FF8();
}
if (D_80162DD6 == 0) {
func_80004EF0();
}
}
}
}
}
s32 func_8000546C(void) {
u32 temp_a0;
u32 temp_a1;
UNUSED u16 unk;
u16 temp_v1;
s16 phi_v1;
s16 phi_v0 = 0;
if (D_80162DB0 >= 0x1000) {
D_800DC4DC->unk_000 = 0x3800;
return;
}
temp_a0 = D_80162DB4[D_80162DB0];
temp_a1 = temp_a0 & 0xFF;
if (temp_a1 < 0x80U) {
phi_v1 = (s16) (temp_a1 & 0xFF);
} else {
phi_v1 = (s16) (temp_a1 | (~0xFF));
}
temp_a1 = (u32) (temp_a0 & 0xFF00) >> 8;
D_800DC4D8->rawStickX = phi_v1;
if (temp_a1 < 0x80U) {
phi_v1 = (s16) (temp_a1 & 0xFF);
} else {
phi_v1 = (s16) (temp_a1 | (~0xFF));
}
D_800DC4D8->rawStickY = phi_v1;
if (temp_a0 & 0x80000000) {
phi_v0 |= A_BUTTON;
}
if (temp_a0 & 0x40000000) {
phi_v0 |= B_BUTTON;
}
if (temp_a0 & 0x20000000) {
phi_v0 |= Z_TRIG;
}
if (temp_a0 & 0x10000000) {
phi_v0 |= R_TRIG;
}
temp_v1 = D_800DC4D8->buttonPressed & 0x1F0F;
D_800DC4D8->buttonPressed = (phi_v0 & (phi_v0 ^ D_80162DA8)) | temp_v1;
temp_v1 = D_800DC4D8->buttonDepressed & 0x1F0F;
D_800DC4D8->buttonDepressed = (D_80162DA8 & (phi_v0 ^ D_80162DA8)) | temp_v1;
D_80162DA8 = phi_v0;
D_800DC4D8->button = phi_v0;
if (D_80162DAC == 0) {
D_80162DB0++;
D_80162DAC = (s32) (D_80162DB4[D_80162DB0] & 0xFF0000);
} else {
D_80162DAC += 0xFFFF0000;
}
}
void func_8000561C(void) {
u32 temp_a0;
u32 temp_v0;
UNUSED u16 unk;
u16 temp_v1;
s16 phi_v1;
s16 phi_a2 = 0;
if (D_80162DA0 >= 0x1000) {
func_80005AE8(D_800DC4E4);
return;
}
temp_a0 = D_80162DA4[D_80162DA0];
temp_v0 = temp_a0 & 0xFF;
if (temp_v0 < 0x80U) {
phi_v1 = (s16) (temp_v0 & 0xFF);
} else {
phi_v1 = (s16) (temp_v0 | (~0xFF));
}
temp_v0 = (u32) (temp_a0 & 0xFF00) >> 8;
D_800DC4D4->rawStickX = phi_v1;
if (temp_v0 < 0x80U) {
phi_v1 = (s16) (temp_v0 & 0xFF);
} else {
phi_v1 = (s16) (temp_v0 | (~0xFF));
}
D_800DC4D4->rawStickY = phi_v1;
if (temp_a0 & 0x80000000) {
phi_a2 = A_BUTTON;
}
if (temp_a0 & 0x40000000) {
phi_a2 |= B_BUTTON;
}
if (temp_a0 & 0x20000000) {
phi_a2 |= Z_TRIG;
}
if (temp_a0 & 0x10000000) {
phi_a2 |= R_TRIG;
}
temp_v1 = D_800DC4D4->buttonPressed & 0x1F0F;
D_800DC4D4->buttonPressed = (phi_a2 & (phi_a2 ^ D_80162D98)) | temp_v1;
temp_v1 = D_800DC4D4->buttonDepressed & 0x1F0F;
D_800DC4D4->buttonDepressed = (D_80162D98 & (phi_a2 ^ D_80162D98)) | temp_v1;
D_80162D98 = phi_a2;
D_800DC4D4->button = phi_a2;
if (D_80162D9C == 0) {
D_80162DA0++;
D_80162D9C = (s32) (D_80162DA4[D_80162DA0] & 0xFF0000);
} else {
D_80162D9C += (s32) 0xFFFF0000;
}
}
void func_800057DC(void) {
u32 temp_a0;
u32 temp_v0;
UNUSED u16 unk;
u16 temp_v1;
s16 phi_v1;
s16 phi_a2 = 0;
if (D_80162D90 >= 0x1000) {
func_80005AE8(D_800DC4E0);
return;
}
temp_a0 = D_80162D94[D_80162D90];
temp_v0 = temp_a0 & 0xFF;
if (temp_v0 < 0x80U) {
phi_v1 = (s16) (temp_v0 & 0xFF);
} else {
phi_v1 = (s16) (temp_v0 | ~0xFF);
}
temp_v0 = (u32) (temp_a0 & 0xFF00) >> 8;
D_800DC4D0->rawStickX = phi_v1;
if (temp_v0 < 0x80U) {
phi_v1 = (s16) (temp_v0 & 0xFF);
} else {
phi_v1 = (s16) (temp_v0 | (~0xFF));
}
D_800DC4D0->rawStickY = phi_v1;
if (temp_a0 & 0x80000000) {
phi_a2 |= A_BUTTON;
}
if (temp_a0 & 0x40000000) {
phi_a2 |= B_BUTTON;
}
if (temp_a0 & 0x20000000) {
phi_a2 |= Z_TRIG;
}
if (temp_a0 & 0x10000000) {
phi_a2 |= R_TRIG;
}
temp_v1 = D_800DC4D0->buttonPressed & 0x1F0F;
D_800DC4D0->buttonPressed = (phi_a2 & (phi_a2 ^ D_80162D88)) | temp_v1;
temp_v1 = D_800DC4D0->buttonDepressed & 0x1F0F;
D_800DC4D0->buttonDepressed = (D_80162D88 & (phi_a2 ^ D_80162D88)) | temp_v1;
D_80162D88 = phi_a2;
D_800DC4D0->button = phi_a2;
if (D_80162D8C == 0) {
D_80162D90++;
D_80162D8C = (s32) (D_80162D94[D_80162D90] & 0xFF0000);
} else {
D_80162D8C += (s32) 0xFFFF0000;
}
}
/*
void func_8000599C(void) {
s16 temp_a2;
u32 temp_v0;
u32 temp_v1;
u32 temp_v2;
u32 *temp_t0;
u32 temp_a0_2;
u32 temp_a3;
u32 phi_a3;
if (D_80162DB8 >= 0x1000) {
D_80162DF8 = 1;
return;
}
temp_v1 &= 0xff;
temp_v2 &= 0xff << 8;
//temp_v1 = D_800DC4DC->unk_0CA;
//if (((temp_v1 & 2) != 0) || ((temp_v1 & 8) != 0)) {
//}
temp_a2 = D_800DC4BC->button;
phi_a3 = 0;
if (temp_a2 & A_BUTTON) {
phi_a3 |= 0x80000000;
}
if (temp_a2 & B_BUTTON) {
phi_a3 |= 0x40000000;
}
if (temp_a2 & Z_TRIG) {
phi_a3 |= 0x20000000;
}
if (temp_a2 & R_TRIG) {
phi_a3 |= 0x10000000;
}
phi_a3 |= temp_v1;
phi_a3 |= temp_v2;
temp_v0 = (D_800DC4BC->rawStickY & 0xFF) << 8;
temp_a3 = phi_a3 | (D_800DC4BC->rawStickX & 0xFF) | temp_v0;
temp_a0_2 = &D_80162DBC[D_80162DB8];;
if (*D_80162DBC == -1) {
*temp_t0 = temp_a3;
} else {
if ((temp_a0_2 & 0xFF00FFFF) == temp_a3) {
if ((temp_a0_2 & 0xFF0000) == 0xFF0000) {
D_80162DB8++;
D_80162DBC[D_80162DB8] = temp_a3;
} else {
*temp_t0 += 0x10000;
}
} else {
D_80162DB8++;
D_80162DBC[D_80162DB8] = temp_a3;
}
}
}
*/
GLOBAL_ASM("asm/non_matchings/code_80004EF0/func_8000599C.s")
// sets player to AI? (unconfirmed)
void func_80005AE8(Player *ply) {
if (((ply->unk_000 & 0x100) != 0) && (ply != D_800DC4DC)) {
ply->unk_000 = 0x3800U;
}
}
#ifdef NON_MATCHING
void func_80005B18(void) {
s16 *temp_v0_2;
s16 *temp_v0_3;
s32 temp_v0;
u16 *phi_a3;
if (gModeSelection == 1) {
temp_v0 = lapCount[0];
//phi_a3 = &D_80162DD4;
if ((lapCount[0] == 3) && (D_80162DDC == 0) && D_80162DF8 != 1) {
//if (D_80162DF8 != 1) {
if (D_80162DD4 == 1) {
D_80162DD0 = D_80162DCC;
func_800052A4(); //gModeSelection, &D_80162DDC, 3, &D_80162DD4);
D_80162DD4 = 0;
D_80162DDC = 1;
D_80162DE0 = D_800DC4DC->unk_254;
D_80162DE8 = D_800DC4DC->unk_254;
D_80162E00 = 0;
D_80162DFC = D_8018CA78;
func_80005AE8(D_800DC4E0); // (u16) &D_80162DDC);
func_80005AE8(D_800DC4E4);
} else {
if (lapCount[4] != 3) {
D_80162DD0 = D_80162DCC;
func_800052A4(); // gModeSelection, &D_80162DDC, 3, &D_80162DD4);
D_80162DDC = 1;
D_80162DE0 = D_800DC4DC->unk_254;
D_80162DFC = D_8018CA78;
D_80162E00 = 0;
D_80162DE8 = D_800DC4DC->unk_254;
func_80005AE8(D_800DC4E0); // (u16) &D_80162DDC);
func_80005AE8(D_800DC4E4);
return;
}
}
D_80162D80 = (void *) ((D_80162DC8 << 0xF) + 0x3000 + &D_802BFB80);
D_80162D84 = D_80162D86;
D_80162DD0 = D_80162DCC;
D_80162DE8 = D_800DC4DC->unk_254;
D_80162DD8 = 0;
D_80162DD4 = 0;
D_80162DDC = 1;
func_80005AE8(D_800DC4E0); // (u16) &D_80162DDC, 3, &D_80162DD4);
func_80005AE8(D_800DC4E4);
return;
}
if ((lapCount[0] == 3) && (D_80162DDC == 0) && (D_80162DF8 == 1)) {
D_80162D80 = (void *) ((D_80162DC8 << 0xF) + 0x3000 + &D_802BFB80);
D_80162D84 = D_80162D86;
D_80162DDC = 1;
}
if (( D_800DC4DC->unk_000 & 0x800) == 0x800) {
func_80005AE8(D_800DC4E0); // (u16) &D_80162DDC, 3, phi_a3);
func_80005AE8(D_800DC4E4);
return;
};
D_80162DEC++;
if (D_80162DEC > 100) {
D_80162DEC = 100;
}
if ((gModeSelection == 1) && (D_800DC52C == 0)) {
if ((D_80162DD4 == 0) && (lapCount[4] != 3)) {
func_800057DC(); //gModeSelection, &D_80162DDC, 3, &D_80162DD4);
}
if ((D_80162DD6 == 0) && (3 != lapCount[8])) {
func_8000561C();
}
if (( D_800DC4DC->unk_000 & 0x800) == 0) {
func_8000599C();
}
}
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80004EF0/func_80005B18.s")
#endif
void func_80005E6C(void) {
if ((gModeSelection == 1) && (gModeSelection == 1) && (D_800DC52C == 0)) {
if ((D_80162DD8 == 0) && (D_80164394 != 3)) {
func_800057DC(); //3
}
if ((D_80162DD6 == 0) && (D_80164398 != 3)) {
func_8000561C(); //2
}
if ((D_800DC4DC->unk_000 & 0x800) != 0x800) {
func_8000546C(); //1
return;
}
func_80005AE8(D_800DC4E0);
func_80005AE8(D_800DC4E4);
}
}
void func_80005F44(void) {
if (D_8015F890 == 1) {
func_80005E6C();
return;
}
if (D_80162DF0 == 0) {
func_80005B18();
return;
}
D_80162DF8 = 1;
}