Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement more functions in find.c #102

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ CploFindSwObjectsByClass__FP2SWi3CIDP2LOiPP2LO = 0x15A4F0; // type:func
PloFindSwObjectByClass__FP2SWi3CIDP2LO = 0x15A838; // type:func
PaloFindLoCommonParent__FP2LOT0 = 0x15A868; // type:func

g_mpcidpvt = 0x247448; // size:0x328

////////////////////////////////////////////////////////////////
// P2/flash.c
////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions include/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <alo.h>
#include <sw.h>
#include <cid.h>
#include <so.h>

/**
* @brief Gets the DL for the SW object with the given OID.
Expand Down Expand Up @@ -56,4 +57,6 @@ LO *PloFindSwObjectByClass(SW *psw, int grffso, CID cid, LO *ploContext);
*/
ALO *PaloFindLoCommonParent(LO *plo, LO *ploOther);

extern void** g_mpcidpvt;

#endif // FIND_H
38 changes: 31 additions & 7 deletions src/P2/find.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,37 @@ INCLUDE_ASM(const s32, "P2/find", MatchSwObject__FP2LOiiiT0iPiPP2LOT6);

INCLUDE_ASM(const s32, "P2/find", CploFindSwObjects__FP2SWi3OIDP2LOiPP2LO);

INCLUDE_ASM(const s32, "P2/find", PloFindSwObject__FP2SWi3OIDP2LO);

INCLUDE_ASM(const s32, "P2/find", PloFindSwNearest__FP2SW3OIDP2LO);

INCLUDE_ASM(const s32, "P2/find", PloFindSwChild__FP2SW3OIDP3ALO);

INCLUDE_ASM(const s32, "P2/find", FIsCidDerivedFrom__F3CIDT0);
LO * PloFindSwObject(SW *psw, int grffso, OID oid, LO *ploContext) {
LO *value1[4];
value1[0] = 0;
CploFindSwObjects(psw, FSO_ReturnActualCount | grffso, oid, ploContext, 1, value1);
return value1[0];
}

LO * PloFindSwNearest(SW *psw, OID oid, LO *ploContext) {
LO *aplo[4];
aplo[0] = 0;
CploFindSwObjects(psw, FSO_ReturnActualCount | FSO_FindNearest, oid, ploContext, 1, aplo);
return aplo[0];
}

LO * PloFindSwChild(SW *psw, OID oid, ALO *paloAncestor) {
LO *aplo[4];
aplo[0] = 0;
CploFindSwObjects(psw, FSO_ReturnActualCount | FSO_FindChild, oid, paloAncestor, 1, aplo);
return aplo[0];
}

int FIsCidDerivedFrom(CID cid, CID cidAncestor) {
void **value1 = (&g_mpcidpvt)[cid];
while (value1 != (void**)0) {
if (value1[1] == (void*)cidAncestor) {
return 1;
}
value1 = (void**) *value1;
}
return 0;
}

INCLUDE_ASM(const s32, "P2/find", CploFindSwObjectsByClass__FP2SWi3CIDP2LOiPP2LO);

Expand Down
Loading