SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
FileLoaderThread.cpp
1#include "Game/System/FileLoaderThread.hpp"
2#include "Game/System/FileRipper.hpp"
3
4#include "Inline.hpp"
5
6namespace {
7 void* loadFileUsingRipper(RequestFileInfo *pInfo) NO_INLINE {
8 s32 val = 0;
9
10 if (pInfo->mRequestType != 1) {
11 val = 1;
12 }
13
14 return FileRipper::loadToMainRAM(pInfo->mFileName, (u8*)pInfo->mFileEntry->mContext, true, pInfo->mFileEntry->mHeap, (FileRipper::AllocDirection)val);
15 }
16};
17
18FileLoaderThread::FileLoaderThread(int a1, int a2, JKRHeap *pHeap) : OSThreadWrapper(0x8000, a2, a1, pHeap) {
19
20}
21
22s32 FileLoaderThread::run() {
23 // OSInitFastCast
24 __asm {
25 li r3, 4
26 oris r3, r3, 4
27 mtspr 0x392, r3
28 li r3, 5
29 oris r3, r3, 5
30 mtspr 0x393, r3
31 li r3, 6
32 oris r3, r3, 6
33 mtspr 0x394, r3
34 li r3, 7
35 oris r3, r3, 7
36 mtspr 0x395, r3
37 };
38
39 while (true) {
40 OSMessage msg;
41 OSReceiveMessage(&mQueue, &msg, 1);
42 RequestFileInfo* info = (RequestFileInfo*)msg;
43
44 switch (info->_0) {
45 case 0:
46 loadToMainRAM(info);
47 break;
48 case 1:
49 mountArchiveAndStartCreateResource(info);
50 break;
51 }
52 }
53}
54
55/* this function matches in other compiler versions */
56void FileLoaderThread::loadToMainRAM(RequestFileInfo *pInfo) {
57 pInfo->_88 = 1;
58 void* data = ::loadFileUsingRipper(pInfo);
59 pInfo->mFileEntry->setContext(data, pInfo->mFileEntry->mHeap);
60 pInfo->_88 = 2;
61}
62
63/* same with this one */
64void FileLoaderThread::mountArchiveAndStartCreateResource(RequestFileInfo *pInfo) {
65 pInfo->_88 = 1;
66 void* data = ::loadFileUsingRipper(pInfo);
67 MR::createAndAddArchive(data, pInfo->mFileEntry->mHeap, pInfo->mFileName);
68 pInfo->mFileEntry->setContext(data, pInfo->mFileEntry->mHeap);
69 pInfo->_88 = 2;
70}
71
72FileLoaderThread::~FileLoaderThread() {
73
74}