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

loadCourse, requestLoad decomp #6

Merged
merged 2 commits into from
Jun 19, 2022
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
3 changes: 2 additions & 1 deletion pack/rel_objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ out/rel/data_808b2d50_808b3188.o
out/LocalizedArchive.o
out/MultiDvdArchive.o
out/rel/text_8052ae5c_8053fc4c.o
out/rel/rodata_8088fe28_80891370.o
out/rel/rodata_8088fe28_80890ae8.o
out/rel/data_808b31e8_808b3c08.o
out/ResourceManager.o
out/rel/text_80542878_80555464.o
out/rel/rodata_80890b20_80891370.o
out/rel/data_808b3c2c_808b42e0.o
out/Random.o
out/rel/text_8055572c_80590128.o
Expand Down
2 changes: 1 addition & 1 deletion pack/rel_slices.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enabled,name,textStart,textEnd,ctorsStart,ctorsEnd,dtorsStart,dtorsEnd,rodataSta
1,source/game/system/GhostFile.cpp,0x8051c088,0x8051d4d4,,,,,,,0x808b2d38,0x808b2d50,,
1,source/game/system/LocalizedArchive.cpp,0x8052a098,0x8052a538,,,,,0x8088fdc0,0x8088fe00,0x808b3188,0x808b31d8,,
1,source/game/system/MultiDvdArchive.cpp,0x8052a538,0x8052ae5c,,,,,0x8088fe00,0x8088fe28,0x808b31d8,0x808b31e8,,
1,source/game/system/ResourceManager.cpp,0x8053FC4C,0x80542878,,,,,,,0x808b3c08,0x808b3c2c,,
1,source/game/system/ResourceManager.cpp,0x8053FC4C,0x80542878,,,,,0x80890AE8,0x80890B20,0x808b3c08,0x808b3c2c,,
1,source/game/util/Random.cpp,0x80555464,0x8055572c,,,,,0x80891370,0x80891380,0x808b42e0,0x808b42ec,,
1,source/game/kart/KartComponent.cpp,0x80590128,0x805901d0,,,,,,,,,0x809c1900,0x809c1910
1,source/game/ui/ControlGroup.cpp,0x805c23e4,0x805c2c18,,,,,,,,,,
Expand Down
76 changes: 46 additions & 30 deletions source/game/system/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

#include "rvl/os/osThread.h"



extern const char* COURSE_NAMES[];

extern const int arr_80890AE8[];
const int arr_80890AE8[] = {
819200,
921600,
36,
48,
14,
51200
};

