Changed Screen::loadPalette to take a reference to a Palette object instead of an array.

svn-id: r41745
This commit is contained in:
Johannes Schickel 2009-06-22 02:37:41 +00:00
parent d2e5166dae
commit d7432e18ea
11 changed files with 37 additions and 46 deletions

View File

@ -82,7 +82,7 @@ bool Debugger::cmd_loadPalette(int argc, const char **argv) {
_vm->screen()->loadBitmap(argv[1], 5, 5, 0);
palette.copy(_vm->screen()->getCPagePtr(5), 0, 256);
_vm->screen()->copyBlockToPage(5, 0, 0, 320, 200, buffer);
} else if (!_vm->screen()->loadPalette(argv[1], palette.getData())) {
} else if (!_vm->screen()->loadPalette(argv[1], palette)) {
DebugPrintf("ERROR: Palette '%s' not found!\n", argv[1]);
return true;
}

View File

@ -358,7 +358,7 @@ void KyraEngine_LoK::startup() {
loadButtonShapes();
initMainButtonList();
loadMainScreen();
_screen->loadPalette("PALETTE.COL", _screen->getPalette(0).getData());
_screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
// XXX
_animator->initAnimStateList();

View File

@ -2785,7 +2785,7 @@ void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, Palette
uint16 palSize = READ_LE_UINT16(srcData + 8);
if (pal && palSize)
loadPalette(srcData + 10, pal->getData(), palSize);
loadPalette(srcData + 10, *pal, palSize);
uint8 *srcPtr = srcData + 10 + palSize;
uint8 *dstData = getPagePtr(dstPage);
@ -2819,38 +2819,30 @@ void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, Palette
delete[] srcData;
}
bool Screen::loadPalette(const char *filename, uint8 *palData) {
uint32 fileSize = 0;
uint8 *srcData = _vm->resource()->fileData(filename, &fileSize);
if (!srcData)
bool Screen::loadPalette(const char *filename, Palette &pal) {
Common::SeekableReadStream *stream = _vm->resource()->createReadStream(filename);
if (!stream)
return false;
if (palData && fileSize) {
loadPalette(srcData, palData, fileSize);
}
delete[] srcData;
debugC(3, kDebugLevelScreen, "Screen::loadPalette('%s', %p)", filename, (const void *)&pal);
if (_vm->gameFlags().platform == Common::kPlatformAmiga)
pal.loadAmigaPalette(*stream, stream->size() / 2);
else
pal.loadVGAPalette(*stream, stream->size() / 3);
delete stream;
return true;
}
void Screen::loadPalette(const byte *data, uint8 *palData, int bytes) {
if (_vm->gameFlags().platform == Common::kPlatformAmiga) {
assert(bytes % 2 == 0);
assert(bytes / 2 <= 256);
bytes >>= 1;
const uint16 *src = (const uint16 *)data;
for (int i = 0; i < bytes; ++i) {
uint16 col = READ_BE_UINT16(src); ++src;
palData[2] = (col & 0xF) << 2; col >>= 4;
palData[1] = (col & 0xF) << 2; col >>= 4;
palData[0] = (col & 0xF) << 2; col >>= 4;
palData += 3;
}
} else if (_use16ColorMode) {
for (int i = 0; i < bytes; ++i)
palData[i] = ((data[i] & 0xF) << 4) | (data[i] & 0xF0);
} else {
memcpy(palData, data, bytes);
}
void Screen::loadPalette(const byte *data, Palette &pal, int bytes) {
Common::MemoryReadStream stream(data, bytes, false);
if (_vm->gameFlags().platform == Common::kPlatformAmiga)
pal.loadAmigaPalette(stream, stream.size() / 2);
else
pal.loadVGAPalette(stream, stream.size() / 3);
}
// dirty rect handling

View File

@ -286,8 +286,8 @@ public:
// misc
void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip=false);
bool loadPalette(const char *filename, uint8 *palData);
void loadPalette(const byte *data, uint8 *palData, int bytes);
bool loadPalette(const char *filename, Palette &pal);
void loadPalette(const byte *data, Palette &pal, int bytes);
void setAnimBlockPtr(int size);

View File

@ -147,7 +147,7 @@ int KyraEngine_HoF::o2_meanWhileScene(EMCState *script) {
_screen->loadBitmap(cpsfile, 3, 3, 0);
_screen->copyPalette(2, 0);
_screen->loadPalette(palfile, _screen->getPalette(2).getData());
_screen->loadPalette(palfile, _screen->getPalette(2));
_screen->fillRect(0, 0, 319, 199, 207);
_screen->setScreenPalette(_screen->getPalette(2));
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
@ -1400,7 +1400,7 @@ int KyraEngine_HoF::o2_demoFinale(EMCState *script) {
assert(strings);
_screen->clearPage(0);
_screen->loadPalette("THANKS.COL", _screen->getPalette(0).getData());
_screen->loadPalette("THANKS.COL", _screen->getPalette(0));
_screen->loadBitmap("THANKS.CPS", 3, 3, 0);
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);

View File

@ -2148,12 +2148,12 @@ int LoLEngine::olol_restoreMagicShroud(EMCState *script) {
uint8 *tpal2 = tpal1 + 768;
uint8 *tpal3 = tpal2 + 768;
uint8 *tpal4 = 0;
_screen->loadPalette("LITEPAL1.COL", tpal1);
_res->loadFileToBuf("LITEPAL1.COL", tpal1, 768);
tpal2 = _screen->generateFadeTable(tpal3, 0, tpal1, 21);
_screen->loadPalette("LITEPAL2.COL", tpal2);
_res->loadFileToBuf("LITEPAL2.COL", tpal2, 768);
tpal4 = tpal2;
tpal2 += 768;
_screen->loadPalette("LITEPAL3.COL", tpal1);
_res->loadFileToBuf("LITEPAL3.COL", tpal1, 768);
_screen->generateFadeTable(tpal2, tpal4, tpal1, 4);
Palette pal(768);
@ -2309,7 +2309,7 @@ int LoLEngine::tlol_setupPaletteFade(const TIM *tim, const uint16 *param) {
int LoLEngine::tlol_loadPalette(const TIM *tim, const uint16 *param) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_loadPalette(%p, %p) (%d)", (const void *)tim, (const void *)param, param[0]);
const char *palFile = (const char *)(tim->text + READ_LE_UINT16(tim->text + (param[0]<<1)));
_screen->loadPalette(palFile, _screen->getPalette(0).getData());
_screen->loadPalette(palFile, _screen->getPalette(0));
return 1;
}

View File

@ -92,7 +92,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
} else {
_screen->setCurPage(2);
_screen->clearPage(2);
_screen->loadPalette("goldfont.col", _screen->getPalette(0).getData());
_screen->loadPalette("goldfont.col", _screen->getPalette(0));
}
if (cb && !(_flags.isDemo && !_flags.isTalkie))

View File

@ -141,7 +141,7 @@ void KyraEngine_LoK::seq_introLogos() {
_screen->clearPage(0);
if (_flags.platform == Common::kPlatformAmiga) {
_screen->loadPalette("INTRO.PAL", _screen->getPalette(0).getData());
_screen->loadPalette("INTRO.PAL", _screen->getPalette(0));
_screen->loadBitmap("BOTTOM.CPS", 3, 5, 0);
_screen->loadBitmap("TOP.CPS", 3, 3, 0);
_screen->copyRegion(0, 0, 0, 111, 320, 64, 2, 0);

View File

@ -304,7 +304,7 @@ int LoLEngine::chooseCharacter() {
_screen->_curPage = 0;
if (_flags.use16ColorMode)
_screen->loadPalette("LOL.NOL", _screen->getPalette(0).getData());
_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
_screen->fadePalette(_screen->getPalette(0), 30, 0);
@ -820,8 +820,7 @@ void LoLEngine::showOutro(int character, bool maxDifficulty) {
default:
_screen->clearPage(3);
memset(_screen->getPalette(0).getData(), 0, 768);
break;
_screen->getPalette(0).clear();
}
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK);

View File

@ -429,7 +429,7 @@ void Sprites::loadDat(const char *filename, SceneExits &exits) {
else
_screen->copyPalette(1, 0);
_screen->loadPalette(_dat + 0x17, _screen->getPalette(1).getData() + 684, 60);
_screen->getPalette(1).copy(_dat + 0x17, 0, 20, 228);
}
uint8 *data = _dat + 0x6B;

View File

@ -392,7 +392,7 @@ int WSAMovie_v2::open(const char *filename, int unk1, Palette *palBuf) {
offsPal = 0x300;
_flags |= WF_HAS_PALETTE;
if (palBuf)
_screen->loadPalette(wsaData + 8 + ((_numFrames << 2) & 0xFFFF), palBuf->getData(), 0x300);
_screen->loadPalette(wsaData + 8 + ((_numFrames << 2) & 0xFFFF), *palBuf, 0x300);
}
if (flags & 2) {
@ -400,7 +400,7 @@ int WSAMovie_v2::open(const char *filename, int unk1, Palette *palBuf) {
offsPal = 0x30;
_flags |= WF_HAS_PALETTE;
if (palBuf)
_screen->loadPalette(wsaData + 8 + ((_numFrames << 2) & 0xFFFF), palBuf->getData(), 0x30);
_screen->loadPalette(wsaData + 8 + ((_numFrames << 2) & 0xFFFF), *palBuf, 0x30);
}
_flags |= WF_XOR;