xoreos  0.0.5
nsbtxfile.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
26 #ifndef AURORA_NSBTXFILE_H
27 #define AURORA_NSBTXFILE_H
28 
29 #include <vector>
30 
31 #include "src/common/types.h"
32 #include "src/common/scopedptr.h"
33 #include "src/common/ustring.h"
34 
35 #include "src/aurora/types.h"
36 #include "src/aurora/archive.h"
37 #include "src/aurora/nitrofile.h"
38 
39 namespace Common {
40  class WriteStream;
41 }
42 
43 namespace Aurora {
44 
45 class NSBTXFile : public Archive, public NitroFile {
46 public:
49  ~NSBTXFile();
50 
52  const ResourceList &getResources() const;
53 
55  uint32 getResourceSize(uint32 index) const;
56 
58  Common::SeekableReadStream *getResource(uint32 index, bool tryNoCopy = false) const;
59 
60 private:
61  enum Format {
70  };
71 
72  enum Transform {
77  };
78 
79  struct Texture {
82 
84 
87 
88  bool wrapX;
89  bool wrapY;
90  bool flipX;
91  bool flipY;
92  bool alpha;
93 
95  };
96 
97  struct Palette {
100  };
101 
102  struct ReadContext {
103  const Texture *texture;
104 
106 
109 
111  ~ReadContext();
112  };
113 
114  typedef std::vector<Texture> Textures;
115  typedef std::vector<Palette> Palettes;
116 
117 
120 
123 
125 
128 
131 
134 
135 
137 
143 
144  void createResourceList();
145 
146  const Palette *findPalette(const Texture &texture) const;
147  void getPalette(ReadContext &ctx) const;
148 
149  static uint32 getITEXSize(const Texture &texture);
150 
151  static void writeITEXHeader(const ReadContext &ctx);
152  static void writePixel(const ReadContext &ctx, byte r, byte g, byte b, byte a);
153 
154  static void getTexture (const ReadContext &ctx);
155  static void getTexture2bpp (const ReadContext &ctx);
156  static void getTexture4bpp (const ReadContext &ctx);
157  static void getTexture8bpp (const ReadContext &ctx);
158  static void getTexture16bpp(const ReadContext &ctx);
159  static void getTextureA3I5 (const ReadContext &ctx);
160  static void getTextureA5I3 (const ReadContext &ctx);
161 };
162 
163 } // End of namespace Aurora
164 
165 #endif // AURORA_NSBTXFILE_H
Common::WriteStream * stream
Definition: nsbtxfile.h:108
Common::UString name
Definition: nsbtxfile.h:80
static void writeITEXHeader(const ReadContext &ctx)
Definition: nsbtxfile.cpp:110
const ResourceList & getResources() const
Return the list of resources.
Definition: nsbtxfile.cpp:95
Common::ScopedPtr< Common::SeekableSubReadStreamEndian > _nsbtx
The name of the NSBTX file.
Definition: nsbtxfile.h:119
NSBTXFile(Common::SeekableReadStream *nsbtx)
Take over this stream and read an NSBTX file out of it.
Definition: nsbtxfile.cpp:84
This is a wrapper around SeekableSubReadStream, but it adds non-endian read methods whose endianness ...
Definition: readstream.h:383
3bit alpha + 5bit color index.
Definition: nsbtxfile.h:63
Definition: 2dafile.h:39
Palettes _palettes
Definition: nsbtxfile.h:133
A class holding an UTF-8 string.
Definition: ustring.h:48
uint32 _textureInfoOffset
Definition: nsbtxfile.h:126
bool flipY
true: flip on every 2nd texture wrap.
Definition: nsbtxfile.h:91
void readPalettes(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:483
Transform texture coordinates using TexCoords.
Definition: nsbtxfile.h:74
Common::SeekableReadStream * getResource(uint32 index, bool tryNoCopy=false) const
Return a stream of the resource&#39;s contents.
Definition: nsbtxfile.cpp:327
void load(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:343
const Palette * findPalette(const Texture &texture) const
Definition: nsbtxfile.cpp:248
Textures _textures
Definition: nsbtxfile.h:132
void readTextures(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:419
bool alpha
true: color index 0 is transparent.
Definition: nsbtxfile.h:92
uint32 _paletteInfoOffset
Definition: nsbtxfile.h:127
void readHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:358
static void getTexture16bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:196
Handling various archive files.
static void getTextureA3I5(const ReadContext &ctx)
Definition: nsbtxfile.cpp:212
A simple scoped smart pointer template.
static void getTexture4bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:159
void readFileHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:363
void createResourceList()
Definition: nsbtxfile.cpp:509
4bit color index.
Definition: nsbtxfile.h:65
8bit color index.
Definition: nsbtxfile.h:66
uint16_t uint16
Definition: types.h:202
bool wrapY
true: wrap, false: clamp.
Definition: nsbtxfile.h:89
uint32 _paletteDataOffset
Definition: nsbtxfile.h:130
std::list< Resource > ResourceList
Definition: archive.h:57
std::vector< Palette > Palettes
Definition: nsbtxfile.h:115
Transform texture coordinates using Normals.
Definition: nsbtxfile.h:75
uint32 _textureDataOffset
Definition: nsbtxfile.h:129
Common::UString name
Definition: nsbtxfile.h:98
Low-level type definitions to handle fixed width types portably.
ResourceList _resources
External list of resource names and types.
Definition: nsbtxfile.h:122
void getPalette(ReadContext &ctx) const
Definition: nsbtxfile.cpp:264
void readInfoHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:392
bool flipX
true: flip on every 2nd texture wrap.
Definition: nsbtxfile.h:90
Generic interface for a writable data stream.
Definition: writestream.h:64
static void getTexture2bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:138
Transform texture coordinates using Vertices.
Definition: nsbtxfile.h:76
std::vector< Texture > Textures
Definition: nsbtxfile.h:114
uint32 getResourceSize(uint32 index) const
Return the size of a resource.
Definition: nsbtxfile.cpp:103
Unicode string handling.
Common::SeekableSubReadStreamEndian * nsbtx
Definition: nsbtxfile.h:107
ReadContext(Common::SeekableSubReadStreamEndian &n, const Texture &t, Common::WriteStream &s)
Definition: nsbtxfile.cpp:75
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
No extra texture coordinate transform.
Definition: nsbtxfile.h:73
Common::ScopedArray< const byte > palette
Definition: nsbtxfile.h:105
uint32_t uint32
Definition: types.h:204
static void getTexture(const ReadContext &ctx)
Definition: nsbtxfile.cpp:293
2bit color index.
Definition: nsbtxfile.h:64
Base class for Nitro (Nintendo DS) files.
An abstract file archive.
Definition: archive.h:45
32bit per 4x4 texel block (Unsupported).
Definition: nsbtxfile.h:67
uint32 _textureOffset
Definition: nsbtxfile.h:124
static uint32 getITEXSize(const Texture &texture)
Definition: nsbtxfile.cpp:99
bool wrapX
true: wrap, false: clamp.
Definition: nsbtxfile.h:88
Interface for a seekable & readable data stream.
Definition: readstream.h:265
static void writePixel(const ReadContext &ctx, byte r, byte g, byte b, byte a)
Definition: nsbtxfile.cpp:131
static void getTexture8bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:180
uint8 byte
Definition: types.h:209
5bit alpha + 3bit color index.
Definition: nsbtxfile.h:68
static void getTextureA5I3(const ReadContext &ctx)
Definition: nsbtxfile.cpp:230