diff --git a/include/rel/d/a/d_a_do/d_a_do.h b/include/rel/d/a/d_a_do/d_a_do.h index 22fb7709e2b..940ce4b907d 100644 --- a/include/rel/d/a/d_a_do/d_a_do.h +++ b/include/rel/d/a/d_a_do/d_a_do.h @@ -23,23 +23,25 @@ class do_class : public fopAc_ac_c { public: /* 0x56C */ u8 field_0x56c[68]; /* 0x5AC */ request_of_phase_process_class mPhase; - /* 0x5B4 */ u8 field_0x5b4[2]; + /* 0x5B4 */ u8 field_0x5b4; + /* 0x5B5 */ u8 field_0x5b5; /* 0x5B6 */ u8 field_0x5b6; /* 0x5B7 */ u8 field_0x5b7[17]; /* 0x5C8 */ float field_0x5c8; - /* 0x5CC */ u8 field_0x5cc[4]; + /* 0x5CC */ s16 field_0x5cc; + /* 0x5CE */ u8 field_0x5ce[2]; /* 0x5D8 */ mDoExt_McaMorf* mpMorf; /* 0x5D4 */ u8 field_0x5d4[8]; /* 0x5DC */ u8 field_0x5dc[8]; - /* 0x5E4 */ s32 field_0x5e4; + /* 0x5E4 */ s32 mResIdx; /* 0x5E8 */ float field_0x5e8; /* 0x5EC */ float field_0x5ec; /* 0x5F0 */ u8 field_0x5f0[2]; - /* 0x5F2 */ s16 field_0x5f2; - /* 0x5F4 */ u8 field_0x5f4[2]; - /* 0x5F6 */ s16 field_0x5f6; + /* 0x5F2 */ s16 mActionStatus; + /* 0x5F4 */ u16 field_0x5f4; + /* 0x5F6 */ s16 mStayStatus; /* 0x5F8 */ u8 field_0x5f8[4]; - /* 0x5FC */ u16 field_0x5fc; + /* 0x5FC */ s16 field_0x5fc; /* 0x5FE */ u8 field_0x5fe[2]; /* 0x600 */ s16 field_0x600; /* 0x602 */ u8 field_0x602[2]; @@ -47,11 +49,12 @@ public: /* 0x606 */ u8 field_0x606[2]; /* 0x608 */ float field_0x608; /* 0x60C */ u8 field_0x60c[8]; - /* 0x614 */ u16 field_0x614; - /* 0x616 */ u8 field_0x616[30]; + /* 0x614 */ s16 field_0x614; + /* 0x616 */ u8 field_0x616; + /* 0x617 */ u8 field_0x617[29]; /* 0x634 */ u32 field_0x634; /* 0x638 */ u8 field_0x638[16]; - /* 0x648 */ u32 field_0x648; + /* 0x648 */ f32 field_0x648; /* 0x64c */ u8 field_0x64c[12]; /* 0x658 */ float field_0x658; /* 0x65C */ float field_0x65c; @@ -83,7 +86,27 @@ public: /* 0xCC0 */ u8 field_0xcc0; public: + enum { + ACTION_STATUS_STAY, + ACTION_STATUS_WALK, + ACTION_STATUS_WALK_RUN, + ACTION_STATUS_RUN, + ACTION_STATUS_RUN_WALK, + ACTION_STATUS_FOOD, + ACTION_STATUS_WAIT_1, + ACTION_STATUS_WAIT_2, + ACTION_STATUS_SIT, + ACTION_STATUS_A_SWIM = 10, + ACTION_STATUS_SWIM = 20, + ACTION_STATUS_HELP, + ACTION_STATUS_BOAT, + ACTION_STATUS_HANG = 30, + ACTION_STATUS_CARRY = 35, + ACTION_STATUS_MESSAGE = 39 + }; + /* 8066EAE4 */ do_class(); + }; class daDo_HIO_c : public do_class { diff --git a/rel/d/a/d_a_do/d_a_do.cpp b/rel/d/a/d_a_do/d_a_do.cpp index 2f35dc147dc..76569a2ef4f 100644 --- a/rel/d/a/d_a_do/d_a_do.cpp +++ b/rel/d/a/d_a_do/d_a_do.cpp @@ -439,11 +439,11 @@ SECTION_DEAD static char const* const stringBase_8066EFB0 = "Do"; #pragma pop /* 80667DA8-80667E68 000148 00C0+00 16/16 0/0 0/0 .text anm_init__FP8do_classifUcf */ -static void anm_init(do_class* i_dogP, int param_1, f32 param_2, u8 param_3, f32 param_4) { +static void anm_init(do_class* i_dogP, int i_resIdx, f32 param_2, u8 param_3, f32 param_4) { if (!(i_dogP->field_0x608 > FLOAT_LABEL(lit_3662))) { - i_dogP->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Do", param_1), param_3, + i_dogP->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Do", i_resIdx), param_3, param_2, param_4, FLOAT_LABEL(lit_3682), FLOAT_LABEL(lit_3683), 0); - i_dogP->field_0x5e4 = param_1; + i_dogP->mResIdx = i_resIdx; } } @@ -656,7 +656,8 @@ static u8 struct_8066F2B4[4]; static u8 lit_3657[12]; /* 8066F2C4-8066F2E4 000054 0020+00 11/12 0/0 0/0 .bss l_HIO */ -static u8 l_HIO[32]; +// likely is a more complicated struct that needs to be mapped +static f32 l_HIO[8]; /* 8066F2E4-8066F2F8 000074 0014+00 1/2 0/0 0/0 .bss target_info */ static fopAc_ac_c* target_info[5]; @@ -762,16 +763,16 @@ static void food_check(do_class* i_dogP) { i_dogP->mFoodBsPcId = search_food(i_dogP); if (fopAcM_SearchByID(i_dogP->mFoodBsPcId)) { - i_dogP->field_0x5f2 = 5; - i_dogP->field_0x5f6 = 0; + i_dogP->mActionStatus = do_class::ACTION_STATUS_FOOD; + i_dogP->mStayStatus = 0; } } /* 806685EC-80668624 00098C 0038+00 1/1 0/0 0/0 .text do_carry_check__FP8do_class */ static int do_carry_check(do_class* i_dogP) { - if (i_dogP->field_0x5f2 != 0x23 && fopAcM_checkCarryNow(i_dogP)) { - i_dogP->field_0x5f2 = 0x23; - i_dogP->field_0x5f6 = 0; + if (i_dogP->mActionStatus != do_class::ACTION_STATUS_CARRY && fopAcM_checkCarryNow(i_dogP)) { + i_dogP->mActionStatus = do_class::ACTION_STATUS_CARRY; + i_dogP->mStayStatus = 0; return 1; } @@ -997,12 +998,12 @@ COMPILER_STRIP_GATE(0x8066EE3C, &lit_4069); /* 80668B18-80668BA0 000EB8 0088+00 4/4 0/0 0/0 .text move_dansa_check__FP8do_classf */ static int move_dansa_check(do_class* i_dogP, f32 param_1) { if (dansa_check2(i_dogP,FLOAT_LABEL(lit_4068)) != 0) { - i_dogP->field_0x5f2 = 6; + i_dogP->mActionStatus = do_class::ACTION_STATUS_WAIT_1; if (param_1 > FLOAT_LABEL(lit_4069)) { - i_dogP->field_0x5f6 = 10; + i_dogP->mStayStatus = 10; } else { - i_dogP->field_0x5f6 = 0; + i_dogP->mStayStatus = 0; } return 1; @@ -1056,8 +1057,8 @@ static void area_check(do_class* i_dogP) { if (i_dogP->field_0x5b6 != 255) { if ((i_dogP->field_0x5b6 * 100.f * 2.0f) > pos_delta.abs()) { - i_dogP->field_0x5f2 = 1; - i_dogP->field_0x5f6 = -1; + i_dogP->mActionStatus = do_class::ACTION_STATUS_WALK; + i_dogP->mStayStatus = -1; i_dogP->field_0x600 = cM_rndF(100.0f) + 100.0f; // random value between 100 and 200 } } @@ -1082,6 +1083,97 @@ COMPILER_STRIP_GATE(0x8066EE60, &lit_4189); #pragma pop /* 80668D5C-80669050 0010FC 02F4+00 2/1 0/0 0/0 .text do_stay__FP8do_class */ +#ifdef NONMATCHING +// regalloc and float literals +static void do_stay(do_class* i_dogP) { + switch (i_dogP->mStayStatus) { + case 0: { + if (i_dogP->field_0x5b4 == 0) { + anm_init(i_dogP,12,0.0f,2,2.0f); // fix float literals + i_dogP->mStayStatus++; + i_dogP->field_0x5fc = 10; + } else { + i_dogP->mActionStatus = do_class::ACTION_STATUS_WALK; + i_dogP->mStayStatus = 0; + return; + } + } + case 1: { + if (i_dogP->field_0x5fc == 0 && i_dogP->field_0x5c8 < l_HIO[6]) { + i_dogP->mStayStatus++; + i_dogP->field_0x5fc = cM_rndF(50.0) + 20.f; // fix float literals // random number between 20 and 70 + } + break; + } + case 2: { + i_dogP->field_0x616 = 1; + i_dogP->field_0x614 = 0xe764; + i_dogP->field_0x648 = 1000.0f; // fix float literals + if (i_dogP->field_0x5fc == 0) { + anm_init(i_dogP,11,0.0f,0,2.0f); // fix float literals + i_dogP->mStayStatus++; + } + break; + } + case 3: { + i_dogP->field_0x616 = 1; + i_dogP->field_0x648 = 2000.0f; // fix float literals + + if (i_dogP->mpMorf->isStop()) { + i_dogP->mActionStatus = do_class::ACTION_STATUS_WALK_RUN; + i_dogP->mStayStatus = 0; + } + break; + } + case 10: { + anm_init(i_dogP,12,0.0f,2,2.0f); // fix float literals + i_dogP->mStayStatus++; + } + case 11: { + i_dogP->field_0x616 = 1; + i_dogP->field_0x614 = 0xe764; + i_dogP->field_0x648 = 1000.0f; // fix float literals + + if (i_dogP->field_0x658 > 30.0f) { + i_dogP->mStayStatus++; + i_dogP->field_0x5fc = cM_rndF(10.0) + 10.f; // fix float literals // random number between 10 and 20 + } + + if (i_dogP->field_0x5c8 > l_HIO[6] + 100.0f) { // fix float literals + i_dogP->field_0x5f4 = 0; + i_dogP->mStayStatus = 0; + } + break; + } + case 12: { + i_dogP->field_0x616 = 1; + i_dogP->field_0x614 = 0xe764; + i_dogP->field_0x648 = 1500.0f; + + if (i_dogP->field_0x658 > 30.0f) { + if (i_dogP->field_0x5fc == 0) { + anm_init(i_dogP,11,0.0f,0,2.0f); // fix float literals + i_dogP->mStayStatus = 13; + } + } else { + i_dogP->mStayStatus = 11; + } + break; + } + case 13: { + i_dogP->field_0x616 = 1; + i_dogP->field_0x648 = 1500.0f; // fix float literals + + if (i_dogP->mpMorf->isStop()) { + i_dogP->mActionStatus = do_class::ACTION_STATUS_WAIT_1; + i_dogP->mStayStatus = 0; + } + } + } + + cLib_addCalc0(&i_dogP->mSpeedF,1.0f,1.0f); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -1090,6 +1182,7 @@ static asm void do_stay(do_class* i_dogP) { #include "asm/rel/d/a/d_a_do/d_a_do/do_stay__FP8do_class.s" } #pragma pop +#endif /* ############################################################################################## */ /* 8066EE64-8066EE68 00007C 0004+00 0/4 0/0 0/0 .rodata @4190 */ @@ -1732,6 +1825,32 @@ static asm void do_carry(do_class* i_dogP) { #pragma pop /* 8066CDEC-8066CEC4 00518C 00D8+00 1/1 0/0 0/0 .text do_message__FP8do_class */ +#ifndef NONMATCHING +static void do_message(do_class* i_dogP) { + i_dogP->field_0x648 = FLOAT_LABEL(lit_4191); + + switch(i_dogP->mStayStatus) { + case 1: { + break; + } + case 0: { + anm_init(i_dogP,21,FLOAT_LABEL(lit_4027),2,FLOAT_LABEL(lit_3662)); + i_dogP->mStayStatus++; + break; + } + } + + cLib_addCalc0(&i_dogP->mSpeedF,FLOAT_LABEL(lit_3662),FLOAT_LABEL(lit_3665)); + i_dogP->field_0x616 = 1; + cLib_addCalcAngleS2(&i_dogP->current.angle.y,i_dogP->field_0x5cc,2,0x1000); + + if (i_dComIfGp_event_runCheck() == 0 && i_dogP->field_0x5c8 > FLOAT_LABEL(lit_3773)) { + i_dogP->mActionStatus = 0; + i_dogP->mStayStatus = 0; + } + +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -1740,6 +1859,7 @@ static asm void do_message(do_class* i_dogP) { #include "asm/rel/d/a/d_a_do/d_a_do/do_message__FP8do_class.s" } #pragma pop +#endif /* ############################################################################################## */ /* 8066EF70-8066EF74 000188 0004+00 0/2 0/0 0/0 .rodata @5948 */