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

#include <nsbtxfile.h>

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

Classes

struct  Palette
 
struct  ReadContext
 
struct  Texture
 

Public Member Functions

 NSBTXFile (Common::SeekableReadStream *nsbtx)
 Take over this stream and read an NSBTX file out of it. More...
 
 ~NSBTXFile ()
 
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...
 
- 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...
 

Private Types

enum  Format {
  kFormatNoTexture = 0, kFormatA3I5 = 1, kFormat2bpp = 2, kFormat4bpp = 3,
  kFormat8bpp = 4, kFormat4x4Compressed = 5, kFormatA5I3 = 6, kFormat16bpp = 7
}
 
enum  Transform { kTransformNone = 0, kTransformTexCoord = 1, kTransformNormal = 2, kTransformVertex = 3 }
 
typedef std::vector< TextureTextures
 
typedef std::vector< PalettePalettes
 

Private Member Functions

void load (Common::SeekableSubReadStreamEndian &nsbtx)
 
void readHeader (Common::SeekableSubReadStreamEndian &nsbtx)
 
void readFileHeader (Common::SeekableSubReadStreamEndian &nsbtx)
 
void readInfoHeader (Common::SeekableSubReadStreamEndian &nsbtx)
 
void readTextures (Common::SeekableSubReadStreamEndian &nsbtx)
 
void readPalettes (Common::SeekableSubReadStreamEndian &nsbtx)
 
void createResourceList ()
 
const PalettefindPalette (const Texture &texture) const
 
void getPalette (ReadContext &ctx) const
 

Static Private Member Functions

static uint32 getITEXSize (const Texture &texture)
 
static void writeITEXHeader (const ReadContext &ctx)
 
static void writePixel (const ReadContext &ctx, byte r, byte g, byte b, byte a)
 
static void getTexture (const ReadContext &ctx)
 
static void getTexture2bpp (const ReadContext &ctx)
 
static void getTexture4bpp (const ReadContext &ctx)
 
static void getTexture8bpp (const ReadContext &ctx)
 
static void getTexture16bpp (const ReadContext &ctx)
 
static void getTextureA3I5 (const ReadContext &ctx)
 
static void getTextureA5I3 (const ReadContext &ctx)
 

Private Attributes

Common::ScopedPtr< Common::SeekableSubReadStreamEndian_nsbtx
 The name of the NSBTX file. More...
 
ResourceList _resources
 External list of resource names and types. More...
 
uint32 _textureOffset
 
uint32 _textureInfoOffset
 
uint32 _paletteInfoOffset
 
uint32 _textureDataOffset
 
uint32 _paletteDataOffset
 
Textures _textures
 
Palettes _palettes
 

Additional Inherited Members

- Public Types inherited from Aurora::Archive
typedef std::list< ResourceResourceList
 
- Static Protected Member Functions inherited from Aurora::NitroFile
static Common::SeekableSubReadStreamEndianopen (Common::SeekableReadStream &stream)
 Treat this stream as a Nitro file and return an endian'd stream according to its BOM. More...
 
static Common::SeekableSubReadStreamEndianopen (Common::SeekableReadStream *stream)
 Treat this stream as a Nitro file, take it over and return an endian'd stream according to its BOM. More...
 

Detailed Description

Definition at line 45 of file nsbtxfile.h.

Member Typedef Documentation

◆ Palettes

typedef std::vector<Palette> Aurora::NSBTXFile::Palettes
private

Definition at line 115 of file nsbtxfile.h.

◆ Textures

typedef std::vector<Texture> Aurora::NSBTXFile::Textures
private

Definition at line 114 of file nsbtxfile.h.

Member Enumeration Documentation

◆ Format

Enumerator
kFormatNoTexture 

Empty.

kFormatA3I5 

3bit alpha + 5bit color index.

kFormat2bpp 

2bit color index.

kFormat4bpp 

4bit color index.

kFormat8bpp 

8bit color index.

kFormat4x4Compressed 

32bit per 4x4 texel block (Unsupported).

kFormatA5I3 

5bit alpha + 3bit color index.

