From 8f4bba878f6da8958b8040ccc0d7297d5d252f3d Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Sat, 19 Sep 2009 13:17:55 +0000 Subject: LOL: start on pc98 support (still messed up and not working though) svn-id: r44195 --- engines/kyra/lol.cpp | 76 ++++++++++++++++++++++++++++------------ engines/kyra/lol.h | 1 + engines/kyra/scene_lol.cpp | 84 +++++++++++++++++++++++++++++++++++++++------ engines/kyra/screen_lol.cpp | 20 +++++++---- engines/kyra/script_tim.cpp | 22 +++++++----- engines/kyra/sound_lol.cpp | 35 ++++++++++--------- 6 files changed, 176 insertions(+), 62 deletions(-) (limited to 'engines') diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 201e55ab5a..74fce1e8fa 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -144,6 +144,7 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _vcnShift = 0; _vcnExpTable = 0; _vmpPtr = 0; + _vcfBlocks = 0; _trueLightTable2 = 0; _trueLightTable1 = 0; _levelShapeProperties = 0; @@ -354,6 +355,7 @@ LoLEngine::~LoLEngine() { delete[] _vcnBlocks; delete[] _vcnShift; delete[] _vmpPtr; + delete[] _vcfBlocks; delete[] _trueLightTable2; delete[] _trueLightTable1; delete[] _levelShapeProperties; @@ -788,13 +790,28 @@ void LoLEngine::startup() { Palette &pal = _screen->getPalette(0); _screen->loadBitmap("PLAYFLD.CPS", 3, 3, &pal); - _screen->copyPalette(1, 0); - pal.fill(0, 1, 0x3F); - pal.fill(2, 126, 0x3F); - pal.fill(192, 4, 0x3F); - _screen->generateOverlay(pal, _screen->_paletteOverlay1, 1, 96); - _screen->generateOverlay(pal, _screen->_paletteOverlay2, 144, 65); - _screen->copyPalette(0, 1); + if (_flags.use16ColorMode) { + memset(_screen->_paletteOverlay1, 0, 256); + memset(_screen->_paletteOverlay2, 0, 256); + + static const uint8 colTable1[] = { 0x00, 0xEE, 0xCC, 0xFF, 0x44, 0x66, 0x44, 0x88, 0xEE, 0xAA, 0x11, 0xCC, 0xDD, 0xEE, 0x44, 0xCC }; + static const uint8 colTable2[] = { 0x00, 0xCC, 0xFF, 0xBB, 0xEE, 0xBB, 0x55, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xFF, 0xCC, 0xDD, 0xBB }; + static const uint8 colTable3[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; + + for (int i = 0; i < 16; i++) { + _screen->_paletteOverlay2[colTable3[i]] = colTable1[i]; + _screen->_paletteOverlay1[colTable3[i]] = colTable2[i]; + } + + } else { + _screen->copyPalette(1, 0); + pal.fill(0, 1, 0x3F); + pal.fill(2, 126, 0x3F); + pal.fill(192, 4, 0x3F); + _screen->generateOverlay(pal, _screen->_paletteOverlay1, 1, 96); + _screen->generateOverlay(pal, _screen->_paletteOverlay2, 144, 65); + _screen->copyPalette(0, 1); + } _screen->getPalette(1).clear(); _screen->getPalette(2).clear(); @@ -1686,18 +1703,28 @@ void LoLEngine::setPaletteBrightness(const Palette &srcPal, int brightness, int void LoLEngine::generateBrightnessPalette(const Palette &src, Palette &dst, int brightness, int modifier) { dst.copy(src); - _screen->loadSpecialColors(dst); + if (_flags.use16ColorMode) { + if (!(brightness && modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08))) + modifier = 8; + modifier >>= 1; + if (modifier) + modifier--; + brightness = 16 * modifier; - brightness = (8 - brightness) << 5; - if (modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)) { - brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8); - if (brightness < 0) - brightness = 0; - } + } else { + _screen->loadSpecialColors(dst); + + brightness = (8 - brightness) << 5; + if (modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)) { + brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8); + if (brightness < 0) + brightness = 0; + } - for (int i = 0; i < 384; i++) { - uint16 c = (dst[i] * brightness) >> 8; - dst[i] = c & 0xff; + for (int i = 0; i < 384; i++) { + uint16 c = (dst[i] * brightness) >> 8; + dst[i] = c & 0xff; + } } } @@ -1722,12 +1749,17 @@ void LoLEngine::createGfxTables() { if (_flags.isTalkie || _loadSuppFilesFlag) return; - Palette tpal(256); - _screen->loadPalette("fxpal.col", tpal); - _screen->loadBitmap("fxpal.shp", 3, 3, 0); - const uint8 *shpPal = _screen->getPtrToShape(_screen->getCPagePtr(2), 0) + 11; + if (_flags.use16ColorMode) { - _screen->generateTruelightTables(shpPal, 20, tpal, _screen->getPalette(1), _trueLightTable1, _trueLightTable2, 70); + _screen->loadPalette("lol.nol", _screen->getPalette(0)); + } else { + Palette tpal(256); + _screen->loadPalette("fxpal.col", tpal); + _screen->loadBitmap("fxpal.shp", 3, 3, 0); + const uint8 *shpPal = _screen->getPtrToShape(_screen->getCPagePtr(2), 0) + 11; + + _screen->generateTruelightTables(shpPal, 20, tpal, _screen->getPalette(1), _trueLightTable1, _trueLightTable2, 70); + } _loadSuppFilesFlag = 1; } diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 00e509aa16..d67d61788a 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -1083,6 +1083,7 @@ private: uint8 *_vcnShift; uint8 *_vcnExpTable; uint16 *_vmpPtr; + uint8 *_vcfBlocks; uint16 *_blockDrawingBuffer; uint8 *_sceneWindowBuffer; LevelShapeProperty *_levelShapeProperties; diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp index 7c45abb970..bdcecdb922 100644 --- a/engines/kyra/scene_lol.cpp +++ b/engines/kyra/scene_lol.cpp @@ -86,7 +86,8 @@ void LoLEngine::loadLevel(int index) { addLevelItems(); deleteMonstersFromBlock(_currentBlock); - _screen->generateGrayOverlay(_screen->getPalette(0), _screen->_grayOverlay, 32, 16, 0, 0, 128, true); + if (!_flags.use16ColorMode) + _screen->generateGrayOverlay(_screen->getPalette(0), _screen->_grayOverlay, 32, 16, 0, 0, 128, true); _sceneDefaultUpdate = 0; if (_screen->_fadeFlag == 3) @@ -97,6 +98,9 @@ void LoLEngine::loadLevel(int index) { setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect); setMouseCursorToItemInHand(); + if (_flags.use16ColorMode) + _screen->fadeToPalette1(10); + snd_playTrack(_curMusicTheme); } @@ -353,12 +357,40 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight } } + if (_flags.use16ColorMode) { + if (_lastSpecialColor == 0x66) + //_lastSpecialColor = stricmp(file, "YVEL2") ? 0xcc : 0x44; + _lastSpecialColor = stricmp(file, "YVEL2") ? 0xc : 0x4; + else if (_lastSpecialColor == 0x6b) + //_lastSpecialColor = 0xcc; + _lastSpecialColor = 0xc; + else + //_lastSpecialColor = 0x44; + _lastSpecialColor = 0x4; + } + char fname[13]; - snprintf(fname, sizeof(fname), "%s.VCN", _lastSuppFile); + const uint8 *v = 0; + int tlen = 0; + + if (_flags.use16ColorMode) { + snprintf(fname, sizeof(fname), "%s.VCF", _lastSuppFile); + _screen->loadBitmap(fname, 3, 3, 0); + v = _screen->getCPagePtr(2); + tlen = READ_LE_UINT16(v) << 5; + v += 2; + if (_vcfBlocks) + delete[] _vcfBlocks; + _vcfBlocks = new uint8[tlen]; + + memcpy(_vcfBlocks, v, tlen); + } + + snprintf(fname, sizeof(fname), "%s.VCN", _lastSuppFile); _screen->loadBitmap(fname, 3, 3, 0); - const uint8 *v = _screen->getCPagePtr(2); - int tlen = READ_LE_UINT16(v); + v = _screen->getCPagePtr(2); + tlen = READ_LE_UINT16(v); v += 2; if (vcnLen == -1) @@ -373,15 +405,27 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight _vcnShift = new uint8[tlen]; memcpy(_vcnShift, v, tlen); - v += tlen; + v += tlen; + + if (_flags.use16ColorMode) { + _screen->getPalette(0).fill(0, 16, 0xff); + _screen->loadPalette("LOL.NOL", _screen->getPalette(0)); - memcpy(_vcnExpTable, v, 128); - v += 128; + /*static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; + Palette &pl = _screen->getPalette(0); + for (int i = 15; i >= 0; i--) + pl.copy(pl, i, 1, colTable[i]);*/ - if (_lastOverridePalFilePtr) { - _res->loadFileToBuf(_lastOverridePalFilePtr, _screen->getPalette(0).getData(), 384); + v += 128; } else { - _screen->getPalette(0).copy(v, 0, 128); + memcpy(_vcnExpTable, v, 128); + v += 128; + + if (_lastOverridePalFilePtr) { + _res->loadFileToBuf(_lastOverridePalFilePtr, _screen->getPalette(0).getData(), 384); + } else { + _screen->getPalette(0).copy(v, 0, 128); + } } v += 384; @@ -433,6 +477,26 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight for (int i = 0; i < 256; i++) _screen->getLevelOverlay(7)[i] = i & 0xff; + if (_flags.use16ColorMode) { + //_screen->getLevelOverlay(6)[0xee] = 0xee; + //if (_lastSpecialColor == 0x44) + // _screen->getLevelOverlay(5)[0xee] = 0xee; + _screen->getLevelOverlay(6)[0xe] = 0xe; + if (_lastSpecialColor == 0x4) + _screen->getLevelOverlay(5)[0xe] = 0xe; + + for (int i = 0; i < 7; i++) + memcpy(_screen->getLevelOverlay(i), _screen->getLevelOverlay(i + 1), 256); + + //static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; + + for (int i = 0; i < 8; i++) { + uint8 *pl = _screen->getLevelOverlay(7 - i); + for (int ii = 15; ii >= 0; ii--) + _vcnExpTable[((7 - i) << 4) + ii] = pl[/*colTable[*/ii/*]*/]; + } + } + _loadSuppFilesFlag = 0; generateBrightnessPalette(_screen->getPalette(0), _screen->getPalette(1), _brightness, _lampEffect); diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp index ccb9ea1e04..8deb43356f 100644 --- a/engines/kyra/screen_lol.cpp +++ b/engines/kyra/screen_lol.cpp @@ -172,7 +172,7 @@ uint8 *Screen_LoL::generateLevelOverlay(const Palette &srcPal, uint8 *ovl, int o uint8 *d = ovl; *d++ = 0; - for (int i = 1; i != 255; i++) { + for (int i = 1; i != srcPal.getNumColors() - 1; i++) { uint16 a = srcPal[i * 3]; uint8 dr = a - ((((a - r) * (weight >> 1)) << 1) >> 8); a = srcPal[i * 3 + 1]; @@ -320,13 +320,18 @@ void Screen_LoL::fadeClearSceneWindow(int delay) { if (_fadeFlag == 1) return; - Palette tpal(getPalette(0).getNumColors()); - tpal.copy(getPalette(0), 128); + if (_use16ColorMode) { + fadeToBlack(delay); + fillRect(112, 0, 288, 120, 68); + } else { + Palette tpal(getPalette(0).getNumColors()); + tpal.copy(getPalette(0), 128); - loadSpecialColors(tpal); - fadePalette(tpal, delay); + loadSpecialColors(tpal); + fadePalette(tpal, delay); - fillRect(112, 0, 288, 120, 0); + fillRect(112, 0, 288, 120, 0); + } _fadeFlag = 1; } @@ -809,6 +814,9 @@ void Screen_LoL::fadeToPalette1(int delay) { } void Screen_LoL::loadSpecialColors(Palette &dst) { + if (_use16ColorMode) + return; + dst.copy(*_screenPalette, 192, 4); } diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index dad8e28978..7b1f07844d 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -964,20 +964,26 @@ TIMInterpreter::Animation *TIMInterpreter_LoL::initAnimStruct(int index, const c anim->wsa->open(file, wsaOpenFlags, &_screen->getPalette(3)); } - if (wsaFlags & 1) { - if (_screen->_fadeFlag != 1) - _screen->fadeClearSceneWindow(10); - _screen->getPalette(3).copy(_screen->getPalette(0), 128, 128); - } else if (wsaFlags & 2) { - _screen->fadeToBlack(10); + if (!_vm->_flags.use16ColorMode) { + if (wsaFlags & 1) { + if (_screen->_fadeFlag != 1) + _screen->fadeClearSceneWindow(10); + _screen->getPalette(3).copy(_screen->getPalette(0), 128, 128); + } else if (wsaFlags & 2) { + _screen->fadeToBlack(10); + } } if (wsaFlags & 7) anim->wsa->displayFrame(0, 0, x, y, 0, 0, 0); if (wsaFlags & 3) { - _screen->loadSpecialColors(_screen->getPalette(3)); - _screen->fadePalette(_screen->getPalette(3), 10); + if (_vm->_flags.use16ColorMode) { + _vm->setPaletteBrightness(_screen->getPalette(0), _vm->_brightness, _vm->_lampEffect); + } else { + _screen->loadSpecialColors(_screen->getPalette(3)); + _screen->fadePalette(_screen->getPalette(3), 10); + } _screen->_fadeFlag = 0; } diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp index 63a42837aa..7ee49a7894 100644 --- a/engines/kyra/sound_lol.cpp +++ b/engines/kyra/sound_lol.cpp @@ -259,20 +259,19 @@ void LoLEngine::snd_playQueuedEffects() { void LoLEngine::snd_loadSoundFile(int track) { if (_sound->musicEnabled()) { - char filename[13]; - int t = (track - 250) * 3; - - if (_curMusicFileIndex != _musicTrackMap[t] || _curMusicFileExt != (char)_musicTrackMap[t + 1]) { - snd_stopMusic(); - snprintf(filename, sizeof(filename), "LORE%02d%c", _musicTrackMap[t], (char)_musicTrackMap[t + 1]); - _sound->loadSoundFile(filename); - _curMusicFileIndex = _musicTrackMap[t]; - _curMusicFileExt = (char)_musicTrackMap[t + 1]; - } else { - snd_stopMusic(); + if (_flags.platform != Common::kPlatformPC98) { + int t = (track - 250) * 3; + if (_curMusicFileIndex != _musicTrackMap[t] || _curMusicFileExt != (char)_musicTrackMap[t + 1]) { + snd_stopMusic(); + char filename[13]; + snprintf(filename, sizeof(filename), "LORE%02d%c", _musicTrackMap[t], (char)_musicTrackMap[t + 1]); + _sound->loadSoundFile(filename); + _curMusicFileIndex = _musicTrackMap[t]; + _curMusicFileExt = (char)_musicTrackMap[t + 1]; + } else { + snd_stopMusic(); + } } - } else { - //XXX } } @@ -284,9 +283,13 @@ int LoLEngine::snd_playTrack(int track) { _lastMusicTrack = track; if (_sound->musicEnabled()) { - snd_loadSoundFile(track); - int t = (track - 250) * 3; - _sound->playTrack(_musicTrackMap[t + 2]); + if (_flags.platform == Common::kPlatformPC98) { + _sound->playTrack(track - 249); + } else { + snd_loadSoundFile(track); + int t = (track - 250) * 3; + _sound->playTrack(_musicTrackMap[t + 2]); + } } return res; -- cgit v1.2.3