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 <dol/mLib/m_dvd.h>
8
12class dRes_c {
13public:
14
17 class callback_c {
18 public:
20 virtual void init(const char *name) = 0;
21
28 virtual void *execute(void *data, u32 folderSig) = 0;
29 };
30
34 public:
36 searchCallback_c(callback_c *callback, u8 **files, int numFiles, int fileIdx, u32 folderSig) :
38 mpFiles(files),
39 mNumFiles(numFiles),
40 mFileIdx(fileIdx),
41 mFolderSig(folderSig) {
42 }
43
45 static void callback(void *cbInfo, void *file, const ARCDirEntry *dirEntry, const char *path);
46
47 private:
49 void callback(void *file, const ARCDirEntry *dirEntry, const char *path);
50
52 u8 **mpFiles;
54 unsigned int mFileIdx;
56 };
57
59 class info_c {
60 public:
61 info_c();
62 ~info_c();
63
66 bool cleanup();
67
77 bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap);
78
85 int setRes(callback_c *callback);
86
87 const char *getName() const { return mName; }
88 int getRefCount() const { return mRefCount; }
89 void *getDvdCmd() const { return mpDvdCmd; }
90 EGG::Archive *getArchive() const { return mpArchive; }
91
92 void incRefCount() { mRefCount++; }
93 void decRefCount() { mRefCount--; }
94
95 private:
96
104 int loadRes(callback_c *callback);
105
106 char mName[0x20];
112 int mUnk;
114 u8 **mpFiles;
115
116 };
117
118 dRes_c();
119 ~dRes_c();
120
128 bool init(u16 maxCount, callback_c *callback);
129
139 bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap);
140
146 bool deleteRes(const char *arcName);
147
155 void *getRes(const char *arcName, const char *resPath) const;
156
165 void *getRes(const char *arcName, const char *resPath, unsigned long *size) const;
166
178 void *getRes(const char *arcName, const char *resPath, unsigned long *size, int *compressionType) const;
179
182 void *getResSilently(const char *arcName, const char *resPath) const;
183
186 void *getResSilently(const char *arcName, const char *resPath, unsigned long *size) const;
187
190 bool syncAllRes();
191
198 info_c *getResInfo(const char *arcName) const;
199
205 info_c *getResInfoLoaded(const char *arcName) const;
206
210
212 static void copyRes(const void *from, void *to, int size);
213
215 static void copyRes(const void *from, void *to, int size, int compressionType);
216
217
218private:
222
224 static void (*mSetCallback)(const char *arcName, EGG::Heap *heap);
225};
A callback class for processing resources.
Definition d_res.hpp:17
virtual void init(const char *name)=0
Initializes the callback with the resource name.
virtual void * execute(void *data, u32 folderSig)=0
Executes the callback.
A class that holds information about an archive.
Definition d_res.hpp:59
EGG::Archive * mpArchive
An EGG::Archive instance for this archive.
Definition d_res.hpp:109
bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap)
Sets information about the archive to be loaded.
~info_c()
Destroys this info_c.
info_c()
Constructs a new info_c.
Definition d_res_info.cpp:7
EGG::Heap * mpMountHeap
The heap used for mounting the archive.
Definition d_res.hpp:110
mDvd_mountMemArchive_c * mpDvdCmd
The DVD command for mounting the archive.
Definition d_res.hpp:108
void decRefCount()
Decrements the reference count.
Definition d_res.hpp:93
char mName[0x20]
The name of the archive.
Definition d_res.hpp:106
void * mpArcBinary
The raw archive data.
Definition d_res.hpp:111
u8 ** mpFiles
An array of pointers to the data of each loaded resource.
Definition d_res.hpp:114
void incRefCount()
Increments the reference count.
Definition d_res.hpp:92
int setRes(callback_c *callback)
Attempts to load the archive into memory and load the resources with a callback.
int mUnk
Unknown.
Definition d_res.hpp:112
EGG::FrmHeap * mDataHeap
The heap used for loading the resources of the archive. [No p because of the string "dRes_c::info_c::...
Definition d_res.hpp:113
int loadRes(callback_c *callback)
Executes a callback on each file and folder of the archive.
u16 mRefCount
The number of references to this archive.
Definition d_res.hpp:107
bool cleanup()
Unmounts the archive and frees the holder for use.
A callback class for EGG::Archive::searchInside.
Definition d_res.hpp:33
searchCallback_c(callback_c *callback, u8 **files, int numFiles, int fileIdx, u32 folderSig)
Constructs a new searchCallback_c.
Definition d_res.hpp:36
unsigned int mFileIdx
The index of the current file in mpFiles.
Definition d_res.hpp:54
callback_c * mpCallback
The file processing callback.
Definition d_res.hpp:51
u32 mFolderSig
The first 4 characters of the current folder.
Definition d_res.hpp:55
u8 ** mpFiles
An array of pointers to the data of each loaded resource.
Definition d_res.hpp:52
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:53
A utility class for loading resource files (files contained within a .arc file).
Definition d_res.hpp:12
~dRes_c()
Destroys this dRes_c.
Definition d_res.cpp:13
info_c * newResInfo()
Gets a free info_c 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:220
dRes_c()
Constructs a new dRes_c.
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 info_c for an archive, if it exists and has been loaded into memory.
Definition d_res.cpp:218
static void(* mSetCallback)(const char *arcName, EGG::Heap *heap)
[Unused]. The callback for when dRes_c::info_c::set is called.
Definition d_res.hpp:224
callback_c * mpCallback
The callback for when a resource is loaded.
Definition d_res.hpp:221
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 the archive as no longer needed.
Definition d_res.cpp:50
void * getRes(const char *arcName, const char *resPath) const
Loads a resource.
Definition d_res.cpp:64
info_c * mpArcInfos
An array of archive holders.
Definition d_res.hpp:219
void * getResSilently(const char *arcName, const char *resPath) const
Loads 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)
Registers an archive to be loaded next.
Definition d_res.cpp:32
bool init(u16 maxCount, callback_c *callback)
Initializes the dRes_c.
Definition d_res.cpp:21
info_c * getResInfo(const char *arcName) const
Gets the info_c for an archive, if it exists.
Definition d_res.cpp:194