/**
 * @file d_a_obj_movebox.cpp
 *
 */

#include "rel/d/a/obj/d_a_obj_movebox/d_a_obj_movebox.h"
#include "SSystem/SComponent/c_math.h"
#include "d/a/d_a_player.h"
#include "d/d_path.h"
#include "dol2asm.h"
#include "rel/d/a/obj/d_a_obj_burnbox/d_a_obj_burnbox.h"
#include "rel/d/a/obj/d_a_obj_eff/d_a_obj_eff.h"

//
// Forward References:
//

extern "C" void __ct__Q212daObjMovebox5Bgc_cFv();
extern "C" void __dt__4cXyzFv();
extern "C" void __ct__4cXyzFv();
extern "C" void
gnd_pos__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cif();
extern "C" void wrt_pos__Q212daObjMovebox5Bgc_cFRC4cXyz();
extern "C" void
wall_pos__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cisf();
extern "C" void proc_vertical__Q212daObjMovebox5Bgc_cFPQ212daObjMovebox5Act_c();
extern "C" void
chk_wall_pre__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cis();
extern "C" void
chk_wall_touch__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cs();
extern "C" void
chk_wall_touch2__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cis();
extern "C" void prm_get_swSave1__Q212daObjMovebox5Act_cCFv();
extern "C" void prmZ_init__Q212daObjMovebox5Act_cFv();
extern "C" void prmX_init__Q212daObjMovebox5Act_cFv();
extern "C" void attr__Q212daObjMovebox5Act_cCFv();
extern "C" void set_mtx__Q212daObjMovebox5Act_cFv();
extern "C" void init_mtx__Q212daObjMovebox5Act_cFv();
extern "C" void path_init__Q212daObjMovebox5Act_cFv();
extern "C" void path_save__Q212daObjMovebox5Act_cFv();
extern "C" void CreateHeap__Q212daObjMovebox5Act_cFv();
extern "C" void RideCallBack__Q212daObjMovebox5Act_cFP4dBgWP10fopAc_ac_cP10fopAc_ac_c();
extern "C" void
PPCallBack__Q212daObjMovebox5Act_cFP10fopAc_ac_cP10fopAc_ac_csQ29dBgW_Base13PushPullLabel();
extern "C" void Create__Q212daObjMovebox5Act_cFv();
extern "C" void afl_sway__Q212daObjMovebox5Act_cFv();
extern "C" void check_to_walk__Q212daObjMovebox5Act_cFv();
extern "C" void clr_moment_cnt__Q212daObjMovebox5Act_cFv();
extern "C" void chk_appear__Q212daObjMovebox5Act_cCFv();
extern "C" void eff_smoke_slip_start__Q212daObjMovebox5Act_cFv();
extern "C" void mode_wait_init__Q212daObjMovebox5Act_cFv();
extern "C" void mode_wait__Q212daObjMovebox5Act_cFv();
extern "C" void mode_walk_init__Q212daObjMovebox5Act_cFv();
extern "C" void mode_walk__Q212daObjMovebox5Act_cFv();
extern "C" void mode_afl_init__Q212daObjMovebox5Act_cFv();
extern "C" void mode_afl__Q212daObjMovebox5Act_cFv();
extern "C" void __dt__14dBgS_ObjGndChkFv();
extern "C" void sound_slip__Q212daObjMovebox5Act_cFv();
extern "C" void sound_limit__Q212daObjMovebox5Act_cFv();
extern "C" void sound_land__Q212daObjMovebox5Act_cFv();
extern "C" void vib_land__Q212daObjMovebox5Act_cFv();
extern "C" void eff_land_smoke__Q212daObjMovebox5Act_cFv();
extern "C" void Execute__Q212daObjMovebox5Act_cFPPA3_A4_f();
extern "C" void Draw__Q212daObjMovebox5Act_cFv();
extern "C" void __dt__8cM3dGPlaFv();
extern "C" void Delete__Q212daObjMovebox5Act_cFv();
extern "C" static void func_80480920();
extern "C" void __dt__8cM3dGCylFv();
extern "C" void __dt__8cM3dGAabFv();
extern "C" void __dt__10dCcD_GSttsFv();
extern "C" static void func_80480BC0();
extern "C" static void func_80480C18();
extern "C" static void func_80480C38();
extern "C" static void func_80480C64();
extern "C" void __dt__10cCcD_GSttsFv();
extern "C" void func_80480CD8(void* _this, fopAc_ac_c const*, daObjMovebox::Act_c::Prm_e,
                              daObjMovebox::Act_c::Prm_e);
extern "C" void __sinit_d_a_obj_movebox_cpp();
extern "C" void func_80480DA0();
extern "C" void __dt__11dBgS_WtrChkFv();
extern "C" void func_80480E50();
extern "C" void __ct__14dBgS_ObjGndChkFv();
extern "C" static void func_80480EE4();
extern "C" static void func_80480EEC();
extern "C" static void func_80480EF4();
extern "C" static void func_80480EFC();
extern "C" static void func_80480F04();
extern "C" static void func_80480F0C();
extern "C" u8 const M_lin5__Q212daObjMovebox5Bgc_c[80];
extern "C" u8 const M_lin20__Q212daObjMovebox5Bgc_c[368];
extern "C" void* const M_arcname__Q212daObjMovebox5Act_c[8];
extern "C" u8 const M_cyl_src__Q212daObjMovebox5Act_c[68];
extern "C" u8 const M_attr__Q212daObjMovebox5Act_c[1280];
extern "C" extern char const* const d_a_obj_movebox__stringBase0;
extern "C" u8 M_gnd_work__Q212daObjMovebox5Bgc_c[1932];
extern "C" u8 M_wrt_work__Q212daObjMovebox5Bgc_c[84];
extern "C" u8 M_wall_work__Q212daObjMovebox5Bgc_c[2576];

//
// External References:
//

extern "C" void mDoMtx_XrotS__FPA4_fs();
extern "C" void mDoMtx_XrotM__FPA4_fs();
extern "C" void mDoMtx_YrotS__FPA4_fs();
extern "C" void mDoMtx_YrotM__FPA4_fs();
extern "C" void transS__14mDoMtx_stack_cFRC4cXyz();
extern "C" void transM__14mDoMtx_stack_cFfff();
extern "C" void transM__14mDoMtx_stack_cFRC4cXyz();
extern "C" void scaleM__14mDoMtx_stack_cFfff();
extern "C" void ZXYrotM__14mDoMtx_stack_cFRC5csXyz();
extern "C" void quatM__14mDoMtx_stack_cFPC10Quaternion();
extern "C" void mDoExt_modelUpdateDL__FP8J3DModel();
extern "C" void mDoExt_J3DModel__create__FP12J3DModelDataUlUl();
extern "C" void fopAcM_delete__FP10fopAc_ac_c();
extern "C" void fopAcM_create__FsUlPC4cXyziPC5csXyzPC4cXyzSc();
extern "C" void fopAcM_createChild__FsUiUlPC4cXyziPC5csXyzPC4cXyzScPFPv_i();
extern "C" void fopAcM_setCullSizeBox__FP10fopAc_ac_cffffff();
extern "C" void fopAcM_posMoveF__FP10fopAc_ac_cPC4cXyz();
extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc();
extern "C" void dComIfG_resDelete__FP30request_of_phase_process_classPCc();
extern "C" void dComIfGp_getReverb__Fi();
extern "C" void onSwitch__10dSv_info_cFii();
extern "C" void offSwitch__10dSv_info_cFii();
extern "C" void isSwitch__10dSv_info_cCFii();
extern "C" void posMoveF_stream__5daObjFP10fopAc_ac_cPC4cXyzPC4cXyzff();
extern "C" void quat_rotBaseY__5daObjFP10QuaternionRC4cXyz();
extern "C" void getRes__14dRes_control_cFPCclP11dRes_info_ci();
extern "C" void getRes__14dRes_control_cFPCcPCcP11dRes_info_ci();
extern "C" void
setModel__18dPa_modelEcallBackFP14JPABaseEmitterP12J3DModelDataRC12dKy_tevstr_cUcPvUcUc();
extern "C" void
set__13dPa_control_cFUcUsPC4cXyzPC12dKy_tevstr_cPC5csXyzPC4cXyzUcP18dPa_levelEcallBackScPC8_GXColorPC8_GXColorPC4cXyzf();
extern "C" void dPath_GetPnt__FPC5dPathi();
extern "C" void dPath_GetRoomPath__Fii();
extern "C" void setSimple__21dDlst_shadowControl_cFP4cXyzffP4cXyzsfP9_GXTexObj();
extern "C" void StartShock__12dVibration_cFii4cXyz();
extern "C" void LineCross__4cBgSFP11cBgS_LinChk();
extern "C" void GroundCross__4cBgSFP11cBgS_GndChk();
extern "C" void GetActorPointer__4cBgSCFi();
extern "C" void GetTriPla__4cBgSCFRC13cBgS_PolyInfoP8cM3dGPla();
extern "C" void GetPolyColor__4dBgSFRC13cBgS_PolyInfo();
extern "C" void SplGrpChk__4dBgSFP14dBgS_SplGrpChk();
extern "C" void dBgS_MoveBGProc_Typical__FP4dBgWPvRC13cBgS_PolyInfobP4cXyzP5csXyzP5csXyz();
extern "C" void dBgS_MoveBGProc_Trans__FP4dBgWPvRC13cBgS_PolyInfobP4cXyzP5csXyzP5csXyz();
extern "C" void RideCallBack__4dBgSFRC13cBgS_PolyInfoP10fopAc_ac_c();
extern "C" void __ct__11dBgS_GndChkFv();
extern "C" void __dt__11dBgS_GndChkFv();
extern "C" void Set__11dBgS_LinChkFPC4cXyzPC4cXyzPC10fopAc_ac_c();
extern "C" void __ct__14dBgS_ObjLinChkFv();
extern "C" void __dt__14dBgS_ObjLinChkFv();
extern "C" void __ct__16dBgS_MoveBgActorFv();
extern "C" bool IsDelete__16dBgS_MoveBgActorFv();
extern "C" bool ToFore__16dBgS_MoveBgActorFv();
extern "C" bool ToBack__16dBgS_MoveBgActorFv();
extern "C" void
MoveBGCreate__16dBgS_MoveBgActorFPCciPFP4dBgWPvRC13cBgS_PolyInfobP4cXyzP5csXyzP5csXyz_vUlPA3_A4_f();
extern "C" void MoveBGDelete__16dBgS_MoveBgActorFv();
extern "C" void MoveBGExecute__16dBgS_MoveBgActorFv();
extern "C" void Set__14dBgS_SplGrpChkFR4cXyzf();
extern "C" void __dt__14dBgS_SplGrpChkFv();
extern "C" void SetObj__16dBgS_PolyPassChkFv();
extern "C" void __ct__11dBgS_WtrChkFv();
extern "C" void Move__4dBgWFv();
extern "C" void GetAc__22dCcD_GAtTgCoCommonBaseFv();
extern "C" void __ct__10dCcD_GSttsFv();
extern "C" void Init__9dCcD_SttsFiiP10fopAc_ac_c();
extern "C" void __ct__12dCcD_GObjInfFv();
extern "C" void ChkTgHit__12dCcD_GObjInfFv();
extern "C" void GetTgHitGObj__12dCcD_GObjInfFv();
extern "C" void Set__8dCcD_CylFRC11dCcD_SrcCyl();
extern "C" void MoveCTg__8dCcD_CylFR4cXyz();
extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c();
extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c();
extern "C" void dKy_pol_sound_get__FPC13cBgS_PolyInfo();
extern "C" void Set__4cCcSFP8cCcD_Obj();
extern "C" void __pl__4cXyzCFRC3Vec();
extern "C" void cM_rnd__Fv();
extern "C" void SetPos__11cBgS_GndChkFPC4cXyz();
extern "C" void seStart__7Z2SeMgrF10JAISoundIDPC3VecUlScffffUc();
extern "C" void seStartLevel__7Z2SeMgrF10JAISoundIDPC3VecUlScffffUc();
extern "C" void __dl__FPv();
extern "C" void __destroy_arr();
extern "C" void __construct_array();
extern "C" void __ptmf_scall();
extern "C" void _savegpr_15();
extern "C" void _savegpr_20();
extern "C" void _savegpr_24();
extern "C" void _savegpr_25();
extern "C" void _savegpr_26();
extern "C" void _savegpr_27();
extern "C" void _savegpr_28();
extern "C" void _savegpr_29();
extern "C" void _restgpr_15();
extern "C" void _restgpr_20();
extern "C" void _restgpr_24();
extern "C" void _restgpr_25();
extern "C" void _restgpr_26();
extern "C" void _restgpr_27();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
extern "C" extern void* __vt__8dCcD_Cyl[36];
extern "C" extern void* __vt__9dCcD_Stts[11];
extern "C" extern void* __vt__12cCcD_CylAttr[25];
extern "C" extern void* __vt__14cCcD_ShapeAttr[22];
extern "C" extern void* __vt__9cCcD_Stts[8];
extern "C" u8 now__14mDoMtx_stack_c[48];
extern "C" f32 Zero__4cXyz[3];
extern "C" u8 BaseY__4cXyz[12];
extern "C" u8 sincosTable___5JMath[65536];
extern "C" u8 mEcallback__18dPa_modelEcallBack[4];
extern "C" u8 mAudioMgrPtr__10Z2AudioMgr[4 + 4 /* padding */];
extern "C" void* M_dir_base__Q212daObjMovebox5Act_c[2];
extern "C" void __register_global_object();

