SComponent c_list / c_node (#5)

* SComponent c_list / c_node

* SComponent: c_tree

* SComponent: start c_phase

* SComponent: c_tag

* SComponent: c_counter

* f_pc_line / f_pc_line_tag

the beginnings of the framework process system

* f_pc_method_tag

* SComponent: c_node_iter / c_list_iter / c_tag_iter / c_tree_iter

* f_pc_draw_priority

* f_pc_method_iter

* f_pc_profile

Also add (untested) base header classes for f_pc_base

* f_pc_searcher

* f_pc_create_tag

* f_pc_creator

* f_pc_layer skeleton

* f_pc_method

* f_pc_line_iter

* f_pc_leaf somewhat

* f_pc_delete_tag

* f_pc_create_req

* Fix a few non-matchings

* c_phase: slight additional notes

* c_node: more matching

* fix build

* c_node: One more matching

* f_pc_line_iter: Matching

* f_pc_create_req: a bit more

* f_pc_load, f_pc_deletor partial

* f_pc_executor partial

* f: minor cleanups

* f_pc_executor

Co-authored-by: Pheenoh <pheenoh@gmail.com>
This commit is contained in:
Jasper St. Pierre
2020-11-30 14:26:55 -08:00
committed by GitHub
parent 89f4055593
commit eff77cbe26
88 changed files with 2117 additions and 2243 deletions
+178 -1
View File
@@ -1 +1,178 @@
// ok
#include "f/f_pc/f_pc_create_req.h"
#include "SComponent/c_phase.h"
#include "f/f_pc/f_pc_base.h"
#include "f/f_pc/f_pc_create_iter.h"
#include "f/f_pc/f_pc_layer.h"
#include "f/f_pc/f_pc_method.h"
#include "f/f_pc/f_pc_executor.h"
#include "f/f_pc/f_pc_deletor.h"
extern "C" {
bool fpcCtRq_isCreatingByID(create_tag *pTag, int *pId)
{
create_request *pReq = (create_request *) (pTag->mpTagData);
return pReq->mBsPcId == *pId;
}
bool fpcCtRq_IsCreatingByID(unsigned int id)
{
return fpcCtIt_Judge((cNdIt_JudgeFunc) fpcCtRq_isCreatingByID, &id) != NULL;
}
void fpcCtRq_CreateQTo(create_request *pReq)
{
fpcCtTg_CreateQTo(pReq);
fpcLy_CreatedMesg(pReq->mpLayer);
fpcLy_CancelQTo(&pReq->mMtdTg);
}
void fpcCtRq_ToCreateQ(create_request *pReq)
{
fpcLy_CreatingMesg(pReq->mpLayer);
fpcLy_ToCancelQ(pReq->mpLayer, &pReq->mMtdTg);
fpcCtTg_ToCreateQ(pReq);
}
extern void cMl_NS_free(void *pPtr);
#if NON_MATCHING
bool fpcCtRq_Delete(create_request *pReq)
{
fpcCtRq_CreateQTo(pReq);
if (pReq->mpCtRqMtd != NULL) {
// flow control
if (fpcMtd_Method(pReq->mpCtRqMtd->mpDelete, pReq) == 0)
return 0;
if (pReq->mpRes)
pReq->mpRes->mpCtRq = NULL;
cMl_NS_free(pReq);
return 1;
}
return 0;
}
#else
asm bool fpcCtRq_Delete(create_request *pReq)
{
nofralloc
/* 80020BA0 0001DAE0 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80020BA4 0001DAE4 7C 08 02 A6 */ mflr r0
/* 80020BA8 0001DAE8 90 01 00 14 */ stw r0, 0x14(r1)
/* 80020BAC 0001DAEC 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80020BB0 0001DAF0 7C 7F 1B 78 */ mr r31, r3
/* 80020BB4 0001DAF4 4B FF FF 6D */ bl fpcCtRq_CreateQTo
/* 80020BB8 0001DAF8 80 7F 00 34 */ lwz r3, 0x34(r31)
/* 80020BBC 0001DAFC 28 03 00 00 */ cmplwi r3, 0
/* 80020BC0 0001DB00 41 82 00 20 */ beq lbl_80020BE0
/* 80020BC4 0001DB04 80 63 00 08 */ lwz r3, 8(r3)
/* 80020BC8 0001DB08 7F E4 FB 78 */ mr r4, r31
/* 80020BCC 0001DB0C 48 00 18 5D */ bl fpcMtd_Method
/* 80020BD0 0001DB10 2C 03 00 00 */ cmpwi r3, 0
/* 80020BD4 0001DB14 40 82 00 0C */ bne lbl_80020BE0
/* 80020BD8 0001DB18 38 60 00 00 */ li r3, 0
/* 80020BDC 0001DB1C 48 00 00 24 */ b lbl_80020C00
lbl_80020BE0:
/* 80020BE0 0001DB20 80 7F 00 40 */ lwz r3, 0x40(r31)
/* 80020BE4 0001DB24 28 03 00 00 */ cmplwi r3, 0
/* 80020BE8 0001DB28 41 82 00 0C */ beq lbl_80020BF4
/* 80020BEC 0001DB2C 38 00 00 00 */ li r0, 0
/* 80020BF0 0001DB30 90 03 00 14 */ stw r0, 0x14(r3)
lbl_80020BF4:
/* 80020BF4 0001DB34 7F E3 FB 78 */ mr r3, r31
/* 80020BF8 0001DB38 48 24 26 69 */ bl cMl_NS_free
/* 80020BFC 0001DB3C 38 60 00 01 */ li r3, 1
lbl_80020C00:
/* 80020C00 0001DB40 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 80020C04 0001DB44 80 01 00 14 */ lwz r0, 0x14(r1)
/* 80020C08 0001DB48 7C 08 03 A6 */ mtlr r0
/* 80020C0C 0001DB4C 38 21 00 10 */ addi r1, r1, 0x10
/* 80020C10 0001DB50 4E 80 00 20 */ blr
}
#endif
bool fpcCtRq_Cancel(create_request *pReq)
{
if (pReq != NULL && !pReq->mbIsCancelling) {
pReq->mbIsCancelling = true;
base_process_class *pProc = pReq->mpRes;
if (pProc != NULL && !fpcDt_Delete(pProc))
return false;
if (pReq->mpCtRqMtd != NULL && !fpcMtd_Method(pReq->mpCtRqMtd->mpCancel, pReq))
return false;
return fpcCtRq_Delete(pReq);
} else {
return true;
}
}
int fpcCtRq_IsDoing(create_request *pReq)
{
if (pReq != NULL)
return pReq->mbIsCreating;
else
return false;
}
static bool fpcCtRq_Do(create_request *pReq)
{
int ret = cPhs_COMPLEATE_e;
if (pReq->mpCtRqMtd != NULL) {
cPhs__Handler pHandler = pReq->mpCtRqMtd->mpHandler;
if (pHandler != NULL) {
pReq->mbIsCreating = true;
ret = pHandler(pReq);
pReq->mbIsCreating = false;
}
}
switch (ret) {
case cPhs_COMPLEATE_e: {
int success = fpcEx_ToExecuteQ(pReq->mpRes);
if (success == 0)
return fpcCtRq_Cancel(pReq);
else
return fpcCtRq_Delete(pReq);
}
case 3:
case cPhs_ERROR_e:
return fpcCtRq_Cancel(pReq);
}
return 1;
}
void fpcCtRq_Handler(void)
{
fpcCtIt_Method((cNdIt_MethodFunc) fpcCtRq_Do, NULL);
}
extern void * cMl_NS_memalignB(int, unsigned long);
extern int fpcBs_MakeOfId(void);
create_request * fpcCtRq_Create(layer_class *pLayer, unsigned long size, create_request_method_class *pMthd)
{
create_request *pReq = (create_request *) cMl_NS_memalignB(-4, size);
if (pReq != NULL) {
fpcCtTg_Init(pReq, pReq);
fpcMtdTg_Init(&pReq->mMtdTg, (process_method_tag_func) fpcCtRq_Cancel, pReq);
pReq->mpLayer = pLayer;
pReq->mpCtRqMtd = pMthd;
pReq->mBsPcId = fpcBs_MakeOfId();
pReq->mpRes = NULL;
pReq->mbIsCancelling = false;
fpcCtRq_ToCreateQ(pReq);
}
return pReq;
}
};
+26 -1
View File
@@ -1 +1,26 @@
// ok
#include "global.h"
#include "f/f_pc/f_pc_create_tag.h"
// g_fpcCtTg_Queue
extern node_list_class lbl_803A3990;
extern "C" {
void fpcCtTg_ToCreateQ(create_tag_class *pTag)
{
cTg_Addition(&lbl_803A3990, pTag);
}
void fpcCtTg_CreateQTo(create_tag_class *pTag)
{
cTg_SingleCut(pTag);
}
int fpcCtTg_Init(create_tag *pTag, void *pUserData)
{
cTg_Create(pTag, pUserData);
return 1;
}
};
+28 -1
View File
@@ -1 +1,28 @@
// ok
#include "f/f_pc/f_pc_creator.h"
#include "f/f_pc/f_pc_base.h"
#include "f/f_pc/f_pc_create_req.h"
extern "C" {
bool fpcCt_IsCreatingByID(unsigned int id)
{
return fpcCtRq_IsCreatingByID(id);
}
int fpcCt_IsDoing(base_process_class *pProc)
{
return fpcCtRq_IsDoing(pProc->mpCtRq);
}
void fpcCt_Abort(base_process_class *pProc)
{
fpcCtRq_Cancel(pProc->mpCtRq);
}
void fpcCt_Handler(void)
{
fpcCtRq_Handler();
}
};
+49 -1
View File
@@ -1 +1,49 @@
// ok
#include "global.h"
#include "f/f_pc/f_pc_delete_tag.h"
// g_fpcDtTg_Queue
extern node_list_class lbl_803A39A0;
extern "C" {
bool fpcDtTg_IsEmpty(delete_tag_class *pTag)
{
return lbl_803A39A0.mSize == 0;
}
void fpcDtTg_ToDeleteQ(delete_tag_class *pTag)
{
pTag->mTimer = 1;
cTg_Addition(&lbl_803A39A0, pTag);
}
void fpcDtTg_DeleteQTo(delete_tag_class *pTag)
{
cTg_SingleCut(pTag);
}
int fpcDtTg_Do(delete_tag_class *pTag, delete_tag_func pFunc)
{
if (pTag->mTimer <= 0) {
fpcDtTg_DeleteQTo(pTag);
int ret = pFunc(pTag->mpTagData);
if (ret == 0) {
fpcDtTg_ToDeleteQ(pTag);
return 0;
} else {
return 1;
}
} else {
pTag->mTimer--;
return 0;
}
}
int fpcDtTg_Init(delete_tag_class *pTag, void *pUserData)
{
cTg_Create(pTag, pUserData);
return 1;
}
};
+23 -1
View File
@@ -1 +1,23 @@
// ok
#include "f/f_pc/f_pc_creator.h"
#include "f/f_pc/f_pc_deletor.h"
#include "f/f_pc/f_pc_base.h"
extern "C" {
int fpcDt_Delete(base_process_class *pProc)
{
if (pProc != NULL) {
if (fpcCt_IsDoing(pProc) == 1)
return 0;
if (pProc->mInitState == 3)
return 0;
return fpcDt_ToDeleteQ(pProc);
} else {
return 1;
}
}
};
+22 -1
View File
@@ -1 +1,22 @@
// ok
#include "global.h"
#include "f/f_pc/f_pc_draw_priority.h"
extern "C" {
int fpcDwPi_Get(draw_priority_class *pDwPi)
{
return pDwPi->mPriority;
}
void fpcDwPi_Set(draw_priority_class *pDwPi, int p)
{
pDwPi->mPriority = p;
}
void fpcDwPi_Init(draw_priority_class *pDwPi, int p)
{
fpcDwPi_Set(pDwPi, p);
}
};
+98 -1
View File
@@ -1 +1,98 @@
// ok
#include "f/f_pc/f_pc_executor.h"
#include "f/f_pc/f_pc_base.h"
#include "f/f_pc/f_pc_line_iter.h"
#include "f/f_pc/f_pc_layer_tag.h"
#include "f/f_pc/f_pc_layer.h"
#include "f/f_pc/f_pc_node.h"
#include "f/f_pc/f_pc_searcher.h"
extern "C" {
extern int fpcLyTg_ToQueue(layer_management_tag_class *pTag, u32 layerID, u16 listID, u16 listPrio);
extern int fpcLyTg_QueueTo(layer_management_tag_class *pTag);
extern int fpcLyIt_OnlyHere(layer_class *pLayer, cNdIt_MethodFunc pFunc, void *pUserData);
extern void * fpcLyIt_AllJudge(void *pFunc, void *pUserData);
extern int fpcPause_IsEnable(base_process_class *pProc, int);
// g_fpcNd_type
extern int lbl_80450D40;
base_process_class * fpcEx_Search(void *pFunc, void *pUserData)
{
return (base_process_class *) fpcLyIt_AllJudge(pFunc, pUserData);
}
base_process_class * fpcEx_SearchByID(u32 id)
{
if (id + 2 <= 1)
return NULL;
return fpcEx_Search(fpcSch_JudgeByID, &id);;
}
bool fpcEx_IsExist(int id)
{
return fpcEx_SearchByID(id) != NULL;
}
int fpcEx_Execute(base_process_class *pProc)
{
if (pProc->mInitState != 2 || fpcPause_IsEnable(pProc, 1) == 1)
return 0;
fpcBs_Execute(pProc);
// TODO: missing return?
}
int fpcEx_ToLineQ(base_process_class *pProc)
{
layer_class *pLayer = pProc->mLyTg.mpLayer;
base_process_class *pLayerPcNode = pLayer->mpPcNode;
if (pLayer->mLayerID == 0 || cTg_IsUse(&pLayerPcNode->mLnTg) == true) {
int ret = fpcLnTg_ToQueue(&pProc->mLnTg, pProc->mPi.b.mListID);
if (ret == 0) {
fpcLyTg_QueueTo(&pProc->mLyTg);
return 0;
}
pProc->mInitState = 2;
if (fpcBs_Is_JustOfType(lbl_80450D40, pProc->mSubType)) {
process_node_class *pNode = (process_node_class *) pProc;
fpcLyIt_OnlyHere(&pNode->mLayer, (cNdIt_MethodFunc) fpcEx_ToLineQ, pNode);
}
return 1;
}
return 0;
}
int fpcEx_ExecuteQTo(base_process_class *pProc)
{
int ret = fpcLyTg_QueueTo(&pProc->mLyTg);
if (ret == 1) {
pProc->mInitState = 3;
return 1;
} else {
return 0;
}
}
int fpcEx_ToExecuteQ(base_process_class *pProc)
{
int ret = fpcLyTg_ToQueue(&pProc->mLyTg, pProc->mPi.b.mLayer, pProc->mPi.b.mListID, pProc->mPi.b.mListPrio);
if (ret == 1) {
fpcEx_ToLineQ(pProc);
return 1;
} else {
return 0;
}
}
void fpcEx_Handler(cNdIt_MethodFunc pFunc)
{
return fpcLnIt_Queue(pFunc);
}
};
+26 -1
View File
@@ -1 +1,26 @@
// ok
#include "f/f_pc/f_pc_leaf.h"
extern "C" {
int fpcLf_GetPriority(leafdraw_class *pLeaf)
{
return fpcDwPi_Get(&pLeaf->mDwPi);
}
int fpcLf_DrawMethod(leafdraw_method_class *pMthd, void *pUserData)
{
return fpcMtd_Method(pMthd->mpDrawFunc, pUserData);
}
#if 0
int fpcLf_Draw(leafdraw_class *pLeaf)
{
int ret = 0;
if (pLeaf->mbUnk0 == 0)
ret = fpcLf_DrawMethod(pLeaf->mpDrawMtd, pLeaf);
return ret;
}
#endif
};
+18 -1
View File
@@ -1 +1,18 @@
// ok
#include "global.h"
#include "SComponent/c_list.h"
// l_fpcLn_Line
extern node_list_class lbl_803F4CF0[16];
extern "C" {
void fpcLn_Create(void)
{
int i = ARRAY_SIZE(lbl_803F4CF0);
node_list_class *pLine = lbl_803F4CF0;
while (i-- > 0)
cLs_Create(pLine++);
}
};
+32 -1
View File
@@ -1 +1,32 @@
// ok
#include "f/f_pc/f_pc_layer.h"
#include "f/f_pc/f_pc_base.h"
#include "SComponent/c_tag_iter.h"
#include "SComponent/c_tree_iter.h"
// g_fpcLn_Queue
extern node_lists_tree_class lbl_804505D8;
extern "C" {
static int fpcLnIt_MethodCall(create_tag_class *pTag, method_filter *pFilter)
{
layer_class *pLayer = ((base_process_class *) pTag->mpTagData)->mLyTg.mpLayer;
layer_class *pCurLayer = fpcLy_CurrentLayer();
fpcLy_SetCurrentLayer(pLayer);
int ret = cTgIt_MethodCall(pTag, pFilter);
fpcLy_SetCurrentLayer(pCurLayer);
return ret;
}
void fpcLnIt_Queue(cNdIt_MethodFunc pFunc)
{
method_filter filter;
filter.mpMethodFunc = pFunc;
filter.mpUserData = NULL;
cTrIt_Method(&lbl_804505D8, (cNdIt_MethodFunc) fpcLnIt_MethodCall, &filter);
}
};
+44 -1
View File
@@ -1 +1,44 @@
// ok
#include "f/f_pc/f_pc_line_tag.h"
// g_fpcLn_Queue
extern node_lists_tree_class lbl_804505D8;
extern "C" {
int fpcLnTg_Move(line_tag *pLineTag, int newLineListID)
{
if (pLineTag->mLineListID != newLineListID) {
fpcLnTg_QueueTo(pLineTag);
return fpcLnTg_ToQueue(pLineTag, newLineListID);
}
return 1;
}
void fpcLnTg_QueueTo(line_tag *pLineTag)
{
cTg_SingleCutFromTree(pLineTag);
pLineTag->mLineListID = -1;
}
int fpcLnTg_ToQueue(line_tag *pLineTag, int lineListID)
{
int ret = cTg_AdditionToTree(&lbl_804505D8, lineListID, pLineTag);
if (ret) {
pLineTag->mLineListID = lineListID;
return 1;
} else {
return 0;
}
}
void fpcLnTg_Init(line_tag *pLineTag, void *pData)
{
cTg_Create(pLineTag, pData);
pLineTag->mLineListID = -1;
}
};
+42 -1
View File
@@ -1 +1,42 @@
// ok
#include "SComponent/c_phase.h"
#include "f/f_pc/f_pc_load.h"
extern "C" {
extern int cDyl_IsLinked(short procName);
extern int cDyl_Unlink(short procName);
extern int cDyl_LinkASync(short procName);
bool fpcLd_Use(u16 procName)
{
if (fpcLd_IsLoaded(procName) == true && fpcLd_Load(procName) == cPhs_COMPLEATE_e)
return true;
return false;
}
int fpcLd_IsLoaded(u16 procName)
{
return cDyl_IsLinked(procName);
}
void fpcLd_Free(u16 procName)
{
cDyl_Unlink(procName);
}
int fpcLd_Load(u16 procName)
{
int phase = cDyl_LinkASync(procName);
switch (phase) {
case cPhs_COMPLEATE_e:
return cPhs_COMPLEATE_e;
case 0:
return 0;
default:
return cPhs_ERROR_e;
}
}
};
+35 -1
View File
@@ -1 +1,35 @@
// ok
#include "global.h"
#include "f/f_pc/f_pc_method.h"
extern "C" {
int fpcMtd_Method(process_method_func pFunc, void *pUserData)
{
if (pFunc != NULL)
return pFunc(pUserData);
else
return 1;
}
int fpcMtd_Execute(process_method_class *pMthd, void *pUserData)
{
return fpcMtd_Method(pMthd->mpExecuteFunc, pUserData);
}
int fpcMtd_IsDelete(process_method_class *pMthd, void *pUserData)
{
return fpcMtd_Method(pMthd->mpIsDeleteFunc, pUserData);
}
int fpcMtd_Delete(process_method_class *pMthd, void *pUserData)
{
return fpcMtd_Method(pMthd->mpDeleteFunc, pUserData);
}
int fpcMtd_Create(process_method_class *pMthd, void *pUserData)
{
return fpcMtd_Method(pMthd->mpCreateFunc, pUserData);
}
};
+12 -1
View File
@@ -1 +1,12 @@
// ok
#include "global.h"
#include "f/f_pc/f_pc_method_iter.h"
extern "C" {
void fpcMtdIt_Method(node_list_class *pList, cNdIt_MethodFunc pMethod)
{
cLsIt_Method(pList, pMethod, NULL);
}
};
+32 -1
View File
@@ -1 +1,32 @@
// ok
#include "f/f_pc/f_pc_method_tag.h"
// g_fpcLn_Queue
extern node_lists_tree_class lbl_804505D8;
extern "C" {
void fpcMtdTg_Do(process_method_tag_class *pMthd)
{
pMthd->mpFunc(pMthd->mpMthdData);
}
void fpcMtdTg_ToMethodQ(node_list_class *pList, process_method_tag_class *pMthd)
{
cTg_Addition(pList, pMthd);
}
void fpcMtdTg_MethodQTo(process_method_tag_class *pMthd)
{
cTg_SingleCut(pMthd);
}
int fpcMtdTg_Init(process_method_tag_class *pMthd, process_method_tag_func pFunc, void *pMthdData)
{
cTg_Create(pMthd, pMthd);
pMthd->mpFunc = pFunc;
pMthd->mpMthdData = pMthdData;
return 1;
}
};
+14 -1
View File
@@ -1 +1,14 @@
// ok
#include "f/f_pc/f_pc_profile.h"
// g_fpcPf_ProfileList_p
extern void ** lbl_80450D50;
extern "C" {
void * fpcPf_Get(s16 profileID)
{
return lbl_80450D50[profileID];
}
};
+23 -1
View File
@@ -1 +1,23 @@
// ok
#include "f/f_pc/f_pc_searcher.h"
#include "f/f_pc/f_pc_base.h"
extern "C" {
void * fpcSch_JudgeForPName(base_process_class *pProc, void *pUserData)
{
short pname = *(short*)pUserData;
if (pProc->mProcName == pname)
return pProc;
return NULL;
}
void * fpcSch_JudgeByID(base_process_class *pProc, void *pUserData)
{
int id = *(int*)pUserData;
if (pProc->mBsPcId == id)
return pProc;
return NULL;
}
};