Create dead.h and update dead code units (#394)

* create dead.h and resolve #350

* Update variables.h

* Update dead.h
This commit is contained in:
Alexander Faßbender 2021-08-25 21:29:59 +02:00 committed by GitHub
parent 3627d909fc
commit 4bdb7280a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 124 additions and 62 deletions

22
include/dead.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef _DEAD_H_
#define _DEAD_H_
#define gCameras dead_gCameras
#define get_variable dead_get_variable
#define set_variable dead_set_variable
#define get_float_variable dead_get_float_variable
#define cos_rad dead_cos_rad
#define set_float_variable dead_set_float_variable
#define playFX_11 dead_playFX_11
#define gPlayerStatusPtr dead_gPlayerStatusPtr
#define set_main_pan_u dead_set_main_pan_u
#define set_main_pan_v dead_set_main_pan_v
#define set_aux_pan_u dead_set_aux_pan_u
#define set_aux_pan_v dead_set_aux_pan_v
#define get_npc_unsafe dead_get_npc_unsafe
#define atan2 dead_atan2
#define clamp_angle dead_clamp_angle
#define rand_int dead_rand_int
#define gItemTable dead_gItemTable
#endif

View File

@ -630,7 +630,6 @@ enum Cams {
};
#define LOOKUP_ITEM(itemID) gItemTable[itemID & ~0xF0000]
#define DEAD_LOOKUP_ITEM(itemID) dead_gItemTable[itemID & ~0xF0000] // Dead gItemTable
typedef s16 ItemID;
enum ItemIDs {

View File

@ -418,22 +418,10 @@ void set_curtain_fade_goal(f32 fade);
void set_curtain_fade(f32 fade);
// Dead functions:
Npc* dead_get_npc_unsafe(NpcID npcId); // get_npc_safe
Npc* func_8003E534(NpcID npcId); // get_npc_safe
void func_80077BD0(s32, s32, s32, s32, s32, s32);
void dead_playFX_11(s32, f32, f32, f32, f32);
s32 dead_get_variable(Evt* script, Bytecode var);
f32 dead_get_float_variable(Evt* script, Bytecode var);
s32 dead_set_variable(Evt* script, Bytecode var, s32 value);
f32 dead_set_float_variable(Evt* script, Bytecode var, f32 value);
f32 dead_clamp_angle(f32 theta);
s32 dead_rand_int(s32);
void func_8006CAC0(float mf[4][4], float x, float y, float z);
f32 dead_cos_rad(f32 x);
f32 dead_atan2(f32 startX, f32 startZ, f32 endX, f32 endZ);
s32 create_generic_entity_world(void (*updateFunc)(void), void (*drawFunc)(void));
EntityModel* get_entity_model(s32 idx);
f32 phys_get_spin_history(s32 lag, s32* x, s32* y, s32* z);

View File

@ -393,11 +393,6 @@ extern s32 D_8038F800;
extern s32 D_803B5000;
extern s32 D_803DA800;
// Dead code
extern PlayerStatus* dead_gPlayerStatusPtr;
extern StaticItem dead_gItemTable[364];
extern Camera dead_gCameras[4];
extern s32 D_80108A64;
extern s32 bMarioIdleAnims[];
extern s32 bMarioDefendAnims[];

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EA0900

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EA0C10

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EA36E0", func_80242DE0_EA36E0);

View File

@ -1,7 +1,8 @@
#include "dead.h"
#include "common.h"
s32 func_80240000_EA6FD0(void) {
s32 temp = dead_get_variable(NULL, SI_STORY_PROGRESS);
s32 temp = get_variable(NULL, SI_STORY_PROGRESS);
if (temp <= 0x26) {
return 0x19010F;

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EA7010

View File

@ -1,9 +1,10 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EA7320
ApiStatus func_80240350_EA7320(Evt* script, s32 isInitialCall) {
Camera* camera = &dead_gCameras[0];
Camera* camera = &gCameras[0];
camera->flags |= 0x1000;
return ApiStatus_DONE2;

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EA8AE0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EB0E60

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EB1170

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EB5130

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EB5470", func_80240340_EB5470);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EB7230

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EB7540", func_80240310_EB7540);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
const char ascii_EC2000[] = "mac_01";

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EB8E90

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
static char* N(exit_str_0) = "flo_07";

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC2200

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC2240

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC2610

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC71B0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC7590

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EC9D00

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ECAA40

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ECAA80", func_80240D80_ECAA80);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ECB930

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ECBB70", func_80241E70_ECBB70);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ECFFF0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ED0030", func_80240040_ED0030);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ED00D0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ED0310

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ED4220", func_80240000_ED4220);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ED4260

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ED42A0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ED46D0", func_802404B0_ED46D0);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE ED5540

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "ED8E20", func_80240000_ED8E20);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EDBFE0", func_80240000_EDBFE0);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EDC020

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EDE9C0", func_80240000_EDE9C0);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EDEA00

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EE2040", func_80243680_EE2040);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EE65B0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EE70C0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EE8940", func_80242390_EE8940);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EED100

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EED140", func_80240040_EED140);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EED1E0

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EEDF50

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EEFAA0", func_802429A0_EEFAA0);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EF2610

View File

@ -1,8 +1,9 @@
#include "dead.h"
#include "common.h"
extern s16 D_80169B16;
ApiStatus func_80240040_EF2650(Evt* script, s32 isInitialCall) {
dead_set_variable(script, *script->ptrReadPos, D_80169B16);
set_variable(script, *script->ptrReadPos, D_80169B16);
return ApiStatus_DONE2;
}

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EF2680

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EF7A80

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
INCLUDE_ASM(s32, "EF7FB0", func_80240530_EF7FB0);

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EF8010

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#define NAMESPACE EFEB00

View File

@ -4,21 +4,21 @@
ApiStatus N(DeadUnkFloatFunc)(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 a1 = *args++;
s32 var0 = dead_get_variable(script, a1);
s32 var0 = get_variable(script, a1);
s32 a2 = *args++;
f32 var1 = dead_get_float_variable(script, *args++);
f32 var2 = dead_get_float_variable(script, *args++);
s32 var3 = dead_get_variable(script, *args++);
s32 var4 = dead_get_variable(script, *args++);
f32 temp = (dead_get_float_variable(script, *args++) / 180.0f) * PI;
f32 var1 = get_float_variable(script, *args++);
f32 var2 = get_float_variable(script, *args++);
s32 var3 = get_variable(script, *args++);
s32 var4 = get_variable(script, *args++);
f32 temp = (get_float_variable(script, *args++) / 180.0f) * PI;
f32 diff = (var2 - var1) / 2;
if (var4 != 0 && var3 < var0) {
var0 = var3;
dead_set_variable(script, a1, var3);
set_variable(script, a1, var3);
}
dead_set_float_variable(script, a2, (var1 + diff) - (diff * dead_cos_rad(((var0 * PI) / var3) + temp)));
set_float_variable(script, a2, (var1 + diff) - (diff * cos_rad(((var0 * PI) / var3) + temp)));
return ApiStatus_DONE2;
}

View File

@ -5,21 +5,21 @@
ApiStatus N(DeadUnkFloatFuncAbs)(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 a1 = *args++;
s32 var0 = dead_get_variable(script, a1);
s32 var0 = get_variable(script, a1);
s32 a2 = *args++;
f32 var1 = dead_get_float_variable(script, *args++);
f32 var2 = dead_get_float_variable(script, *args++);
s32 var3 = dead_get_variable(script, *args++);
s32 var4 = dead_get_variable(script, *args++);
f32 temp = (dead_get_float_variable(script, *args++) / 180.0f) * PI;
f32 var1 = get_float_variable(script, *args++);
f32 var2 = get_float_variable(script, *args++);
s32 var3 = get_variable(script, *args++);
s32 var4 = get_variable(script, *args++);
f32 temp = (get_float_variable(script, *args++) / 180.0f) * PI;
f32 diff = fabsf(var2 - var1) / 2;
if (var4 != 0 && var3 < var0) {
var0 = var3;
dead_set_variable(script, a1, var3);
set_variable(script, a1, var3);
}
dead_set_float_variable(script, a2, (var1 + diff) - (diff * dead_cos_rad(((var0 * PI) / var3) + temp)));
set_float_variable(script, a2, (var1 + diff) - (diff * cos_rad(((var0 * PI) / var3) + temp)));
return ApiStatus_DONE2;
}

View File

@ -1,7 +1,7 @@
#include "common.h"
#include "map.h"
void N(dead_foliage_setup_shear_mtx)(Matrix4f mtx, f32 scale, f32 xAmount, f32 zAmount) {
void N(foliage_setup_shear_mtx)(Matrix4f mtx, f32 scale, f32 xAmount, f32 zAmount) {
osGetCause(mtx);
mtx[1][0] = scale * xAmount;
mtx[1][1] = 1.0f;
@ -10,17 +10,17 @@ void N(dead_foliage_setup_shear_mtx)(Matrix4f mtx, f32 scale, f32 xAmount, f32 z
ApiStatus N(DeadTransformFoliage)(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 modelListIndex = func_80125270(dead_get_variable(script, *args++));
f32 scale = dead_get_float_variable(script, *args++);
f32 dx = dead_get_float_variable(script, *args++);
f32 dy = dead_get_float_variable(script, *args++);
f32 dz = dead_get_float_variable(script, *args++);
s32 modelListIndex = func_80125270(get_variable(script, *args++));
f32 scale = get_float_variable(script, *args++);
f32 dx = get_float_variable(script, *args++);
f32 dy = get_float_variable(script, *args++);
f32 dz = get_float_variable(script, *args++);
Model* model = func_80124F44(modelListIndex);
Matrix4f mtx;
if (!(model->flags & 0x400)) {
func_8006CAC0(model->transformMatrix, 0.0f, dy, 0.0f);
N(dead_foliage_setup_shear_mtx)(mtx, scale, dx, dz);
N(foliage_setup_shear_mtx)(mtx, scale, dx, dz);
osSiRawReadIo(mtx, model->transformMatrix, model->transformMatrix);
func_8006CAC0(mtx, 0.0f, -dy, 0.0f);
osSiRawReadIo(mtx, model->transformMatrix, model->transformMatrix);
@ -28,7 +28,7 @@ ApiStatus N(DeadTransformFoliage)(Evt* script, s32 isInitialCall) {
} else {
func_8006CAC0(mtx, 0.0f, dy, 0.0f);
osSiRawReadIo(mtx, model->transformMatrix, model->transformMatrix);
N(dead_foliage_setup_shear_mtx)(mtx, scale, dx, dz);
N(foliage_setup_shear_mtx)(mtx, scale, dx, dz);
osSiRawReadIo(mtx, model->transformMatrix, model->transformMatrix);
func_8006CAC0(mtx, 0.0f, -dy, 0.0f);
osSiRawReadIo(mtx, model->transformMatrix, model->transformMatrix);

View File

@ -3,8 +3,8 @@
ApiStatus N(DeadGetItemName)(Evt* script, s32 isInitialCall) {
Bytecode args = *script->ptrReadPos;
s32 itemID = dead_get_variable(script, args);
s32 itemID = get_variable(script, args);
dead_set_variable(script, args, DEAD_LOOKUP_ITEM(itemID).nameString);
set_variable(script, args, LOOKUP_ITEM(itemID).nameString);
return ApiStatus_DONE2;
}

View File

@ -3,10 +3,10 @@
void N(DeadUnkNpcAIFunc1)(Evt* script, NpcAISettings* aiSettings, EnemyTerritoryThing* territory) {
Enemy* enemy = script->owner1.enemy;
Npc* npc = dead_get_npc_unsafe(enemy->npcID);
Npc* npc = get_npc_unsafe(enemy->npcID);
npc->duration = (aiSettings->waitTime / 2) + dead_rand_int((aiSettings->waitTime / 2) + 1);
npc->yaw = dead_clamp_angle(npc->yaw + dead_rand_int(180) - 90.0f);
npc->duration = (aiSettings->waitTime / 2) + rand_int((aiSettings->waitTime / 2) + 1);
npc->yaw = clamp_angle(npc->yaw + rand_int(180) - 90.0f);
npc->currentAnim.w = *enemy->animList;
script->functionTemp[0] = 3;
}

View File

@ -3,7 +3,7 @@
void N(DeadUnkNpcAIFunc14)(Evt* script, NpcAISettings* aiSettings) {
Enemy* enemy = script->owner1.enemy;
Npc* npc = dead_get_npc_unsafe(enemy->npcID);
Npc* npc = get_npc_unsafe(enemy->npcID);
f32 vt5 = enemy->varTable[5];
f32 jumpVelocity = vt5 / 100.0;
f32 vt6 = enemy->varTable[6];
@ -13,7 +13,7 @@ void N(DeadUnkNpcAIFunc14)(Evt* script, NpcAISettings* aiSettings) {
npc->jumpVelocity = jumpVelocity;
npc->jumpScale = jumpScale;
npc->moveSpeed = aiSettings->chaseSpeed;
npc->yaw = dead_atan2(npc->pos.x, npc->pos.z, dead_gPlayerStatusPtr->position.x, dead_gPlayerStatusPtr->position.z);
npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->position.x, gPlayerStatusPtr->position.z);
enemy->varTable[2] = 0;

View File

@ -1,15 +1,16 @@
#include "common.h"
#include "effects.h"
ApiStatus N(DeadUnkPartnerPosFunc)(Evt* script, s32 isInitialCall) {
Npc* partner = func_8003E534(NPC_PARTNER);
dead_playFX_11(2, partner->pos.x, partner->pos.y + 30.0f, partner->pos.z, 30.0f);
playFX_11(2, partner->pos.x, partner->pos.y + 30.0f, partner->pos.z, 30.0f);
return ApiStatus_DONE2;
}
ApiStatus N(DeadUnkPartnerPosFunc2)(Evt* script, s32 isInitialCall) {
Npc* partner = func_8003E534(NPC_PARTNER);
dead_playFX_11(4, partner->pos.x, partner->pos.y + 30.0f, partner->pos.z, 30.0f);
playFX_11(4, partner->pos.x, partner->pos.y + 30.0f, partner->pos.z, 30.0f);
return ApiStatus_DONE2;
}

View File

@ -1,3 +1,4 @@
#include "dead.h"
#include "common.h"
#include "map.h"
@ -30,9 +31,9 @@ ApiStatus N(DeadUnkTexturePanFunc)(Evt* script, s32 isInitialCall) {
script->varTable[12] -= 0x20000;
}
dead_set_main_pan_u(script->varTable[0], script->varTable[9]);
dead_set_main_pan_v(script->varTable[0], script->varTable[10]);
dead_set_aux_pan_u(script->varTable[0], script->varTable[11]);
dead_set_aux_pan_v(script->varTable[0], script->varTable[12]);
set_main_pan_u(script->varTable[0], script->varTable[9]);
set_main_pan_v(script->varTable[0], script->varTable[10]);
set_aux_pan_u(script->varTable[0], script->varTable[11]);
set_aux_pan_v(script->varTable[0], script->varTable[12]);
return ApiStatus_BLOCK;
}

View File

@ -45,10 +45,10 @@ ApiStatus N(DeadUnkTexturePanFunc2)(Evt* script, s32 isInitialCall) {
}
}
dead_set_main_pan_u(script->varTable[0], script->varTable[9]);
dead_set_main_pan_v(script->varTable[0], script->varTable[10]);
dead_set_aux_pan_u(script->varTable[0], script->varTable[11]);
dead_set_aux_pan_v(script->varTable[0], script->varTable[12]);
set_main_pan_u(script->varTable[0], script->varTable[9]);
set_main_pan_v(script->varTable[0], script->varTable[10]);
set_aux_pan_u(script->varTable[0], script->varTable[11]);
set_aux_pan_v(script->varTable[0], script->varTable[12]);
script->functionTemp[0]++;
script->functionTemp[1]++;