//
// Declarations:
//

/* 80481704-80481710 000000 000C+00 1/1 0/0 0/0 .data            cNullVec__6Z2Calc */
SECTION_DATA static u8 cNullVec__6Z2Calc[12] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

/* 80481710-80481724 00000C 0004+10 0/0 0/0 0/0 .data            @1787 */
#pragma push
#pragma force_active on
SECTION_DATA static u32 lit_1787[1 + 4 /* padding */] = {
    0x02000201,
    /* padding */
    0x40080000,
    0x00000000,
    0x3FE00000,
    0x00000000,
};
#pragma pop

/* ############################################################################################## */
/* 80480F28-80480F78 000000 0050+00 14/14 0/0 0/0 .rodata          M_lin5__Q212daObjMovebox5Bgc_c */
const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin5[] = {
    {0.0f, 0.0f, 0.0f, 0.0f},   {-0.5f, -0.5f, 1.0f, 1.0f}, {0.5f, -0.5f, -1.0f, 1.0f},
    {0.5f, 0.5f, -1.0f, -1.0f}, {-0.5f, 0.5f, 1.0f, -1.0f},
};

/* 80480F78-804810E8 000050 0170+00 0/4 0/0 0/0 .rodata          M_lin20__Q212daObjMovebox5Bgc_c */
SECTION_RODATA const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin20[] = {
    {0.0f, 0.0f, 0.0f, 0.0f},    {-0.25f, -0.25f, 0.0f, 0.0f}, {-0.5f, -0.5f, 1.0f, 1.0f},
    {0.0f, -0.5f, -1.0f, 1.0f},  {0.0f, 0.0f, -1.0f, -1.0f},   {-0.5f, 0.0f, 1.0f, -1.0f},
    {0.25f, -0.25f, 0.0f, 0.0f}, {0.0f, -0.5f, 1.0f, 1.0f},    {0.5f, -0.5f, -1.0f, 1.0f},
    {0.5f, 0.0f, -1.0f, -1.0f},  {0.0f, 0.0f, 1.0f, -1.0f},    {0.25f, 0.25f, 0.0f, 0.0f},
    {0.0f, 0.0f, 1.0f, 1.0f},    {0.5f, 0.0f, -1.0f, 1.0f},    {0.5f, 0.5f, -1.0f, -1.0f},
    {0.0f, 0.5f, 1.0f, -1.0f},   {-0.25f, 0.25f, 0.0f, 0.0f},  {-0.5f, 0.0f, 1.0f, 1.0f},
    {0.0f, 0.0f, -1.0f, 1.0f},   {0.0f, 0.5f, -1.0f, -1.0f},   {-0.5f, 0.5f, 1.0f, -1.0f},
    {-0.75f, 0.25f, 0.0f, 0.0f}, {-0.75f, -0.25f, 0.0f, 0.0f},
};

/* 8047DAEC-8047DBB0 0000EC 00C4+00 1/1 0/0 0/0 .text            __ct__Q212daObjMovebox5Bgc_cFv */
daObjMovebox::Bgc_c::Bgc_c() {
    for (int i = 0; i < 23; i++) {
        field_0x0[i] = 0.0f;
        field_0x64[i] = cXyz::Zero;
    }

    field_0x5c = 0xFFFFFFFF;
    field_0x178 = 0xFFFFFFFF;
    field_0x17c = FLT_MAX;
    field_0x60 = 0.0f;
    mState = STATE_0_e;
}

/* 80481888-8048188C 000008 0001+03 4/4 0/0 0/0 .bss             @1109 */
static u8 lit_1109[1 + 3 /* padding */];

/* 8048188C-80481890 00000C 0001+03 0/0 0/0 0/0 .bss             @1107 */
#pragma push
#pragma force_active on
static u8 lit_1107[1 + 3 /* padding */];
#pragma pop

/* 80481890-80481894 000010 0001+03 0/0 0/0 0/0 .bss             @1105 */
#pragma push
#pragma force_active on
static u8 lit_1105[1 + 3 /* padding */];
#pragma pop

/* 80481894-80481898 000014 0001+03 0/0 0/0 0/0 .bss             @1104 */
#pragma push
#pragma force_active on
static u8 lit_1104[1 + 3 /* padding */];
#pragma pop

/* 80481898-8048189C 000018 0001+03 0/0 0/0 0/0 .bss             @1099 */
#pragma push
#pragma force_active on
static u8 lit_1099[1 + 3 /* padding */];
#pragma pop

/* 8048189C-804818A0 00001C 0001+03 0/0 0/0 0/0 .bss             @1097 */
#pragma push
#pragma force_active on
static u8 lit_1097[1 + 3 /* padding */];
#pragma pop

/* 804818A0-804818A4 000020 0001+03 0/0 0/0 0/0 .bss             @1095 */
#pragma push
#pragma force_active on
static u8 lit_1095[1 + 3 /* padding */];
#pragma pop

/* 804818A4-804818A8 000024 0001+03 0/0 0/0 0/0 .bss             @1094 */
#pragma push
#pragma force_active on
static u8 lit_1094[1 + 3 /* padding */];
#pragma pop

/* 804818A8-804818AC 000028 0001+03 0/0 0/0 0/0 .bss             @1057 */
#pragma push
#pragma force_active on
static u8 lit_1057[1 + 3 /* padding */];
#pragma pop

/* 804818AC-804818B0 00002C 0001+03 0/0 0/0 0/0 .bss             @1055 */
#pragma push
#pragma force_active on
static u8 lit_1055[1 + 3 /* padding */];
#pragma pop

/* 804818B0-804818B4 000030 0001+03 0/0 0/0 0/0 .bss             @1053 */
#pragma push
#pragma force_active on
static u8 lit_1053[1 + 3 /* padding */];
#pragma pop

/* 804818B4-804818B8 000034 0001+03 0/0 0/0 0/0 .bss             @1052 */
#pragma push
#pragma force_active on
static u8 lit_1052[1 + 3 /* padding */];
#pragma pop

/* 804818B8-804818BC 000038 0001+03 0/0 0/0 0/0 .bss             @1014 */
#pragma push
#pragma force_active on
static u8 lit_1014[1 + 3 /* padding */];
#pragma pop

/* 804818BC-804818C0 00003C 0001+03 0/0 0/0 0/0 .bss             @1012 */
#pragma push
#pragma force_active on
static u8 lit_1012[1 + 3 /* padding */];
#pragma pop

/* 804818C0-804818C4 000040 0001+03 0/0 0/0 0/0 .bss             @1010 */
#pragma push
#pragma force_active on
static u8 lit_1010[1 + 3 /* padding */];
#pragma pop

/* 804818C4-804818C8 000044 0001+03 0/0 0/0 0/0 .bss             @1009 */
#pragma push
#pragma force_active on
static u8 lit_1009[1 + 3 /* padding */];
#pragma pop

