1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-07 14:50:15 +00:00

Decompiles z_en_wonder_talk.c (#309)

* Decompiles z_en_wonder_talk.c

	* EnWonderTalk_Init
	* EnWonderTalk_Update
	* func_80B395F0
	* func_80B391CC
	* func_80B3943C

Removes unused asm's

* Addresses PR comments

* Uses VT macros in z_en_wonder_talk

* Adds translations to stdout messages in comments

* Addresses additional PR comments

* Addresses PR comments #3

Co-authored-by: i82orbom <i82orbom@github>
Co-authored-by: i82orbom <i82orbom i82orbom@github>
This commit is contained in:
i82orbom 2020-08-19 00:27:03 +02:00 committed by GitHub
parent 7a9c51375b
commit c76bd0d2e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 240 additions and 772 deletions

View file

@ -5,6 +5,7 @@
*/
#include "z_en_wonder_talk.h"
#include <vt.h>
#define FLAGS 0x08000009
@ -14,7 +15,10 @@ void EnWonderTalk_Init(Actor* thisx, GlobalContext* globalCtx);
void EnWonderTalk_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnWonderTalk_Update(Actor* thisx, GlobalContext* globalCtx);
/*
void func_80B391CC(EnWonderTalk* this, GlobalContext* globalCtx);
void func_80B395F0(EnWonderTalk* this, GlobalContext* globalCtx);
void func_80B3943C(EnWonderTalk* this, GlobalContext* globalCtx);
const ActorInit En_Wonder_Talk_InitVars = {
ACTOR_EN_WONDER_TALK,
ACTORTYPE_PROP,
@ -26,15 +30,230 @@ const ActorInit En_Wonder_Talk_InitVars = {
(ActorFunc)EnWonderTalk_Update,
NULL,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/EnWonderTalk_Destroy.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/EnWonderTalk_Init.s")
void EnWonderTalk_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/func_80B391CC.s")
void EnWonderTalk_Init(Actor* thisx, GlobalContext* globalCtx) {
EnWonderTalk* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/func_80B3943C.s")
osSyncPrintf("\n\n");
// Special conversation
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 特殊会話くん ☆☆☆☆☆ %x\n" VT_RST, this->actor.params);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/func_80B395F0.s")
this->unk_150 = (this->actor.params >> 0xB) & 0x1F;
this->unk_152 = (this->actor.params >> 6) & 0x1F;
this->switchFlag = this->actor.params & 0x3F;
if (this->switchFlag == 0x3F) {
this->switchFlag = -1;
}
this->actor.unk_1F = 1;
if (this->switchFlag >= 0) {
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag);
Actor_Kill(&this->actor);
return;
}
}
this->actionFunc = func_80B391CC;
this->unk_15C = 40.0f;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Wonder_Talk/EnWonderTalk_Update.s")
void func_80B391CC(EnWonderTalk* this, GlobalContext* globalCtx) {
if (this->switchFlag < 0 || !Flags_GetSwitch(globalCtx, this->switchFlag)) {
switch (this->unk_150) {
case 1:
// Slate GO!
osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 石板GO! ☆☆☆☆☆ \n" VT_RST);
this->height = 0.0f;
this->unk_15C = 80.0f;
// Attention coordinates
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f);
if (LINK_IS_CHILD) {
this->actor.textId = 0x7040;
// Children
osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ こども ☆☆☆☆☆ \n" VT_RST);
} else {
// Adult
osSyncPrintf(VT_FGCOL(CYAN) " ☆☆☆☆☆ おとな ☆☆☆☆☆ \n" VT_RST);
this->actor.textId = 0x7088;
}
this->unk_156 = 5;
osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ this->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, this->actor.textId);
break;
case 2:
// Diary start!
osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ 日記帳スタート! ☆☆☆☆☆ \n" VT_RST);
this->actor.textId = 0x5002;
this->unk_156 = 4;
this->height = 30.0f;
this->unk_15C = 40.0f;
// Attention coordinates
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 30.0f);
break;
case 3:
this->actor.textId = 0x501E;
this->unk_156 = 5;
this->height = 0.0f;
this->unk_15C = 110.0f;
// Attention coordinates
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f);
break;
case 4:
this->actor.textId = 0x5020;
this->unk_156 = 6;
this->height = 0.0f;
// Attention coordinates
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f);
this->unk_15C = 120.0f;
if (gSaveContext.eventChkInf[1] & 0x2000) {
Actor_Kill(&this->actor);
}
break;
case 5:
this->actor.textId = 0x501F;
this->unk_156 = 5;
this->height = 0.0f;
this->unk_15C = 110.0f;
// Attention coordinates
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 注目座標\t \t☆☆☆☆☆ %f\n" VT_RST, 0.0f);
break;
default:
this->actor.textId = 0x7072;
this->unk_156 = 5;
break;
}
osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ this->actor.talk_message ☆☆☆☆☆ %x\n" VT_RST, this->actor.textId);
this->actionFunc = func_80B3943C;
}
}
void func_80B3943C(EnWonderTalk* this, GlobalContext* globalCtx) {
s16 yawDiff;
s16 yawDiffTemp;
this->unk_15A++;
if (this->unk_150 == 4 && (gSaveContext.eventChkInf[1] & 0x2000)) {
Actor_Kill(&this->actor);
return;
}
if (this->switchFlag < 0 || !Flags_GetSwitch(globalCtx, this->switchFlag)) {
if ((func_8002F194(&this->actor, globalCtx))) {
if (this->unk_156 != 6) {
this->actionFunc = func_80B395F0;
} else {
if (this->switchFlag >= 0) {
this->actor.flags &= ~1;
Flags_SetSwitch(globalCtx, this->switchFlag);
}
this->actionFunc = func_80B391CC;
}
} else if (!(this->unk_15C < this->actor.xzDistFromLink)) {
yawDiffTemp = (this->actor.yawTowardsLink - this->actor.posRot.rot.y);
yawDiff = ABS(yawDiffTemp);
if (yawDiff < 0x4000) {
if (this->unk_15A >= 2) {
osSyncPrintf("\n\n");
// Save information
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ セーブ情報\t\t☆☆☆☆☆ %d\n" VT_RST, this->switchFlag);
// Type index
osSyncPrintf(VT_FGCOL(PURPLE) "☆☆☆☆☆ 種類インデックス\t☆☆☆☆☆ %d\n" VT_RST, this->unk_150);
// Actual message type
osSyncPrintf(VT_FGCOL(CYAN) "☆☆☆☆☆ 実質メッセージ種類 %x\n" VT_RST, this->actor.textId);
// Specified range
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 指定範囲 %d\n" VT_RST, this->actor.posRot.rot.z);
osSyncPrintf("\n\n");
}
this->unk_15A = 0;
func_8002F2CC(&this->actor, globalCtx, this->unk_15C);
}
}
}
}
void func_80B395F0(EnWonderTalk* this, GlobalContext* globalCtx) {
if (this->unk_156 == func_8010BDBC(&globalCtx->msgCtx)) {
if (func_80106BC8(globalCtx)) {
if (this->switchFlag >= 0) {
this->actor.flags &= -2;
Flags_SetSwitch(globalCtx, this->switchFlag);
}
switch (this->unk_150) {
case 1:
func_80106CCC(globalCtx);
this->actionFunc = func_80B391CC;
break;
case 2:
switch (globalCtx->msgCtx.choiceIndex) {
case 0:
if (LINK_IS_CHILD) {
// I'm still a child!
osSyncPrintf(VT_FGCOL(GREEN) " ☆☆☆☆☆ まだコドモなの! ☆☆☆☆☆ \n" VT_RST);
this->actor.textId = 0x5001;
} else {
// I'm an adult. .. ..
osSyncPrintf(VT_FGCOL(YELLOW) " ☆☆☆☆☆ アダルトなの。。。 ☆☆☆☆☆ \n" VT_RST);
this->actor.textId = 0x5003;
}
break;
case 1:
// Out!
osSyncPrintf(VT_FGCOL(PURPLE) " ☆☆☆☆☆ はずれ! ☆☆☆☆☆ \n" VT_RST);
this->actor.textId = 0x5004;
break;
}
this->unk_156 = 6;
func_8010B720(globalCtx, this->actor.textId);
this->actionFunc = func_80B391CC;
break;
case 3:
func_80106CCC(globalCtx);
if (this->unk_164 == 0) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->actor.posRot.pos.x,
this->actor.posRot.pos.y, this->actor.posRot.pos.z, 0, 0, 0, 2);
this->unk_164 = 1;
}
this->actionFunc = func_80B391CC;
break;
case 5:
func_80106CCC(globalCtx);
if (this->unk_164 == 0) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->actor.posRot.pos.x,
this->actor.posRot.pos.y, this->actor.posRot.pos.z, 0, 0, 0, 3);
this->unk_164 = 1;
}
this->actionFunc = func_80B391CC;
break;
}
}
}
}
void EnWonderTalk_Update(Actor* thisx, GlobalContext* globalCtx) {
EnWonderTalk* this = THIS;
if (this->unk_158 != 0) {
this->unk_158--;
}
this->actionFunc(this, globalCtx);
Actor_SetHeight(&this->actor, this->height);
if (BREG(0) != 0) {
if (this->unk_15A != 0) {
if ((this->unk_15A & 1) == 0) {
DebugDisplay_AddObject(this->actor.posRot.pos.x, this->actor.posRot.pos.y, this->actor.posRot.pos.z,
this->actor.posRot.rot.x, this->actor.posRot.rot.y, this->actor.posRot.rot.z,
1.0f, 1.0f, 1.0f, 10, 10, 10, 255, 4, globalCtx->state.gfxCtx);
}
} else {
DebugDisplay_AddObject(this->actor.posRot.pos.x, this->actor.posRot.pos.y, this->actor.posRot.pos.z,
this->actor.posRot.rot.x, this->actor.posRot.rot.y, this->actor.posRot.rot.z, 1.0f,
1.0f, 1.0f, 0, 255, 0, 255, 4, globalCtx->state.gfxCtx);
}
}
}

View file

@ -6,9 +6,20 @@
struct EnWonderTalk;
typedef void (*EnWonderTalkFunc)(struct EnWonderTalk*, GlobalContext*);
typedef struct EnWonderTalk {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x1C];
/* 0x014C */ EnWonderTalkFunc actionFunc;
/* 0x0150 */ s16 unk_150;
/* 0x0152 */ s16 unk_152;
/* 0x0154 */ s16 switchFlag;
/* 0x0156 */ s16 unk_156;
/* 0x0158 */ s16 unk_158;
/* 0x0160 */ s16 unk_15A;
/* 0x015C */ f32 unk_15C;
/* 0x0160 */ f32 height;
/* 0x0164 */ u8 unk_164;
} EnWonderTalk; // size = 0x0168
extern const ActorInit En_Wonder_Talk_InitVars;