tp/src/f_op/f_op_msg_mng.cpp

418 lines
13 KiB
C++

//
// Generated By: dol2asm
// Translation Unit: f_op/f_op_msg_mng
//
#include "f_op/f_op_msg_mng.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "SSystem/SComponent/c_malloc.h"
#include "d/meter/d_meter2.h"
#include "d/meter/d_meter2_info.h"
#include "d/msg/d_msg_object.h"
#include "dol2asm.h"
#include "f_op/f_op_scene_mng.h"
#include "global.h"
//
// Forward References:
//
extern "C" void fopMsgM_valueIncrease__FiiUc();
extern "C" extern dMsgObject_HIO_c g_MsgObject_HIO_c;
//
// External References:
//
extern "C" u8 sincosTable___5JMath[65536];
//
// Declarations:
//
/* 8001F9B4-8001FA24 01A2F4 0070+00 0/0 3/3 0/0 .text fopMsgM_setStageLayer__FPv */
s32 fopMsgM_setStageLayer(void* param_0) {
scene_class* scn = fopScnM_SearchByID(dStage_roomControl_c::getProcID());
int id = fopScnM_LayerID(scn);
return fpcM_ChangeLayerID(param_0, id);
}
/* 8001FA24-8001FA44 01A364 0020+00 3/3 14/14 4/4 .text fopMsgM_SearchByID__FUi */
msg_class* fopMsgM_SearchByID(unsigned int i_id) {
return (msg_class*)fpcEx_SearchByID(i_id);
}
/* 8001FA44-8001FA4C 01A384 0008+00 0/0 2/2 0/0 .text fopMsgM_GetAppend__FPv */
fopMsg_prm_class* fopMsgM_GetAppend(void* i_msg) {
msg_class* msg = static_cast<msg_class*>(i_msg);
return (fopMsg_prm_class*)msg->mBase.mpUserData;
}
/* 8001FA4C-8001FA6C 01A38C 0020+00 0/0 2/2 0/0 .text fopMsgM_Delete__FPv */
void fopMsgM_Delete(void* i_this) {
fpcM_Delete(i_this);
}
/* ############################################################################################## */
/* 80451C70-80451C74 000270 0004+00 6/6 0/0 0/0 .sdata2 @3902 */
SECTION_SDATA2 static u8 lit_3902[4] = {
0x00,
0x00,
0x00,
0x00,
};
/* 8001FA6C-8001FB50 01A3AC 00E4+00 1/1 0/0 0/0 .text createAppend__FP10fopAc_ac_cP4cXyzPUlPUlUi
*/
static fopMsg_prm_class* createAppend(fopAc_ac_c* i_actor, cXyz* i_pos, u32* i_msgID, u32* param_3,
unsigned int param_4) {
fopMsg_prm_class* params =
static_cast<fopMsg_prm_class*>(cMl::memalignB(-4, sizeof(fopMsg_prm_class)));
if (params == NULL) {
return NULL;
}
params->mpActor = i_actor;
dMsgObject_setTalkActor(i_actor);
if (i_msgID != NULL) {
params->mMsgID = *i_msgID;
}
if (param_3 != NULL) {
params->field_0x14 = *param_3;
}
if (i_pos != NULL) {
params->mPos = *i_pos;
} else {
f32 tmp_0 = FLOAT_LABEL(lit_3902);
cXyz tmp(tmp_0, tmp_0, tmp_0);
params->mPos = tmp;
}
params->field_0x18 = param_4;
return params;
}
/* 8001FB50-8001FC4C 01A490 00FC+00 1/1 0/0 0/0 .text createTimerAppend__FiUlUcUcffffUi
*/
static fopMsg_prm_timer* createTimerAppend(int i_mode, u32 i_limitMs, u8 i_type, u8 param_3,
f32 param_4, f32 param_5, f32 param_6, f32 param_7,
unsigned int param_8) {
fopMsg_prm_timer* appen = (fopMsg_prm_timer*)cMl::memalignB(-4, sizeof(fopMsg_prm_timer));
if (appen == NULL) {
appen = NULL;
} else {
appen->mpActor = 0;
appen->mMsgID = 0;
appen->field_0x14 = 0;
appen->mPos = cXyz(FLOAT_LABEL(lit_3902), FLOAT_LABEL(lit_3902), FLOAT_LABEL(lit_3902));
appen->field_0x18 = param_8;
appen->timer_mode = i_mode;
appen->limit_ms = i_limitMs;
appen->type = i_type;
appen->field_0x25 = param_3;
appen->field_0x28 = param_4;
appen->field_0x2c = param_5;
appen->field_0x30 = param_6;
appen->field_0x34 = param_7;
}
return appen;
}
/* 8001FC4C-8001FCC0 01A58C 0074+00 0/0 1/1 0/0 .text
* fopMsgM_create__FsP10fopAc_ac_cP4cXyzPUlPUlPFPv_i */
s32 fopMsgM_create(s16 param_0, fopAc_ac_c* param_1, cXyz* param_2, u32* param_3, u32* param_4,
fopMsgCreateFunc createFunc) {
fopMsg_prm_class* params = createAppend(param_1, param_2, param_3, param_4, -1);
if (params == NULL) {
return -1;
}
return fpcSCtRq_Request(fpcLy_CurrentLayer(), param_0, (stdCreateFunc)createFunc, NULL, params);
}
/* 8001FCC0-8001FD34 01A600 0074+00 0/0 2/2 0/0 .text fop_Timer_create__FsUcUlUcUcffffPFPv_i */
s32 fop_Timer_create(s16 i_procName, u8 i_mode, u32 i_limitMs, u8 i_type, u8 param_4, f32 param_5,
f32 param_6, f32 param_7, f32 param_8, fopMsgCreateFunc i_createFunc) {
fopMsg_prm_timer* timer_prm = createTimerAppend(i_mode, i_limitMs, i_type, param_4, param_5,
param_6, param_7, param_8, -1);
if (timer_prm == NULL) {
return -1;
}
return fpcSCtRq_Request(fpcLy_CurrentLayer(), i_procName, (stdCreateFunc)i_createFunc, NULL,
timer_prm);
}
/* ############################################################################################## */
/* 804505C8-804505D0 000048 0004+04 4/4 0/0 0/0 .sdata i_msgID */
static u32 i_msgID = 0xFFFFFFFF;
/* 8001FD34-8001FE84 01A674 0150+00 0/0 2/2 1/1 .text fopMsgM_messageSet__FUlP10fopAc_ac_cUl */
int fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_actorP, u32 param_2) {
if (dComIfGp_isHeapLockFlag() == 8) {
dMeter2Info_getMeterClass()->emphasisButtonDelete();
}
if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 &&
dComIfGp_isHeapLockFlag() != 2 && dComIfGp_isHeapLockFlag() != 3 &&
dComIfGp_isHeapLockFlag() != 1)
{
return -1;
} else {
dComIfGp_clearMesgAnimeTagInfo();
dComIfGp_clearMesgCameraTagInfo();
cXyz pos;
if (i_actorP) {
pos = i_actorP->eyePos;
} else {
pos.set(FLOAT_LABEL(lit_3902), FLOAT_LABEL(lit_3902), FLOAT_LABEL(lit_3902));
}
if (g_MsgObject_HIO_c.mMsgDebug == true) {
i_msgIdx = g_MsgObject_HIO_c.mMsgIndex;
}
dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID);
if (msg && msg->mMode == 1) {
msg->mPos.set(pos);
msg->mMsgID = i_msgIdx;
msg->field_0xf0 = param_2;
msg->mpActor = i_actorP;
msg->setMessageIndex(i_msgIdx, param_2, false);
return i_msgID;
} else {
return 0;
}
}
}
/* 8001FE84-8001FFC4 01A7C4 0140+00 0/0 6/6 4/4 .text fopMsgM_messageSet__FUlUl */
int fopMsgM_messageSet(u32 msgIdx, u32 param_1) {
if (dComIfGp_isHeapLockFlag() == 8) {
dMeter2Info_getMeterClass()->emphasisButtonDelete();
}
if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 &&
dComIfGp_isHeapLockFlag() != 2 && dComIfGp_isHeapLockFlag() != 3 &&
dComIfGp_isHeapLockFlag() != 1)
{
return -1;
} else {
cXyz pos;
pos.z = FLOAT_LABEL(lit_3902);
pos.y = FLOAT_LABEL(lit_3902);
pos.x = FLOAT_LABEL(lit_3902);
dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID);
if (msg) {
if (msg->mMode == 1) {
msg->mPos.set(pos);
msg->mMsgID = msgIdx;
msg->field_0xf0 = param_1;
msg->mpActor = NULL;
msg->setTalkPartner(NULL);
msg->setMessageIndex(msgIdx, param_1, false);
return i_msgID;
}
if (msg->mMode == 15) {
msg->mPos.set(pos);
msg->mMsgID = msgIdx;
msg->field_0xf0 = param_1;
msg->mpActor = NULL;
return i_msgID;
}
}
return 0;
}
}
/* 8001FFC4-800200C0 01A904 00FC+00 0/0 1/1 13/13 .text fopMsgM_messageSetDemo__FUl */
int fopMsgM_messageSetDemo(u32 param_0) {
dMsgObject_endFlowGroup();
if (dComIfGp_isHeapLockFlag() == 8) {
dMeter2Info_getMeterClass()->emphasisButtonDelete();
}
if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 &&
dComIfGp_isHeapLockFlag() != 2 && dComIfGp_isHeapLockFlag() != 3 &&
dComIfGp_isHeapLockFlag() != 1)
{
return -1;
} else {
cXyz pos;
pos.z = FLOAT_LABEL(lit_3902);
pos.y = FLOAT_LABEL(lit_3902);
pos.x = FLOAT_LABEL(lit_3902);
dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID);
if (msg && msg->mMode == 1) {
msg->mPos.set(pos);
msg->mMsgID = param_0;
msg->field_0xf0 = 1000;
msg->mpActor = NULL;
msg->setMessageIndexDemo(param_0, false);
return i_msgID;
} else {
return 0;
}
}
}
/* 800200C0-80020100 01AA00 0040+00 0/0 7/7 1/1 .text fopMsgM_messageGet__FPcUl */
char* fopMsgM_messageGet(char* i_stringBuf, u32 i_msgId) {
dMeter2Info_getString(i_msgId, i_stringBuf, NULL);
return i_stringBuf;
}
/* 80020100-80020108 01AA40 0008+00 0/0 1/1 0/0 .text fopMsgM_setMessageID__FUi */
void fopMsgM_setMessageID(unsigned int msg_id) {
i_msgID = msg_id;
}
/* 80020108-80020158 01AA48 0050+00 0/0 2/2 0/0 .text fopMsgM_Create__FsPFPv_iPv */
u32 fopMsgM_Create(s16 i_procName, FastCreateReqFunc i_createFunc, void* i_process) {
return fpcM_Create(i_procName, i_createFunc, i_process);
}
/* 80020158-80020160 -00001 0008+00 0/0 0/0 0/0 .text setAlpha__7J2DPaneFUc */
void J2DPane::setAlpha(u8 alpha) {
mAlpha = alpha;
}
/* ############################################################################################## */
/* 803A3970-803A3990 -00001 001C+04 1/1 0/0 0/0 .data @4305 */
SECTION_DATA static void* lit_4305[7 + 1 /* padding */] = {
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0x88),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0x90),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0xB4),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0xBC),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0xD8),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0x10C),
(void*)(((char*)fopMsgM_valueIncrease__FiiUc) + 0x140),
/* padding */
NULL,
};
/* 80451C74-80451C78 000274 0004+00 1/1 0/0 0/0 .sdata2 @4167 */
SECTION_SDATA2 static f32 lit_4167 = 0.5f;
/* 80451C78-80451C7C 000278 0004+00 1/1 0/0 0/0 .sdata2 @4298 */
SECTION_SDATA2 static f32 lit_4298 = 1.0f;
/* 80451C7C-80451C80 00027C 0004+00 1/1 0/0 0/0 .sdata2 @4299 */
SECTION_SDATA2 static f32 lit_4299 = 2.0f;
/* 80451C80-80451C84 000280 0004+00 1/1 0/0 0/0 .sdata2 @4300 */
SECTION_SDATA2 static f32 lit_4300 = 32768.0f;
/* 80451C84-80451C88 000284 0004+00 1/1 0/0 0/0 .sdata2 @4301 */
SECTION_SDATA2 static f32 lit_4301 = 65535.0f;
/* 80451C88-80451C90 000288 0008+00 1/1 0/0 0/0 .sdata2 @4303 */
SECTION_SDATA2 static f64 lit_4303 = 4503601774854144.0 /* cast s32 to float */;
/* 80020160-800202CC 01AAA0 016C+00 1/0 4/4 2/2 .text fopMsgM_valueIncrease__FiiUc */
#ifdef NONMATCHING
// regalloc + something up with case 2
f32 fopMsgM_valueIncrease(int param_0, int param_1, u8 param_2) {
f32 ret;
if (param_0 <= 0) {
return FLOAT_LABEL(lit_4298);
} else {
if (param_1 < 0) {
param_1 = 0;
} else if (param_1 > param_0) {
param_1 = param_0;
}
ret = param_1;
f32 out_tmp = ret / param_0;
switch (param_2) {
case 0: {
ret = out_tmp * out_tmp;
break;
}
case 1: {
ret = JMAFastSqrt(out_tmp);
break;
}
case 2: { // seems like this should be default case, but it causes other issues
ret = out_tmp;
break;
}
case 3: {
f32 tmp = (FLOAT_LABEL(lit_4299) * out_tmp) - FLOAT_LABEL(lit_4298);
tmp = out_tmp * tmp;
ret = tmp - FLOAT_LABEL(lit_4298);
break;
}
case 4: {
f32 tmp = cM_ssin(FLOAT_LABEL(lit_4167) * (FLOAT_LABEL(lit_4300) * out_tmp));
ret = tmp * tmp;
break;
}
case 5: {
f32 tmp = cM_ssin(FLOAT_LABEL(lit_4167) * (FLOAT_LABEL(lit_4301) * out_tmp));
ret = tmp * tmp;
break;
}
case 6: {
ret = cM_ssin(FLOAT_LABEL(lit_4300) * out_tmp);
}
}
}
return ret;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm f32 fopMsgM_valueIncrease(int param_0, int param_1, u8 param_2) {
nofralloc
#include "asm/f_op/f_op_msg_mng/fopMsgM_valueIncrease__FiiUc.s"
}
#pragma pop
#endif
// Here to generate J2DPicture virtual inlines
static void dummyVirtual(J2DPicture* picture, f32 param_1, f32 param_2, const char* param_3) {
picture->append(param_3, param_1);
picture->setBlendRatio(param_1, param_2);
}
/* 8002039C-800203E0 01ACDC 0044+00 0/0 3/3 0/0 .text fopMsgM_createExpHeap__FUlP7JKRHeap
*/
JKRExpHeap* fopMsgM_createExpHeap(u32 i_heapSize, JKRHeap* i_heap) {
if (i_heap == NULL) {
i_heap = mDoExt_getGameHeap();
}
return JKRExpHeap::create(i_heapSize, i_heap, false);
}
/* 800203E0-80020400 01AD20 0020+00 0/0 3/3 0/0 .text fopMsgM_destroyExpHeap__FP10JKRExpHeap */
void fopMsgM_destroyExpHeap(JKRExpHeap* i_heap) {
i_heap->destroy();
}