kFormat16bpp 

R5B5G5A1.

Definition at line 61 of file nsbtxfile.h.

◆ Transform

Enumerator
kTransformNone 

No extra texture coordinate transform.

kTransformTexCoord 

Transform texture coordinates using TexCoords.

kTransformNormal 

Transform texture coordinates using Normals.

kTransformVertex 

Transform texture coordinates using Vertices.

Definition at line 72 of file nsbtxfile.h.

Constructor & Destructor Documentation

◆ NSBTXFile()

Aurora::NSBTXFile::NSBTXFile ( Common::SeekableReadStream nsbtx)

Take over this stream and read an NSBTX file out of it.

Definition at line 84 of file nsbtxfile.cpp.

References _nsbtx, load(), Aurora::NitroFile::open(), and Common::ScopedPtrBase< T, Deallocator >::reset().

Here is the call graph for this function:

◆ ~NSBTXFile()

Aurora::NSBTXFile::~NSBTXFile ( )

Definition at line 92 of file nsbtxfile.cpp.

Member Function Documentation

◆ createResourceList()

void Aurora::NSBTXFile::createResourceList ( )
private

Definition at line 509 of file nsbtxfile.cpp.

References _resources, _textures, and Aurora::kFileTypeXEOSITEX.

Referenced by load().

Here is the caller graph for this function:

◆ findPalette()

const NSBTXFile::Palette * Aurora::NSBTXFile::findPalette ( const Texture texture) const
private

Definition at line 248 of file nsbtxfile.cpp.

References _palettes, and Aurora::NSBTXFile::Texture::name.

Referenced by getPalette().

Here is the caller graph for this function:

◆ getITEXSize()

uint32 Aurora::NSBTXFile::getITEXSize ( const Texture texture)
staticprivate

Definition at line 99 of file nsbtxfile.cpp.

References Aurora::NSBTXFile::Texture::height, kXEOSITEXHeaderSize, kXEOSITEXMipMapHeaderSize, and Aurora::NSBTXFile::Texture::width.

Referenced by getResource(), and getResourceSize().

Here is the caller graph for this function:

◆ getPalette()

void Aurora::NSBTXFile::getPalette ( ReadContext ctx) const
private

◆ getResource()

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

Return a stream of the resource's contents.

Implements Aurora::Archive.

Definition at line 327 of file nsbtxfile.cpp.

References _nsbtx, _textures, Common::MemoryWriteStreamDynamic::getData(), getITEXSize(), getPalette(), getTexture(), Common::MemoryWriteStreamDynamic::setDisposable(), Common::MemoryWriteStreamDynamic::size(), and writeITEXHeader().

Here is the call graph for this function:

◆ getResources()

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

Return the list of resources.

Implements Aurora::Archive.

Definition at line 95 of file nsbtxfile.cpp.

References _resources.

◆ getResourceSize()

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

Return the size of a resource.

Reimplemented from Aurora::Archive.

Definition at line 103 of file nsbtxfile.cpp.

References _textures, and getITEXSize().

Here is the call graph for this function:

◆ getTexture()

void Aurora::NSBTXFile::getTexture ( const ReadContext ctx)
staticprivate

◆ getTexture16bpp()

void Aurora::NSBTXFile::getTexture16bpp ( const ReadContext ctx)
staticprivate

Definition at line 196 of file nsbtxfile.cpp.

References Aurora::NSBTXFile::Texture::height, Aurora::NSBTXFile::ReadContext::nsbtx, Common::SeekableSubReadStreamEndian::readUint16(), Aurora::NSBTXFile::ReadContext::texture, Aurora::NSBTXFile::Texture::width, and writePixel().

Referenced by getTexture().

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

◆ getTexture2bpp()

void Aurora::NSBTXFile::getTexture2bpp ( const ReadContext ctx)
staticprivate

◆ getTexture4bpp()

void Aurora::NSBTXFile::getTexture4bpp ( const ReadContext ctx)
staticprivate

◆ getTexture8bpp()

void Aurora::NSBTXFile::getTexture8bpp ( const ReadContext ctx)
staticprivate

