xoreos  0.0.5
nsbtxfile.cpp
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 /* Based heavily on the BTX0 reader found in the NDS file viewer
27  * and editor Tinke by pleoNeX (<https://github.com/pleonex/tinke>),
28  * which is licensed under the terms of the GPLv3.
29  *
30  * Tinke in turn is based on the NSBTX documentation by lowlines
31  * (<http://llref.emutalk.net/docs/?file=xml/btx0.xml>) and the
32  * Nintendo DS technical information GBATEK by Martin Korth
33  * (<http://problemkaputt.de/gbatek.htm>).
34  *
35  * The original copyright note in Tinke reads as follows:
36  *
37  * Copyright (C) 2011 pleoNeX
38  *
39  * This program is free software: you can redistribute it and/or modify
40  * it under the terms of the GNU General Public License as published by
41  * the Free Software Foundation, either version 3 of the License, or
42  * (at your option) any later version.
43  *
44  * This program is distributed in the hope that it will be useful,
45  * but WITHOUT ANY WARRANTY; without even the implied warranty of
46  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47  * GNU General Public License for more details.
48  *
49  * You should have received a copy of the GNU General Public License
50  * along with this program. If not, see <http://www.gnu.org/licenses/>.
51  */
52 
53 #include <cassert>
54 
55 #include "src/common/util.h"
56 #include "src/common/strutil.h"
57 #include "src/common/error.h"
60 #include "src/common/encoding.h"
61 
62 #include "src/aurora/nsbtxfile.h"
63 
64 static const uint32 kXEOSID = MKTAG('X', 'E', 'O', 'S');
65 static const uint32 kITEXID = MKTAG('I', 'T', 'E', 'X');
66 
67 static const uint32 kXEOSITEXHeaderSize = 4 + 4 + 4 + 4 + 4 + 1 + 1 + 1 + 1 + 1 + 1;
68 static const uint32 kXEOSITEXMipMapHeaderSize = 4 + 4 + 4;
69 
70 static const uint32 kBTX0ID = MKTAG('B', 'T', 'X', '0');
71 static const uint32 kTEX0ID = MKTAG('T', 'E', 'X', '0');
72 
73 namespace Aurora {
74 
77  texture(&t), nsbtx(&n), stream(&s) {
78 }
79 
81 }
82 
83 
85  assert(nsbtx);
86 
87  _nsbtx.reset(open(nsbtx));
88 
89  load(*_nsbtx);
90 }
91 
93 }
94 
96  return _resources;
97 }
98 
100  return kXEOSITEXHeaderSize + kXEOSITEXMipMapHeaderSize + texture.width * texture.height * 4;
101 }
102 
104  if (index >= _textures.size())
105  throw Common::Exception("Texture index out of range (%u/%u)", index, (uint)_textures.size());
106 
107  return getITEXSize(_textures[index]);
108 }
109 
113  ctx.stream->writeUint32LE(0); // Version
114  ctx.stream->writeUint32LE(4); // Pixel format / bytes per pixel
115 
116  ctx.stream->writeByte((uint8) ctx.texture->wrapX);
117  ctx.stream->writeByte((uint8) ctx.texture->wrapY);
118  ctx.stream->writeByte((uint8) ctx.texture->flipX);
119  ctx.stream->writeByte((uint8) ctx.texture->flipY);
121 
122  ctx.stream->writeByte(0x00); // Don't filter the texture
123 
124  ctx.stream->writeUint32LE(1); // Number of mip maps
125 
126  ctx.stream->writeUint32LE(ctx.texture->width);
127  ctx.stream->writeUint32LE(ctx.texture->height);
128  ctx.stream->writeUint32LE(ctx.texture->width * ctx.texture->height * 4);
129 }
130 
131 void NSBTXFile::writePixel(const ReadContext &ctx, byte r, byte g, byte b, byte a) {
132  ctx.stream->writeByte(b);
133  ctx.stream->writeByte(g);
134  ctx.stream->writeByte(r);
135  ctx.stream->writeByte(a);
136 }
137 
139  for (uint32 y = 0; y < ctx.texture->height; y++) {
140  for (uint32 x = 0; x < ctx.texture->width; ) {
141 
142  uint8 pixels = ctx.nsbtx->readByte();
143  for (uint32 n = 0; n < 4; n++, x++, pixels >>= 2) {
144  const uint8 pixel = pixels & 3;
145 
146  const byte r = ctx.palette[pixel * 3 + 0];
147  const byte g = ctx.palette[pixel * 3 + 1];
148  const byte b = ctx.palette[pixel * 3 + 2];
149 
150  const byte a = (ctx.texture->alpha && (pixel == 0)) ? 0x00 : 0xFF;
151 
152  writePixel(ctx, r, g, b, a);
153  }
154 
155  }
156  }
157 }
158 
160  for (uint32 y = 0; y < ctx.texture->height; y++) {
161  for (uint32 x = 0; x < ctx.texture->width; ) {
162 
163  uint8 pixels = ctx.nsbtx->readByte();
164  for (uint32 n = 0; n < 2; n++, x++, pixels >>= 4) {
165  const uint8 pixel = pixels & 0xF;
166 
167  const byte r = ctx.palette[pixel * 3 + 0];
168  const byte g = ctx.palette[pixel * 3 + 1];
169  const byte b = ctx.palette[pixel * 3 + 2];
170 
171  const byte a = (ctx.texture->alpha && (pixel == 0)) ? 0x00 : 0xFF;
172 
173  writePixel(ctx, r, g, b, a);
174  }
175 
176  }
177  }
178 }
179 
181  for (uint32 y = 0; y < ctx.texture->height; y++) {
182  for (uint32 x = 0; x < ctx.texture->width; x++) {
183  const uint8 pixel = ctx.nsbtx->readByte();
184 
185  const byte r = ctx.palette[pixel * 3 + 0];
186  const byte g = ctx.palette[pixel * 3 + 1];
187  const byte b = ctx.palette[pixel * 3 + 2];
188 
189  const byte a = (ctx.texture->alpha && (pixel == 0)) ? 0x00 : 0xFF;
190 
191  writePixel(ctx, r, g, b, a);
192  }
193  }
194 }
195 
197  for (uint32 y = 0; y < ctx.texture->height; y++) {
198  for (uint32 x = 0; x < ctx.texture->width; x++) {
199  const uint16 pixel = ctx.nsbtx->readUint16();
200 
201  const byte r = ( pixel & 0x1F) << 3;
202  const byte g = ((pixel >> 5) & 0x1F) << 3;
203  const byte b = ((pixel >> 10) & 0x1F) << 3;
204 
205  const byte a = ((pixel >> 15) == 0) ? 0x00 : 0xFF;
206 
207  writePixel(ctx, r, g, b, a);
208  }
209  }
210 }
211 
213  for (uint32 y = 0; y < ctx.texture->height; y++) {
214  for (uint32 x = 0; x < ctx.texture->width; x++) {
215  const uint8 pixel = ctx.nsbtx->readByte();
216 
217  const uint8 index = pixel & 0x1F;
218 
219  const byte r = ctx.palette[index * 3 + 0];
220  const byte g = ctx.palette[index * 3 + 1];
221  const byte b = ctx.palette[index * 3 + 2];
222 
223  const byte a = (((pixel >> 5) << 2) + (pixel >> 6)) << 3;
224 
225  writePixel(ctx, r, g, b, a);
226  }
227  }
228 }
229 
231  for (uint32 y = 0; y < ctx.texture->height; y++) {
232  for (uint32 x = 0; x < ctx.texture->width; x++) {
233  const uint8 pixel = ctx.nsbtx->readByte();
234 
235  const uint8 index = pixel & 0x07;
236 
237  const byte r = ctx.palette[index * 3 + 0];
238  const byte g = ctx.palette[index * 3 + 1];
239  const byte b = ctx.palette[index * 3 + 2];
240 
241  const byte a = (pixel >> 3) << 3;
242 
243  writePixel(ctx, r, g, b, a);
244  }
245  }
246 }
247 
248 const NSBTXFile::Palette *NSBTXFile::findPalette(const Texture &texture) const {
249  std::vector<Common::UString> palNames;
250 
251  palNames.push_back(texture.name);
252  palNames.push_back(texture.name + "_pl");
253  palNames.push_back(texture.name + "_p");
254  palNames.push_back(texture.name + "_");
255 
256  for (std::vector<Common::UString>::iterator n = palNames.begin(); n != palNames.end(); ++n)
257  for (Palettes::const_iterator p = _palettes.begin(); p != _palettes.end(); ++p)
258  if (p->name == *n)
259  return &*p;
260 
261  return 0;
262 }
263 
265  static const uint16 kPaletteSize[] = { 0, 32, 4, 16, 256, 256, 8, 0 };
266 
267  const uint16 size = kPaletteSize[(size_t)ctx.texture->format] * 3;
268  if (size == 0)
269  return;
270 
271  const Palette *palette = findPalette(*ctx.texture);
272  if (!palette)
273  throw Common::Exception("Couldn't find a palette for texture \"%s\"", ctx.texture->name.c_str());
274 
275  Common::ScopedArray<byte> palData(new byte[size]);
276  memset(palData.get(), 0, size);
277 
278  ctx.nsbtx->seek(palette->offset);
279 
280  const uint16 palDataSize = MIN<size_t>(size, ((ctx.nsbtx->size() - ctx.nsbtx->pos()) / 2) * 3);
281 
282  for (uint16 i = 0; i < palDataSize; i += 3) {
283  const uint16 pixel = ctx.nsbtx->readUint16();
284 
285  palData[i + 0] = ( pixel & 0x1F) << 3;
286  palData[i + 1] = ((pixel >> 5) & 0x1F) << 3;
287  palData[i + 2] = ((pixel >> 10) & 0x1F) << 3;
288  }
289 
290  ctx.palette.reset(palData.release());
291 }
292 
294  ctx.nsbtx->seek(ctx.texture->offset);
295 
296  switch (ctx.texture->format) {
297  case kFormat2bpp:
298  getTexture2bpp(ctx);
299  break;
300 
301  case kFormat4bpp:
302  getTexture4bpp(ctx);
303  break;
304 
305  case kFormat8bpp:
306  getTexture8bpp(ctx);
307  break;
308 
309  case kFormat16bpp:
310  getTexture16bpp(ctx);
311  break;
312 
313  case kFormatA3I5:
314  getTextureA3I5(ctx);
315  break;
316 
317  case kFormatA5I3:
318  getTextureA5I3(ctx);
319  break;
320 
321  default:
322  throw Common::Exception("Unsupported texture format %d", (int) ctx.texture->format);
323  break;
324  }
325 }
326 
328  if (index >= _textures.size())
329  throw Common::Exception("Texture index out of range (%u/%u)", index, (uint)_textures.size());
330 
332 
333  ReadContext ctx(*_nsbtx, _textures[index], stream);
334  writeITEXHeader(ctx);
335 
336  getPalette(ctx);
337  getTexture(ctx);
338 
339  stream.setDisposable(false);
340  return new Common::MemoryReadStream(stream.getData(), stream.size(), true);
341 }
342 
344  try {
345 
346  readHeader(nsbtx);
347  readTextures(nsbtx);
348  readPalettes(nsbtx);
349 
351 
352  } catch (Common::Exception &e) {
353  e.add("Failed reading NSBTX file");
354  throw;
355  }
356 }
357 
359  readFileHeader(nsbtx);
360  readInfoHeader(nsbtx);
361 }
362 
364  const uint32 tag = nsbtx.readUint32BE();
365  if (tag != kBTX0ID)
366  throw Common::Exception("Invalid NSBTX file (%s)", Common::debugTag(tag).c_str());
367 
368  const uint16 bom = nsbtx.readUint16();
369  if (bom != 0xFEFF)
370  throw Common::Exception("Invalid BOM: 0x%04X", (uint) bom);
371 
372  const uint8 versionMajor = nsbtx.readByte();
373  const uint8 versionMinor = nsbtx.readByte();
374  if ((versionMajor != 1) || (versionMinor != 0))
375  throw Common::Exception("Unsupported version %u.%u", versionMajor, versionMinor);
376 
377  const uint32 fileSize = nsbtx.readUint32();
378  if (fileSize > (uint32)nsbtx.size())
379  throw Common::Exception("Size too large (%u > %u)", fileSize, (uint)nsbtx.size());
380 
381  const uint16 headerSize = nsbtx.readUint16();
382  if (headerSize != 16)
383  throw Common::Exception("Invalid header size (%u)", headerSize);
384 
385  const uint16 sectionCount = nsbtx.readUint16();
386  if (sectionCount != 1)
387  throw Common::Exception("Invalid number of sections (%u)", sectionCount);
388 
389  _textureOffset = nsbtx.readUint32();
390 }
391 
393  nsbtx.seek(_textureOffset);
394 
395  const uint32 tag = nsbtx.readUint32BE();
396  if (tag != kTEX0ID)
397  throw Common::Exception("Invalid NSBTX texture (%s)", Common::debugTag(tag).c_str());
398 
399  nsbtx.skip(4 + 4 + 2); // Section size + padding + data size
400 
402 
403  nsbtx.skip(4); // Padding
404 
406 
407  nsbtx.skip(4); // Padding
408  nsbtx.skip(2 + 2); // Compressed data size and info offset
409  nsbtx.skip(4); // Padding
410  nsbtx.skip(4 + 4); // Compressed data offset and info data offset
411  nsbtx.skip(4); // Padding
412 
413  nsbtx.skip(4); // Palette data size
414 
417 }
418 
420  nsbtx.seek(_textureInfoOffset);
421 
422  nsbtx.skip(1); // Unknown
423 
424  const uint8 textureCount = nsbtx.readByte();
425 
426  nsbtx.skip(2); // Section size
427  nsbtx.skip(2 + 2 + 4 + textureCount * (2 + 2)); // Unknown
428 
429  nsbtx.skip(2 + 2); // Header size + section size
430 
431  _textures.resize(textureCount);
432  for (Textures::iterator t = _textures.begin(); t != _textures.end(); ++t) {
433  t->offset = _textureDataOffset + nsbtx.readUint16() * 8;
434 
435  const uint16 flags = nsbtx.readUint16();
436 
437  nsbtx.skip(1); // Unknown
438 
439  const uint8 unknown = nsbtx.readByte();
440 
441  nsbtx.skip(2); // Unknown
442 
443  t->width = 8 << ((flags >> 4) & 7);
444  t->height = 8 << ((flags >> 7) & 7);
445 
446  t->format = (Format) ((flags >> 10) & 7);
447 
448  t->wrapX = ( flags & 1) != 0;
449  t->wrapY = ((flags >> 1) & 1) != 0;
450  t->flipX = ((flags >> 2) & 1) != 0;
451  t->flipY = ((flags >> 3) & 1) != 0;
452  t->alpha = ((flags >> 13) & 1) != 0;
453 
454  t->coordTransform = (Transform) (flags >> 14);
455 
456  if (t->width == 0x00) {
457  switch (unknown & 0x3) {
458  case 2:
459  t->width = 0x200;
460  break;
461  default:
462  t->width = 0x100;
463  break;
464  }
465  }
466 
467  if (t->height == 0x00) {
468  switch ((unknown >> 4) & 0x3) {
469  case 2:
470  t->height = 0x200;
471  break;
472  default:
473  t->height = 0x100;
474  break;
475  }
476  }
477  }
478 
479  for (Textures::iterator t = _textures.begin(); t != _textures.end(); ++t)
481 }
482 
484  nsbtx.seek(_paletteInfoOffset);
485 
486  nsbtx.skip(1); // Unknown
487 
488  const uint8 paletteCount = nsbtx.readByte();
489 
490  nsbtx.skip(2); // Section size
491  nsbtx.skip(2 + 2 + 4 + paletteCount * (2 + 2)); // Unknown
492 
493  nsbtx.skip(2 + 2); // Header size + section size
494 
495  _palettes.resize(paletteCount);
496  for (Palettes::iterator p = _palettes.begin(); p != _palettes.end(); ++p) {
497  const uint16 offset = nsbtx.readUint16() & 0x1FFF;
498  const uint16 flags = nsbtx.readUint16();
499 
500  const uint8 paletteStep = ((flags & 1) != 0) ? 16 : 8;
501 
502  p->offset = _paletteDataOffset + offset * paletteStep;
503  }
504 
505  for (Palettes::iterator p = _palettes.begin(); p != _palettes.end(); ++p)
507 }
508 
510  _resources.resize(_textures.size());
511 
512  ResourceList::iterator res = _resources.begin();
513  Textures::iterator tex = _textures.begin();
514 
515  uint32 index = 0;
516  for ( ; (res != _resources.end()) && (tex != _textures.end()); ++res, ++tex, ++index) {
517  res->name = tex->name;
518  res->type = kFileTypeXEOSITEX;
519  res->index = index;
520  }
521 }
522 
523 } // End of namespace Aurora
Common::WriteStream * stream
Definition: nsbtxfile.h:108
Common::UString name
Definition: nsbtxfile.h:80
static void writeITEXHeader(const ReadContext &ctx)
Definition: nsbtxfile.cpp:110
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
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
void add(const char *s,...) GCC_PRINTF(2
Definition: error.cpp:58
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
Palettes _palettes
Definition: nsbtxfile.h:133
A stream that dynamically grows as it&#39;s written to.
uint32 _textureInfoOffset
Definition: nsbtxfile.h:126
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
bool flipY
true: flip on every 2nd texture wrap.
Definition: nsbtxfile.h:91
void readPalettes(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:483
uint8_t uint8
Definition: types.h:200
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
Implementing the reading stream interfaces for plain memory blocks.
uint32 _paletteInfoOffset
Definition: nsbtxfile.h:127
Treat Nintendo NSBTX files, which contain multiple textures as an archive of intermediate textures...
void readHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:358
size_t pos() const
Obtains the current value of the stream position indicator of the stream.
Definition: readstream.cpp:140
static void getTexture16bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:196
static const uint32 kXEOSID
Definition: nsbtxfile.cpp:64
static void getTextureA3I5(const ReadContext &ctx)
Definition: nsbtxfile.cpp:212
Utility templates and functions for working with strings and streams.
Exception that provides a stack of explanations.
Definition: error.h:36
size_t size() const
Obtains the total size of the stream, measured in bytes.
Definition: readstream.cpp:144
static void getTexture4bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:159
void readFileHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:363
size_t size() const
Return the number of bytes written to this stream in total.
Basic exceptions to throw.
static const uint32 kBTX0ID
Definition: nsbtxfile.cpp:70
void createResourceList()
Definition: nsbtxfile.cpp:509
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
4bit color index.
Definition: nsbtxfile.h:65
size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)
Sets the stream position indicator for the stream.
Definition: readstream.cpp:148
8bit color index.
Definition: nsbtxfile.h:66
uint16_t uint16
Definition: types.h:202
#define UNUSED(x)
Definition: system.h:170
Utility templates and functions.
Implementing the writing stream interfaces for memory blocks.
bool wrapY
true: wrap, false: clamp.
Definition: nsbtxfile.h:89
uint32 _paletteDataOffset
Definition: nsbtxfile.h:130
static const uint32 kITEXID
Definition: nsbtxfile.cpp:65
std::list< Resource > ResourceList
Definition: archive.h:57
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
Definition: readstream.h:317
static const uint32 kTEX0ID
Definition: nsbtxfile.cpp:71
uint32 _textureDataOffset
Definition: nsbtxfile.h:129
Simple memory based &#39;stream&#39;, which implements the ReadStream interface for a plain memory block...
Definition: memreadstream.h:66
Utility functions for working with differing string encodings.
StackException Exception
Definition: error.h:59
ResourceList _resources
External list of resource names and types.
Definition: nsbtxfile.h:122
void getPalette(ReadContext &ctx) const
Definition: nsbtxfile.cpp:264
void setDisposable(bool disposeMemory)
void writeByte(byte value)
Definition: writestream.h:88
void readInfoHeader(Common::SeekableSubReadStreamEndian &nsbtx)
Definition: nsbtxfile.cpp:392
bool flipX
true: flip on every 2nd texture wrap.
Definition: nsbtxfile.h:90
Intermediate texture.
Definition: types.h:390
Generic interface for a writable data stream.
Definition: writestream.h:64
uint32 readUint32BE()
Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it...
Definition: readstream.h:166
static void getTexture2bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:138
static const uint32 kXEOSITEXHeaderSize
Definition: nsbtxfile.cpp:67
static const uint32 kXEOSITEXMipMapHeaderSize
Definition: nsbtxfile.cpp:68
uint32 getResourceSize(uint32 index) const
Return the size of a resource.
Definition: nsbtxfile.cpp:103
Common::SeekableSubReadStreamEndian * nsbtx
Definition: nsbtxfile.h:107
ReadContext(Common::SeekableSubReadStreamEndian &n, const Texture &t, Common::WriteStream &s)
Definition: nsbtxfile.cpp:75
Plain, unextended ASCII (7bit clean).
Definition: encoding.h:40
UString toLower() const
Return a lowercased copy of the string.
Definition: ustring.cpp:481
Common::ScopedArray< const byte > palette
Definition: nsbtxfile.h:105
uint32_t uint32
Definition: types.h:204
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
Definition: strutil.cpp:117
static void getTexture(const ReadContext &ctx)
Definition: nsbtxfile.cpp:293
2bit color index.
Definition: nsbtxfile.h:64
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
Definition: encoding.cpp:297
void writeUint32BE(uint32 value)
Definition: writestream.h:122
uint32 _textureOffset
Definition: nsbtxfile.h:124
static uint32 getITEXSize(const Texture &texture)
Definition: nsbtxfile.cpp:99
static Common::SeekableSubReadStreamEndian * open(Common::SeekableReadStream &stream)
Treat this stream as a Nitro file and return an endian&#39;d stream according to its BOM.
Definition: nitrofile.cpp:52
bool wrapX
true: wrap, false: clamp.
Definition: nsbtxfile.h:88
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void writeUint32LE(uint32 value)
Definition: writestream.h:104
static void writePixel(const ReadContext &ctx, byte r, byte g, byte b, byte a)
Definition: nsbtxfile.cpp:131
byte readByte()
Read an unsigned byte from the stream and return it.
Definition: readstream.h:92
static void getTexture8bpp(const ReadContext &ctx)
Definition: nsbtxfile.cpp:180
uint8 byte
Definition: types.h:209
unsigned int uint
Definition: types.h:211
5bit alpha + 3bit color index.
Definition: nsbtxfile.h:68
static void getTextureA5I3(const ReadContext &ctx)
Definition: nsbtxfile.cpp:230