/* 804818D4-80482060 000054 078C+00 7/8 0/0 0/0 .bss             M_gnd_work__Q212daObjMovebox5Bgc_c
 */
dBgS_ObjGndChk daObjMovebox::Bgc_c::M_gnd_work[23];

/* 8047DBF0-8047DD88 0001F0 0198+00 1/1 0/0 0/0 .text
 * gnd_pos__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cif */
void daObjMovebox::Bgc_c::gnd_pos(const daObjMovebox::Act_c* i_actor,
                                  const daObjMovebox::BgcSrc_c* i_bgcSrc, int i_checkNum,
                                  f32 param_3) {
    cXyz sp50;
    cXyz sp5C;
    f32 var_f31 = -1000000000.0f;

    mDoMtx_stack_c::transS(i_actor->current.pos);
    mDoMtx_stack_c::YrotM(i_actor->home.angle.y);
    field_0x5c = -1;

    for (int i = 0; i < i_checkNum; i++, i_bgcSrc++) {
        sp50.set(i_bgcSrc->field_0xc + i_bgcSrc->field_0x4 * i_actor->attr().field_0x70, param_3,
                 i_bgcSrc->field_0x8 + i_bgcSrc->field_0x0 * i_actor->attr().field_0x78);

        mDoMtx_stack_c::multVec(&sp50, &sp5C);
        M_gnd_work[i].SetPos(&sp5C);
        M_gnd_work[i].SetActorPid(i_actor->mBase.mBsPcId);
        field_0x0[i] = dComIfG_Bgsp().GroundCross(&M_gnd_work[i]);

        if (field_0x0[i] > var_f31) {
            fopAc_ac_c* bg_actor = dComIfG_Bgsp().GetActorPointer(M_gnd_work[i]);
            if (bg_actor == NULL || fopAcM_GetName(bg_actor) != PROC_Obj_Movebox ||
                ((daObjMovebox::Act_c*)bg_actor)->field_0x5ac != 2)
            {
                var_f31 = field_0x0[i];
                field_0x5c = i;
            }
        }
    }
}

/* 8048206C-804820C0 0007EC 0054+00 1/2 0/0 0/0 .bss             M_wrt_work__Q212daObjMovebox5Bgc_c
 */
dBgS_WtrChk daObjMovebox::Bgc_c::M_wrt_work;

/* 8047DD88-8047DE58 000388 00D0+00 1/1 0/0 0/0 .text wrt_pos__Q212daObjMovebox5Bgc_cFRC4cXyz */
void daObjMovebox::Bgc_c::wrt_pos(cXyz const& param_0) {
    cXyz sp28(param_0);

    f32 var_f31 = param_0.y + 400.0f;
    sp28.y -= 100.0f;

    M_wrt_work.Set(sp28, var_f31);

    if (dComIfG_Bgsp().WaterChk(&M_wrt_work)) {
        field_0x60 = M_wrt_work.GetHeight();

        cLib_onBit<daObjMovebox::Bgc_c::State_e>(mState, STATE_8_e);
        if (field_0x60 > param_0.y) {
            cLib_onBit<daObjMovebox::Bgc_c::State_e>(mState, STATE_10_e);
        }
    }
}

/* 804820CC-80482ADC 00084C 0A10+00 3/4 0/0 0/0 .bss             M_wall_work__Q212daObjMovebox5Bgc_c
 */
dBgS_ObjLinChk daObjMovebox::Bgc_c::M_wall_work[23];

/* 8047DE58-8047E134 000458 02DC+00 1/1 0/0 0/0 .text
 * wall_pos__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cisf */
void daObjMovebox::Bgc_c::wall_pos(daObjMovebox::Act_c const* i_actor,
                                   daObjMovebox::BgcSrc_c const* i_bgcSrc, int i_num, s16 param_3,
                                   f32 param_4) {
    const s16 sp8C = i_actor->home.angle.y + param_3;

    cXyz sp48;
    cXyz sp54;
    cXyz sp60;
    cXyz sp6C;
    cXyz sp78;

    field_0x178 = -1;
    field_0x17c = FLT_MAX;

    mDoMtx_stack_c::YrotS(sp8C);
    mDoMtx_stack_c::XrotM(0x4000);
    mDoMtx_stack_c::multVec(&cXyz::BaseY, &sp6C);
    sp6C *= param_4 + i_actor->attr().field_0x78 * 0.5f;

    for (int i = 0; i < i_num; i++, i_bgcSrc++) {
        mDoMtx_stack_c::XrotS(0x4000);
        sp78.set(i_bgcSrc->field_0xc, 0.0f, i_bgcSrc->field_0x8);
        mDoMtx_stack_c::multVec(&sp78, &sp60);

        mDoMtx_stack_c::YrotS(sp8C);
        mDoMtx_stack_c::transM(sp60);
        mDoMtx_stack_c::scaleM(i_actor->attr().field_0x70, i_actor->attr().field_0x64,
                               i_actor->attr().field_0x70);
        mDoMtx_stack_c::transM(0.0f, 0.5f, 0.0f);
        mDoMtx_stack_c::XrotM(0x4000);

        sp78.set(i_bgcSrc->field_0x4, 0.0f, i_bgcSrc->field_0x0);
        mDoMtx_stack_c::multVec(&sp78, &sp48);
        sp48 += i_actor->current.pos;
        sp54 = sp48 + sp6C;

        M_wall_work[i].Set(&sp48, &sp54, i_actor);
        M_wall_work[i].SetActorPid(i_actor->mBase.mBsPcId);

        if (dComIfG_Bgsp().LineCross(&M_wall_work[i])) {
            field_0x64[i] = M_wall_work[i].i_GetCross();

            f32 var_f31 = sp48.abs2(field_0x64[i]);
            if (var_f31 < field_0x17c) {
                field_0x17c = var_f31;
                field_0x178 = i;
            }
        } else {
            field_0x64[i] = cXyz::Zero;
        }
    }
}

/* 8047E134-8047E2D4 000734 01A0+00 2/2 0/0 0/0 .text
 * proc_vertical__Q212daObjMovebox5Bgc_cFPQ212daObjMovebox5Act_c */
void daObjMovebox::Bgc_c::proc_vertical(daObjMovebox::Act_c* i_actor) {
    State_e var_r29 = mState;
    mState = STATE_0_e;

    int check_num = i_actor->attr().field_0x9e ? 21 : 5;
    const BgcSrc_c* pbgc = i_actor->attr().field_0x9e ? M_lin20 : M_lin5;

    gnd_pos(i_actor, pbgc, check_num, 100.0f);

    if (field_0x5c >= 0 && field_0x0[field_0x5c] > i_actor->current.pos.y) {
        i_actor->current.pos.y = field_0x0[field_0x5c];
        cLib_onBit<State_e>(mState, STATE_1_e);
        i_actor->speed.y = 0.0f;
    }

    wrt_pos(i_actor->current.pos);

    if (cLib_checkBit<State_e>(mState, STATE_8_e) && field_0x60 > i_actor->current.pos.y) {
        cLib_onBit<State_e>(mState, STATE_10_e);
    }

    if (!cLib_checkBit<State_e>(mState, STATE_1_e) && cLib_checkBit<State_e>(var_r29, STATE_1_e)) {
        cLib_onBit<State_e>(mState, STATE_2_e);
        i_actor->speed.y = i_actor->attr().mFallYInitSpeed;
    }

    if (cLib_checkBit<State_e>(mState, STATE_1_e) && !cLib_checkBit<State_e>(var_r29, STATE_1_e)) {
        cLib_onBit<State_e>(mState, STATE_4_e);
    }

    if (cLib_checkBit<State_e>(mState, STATE_10_e) && !cLib_checkBit<State_e>(var_r29, STATE_10_e))
    {
        cLib_onBit<State_e>(mState, STATE_20_e);
    }

    if (cLib_checkBit<State_e>(mState, STATE_1_e) && field_0x5c >= 0) {
        dComIfG_Bgsp().RideCallBack(M_gnd_work[field_0x5c], i_actor);
    }
}

/* 8047E2D4-8047E350 0008D4 007C+00 2/2 0/0 0/0 .text
 * chk_wall_pre__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cis */
bool daObjMovebox::Bgc_c::chk_wall_pre(daObjMovebox::Act_c const* i_actor,
                                       daObjMovebox::BgcSrc_c const* i_bgcSrc, int i_num,
                                       s16 param_3) {
    wall_pos(i_actor, i_bgcSrc, i_num, param_3, i_actor->attr().mUnitDistance - 1.0f);
    return field_0x178 >= 0;
}

/* 8047E350-8047E5A0 000950 0250+00 1/1 0/0 0/0 .text
 * chk_wall_touch__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cs */
bool daObjMovebox::Bgc_c::chk_wall_touch(daObjMovebox::Act_c const* i_actor,
                                         daObjMovebox::BgcSrc_c const* i_bgcSrc, s16 param_2) {
    static dBgS_ObjLinChk touch_work;

    const s16 sp8C = i_actor->home.angle.y + param_2;

    cXyz sp38;
    cXyz sp44;
    cXyz sp50;
    cXyz sp5C;
    cXyz sp68;

    mDoMtx_stack_c::YrotS(sp8C);
    mDoMtx_stack_c::XrotM(0x4000);
    sp50.set(i_bgcSrc->field_0xc, 0.0f, i_bgcSrc->field_0x8);
    mDoMtx_stack_c::multVec(&cXyz::BaseY, &sp68);
    sp68 *= i_actor->attr().field_0x70 * 0.5f + 10.0f;

    mDoMtx_stack_c::XrotM(0x4000);
    sp50.set(i_bgcSrc->field_0xc, 0.0f, i_bgcSrc->field_0x8);
    mDoMtx_stack_c::multVec(&sp50, &sp5C);
    mDoMtx_stack_c::YrotS(sp8C);

    mDoMtx_stack_c::transM(sp5C);
    mDoMtx_stack_c::scaleM(i_actor->attr().field_0x70, i_actor->attr().field_0x64,
                           i_actor->attr().field_0x70);
    mDoMtx_stack_c::transM(0.0f, 0.5f, 0.0f);
    mDoMtx_stack_c::XrotM(0x4000);

    sp50.set(i_bgcSrc->field_0x4, 0.0f, i_bgcSrc->field_0x0);
    mDoMtx_stack_c::multVec(&sp50, &sp38);
    sp38 += i_actor->current.pos;
    sp44 = sp38 + sp68;

    touch_work.SetActorPid(i_actor->mBase.mBsPcId);
    touch_work.Set(&sp38, &sp44, i_actor);
    return dComIfG_Bgsp().LineCross(&touch_work);
}

