mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-05 02:17:05 +00:00
DIRECTOR: Refactoring palette loading
This commit is contained in:
parent
acc0d70054
commit
75a01e0ea0
@ -28,6 +28,7 @@
|
||||
#include "graphics/pixelformat.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "image/codecs/codec.h"
|
||||
#include "common/util.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
namespace Director {
|
||||
@ -48,7 +49,6 @@ void DIBDecoder::destroy() {
|
||||
|
||||
delete[] _palette;
|
||||
_palette = 0;
|
||||
|
||||
_paletteColorCount = 0;
|
||||
|
||||
delete _codec;
|
||||
@ -56,31 +56,28 @@ void DIBDecoder::destroy() {
|
||||
}
|
||||
|
||||
void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) {
|
||||
uint16 palentries = 256;
|
||||
_palette = new byte[1024];
|
||||
|
||||
uint16 size = stream.size();
|
||||
uint16 index = 0;
|
||||
for (int i = 6; i < stream.size() + 6; i+=6) {
|
||||
uint16 n = size - i;
|
||||
if (i >= palentries) {
|
||||
break;
|
||||
}
|
||||
stream.seek(n + 4);
|
||||
_palette[index] = stream.readByte();
|
||||
++index;
|
||||
stream.seek(n + 2);
|
||||
_palette[index] = stream.readByte();
|
||||
++index;
|
||||
stream.seek(n);
|
||||
_palette[index] = stream.readByte();
|
||||
++index;
|
||||
_palette[index] = 0;
|
||||
++index;
|
||||
uint16 steps = stream.size()/6;
|
||||
uint16 index = (steps * 4) - 1;
|
||||
|
||||
for (uint8 i = 0; i < steps; i++) {
|
||||
_palette[index--] = 0;
|
||||
|
||||
_palette[index--] = stream.readByte();
|
||||
stream.readByte();
|
||||
|
||||
_palette[index--] = stream.readByte();
|
||||
stream.readByte();
|
||||
|
||||
_palette[index--] = stream.readByte();
|
||||
stream.readByte();
|
||||
}
|
||||
|
||||
index = (steps * 4) - 1;
|
||||
|
||||
while (index < 1024) {
|
||||
_palette[index] = 0;
|
||||
++index;
|
||||
_palette[index++] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,11 +54,11 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
|
||||
//FIXME
|
||||
RIFFArchive riff;
|
||||
riff.openFile("bookshelf_example.mmm");
|
||||
Common::SeekableReadStream *dib = riff.getResource(1145651744, 1103);
|
||||
Common::SeekableReadStream *pal = riff.getResource(1129076052, 1025);
|
||||
Director::DIBDecoder img;
|
||||
img.loadPalette(*pal);
|
||||
Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1103);
|
||||
img.loadStream(*dib);
|
||||
Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025);
|
||||
img.loadPalette(*pal);
|
||||
}
|
||||
|
||||
DirectorEngine::~DirectorEngine() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user