mirror of https://github.com/zeldaret/tp.git
295 lines
9.7 KiB
C++
295 lines
9.7 KiB
C++
//
|
|
// Generated By: dol2asm
|
|
// Translation Unit: d/d_tresure
|
|
//
|
|
|
|
#include "d/d_tresure.h"
|
|
#include "d/com/d_com_inf_game.h"
|
|
#include "d/map/d_map_path_dmap.h"
|
|
#include "d/d_path.h"
|
|
#include "SSystem/SComponent/c_math.h"
|
|
|
|
//
|
|
// Forward References:
|
|
//
|
|
|
|
//
|
|
// External References:
|
|
//
|
|
|
|
extern bool data_80450680;
|
|
|
|
/* ############################################################################################## */
|
|
/* 80450F98-80450F9C 000498 0004+00 2/2 0/0 0/0 .sbss mTypeGroupData__7dTres_c */
|
|
dTres_c::typeGroupData_c* dTres_c::mTypeGroupData;
|
|
|
|
/* 8009BBD8-8009BC18 096518 0040+00 0/0 1/1 0/0 .text createWork__7dTres_cFv */
|
|
int dTres_c::createWork() {
|
|
mTypeGroupData = new dTres_c::typeGroupData_c[0x40];
|
|
return 1;
|
|
}
|
|
|
|
/* 8009BC18-8009BC60 096558 0048+00 0/0 1/1 0/0 .text create__7dTres_cFv */
|
|
void dTres_c::create() {
|
|
if (dStage_stagInfo_GetSTType(i_dComIfGp_getStage()->getStagInfo()) != ST_BOSS_ROOM) {
|
|
reset();
|
|
}
|
|
}
|
|
|
|
/* 8009BC60-8009BC6C 0965A0 000C+00 0/0 1/1 0/0 .text remove__7dTres_cFv */
|
|
void dTres_c::remove() {
|
|
data_80450680 = true;
|
|
}
|
|
|
|
/* ############################################################################################## */
|
|
/* 80425438-80425508 052158 00CC+04 6/6 3/3 0/0 .bss mTypeGroupListAll__7dTres_c */
|
|
dTres_c::type_group_list dTres_c::mTypeGroupListAll[17];
|
|
|
|
/* 80450F9C-80450FA0 00049C 0002+02 2/2 0/0 0/0 .sbss mNum__7dTres_c */
|
|
u16 dTres_c::mNum;
|
|
|
|
/* 8009BC6C-8009BCB4 0965AC 0048+00 2/2 0/0 0/0 .text reset__7dTres_cFv */
|
|
void dTres_c::reset() {
|
|
if (data_80450680) {
|
|
mNum = 0;
|
|
data_80450680 = false;
|
|
|
|
for (int i = 0; i < 17; i++) {
|
|
mTypeGroupListAll[i].field_0x0 = NULL;
|
|
mTypeGroupListAll[i].field_0x4 = NULL;
|
|
mTypeGroupListAll[i].mNumber = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 8009BCB4-8009BE28 0965F4 0174+00 0/0 1/1 0/0 .text addData__7dTres_cFPQ27dTres_c10list_classSc
|
|
*/
|
|
void dTres_c::addData(dTres_c::list_class* p_list, s8 roomNo) {
|
|
if (dStage_stagInfo_GetSTType(i_dComIfGp_getStage()->getStagInfo()) != ST_BOSS_ROOM) {
|
|
reset();
|
|
|
|
data_s* listData = p_list->field_0x4->getDataPointer();
|
|
typeGroupData_c* groupData = &mTypeGroupData[mNum];
|
|
for (int i = 0; i < p_list->field_0x0; i++, listData++, groupData++) {
|
|
*(data_s*)groupData = *listData;
|
|
groupData->mRoomNo = roomNo;
|
|
groupData->mStatus = 0;
|
|
|
|
u32 typeGroupNo = getTypeToTypeGroupNo(groupData->mType);
|
|
groupData->setNextDataPointer(NULL);
|
|
groupData->setTypeGroupNo(typeGroupNo);
|
|
|
|
type_group_list* typeGroupList = mTypeGroupListAll + typeGroupNo;
|
|
if (typeGroupList->field_0x0 == NULL) {
|
|
typeGroupList->field_0x0 = groupData;
|
|
}
|
|
|
|
if (typeGroupList->field_0x4 != NULL) {
|
|
typeGroupList->field_0x4->setNextDataPointer(groupData);
|
|
}
|
|
typeGroupList->field_0x4 = groupData;
|
|
typeGroupList->mNumber++;
|
|
|
|
switch (groupData->mType) {
|
|
case 0xFF:
|
|
checkTreasureBox(groupData);
|
|
break;
|
|
}
|
|
|
|
mNum++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ############################################################################################## */
|
|
|
|
/* 8009BE28-8009C168 096768 0340+00 1/1 0/0 0/0 .text
|
|
* checkTreasureBox__7dTres_cFPQ27dTres_c6data_s */
|
|
void dTres_c::checkTreasureBox(dTres_c::data_s* param_0) {
|
|
if (param_0->mSwBit != 0xff && param_0->mArg1 != 0xff){
|
|
dPath* path = dPath_GetRoomPath(param_0->mArg1, -1);
|
|
|
|
if (path == NULL) return;
|
|
|
|
if (param_0->mArg2 == 0) {
|
|
s16 sVar5 = 0;
|
|
for (int i = 0; i < 4; i++) {
|
|
int sStack_62;
|
|
if (dComIfGs_isSwitch(param_0->mSwBit + i, param_0->mRoomNo) != 0) {
|
|
sStack_62 = (1 << i);
|
|
} else {
|
|
sStack_62 = 0;
|
|
}
|
|
sVar5 += sStack_62;
|
|
}
|
|
if (sVar5 != 0) {
|
|
s16 uStack_34 = cM_deg2s((sVar5 - 1) * 0x18 + 12);
|
|
cXyz cStack_48(path->m_points[0].m_position);
|
|
cXyz cStack_54(path->m_points[path->m_num - 1].m_position);
|
|
f32 dVar7 = cStack_48.absXZ(cStack_54);
|
|
cXyz local_60(0.0f, 0.0f, dVar7);
|
|
mDoMtx_stack_c::YrotS(uStack_34);
|
|
mDoMtx_stack_c::multVec(&local_60, &local_60);
|
|
local_60 += cStack_48;
|
|
local_60.y = cStack_54.y;
|
|
param_0->mPos = local_60;
|
|
} else {
|
|
param_0->mPos = path->m_points[0].m_position;
|
|
}
|
|
dMapInfo_n::correctionOriginPos(param_0->mRoomNo, ¶m_0->mPos);
|
|
} else {
|
|
dStage_dPnt_c* point;
|
|
if (dComIfGs_isSwitch(param_0->mSwBit, param_0->mRoomNo)) {
|
|
point = &path->m_points[path->m_num - 1];
|
|
} else {
|
|
point = &path->m_points[0];
|
|
}
|
|
|
|
param_0->mPos = point->m_position;
|
|
dMapInfo_n::correctionOriginPos(param_0->mRoomNo, ¶m_0->mPos);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 8009C168-8009C1F0 096AA8 0088+00 0/0 0/0 3/3 .text onStatus__7dTres_cFUcii */
|
|
void dTres_c::onStatus(u8 listIdx, int param_1, int flag) {
|
|
typeGroupData_c* groupData = getFirstData(listIdx);
|
|
int typeGroupNo = getTypeGroupNumber(listIdx);
|
|
|
|
for (int i = 0; i < typeGroupNo; i++) {
|
|
if (param_1 == groupData->getNo()) {
|
|
u8 status = groupData->getStatus();
|
|
|
|
cLib_onBit<u8>(status, flag);
|
|
groupData->setStatus(status);
|
|
}
|
|
groupData = getNextData(groupData);
|
|
}
|
|
}
|
|
|
|
/* 8009C1F0-8009C27C 096B30 008C+00 0/0 0/0 3/3 .text offStatus__7dTres_cFUcii */
|
|
void dTres_c::offStatus(u8 listIdx, int param_1, int flag) {
|
|
typeGroupData_c* groupData = getFirstData(listIdx);
|
|
s32 typeGroupNo = getTypeGroupNumber(listIdx);
|
|
|
|
for (int i = 0; i < typeGroupNo; i++) {
|
|
if (param_1 == groupData->getNo()) {
|
|
u8 status = groupData->getStatus();
|
|
|
|
cLib_offBit<u8>(status, flag);
|
|
groupData->setStatus(status);
|
|
}
|
|
groupData = getNextData(groupData);
|
|
}
|
|
}
|
|
|
|
/* 8009C27C-8009C360 096BBC 00E4+00 0/0 1/1 0/0 .text getBossIconFloorNo__7dTres_cFPi */
|
|
int dTres_c::getBossIconFloorNo(int* o_floorNo) {
|
|
int ret;
|
|
|
|
if (o_floorNo == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
ret = 0;
|
|
*o_floorNo = 0;
|
|
typeGroupData_c* groupData = getFirstData(3);
|
|
|
|
if (groupData != NULL && dComIfGs_isDungeonItemCompass()) {
|
|
if ((groupData->getSwBit() == 0xFF ||
|
|
(groupData->getSwBit() != 0xFF &&
|
|
dComIfGs_isSwitch(groupData->getSwBit(), groupData->getRoomNo()))) &&
|
|
!dComIfGs_isStageBossEnemy()) {
|
|
*o_floorNo =
|
|
dMapInfo_c::calcFloorNo(groupData->getPos()->y, true, groupData->getRoomNo());
|
|
ret = 1;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* 8009C360-8009C39C 096CA0 003C+00 4/4 4/4 0/0 .text getFirstData__7dTres_cFUc */
|
|
dTres_c::typeGroupData_c* dTres_c::getFirstData(u8 listIdx) {
|
|
if (mTypeGroupListAll + listIdx == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
if ((s32)mTypeGroupListAll[listIdx].mNumber == 0) {
|
|
return NULL;
|
|
}
|
|
|
|
return mTypeGroupListAll[listIdx].field_0x0;
|
|
}
|
|
|
|
/* 8009C39C-8009C3B4 096CDC 0018+00 2/2 3/3 0/0 .text
|
|
* getNextData__7dTres_cFPQ27dTres_c15typeGroupData_c */
|
|
dTres_c::typeGroupData_c* dTres_c::getNextData(dTres_c::typeGroupData_c* p_data) {
|
|
if (p_data == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
return p_data->getNextDataPointer();
|
|
}
|
|
|
|
/* 8009C3B4-8009C3CC 096CF4 0018+00 0/0 1/1 0/0 .text
|
|
* getNextData__7dTres_cFPCQ27dTres_c15typeGroupData_c */
|
|
dTres_c::typeGroupData_c* dTres_c::getNextData(dTres_c::typeGroupData_c const* p_data) {
|
|
if (p_data == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
return p_data->getNextDataPointer();
|
|
}
|
|
|
|
/* 8009C3CC-8009C49C 096D0C 00D0+00 0/0 0/0 14/14 .text setPosition__7dTres_cFiUcPC3Veci
|
|
*/
|
|
void dTres_c::setPosition(int dataNo, u8 listIdx, Vec const* i_pos, int i_roomNo) {
|
|
typeGroupData_c* groupData = getFirstData(listIdx);
|
|
|
|
for (int i = getTypeGroupNumber(listIdx); i > 0; i--) {
|
|
if (dataNo == groupData->getNo()) {
|
|
Vec pos;
|
|
pos.x = i_pos->x;
|
|
pos.y = i_pos->y;
|
|
pos.z = i_pos->z;
|
|
|
|
if (i_roomNo >= 0) {
|
|
groupData->setRoomNo(i_roomNo);
|
|
}
|
|
dMapInfo_n::correctionOriginPos(groupData->getRoomNo(), &pos);
|
|
groupData->setPos(pos);
|
|
return;
|
|
}
|
|
groupData = groupData->getNextDataPointer();
|
|
}
|
|
}
|
|
|
|
/* ############################################################################################## */
|
|
/* 8037B0D8-8037B100 007738 0022+06 2/2 0/0 0/0 .rodata typeToTypeGroup__7dTres_c */
|
|
u8 const dTres_c::typeToTypeGroup[17][2] = {
|
|
{0xFF, 0x00}, {0x00, 0x01}, {0x01, 0x02}, {0x02, 0x03}, {0x03, 0x04}, {0x04, 0x05},
|
|
{0x05, 0x06}, {0x06, 0x07}, {0x07, 0x08}, {0x80, 0x09}, {0x81, 0x0A}, {0x82, 0x0B},
|
|
{0x83, 0x0C}, {0x84, 0x0D}, {0x85, 0x0E}, {0x87, 0x0F}, {0x88, 0x10},
|
|
};
|
|
|
|
/* 8009C49C-8009C4B0 096DDC 0014+00 0/0 1/1 0/0 .text getTypeGroupNoToType__7dTres_cFUc
|
|
*/
|
|
int dTres_c::getTypeGroupNoToType(u8 i_typeGroupNo) {
|
|
return typeToTypeGroup[i_typeGroupNo][0];
|
|
}
|
|
|
|
/* 8009C4B0-8009C4FC 096DF0 004C+00 1/1 3/3 0/0 .text getTypeToTypeGroupNo__7dTres_cFUc
|
|
*/
|
|
u8 dTres_c::getTypeToTypeGroupNo(u8 i_type) {
|
|
int groupNo = 17;
|
|
for (int i = 0; i < 17; i++) {
|
|
if (i_type == typeToTypeGroup[i][0]) {
|
|
groupNo = typeToTypeGroup[i][1];
|
|
break;
|
|
}
|
|
}
|
|
|
|
return groupNo;
|
|
}
|