Skip to content

Commit

Permalink
d_a_obj_quake (#676)
Browse files Browse the repository at this point in the history
* d_a_obj_quake work

* daObjQuake_c::_create matching

* daObjQuake_c::_is_delete matching

* d_a_obj_quake matching
  • Loading branch information
DanTGL authored Aug 27, 2024
1 parent 660a5ac commit 596fe9a
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 32 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def JSystemLib(lib_name, objects):
ActorRel(NonMatching, "d_a_obj_otble"),
ActorRel(Matching, "d_a_obj_pbco"),
ActorRel(NonMatching, "d_a_obj_pirateship"),
ActorRel(NonMatching, "d_a_obj_quake"),
ActorRel(Matching, "d_a_obj_quake"),
ActorRel(NonMatching, "d_a_obj_rcloud"),
ActorRel(Matching, "d_a_obj_roten", extra_cflags=['-pragma "nosyminline on"']),
ActorRel(NonMatching, "d_a_obj_shelf"),
Expand Down
41 changes: 34 additions & 7 deletions include/d/actor/d_a_obj_quake.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,54 @@
#define D_A_OBJ_QUAKE_H

#include "f_op/f_op_actor.h"
#include "m_Do/m_Do_hostIO.h"

class daObjQuake_c : public fopAc_ac_c {
public:
enum Prm_e {
PRM_SCH_W = 0x8,
PRM_SCH_S = 0x0,

PRM_TYPE_W = 0x3,
PRM_TYPE_S = 0x8,

PRM_POWER_W = 0x3,
PRM_POWER_S = 0xB,
};

s32 _create();
BOOL _delete();
void _is_delete();
BOOL _is_delete();
BOOL _execute();
void getPrmType();
void getPrmSch();
void getPrmPower();
u8 getPrmType();
u8 getPrmSch();
s32 getPrmPower();

public:
/* Place member variables here */
/* 0x290 */ f32 m290;
/* 0x294 */ f32 m294;
/* 0x298 */ f32 m298;
/* 0x29C */ f32 m29C;
/* 0x2A0 */ u8 mType;
/* 0x2A1 */ bool m2A1;
};

class daObjQuake_HIO_c {
class daObjQuake_HIO_c : public JORReflexible {
public:
daObjQuake_HIO_c();
virtual ~daObjQuake_HIO_c() {}

public:
/* Place member variables here */
/* 0x04 */ s8 mChildID;
/* 0x08 */ s32 field_0x08;
/* 0x0C */ u8 field_0x0C;
/* 0x0D */ u8 field_0x0D;
/* 0x0E */ u8 field_0x0E;
/* 0x0F */ u8 field_0x0F;
/* 0x10 */ u8 field_0x10;
/* 0x11 */ u8 field_0x11;
/* 0x12 */ u8 field_0x12;
/* 0x13 */ u8 field_0x13;
};

#endif /* D_A_OBJ_QUAKE_H */
1 change: 1 addition & 0 deletions include/d/d_kankyo.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ cXyz dKy_get_orion_pos();
cXyz dKy_get_hokuto_pos();
void dKy_DayProc();
u8 dKy_get_schbit();
int dKy_get_schbit_timer();
int dKy_rain_check();
void dKy_setLight_mine(dKy_tevstr_c* pTevStr);
BOOL dKy_daynighttact_stop_chk();
Expand Down
4 changes: 3 additions & 1 deletion include/d/d_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,12 @@ inline s8 dStage_stagInfo_GetTimeH(stage_stag_info_class* p_info) {
inline u8 dStage_stagInfo_getStartSch(stage_stag_info_class* p_info) {
return (p_info->field_0x10 >> 0x10) & 0xFF;
}
inline u8 dStage_stagInfo_GetSchSec(stage_stag_info_class* p_info) {
return p_info->field_0x0c & 0xFF;
}

// TODO:
// dStage_stagInfo_GetAgbCon__FP21stage_stag_info_class
// dStage_stagInfo_GetSchSec__FP21stage_stag_info_class - field_0x0c & 0xFF
// dStage_stagInfo_DefaultCameraType__FP21stage_stag_info_class
// dStage_stagInfo_GetCullPoint__FP21stage_stag_info_class
// dStage_stagInfo_GetUpButton__FP21stage_stag_info_class
Expand Down
187 changes: 165 additions & 22 deletions src/d/actor/d_a_obj_quake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,213 @@

#include "d/actor/d_a_obj_quake.h"
#include "d/d_procname.h"
#include "d/d_a_obj.h"
#include "d/d_com_inf_game.h"

static daObjQuake_HIO_c l_HIO;

/* 000000EC-00000134 .text __ct__16daObjQuake_HIO_cFv */
daObjQuake_HIO_c::daObjQuake_HIO_c() {
/* Nonmatching */
mChildID = -1;
field_0x08 = 0;
field_0x0C = 0;
field_0x0D = 0;
field_0x0E = 3;
field_0x0F = 3;
field_0x10 = 1;
field_0x11 = 1;
field_0x12 = 1;
field_0x13 = 0;
}

/* 00000134-000002C4 .text _create__12daObjQuake_cFv */
s32 daObjQuake_c::_create() {
/* Nonmatching */
fopAcM_SetupActor(this, daObjQuake_c);

if (dComIfGs_isSymbol(1)) {
return cPhs_UNK3_e;
}

if (getPrmType() < 3) {
fopAcM_offDraw(this);
mType = getPrmType();
m2A1 = false;
m290 = 30.0f * dStage_stagInfo_GetSchSec(dComIfGp_getStageStagInfo());

switch (mType) {
case 0:
case 2:
m298 = 4.0f;
m29C = 6.0f;
break;
case 1:
m298 = 0.0f;
m29C = 6.0f;
break;
}

if (l_HIO.mChildID < 0) {
l_HIO.mChildID = mDoHIO_root.mDoHIO_createChild("振動効果", &l_HIO);
}

l_HIO.field_0x08 += 1;
return cPhs_COMPLEATE_e;
}

return cPhs_ERROR_e;
}

/* 000002C4-000002CC .text _delete__12daObjQuake_cFv */
BOOL daObjQuake_c::_delete() {
/* Nonmatching */
return TRUE;
}

/* 000002CC-00000390 .text _is_delete__12daObjQuake_cFv */
void daObjQuake_c::_is_delete() {
/* Nonmatching */
BOOL daObjQuake_c::_is_delete() {
if (m2A1) {
switch (mType) {
case 0:
dComIfGp_getVibration().StopQuake(0x3E);
break;
case 2:
dComIfGp_getVibration().StopQuake(1);
break;
}
}

if (l_HIO.mChildID >= 0) {
l_HIO.field_0x08 -= 1;
if (l_HIO.field_0x08 == 0) {
mDoHIO_root.mDoHIO_deleteChild(l_HIO.mChildID);
l_HIO.mChildID = -1;
}
}

return TRUE;
}

/* 00000390-00000674 .text _execute__12daObjQuake_cFv */
BOOL daObjQuake_c::_execute() {
/* Nonmatching */
// Required for match
const char* unused[] = {"camera", "sound", "motor"}; // Has to be in a function after _create and before getPrmType

m294 = dKy_get_schbit_timer();
s32 var_r30 = 0x2E;
s32 var_r29 = getPrmPower();
s32 var_r28 = getPrmPower();

if (l_HIO.field_0x0C != 0) {
var_r29 = l_HIO.field_0x0E + 1;
}

if (l_HIO.field_0x0D != 0) {
var_r28 = l_HIO.field_0x0F + 1;

if (l_HIO.field_0x10 != 0) {
var_r30 = var_r30 | 2;
} else {
var_r30 = var_r30 & ~2;
}

if (l_HIO.field_0x11 != 0) {
var_r30 = var_r30 | 4;
} else {
var_r30 = var_r30 & ~4;
}

if (l_HIO.field_0x12 != 0) {
var_r30 = var_r30 | 8;
} else {
var_r30 = var_r30 & ~8;
}

if (l_HIO.field_0x13 != 0) {
var_r30 = var_r30 | 0x10;
} else {
var_r30 = var_r30 & ~0x10;
}
}

u8 sch = getPrmSch();
bool var_r27 = false;
if (sch & dKy_get_schbit() && !dComIfGp_event_chkEventFlag(dEvtFlag_TALK_e)) {
f32 a = (m29C / 6.0f) * m290;
f32 b = (m298 / 6.0f) * m290;
if (m294 >= b && m294 < a) {
var_r27 = true;
}
}

if (m2A1) {
if (mType == 1) {
mDoAud_seStart(JA_SE_ATM_JINARI);
}

if (!var_r27) {
switch (mType) {
case 0:
dComIfGp_getVibration().StopQuake(var_r30);
break;
case 2:
dComIfGp_getVibration().StopQuake(1);
break;
}
m2A1 = false;
}
} else if (var_r27) {
switch (mType) {
case 0:
dComIfGp_getVibration().StartQuake(var_r28, var_r30, cXyz(0.0f, 1.0f, 0.0f));
break;
case 2:
dComIfGp_getVibration().StartQuake(var_r29, 1, cXyz(0.0f, 1.0f, 0.0f));
break;
}

m2A1 = true;
}

return TRUE;
}

/* 00000674-000006A0 .text getPrmType__12daObjQuake_cFv */
void daObjQuake_c::getPrmType() {
/* Nonmatching */
u8 daObjQuake_c::getPrmType() {
return daObj::PrmAbstract<Prm_e>(this, PRM_TYPE_W, PRM_TYPE_S);
}

/* 000006A0-000006CC .text getPrmSch__12daObjQuake_cFv */
void daObjQuake_c::getPrmSch() {
/* Nonmatching */
u8 daObjQuake_c::getPrmSch() {
return daObj::PrmAbstract<Prm_e>(this, PRM_SCH_W, PRM_SCH_S);
}

/* 000006CC-000006F8 .text getPrmPower__12daObjQuake_cFv */
void daObjQuake_c::getPrmPower() {
/* Nonmatching */
s32 daObjQuake_c::getPrmPower() {
return daObj::PrmAbstract<Prm_e>(this, PRM_POWER_W, PRM_POWER_S) + 1;
}

/* 000006F8-00000718 .text daObjQuakeCreate__FPv */
static s32 daObjQuakeCreate(void*) {
/* Nonmatching */
static s32 daObjQuakeCreate(void* i_this) {
return static_cast<daObjQuake_c*>(i_this)->_create();
}

/* 00000718-00000738 .text daObjQuakeDelete__FPv */
static BOOL daObjQuakeDelete(void*) {
/* Nonmatching */
static BOOL daObjQuakeDelete(void* i_this) {
return static_cast<daObjQuake_c*>(i_this)->_delete();
}

/* 00000738-00000758 .text daObjQuakeExecute__FPv */
static BOOL daObjQuakeExecute(void*) {
/* Nonmatching */
static BOOL daObjQuakeExecute(void* i_this) {
return static_cast<daObjQuake_c*>(i_this)->_execute();
}

/* 00000758-00000760 .text daObjQuakeDraw__FPv */
static BOOL daObjQuakeDraw(void*) {
/* Nonmatching */
static BOOL daObjQuakeDraw(void* i_this) {
return TRUE;
}

/* 00000760-00000780 .text daObjQuakeIsDelete__FPv */
static BOOL daObjQuakeIsDelete(void*) {
/* Nonmatching */
static BOOL daObjQuakeIsDelete(void* i_this) {
return static_cast<daObjQuake_c*>(i_this)->_is_delete();
}

static actor_method_class daObjQuakeMethodTable = {
Expand Down
2 changes: 1 addition & 1 deletion src/d/d_kankyo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ s32 dStage_roomControl_c::GetTimePass() {
*/
void dScnKy_env_light_c::SetSchbit() {
stage_stag_info_class* pstag = dComIfGp_getStageStagInfo();
int uvar1 = pstag->field_0x0c & 0xFF;
int uvar1 = dStage_stagInfo_GetSchSec(pstag);

if (dStage_stagInfo_getStartSch(pstag) != 0) {
if (mSchbit == 0) {
Expand Down

0 comments on commit 596fe9a

Please sign in to comment.