xoreos  0.0.5
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Aurora::NDSFile Class Reference

A class encapsulating Nintendo DS ROM access. More...

#include <ndsrom.h>

Inheritance diagram for Aurora::NDSFile:
Inheritance graph
[legend]
Collaboration diagram for Aurora::NDSFile:
Collaboration graph
[legend]

Classes

struct  IResource
 Internal resource information. More...
 

Public Member Functions

 NDSFile (const Common::UString &fileName)
 Over this file in the filesystem and read a NDS file out of it. More...
 
 NDSFile (Common::SeekableReadStream *nds)
 Take over this stream and read a NDS file out of it. More...
 
 ~NDSFile ()
 
bool hasResource (Common::UString name) const
 Does the Nintendo DS ROM contain a certain resource? More...
 
const ResourceListgetResources () const
 Return the list of resources. More...
 
uint32 getResourceSize (uint32 index) const
 Return the size of a resource. More...
 
Common::SeekableReadStreamgetResource (uint32 index, bool tryNoCopy=false) const
 Return a stream of the resource's contents. More...
 
const Common::UStringgetTitle () const
 Return the game title string stored in the NDS header. More...
 
const Common::UStringgetCode () const
 Return the game code string stored in the NDS header. More...
 
const Common::UStringgetMaker () const
 Return the maker code string stored in the NDS header. More...
 
- Public Member Functions inherited from Aurora::Archive
 Archive ()
 
virtual ~Archive ()
 
virtual Common::HashAlgo getNameHashAlgo () const
 Return with which algorithm the name is hashed. More...
 
uint32 findResource (uint64 hash) const
 Return the index of the resource matching the hash, or 0xFFFFFFFF if not found. More...
 
uint32 findResource (const Common::UString &name, FileType type) const
 Return the index of the resource matching the name and type, or 0xFFFFFFFF if not found. More...
 

Static Public Member Functions

static bool isNDS (Common::SeekableReadStream &stream, Common::UString &title, Common::UString &code, Common::UString &maker)
 Check if a stream is a valid Nintendo DS ROM and read its title, code and maker strings. More...
 

Private Types

typedef std::vector< IResourceIResourceList
 

Private Member Functions

void load (Common::SeekableReadStream &nds)
 
void readNames (Common::SeekableReadStream &nds, uint32 offset, uint32 length)
 
void readFAT (Common::SeekableReadStream &nds, uint32 offset)
 
const IResourcegetIResource (uint32 index) const
 

Private Attributes

Common::ScopedPtr< Common::SeekableReadStream_nds
 
Common::UString _title
 
Common::UString _code
 
Common::UString _maker
 
ResourceList _resources
 External list of resource names and types. More...
 
IResourceList _iResources
 Internal list of resource offsets and sizes. More...
 

Additional Inherited Members

- Public Types inherited from Aurora::Archive
typedef std::list< ResourceResourceList
 

Detailed Description

A class encapsulating Nintendo DS ROM access.

Definition at line 45 of file ndsrom.h.

Member Typedef Documentation

◆ IResourceList

typedef std::vector<IResource> Aurora::NDSFile::IResourceList
private

Definition at line 83 of file ndsrom.h.

Constructor & Destructor Documentation

◆ NDSFile() [1/2]

Aurora::NDSFile::NDSFile ( const Common::UString fileName)

Over this file in the filesystem and read a NDS file out of it.

Definition at line 41 of file ndsrom.cpp.

References _nds, load(), and Common::ScopedPtrBase< T, Deallocator >::reset().

Here is the call graph for this function:

◆ NDSFile() [2/2]

Aurora::NDSFile::NDSFile ( Common::SeekableReadStream nds)

Take over this stream and read a NDS file out of it.

Definition at line 47 of file ndsrom.cpp.

References _nds, and load().

Here is the call graph for this function:

◆ ~NDSFile()

Aurora::NDSFile::~NDSFile ( )

Definition at line 53 of file ndsrom.cpp.

Member Function Documentation

◆ getCode()

const Common::UString & Aurora::NDSFile::getCode ( ) const

Return the game code string stored in the NDS header.

Definition at line 114 of file ndsrom.cpp.

References _code.

◆ getIResource()

const NDSFile::IResource & Aurora::NDSFile::getIResource ( uint32  index) const
private

