* f_op debug 1

* f_op debug 2

* f_op debug 3

* f_op debug 4

* f_op debug 5

* f_op_debug fix build

* f_op linking

* remove goto in fopac_create

* fix regressions

* fix regressions

* pr comments

* f_op debug 6

* f_op debug 7

* f_op debug 8

* f_op debug 9

* f_op debug 10

* f_op work, linking, symbols, heap

* regressions 1

* regressions 2

* pr comments
This commit is contained in:
Niklas Bauer
2025-12-30 13:22:38 +01:00
committed by GitHub
parent 798ba743a0
commit b3803dfa74
32 changed files with 729 additions and 302 deletions
+104 -50
View File
@@ -1,4 +1,4 @@
#include "d/dolzel.h" // IWYU pragma: keep
#include "d/dolzel.h" // IWYU pragma: keep
#include "JSystem/JKernel/JKRExpHeap.h"
#include "SSystem/SComponent/c_malloc.h"
@@ -9,15 +9,17 @@
#include "f_op/f_op_msg_mng.h"
#include "f_op/f_op_scene_mng.h"
s32 fopMsgM_setStageLayer(void* i_process) {
scene_class* scn = fopScnM_SearchByID(dStage_roomControl_c::getProcID());
static fpc_ProcID i_msgID = fpcM_ERROR_PROCESS_ID_e;
int id = fopScnM_LayerID(scn);
return fpcM_ChangeLayerID(i_process, id);
s32 fopMsgM_setStageLayer(void* i_process) {
scene_class* stageProc = fopScnM_SearchByID(dStage_roomControl_c::getProcID());
JUT_ASSERT(93, stageProc != 0);
return fpcM_ChangeLayerID(i_process, fopScnM_LayerID(stageProc));
}
msg_class* fopMsgM_SearchByID(fpc_ProcID i_id) {
return (msg_class*)fpcEx_SearchByID(i_id);
return (msg_class*)fpcM_SearchByID(i_id);
}
fopMsg_prm_class* fopMsgM_GetAppend(void* i_msg) {
@@ -28,8 +30,8 @@ void fopMsgM_Delete(void* i_this) {
fpcM_Delete(i_this);
}
static fopMsg_prm_class* createAppend(fopAc_ac_c* i_talkActor, cXyz* i_pos, u32* i_msgIdx, u32* param_3,
fpc_ProcID param_4) {
static fopMsg_prm_class* createAppend(fopAc_ac_c* i_talkActor, cXyz* i_pos, u32* i_msgIdx,
u32* param_3, fpc_ProcID param_4) {
fopMsg_prm_class* append = (fopMsg_prm_class*)cMl::memalignB(-4, sizeof(fopMsg_prm_class));
if (append == NULL) {
return NULL;
@@ -40,10 +42,14 @@ static fopMsg_prm_class* createAppend(fopAc_ac_c* i_talkActor, cXyz* i_pos, u32*
if (i_msgIdx != NULL) {
append->msg_idx = *i_msgIdx;
} else {
i_msgIdx = NULL;
}
if (param_3 != NULL) {
append->field_0x14 = *param_3;
} else {
param_3 = NULL;
}
if (i_pos != NULL) {
@@ -81,29 +87,33 @@ static fopMsg_prm_timer* createTimerAppend(int i_mode, u32 i_limitMs, u8 i_type,
return appen;
}
fpc_ProcID fopMsgM_create(s16 i_procName, fopAc_ac_c* i_talkActor, cXyz* i_pos, u32* i_msgIdx, u32* param_4,
fopMsgCreateFunc createFunc) {
fopMsg_prm_class* append = createAppend(i_talkActor, i_pos, i_msgIdx, param_4, fpcM_ERROR_PROCESS_ID_e);
fpc_ProcID fopMsgM_create(s16 i_procName, fopAc_ac_c* i_talkActor, cXyz* i_pos, u32* i_msgIdx,
u32* param_4, FastCreateReqFunc i_createFunc) {
fopMsg_prm_class* append =
createAppend(i_talkActor, i_pos, i_msgIdx, param_4, fpcM_ERROR_PROCESS_ID_e);
if (append == NULL) {
return fpcM_ERROR_PROCESS_ID_e;
}
return fpcSCtRq_Request(fpcLy_CurrentLayer(), i_procName, (stdCreateFunc)createFunc, NULL, append);
return fpcM_Create(i_procName, i_createFunc, append);
}
fpc_ProcID 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* append = createTimerAppend(i_mode, i_limitMs, i_type, param_4, param_5,
param_6, param_7, param_8, fpcM_ERROR_PROCESS_ID_e);
fpc_ProcID 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,
FastCreateReqFunc i_createFunc) {
fopMsg_prm_timer* append =
createTimerAppend(i_mode, i_limitMs, i_type, param_4, param_5, param_6, param_7, param_8,
fpcM_ERROR_PROCESS_ID_e);
if (append == NULL) {
return fpcM_ERROR_PROCESS_ID_e;
}
return fpcSCtRq_Request(fpcLy_CurrentLayer(), i_procName, (stdCreateFunc)i_createFunc, NULL,
append);
return fpcM_Create(i_procName, i_createFunc, append);
}
static fpc_ProcID i_msgID = fpcM_ERROR_PROCESS_ID_e;
void dummySet() {
csXyz().set(0, 0, 0);
}
fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_talkActor, u32 param_2) {
if (dComIfGp_isHeapLockFlag() == 8) {
@@ -115,7 +125,6 @@ fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_talkActor, u32 param_2
dComIfGp_isHeapLockFlag() != 1)
{
return fpcM_ERROR_PROCESS_ID_e;
}
dComIfGp_clearMesgAnimeTagInfo();
@@ -156,9 +165,9 @@ fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, u32 param_1) {
dComIfGp_isHeapLockFlag() != 1)
{
return fpcM_ERROR_PROCESS_ID_e;
}
fopAc_ac_c* actor = NULL;
cXyz pos;
pos.x = pos.y = pos.z = 0.0f;
@@ -169,7 +178,7 @@ fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, u32 param_1) {
msg->pos.set(pos);
msg->msg_idx = i_msgIdx;
msg->field_0xf0 = param_1;
msg->talk_actor = NULL;
msg->talk_actor = actor;
msg->setTalkPartner(NULL);
msg->setMessageIndex(i_msgIdx, param_1, false);
return i_msgID;
@@ -177,7 +186,7 @@ fpc_ProcID fopMsgM_messageSet(u32 i_msgIdx, u32 param_1) {
msg->pos.set(pos);
msg->msg_idx = i_msgIdx;
msg->field_0xf0 = param_1;
msg->talk_actor = NULL;
msg->talk_actor = actor;
return i_msgID;
}
}
@@ -196,9 +205,10 @@ fpc_ProcID fopMsgM_messageSetDemo(u32 i_msgidx) {
dComIfGp_isHeapLockFlag() != 1)
{
return fpcM_ERROR_PROCESS_ID_e;
}
fopAc_ac_c* NULL_ = NULL;
cXyz pos;
pos.x = pos.y = pos.z = 0.0f;
@@ -208,7 +218,7 @@ fpc_ProcID fopMsgM_messageSetDemo(u32 i_msgidx) {
msg->pos.set(pos);
msg->msg_idx = i_msgidx;
msg->field_0xf0 = 1000;
msg->talk_actor = NULL;
msg->talk_actor = NULL_;
msg->setMessageIndexDemo(i_msgidx, false);
return i_msgID;
}
@@ -238,56 +248,67 @@ u8 fopMsgM_itemNumIdx(u8 i_no) {
return itemicon[i_no] & 0xFF;
}
void J2DPane::setAlpha(u8 alpha) {
mAlpha = alpha;
}
f32 dummy() {
J2DPane* dummyPlane = NULL;
dummyPlane->getAlpha();
dummyPlane->getHeight();
dummyPlane->getWidth();
dummyPlane->setAlpha(0);
#if !PLATFORM_GCN
J2DPicture* dummyPicture = NULL;
const char* str = NULL;
dummyPicture->append(str, 0.0f);
dummyPicture->setBlendRatio(0.0f, 0.0f);
#endif
return 0.5f;
}
f32 fopMsgM_valueIncrease(int param_0, int param_1, u8 i_type) {
if (param_0 <= 0) {
// Wii: NONMATCHING, float regalloc in case 3
f32 fopMsgM_valueIncrease(int i_max, int i_value, u8 i_mode) {
if (i_max <= 0) {
return 1.0f;
}
if (param_1 < 0) {
param_1 = 0;
} else if (param_1 > param_0) {
param_1 = param_0;
if (i_value < 0) {
i_value = 0;
} else if (i_value > i_max) {
i_value = i_max;
}
f32 var_f31 = (f32)param_1 / param_0;
f32 var_f30;
f32 v = (f32)i_value / i_max;
f32 ret;
switch (i_type) {
switch (i_mode) {
case 0:
var_f30 = var_f31 * var_f31;
ret = v * v;
break;
case 1:
var_f30 = JMAFastSqrt(var_f31);
ret = JMAFastSqrt(v);
break;
case 2:
default:
var_f30 = var_f31;
ret = v;
break;
case 3:
var_f30 = (2.0f * ((2.0f * var_f31) - 1.0f)) - 1.0f;
v = (2.0f * v) - 1.0f;
ret = (2.0f * v) - 1.0f;
break;
case 4:
var_f31 = cM_ssin(0.5f * ((f32)0x8000 * var_f31));
var_f30 = var_f31 * var_f31;
v = cM_ssin((int)(0.5f * ((f32)0x8000 * v)));
ret = v * v;
break;
case 5:
var_f31 = cM_ssin(0.5f * ((f32)0xFFFF * var_f31));
var_f30 = var_f31 * var_f31;
v = cM_ssin((int)(0.5f * ((f32)0xFFFF * v)));
ret = v * v;
break;
case 6:
var_f30 = cM_ssin((f32)0x8000 * var_f31);
ret = cM_ssin((int)((f32)0x8000 * v));
break;
}
return var_f30;
return ret;
}
// Here to generate J2DPicture virtual inlines
@@ -297,13 +318,46 @@ static void dummyVirtual(J2DPicture* picture, f32 param_1, f32 param_2, const ch
}
JKRExpHeap* fopMsgM_createExpHeap(u32 i_heapSize, JKRHeap* i_heap) {
JKRHeap* heap;
if (i_heap == NULL) {
i_heap = mDoExt_getGameHeap();
heap = mDoExt_getGameHeap();
} else {
heap = i_heap;
}
JKRExpHeap* exp_heap = JKRCreateExpHeap(i_heapSize, heap, false);
#if DEBUG
static int displayed = false;
if (exp_heap == NULL && !displayed) {
displayed = true;
int _;
return JKRExpHeap::create(i_heapSize, i_heap, false);
// Failed to allocate %f KB of ExpHeap Continuous free space = %f KB
// Remaining free space = %f
OS_REPORT("\x1b[43;30mfopMsgM_createMaxExpHeap : Expヒープ%fKの確保に失敗 連続空き容量=%fK "
"残り空き容量=%f\n\x1b[m",
i_heapSize / 1024.0f, heap->getFreeSize() / 1024.0f,
heap->getTotalFreeSize() / 1024.0f);
}
#endif
return exp_heap;
}
void fopMsgM_destroyExpHeap(JKRExpHeap* i_heap) {
#if DEBUG
if (!i_heap->check()) {
// EXPHeap is corrupted %08x
OS_REPORT_ERROR("EXPヒープ破壊されている %08x\n", i_heap);
} else if (i_heap->isEmpty() == false) {
// EXPHeap has not been completely freed %08x %08x
OS_REPORT_ERROR("EXPヒープ全開放されていない %08x %08x\n", i_heap,
i_heap->getTotalUsedSize());
i_heap->dump();
i_heap->freeAll();
}
#endif
i_heap->destroy();
}