/* 8047E5A0-8047E628 000BA0 0088+00 1/1 0/0 0/0 .text
 * chk_wall_touch2__Q212daObjMovebox5Bgc_cFPCQ212daObjMovebox5Act_cPCQ212daObjMovebox8BgcSrc_cis */
bool daObjMovebox::Bgc_c::chk_wall_touch2(daObjMovebox::Act_c const* i_actor,
                                          daObjMovebox::BgcSrc_c const* i_bgcSrc, int i_num,
                                          s16 param_3) {
    bool chk = false;
    for (int i = 0; i < i_num; i++) {
        if (chk_wall_touch(i_actor, &i_bgcSrc[i], param_3)) {
            chk = true;
            break;
        }
    }

    return chk;
}

/* 8047E628-8047E650 000C28 0028+00 4/4 0/0 0/0 .text prm_get_swSave1__Q212daObjMovebox5Act_cCFv
 */
int daObjMovebox::Act_c::prm_get_swSave1() const {
    return prm_get_swSave();
}

/* 8047E650-8047E680 000C50 0030+00 1/1 0/0 0/0 .text            prmZ_init__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::prmZ_init() {
    if (!field_0x900) {
        field_0x900 = 1;

        if (prm_get_dmy()) {
            mPrmZ = 0xFFFF;
        } else {
            mPrmZ = home.angle.z;
        }

        home.angle.z = 0;
        current.angle.z = 0;
        shape_angle.z = 0;
    }
}

/* 8047E680-8047E6B0 000C80 0030+00 1/1 0/0 0/0 .text            prmX_init__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::prmX_init() {
    if (!field_0x901) {
        mPrmX = home.angle.x;
        field_0x901 = 1;
    }

    home.angle.x = 0;
    current.angle.x = 0;
    shape_angle.x = 0;
}

/* 80481104-80481124 -00001 0020+00 3/3 0/0 0/0 .rodata          M_arcname__Q212daObjMovebox5Act_c
 */
SECTION_RODATA const char* daObjMovebox::Act_c::M_arcname[8] = {
    "Kkiba_00", "Osiblk", "H_Box20", "A_SMBlock", "P_Lv4blk", "P_Lv4blk2", "H_OsiHaka", "dummy4",
};

/* 80481124-80481168 0001FC 0044+00 0/1 0/0 0/0 .rodata          M_cyl_src__Q212daObjMovebox5Act_c
 */
const dCcD_SrcCyl daObjMovebox::Act_c::M_cyl_src = {
    {
        0,
        {{0, 0, 0}, {0xD8FAFDBF, 0x11}, {0x78}},  // mObj
        {dCcD_SE_NONE, 0, 0, 0, 0},               // mGObjAt
        {dCcD_SE_NONE, 0, 0, 0, 0},               // mGObjTg
        {0},                                      // mGObjCo
    },                                            // mObjInf
    {
        {0.0f, 0.0f, 0.0f},  // mCenter
        75.0f,               // mRadius
        150.0f,              // mHeight
    }  // mCyl
};

/* 80481168-80481668 000240 0500+00 6/18 0/0 0/0 .rodata          M_attr__Q212daObjMovebox5Act_c */
const daObjMovebox::Hio_c::Attr_c daObjMovebox::Act_c::M_attr[8] = {
    {
        0x6,     0xE,     0xA,     0x6,           0xE,    0xA,           75.0f,  90.0f,   -3.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          3.9f,   -0.39f,        -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0xC00,   150.0f,  150.0f,  0.0066666668f, 150.0f, 0.0066666668f, 150.0f, 0x8013C, 0x8013D,
        0x80151, 0x8002A, 0x8002D, 0xFFA6,        0xFFFF, 0xFFA6,        0x5A,   0x97,    0x5A,
        0,       0,       0,
    },
    {
        0x8,     0x13,    0xD,     0x8,           0x13,   0xD,           75.0f,  90.0f,   -5.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          4.5f,   -0.5f,         -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0xC00,   150.0f,  150.0f,  0.0066666668f, 150.0f, 0.0066666668f, 150.0f, 0x20038, 0x20039,
        0x8002F, 0x8002B, 0x8002E, 0xFFA6,        0xFFFF, 0xFFA6,        0x5A,   0x97,    0x5A,
        0,       0,       0,
    },
    {
        0x8,    0x13,   0xD,    0x8,    0x13,    0xD,     50.0f,   110.0f,  -5.0f,   0.005f,
        0.001f, 0.0f,   1.8f,   4.5f,   -0.5f,   -0.2f,   0.02f,   0x3E8,   0.04f,   0.013f,
        0.15f,  0.1f,   0.1f,   0.06f,  0.075f,  4,       7,       0x1000,  200.0f,  200.0f,
        0.005f, 200.0f, 0.005f, 200.0f, 0x80154, 0x80155, 0x8002F, 0x8002B, 0x8002E, 0xFF92,
        0xFFFF, 0xFF92, 0x6E,   0xD2,   0x6E,    0,       1,       0,
    },
    {
        0x8,     0x13,    0xD,     0x8,           0x13,   0xD,           75.0f,  180.0f,  -5.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          4.5f,   -0.5f,         -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0xC00,   300.0f,  300.0f,  0.0033333334f, 300.0f, 0.0033333334f, 300.0f, 0x20038, 0x20039,
        0x8002F, 0x8002B, 0x8002E, 0xFF4C,        0xFFFF, 0xFF4C,        0xB4,   0x136,   0xB4,
        0,       0,       0,
    },
    {
        0x8,     0x13,    0xD,     0x8,           0x13,   0xD,           75.0f,  180.0f,  -5.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          4.5f,   -0.5f,         -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0x2670,  300.0f,  300.0f,  0.0033333334f, 300.0f, 0.0033333334f, 300.0f, 0x20038, 0x20039,
        0x8002F, 0x8002B, 0x8002E, 0xFF4C,        0xFFFF, 0xFF4C,        0xB4,   0x136,   0xB4,
        0,       0,       0,
    },
    {
        0x8,     0x13,    0xD,     0x8,           0x13,   0xD,           75.0f,  90.0f,   -5.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          4.5f,   -0.5f,         -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0xC00,   150.0f,  150.0f,  0.0066666668f, 150.0f, 0.0066666668f, 150.0f, 0x20038, 0x20039,
        0x8002F, 0x8002B, 0x8002E, 0xFFA6,        0xFFFF, 0xFFA6,        0x5A,   0x168,   0x5A,
        0,       0,       0,
    },
    {
        0x8,    0x13,   0xD,           0x8,    0x13,    0xD,     50.0f,   90.0f,   -3.0f,   0.005f,
        0.001f, 0.0f,   1.8f,          3.9f,   -0.39f,  -0.2f,   0.02f,   0x3E8,   0.04f,   0.013f,
        0.15f,  0.1f,   0.1f,          0.06f,  0.075f,  4,       7,       0x1620,  200.0f,  200.0f,
        0.005f, 230.0f, 0.0043478259f, 100.0f, 0x8013C, 0x8013D, 0x80151, 0x8002A, 0x8002D, 0xFF7E,
        0xFFF6, 0xFFC4, 0x82,          0xD2,   0x3C,    0,       1,       0,
    },
    {
        0x4,     0x4,     0x14,    0x4,           0x4,    0x14,          75.0f,  90.0f,   -3.0f,
        0.005f,  0.001f,  0.0f,    1.8f,          3.9f,   -0.39f,        -0.2f,  0.02f,   0x3E8,
        0.04f,   0.013f,  0.15f,   0.1f,          0.1f,   0.06f,         0.075f, 4,       7,
        0x1620,  150.0f,  150.0f,  0.0066666668f, 150.0f, 0.0066666668f, 150.0f, 0x8013C, 0x8013D,
        0x80151, 0x8002A, 0x8002D, 0xFFA6,        0xFFFF, 0xFFA6,        0x5A,   0x97,    0x5A,
        0,       0,       0,
    },
};

/* 8047E6B0-8047E6C8 000CB0 0018+00 5/5 0/0 0/0 .text            attr__Q212daObjMovebox5Act_cCFv */
const daObjMovebox::Hio_c::Attr_c& daObjMovebox::Act_c::attr() const {
    return M_attr[mType];
}

