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

d_rawarchive followups #42

Merged
merged 3 commits into from
Sep 30, 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
7 changes: 7 additions & 0 deletions config/SOUE01/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ d/d_stage.cpp:
d/d_sys.cpp:
.text start:0x80064250 end:0x80064920

toBeSorted/arc_callback_handler.cpp:
.text start:0x80065050 end:0x80065590
.ctors start:0x804DB69C end:0x804DB6A0
.data start:0x8050DF28 end:0x8050DF60
.sdata start:0x80571D10 end:0x80571D20
.sbss start:0x80575250 end:0x80575258

toBeSorted/arc_managers/current_stage_arc_manager.cpp:
.text start:0x80068FD0 end:0x80069910
.ctors start:0x804DB6A8 end:0x804DB6AC
Expand Down
36 changes: 18 additions & 18 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2738,9 +2738,9 @@ fn_80061A30 = .text:0x80061A30; // type:function size:0x58
fn_80061A90 = .text:0x80061A90; // type:function size:0x4
fn_80061AA0 = .text:0x80061AA0; // type:function size:0x4
dPlayerModel__sinit = .text:0x80061AB0; // type:function size:0x5C
fn_80061B10 = .text:0x80061B10; // type:function size:0x88
fn_80061BA0 = .text:0x80061BA0; // type:function size:0x34
fn_80061BE0 = .text:0x80061BE0; // type:function size:0x10
computeChecksumInner__FPvUl = .text:0x80061B10; // type:function size:0x88
computeChecksum__FPvUl = .text:0x80061BA0; // type:function size:0x34
setPrefix__FP18ArcCallbackHandlerPCcUl = .text:0x80061BE0; // type:function size:0x10
__ct__14dRawArcEntry_cFv = .text:0x80061BF0; // type:function size:0x28
__dt__14dRawArcEntry_cFv = .text:0x80061C20; // type:function size:0x80
searchCallback__14dRawArcEntry_cFPvPvPC11ARCDirEntryPCcb = .text:0x80061CA0; // type:function size:0xA0
Expand All @@ -2751,12 +2751,12 @@ loadArcFromDiskChecked__14dRawArcEntry_cFPCcPCcUcPQ23EGG4Heap = .text:0x80061E70
loadArcFromDisk__14dRawArcEntry_cFPCcPCcUcPQ23EGG4Heap = .text:0x80061EF0; // type:function size:0xD0
checkArcExistsOnDisk__14dRawArcEntry_cFPCcPCc = .text:0x80061FC0; // type:function size:0x34
checkArcExistsOnDiskInner__14dRawArcEntry_cFR16SizedString<128>PCcPCc = .text:0x80062000; // type:function size:0x9C
mount__14dRawArcEntry_cFPCcPvPvUcPQ23EGG4Heap = .text:0x800620A0; // type:function size:0x104
mount__14dRawArcEntry_cFPCcPvP18ArcCallbackHandlerUcPQ23EGG4Heap = .text:0x800620A0; // type:function size:0x104
ensureLoadedMaybe__14dRawArcEntry_cFPv = .text:0x800621B0; // type:function size:0x14C
onMount__14dRawArcEntry_cFPv = .text:0x80062300; // type:function size:0x5C
__ct__14dRawArcTable_cFv = .text:0x80062360; // type:function size:0x14
__dt__14dRawArcTable_cFv = .text:0x80062380; // type:function size:0x74
init__14dRawArcTable_cFUsPvPQ23EGG4Heap = .text:0x80062400; // type:function size:0x90
init__14dRawArcTable_cFUsP18ArcCallbackHandlerPQ23EGG4Heap = .text:0x80062400; // type:function size:0x90
getArcOrLoadFromDisk__14dRawArcTable_cFPCcPCcUcPQ23EGG4Heap = .text:0x80062490; // type:function size:0xAC
addEntryFromSuperArc__14dRawArcTable_cFPCcPvUcPQ23EGG4Heap = .text:0x80062540; // type:function size:0xB0
ensureLoadedMaybe2__14dRawArcTable_cFPCc = .text:0x800625F0; // type:function size:0x44
Expand Down Expand Up @@ -2855,10 +2855,10 @@ fn_80064FC0 = .text:0x80064FC0; // type:function size:0x30
fn_80064FF0 = .text:0x80064FF0; // type:function size:0x24
fn_80065020 = .text:0x80065020; // type:function size:0x14
fn_80065040 = .text:0x80065040; // type:function size:0x8
BindSystemModelsAndLighting = .text:0x80065050; // type:function size:0x164
fn_800651C0 = .text:0x800651C0; // type:function size:0x204
fn_800653D0 = .text:0x800653D0; // type:function size:0x194
fn_80065570 = .text:0x80065570; // type:function size:0x20
BindSystemModelsAndLighting__FQ34nw4r3g3d7ResFile = .text:0x80065050; // type:function size:0x164
CreateArcEntry__22ArcCallbackHandlerBaseFPvPCc = .text:0x800651C0; // type:function size:0x204
DestroyArcEntry__22ArcCallbackHandlerBaseFPCc = .text:0x800653D0; // type:function size:0x194
__sinit_\arc_callback_handler_cpp = .text:0x80065570; // type:function size:0x20 scope:local
create__6mVideoFv = .text:0x80065590; // type:function size:0x54
fn_800655F0 = .text:0x800655F0; // type:function size:0x4
fn_80065600 = .text:0x80065600; // type:function size:0x3C
Expand Down Expand Up @@ -26668,8 +26668,8 @@ createTexture__Q23EGG19LightTextureManagerFPCc = .text:0x804AD690; // type:funct
EGG__LightTextureManager__createTextureFromBin = .text:0x804AD7A0; // type:function size:0x5C
EGG__LightTextureManager__createTexturesFromBin = .text:0x804AD800; // type:function size:0x6C
deleteTexture__Q23EGG19LightTextureManagerFi = .text:0x804AD870; // type:function size:0x84
replaceModelTextures__Q23EGG19LightTextureManagerCFPQ34nw4r3g3d6ResMdl = .text:0x804AD900; // type:function size:0x84
replaceModelTexture__Q23EGG19LightTextureManagerCFiPQ34nw4r3g3d6ResMdl = .text:0x804AD990; // type:function size:0x104
replaceModelTextures__Q23EGG19LightTextureManagerCFQ34nw4r3g3d6ResMdl = .text:0x804AD900; // type:function size:0x84
replaceModelTexture__Q23EGG19LightTextureManagerCFiQ34nw4r3g3d6ResMdl = .text:0x804AD990; // type:function size:0x104
getTextureIndex__Q23EGG19LightTextureManagerCFPCc = .text:0x804ADAA0; // type:function size:0x7C
setBinaryToTexture__Q23EGG19LightTextureManagerFPCv = .text:0x804ADB20; // type:function size:0x90
correctLightObject__Q23EGG19LightTextureManagerFv = .text:0x804ADBB0; // type:function size:0x90
Expand Down Expand Up @@ -27544,7 +27544,7 @@ sprintf = .text:0x804CC5D8; // type:function size:0xD4 scope:global
__StringRead = .text:0x804CC6AC; // type:function size:0x694
fn_804CCD40 = .text:0x804CCD40; // type:function size:0xC98
fn_804CD9D8 = .text:0x804CD9D8; // type:function size:0x88
fn_804CDA60 = .text:0x804CDA60; // type:function size:0x130
sscanf = .text:0x804CDA60; // type:function size:0x130
strcpy = .text:0x804CDB90; // type:function size:0xC0 scope:global
strncpy = .text:0x804CDC50; // type:function size:0x44
strcat = .text:0x804CDC94; // type:function size:0x2C
Expand Down Expand Up @@ -30773,9 +30773,9 @@ lbl_8050DEB4 = .data:0x8050DEB4; // type:object size:0x10
lbl_8050DEC4 = .data:0x8050DEC4; // type:object size:0x10
RootHeapsManager__EGG__T_System<>__Configuration__vtable = .data:0x8050DED4; // type:object size:0x3C
lbl_8050DF10 = .data:0x8050DF10; // type:object size:0x18
lbl_8050DF28 = .data:0x8050DF28; // type:object size:0x14
lbl_8050DF3C = .data:0x8050DF3C; // type:object size:0x14
lbl_8050DF50 = .data:0x8050DF50; // type:object size:0x10
lbl_8050DF28 = .data:0x8050DF28; // type:object size:0x11 data:string
lbl_8050DF3C = .data:0x8050DF3C; // type:object size:0x11 data:string
__vt__18ArcCallbackHandler = .data:0x8050DF50; // type:object size:0x10
lbl_8050DF60 = .data:0x8050DF60; // type:object size:0x10
lbl_8050DF70 = .data:0x8050DF70; // type:object size:0x14
lbl_8050DF84 = .data:0x8050DF84; // type:object size:0xC
Expand Down Expand Up @@ -37661,8 +37661,8 @@ lbl_80571CF8 = .sdata:0x80571CF8; // type:object size:0x8 data:string
lbl_80571D00 = .sdata:0x80571D00; // type:object size:0x8 data:string
RootActorID = .sdata:0x80571D08; // type:object size:0x2 data:2byte
gameStateIsActive = .sdata:0x80571D0A; // type:object size:0x6 data:byte
lbl_80571D10 = .sdata:0x80571D10; // type:object size:0x8
lbl_80571D18 = .sdata:0x80571D18; // type:object size:0x8
lbl_80571D10 = .sdata:0x80571D10; // type:object size:0x7 data:string
lbl_80571D18 = .sdata:0x80571D18; // type:object size:0x3 data:string
lbl_80571D20 = .sdata:0x80571D20; // type:object size:0x8
lbl_80571D28 = .sdata:0x80571D28; // type:object size:0x8 data:string
lbl_80571D30 = .sdata:0x80571D30; // type:object size:0x7 data:string
Expand Down Expand Up @@ -39822,7 +39822,7 @@ dSystem__s_NewMEM1ArenaLo = .sbss:0x80575238; // type:object size:0x4 data:4byte
dSystem__s_OrgMEM1ArenaHi = .sbss:0x8057523C; // type:object size:0x4 data:4byte
dSystem__s_NewMEM1ArenaHi = .sbss:0x80575240; // type:object size:0x8 data:4byte
dSystem__myDylinkInitPhase = .sbss:0x80575248; // type:object size:0x8
lbl_80575250 = .sbss:0x80575250; // type:object size:0x8 data:4byte
sInstance__18ArcCallbackHandler = .sbss:0x80575250; // type:object size:0x8 data:4byte
aspectRatio = .sbss:0x80575258; // type:object size:0x8 data:float
lbl_80575260 = .sbss:0x80575260; // type:object size:0x8 data:4byte
lbl_80575268 = .sbss:0x80575268; // type:object size:0x8 data:4byte
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Object(NonMatching, "d/d_stage.cpp"),
Object(NonMatching, "d/d_sys.cpp"),
Object(NonMatching, "toBeSorted/sound_info.cpp"),
Object(Matching, "toBeSorted/arc_callback_handler.cpp"),
Object(NonMatching, "d/a/d_a_base.cpp"),
Object(NonMatching, "d/a/obj/d_a_obj_base.cpp"),
Object(NonMatching, "d/a/obj/d_a_obj_item.cpp"),
Expand Down
1 change: 1 addition & 0 deletions include/MSL_C/MSL_Common/Src/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ int strcmp(const char* str1, const char* str2);
char* strcat(char* dst, const char* src);
char* strncpy(char* dst, const char* src, size_t n);
char* strcpy(char* dst, const char* src);
int sscanf(const char *buffer, const char *format, ...);
size_t strlen(const char* str);