◆ getTextureA3I5()

void Aurora::NSBTXFile::getTextureA3I5 ( const ReadContext ctx)
staticprivate

◆ getTextureA5I3()

void Aurora::NSBTXFile::getTextureA5I3 ( const ReadContext ctx)
staticprivate

◆ load()

void Aurora::NSBTXFile::load ( Common::SeekableSubReadStreamEndian nsbtx)
private

Definition at line 343 of file nsbtxfile.cpp.

References Common::StackException::add(), createResourceList(), readHeader(), readPalettes(), and readTextures().

Referenced by NSBTXFile().

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

◆ readFileHeader()

void Aurora::NSBTXFile::readFileHeader ( Common::SeekableSubReadStreamEndian nsbtx)
private

◆ readHeader()

void Aurora::NSBTXFile::readHeader ( Common::SeekableSubReadStreamEndian nsbtx)
private

Definition at line 358 of file nsbtxfile.cpp.

References readFileHeader(), and readInfoHeader().

Referenced by load().

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

◆ readInfoHeader()

void Aurora::NSBTXFile::readInfoHeader ( Common::SeekableSubReadStreamEndian nsbtx)
private

◆ readPalettes()

void Aurora::NSBTXFile::readPalettes ( Common::SeekableSubReadStreamEndian nsbtx)
private

◆ readTextures()

void Aurora::NSBTXFile::readTextures ( Common::SeekableSubReadStreamEndian nsbtx)
private

◆ writeITEXHeader()

void Aurora::NSBTXFile::writeITEXHeader ( const ReadContext ctx)
staticprivate

◆ writePixel()

void Aurora::NSBTXFile::writePixel ( const ReadContext ctx,
byte  r,
byte  g,
byte  b,
byte  a 
)
staticprivate

Definition at line 131 of file nsbtxfile.cpp.

References Aurora::NSBTXFile::ReadContext::stream, and Common::WriteStream::writeByte().

Referenced by getTexture16bpp(), getTexture2bpp(), getTexture4bpp(), getTexture8bpp(), getTextureA3I5(), and getTextureA5I3().

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

Member Data Documentation

◆ _nsbtx

Common::ScopedPtr<Common::SeekableSubReadStreamEndian> Aurora::NSBTXFile::_nsbtx
private

The name of the NSBTX file.

Definition at line 119 of file nsbtxfile.h.

Referenced by getResource(), and NSBTXFile().

◆ _paletteDataOffset

uint32 Aurora::NSBTXFile::_paletteDataOffset
private

Definition at line 130 of file nsbtxfile.h.

Referenced by readInfoHeader(), and readPalettes().

◆ _paletteInfoOffset

uint32 Aurora::NSBTXFile::_paletteInfoOffset
private

Definition at line 127 of file nsbtxfile.h.

Referenced by readInfoHeader(), and readPalettes().

◆ _palettes

Palettes Aurora::NSBTXFile::_palettes
private

Definition at line 133 of file nsbtxfile.h.

Referenced by findPalette(), and readPalettes().

◆ _resources

ResourceList Aurora::NSBTXFile::_resources
private

External list of resource names and types.

Definition at line 122 of file nsbtxfile.h.

Referenced by createResourceList(), and getResources().

◆ _textureDataOffset

uint32 Aurora::NSBTXFile::_textureDataOffset
private

Definition at line 129 of file nsbtxfile.h.

Referenced by readInfoHeader(), and readTextures().

◆ _textureInfoOffset

uint32 Aurora::NSBTXFile::_textureInfoOffset
private

Definition at line 126 of file nsbtxfile.h.

Referenced by readInfoHeader(), and readTextures().

◆ _textureOffset

uint32 Aurora::NSBTXFile::_textureOffset
private

Definition at line 124 of file nsbtxfile.h.

Referenced by readFileHeader(), and readInfoHeader().

◆ _textures

Textures Aurora::NSBTXFile::_textures
private

Definition at line 132 of file nsbtxfile.h.

Referenced by createResourceList(), getResource(), getResourceSize(), and readTextures().


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