/* 8047E6C8-8047E7B0 000CC8 00E8+00 2/2 0/0 0/0 .text            set_mtx__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::set_mtx() {
    bool var_r29 = field_0x5ac == 2;

    mDoMtx_stack_c::transS(current.pos);

    if (var_r29) {
        cXyz sp28(field_0x8c8, 1.0f, field_0x8cc);
        mDoMtx_stack_c::transM(0.0f, field_0x8d8, 0.0f);

        Quaternion quat;
        daObj::quat_rotBaseY(&quat, sp28);
        mDoMtx_stack_c::quatM(&quat);
    }

    mDoMtx_stack_c::ZXYrotM(shape_angle);

    if (var_r29) {
        mDoMtx_stack_c::transM(0.0f, -field_0x8d8, 0.0f);
    }

    if (mpModel != NULL) {
        mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
    }

    cMtx_copy(mDoMtx_stack_c::get(), mBgMtx);
}

/* 8047E7B0-8047E7F4 000DB0 0044+00 1/1 0/0 0/0 .text            init_mtx__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::init_mtx() {
    if (mpModel != NULL) {
        mpModel->setBaseScale(scale);
    }

    set_mtx();
}

/* 8047E7F4-8047E92C 000DF4 0138+00 1/1 0/0 0/0 .text            path_init__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::path_init() {
    int path_id = prmZ_get_pathId();
    int sw1 = prm_get_swSave1();

    if (path_id != 0xFF && sw1 != 0xFF) {
        int sw2 = prmZ_get_swSave2();
        bool is_sw1 = is_switch1();
        bool var_r22 = sw2 == 0xFF ? false : is_switch2();

        int pnt_no = 0;
        if (is_sw1) {
            pnt_no++;
        }

        if (var_r22) {
            pnt_no += 2;
        }

        mpPath = dPath_GetRoomPath(path_id, fopAcM_GetHomeRoomNo(this));
        dStage_dPnt_c* point = dPath_GetPnt(mpPath, pnt_no);
        home.pos.set(point->m_position);
        current.pos.set(point->m_position);
    }
}

/* 8047E92C-8047EB48 000F2C 021C+00 1/1 0/0 0/0 .text            path_save__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::path_save() {
    int path_id = prmZ_get_pathId();
    int sw1 = prm_get_swSave1();
    u8 answer = prm_get_answer();

    if (path_id != 0xFF && sw1 != 0xFF) {
        int sw2 = prmZ_get_swSave2();

        int var_r27 = sw2 == 0xFF ? 2 : 4;
        if (var_r27 > mpPath->m_num) {
            var_r27 = mpPath->m_num;
        }

        int var_r29 = 0;
        for (; var_r29 < var_r27; var_r29++) {
            dStage_dPnt_c* pnt = dPath_GetPnt(mpPath, var_r29);
            cXyz sp38;
            sp38.set(pnt->m_position);

            if (current.pos.abs2(sp38) < 9.0f) {
                break;
            }
        }

        if (var_r29 < var_r27) {
            if (var_r29 & 1) {
                on_switch1();
            } else {
                off_switch1();
            }

            if (sw2 != 0xFF) {
                if (var_r29 & 2) {
                    on_switch2();
                } else {
                    off_switch2();
                }
            }
        }

        if (answer != 0xF) {
            int var_r28 = 0;
            if (is_switch1()) {
                var_r28++;
            }

            if (is_switch2()) {
                var_r28 += 2;
            }

            if (answer == var_r28) {
                mpBgW->OffPushPullOk();
            }
        }
    }
}

/* 8047EB48-8047EBEC 001148 00A4+00 1/0 0/0 0/0 .text CreateHeap__Q212daObjMovebox5Act_cFv */
int daObjMovebox::Act_c::CreateHeap() {
    BOOL var_r29 = true;

    if (i_attr().field_0x58 >= 0) {
        J3DModelData* modelData =
            (J3DModelData*)dComIfG_getObjectRes(M_arcname[mType], i_attr().field_0x58);
        JUT_ASSERT(modelData != 0);

        mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
        var_r29 = mpModel != NULL;
    } else {
        mpModel = NULL;
    }

    return var_r29;
}

/* 8047EBEC-8047ED10 0011EC 0124+00 1/1 0/0 0/0 .text
 * RideCallBack__Q212daObjMovebox5Act_cFP4dBgWP10fopAc_ac_cP10fopAc_ac_c */
void daObjMovebox::Act_c::RideCallBack(dBgW* i_bgw, fopAc_ac_c* i_actor, fopAc_ac_c* i_rideActor) {
    i_bgw;  // affects stack
    Act_c* a_this = (Act_c*)i_actor;

    if (a_this->field_0x5ac == 2) {
        f32 var_f31;
        f32 var_f30;
        f32 var_f26;
        f32 var_f29;
        f32 var_f28;
        f32 var_f27;

        var_f26 = a_this->i_attr().mPlayerGravity + a_this->i_attr().mMiscGravity;
        var_f29 = i_rideActor->current.pos.x - a_this->current.pos.x;
        var_f28 = i_rideActor->current.pos.z - a_this->current.pos.z;

        if (fopAcM_GetProfName(i_rideActor) == PROC_ALINK) {
            var_f30 = a_this->i_attr().mPlayerGravity;
            var_f27 = a_this->i_attr().field_0x74 * a_this->i_attr().mPlayerTiltPower;
        } else {
            var_f30 = a_this->i_attr().mMiscGravity;
            var_f27 = a_this->i_attr().field_0x74 * a_this->i_attr().mMiscTiltPower;
        }

        var_f31 = 1.0f - (JMAFastSqrt(var_f29 * var_f29 + var_f28 * var_f28) *
                          a_this->i_attr().field_0x74);
        var_f31 = (var_f31 * 0.9f) + 0.1f;
        if (var_f31 < 0.0f) {
            var_f31 = 0.0f;
        }

        var_f30 *= var_f31;

        a_this->field_0x8bc += var_f30;
        if (a_this->field_0x8bc < var_f26) {
            a_this->field_0x8bc = var_f26;
        }

        a_this->field_0x8c0 += var_f27 * var_f29;
        a_this->field_0x8c4 += var_f27 * var_f28;
    } else if (fopAcM_GetProfName(i_rideActor) == PROC_Obj_Movebox) {
        cLib_onBit<daObjMovebox::Bgc_c::State_e>(a_this->mBgc.mState,
                                                 daObjMovebox::Bgc_c::STATE_40_e);
    }
}

enum MOVE_DIR {
    DIR_SOUTH,
    DIR_EAST,
    DIR_NORTH,
    DIR_WEST,
};

/* 8047ED10-8047EE0C 001310 00FC+00 1/1 0/0 0/0 .text
 * PPCallBack__Q212daObjMovebox5Act_cFP10fopAc_ac_cP10fopAc_ac_csQ29dBgW_Base13PushPullLabel */
fopAc_ac_c* daObjMovebox::Act_c::PPCallBack(fopAc_ac_c* i_bgActor, fopAc_ac_c* i_pushActor,
                                            s16 i_angle, dBgW_Base::PushPullLabel i_pplabel) {
    Act_c* a_this = (Act_c*)i_bgActor;
    dBgW::PushPullLabel var_r26 = cLib_checkBit<dBgW::PushPullLabel>(
        i_pplabel, (dBgW::PushPullLabel)(dBgW::PPLABEL_PUSH | dBgW::PPLABEL_PULL));

    bool sp34;
    if (a_this->i_attr().field_0x9e) {
        sp34 = cLib_checkBit<dBgW::PushPullLabel>(i_pplabel, dBgW::PPLABEL_HEAVY) != 0;
    } else {
        sp34 = true;
    }

    if (var_r26 != 0 && sp34) {
        s16 var_r29 = (s16)(cLib_checkBit<dBgW::PushPullLabel>(var_r26, dBgW::PPLABEL_PULL) ?
                                i_angle - 0x8000 :
                                i_angle) -
                      a_this->home.angle.y;

        a_this->mPPLabel = i_pplabel;

        int move_dir;
        if (var_r29 >= -0x2000 && var_r29 < 0x2000) {
            move_dir = DIR_SOUTH;
        } else if (var_r29 >= 0x2000 && var_r29 < 0x6000) {
            move_dir = DIR_EAST;
        } else if (var_r29 >= 0x6000 || var_r29 < -0x6000) {
            move_dir = DIR_NORTH;
        } else {
            move_dir = DIR_WEST;
        }

        for (int i = 0; i < 4; i++) {
            if (i == move_dir) {
                a_this->field_0x8f0[i]++;
            } else {
                a_this->field_0x8f0[i] = 0;
            }
        }

        a_this->field_0x8fe = 1;
    }
}

/* 8047EE0C-8047F11C 00140C 0310+00 1/0 0/0 0/0 .text            Create__Q212daObjMovebox5Act_cFv */
int daObjMovebox::Act_c::Create() {
    field_0x8b8 = 0;
    field_0x8bc = 0.0f;
    field_0x8c0 = 0.0f;
    field_0x8c4 = 0.0f;
    field_0x8c8 = 0.0f;
    field_0x8cc = 0.0f;
    field_0x8d0 = 0.0f;
    field_0x8d4 = 0.0f;
    field_0x8d8 = i_attr().field_0x68 * 0.5f;
    field_0x8dc = 0;
    field_0x8e0 = 0;
    field_0x8e4 = 0.0f;
    field_0x8e8 = -1;
    mPPLabel = dBgW::PPLABEL_NONE;

    clr_moment_cnt();

    field_0x8f8 = 0;
    field_0x8fa = 0;
    field_0x8fc = 20;
    field_0x8fe = 0;

    mpBgW->SetRideCallback(RideCallBack);
    mpBgW->SetPushPullCallback(PPCallBack);

    mCcStts.Init(0xFF, 0xFF, this);
    mCcCyl.Set(M_cyl_src);
    mCcCyl.SetStts(&mCcStts);
    mCcCyl.SetTgVec(const_cast<cXyz&>(cXyz::Zero));
    mCcCyl.OnTgNoHitMark();
    mCcCyl.OffCoSPrmBit(1);

    fopAcM_SetMtx(this, mBgMtx);

    fopAcM_setCullSizeBox(this, i_attr().field_0x90, i_attr().field_0x92, i_attr().field_0x94,
                          i_attr().field_0x96, i_attr().field_0x98, i_attr().field_0x9a);
    fopAcM_SetSpeedF(this, 0.0f);
    fopAcM_SetGravity(this, i_attr().mGravity);
    fopAcM_posMoveF(this, NULL);

    mBgc.proc_vertical(this);
    cLib_offBit<daObjMovebox::Bgc_c::State_e>(
        mBgc.mState, (daObjMovebox::Bgc_c::State_e)(daObjMovebox::Bgc_c::STATE_20_e |
                                                    daObjMovebox::Bgc_c::STATE_4_e |
                                                    daObjMovebox::Bgc_c::STATE_2_e));
    field_0x902 = 1;
    mReverb = dComIfGp_getReverb(home.roomNo);

    u8 answer = prm_get_answer();
    int var_r30 = 0;
    if (is_switch1()) {
        var_r30++;
    }

    if (is_switch2()) {
        var_r30 += 2;
    }

    if (answer != 0xF && answer == var_r30) {
        mpBgW->OffPushPullOk();
    }

    init_mtx();
    mpBgW->Move();
    field_0x904 = 0;
    eyePos = current.pos;

    mode_wait_init();
    return 1;
}

