NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_res.hpp
1#pragma once
2#include <types.h>
3#include <lib/rvl/arc/ARC.h>
4#include <lib/egg/heap/eggHeap.hpp>
5#include <lib/egg/heap/eggFrmHeap.hpp>
6#include <lib/egg/archive.hpp>
7#include <game/mLib/m_dvd.h>
8
77class dRes_c {
78public:
79
82 class callback_c {
83 public:
85 virtual void init(const char *name) = 0;
86
94 virtual void *execute(void *data, u32 folderSig, const char* path) = 0;
95 };
96
100 public:
102 searchCallback_c(callback_c *callback, u8 **files, int numFiles, int fileIdx, u32 folderSig) :
104 mpFiles(files),
105 mNumFiles(numFiles),
106 mFileIdx(fileIdx),
107 mFolderSig(folderSig) {
108 }
109
111 static void callback(void *cbInfo, void *file, const ARCDirEntry *dirEntry, const char *path);
112
113 private:
115 void callback(void *file, const ARCDirEntry *dirEntry, const char *path);
116
118 u8 **mpFiles;
120 unsigned int mFileIdx;
122 };
123
147 class info_c {
148 public:
149
156
157 info_c();
158 ~info_c();
159
162 bool cleanup();
163
173 bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap);
174
182
183 const char *getName() const { return mName; }
184 int getRefCount() const { return mRefCount; }
185
190
194 EGG::Archive *getArchive() const { return mpArchive; }
195
196 void incRefCount() { mRefCount++; }
197 void decRefCount() { mRefCount--; }
198
199 private:
200
207
208 char mName[0x20];
215
219
220 u8 **mpFiles;
221 };
222
223 dRes_c();
224 ~dRes_c();
225
233 bool init(u16 maxCount, callback_c *callback);
234
243 bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap);
244
251 bool deleteRes(const char *arcName);
252
260 void *getRes(const char *arcName, const char *resPath) const;
261
270 void *getRes(const char *arcName, const char *resPath, unsigned long *size) const;
271
285 void *getRes(const char *arcName, const char *resPath, unsigned long *size, int *compressionType) const;
286
289 void *getResSilently(const char *arcName, const char *resPath) const;
290
293 void *getResSilently(const char *arcName, const char *resPath, unsigned long *size) const;
294
297 bool syncAllRes();
298
299private:
305 info_c *getResInfo(const char *arcName) const;
306
313 info_c *getResInfoLoaded(const char *arcName) const;
314
318
319public:
321 static void copyRes(const void *from, void *to, int size);
322
326 static void copyRes(const void *from, void *to, int size, int compressionType);
327
328private:
332
334 static void (*mSetCallback)(const char *arcName, EGG::Heap *heap);
335};
A callback class for processing resources.
Definition d_res.hpp:82
virtual void init(const char *name)=0
Initializes the callback with the resource name.
virtual void * execute(void *data, u32 folderSig, const char *path)=0
Executes the callback.
An archive holder.
Definition d_res.hpp:147
EGG::Archive * mpArchive
The accessor for this archive.
Definition d_res.hpp:211
bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap)
Sets information about the archive to be loaded.
mDvd_mountMemArchive_c * getDvdCmd() const
Gets the file loading command.
Definition d_res.hpp:189
~info_c()
Destroys the archive holder.
LOAD_STATUS_e
The loading status of the archive.
Definition d_res.hpp:151
@ LOAD_IN_PROGRESS
The archive is currently being loaded.
Definition d_res.hpp:154
@ LOAD_SUCCESS
The archive was loaded successfully.
Definition d_res.hpp:153
@ LOAD_ERROR
An error occurred while loading the archive.
Definition d_res.hpp:152
info_c()
Constructs a new archive holder.
Definition d_res_info.cpp:7
EGG::Heap * mpMountHeap
The heap used for mounting the archive.
Definition d_res.hpp:212
mDvd_mountMemArchive_c * mpDvdCmd
The DVD command for mounting the archive.
Definition d_res.hpp:210
void decRefCount()
Decrements the reference count.
Definition d_res.hpp:197
char mName[0x20]
The name of the archive.
Definition d_res.hpp:208
void * mpArcBinary
The raw archive data.
Definition d_res.hpp:213
u8 ** mpFiles
An array of pointers to the data of each loaded resource.
Definition d_res.hpp:220
int mArchiveSize
The archive size.
Definition d_res.hpp:214
void incRefCount()
Increments the reference count.
Definition d_res.hpp:196
LOAD_STATUS_e loadRes(callback_c *callback)
Builds the resource list and executes a callback on each file and directory.
EGG::FrmHeap * mDataHeap
The heap used for loading the resources of the archive.
Definition d_res.hpp:218
u16 mRefCount
The number of references to this archive.
Definition d_res.hpp:209
EGG::Archive * getArchive() const
Gets the archive accessor.
Definition d_res.hpp:194
bool cleanup()
Unmounts the archive and frees the holder for use.
LOAD_STATUS_e setRes(callback_c *callback)
Attempts to load the archive into memory and load the resources with a callback.
A callback class for EGG::Archive::searchInside.
Definition d_res.hpp:99
searchCallback_c(callback_c *callback, u8 **files, int numFiles, int fileIdx, u32 folderSig)
Constructs a new searchCallback_c.
Definition d_res.hpp:102
unsigned int mFileIdx
The index of the current file in mpFiles.
Definition d_res.hpp:120
callback_c * mpCallback
The file processing callback.
Definition d_res.hpp:117
u32 mFolderSig
The first 4 characters of the current folder.
Definition d_res.hpp:121
u8 ** mpFiles
An array of pointers to the data of each loaded resource.
Definition d_res.hpp:118
static void callback(void *cbInfo, void *file, const ARCDirEntry *dirEntry, const char *path)
The callback function.
int mNumFiles
The number of files in mpFiles.
Definition d_res.hpp:119
An archive resource management class.
Definition d_res.hpp:77
~dRes_c()
Destroys the manager.
Definition d_res.cpp:13
info_c * newResInfo()
Gets a free archive holder that can be used to store an archive reference.
Definition d_res.cpp:206
u16 mNumArcs
The number of archive holders.
Definition d_res.hpp:330
dRes_c()
Constructs a new manager.
Definition d_res.cpp:7
static void copyRes(const void *from, void *to, int size)
Copies an uncompressed resource.
Definition d_res.cpp:130
info_c * getResInfoLoaded(const char *arcName) const
Gets the holder for a loaded archive.
Definition d_res.cpp:218
static void(* mSetCallback)(const char *arcName, EGG::Heap *heap)
[Unused]. The callback for when an archive is scheduled for loading.
Definition d_res.hpp:334
callback_c * mpCallback
The callback for when a resource is loaded.
Definition d_res.hpp:331
bool syncAllRes()
Attempts to load the resources of an archive that has finished loading since the last call to this fu...
Definition d_res.cpp:181
bool deleteRes(const char *arcName)
Marks an archive as no longer needed.
Definition d_res.cpp:50
void * getRes(const char *arcName, const char *resPath) const
Gets a resource.
Definition d_res.cpp:64
info_c * mpArcInfos
An array of archive holders.
Definition d_res.hpp:329
void * getResSilently(const char *arcName, const char *resPath) const
Gets a resource without logging a message if the resource is not found.
Definition d_res.cpp:142
bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap)
Schedules an archive for loading.
Definition d_res.cpp:32
bool init(u16 maxCount, callback_c *callback)
Initializes the manager by allocating the archive holders and setting the callback.
Definition d_res.cpp:21
info_c * getResInfo(const char *arcName) const
Gets the holder for an archive.
Definition d_res.cpp:194