mirror of
https://github.com/zeldaret/tp
synced 2026-05-23 15:01:53 -04:00
3ee8a929a9
* c_phase: Make cPhs_Do a little more matching Still doesn't fully match, but now the branch offsets and everything else line up. The load of pUserData still doesn't properly match though. * c_phase: Make cPhs_Next completely match Co-authored-by: Pheenoh <pheenoh@gmail.com>
83 lines
2.3 KiB
C++
83 lines
2.3 KiB
C++
|
|
#include "SComponent/c_phase.h"
|
|
#include "global.h"
|
|
|
|
void cPhs_Reset(request_of_phase_process_class* pPhase) {
|
|
pPhase->mPhaseStep = 0;
|
|
}
|
|
|
|
void cPhs_Set(request_of_phase_process_class* pPhase, cPhs__Handler* pHandlerTable) {
|
|
pPhase->mpHandlerTable = pHandlerTable;
|
|
pPhase->mPhaseStep = 0;
|
|
}
|
|
|
|
void cPhs_UnCompleate(request_of_phase_process_class* pPhase) {
|
|
pPhase->mpHandlerTable = NULL;
|
|
cPhs_Reset(pPhase);
|
|
}
|
|
|
|
int cPhs_Compleate(request_of_phase_process_class* pPhase) {
|
|
pPhase->mpHandlerTable = NULL;
|
|
return cPhs_COMPLEATE_e;
|
|
}
|
|
|
|
int cPhs_Next(request_of_phase_process_class* pPhase) {
|
|
if (const cPhs__Handler* handlerTable = pPhase->mpHandlerTable) {
|
|
pPhase->mPhaseStep++;
|
|
cPhs__Handler handler = handlerTable[pPhase->mPhaseStep];
|
|
|
|
// Double null check here actually matters for emitted assembly.
|
|
// Wee old compilers.
|
|
if (handler == NULL || handler == NULL) {
|
|
return cPhs_Compleate(pPhase);
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
return cPhs_COMPLEATE_e;
|
|
}
|
|
|
|
#if NON_MATCHING
|
|
int cPhs_Do(request_of_phase_process_class* pPhase, void* pUserData) {
|
|
if (const cPhs__Handler* pHandlerTable = pPhase->mpHandlerTable) {
|
|
// the load of pUserData seems to be slightly scrambled..
|
|
const cPhs__Handler pHandler = pHandlerTable[pPhase->mPhaseStep];
|
|
const int newStep = pHandler(pUserData);
|
|
|
|
switch (newStep) {
|
|
case 1:
|
|
return cPhs_Next(pPhase);
|
|
case 2: {
|
|
const int step2 = cPhs_Next(pPhase);
|
|
return step2 == 1 ? 2 : cPhs_COMPLEATE_e;
|
|
}
|
|
case cPhs_COMPLEATE_e:
|
|
return cPhs_Compleate(pPhase);
|
|
case 3: {
|
|
cPhs_UnCompleate(pPhase);
|
|
return 3;
|
|
}
|
|
case cPhs_ERROR_e:
|
|
cPhs_UnCompleate(pPhase);
|
|
return cPhs_ERROR_e;
|
|
}
|
|
|
|
return newStep;
|
|
} else {
|
|
return cPhs_Compleate(pPhase);
|
|
}
|
|
}
|
|
#else
|
|
asm int cPhs_Do(request_of_phase_process_class* pPhase, void* pUserData) {
|
|
nofralloc
|
|
#include "SComponent/c_phase/asm/func_802666D8.s"
|
|
}
|
|
#endif
|
|
|
|
int cPhs_Handler(request_of_phase_process_class* pPhase, cPhs__Handler* pHandlerTable,
|
|
void* pUserData) {
|
|
pPhase->mpHandlerTable = pHandlerTable;
|
|
return cPhs_Do(pPhase, pUserData);
|
|
}
|