/* 8047F11C-8047F38C 00171C 0270+00 1/1 0/0 0/0 .text            afl_sway__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::afl_sway() {
    f32 var_f31 = field_0x8c0 * field_0x8c0 + field_0x8c4 * field_0x8c4;
    f32 var_f29 = i_attr().mMaxTiltPower * i_attr().mMaxTiltPower;

    const BgcSrc_c* pbgc = i_attr().field_0x9e ? mBgc.M_lin20 : mBgc.M_lin5;
    int check_num = i_attr().field_0x9e ? 21 : 5;

    bool var_r22 = true;
    if (!mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[0]) &&
        !mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[2]))
    {
        var_r22 = false;
    }

    bool var_r21 = true;
    if (!mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[1]) &&
        !mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[3]))
    {
        var_r21 = false;
    }

    if (var_f31 > var_f29) {
        f32 var_f30 = i_attr().mMaxTiltPower / JMAFastSqrt(var_f31);
        field_0x8c0 *= var_f30;
        field_0x8c4 *= var_f30;
    }

    f32 var_f24 = field_0x8c8 - field_0x8c0;
    f32 var_f23 = field_0x8cc - field_0x8c4;

    f32 var_f28 = i_attr().mTiltSpringFactor * -var_f24;
    f32 var_f27 = i_attr().mTiltSpringFactor * -var_f23;
    f32 var_f26 = field_0x8d0 * -i_attr().mTiltViscoscityResistance;
    f32 var_f25 = field_0x8d4 * -i_attr().mTiltViscoscityResistance;

    field_0x8d0 += var_f28 * var_f26;
    field_0x8d4 += var_f27 * var_f25;
    field_0x8c8 += field_0x8d0;
    field_0x8cc += field_0x8d4;

    if (var_r21) {
        field_0x8c8 = 0.0f;
    }

    if (var_r22) {
        field_0x8cc = 0.0f;
    }

    field_0x8c0 = 0.0f;
    field_0x8c4 = 0.0f;
}

/* #pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void daObjMovebox::Act_c::afl_sway() {
    nofralloc
#include "asm/rel/d/a/obj/d_a_obj_movebox/d_a_obj_movebox/afl_sway__Q212daObjMovebox5Act_cFv.s"
}
#pragma pop */

/* 8047F38C-8047F50C 00198C 0180+00 1/1 0/0 0/0 .text check_to_walk__Q212daObjMovebox5Act_cFv */
int daObjMovebox::Act_c::check_to_walk() {
    int var_r27 = -1;
    bool var_r26 = true;

    if (field_0x8fe != 0 &&
        cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState, daObjMovebox::Bgc_c::STATE_1_e) &&
        !cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState, daObjMovebox::Bgc_c::STATE_40_e))
    {
        dBgW::PushPullLabel sp28 = cLib_checkBit<dBgW::PushPullLabel>(mPPLabel, dBgW::PPLABEL_PULL);
        dBgW::PushPullLabel var_r25 = cLib_checkBit<dBgW::PushPullLabel>(mPPLabel, dBgW::PPLABEL_4);

        s16 var_r28;
        if (sp28) {
            if (var_r25) {
                var_r28 = i_attr().mFirstPullStopTime;
            } else {
                var_r28 = i_attr().mRepeatPullStopTime;
            }
        } else {
            if (var_r25) {
                var_r28 = i_attr().mFirstPushStopTime;
            } else {
                var_r28 = i_attr().mRepeatPushStopTime;
            }
        }

        for (int i = 0; i < 4; i++) {
            if (field_0x8f0[i] >= var_r28) {
                const BgcSrc_c* pbgc = i_attr().field_0x9e ? mBgc.M_lin20 : mBgc.M_lin5;
                int check_num = i_attr().field_0x9e ? 21 : 5;

                if (!mBgc.chk_wall_pre(this, pbgc, check_num, M_dir_base[i])) {
                    var_r27 = i;
                }
            } else {
                var_r26 = false;
            }
        }
    }

    if (var_r26) {
        clr_moment_cnt();
    }

    field_0x8fe = 0;
    return var_r27;
}

/* #pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm int daObjMovebox::Act_c::check_to_walk() {
    nofralloc
#include "asm/rel/d/a/obj/d_a_obj_movebox/d_a_obj_movebox/check_to_walk__Q212daObjMovebox5Act_cFv.s"
}
#pragma pop */

/* 8047F50C-8047F530 001B0C 0024+00 3/3 0/0 0/0 .text clr_moment_cnt__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::clr_moment_cnt() {
    for (int i = 0; i < 4; i++) {
        field_0x8f0[i] = 0;
    }
}

/* 8047F530-8047F5CC 001B30 009C+00 1/1 0/0 0/0 .text chk_appear__Q212daObjMovebox5Act_cCFv */
bool daObjMovebox::Act_c::chk_appear() const {
    int path_id = prmZ_get_pathId();
    int sw1 = prm_get_swSave1();

    if (path_id != 0xFF || sw1 == 0xFF) {
        return true;
    }

    BOOL is_sw1 = is_switch1();
    BOOL temp_r29 = prm_get_dmy();

    return (!is_sw1 && !temp_r29) || (is_sw1 && temp_r29);
}

/* #pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm BOOL daObjMovebox::Act_c::chk_appear() const {
    nofralloc
#include "asm/rel/d/a/obj/d_a_obj_movebox/d_a_obj_movebox/chk_appear__Q212daObjMovebox5Act_cCFv.s"
}
#pragma pop */

/* 8047F5CC-8047F634 001BCC 0068+00 1/1 0/0 0/0 .text
 * eff_smoke_slip_start__Q212daObjMovebox5Act_cFv               */
void daObjMovebox::Act_c::eff_smoke_slip_start() {
    static cXyz scl(0.6f, 0.6f, 0.6f);

    s16 var_r30 = cLib_checkBit<dBgW::PushPullLabel>(mPPLabel, dBgW::PPLABEL_PULL) != 0 ?
                      i_attr().mPushMoveTime :
                      i_attr().mPullMoveTime;
}

/* 8047F634-8047F6A8 001C34 0074+00 3/3 0/0 0/0 .text mode_wait_init__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::mode_wait_init() {
    fopAcM_SetSpeedF(this, 0.0f);
    fopAcM_SetGravity(this, i_attr().mGravity);
    mpBgW->SetCrrFunc(dBgS_MoveBGProc_Trans);
    clr_moment_cnt();
    field_0x8e8 = -1;
    field_0x5ac = 0;
}

/* 8047F6A8-8047F8D4 001CA8 022C+00 1/0 0/0 0/0 .text            mode_wait__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::mode_wait() {
    if (field_0x8fa > 0) {
        field_0x8fa--;
    }

    int var_r30 = check_to_walk();
    if (field_0x902 == 0 &&
        cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState, daObjMovebox::Bgc_c::STATE_1_e))
    {
        field_0x902 = 1;
        path_save();
    }

    daObj::posMoveF_stream(this, NULL, &cXyz::Zero, i_attr().mViscosityResistance,
                           i_attr().mInertiaResistance);

    cXyz sp48;
    mDoMtx_stack_c::transS(home.pos);
    mDoMtx_stack_c::YrotM(home.angle.y);
    mDoMtx_stack_c::transM(field_0x8dc * i_attr().mUnitDistance, 0.0f,
                           field_0x8e0 * i_attr().mUnitDistance);
    mDoMtx_stack_c::multVecZero(&sp48);

    current.pos.x = sp48.x;
    current.pos.z = sp48.z;

    if (var_r30 != -1) {
        field_0x8e8 = var_r30;
        eff_smoke_slip_start();
        ((daPy_py_c*)dComIfGp_getPlayer(0))->onPushPullKeep();

        mode_walk_init();

        if (cLib_checkBit<dBgW::PushPullLabel>(mPPLabel, dBgW::PPLABEL_PULL)) {
            field_0x8f8 = i_attr().mPullMoveTime;
            field_0x8e4 = 32768.0f / i_attr().mPullMoveTime;
        } else {
            field_0x8f8 = i_attr().mPushMoveTime;
            field_0x8e4 = 32768.0f / i_attr().mPushMoveTime;
        }
    }
}

/* 8047F8D4-8047F8F4 001ED4 0020+00 1/1 0/0 0/0 .text mode_walk_init__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::mode_walk_init() {
    fopAcM_SetSpeedF(this, 0.0f);
    field_0x902 = 0;
    field_0x5ac = 1;
}

/* 8047F8F4-8047FCBC 001EF4 03C8+00 1/0 0/0 0/0 .text            mode_walk__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::mode_walk() {
    static cXyz dir_vec[] = {
        cXyz(0.0f, 0.0f, 1.0f),
        cXyz(1.0f, 0.0f, 0.0f),
        cXyz(0.0f, 0.0f, -1.0f),
        cXyz(-1.0f, 0.0f, 0.0f),
    };

    bool var_r28 = --field_0x8f8 <= 0;
    f32 var_f31 = (cM_scos(field_0x8f8 * field_0x8e4) + 1.0f) * 0.5f;

    cXyz sp78;
    mDoMtx_stack_c::transS(home.pos);
    mDoMtx_stack_c::YrotM(home.angle.y);
    mDoMtx_stack_c::transM(
        (field_0x8dc + var_f31 * dir_vec[field_0x8e8].x) * i_attr().mUnitDistance, 0.0f,
        (field_0x8e0 + var_f31 * dir_vec[field_0x8e8].z) * i_attr().mUnitDistance);
    mDoMtx_stack_c::multVecZero(&sp78);

    current.pos.x = sp78.x;
    current.pos.z = sp78.z;
    eyePos = current.pos;

    sound_slip();

    if (var_r28) {
        const BgcSrc_c* pbgc = i_attr().field_0x9e ? mBgc.M_lin20 : mBgc.M_lin5;
        int check_num = i_attr().field_0x9e ? 21 : 5;

        if (mBgc.chk_wall_pre(this, pbgc, check_num, M_dir_base[field_0x8e8])) {
            sound_limit();
        }
    }

    daObj::posMoveF_stream(this, NULL, &cXyz::Zero, i_attr().mViscosityResistance,
                           i_attr().mInertiaResistance);

    current.pos.x = sp78.x;
    current.pos.z = sp78.z;

    if (var_r28) {
        if (field_0x8e8 == 0) {
            field_0x8e0++;
        } else if (field_0x8e8 == 1) {
            field_0x8dc++;
        } else if (field_0x8e8 == 2) {
            field_0x8e0--;
        } else if (field_0x8e8 == 3) {
            field_0x8dc--;
        }

        ((daPy_py_c*)dComIfGp_getPlayer(0))->offPushPullKeep();
        mode_wait_init();
    }
}

/* 8047FCBC-8047FCE4 0022BC 0028+00 1/1 0/0 0/0 .text mode_afl_init__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::mode_afl_init() {
    fopAcM_SetSpeedF(this, 0.0f);
    mpBgW->SetCrrFunc(dBgS_MoveBGProc_Trans);
    field_0x5ac = 2;
}

/* 8047FCE4-8047FEE4 0022E4 0200+00 1/0 0/0 0/0 .text            mode_afl__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::mode_afl() {
    f32 var_f31;
    f32 var_f30 = current.pos.y - mBgc.field_0x60;
    if (var_f30 > 0.0f) {
        var_f31 = 0.0f;
    } else if (var_f30 > -i_attr().field_0x68) {
        var_f31 = 1.0f;
    } else {
        var_f31 = -var_f30 * i_attr().field_0x6c;
    }

    field_0x8b8 += i_attr().mWaterOscillationAngleSpeed * (cM_rnd() + 1.0f);
    fopAcM_SetGravity(this, field_0x8bc + var_f31 * i_attr().mBuoyancy +
                                i_attr().mGravity * cM_ssin(field_0x8b8));
    field_0x8bc = 0.0f;

    if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState, daObjMovebox::Bgc_c::STATE_1_e)) {
        afl_sway();
    }
}

/* #pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void daObjMovebox::Act_c::mode_afl() {
    nofralloc
#include "asm/rel/d/a/obj/d_a_obj_movebox/d_a_obj_movebox/mode_afl__Q212daObjMovebox5Act_cFv.s"
}
#pragma pop */

