diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index e01e72614ad..dd984bcc85a 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -31,12 +31,33 @@ struct TVec3 { } }; +inline void setTVec3f(const f32* vec_a, f32* vec_b) { + const register f32* v_a = vec_a; + register f32* v_b = vec_b; + + register f32 a_x; + register f32 b_x; + + asm { + psq_l a_x, 0(v_a), 0, 0 /* qr0 */ + lfs b_x, 8(v_a) + psq_st a_x, 0(v_b), 0, 0 /* qr0 */ + stfs b_x, 8(v_b) + }; +} + template <> struct TVec3 { f32 x; f32 y; f32 z; + /* TVec3(const Vec& i_vec) { + setTVec3f(&i_vec.x, &x); + } */ + + /* TVec3() {} */ + operator Vec*() { return (Vec*)&x; } operator const Vec*() const { return (Vec*)&x; } diff --git a/include/JSystem/JParticle/JPAParticle.h b/include/JSystem/JParticle/JPAParticle.h index 3448720ae0f..ed4fe9142a7 100644 --- a/include/JSystem/JParticle/JPAParticle.h +++ b/include/JSystem/JParticle/JPAParticle.h @@ -250,6 +250,13 @@ public: void setGlobalRTMatrix(const Mtx m) { JPASetRMtxTVecfromMtx(m, mGlobalRot, &mGlobalTrs); } void setGlobalTranslation(f32 x, f32 y, f32 z) { mGlobalTrs.set(x, y, z); } void setGlobalAlpha(u8 alpha) { mGlobalPrmClr.a = alpha; } + void setVolumeSize(u16 size) { mVolumeSize = size; } + void setLifeTime(s16 lifetime) { mLifeTime = lifetime; } + + void setGlobalParticleScale(const JGeometry::TVec3& scale) { + mGlobalPScl.set(scale.x, scale.y); + } + // void setGlobalScale(const JGeometry::TVec3& scale) { // mGlobalScl = scale; // mGlobalPScl = scale; diff --git a/include/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.h b/include/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.h index 2fde93b7be6..8ac6b3cf82f 100644 --- a/include/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.h +++ b/include/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.h @@ -1,6 +1,22 @@ #ifndef D_A_KYTAG10_H #define D_A_KYTAG10_H -#include "dolphin/types.h" +#include "f_op/f_op_actor_mng.h" + +struct dPath; + +class kytag10_class : public fopAc_ac_c { +public: + /* 0x568 */ dPath* mpPath; + /* 0x56C */ JPABaseEmitter* mpEmitter1; + /* 0x570 */ JPABaseEmitter* mpEmitter2; + /* 0x574 */ cXyz mEmitterPtclScale; + /* 0x580 */ s16 mEmitterVolSize; + /* 0x582 */ s16 mEmitterLifeTime; + /* 0x584 */ u8 field_0x584; + /* 0x588 */ cXyz field_0x588; + /* 0x594 */ f32 field_0x594; + /* 0x598 */ int mPathPoint; +}; #endif /* D_A_KYTAG10_H */ diff --git a/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.cpp b/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.cpp index dab2be8bace..a5a229cbf74 100644 --- a/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.cpp +++ b/rel/d/a/kytag/d_a_kytag10/d_a_kytag10.cpp @@ -1,43 +1,17 @@ -// -// Generated By: dol2asm -// Translation Unit: d_a_kytag10 -// +/** + * d_a_kytag10.cpp + * Sparks Particle Emitter on a Path + */ #include "rel/d/a/kytag/d_a_kytag10/d_a_kytag10.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JMath/JMath.h" +#include "SSystem/SComponent/c_math.h" +#include "d/com/d_com_inf_game.h" +#include "d/d_path.h" +#include "d/d_procname.h" +#include "d/kankyo/d_kankyo_rain.h" #include "dol2asm.h" -#include "dolphin/types.h" - -// -// Types: -// - -struct kytag10_class {}; - -struct fopAc_ac_c { - /* 80018B64 */ fopAc_ac_c(); -}; - -struct dPath {}; - -struct dPa_levelEcallBack {}; - -struct dKy_tevstr_c {}; - -struct csXyz {}; - -struct _GXColor {}; - -struct cXyz {}; - -struct dPa_control_c { - /* 8004CA90 */ void set(u8, u16, cXyz const*, dKy_tevstr_c const*, csXyz const*, cXyz const*, - u8, dPa_levelEcallBack*, s8, _GXColor const*, _GXColor const*, - cXyz const*, f32); -}; - -struct JPABaseEmitter { - /* 8027EC60 */ void deleteAllParticle(); -}; // // Forward References: @@ -53,7 +27,6 @@ extern "C" static void daKytag10_Execute__FP13kytag10_class(); extern "C" static bool daKytag10_IsDelete__FP13kytag10_class(); extern "C" static void daKytag10_Delete__FP13kytag10_class(); extern "C" static void daKytag10_Create__FP10fopAc_ac_c(); -extern "C" extern void* g_profile_KYTAG10[12]; // // External References: @@ -66,16 +39,10 @@ extern "C" void dPath_GetRoomPath__Fii(); extern "C" void dKyr_get_vectle_calc__FP4cXyzP4cXyzP4cXyz(); extern "C" void cM_atan2s__Fff(); extern "C" void deleteAllParticle__14JPABaseEmitterFv(); -extern "C" void PSVECSquareDistance(); extern "C" void _savegpr_27(); extern "C" void _savegpr_29(); extern "C" void _restgpr_27(); extern "C" void _restgpr_29(); -extern "C" extern void* g_fopAc_Method[8]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u8 g_env_light[4880]; -extern "C" extern u32 __float_nan; // // Declarations: @@ -93,49 +60,74 @@ COMPILER_STRIP_GATE(0x80529400, &lit_3788); /* 80528BF8-80528D0C 000078 0114+00 1/1 0/0 0/0 .text get_rail_ratio_pos__FP5dPathifPsPs */ +// matches with literals +#ifdef NONMATCHING +static cXyz get_rail_ratio_pos(dPath* i_path, int i_pointIdx, f32 param_2, s16* param_3, + s16* param_4) { + cXyz point_a; + cXyz point_b; + cXyz ret; + cXyz calc_vec; + + point_a.x = i_path->m_points[i_pointIdx].m_position.x; + point_a.y = i_path->m_points[i_pointIdx].m_position.y; + point_a.z = i_path->m_points[i_pointIdx].m_position.z; + + point_b.x = i_path->m_points[i_pointIdx + 1].m_position.x; + point_b.y = i_path->m_points[i_pointIdx + 1].m_position.y; + point_b.z = i_path->m_points[i_pointIdx + 1].m_position.z; + + ret.x = point_a.x + param_2 * (point_b.x - point_a.x); + ret.y = point_a.y + param_2 * (point_b.y - point_a.y); + ret.z = point_a.z + param_2 * (point_b.z - point_a.z); + + dKyr_get_vectle_calc(&point_a, &point_b, &calc_vec); + + *param_3 = + cM_atan2s(JMAFastSqrt(calc_vec.x * calc_vec.x + calc_vec.z * calc_vec.z), calc_vec.y); + *param_4 = cM_atan2s(calc_vec.x, calc_vec.z); + + return ret; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void get_rail_ratio_pos(dPath* param_0, int param_1, f32 param_2, s16* param_3, +static asm cXyz get_rail_ratio_pos(dPath* param_0, int param_1, f32 param_2, s16* param_3, s16* param_4) { nofralloc #include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/get_rail_ratio_pos__FP5dPathifPsPs.s" } #pragma pop +#endif /* 80528D0C-80528D54 00018C 0048+00 1/1 0/0 0/0 .text set_path_info__FP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void set_path_info(fopAc_ac_c* param_0) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/set_path_info__FP10fopAc_ac_c.s" +static dPath* set_path_info(fopAc_ac_c* i_actor) { + dPath* path_p = NULL; + u8 path_id = fopAcM_GetParam(i_actor) >> 0x10; + + if (path_id != 0xFF) { + path_p = dPath_GetRoomPath(path_id, fopAcM_GetRoomNo(i_actor)); + } + + return path_p; } -#pragma pop /* 80528D54-80528D64 0001D4 0010+00 1/1 0/0 0/0 .text * get_Extent_pos_start_get__FP13kytag10_classP5dPathP4cXyzfPi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void get_Extent_pos_start_get(kytag10_class* param_0, dPath* param_1, cXyz* param_2, - f32 param_3, int* param_4) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/get_Extent_pos_start_get__FP13kytag10_classP5dPathP4cXyzfPi.s" +static dPath* get_Extent_pos_start_get(kytag10_class* i_this, dPath* i_path, cXyz*, f32, + int* param_4) { + *param_4 = 0; + return i_path; } -#pragma pop /* 80528D64-80528D78 0001E4 0014+00 1/1 0/0 0/0 .text * get_Extent_pos_end_get__FP13kytag10_classP5dPathP4cXyzfPi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void get_Extent_pos_end_get(kytag10_class* param_0, dPath* param_1, cXyz* param_2, - f32 param_3, int* param_4) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/get_Extent_pos_end_get__FP13kytag10_classP5dPathP4cXyzfPi.s" +static dPath* get_Extent_pos_end_get(kytag10_class* param_0, dPath* i_path, cXyz*, f32, + int* param_4) { + *param_4 = i_path->m_num - 1; + return i_path; } -#pragma pop /* ############################################################################################## */ /* 80529404-80529408 000004 0004+00 0/1 0/0 0/0 .rodata @3950 */ @@ -218,6 +210,72 @@ COMPILER_STRIP_GATE(0x80529438, &lit_3959); #pragma pop /* 80528D78-80529148 0001F8 03D0+00 1/1 0/0 0/0 .text sparks_move__FP13kytag10_class */ +// TVec3 constructors need to be setup +#ifdef NONMATCHING +static void sparks_move(kytag10_class* i_this) { + camera_class* camera_p = dComIfGp_getCamera(0); + + cXyz ratio_pos_1; + cXyz ratio_pos_2; + cXyz ratio_pos_5; + cXyz ratio_pos_3; + cXyz ratio_pos_4; + + dPath* path_p = i_this->mpPath; + + if (path_p != NULL) { + int start_point_idx; + dPath* path_start = get_Extent_pos_start_get(i_this, path_p, &camera_p->mLookat.mEye, + 1000.0f, &start_point_idx); + + int end_point_idx; + dPath* path_end = get_Extent_pos_end_get(i_this, path_p, &camera_p->mLookat.mEye, 1000.0f, + &end_point_idx); + + s16 spD6; + s16 spD8; + ratio_pos_1 = get_rail_ratio_pos(path_start, 0, 0.0f, &spD6, &spD8); + ratio_pos_2 = get_rail_ratio_pos(path_end, end_point_idx - 1, 1.0f, &spD6, &spD8); + ratio_pos_3 = get_rail_ratio_pos(path_start, i_this->mPathPoint, 0.0f, &spD6, &spD8); + ratio_pos_4 = get_rail_ratio_pos(path_start, i_this->mPathPoint, 1.0f, &spD6, &spD8); + + f32 temp_f = 250.0f / ratio_pos_3.abs(ratio_pos_4); + + ratio_pos_5 = + get_rail_ratio_pos(path_start, i_this->mPathPoint, i_this->field_0x594, &spD6, &spD8); + i_this->field_0x588 = ratio_pos_5; + + i_this->mpEmitter1->setGlobalTranslation(ratio_pos_5.x, ratio_pos_5.y, ratio_pos_5.z); + i_this->mpEmitter2->setGlobalTranslation(ratio_pos_5.x, ratio_pos_5.y, ratio_pos_5.z); + + i_this->mpEmitter1->setVolumeSize(i_this->mEmitterVolSize); + i_this->mpEmitter1->setLifeTime(i_this->mEmitterLifeTime); + + i_this->mpEmitter2->setVolumeSize(i_this->mEmitterVolSize); + i_this->mpEmitter2->setLifeTime(i_this->mEmitterLifeTime); + + i_this->mpEmitter1->setGlobalParticleScale(i_this->mEmitterPtclScale); + i_this->mpEmitter2->setGlobalParticleScale(i_this->mEmitterPtclScale); + + if (i_this->field_0x584 != 0xFF) { + f32 rate = i_this->field_0x584 / 100.0f; + i_this->mpEmitter1->setRate(rate); + i_this->mpEmitter2->setRate(rate); + } + + if (i_this->field_0x594 <= 1.0f - (250.0f * temp_f)) { + i_this->field_0x594 += temp_f; + return; + } else if (i_this->mPathPoint >= end_point_idx - 1) { + i_this->mPathPoint = start_point_idx; + } else { + i_this->mPathPoint++; + } + + i_this->field_0x594 = 0.0f; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -226,38 +284,48 @@ static asm void sparks_move(kytag10_class* param_0) { #include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/sparks_move__FP13kytag10_class.s" } #pragma pop +#endif /* 80529148-80529150 0005C8 0008+00 1/0 0/0 0/0 .text daKytag10_Draw__FP13kytag10_class */ -static bool daKytag10_Draw(kytag10_class* param_0) { - return true; +static int daKytag10_Draw(kytag10_class* i_this) { + return 1; } /* 80529150-80529174 0005D0 0024+00 1/0 0/0 0/0 .text daKytag10_Execute__FP13kytag10_class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daKytag10_Execute(kytag10_class* param_0) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/daKytag10_Execute__FP13kytag10_class.s" +static int daKytag10_Execute(kytag10_class* i_this) { + sparks_move(i_this); + return 1; } -#pragma pop /* 80529174-8052917C 0005F4 0008+00 1/0 0/0 0/0 .text daKytag10_IsDelete__FP13kytag10_class */ -static bool daKytag10_IsDelete(kytag10_class* param_0) { - return true; +static int daKytag10_IsDelete(kytag10_class* i_this) { + return 1; } /* 8052917C-80529248 0005FC 00CC+00 1/0 0/0 0/0 .text daKytag10_Delete__FP13kytag10_class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daKytag10_Delete(kytag10_class* param_0) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/daKytag10_Delete__FP13kytag10_class.s" +static int daKytag10_Delete(kytag10_class* i_this) { + g_env_light.field_0xf21 = 0; + + if (i_this->mpEmitter1 != NULL) { + i_this->mpEmitter1->deleteAllParticle(); + i_this->mpEmitter1->becomeInvalidEmitter(); + i_this->mpEmitter1->quitImmortalEmitter(); + i_this->mpEmitter1->setEmitterCallBackPtr(NULL); + i_this->mpEmitter1 = NULL; + } + + if (i_this->mpEmitter2 != NULL) { + i_this->mpEmitter2->deleteAllParticle(); + i_this->mpEmitter2->becomeInvalidEmitter(); + i_this->mpEmitter2->quitImmortalEmitter(); + i_this->mpEmitter2->setEmitterCallBackPtr(NULL); + i_this->mpEmitter2 = NULL; + } + + return 1; } -#pragma pop /* ############################################################################################## */ /* 80529440-80529444 000040 0004+00 0/0 0/0 0/0 .rodata @3971 */ @@ -275,34 +343,82 @@ COMPILER_STRIP_GATE(0x80529444, &lit_4058); #pragma pop /* 80529248-805293F8 0006C8 01B0+00 1/0 0/0 0/0 .text daKytag10_Create__FP10fopAc_ac_c */ +// matches with literals +#ifdef NONMATCHING +static int daKytag10_Create(fopAc_ac_c* i_this) { + if (!fopAcM_CheckCondition(i_this, 8)) { + new (i_this) kytag10_class(); + fopAcM_OnCondition(i_this, 8); + } + + u8 prm0 = fopAcM_GetParam(i_this); + if (prm0 == 0xFF) { + prm0 = 10; + } + + ((kytag10_class*)i_this)->mEmitterPtclScale.z = prm0 * 0.1f; + ((kytag10_class*)i_this)->mEmitterPtclScale.y = prm0 * 0.1f; + ((kytag10_class*)i_this)->mEmitterPtclScale.x = prm0 * 0.1f; + + s16 prm1 = (fopAcM_GetParam(i_this) >> 8) & 0xFF; + if (prm1 == 0xFF) { + prm1 = 0; + } + + ((kytag10_class*)i_this)->mEmitterVolSize = prm1 * 10; + + s16 prm3 = (fopAcM_GetParam(i_this) >> 0x18) & 0xFF; + if (prm3 == 0xFF) { + prm3 = 15; + } + + ((kytag10_class*)i_this)->mEmitterLifeTime = prm3 * 10; + ((kytag10_class*)i_this)->field_0x584 = i_this->current.angle.x & 0xFF; + ((kytag10_class*)i_this)->mpEmitter1 = NULL; + ((kytag10_class*)i_this)->mpEmitter2 = NULL; + ((kytag10_class*)i_this)->field_0x594 = 0.0f; + ((kytag10_class*)i_this)->mPathPoint = 0; + ((kytag10_class*)i_this)->mpPath = set_path_info(i_this); + ((kytag10_class*)i_this)->mpEmitter1 = + dComIfGp_particle_set(0x852B, &i_this->current.pos, NULL, NULL); + ((kytag10_class*)i_this)->mpEmitter2 = + dComIfGp_particle_set(0x852C, &i_this->current.pos, NULL, NULL); + + return cPhs_COMPLEATE_e; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daKytag10_Create(fopAc_ac_c* param_0) { +static asm int daKytag10_Create(fopAc_ac_c* param_0) { nofralloc #include "asm/rel/d/a/kytag/d_a_kytag10/d_a_kytag10/daKytag10_Create__FP10fopAc_ac_c.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80529448-80529468 -00001 0020+00 1/0 0/0 0/0 .data l_daKytag10_Method */ -SECTION_DATA static void* l_daKytag10_Method[8] = { - (void*)daKytag10_Create__FP10fopAc_ac_c, - (void*)daKytag10_Delete__FP13kytag10_class, - (void*)daKytag10_Execute__FP13kytag10_class, - (void*)daKytag10_IsDelete__FP13kytag10_class, - (void*)daKytag10_Draw__FP13kytag10_class, - (void*)NULL, - (void*)NULL, - (void*)NULL, +static actor_method_class l_daKytag10_Method = { + (process_method_func)daKytag10_Create, (process_method_func)daKytag10_Delete, + (process_method_func)daKytag10_Execute, (process_method_func)daKytag10_IsDelete, + (process_method_func)daKytag10_Draw, }; /* 80529468-80529498 -00001 0030+00 0/0 0/0 1/0 .data g_profile_KYTAG10 */ -SECTION_DATA extern void* g_profile_KYTAG10[12] = { - (void*)0xFFFFFFFD, (void*)0x0007FFFD, - (void*)0x02B40000, (void*)&g_fpcLf_Method, - (void*)0x0000059C, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x00680000, (void*)&l_daKytag10_Method, - (void*)0x00044000, (void*)NULL, +extern actor_process_profile_definition g_profile_KYTAG10 = { + -3, + 7, + -3, + PROC_KYTAG10, + &g_fpcLf_Method.mBase, + sizeof(kytag10_class), + 0, + 0, + &g_fopAc_Method.base, + 104, + &l_daKytag10_Method, + 0x44000, + 0, + 0, }; diff --git a/rel/d/a/tag/d_a_tag_mstop/d_a_tag_mstop.cpp b/rel/d/a/tag/d_a_tag_mstop/d_a_tag_mstop.cpp index 8f49916715e..b38b7b37831 100644 --- a/rel/d/a/tag/d_a_tag_mstop/d_a_tag_mstop.cpp +++ b/rel/d/a/tag/d_a_tag_mstop/d_a_tag_mstop.cpp @@ -200,91 +200,87 @@ COMPILER_STRIP_GATE(0x805A6980, &lit_4059); #pragma pop /* 805A63F8-805A693C 000338 0544+00 1/1 0/0 0/0 .text execute__12daTagMstop_cFv */ +// one small block with issues #ifdef NONMATCHING -// inline function nightmare int daTagMstop_c::execute() { if (field_0x56c) { fopAcM_seStartCurrentLevel(this, Z2SE_OBJ_DARK_GATE, 0); } - daMidna_c* midna = daPy_py_c::getMidnaActor(); + daMidna_c* midna_p = daPy_py_c::getMidnaActor(); - if (!midna) { + if (midna_p == NULL) { return 1; - } else { - daAlink_c* link = (daAlink_c*)daPy_getLinkPlayerActorClass(); - - if (checkNoAttention()) { - mAttentionInfo.mPosition = midna->mAttentionInfo.mPosition; - shape_angle.y = midna->shape_angle.y; - mEyePos = midna->mAttentionInfo.mPosition; - - } else { - shape_angle.y = fopAcM_searchPlayerAngleY(this); - } - - if (field_0x56e == 4) { - if (field_0x5c8.abs2(link->current.pos) < 2500.0f) { - i_dComIfGp_event_reset(); - link->i_cancelOriginalDemo(); - field_0x56e = 0; - } - } else if (field_0x56e == 3) { - if (link->checkHorseRide()) { - link->setPlayerPosAndAngle(&field_0x5c8, link->shape_angle.y, 0); - i_dComIfGp_event_reset(); - field_0x56e = 0; - } else { - field_0x56e = 4; - link->i_changeOriginalDemo(); - - field_0x56a == 0 ? link->i_changeDemoMode(3, 0, 0, 0) : - link->i_changeDemoMode(2, 0, 0, 0); - link->i_changeDemoPos0(&field_0x5c8); - } - } else if (mEvtInfo.checkCommandTalk()) { - if (field_0x56e == 2) { - int shadowmode = midna->checkShadowModelDraw(); - if (midna->checkShadowReturnEnd()) { - i_dComIfGp_getEvent().reset(this); - fopAcM_orderPotentialEvent(this, 0x400, 0x14f, 1); - field_0x56e = 3; - } else if (shadowmode == 0) { - return 1; - } - } - } else if (mSwitch != 0xFF || i_fopAcM_isSwitch(this, mSwitch) && field_0x572 == -1 || - dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[field_0x572])) - { - fopAcM_delete(this); - - } else if (field_0x568 == 0xFF || - i_fopAcM_isSwitch(this, field_0x568) && field_0x570 == -1 || - dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[field_0x572]) && - current.pos.y <= link->current.pos.y && link->current.pos.y <= field_0x5c4 && - fopAcM_searchPlayerDistanceXZ2(this) < field_0x5c0) - { - eventOrder(); - - } else { - if (midna->checkShadowModeTalkWait()) { - if (field_0x56e == 0) { - mMsgFlow.init(this, shape_angle.z, 0, 0); - mDoAud_seStart(16, 0, 0, 0); - field_0x56e = 1; - } else { - if (mMsgFlow.doFlow(this, 0, 0)) { - field_0x56e = 2; - mDoAud_seStart(17, 0, 0, 0); - - if (midna->checkShadowModelDraw()) { - midna->setShadowReturn(); - } - } - } - } - } } + + daPy_py_c* player_p = daPy_getLinkPlayerActorClass(); + + if (checkNoAttention()) { + mAttentionInfo.mPosition = midna_p->mAttentionInfo.mPosition; + shape_angle.y = midna_p->shape_angle.y; + mEyePos = mAttentionInfo.mPosition; + } else { + shape_angle.y = fopAcM_searchPlayerAngleY(this); + } + + if (field_0x56e == 4) { + if (field_0x5c8.abs2(player_p->current.pos) < 2500.0f) { + i_dComIfGp_event_reset(); + player_p->i_cancelOriginalDemo(); + field_0x56e = 0; + } + } else if (field_0x56e == 3) { + if (player_p->checkHorseRide()) { + player_p->setPlayerPosAndAngle(&field_0x5c8, player_p->shape_angle.y, 0); + i_dComIfGp_event_reset(); + field_0x56e = 0; + } else { + field_0x56e = 4; + player_p->i_changeOriginalDemo(); + field_0x56a == 0 ? player_p->i_changeDemoMode(3, 0, 0, 0) : + player_p->i_changeDemoMode(2, 0, 0, 0); + + player_p->i_changeDemoPos0(&field_0x5c8); + } + } else if (mEvtInfo.checkCommandTalk()) { + if (field_0x56e == 2) { + if (!midna_p->checkShadowModelDraw() || midna_p->checkShadowReturnEnd()) { + i_dComIfGp_getEvent().reset(this); + fopAcM_orderPotentialEvent(this, 0x400, 0x14f, 1); + field_0x56e = 3; + } + } else if (!midna_p->checkShadowModeTalkWait()) { + if (field_0x56e == 0) { + mMsgFlow.init(this, (u16)shape_angle.z, 0, 0); + mDoAud_seStart(Z2SE_NAVI_TALK_START, 0, 0, 0); + field_0x56e = 1; + } else if (mMsgFlow.doFlow(this, 0, 0)) { + field_0x56e = 2; + mDoAud_seStart(Z2SE_NAVI_TALK_END, 0, 0, 0); + + if (midna_p->checkShadowModelDraw()) { + midna_p->setShadowReturn(); + } + } + } + } else if ((mSwitch != 0xFF && i_fopAcM_isSwitch(this, mSwitch)) || + (field_0x572 != 0xFFFF && + i_dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[field_0x572]))) + { + fopAcM_delete(this); + return 1; + } else if ((field_0x568 != 0xFF && !i_fopAcM_isSwitch(this, field_0x568)) || + (field_0x570 != 0xFFFF && + !i_dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[field_0x570]))) + { + return 1; + } else if (current.pos.y <= player_p->current.pos.y && field_0x5c4 >= player_p->current.pos.y && + fopAcM_searchPlayerDistanceXZ2(this) < field_0x5c0) + { + eventOrder(); + } + + return 1; } #else #pragma push