NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
dRes_c::info_c Class Reference

#include <game/bases/d_res.hpp>

Description

An archive holder.

info_c is a high-level interface to resource archives ( .arc files). It is generally not accessed directly, but is managed by the outer dRes_c class. It wraps the functionalities of mDvd_mountMemArchive_c and EGG::Archive to simplify the loading and iteration of resource archives.

Loading an Archive

Use the set function to manually schedule an archive for loading. If successful, a file loading command is generated and queued to continue the loading process in the background.

Checking Progress

Use the setRes function to query the archive's loading state. Once the loading process is completed, the command is deleted and the archive's resource list is built using the provided callback.

Archive Disposal

Each archive holder features a reference count, which acts as a garbage disposal mechanism: each time the archive is requested the count increases, while it decreases when its deletion is requested. When the counter reaches zero (or the holder is deleted), the archive is automatically disposed.

Definition at line 59 of file d_res.hpp.

Public Types

enum  LOAD_STATUS_e {
  LOAD_ERROR = -1 ,
  LOAD_SUCCESS = 0 ,
  LOAD_IN_PROGRESS = 1
}
 The loading status of the archive. More...
 

Public Member Functions

 info_c ()
 Constructs a new archive holder.
 
 ~info_c ()
 Destroys the archive holder.
 
bool cleanup ()
 Unmounts the archive and frees the holder for use.
 
bool set (const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap)
 Sets information about the archive to be loaded.
 
LOAD_STATUS_e setRes (callback_c *callback)
 Attempts to load the archive into memory and load the resources with a callback.
 
const char * getName () const
 
int getRefCount () const
 
mDvd_mountMemArchive_cgetDvdCmd () const
 Gets the file loading command.
 
EGG::ArchivegetArchive () const
 Gets the archive accessor.
 
void incRefCount ()
 Increments the reference count.
 
void decRefCount ()
 Decrements the reference count.
 

Private Member Functions

LOAD_STATUS_e loadRes (callback_c *callback)
 Builds the resource list and executes a callback on each file and directory.
 

Private Attributes

char mName [0x20]
 The name of the archive.
 
u16 mRefCount
 The number of references to this archive.
 
mDvd_mountMemArchive_cmpDvdCmd
 The DVD command for mounting the archive.
 
EGG::ArchivempArchive
 The accessor for this archive.
 
EGG::HeapmpMountHeap
 The heap used for mounting the archive.
 
void * mpArcBinary
 The raw archive data.
 
int mArchiveSize
 The archive size.
 
EGG::FrmHeapmDataHeap
 The heap used for loading the resources of the archive.
 
u8 ** mpFiles
 An array of pointers to the data of each loaded resource.
 

Member Enumeration Documentation

◆ LOAD_STATUS_e

The loading status of the archive.

Enumerator
LOAD_ERROR 

An error occurred while loading the archive.

LOAD_SUCCESS 

The archive was loaded successfully.

LOAD_IN_PROGRESS 

The archive is currently being loaded.

Definition at line 63 of file d_res.hpp.

Constructor & Destructor Documentation

◆ info_c()

dRes_c::info_c::info_c ( )

Constructs a new archive holder.

Definition at line 7 of file d_res_info.cpp.

◆ ~info_c()

dRes_c::info_c::~info_c ( )

Destroys the archive holder.

Definition at line 17 of file d_res_info.cpp.

Member Function Documentation

◆ cleanup()

bool dRes_c::info_c::cleanup ( )

Unmounts the archive and frees the holder for use.

Returns
Whether the operation was successful.

Definition at line 27 of file d_res_info.cpp.

◆ set()

bool dRes_c::info_c::set ( const char * arcName,
const char * containingFolder,
u8 allocDirection,
EGG::Heap * heap )

Sets information about the archive to be loaded.

Parameters
arcNameThe name of the archive.
containingFolderThe path to the folder which the archive is in.
allocDirectionThe allocation direction. See MEMExpHeapAllocDir.
heapThe heap to load the resources of the archive into, or nullptr to use the default heap.
Returns
Whether the archive was prepared successfully and will be loaded.

Definition at line 63 of file d_res_info.cpp.

◆ setRes()

dRes_c::info_c::LOAD_STATUS_e dRes_c::info_c::setRes ( callback_c * callback)

Attempts to load the archive into memory and load the resources with a callback.

Parameters
callbackThe resource loaded callback, or nullptr .
Returns
The result of the operation.

Definition at line 79 of file d_res_info.cpp.

◆ getName()

const char * dRes_c::info_c::getName ( ) const
inline

Definition at line 95 of file d_res.hpp.

◆ getRefCount()

int dRes_c::info_c::getRefCount ( ) const
inline

Definition at line 96 of file d_res.hpp.

◆ getDvdCmd()

mDvd_mountMemArchive_c * dRes_c::info_c::getDvdCmd ( ) const
inline

Gets the file loading command.

Returns
The file loading command, or nullptr if the archive has already been loaded or the holder is empty.

Definition at line 101 of file d_res.hpp.

◆ getArchive()

EGG::Archive * dRes_c::info_c::getArchive ( ) const
inline

Gets the archive accessor.

Returns
The archive accessor, or nullptr if the archive has not yet been loaded or the holder is empty.

Definition at line 106 of file d_res.hpp.

◆ incRefCount()

void dRes_c::info_c::incRefCount ( )
inline

Increments the reference count.

Definition at line 108 of file d_res.hpp.

◆ decRefCount()

void dRes_c::info_c::decRefCount ( )
inline

Decrements the reference count.

Definition at line 109 of file d_res.hpp.

◆ loadRes()

dRes_c::info_c::LOAD_STATUS_e dRes_c::info_c::loadRes ( dRes_c::callback_c * callback)
private

Builds the resource list and executes a callback on each file and directory.

Parameters
callbackThe resource loaded callback, or nullptr .
Returns
The result of the operation.

Definition at line 143 of file d_res_info.cpp.

Member Data Documentation

◆ mName

char dRes_c::info_c::mName[0x20]
private

The name of the archive.

Definition at line 120 of file d_res.hpp.

◆ mRefCount

u16 dRes_c::info_c::mRefCount
private

The number of references to this archive.

Definition at line 121 of file d_res.hpp.

◆ mpDvdCmd

mDvd_mountMemArchive_c* dRes_c::info_c::mpDvdCmd
private

The DVD command for mounting the archive.

Definition at line 122 of file d_res.hpp.

◆ mpArchive

EGG::Archive* dRes_c::info_c::mpArchive
private

The accessor for this archive.

Definition at line 123 of file d_res.hpp.

◆ mpMountHeap

EGG::Heap* dRes_c::info_c::mpMountHeap
private

The heap used for mounting the archive.

Definition at line 124 of file d_res.hpp.

◆ mpArcBinary

void* dRes_c::info_c::mpArcBinary
private

The raw archive data.

Definition at line 125 of file d_res.hpp.

◆ mArchiveSize

int dRes_c::info_c::mArchiveSize
private

The archive size.

Definition at line 126 of file d_res.hpp.

◆ mDataHeap

EGG::FrmHeap* dRes_c::info_c::mDataHeap
private

The heap used for loading the resources of the archive.

Decompilation Note
No p because of the string "dRes_c::info_c::mDataHeap"

Definition at line 130 of file d_res.hpp.

◆ mpFiles

u8** dRes_c::info_c::mpFiles
private

An array of pointers to the data of each loaded resource.

Definition at line 132 of file d_res.hpp.