merged from master

This commit is contained in:
chandler
2020-04-07 18:00:34 -04:00
8 changed files with 215 additions and 774 deletions
+10 -22
View File
@@ -1,5 +1,6 @@
#include <ultra64.h>
#include <global.h>
#include <PR/os_cont.h>
u16 D_8011E1C0 = 0;
u16 D_8011E1C4 = 0;
@@ -95,19 +96,17 @@ void func_80064558(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
}
#ifdef NON_MATCHING
// minor ordering and regalloc differences
void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
CutsceneStateHandler handler;
Input* pad1 = &globalCtx->state.input[0];
if (!~(globalCtx->state.input[0].padPressed | -0x201) && (csCtx->state == CS_STATE_IDLE) &&
if (!~(pad1->padPressed | ~L_JPAD) && (csCtx->state == CS_STATE_IDLE) &&
(gSaveContext.scene_setup_index >= 4)) {
D_8015FCC8 = 0;
gSaveContext.cutscene_index = 0xFFFD;
gSaveContext.cutscene_trigger = 1;
}
if (!~(globalCtx->state.input[0].padPressed | -0x801) && (csCtx->state == CS_STATE_IDLE) &&
if (!~(pad1->padPressed | ~U_JPAD) && (csCtx->state == CS_STATE_IDLE) &&
(gSaveContext.scene_setup_index >= 4) && (D_8011D394 == 0)) {
D_8015FCC8 = 1;
gSaveContext.cutscene_index = 0xFFFD;
@@ -127,13 +126,9 @@ void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
if (gSaveContext.cutscene_index >= 0xFFF0) {
func_80068ECC(globalCtx, csCtx);
handler = sCsStateHandlers2[csCtx->state];
handler(globalCtx, csCtx);
sCsStateHandlers2[csCtx->state](globalCtx, csCtx);
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800645A0.s")
#endif
void func_80064720(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
@@ -164,8 +159,6 @@ void func_800647C0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
// Command 3: Misc. Actions
#ifdef NON_MATCHING
// regalloc and minor ordering differences
void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
Player* player = PLAYER;
f32 temp;
@@ -195,6 +188,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
if (sp3F != 0) {
func_800F6D58(0xF, 0, 0);
func_800753C4(globalCtx, 3);
if (1) {}
D_8015FD70 = 1;
}
break;
@@ -320,7 +314,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
break;
case 25:
gSaveContext.day_time += 30;
if ((gSaveContext.day_time & 0xFFFF) > 0xCAAA) {
if ((gSaveContext.day_time) > 0xCAAA) {
gSaveContext.day_time = 0xCAAA;
}
break;
@@ -384,9 +378,6 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
break;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_80064824.s")
#endif
// Command 4: Set Environment Lighting
void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) {
@@ -433,8 +424,6 @@ void Cutscene_Command_09(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmd
}
// Command 0x8C: Set Time of Day & Environment Time
#ifdef NON_MATCHING
// regalloc differences
void func_80065134(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) {
s16 temp1;
s16 temp2;
@@ -442,12 +431,11 @@ void func_80065134(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTim
if (csCtx->frames == cmd->startFrame) {
temp1 = (cmd->hour * 60.0f) / 0.021972656f;
temp2 = (cmd->minute + 1) / 0.021972656f;
gSaveContext.environment_time = gSaveContext.day_time = temp1 + temp2;
gSaveContext.day_time = temp1 + temp2;
gSaveContext.environment_time = temp1 + temp2;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_80065134.s")
#endif
// Command 0x3E8: Code Execution (& Terminates Cutscene?)
void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
@@ -1,3 +1,9 @@
/*
* File: z_bg_hidan_firewall.c
* Overlay: ovl_Bg_Hidan_Firewall
* Description: Proximity Flame Wall
*/
#include "z_bg_hidan_firewall.h"
#define ROOM 0x00
@@ -5,9 +11,17 @@
void BgHidanFirewall_Init(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Destroy(BgHidanFirewall* this, GlobalContext* globalCtx);
s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Update(BgHidanFirewall* this, GlobalContext* globalCtx);
void BgHidanFirewall_Draw(BgHidanFirewall* this, GlobalContext* globalCtx);
extern Gfx D_0600DA80[];
/*
const ActorInit Bg_Hidan_Firewall_InitVars = {
ACTOR_BG_HIDAN_FIREWALL,
ACTORTYPE_BG,
@@ -20,23 +34,194 @@ const ActorInit Bg_Hidan_Firewall_InitVars = {
(ActorFunc)BgHidanFirewall_Update,
NULL,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/BgHidanFirewall_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/BgHidanFirewall_Destroy.s")
static ColliderCylinderInit cylinderInitData = {
0x0A, 0x11, 0x00, 0x09,
0x20, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x20000000,
0x01, 0x04, 0x00, 0x00,
0xFFCFFFFF,
0x00, 0x00, 0x00, 0x00,
0x19, 0x00, 0x01, 0x00,
0x001E, 0x0053,
0x0000,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_80886728.s")
static Sub98Init4 actor98InitData = {
0x01, 0x0050, 0x0064, 0xFF,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_80886794.s")
UNK_PTR D_80886D04[] = {
0x06015D20,
0x06016120,
0x06016520,
0x06016920,
0x06016D20,
0x06017120,
0x06017520,
0x06017920,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_808867DC.s")
void BgHidanFirewall_Init(BgHidanFirewall* this, GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_80886810.s")
f32 scale;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_80886898.s")
scale = 0.12f;
this->actor.scale.x = scale;
this->actor.scale.z = scale;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_808868FC.s")
scale = 0.01f;
this->actor.scale.y = 0.01f;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/BgHidanFirewall_Update.s")
this->unk_150 = 0;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Firewall/func_80886B34.s")
ActorCollider_AllocCylinder(globalCtx, &this->collider);
ActorCollider_InitCylinder(globalCtx, &this->collider, &this->actor, &cylinderInitData);
this->collider.dim.position.y = this->actor.posRot.pos.y;
func_80061ED4(&this->actor.sub_98, NULL, &actor98InitData);
this->actionFunc = (ActorFunc)BgHidanFirewall_Wait;
}
void BgHidanFirewall_Destroy(BgHidanFirewall* this, GlobalContext* globalCtx) {
BgHidanFirewall* thing = this;
ActorCollider_FreeCylinder(globalCtx, &this->collider);
}
s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx) {
Player* player;
Vec3f distance;
player = PLAYER;
func_8002DBD0(&this->actor, &distance, &player->actor.posRot.pos);
if (fabsf(distance.x) < 100.0f && fabsf(distance.z) < 120.0f) {
return 1;
}
return 0;
}
void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx) {
if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) {
this->actor.draw = BgHidanFirewall_Draw;
this->actor.params = 5;
this->actionFunc = (ActorFunc)BgHidanFirewall_Countdown;
}
}
void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx) {
if (this->actor.params != 0) {
this->actor.params--;
}
if (this->actor.params == 0) {
this->actionFunc = (ActorFunc)BgHidanFirewall_Erupt;
}
}
void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx) {
if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) {
Math_ApproxF(&this->actor.scale.y, 0.1f, 0.01f/0.4f);
} else {
if (Math_ApproxF(&this->actor.scale.y, 0.01f, 0.01f) != 0) {
this->actor.draw = NULL;
this->actionFunc = (ActorFunc)BgHidanFirewall_Wait;
} else {
this->actor.params = 0;
}
}
}
void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx) {
s16 phi_a3;
if (func_8002E084(&this->actor, 0x4000) != 0) {
phi_a3 = this->actor.shape.rot.y;
} else {
phi_a3 = this->actor.shape.rot.y + 0x8000;
}
func_8002F71C(globalCtx, &this->actor, 5.0f, phi_a3, 1.0f);
}
void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx) {
Player* player;
Vec3f sp30;
f32 temp_ret;
f32 sp28;
f32 phi_f0;
player = PLAYER;
func_8002DBD0(&this->actor, &sp30, &player->actor.posRot.pos);
if (sp30.x < -70.0f) {
sp30.x = -70.0f;
} else {
if (70.0f < sp30.x) {
phi_f0 = 70.0f;
} else {
phi_f0 = sp30.x;
}
sp30.x = phi_f0;
}
if (this->actor.params == 0) {
if (0.0f < sp30.z) {
sp30.z = -25.0f;
this->actor.params = -1;
} else {
sp30.z = 25.0f;
this->actor.params = 1;
}
} else {
sp30.z = this->actor.params * 25.0f;
}
sp28 = Math_Sins(this->actor.shape.rot.y);
temp_ret = Math_Coss(this->actor.shape.rot.y);
this->collider.dim.position.x = this->actor.posRot.pos.x + sp30.x * temp_ret + sp30.z * sp28;
this->collider.dim.position.z = this->actor.posRot.pos.z - sp30.x * sp28 + sp30.z * temp_ret;
}
void BgHidanFirewall_Update(BgHidanFirewall* this, GlobalContext* globalCtx) {
s32 pad1;
s32 pad2;
this->unk_150 = (this->unk_150 + 1) % 8;
if (this->collider.base.colliderFlags & 2) {
this->collider.base.colliderFlags &= ~2;
BgHidanFirewall_Collide(this, globalCtx);
}
this->actionFunc(this, globalCtx);
if (this->actionFunc == (ActorFunc)BgHidanFirewall_Erupt) {
BgHidanFirewall_ColliderFollowPlayer(this, globalCtx);
Actor_CollisionCheck_SetAT(globalCtx, &globalCtx->sub_11E60, &this->collider);
Actor_CollisionCheck_SetOT(globalCtx, &globalCtx->sub_11E60, &this->collider);
func_8002F974(&this->actor, 0x2034);
}
}
void BgHidanFirewall_Draw(BgHidanFirewall* this, GlobalContext* globalCtx) {
UNK_PTR* temp;
u32 pad;
GraphicsContext* gfxCtx;
Gfx* dispRefs[3];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 448);
gfxCtx->polyXlu.p = Gfx_CallSetupDL(gfxCtx->polyXlu.p, 0x14);
temp = D_80886D04;
gSPSegment(gfxCtx->polyXlu.p++, 0x08, SEGMENTED_TO_VIRTUAL(temp[this->unk_150]));
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0x01, 0xFF, 0xFF, 0x00, 0x96);
gDPSetEnvColor(gfxCtx->polyXlu.p++, 0xFF, 0x00, 0x00, 0xFF);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 458),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyXlu.p++, D_0600DA80);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_hidan_firewall.c", 463);
}
@@ -5,10 +5,10 @@
#include <global.h>
typedef struct {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x54];
/* 0x0000 */ Actor actor;
/* 0x014C */ ActorFunc actionFunc;
/* 0x0150 */ s16 unk_150;
/* 0x0154 */ ColliderCylinderMain collider;
} BgHidanFirewall; // size = 0x01A0
extern const ActorInit Bg_Hidan_Firewall_InitVars;
#endif