Skip to content

Commit

Permalink
andsw0 Work (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDude88 authored Sep 16, 2023
1 parent a321031 commit f00e07e
Showing 1 changed file with 246 additions and 42 deletions.
288 changes: 246 additions & 42 deletions src/d/actor/d_a_andsw0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "JSystem/JKernel/JKRHeap.h"
#include "f_op/f_op_actor_mng.h"
#include "d/d_com_inf_game.h"
#include "d/d_procname.h"

enum {
ACT_ON_ALL = 0,
Expand All @@ -19,76 +20,259 @@ enum {
struct andsw0_class : public fopAc_ac_c {
public:
/* 0x290 */ u32 _pad[2];
/* 0x298 */ u8 mAction;
/* 0x298 */ s8 mAction;
/* 0x299 */ u8 mNumSwitchesToCheck;
/* 0x29A */ u8 mBehaviorType;
/* 0x29B */ u8 mSwitchToSet;
/* 0x29C */ u8 mFirstSwitchToCheck;
/* 0x29E */ u16 mTimer;
/* 0x2A0 */ u16 mEventMapToolNo;
/* 0x292 */ u8 mEventIdx;
/* 0x293 */ u8 mEventState;
/* 0x2A0 */ s16 mEventIdx;
/* 0x2A2 */ u8 mEventNo;
/* 0x2A3 */ s8 mEventState;
};

/* 00000078-00000080 .text daAndsw0_Draw__FP12andsw0_class */
s32 daAndsw0_Draw(andsw0_class*) {
static s32 daAndsw0_Draw(andsw0_class*) {
return 1;
}

/* 00000080-000003C4 .text daAndsw0_check__FP12andsw0_class */
void daAndsw0_check(andsw0_class*) {
static void daAndsw0_check(andsw0_class* i_this) {
/* Nonmatching */
u8 numToCheck = i_this->mNumSwitchesToCheck;
u32 switchIdxToCheck = i_this->mFirstSwitchToCheck ? i_this->mFirstSwitchToCheck : i_this->mSwitchToSet + 1;

switch(i_this->mAction) {
case ACT_ON_ALL:
for(int i = 0; i < numToCheck; i++) {
if(dComIfGs_isSwitch(switchIdxToCheck, i_this->current.roomNo) == false) {
break;
}

if(i == numToCheck - 1) {
if(i_this->mBehaviorType != 3) {
dComIfGs_onSwitch(i_this->mSwitchToSet, i_this->current.roomNo);
}

switch(i_this->mBehaviorType) {
case 0:
i_this->mAction = ACT_WAIT;
break;
case 3:
i_this->mAction = ACT_TIMER_SET;
i_this->mTimer = 0x41;
break;
default:
i_this->mAction = ACT_OFF_ALL;
break;
}
}

switchIdxToCheck += 1;
}

break;
case ACT_OFF_ALL:
switchIdxToCheck = i_this->mFirstSwitchToCheck ? i_this->mFirstSwitchToCheck : i_this->mSwitchToSet + 1;

for(int i = 0; i < numToCheck; i++) {
if(dComIfGs_isSwitch(switchIdxToCheck, i_this->current.roomNo) == false) {
dComIfGs_offSwitch(i_this->mSwitchToSet, i_this->current.roomNo);
i_this->mAction = ACT_ON_ALL;
break;
}

switchIdxToCheck += 1;
}

break;
case ACT_TIMER:
i_this->mTimer = (i_this->orig.angle.z & 0xFF) * 0xF;
if(fopAcM_isSwitch(i_this, i_this->mSwitchToSet)) {
i_this->mAction = ACT_WAIT;
}
else {
for(int i = 0; i < numToCheck; i++) {
if(fopAcM_isSwitch(i_this, switchIdxToCheck)) {
i_this->mAction += 1;
break;
}

switchIdxToCheck += 1;
}
}

break;
case ACT_TIMER2:
i_this->mTimer -= 1;
if(i_this->mTimer == 0) {
for(int i = 0; i < numToCheck; i++) {
fopAcM_offSwitch(i_this, switchIdxToCheck);
switchIdxToCheck += 1;
}

i_this->mAction = ACT_TIMER;
}
else {
switchIdxToCheck = i_this->mFirstSwitchToCheck ? i_this->mFirstSwitchToCheck : i_this->mSwitchToSet + 1;

for(int i = 0; i < numToCheck; i++) {
if(fopAcM_isSwitch(i_this, switchIdxToCheck) == false) {
break;
}

if(i == numToCheck - 1) {
fopAcM_onSwitch(i_this, i_this->mSwitchToSet);
i_this->mAction = ACT_WAIT;
}

switchIdxToCheck += 1;
}
}

break;
case ACT_TIMER_SET:
i_this->mTimer -= 1;
if(i_this->mTimer == 0) {
fopAcM_onSwitch(i_this, i_this->mSwitchToSet);
i_this->mAction = ACT_WAIT;
}

break;
case ACT_WAIT:
default:
break;
}
}

/* 000003C4-0000044C .text bk_s_sub1__FPvPv */
void bk_s_sub1(void*, void*) {
/* Nonmatching */
static void* ac[7];
static s32 check_count;

static void* bk_s_sub1(void* i_this, void*) {
if(fopAcM_IsActor(i_this) && fopAcM_GetName(i_this) == 0xBE && (fopAcM_GetParam(i_this) & 0xF) == 7) {
s32 count = check_count; //regswaps without this
if(count < 2) {
ac[check_count] = i_this;
check_count++;
}

return 0;
}

return 0;
}

/* 0000044C-000004D4 .text bk_s_sub2__FPvPv */
void bk_s_sub2(void*, void*) {
/* Nonmatching */
static void* bk_s_sub2(void* i_this, void*) {
if(fopAcM_IsActor(i_this) && fopAcM_GetName(i_this) == 0xBE && (fopAcM_GetParam(i_this) & 0xF) == 4) {
s32 count = check_count; //regswaps without this
if(count == 2) {
ac[check_count] = i_this;
check_count++;
}

return 0;
}

return 0;
}

/* 000004D4-0000055C .text bk_s_sub3__FPvPv */
void bk_s_sub3(void*, void*) {
/* Nonmatching */
static void* bk_s_sub3(void* i_this, void*) {
if(fopAcM_IsActor(i_this) && fopAcM_GetName(i_this) == 0xBE && (fopAcM_GetParam(i_this) & 0xF) == 5) {
s32 count = check_count; //regswaps without this
if(count < 5) {
ac[check_count] = i_this;
check_count++;
}

return 0;
}

return 0;
}

/* 0000055C-000005D4 .text bb_s_sub__FPvPv */
void bb_s_sub(void*, void*) {
/* Nonmatching */
static void* bb_s_sub(void* i_this, void*) {
if(fopAcM_IsActor(i_this) && fopAcM_GetName(i_this) == 0xB6) {
s32 count = check_count; //regswaps without this
if(count < 7) {
ac[check_count] = i_this;
check_count++;
}

return 0;
}

return 0;
}

/* 000005D4-000006AC .text hajimari_actor_entry__FP12andsw0_class */
s32 hajimari_actor_entry(andsw0_class*) {
/* Nonmatching */
static s32 hajimari_actor_entry(andsw0_class* i_this) {
for(int i = 0; i < 7; i++) {
ac[i] = 0;
}
check_count = 0;

i_fpcM_Search(&bk_s_sub1, i_this);
i_fpcM_Search(&bk_s_sub2, i_this);
i_fpcM_Search(&bk_s_sub3, i_this);
check_count = 5;
i_fpcM_Search(&bb_s_sub, i_this);

for(int i = 0; i < 7; i++) {
if(ac[i] == 0) {
return 0;
}
}

return 1;
}

/* 000006AC-0000081C .text hajimarinomori_check__FP12andsw0_class */
void hajimarinomori_check(andsw0_class* i_this) {
static void hajimarinomori_check(andsw0_class* i_this) {
/* Nonmatching */
if (i_this->mBehaviorType == 0) {
if (hajimari_actor_entry(i_this))
if (hajimari_actor_entry(i_this)) {
i_this->mBehaviorType = 1;
} else {
}
}
else {
for(int i = 0; i < 7; i++) {}

//looks like these have something to do with bk_class and bb_class (based on the 0xB6/0xBE proc names earlier)
//finishing this probably needs some work on those
if (dComIfGs_isEventBit(4)) {
//
fopAcM_delete((fopAc_ac_c*)ac[5]);
fopAcM_delete((fopAc_ac_c*)ac[6]);
//ac[3]->field_0x121C = 1;
//ac[4]->field_0x121C = 1;

if (dComIfGs_isEventBit(0x301)) {
//ac[0]->field_0x121C = 1;
}
if (dComIfGs_isEventBit(0x480)) {
//ac[1]->field_0x121C = 1;
}
if (dComIfGs_isEventBit(0x301) && dComIfGs_isEventBit(0x480)) {
//ac[2]->field_0x121C = 1;
}
}
else {
//ac[0]->field_0x121C = 1;
//ac[1]->field_0x121C = 1;
}
}

fopAcM_delete(i_this);
}

/* 0000081C-00000914 .text event_start_check__FP12andsw0_class */
static void event_start_check(andsw0_class* i_this) {
/* Nonmatching */
switch (i_this->mEventState) {
case 0:
default:
if (i_this->mEventIdx != -1 && fopAcM_isSwitch(i_this, i_this->mSwitchToSet)) {
if (i_this->mEvtInfo.i_checkCommandDemoAccrpt()) {
i_this->mEventState++;
} else {
fopAcM_orderOtherEventId(i_this, i_this->mEventIdx, i_this->mEventMapToolNo, 0xFFFF, 0, 1);
fopAcM_orderOtherEventId(i_this, i_this->mEventIdx, i_this->mEventNo, 0xFFFF, 0, 1);
}
}

break;
case 1:
if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) {
dComIfGp_event_onEventFlag(8);
Expand All @@ -98,8 +282,7 @@ static void event_start_check(andsw0_class* i_this) {
}
}

/* 00000914-00000964 .text daAndsw0_Execute__FP12andsw0_class */
s32 daAndsw0_Execute(andsw0_class* i_this) {
static s32 daAndsw0_Execute(andsw0_class* i_this) {
event_start_check(i_this);
if (i_this->mNumSwitchesToCheck == 0xFF)
hajimarinomori_check(i_this);
Expand All @@ -108,28 +291,25 @@ s32 daAndsw0_Execute(andsw0_class* i_this) {
return 1;
}

/* 00000964-0000096C .text daAndsw0_IsDelete__FP12andsw0_class */
s32 daAndsw0_IsDelete(andsw0_class*) {
static s32 daAndsw0_IsDelete(andsw0_class*) {
return 1;
}

/* 0000096C-00000974 .text daAndsw0_Delete__FP12andsw0_class */
s32 daAndsw0_Delete(andsw0_class*) {
static s32 daAndsw0_Delete(andsw0_class*) {
return 1;
}

/* 00000974-00000A64 .text daAndsw0_Create__FP10fopAc_ac_c */
s32 daAndsw0_Create(fopAc_ac_c* ac) {
static s32 daAndsw0_Create(fopAc_ac_c* ac) {
fopAcM_SetupActor(ac, andsw0_class);

andsw0_class * i_this = (andsw0_class *)ac;
i_this->mNumSwitchesToCheck = (fopAcM_GetParam(ac) >> 0) & 0xFF;
i_this->mBehaviorType = (fopAcM_GetParam(ac) >> 8) & 0xFF;
i_this->mSwitchToSet = (fopAcM_GetParam(ac) >> 24) & 0xFF;
i_this->mFirstSwitchToCheck = (fopAcM_GetParam(ac) >> 16) & 0xFF;
i_this->mTimer = (i_this->orig.angle.z & 0xFF) * 16;
i_this->mEventMapToolNo = i_this->orig.angle.x;
i_this->mEventIdx = dComIfGp_evmng_getEventIdx(NULL, i_this->mEventMapToolNo);
i_this->mTimer = (i_this->orig.angle.z & 0xFF) * 0xF;
i_this->mEventNo = i_this->orig.angle.x;
i_this->mEventIdx = dComIfGp_evmng_getEventIdx(NULL, i_this->mEventNo);
if (i_this->mBehaviorType == 2)
i_this->mAction = ACT_TIMER;
if (i_this->mFirstSwitchToCheck == 0xFF)
Expand All @@ -142,3 +322,27 @@ s32 daAndsw0_Create(fopAc_ac_c* ac) {
return cPhs_COMPLEATE_e;
}

static actor_method_class l_daAndsw0_Method = {
(process_method_func)daAndsw0_Create,
(process_method_func)daAndsw0_Delete,
(process_method_func)daAndsw0_Execute,
(process_method_func)daAndsw0_IsDelete,
(process_method_func)daAndsw0_Draw,
};

extern actor_process_profile_definition g_profile_ANDSW0 = {
fpcLy_CURRENT_e,
7,
fpcPi_CURRENT_e,
PROC_ANDSW0,
&g_fpcLf_Method.mBase,
sizeof(andsw0_class),
0,
0,
&g_fopAc_Method.base,
0x0135,
&l_daAndsw0_Method,
0x00040000,
fopAc_ACTOR_e,
fopAc_CULLBOX_0_e,
};

0 comments on commit f00e07e

Please sign in to comment.