#ifdef __cplusplus
Expand Down
26 changes: 21 additions & 5 deletions include/d/d_rawarchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@

#include <common.h>
#include <m/m_dvd.h>
// clang-format off
#include <sized_string.h>
// clang-format on

class ArcCallbackHandlerBase {
public:
ArcCallbackHandlerBase(): mPrefix(' ') {}
/* vtable at 8050df50 */
/** 800651c0 */
virtual void CreateArcEntry(void *data, const char *path);
/** 800653d0 */
virtual void DestroyArcEntry(const char *path);

u32 mPrefix;
};

class ArcCallbackHandler : public ArcCallbackHandlerBase {
public:
ArcCallbackHandler() {}
static ArcCallbackHandler sInstance;
};
Comment on lines +8 to +24
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't match the sinit part without two separate classes /shrug


// TODO: loading status could be an enum (-2/-1/0/+1)

Expand All @@ -22,7 +38,7 @@ class dRawArcEntry_c {
static BOOL checkArcExistsOnDisk(const char *fileName, const char *dirName);
static BOOL checkArcExistsOnDiskInner(SizedString<128> &path, const char *fileName, const char *dirName);

int mount(const char *name, void *data, void *callbackArg, u8 mountDirection, EGG::Heap *heap);
int mount(const char *name, void *data, ArcCallbackHandler *callbackArg, u8 mountDirection, EGG::Heap *heap);
int onMount(void *callbackArg);

int ensureLoadedMaybe(void *callbackArg);
Expand Down Expand Up @@ -83,7 +99,7 @@ class dRawArcTable_c {
dRawArcTable_c();
~dRawArcTable_c();

bool init(u16 count, void *callbackArg, EGG::Heap *heap);
bool init(u16 count, ArcCallbackHandler *callbackArg, EGG::Heap *heap);
BOOL getArcOrLoadFromDisk(const char *name, const char *dirName, u8 mountDirection, EGG::Heap *heap);
BOOL addEntryFromSuperArc(const char *name, void *data, u8 mountDirection, EGG::Heap *heap);
int ensureLoadedMaybe2(const char *name);
Expand All @@ -101,7 +117,7 @@ class dRawArcTable_c {
private:
/* 0x0 */ dRawArcEntry_c *mpEntries;
/* 0x4 */ u16 mCount;
/* 0x8 */ void *mCallbackArg;
/* 0x8 */ ArcCallbackHandler *mCallbackArg;
};

#endif;
1 change: 1 addition & 0 deletions include/egg/gfx/eggLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class LightTextureManager : public IBinary<LightTextureManager> {
virtual void GetBinaryInner(Bin *) const override;
virtual size_t GetBinarySize() override;
virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
void replaceModelTextures(nw4r::g3d::ResMdl) const;

void drawAndCaptureTexture(f32, f32, f32, f32);
};
Expand Down
7 changes: 5 additions & 2 deletions include/nw4r/g3d/g3d_resfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct ResFileData {
struct ResFile {
ResCommon<ResFileData> mFile; // at 0x0

ResFile(): mFile((void*)nullptr) {}
ResFile(void *ptr): mFile(ptr) {}
ResFile() : mFile((void *)nullptr) {}
ResFile(void *ptr) : mFile(ptr) {}

inline ResFileData &ref() const {
return mFile.ref();
Expand Down Expand Up @@ -79,6 +79,9 @@ struct ResFile {
u32 GetResAnmScnNumEntries() const;

bool Bind(ResFile);
bool Bind() {
return Bind(*this);
}
void Release();
void Init();
void Terminate();
Expand Down
4 changes: 4 additions & 0 deletions include/nw4r/g3d/g3d_resmat.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct ResPixDL {
struct ResMatPix : public ResCommon<ResPixDL> {
ResMatPix(void *vptr) : ResCommon(vptr) {}
void DCStore(bool sync);
void GXGetDstAlpha(u8*, u8*) const;
void GXSetDstAlpha(u8, u8);
void CallDisplayList(bool bSync) const;
ResMatPix CopyTo(void *p) const;

Expand Down Expand Up @@ -179,6 +181,8 @@ struct ResMat : public ResCommon<ResMatData> {
return ResMatTexCoordGen(&ofs_to_ptr<ResMatDLData>(ref().toResMatDLData)->dlTexCoordGen);
}

bool IsOpaque() const;

bool Bind(ResFile);
UNKTYPE Release();
UNKTYPE Init();
Expand Down
41 changes: 15 additions & 26 deletions src/d/d_rawarchive.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
#include <d/d_rawarchive.h>
#include <rvl/VI.h>

class UnkManager {
public:
/* vtable at 8050df50 */
/** 800651c0 */
virtual void CreateArc(void *data, const char *path);
/** 800653d0 */
virtual void DestroyArc(const char *path);

u32 stage;
};

extern "C" int fn_80061B10(void *d, u32 len) {

int computeChecksumInner(void *d, u32 len) {
u32 *data = (u32 *)d;
u32 result = 0;
// Compiler will unroll this loop
Expand All @@ -22,16 +12,15 @@ extern "C" int fn_80061B10(void *d, u32 len) {
return result;
}

extern "C" int fn_80061BA0(void *data, u32 len) {
int result = fn_80061B10(data, len);
int computeChecksum(void *data, u32 len) {
int result = computeChecksumInner(data, len);
return result != 0 ? result : -1;
}

extern "C" void fn_80061BE0(UnkManager *mgr, const char *name, size_t len) {
// Sets stage to all spaces
mgr->stage = 0x20202020;
// copies the stage name?
memcpy((char *)&mgr->stage, name, len);
void setPrefix(ArcCallbackHandler *mgr, const char *name, size_t len) {
mgr->mPrefix = ' ';
// Copy the actual name
memcpy(&mgr->mPrefix, name, len);
}

dRawArcEntry_c::dRawArcEntry_c() {
Expand All @@ -55,18 +44,18 @@ dRawArcEntry_c::~dRawArcEntry_c() {
}

void dRawArcEntry_c::searchCallback(void *arg, void *data, const ARCDirEntry *entry, const char *path, bool ctrl) {
UnkManager *mgr = (UnkManager *)arg;
ArcCallbackHandler *mgr = (ArcCallbackHandler *)arg;
if (entry->isDir) {
int len = strlen(entry->name);
fn_80061BE0(mgr, entry->name, len <= 4 ? len : 4);
setPrefix(mgr, entry->name, len <= 4 ? len : 4);
} else {
// dolphin: arg vtable at 8050df50
// any others?
if (ctrl) {
mgr->CreateArc(data, path);
mgr->CreateArcEntry(data, path);
// branch to 800651c0, sets up room
} else {
mgr->DestroyArc(path);
mgr->DestroyArcEntry(path);
// branch to 800653d0, destroys room
}
}
Expand Down Expand Up @@ -153,7 +142,7 @@ BOOL dRawArcEntry_c::checkArcExistsOnDiskInner(SizedString<128> &path, const cha
return true;
}

int dRawArcEntry_c::mount(const char *name, void *data, void *callbackArg, u8 mountDirection, EGG::Heap *heap) {
int dRawArcEntry_c::mount(const char *name, void *data, ArcCallbackHandler *callbackArg, u8 mountDirection, EGG::Heap *heap) {
mArcName = name;
mpArc = EGG::Archive::mount(data, heap, (mountDirection == 0 || mountDirection == 1) ? 4 : -4);
if (mpArc == nullptr) {
Expand Down Expand Up @@ -201,7 +190,7 @@ int dRawArcEntry_c::ensureLoadedMaybe(void *callbackArg) {
int result = onMount(callbackArg);
mHeap::restoreCurrentHeap();
mHeap::adjustFrmHeap(mpFrmHeap);
mChecksum = fn_80061BA0(mpData, mAmountRead);
mChecksum = computeChecksum(mpData, mAmountRead);
if (result == -1) {
return result;
}
Expand Down Expand Up @@ -233,7 +222,7 @@ dRawArcTable_c::~dRawArcTable_c() {
}
}

bool dRawArcTable_c::init(u16 count, void *callbackArg, EGG::Heap *heap) {
bool dRawArcTable_c::init(u16 count, ArcCallbackHandler *callbackArg, EGG::Heap *heap) {
mpEntries = new (heap, 0x04) dRawArcEntry_c[count]();
if (mpEntries == nullptr) {
return false;
Expand Down
Loading