void daObjMovebox::Act_c::mode_proc_call() {
    typedef void (daObjMovebox::Act_c::*modeFunc)();
    static modeFunc mode_proc[] = {
        &daObjMovebox::Act_c::mode_wait,
        &daObjMovebox::Act_c::mode_walk,
        &daObjMovebox::Act_c::mode_afl,
    };

    (this->*mode_proc[field_0x5ac])();
}

/* 8047FF5C-80480020 00255C 00C4+00 1/1 0/0 0/0 .text sound_slip__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::sound_slip() {
    u32 var_r29 = 0;
    if (mBgc.field_0x5c >= 0) {
        const dBgS_ObjGndChk& chk = mBgc.M_gnd_work[mBgc.field_0x5c];
        int bg_index = chk.GetBgIndex();
        if (bg_index >= 0 && bg_index < 0x100) {
            var_r29 = dComIfG_Bgsp().GetMtrlSndId(chk);
        }
    }

    mDoAud_seStartLevel(i_attr().field_0x7c, &eyePos, var_r29, mReverb);
}

/* 80480020-804800E4 002620 00C4+00 1/1 0/0 0/0 .text sound_limit__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::sound_limit() {
    u32 var_r29 = 0;
    if (mBgc.field_0x178 >= 0) {
        const dBgS_ObjLinChk& chk = mBgc.M_wall_work[mBgc.field_0x178];
        int bg_index = chk.GetBgIndex();
        if (bg_index >= 0 && bg_index < 0x100) {
            var_r29 = dComIfG_Bgsp().GetMtrlSndId(chk);
        }
    }

    mDoAud_seStartLevel(i_attr().field_0x80, &eyePos, var_r29, mReverb);
}

/* 804800E4-804801A8 0026E4 00C4+00 1/1 0/0 0/0 .text sound_land__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::sound_land() {
    u32 var_r29 = 0;
    if (mBgc.field_0x5c >= 0) {
        const dBgS_ObjGndChk& chk = mBgc.M_gnd_work[mBgc.field_0x5c];
        int bg_index = chk.GetBgIndex();
        if (bg_index >= 0 && bg_index < 0x100) {
            var_r29 = dComIfG_Bgsp().GetMtrlSndId(chk);
        }
    }

    mDoAud_seStartLevel(i_attr().field_0x84, &eyePos, var_r29, mReverb);
}

/* 804801A8-804801FC 0027A8 0054+00 1/1 0/0 0/0 .text            vib_land__Q212daObjMovebox5Act_cFv
 */
void daObjMovebox::Act_c::vib_land() {
    dComIfGp_getVibration().StartShock(4, 31, cXyz(0.0f, 1.0f, 0.0f));
}

/* 8048168C-80481690 000764 0004+00 0/0 0/0 0/0 .rodata          @4774 */
#pragma push
#pragma force_active on
SECTION_RODATA static f32 const lit_4774 = 2.0f;
COMPILER_STRIP_GATE(0x8048168C, &lit_4774);
#pragma pop

/* 80481690-80481694 000768 0004+00 0/0 0/0 0/0 .rodata          @4775 */
#pragma push
#pragma force_active on
SECTION_RODATA static f32 const lit_4775 = 75.0f;
COMPILER_STRIP_GATE(0x80481690, &lit_4775);
#pragma pop

/* 804801FC-8048027C 0027FC 0080+00 1/1 0/0 0/0 .text eff_land_smoke__Q212daObjMovebox5Act_cFv */
void daObjMovebox::Act_c::eff_land_smoke() {
    daObjEff::Act_c::make_land_smoke(&current.pos, i_attr().mLandSmokeScale);
}

/* 80482BDC-80482BEC 00135C 000C+04 0/0 0/0 0/0 .bss             @4762 */
#pragma push
#pragma force_active on
static u8 lit_4762[12 + 4 /* padding */];
#pragma pop

/* 80482BEC-80482BF8 00136C 000C+00 0/0 0/0 0/0 .bss             particle_scale$4761 */
#pragma push
#pragma force_active on
static u8 particle_scale[12];
#pragma pop

/* 80482BF8-80482BFC 001378 0004+00 0/0 0/0 0/0 .bss
 * sInstance__40JASGlobalInstance<19JASDefaultBankTable>        */
#pragma push
#pragma force_active on
static u8 data_80482BF8[4];
#pragma pop

/* 80482BFC-80482C00 00137C 0004+00 0/0 0/0 0/0 .bss
 * sInstance__35JASGlobalInstance<14JASAudioThread>             */
#pragma push
#pragma force_active on
static u8 data_80482BFC[4];
#pragma pop

/* 80482C00-80482C04 001380 0004+00 0/0 0/0 0/0 .bss sInstance__27JASGlobalInstance<7Z2SeMgr> */
#pragma push
#pragma force_active on
static u8 data_80482C00[4];
#pragma pop

/* 80482C04-80482C08 001384 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8Z2SeqMgr> */
#pragma push
#pragma force_active on
static u8 data_80482C04[4];
#pragma pop

/* 80482C08-80482C0C 001388 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SceneMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C08[4];
#pragma pop

/* 80482C0C-80482C10 00138C 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2StatusMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C0C[4];
#pragma pop

/* 80482C10-80482C14 001390 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2DebugSys>
 */
#pragma push
#pragma force_active on
static u8 data_80482C10[4];
#pragma pop

/* 80482C14-80482C18 001394 0004+00 0/0 0/0 0/0 .bss
 * sInstance__36JASGlobalInstance<15JAISoundStarter>            */
#pragma push
#pragma force_active on
static u8 data_80482C14[4];
#pragma pop

/* 80482C18-80482C1C 001398 0004+00 0/0 0/0 0/0 .bss
 * sInstance__35JASGlobalInstance<14Z2SoundStarter>             */
#pragma push
#pragma force_active on
static u8 data_80482C18[4];
#pragma pop

/* 80482C1C-80482C20 00139C 0004+00 0/0 0/0 0/0 .bss
 * sInstance__33JASGlobalInstance<12Z2SpeechMgr2>               */
#pragma push
#pragma force_active on
static u8 data_80482C1C[4];
#pragma pop

/* 80482C20-80482C24 0013A0 0004+00 0/0 0/0 0/0 .bss sInstance__28JASGlobalInstance<8JAISeMgr> */
#pragma push
#pragma force_active on
static u8 data_80482C20[4];
#pragma pop

/* 80482C24-80482C28 0013A4 0004+00 0/0 0/0 0/0 .bss sInstance__29JASGlobalInstance<9JAISeqMgr> */
#pragma push
#pragma force_active on
static u8 data_80482C24[4];
#pragma pop

/* 80482C28-80482C2C 0013A8 0004+00 0/0 0/0 0/0 .bss
 * sInstance__33JASGlobalInstance<12JAIStreamMgr>               */
#pragma push
#pragma force_active on
static u8 data_80482C28[4];
#pragma pop

/* 80482C2C-80482C30 0013AC 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2SoundMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C2C[4];
#pragma pop

/* 80482C30-80482C34 0013B0 0004+00 0/0 0/0 0/0 .bss
 * sInstance__33JASGlobalInstance<12JAISoundInfo>               */
#pragma push
#pragma force_active on
static u8 data_80482C30[4];
#pragma pop

/* 80482C34-80482C38 0013B4 0004+00 0/0 0/0 0/0 .bss
 * sInstance__34JASGlobalInstance<13JAUSoundTable>              */
#pragma push
#pragma force_active on
static u8 data_80482C34[4];
#pragma pop

/* 80482C38-80482C3C 0013B8 0004+00 0/0 0/0 0/0 .bss
 * sInstance__38JASGlobalInstance<17JAUSoundNameTable>          */
#pragma push
#pragma force_active on
static u8 data_80482C38[4];
#pragma pop

/* 80482C3C-80482C40 0013BC 0004+00 0/0 0/0 0/0 .bss
 * sInstance__33JASGlobalInstance<12JAUSoundInfo>               */
#pragma push
#pragma force_active on
static u8 data_80482C3C[4];
#pragma pop

/* 80482C40-80482C44 0013C0 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SoundInfo>
 */
#pragma push
#pragma force_active on
static u8 data_80482C40[4];
#pragma pop

/* 80482C44-80482C48 0013C4 0004+00 0/0 0/0 0/0 .bss
 * sInstance__34JASGlobalInstance<13Z2SoundObjMgr>              */
#pragma push
#pragma force_active on
static u8 data_80482C44[4];
#pragma pop

