HDB: Add the Tile class to load 32x32 Tiles

This commit is contained in:
Nipun Garg 2019-06-01 17:56:04 +05:30 committed by Eugene Sandulenko
parent 6986e5495a
commit 07b3408ff4
2 changed files with 34 additions and 0 deletions

View file

@ -42,6 +42,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
_width = stream->readUint32LE();
_height = stream->readUint32LE();
stream->read(_name, 64);
Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
debug(8, "Picture: _width: %d, _height: %d", _width, _height);
@ -63,4 +64,26 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
return _surface;
}
Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
_flags = stream->readUint32LE();
stream->read(_name, 64);
Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
_surface.create(32, 32, format);
stream->readUint32LE(); // Skip Win32 Surface
uint16 *ptr;
for (uint y = 0; y < 32; y++) {
ptr = (uint16 *)_surface.getBasePtr(0, y);
for (uint x = 0; x < 32; x++) {
*ptr = TO_LE_16(stream->readUint16LE());
ptr++;
}
}
return _surface;
}
}

View file

@ -75,6 +75,17 @@ private:
};
class Tile {
public:
Graphics::Surface load(Common::SeekableReadStream *stream);
private:
uint32 _flags;
char _name[64];
Graphics::Surface _surface;
};
} // End of Namespace HDB
#endif // !HDB_DRAW_MANAGER_H