c_phase: Make cPhs_Next completely matching (#102)

* 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>
This commit is contained in:
LC 2021-01-26 17:08:35 -05:00 committed by GitHub
parent c11228ea86
commit 3ee8a929a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 49 deletions

View File

@ -1,28 +0,0 @@
/* 80266678 002635B8 94 21 FF F0 */ stwu r1,-0x10(r1)
/* 8026667C 002635BC 7C 08 02 A6 */ mflr r0
/* 80266680 002635C0 90 01 00 14 */ stw r0,0x14(r1)
/* 80266684 002635C4 80 A3 00 00 */ lwz r5,0(r3)
/* 80266688 002635C8 28 05 00 00 */ cmplwi r5,0
/* 8026668C 002635CC 41 82 00 38 */ beq lbl_802666C4
/* 80266690 002635D0 80 83 00 04 */ lwz r4,4(r3)
/* 80266694 002635D4 38 04 00 01 */ addi r0,r4,1
/* 80266698 002635D8 90 03 00 04 */ stw r0,4(r3)
/* 8026669C 002635DC 80 03 00 04 */ lwz r0,4(r3)
/* 802666A0 002635E0 54 00 10 3A */ slwi r0,r0,2
/* 802666A4 002635E4 7C 05 00 2E */ lwzx r0,r5,r0
/* 802666A8 002635E8 28 00 00 00 */ cmplwi r0,0
/* 802666AC 002635EC 41 82 00 08 */ beq lbl_802666B4
/* 802666B0 002635F0 40 82 00 0C */ bne lbl_802666BC
lbl_802666B4:
/* 802666B4 002635F4 4B FF FF B5 */ bl cPhs_Compleate
/* 802666B8 002635F8 48 00 00 10 */ b lbl_802666C8
lbl_802666BC:
/* 802666BC 002635FC 38 60 00 01 */ li r3,1
/* 802666C0 00263600 48 00 00 08 */ b lbl_802666C8
lbl_802666C4:
/* 802666C4 00263604 38 60 00 04 */ li r3,4
lbl_802666C8:
/* 802666C8 00263608 80 01 00 14 */ lwz r0,0x14(r1)
/* 802666CC 0026360C 7C 08 03 A6 */ mtlr r0
/* 802666D0 00263610 38 21 00 10 */ addi r1,r1,0x10
/* 802666D4 00263614 4E 80 00 20 */ blr

View File

@ -21,49 +21,43 @@ int cPhs_Compleate(request_of_phase_process_class* pPhase) {
return cPhs_COMPLEATE_e;
}
#if NON_MATCHING
int cPhs_Next(request_of_phase_process_class* pPhase) {
// flow control
if (pPhase->mpHandlerTable != NULL) {
if (const cPhs__Handler* handlerTable = pPhase->mpHandlerTable) {
pPhase->mPhaseStep++;
cPhs__Handler pHandler = pPhase->mpHandlerTable[pPhase->mPhaseStep];
if (pHandler == NULL)
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 if (pHandler != NULL)
} else {
return 1;
}
}
return cPhs_COMPLEATE_e;
}
#else
asm int cPhs_Next(request_of_phase_process_class* pPhase) {
nofralloc
#include "SComponent/c_phase/asm/func_80266678.s"
}
#endif
#if NON_MATCHING
int cPhs_Do(request_of_phase_process_class* pPhase, void* pUserData) {
cPhs__Handler* pHandlerTable = pPhase->mpHandlerTable;
if (pHandlerTable != NULL) {
if (const cPhs__Handler* pHandlerTable = pPhase->mpHandlerTable) {
// the load of pUserData seems to be slightly scrambled..
int step = pPhase->mPhaseStep;
cPhs__Handler pHandler = pHandlerTable[step];
int newStep = pHandler(pUserData);
const cPhs__Handler pHandler = pHandlerTable[pPhase->mPhaseStep];
const int newStep = pHandler(pUserData);
switch (newStep) {
case 1:
return cPhs_Next(pPhase);
case 2: {
int step2 = cPhs_Next(pPhase);
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_COMPLEATE_e:
return cPhs_Compleate(pPhase);
case cPhs_ERROR_e:
cPhs_UnCompleate(pPhase);
return cPhs_ERROR_e;