/* 80482C48-80482C4C 0013C8 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2Audience>
 */
#pragma push
#pragma force_active on
static u8 data_80482C48[4];
#pragma pop

/* 80482C4C-80482C50 0013CC 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2FxLineMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C4C[4];
#pragma pop

/* 80482C50-80482C54 0013D0 0004+00 0/0 0/0 0/0 .bss sInstance__31JASGlobalInstance<10Z2EnvSeMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C50[4];
#pragma pop

/* 80482C54-80482C58 0013D4 0004+00 0/0 0/0 0/0 .bss sInstance__32JASGlobalInstance<11Z2SpeechMgr>
 */
#pragma push
#pragma force_active on
static u8 data_80482C54[4];
#pragma pop

/* 80482C58-80482C5C 0013D8 0004+00 0/0 0/0 0/0 .bss
 * sInstance__34JASGlobalInstance<13Z2WolfHowlMgr>              */
#pragma push
#pragma force_active on
static u8 data_80482C58[4];
#pragma pop

/* 8048027C-80480728 00287C 04AC+00 1/0 0/0 0/0 .text Execute__Q212daObjMovebox5Act_cFPPA3_A4_f */
int daObjMovebox::Act_c::Execute(Mtx** param_0) {
    if (field_0x908 != 0) {
        if (--field_0x908 == 0) {
            fopAcM_delete(this);
        }

        return 1;
    }

    if (mCcCyl.ChkTgHit()) {
        dCcD_GObjInf* hit_obj = mCcCyl.GetTgHitGObj();

        if (mCcCyl.ChkTgHit() && hit_obj != NULL) {
            if (!hit_obj->ChkAtType(AT_TYPE_LANTERN_SWING) && hit_obj->GetAtMtrl() == dCcD_MTRL_FIRE) {
                u32 params;
                daObjBurnBox_c::make_prm_burnbox(&params, 1);

                fopAcM_createChild(PROC_Obj_BurnBox, fopAcM_GetID(this), params, &current.pos,
                                   fopAcM_GetRoomNo(this), &shape_angle, &scale, -1, NULL);
                field_0x908 = 5;
            } else if (hit_obj->ChkAtType(AT_TYPE_BOMB) || hit_obj->ChkAtType(AT_TYPE_IRON_BALL)) {
                fopAc_ac_c* hit_ac = mCcCyl.GetTgHitAc();
                if (hit_ac != NULL && fopAcM_GetProfName(hit_ac) != PROC_Obj_Carry) {
                    cXyz sp48(current.pos);
                    J3DModelData* kibako_bmd =
                        (J3DModelData*)dComIfG_getObjectRes("Always", "BreakWoodBox.bmd");
                    JUT_ASSERT(kibako_bmd != 0);

                    s32 room_no = fopAcM_GetRoomNo(this);
                    JPABaseEmitter* emitter = dComIfGp_particle_set(
                        0x82AF, &sp48, NULL, NULL, 0xFF, dPa_modelEcallBack::getEcallback(),
                        room_no, NULL, NULL, &scale);
                    dPa_modelEcallBack::setModel(emitter, kibako_bmd, tevStr, 3, NULL, 0, 0);

                    for (int i = 0; i < 3; i++) {
                        static const u16 particle_id[] = {0x82AB, 0x82AC, 0x82AD};
                        dComIfGp_particle_set(particle_id[i], &sp48, NULL, &scale, 0xFF, NULL, -1,
                                              NULL, NULL, NULL);
                    }

                    fopAcM_delete(this);
                }
            }
        }
    }

    if (field_0x908 == 0) {
        if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState,
                                                        daObjMovebox::Bgc_c::STATE_20_e))
        {
            mDoAud_seStartLevel(i_attr().field_0x88, &eyePos, 0, mReverb);
        }

        if (field_0x5ac == 0) {
            if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState,
                                                            daObjMovebox::Bgc_c::STATE_10_e) &&
                field_0x8fa == 0)
            {
                if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState,
                                                                daObjMovebox::Bgc_c::STATE_1_e))
                {
                    if (i_attr().mBuoyancy + i_attr().mGravity > 0.0f) {
                        mode_afl_init();
                    }
                } else {
                    mode_afl_init();
                }
            }
        } else if (field_0x5ac == 2 && cLib_checkBit<daObjMovebox::Bgc_c::State_e>(
                                           mBgc.mState, daObjMovebox::Bgc_c::STATE_1_e))
        {
            mode_wait_init();
            field_0x8fa = 20;
        }

        mode_proc_call();

        mBgc.proc_vertical(this);
        if (mBgc.field_0x5c >= 0) {
            tevStr.mRoomNo = current.roomNo;
            tevStr.mEnvrIdxOverride = dComIfG_Bgsp().GetPolyColor(mBgc.M_gnd_work[mBgc.field_0x5c]);
        }

        if (field_0x8fc > 0) {
            field_0x8fc--;
        } else if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState,
                                                               daObjMovebox::Bgc_c::STATE_4_e))
        {
            sound_land();
            vib_land();

            if (!cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState,
                                                             daObjMovebox::Bgc_c::STATE_10_e))
            {
                eff_land_smoke();
            }
        }

        set_mtx();

        if (mType == 0) {
            mCcCyl.MoveCTg(current.pos);
            dComIfG_Ccsp()->Set(&mCcCyl);
        }
    }

    *param_0 = &mBgMtx;
    return 1;
}

/* 80480728-804808B4 002D28 018C+00 1/0 0/0 0/0 .text            Draw__Q212daObjMovebox5Act_cFv */
int daObjMovebox::Act_c::Draw() {
    if (mpModel != NULL) {
        g_env_light.settingTevStruct(0x10, &current.pos, &tevStr);
        g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);

        dComIfGd_setListBG();
        mDoExt_modelUpdateDL(mpModel);
        dComIfGd_setList();
    }

    if (i_attr().field_0x9d == 0 && mBgc.field_0x5c >= 0) {
        f32 var_f31 = mBgc.field_0x0[mBgc.field_0x5c];
        cM3dGPla sp40;

        if (dComIfG_Bgsp().GetTriPla(mBgc.M_gnd_work[mBgc.field_0x5c], &sp40) &&
            var_f31 != -1000000000.0f)
        {
            dComIfGd_setSimpleShadow(&current.pos, var_f31, i_attr().mShadowSize, &sp40.mNormal,
                                     shape_angle.y, -0.4f, NULL);
        }
    }

    return 1;
}

/* 804808FC-80480920 002EFC 0024+00 1/0 0/0 0/0 .text            Delete__Q212daObjMovebox5Act_cFv */
int daObjMovebox::Act_c::Delete() {
    if (mpBgW != NULL) {
        mpBgW->SetRideCallback(NULL);
        mpBgW->SetPushPullCallback(NULL);
    }

    return 1;
}

int daObjMovebox::Act_c::Mthd_Create() {
    fopAcM_SetupActor(this, daObjMovebox::Act_c);
    mType = prm_get_type();

    prmX_init();
    prmZ_init();

    if (!chk_appear()) {
        return cPhs_ERROR_e;
    }

    int phase_state = dComIfG_resLoad(&mPhase, M_arcname[mType]);
    if (phase_state == cPhs_COMPLEATE_e) {
        u32 heap_size = i_attr().field_0x60;
        path_init();

        phase_state = MoveBGCreate(M_arcname[mType], i_attr().field_0x5c, dBgS_MoveBGProc_Trans,
                                   heap_size, NULL);
        JUT_ASSERT((phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e));
    }
}

int daObjMovebox::Act_c::Mthd_Delete() {
    int rt = MoveBGDelete();
    dComIfG_resDelete(&mPhase, M_arcname[mType]);
    return rt;
}

namespace {
/* 80480920-80480AD4 002F20 01B4+00 1/0 0/0 0/0 .text
 * Mthd_Create__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */
int Mthd_Create(void* i_this) {
    return ((daObjMovebox::Act_c*)i_this)->Mthd_Create();
}

/* 80480BC0-80480C18 0031C0 0058+00 1/0 0/0 0/0 .text
 * Mthd_Delete__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */
int Mthd_Delete(void* i_this) {
    return ((daObjMovebox::Act_c*)i_this)->Mthd_Delete();
}

/* 80480C18-80480C38 003218 0020+00 1/0 0/0 0/0 .text
 * Mthd_Execute__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */
int Mthd_Execute(void* i_this) {
    return ((daObjMovebox::Act_c*)i_this)->MoveBGExecute();
}

/* 80480C38-80480C64 003238 002C+00 1/0 0/0 0/0 .text
 * Mthd_Draw__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */
int Mthd_Draw(void* i_this) {
    return ((daObjMovebox::Act_c*)i_this)->MoveBGDraw();
}

/* 80480C64-80480C90 003264 002C+00 1/0 0/0 0/0 .text
 * Mthd_IsDelete__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */
int Mthd_IsDelete(void* i_this) {
    return ((daObjMovebox::Act_c*)i_this)->MoveBGIsDelete();
}

/* 8048176C-8048178C -00001 0020+00 1/0 0/0 0/0 .data
 * Mthd_Table__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@  */
static actor_method_class Mthd_Table = {
    (process_method_func)Mthd_Create,  (process_method_func)Mthd_Delete,
    (process_method_func)Mthd_Execute, (process_method_func)Mthd_IsDelete,
    (process_method_func)Mthd_Draw,
};
}  // namespace

/* 8048178C-804817BC -00001 0030+00 0/0 0/0 1/0 .data            g_profile_Obj_Movebox */
extern actor_process_profile_definition g_profile_Obj_Movebox = {
    fpcLy_CURRENT_e,              // mLayerID
    3,                            // mListID
    fpcPi_CURRENT_e,              // mListPrio
    PROC_Obj_Movebox,             // mProcName
    &g_fpcLf_Method.mBase,        // sub_method
    sizeof(daObjMovebox::Act_c),  // mSize
    0,                            // mSizeOther
    0,                            // mParameters
    &g_fopAc_Method.base,         // sub_method
    17,                           // mPriority
    &Mthd_Table,                  // sub_method
    0x00040504,                   // mStatus
    fopAc_ACTOR_e,                // mActorType
    fopAc_CULLBOX_CUSTOM_e,       // cullType
};