extern "C" {
extern UNKNOWN_FUNCTION(load__Q26System10DvdArchiveFPCcUlPQ23EGG4Heap);
extern UNKNOWN_FUNCTION(getFileCopy__Q26System10DvdArchiveFPcPQ23EGG4HeapPUlSc);
Expand Down Expand Up @@ -349,10 +363,10 @@ asm UNKNOWN_FUNCTION(unk_80540038) {
// clang-format on
}

// Symbol: ResourceManager_process
// Symbol: process__Q26System15ResourceManagerFv
// PAL: 0x805400a0..0x805401ec
MARK_BINARY_BLOB(ResourceManager_process, 0x805400a0, 0x805401ec);
asm UNKNOWN_FUNCTION(ResourceManager_process) {
MARK_BINARY_BLOB(process__Q26System15ResourceManagerFv, 0x805400a0, 0x805401ec);
asm UNKNOWN_FUNCTION(process__Q26System15ResourceManagerFv) {
// clang-format off
nofralloc;
stwu r1, -0x20(r1);
Expand Down Expand Up @@ -477,7 +491,7 @@ asm UNKNOWN_FUNCTION(unk_805401fc) {

// Symbol: unk_8054020c
// PAL: 0x8054020c..0x805402c0
MARK_BINARY_BLOB(unk_8054020c, 0x8054020c, 0x805402c0);
/*MARK_BINARY_BLOB(unk_8054020c, 0x8054020c, 0x805402c0);
asm UNKNOWN_FUNCTION(unk_8054020c) {
// clang-format off
nofralloc;
Expand Down Expand Up @@ -505,7 +519,7 @@ asm UNKNOWN_FUNCTION(unk_8054020c) {
lwz r3, 0x584(r27);
bl unk_805553b0;
mr r3, r27;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r29;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand All @@ -528,6 +542,21 @@ asm UNKNOWN_FUNCTION(unk_8054020c) {
addi r1, r1, 0x20;
blr;
// clang-format on
}*/

namespace System {
void ResourceManager::requestLoad(s32 idx, MultiDvdArchive* m, const char* p, EGG::Heap* archiveHeap) {
this->jobContexts[idx].multiArchive = m;
strncpy(this->jobContexts[idx].filename, p, 0x40);
this->jobContexts[idx].archiveHeap = archiveHeap;

this->taskThread->request(ResourceManager::doLoadTask, (void*)idx, 0);
this->process();

if (!m->isLoaded()) {
OSSleepMilliseconds(16);
}
}
}

// Symbol: unk_805402c0
Expand Down Expand Up @@ -562,7 +591,7 @@ asm UNKNOWN_FUNCTION(unk_805402c0) {
lwz r3, 0x584(r26);
bl unk_805553b0;
mr r3, r26;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
lwz r0, 0x20(r28);
li r3, 0;
cmpwi r0, 4;
Expand Down Expand Up @@ -627,7 +656,7 @@ asm UNKNOWN_FUNCTION(unk_80540394) {
lwz r3, 0x584(r26);
bl unk_805553b0;
mr r3, r26;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r28;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -699,7 +728,7 @@ asm UNKNOWN_FUNCTION(ResourceManager_load) {
li r6, 0;
bl unk_805553b0;
mr r3, r31;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r30;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -781,7 +810,7 @@ asm UNKNOWN_FUNCTION(unk_80540558) {
li r6, 0;
bl unk_805553b0;
mr r3, r30;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
lwz r0, 0x2c8(r28);
li r3, 0;
cmpwi r0, 4;
Expand Down Expand Up @@ -853,7 +882,7 @@ asm UNKNOWN_FUNCTION(ResourceManager_loadUI) {
li r6, 0;
bl unk_805553b0;
mr r3, r29;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r31;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -975,7 +1004,7 @@ asm UNKNOWN_FUNCTION(ResourceManager_loadCourse) {
li r6, 0;
bl unk_805553b0;
mr r3, r31;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r30;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -1006,19 +1035,6 @@ asm UNKNOWN_FUNCTION(ResourceManager_loadCourse) {
}*/

namespace System {
void ResourceManager::requestLoad(s32 idx, MultiDvdArchive* m, const char* p, EGG::Heap* archiveHeap) {
this->jobContexts[idx].multiArchive = m;
strncpy(this->jobContexts[idx].filename, p, 0x40);
this->jobContexts[idx].archiveHeap = archiveHeap;

this->taskThread->request(ResourceManager::doLoadTask, (void*)idx, 0);
this->process();

if (!m->isLoaded()) {
OSSleepMilliseconds(16);
}
}

MultiDvdArchive* ResourceManager::loadCourse(CourseId courseId, EGG::Heap* param_3, bool splitScreen) {
char courseName[128];

Expand Down Expand Up @@ -1160,7 +1176,7 @@ asm UNKNOWN_FUNCTION(ResourceManager_loadMission) {
li r6, 0;
bl unk_805553b0;
mr r3, r28;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r29;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -1297,7 +1313,7 @@ asm UNKNOWN_FUNCTION(ResourceManager_loadCompetition) {
li r6, 0;
bl unk_805553b0;
mr r3, r23;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r21;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -1389,7 +1405,7 @@ asm UNKNOWN_FUNCTION(unk_80540cfc) {
li r6, 0;
bl unk_805553b0;
mr r3, r28;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r31;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -1489,7 +1505,7 @@ asm UNKNOWN_FUNCTION(unk_80540e3c) {
li r6, 0;
bl unk_805553b0;
mr r3, r30;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r31;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -1590,7 +1606,7 @@ asm UNKNOWN_FUNCTION(unk_80540f90) {
li r6, 0;
bl unk_805553b0;
mr r3, r30;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
mr r3, r31;
bl isLoaded__Q26System15MultiDvdArchiveFv;
cmpwi r3, 0;
Expand Down Expand Up @@ -2674,7 +2690,7 @@ asm UNKNOWN_FUNCTION(unk_80541c48) {
cmpwi r31, 0;
beq lbl_80541ca0;
mr r3, r30;
bl ResourceManager_process;
bl process__Q26System15ResourceManagerFv;
lbl_80541ca0:
mr r3, r31;
lwz r31, 0xc(r1);
Expand Down
8 changes: 3 additions & 5 deletions source/game/system/ResourceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ UNKNOWN_FUNCTION(ResourceManager_destroy);
// PAL: 0x80540038..0x805400a0
UNKNOWN_FUNCTION(unk_80540038);
// PAL: 0x805400a0..0x805401ec
UNKNOWN_FUNCTION(ResourceManager_process);
UNKNOWN_FUNCTION(process__Q26System15ResourceManagerFv);
// PAL: 0x805401ec..0x805401fc
UNKNOWN_FUNCTION(unk_805401ec);
// PAL: 0x805401fc..0x8054020c
Expand Down Expand Up @@ -167,8 +167,6 @@ UNKNOWN_FUNCTION(unk_80542868);

namespace System {

const char* COURSE_NAMES[] = {"TODO"};

struct JobContext {
MultiDvdArchive* multiArchive;
DvdArchive* archive;
Expand Down Expand Up @@ -213,8 +211,8 @@ class CourseCache : EGG::Disposer {
//private: // idk if rii prefers to befriend every class over public-ing everything
void* mBuffer;
EGG::ExpHeap* mHeap;
u32 mCourseId;
volatile u32 mState;
s32 mCourseId;
s32 mState;
MultiDvdArchive* mArchive;
};

Expand Down