Definition at line 155 of file ndsrom.cpp.

References _iResources.

Referenced by getResource(), and getResourceSize().

Here is the caller graph for this function:

◆ getMaker()

const Common::UString & Aurora::NDSFile::getMaker ( ) const

Return the maker code string stored in the NDS header.

Definition at line 118 of file ndsrom.cpp.

References _maker.

◆ getResource()

Common::SeekableReadStream * Aurora::NDSFile::getResource ( uint32  index,
bool  tryNoCopy = false 
) const
virtual

Return a stream of the resource's contents.

Implements Aurora::Archive.

Definition at line 166 of file ndsrom.cpp.

References _nds, Common::ScopedPtrBase< T, Deallocator >::get(), getIResource(), Aurora::NDSFile::IResource::offset, and Aurora::NDSFile::IResource::size.

Here is the call graph for this function:

◆ getResources()

const Archive::ResourceList & Aurora::NDSFile::getResources ( ) const
virtual

Return the list of resources.

Implements Aurora::Archive.

Definition at line 151 of file ndsrom.cpp.

References _resources.

◆ getResourceSize()

uint32 Aurora::NDSFile::getResourceSize ( uint32  index) const
virtual

Return the size of a resource.

Reimplemented from Aurora::Archive.

Definition at line 162 of file ndsrom.cpp.

References getIResource(), and Aurora::NDSFile::IResource::size.

Here is the call graph for this function:

◆ getTitle()

const Common::UString & Aurora::NDSFile::getTitle ( ) const

Return the game title string stored in the NDS header.

Definition at line 110 of file ndsrom.cpp.

References _title.

◆ hasResource()

bool Aurora::NDSFile::hasResource ( Common::UString  name) const

Does the Nintendo DS ROM contain a certain resource?

Definition at line 141 of file ndsrom.cpp.

References _resources, Common::UString::makeLower(), and TypeMan.

Referenced by Engines::Sonic::SonicEngine::detectLanguages().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNDS()

bool Aurora::NDSFile::isNDS ( Common::SeekableReadStream stream,
Common::UString title,
Common::UString code,
Common::UString maker 
)
static

Check if a stream is a valid Nintendo DS ROM and read its title, code and maker strings.

Definition at line 122 of file ndsrom.cpp.

References Common::kEncodingASCII, Common::readStringFixed(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::size().

Referenced by load(), and Engines::Sonic::EngineProbe::probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

void Aurora::NDSFile::load ( Common::SeekableReadStream nds)
private

Definition at line 56 of file ndsrom.cpp.

References _code, _maker, _title, Common::StackException::add(), isNDS(), readFAT(), readNames(), Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::seek().

Referenced by NDSFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFAT()

void Aurora::NDSFile::readFAT ( Common::SeekableReadStream nds,
uint32  offset 
)
private

Definition at line 100 of file ndsrom.cpp.

References _iResources, _resources, Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::seek().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readNames()

void Aurora::NDSFile::readNames ( Common::SeekableReadStream nds,
uint32  offset,
uint32  length 
)
private

Member Data Documentation

◆ _code

Common::UString Aurora::NDSFile::_code
private

Definition at line 88 of file ndsrom.h.

Referenced by getCode(), and load().

◆ _iResources

IResourceList Aurora::NDSFile::_iResources
private

Internal list of resource offsets and sizes.

Definition at line 95 of file ndsrom.h.

Referenced by getIResource(), and readFAT().

◆ _maker

Common::UString Aurora::NDSFile::_maker
private

Definition at line 89 of file ndsrom.h.

Referenced by getMaker(), and load().

◆ _nds

Common::ScopedPtr<Common::SeekableReadStream> Aurora::NDSFile::_nds
private

Definition at line 85 of file ndsrom.h.

Referenced by getResource(), and NDSFile().

◆ _resources

ResourceList Aurora::NDSFile::_resources
private

External list of resource names and types.

Definition at line 92 of file ndsrom.h.

Referenced by getResources(), hasResource(), readFAT(), and readNames().

◆ _title

Common::UString Aurora::NDSFile::_title
private

Definition at line 87 of file ndsrom.h.

Referenced by getTitle(), and load().


The documentation for this class was generated from the following files: