diff options
author | athrxx | 2012-02-13 18:39:50 +0100 |
---|---|---|
committer | athrxx | 2012-02-21 21:48:39 +0100 |
commit | 86a817beb5eef248c5f5e28f18133db802a59c2e (patch) | |
tree | dc606582deb0ccd10114fdf77554a8a4697110aa /engines | |
parent | 66ba9343987d67e8bf8e1742fcf139dee95a8448 (diff) | |
download | scummvm-rg350-86a817beb5eef248c5f5e28f18133db802a59c2e.tar.gz scummvm-rg350-86a817beb5eef248c5f5e28f18133db802a59c2e.tar.bz2 scummvm-rg350-86a817beb5eef248c5f5e28f18133db802a59c2e.zip |
KYRA: (EOB) - start work on CGA and EGA graphics modes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/chargen.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/darkmoon.cpp | 15 | ||||
-rw-r--r-- | engines/kyra/darkmoon.h | 17 | ||||
-rw-r--r-- | engines/kyra/eob.cpp | 21 | ||||
-rw-r--r-- | engines/kyra/eob.h | 1 | ||||
-rw-r--r-- | engines/kyra/eobcommon.cpp | 72 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 15 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/kyra_rpg.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/kyra_rpg.h | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 2 | ||||
-rw-r--r-- | engines/kyra/resource.h | 150 | ||||
-rw-r--r-- | engines/kyra/saveload_eob.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/scene_eob.cpp | 54 | ||||
-rw-r--r-- | engines/kyra/scene_lol.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/scene_rpg.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 110 | ||||
-rw-r--r-- | engines/kyra/screen.h | 34 | ||||
-rw-r--r-- | engines/kyra/screen_eob.cpp | 320 | ||||
-rw-r--r-- | engines/kyra/screen_eob.h | 18 | ||||
-rw-r--r-- | engines/kyra/sequences_darkmoon.cpp | 629 | ||||
-rw-r--r-- | engines/kyra/sequences_eob.cpp | 102 | ||||
-rw-r--r-- | engines/kyra/sprites_eob.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/staticres_eob.cpp | 79 |
26 files changed, 1141 insertions, 561 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index ed761e53c6..23274349e7 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -248,10 +248,10 @@ void CharacterGenerator::init() { _faceShapes = new uint8*[44]; for (int i = 0; i < 44; i++) - _faceShapes[i] = _screen->encodeShape((i % 10) << 2, (i / 10) << 5, 4, 32, true); + _faceShapes[i] = _screen->encodeShape((i % 10) << 2, (i / 10) << 5, 4, 32, true, _vm->_cgaMappingDefault); _screen->_curPage = 0; - _screen->loadEoBBitmap("CHARGEN", 0, 3, 3, 0); + _screen->loadEoBBitmap("CHARGEN", _vm->_cgaMappingDefault, 3, 3, 0); _screen->loadShapeSetBitmap("CHARGENB", 3, 3); if (_chargenMagicShapes) { for (int i = 0; i < 10; i++) @@ -261,14 +261,14 @@ void CharacterGenerator::init() { _chargenMagicShapes = new uint8*[10]; for (int i = 0; i < 10; i++) - _chargenMagicShapes[i] = _screen->encodeShape(i << 2, 0, 4, 32, true); + _chargenMagicShapes[i] = _screen->encodeShape(i << 2, 0, 4, 32, true, _vm->_cgaMappingDefault); for (int i = 0; i < 17; i++) { const CreatePartyModButton *c = &_chargenModButtons[i]; - _chargenButtonLabels[i] = c->labelW ? _screen->encodeShape(c->encodeLabelX, c->encodeLabelY, c->labelW, c->labelH, true) : 0; + _chargenButtonLabels[i] = c->labelW ? _screen->encodeShape(c->encodeLabelX, c->encodeLabelY, c->labelW, c->labelH, true, _vm->_cgaMappingDefault) : 0; } - _screen->copyPage(3, 2); + _screen->convertPage(3, 2, _vm->_cgaMappingDefault); _screen->_curPage = 0; _screen->copyRegion(144, 64, 0, 0, 180, 128, 0, 2, Screen::CR_NO_P_CHECK); _screen->updateScreen(); diff --git a/engines/kyra/darkmoon.cpp b/engines/kyra/darkmoon.cpp index f63d49933b..918221e0dd 100644 --- a/engines/kyra/darkmoon.cpp +++ b/engines/kyra/darkmoon.cpp @@ -29,22 +29,21 @@ namespace Kyra { DarkMoonEngine::DarkMoonEngine(OSystem *system, const GameFlags &flags) : EoBCoreEngine(system, flags) { - _seqIntro = _seqFinale = 0; + _animIntro = _animFinale = 0; _shapesIntro = _shapesFinale = 0; _dscDoorType5Offs = 0; _numSpells = 70; _menuChoiceInit = 4; _introStrings = _cpsFilesIntro = _cpsFilesFinale = _finaleStrings = _kheldranStrings = _npcStrings[0] = _npcStrings[1] = _hornStrings = 0; - _seqIntro = _seqFinale = 0; _shapesIntro = _shapesFinale = 0; _creditsData = _npcShpData = _dscDoorType5Offs = _hornSounds = 0; _dreamSteps = 0; } DarkMoonEngine::~DarkMoonEngine() { - delete[] _seqIntro; - delete[] _seqFinale; + delete[] _animIntro; + delete[] _animFinale; delete[] _shapesIntro; delete[] _shapesFinale; } @@ -58,6 +57,14 @@ Common::Error DarkMoonEngine::init() { _monsterProps = new EoBMonsterProperty[10]; + if (_configRenderMode == Common::kRenderEGA) { + Palette pal(16); + _screen->loadPalette(_egaDefaultPalette, pal, 16); + _screen->setScreenPalette(pal); + } else { + _screen->loadPalette("palette.col", _screen->getPalette(0)); + } + return Common::kNoError; } diff --git a/engines/kyra/darkmoon.h b/engines/kyra/darkmoon.h index 78413d2c38..f6e7b3ed2c 100644 --- a/engines/kyra/darkmoon.h +++ b/engines/kyra/darkmoon.h @@ -31,7 +31,7 @@ namespace Kyra { class DarkmoonSequenceHelper; -struct EoBSequenceStep { +struct DarkMoonAnimCommand { uint8 command; uint8 obj; int16 x1; @@ -74,17 +74,19 @@ private: const char * const *_introStrings; const char * const *_cpsFilesIntro; - const EoBSequenceStep **_seqIntro; - const EoBShapeDef **_shapesIntro; + const DarkMoonAnimCommand **_animIntro; + const DarkMoonShapeDef **_shapesIntro; const char * const *_finaleStrings; const uint8 *_creditsData; const char * const *_cpsFilesFinale; - const EoBSequenceStep **_seqFinale; - const EoBShapeDef **_shapesFinale; + const DarkMoonAnimCommand **_animFinale; + const DarkMoonShapeDef **_shapesFinale; - static const char *_palFilesIntro[]; - static const char *_palFilesFinale[]; + static const char *_palFilesIntroVGA[]; + static const char *_palFilesIntroEGA[]; + static const char *_palFilesFinaleVGA[]; + static const char *_palFilesFinaleEGA[]; // Ingame sequence void seq_nightmare(); @@ -135,6 +137,7 @@ private: const uint8 *_hornSounds; static const KyraRpgGUISettings _guiSettings; + static const uint8 _egaDefaultPalette[]; }; } // End of namespace Kyra diff --git a/engines/kyra/eob.cpp b/engines/kyra/eob.cpp index 40b028184f..3a1cfc1c84 100644 --- a/engines/kyra/eob.cpp +++ b/engines/kyra/eob.cpp @@ -55,7 +55,7 @@ Common::Error EoBEngine::init() { initStaticResource(); - _itemsOverlay = _res->fileData("ITEMRMP.VGA", 0); + _itemsOverlay = _res->fileData((_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA) ? "ITEMRMP.EGA" : "ITEMRMP.VGA", 0); _screen->modifyScreenDim(7, 0x01, 0xB3, 0x22, 0x12); _screen->modifyScreenDim(9, 0x01, 0x7D, 0x26, 0x3F); @@ -63,6 +63,14 @@ Common::Error EoBEngine::init() { _scriptTimersCount = 1; + if (_configRenderMode == Common::kRenderEGA) { + Palette pal(16); + _screen->loadPalette(_egaDefaultPalette, pal, 16); + _screen->setScreenPalette(pal); + } else { + _screen->loadPalette("palette.col", _screen->getPalette(0)); + } + return Common::kNoError; } @@ -73,6 +81,7 @@ void EoBEngine::startupNew() { _currentBlock = 490; _currentDirection = 0; setHandItem(0); + EoBCoreEngine::startupNew(); } @@ -134,7 +143,7 @@ void EoBEngine::drawNpcScene(int npcIndex) { void EoBEngine::encodeDrawNpcSeqShape(int npcIndex, int drawX, int drawY) { const uint8 *shpDef = &_npcShpData[npcIndex << 2]; _screen->_curPage = 2; - const uint8 *shp = _screen->encodeShape(shpDef[0], shpDef[1], shpDef[2], shpDef[3]); + const uint8 *shp = _screen->encodeShape(shpDef[0], shpDef[1], shpDef[2], shpDef[3], false, _cgaMappingDefault); _screen->_curPage = 0; _screen->drawShape(0, shp, drawX - (shp[2] << 2), drawY - shp[1], 5); delete[] shp; @@ -352,9 +361,9 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s if (doorType1 != 0xff) { for (int i = 0; i < 3; i++) { const uint8 *enc = &_doorShapeEncodeDefs[(doorType1 * 3 + i) << 2]; - _doorShapes[shapeId1 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3]); + _doorShapes[shapeId1 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); enc = &_doorSwitchShapeEncodeDefs[(doorType1 * 3 + i) << 2]; - _doorSwitches[shapeId1 + i].shp = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3]); + _doorSwitches[shapeId1 + i].shp = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); _doorSwitches[shapeId1 + i].x = _doorSwitchCoords[doorType1 * 6 + i * 2]; _doorSwitches[shapeId1 + i].y = _doorSwitchCoords[doorType1 * 6 + i * 2 + 1]; } @@ -363,9 +372,9 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s if (doorType2 != 0xff) { for (int i = 0; i < 3; i++) { const uint8 *enc = &_doorShapeEncodeDefs[(doorType2 * 3 + i) << 2]; - _doorShapes[shapeId2 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3]); + _doorShapes[shapeId2 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); enc = &_doorSwitchShapeEncodeDefs[(doorType2 * 3 + i) << 2]; - _doorSwitches[shapeId2 + i].shp = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3]); + _doorSwitches[shapeId2 + i].shp = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); _doorSwitches[shapeId2 + i].x = _doorSwitchCoords[doorType2 * 6 + i * 2]; _doorSwitches[shapeId2 + i].y = _doorSwitchCoords[doorType2 * 6 + i * 2 + 1]; } diff --git a/engines/kyra/eob.h b/engines/kyra/eob.h index 89d2b25b23..9d583a0cd7 100644 --- a/engines/kyra/eob.h +++ b/engines/kyra/eob.h @@ -109,6 +109,7 @@ private: const KyraRpgGUISettings *guiSettings(); static const KyraRpgGUISettings _guiSettings; + static const uint8 _egaDefaultPalette[]; }; diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index 42ceed593e..a68c7de9e8 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -47,6 +47,7 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags) _numThrownItemShapes(flags.gameID == GI_EOB1 ? 12 : 9), _numItemIconShapes(flags.gameID == GI_EOB1 ? 89 : 112), _teleporterWallId(flags.gameID == GI_EOB1 ? 52 : 44) { + _screen = 0; _gui = 0; _debugger = 0; @@ -212,6 +213,8 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags) _spellLevelsMage = _spellLevelsCleric = _numSpellsCleric = _numSpellsWisAdj = _numSpellsPal = _numSpellsMage = 0; _mnNumWord = _numSpells = _mageSpellListSize = _spellLevelsMageSize = _spellLevelsClericSize = 0; _inventorySlotsX = _slotValidationFlags = _encodeMonsterShpTable = 0; + _cgaMappingDefault = _cgaMappingAlt = _cgaMappingInv = _cgaLevelMappingIndex = _cgaMappingItemsL = _cgaMappingItemsS = _cgaMappingThrown = _cgaMappingIcons = _cgaMappingDeco = 0; + memset(_cgaMappingLevel, 0, sizeof(_cgaMappingLevel)); memset(_expRequirementTables, 0, sizeof(_expRequirementTables)); memset(_saveThrowTables, 0, sizeof(_saveThrowTables)); memset(_doorType, 0, sizeof(_doorType)); @@ -364,6 +367,9 @@ Common::Error EoBCoreEngine::init() { // This makes a tick length of 54.94. _tickLength = 55; + if (ConfMan.hasKey("render_mode")) + _configRenderMode = Common::parseRenderMode(ConfMan.get("render_mode")); + _screen = new Screen_EoB(this, _system); assert(_screen); _screen->setResolution(); @@ -497,8 +503,7 @@ Common::Error EoBCoreEngine::go() { _debugger->initialize(); _txt->removePageBreakFlag(); - _screen->loadPalette("palette.col", _screen->getPalette(0)); - _screen->setScreenPalette(_screen->getPalette(0)); + _screen->setFont(Screen::FID_8_FNT); loadItemsAndDecorationsShapes(); @@ -661,44 +666,43 @@ bool EoBCoreEngine::checkPartyStatus(bool handleDeath) { void EoBCoreEngine::loadItemsAndDecorationsShapes() { releaseItemsAndDecorationsShapes(); - _screen->setCurPage(2); - _screen->loadBitmap("ITEML1.CPS", 5, 3, 0); + _screen->loadShapeSetBitmap("ITEML1", 5, 3); _largeItemShapes = new const uint8*[_numLargeItemShapes]; int div = (_flags.gameID == GI_EOB1) ? 3 : 8; int mul = (_flags.gameID == GI_EOB1) ? 64 : 24; for (int i = 0; i < _numLargeItemShapes; i++) - _largeItemShapes[i] = _screen->encodeShape((i / div) << 3, (i % div) * mul, 8, 24); + _largeItemShapes[i] = _screen->encodeShape((i / div) << 3, (i % div) * mul, 8, 24, false, _cgaMappingItemsL); - _screen->loadBitmap("ITEMS1.CPS", 5, 3, 0); + _screen->loadShapeSetBitmap("ITEMS1", 5, 3); _smallItemShapes = new const uint8*[_numSmallItemShapes]; for (int i = 0; i < _numSmallItemShapes; i++) - _smallItemShapes[i] = _screen->encodeShape((i / div) << 2, (i % div) * mul, 4, 24); + _smallItemShapes[i] = _screen->encodeShape((i / div) << 2, (i % div) * mul, 4, 24, false, _cgaMappingItemsS); - _screen->loadBitmap("THROWN.CPS", 5, 3, 0); + _screen->loadShapeSetBitmap("THROWN", 5, 3); _thrownItemShapes = new const uint8*[_numThrownItemShapes]; for (int i = 0; i < _numThrownItemShapes; i++) - _thrownItemShapes[i] = _screen->encodeShape((i / div) << 2, (i % div) * mul, 4, 24); + _thrownItemShapes[i] = _screen->encodeShape((i / div) << 2, (i % div) * mul, 4, 24, false, _cgaMappingThrown); _spellShapes = new const uint8*[4]; for (int i = 0; i < 4; i++) - _spellShapes[i] = _screen->encodeShape(8, i << 5, 6, 32); + _spellShapes[i] = _screen->encodeShape(8, i << 5, 6, 32, false, _cgaMappingThrown); _firebeamShapes = new const uint8*[3]; - _firebeamShapes[0] = _screen->encodeShape(16, 0, 4, 24); - _firebeamShapes[1] = _screen->encodeShape(16, 24, 4, 24); - _firebeamShapes[2] = _screen->encodeShape(16, 48, 3, 24); - _redSplatShape = _screen->encodeShape(16, _flags.gameID == GI_EOB1 ? 144 : 72, 5, 24); - _greenSplatShape = _screen->encodeShape(16, _flags.gameID == GI_EOB1 ? 168 : 96, 5, 16); + _firebeamShapes[0] = _screen->encodeShape(16, 0, 4, 24, false, _cgaMappingThrown); + _firebeamShapes[1] = _screen->encodeShape(16, 24, 4, 24, false, _cgaMappingThrown); + _firebeamShapes[2] = _screen->encodeShape(16, 48, 3, 24, false, _cgaMappingThrown); + _redSplatShape = _screen->encodeShape(16, _flags.gameID == GI_EOB1 ? 144 : 72, 5, 24, false, _cgaMappingThrown); + _greenSplatShape = _screen->encodeShape(16, _flags.gameID == GI_EOB1 ? 168 : 96, 5, 16, false, _cgaMappingThrown); - _screen->loadBitmap("ITEMICN.CPS", 5, 3, 0); + _screen->loadShapeSetBitmap("ITEMICN", 5, 3); _itemIconShapes = new const uint8*[_numItemIconShapes]; for (int i = 0; i < _numItemIconShapes; i++) - _itemIconShapes[i] = _screen->encodeShape((i % 0x14) << 1, (i / 0x14) << 4, 2, 0x10); + _itemIconShapes[i] = _screen->encodeShape((i % 0x14) << 1, (i / 0x14) << 4, 2, 0x10, false, _cgaMappingIcons); _tempIconShape = new uint8[300]; - _screen->loadBitmap("DECORATE.CPS", 5, 3, 0); + _screen->loadShapeSetBitmap("DECORATE", 5, 3); if (_flags.gameID == GI_EOB2) { _lightningColumnShape = _screen->encodeShape(18, 88, 4, 64); @@ -709,16 +713,16 @@ void EoBCoreEngine::loadItemsAndDecorationsShapes() { _teleporterShapes = new const uint8*[6]; for (int i = 0; i < 6; i++) - _teleporterShapes[i] = _screen->encodeShape(_teleporterShapeDefs[(i << 2)], _teleporterShapeDefs[(i << 2) + 1], _teleporterShapeDefs[(i << 2) + 2], _teleporterShapeDefs[(i << 2) + 3]); + _teleporterShapes[i] = _screen->encodeShape(_teleporterShapeDefs[(i << 2)], _teleporterShapeDefs[(i << 2) + 1], _teleporterShapeDefs[(i << 2) + 2], _teleporterShapeDefs[(i << 2) + 3], false, _cgaMappingDefault); _sparkShapes = new const uint8*[3]; - _sparkShapes[0] = _screen->encodeShape(29, 0, 2, 16); - _sparkShapes[1] = _screen->encodeShape(31, 0, 2, 16); - _sparkShapes[2] = _screen->encodeShape(33, 0, 2, 16); - _deadCharShape = _screen->encodeShape(0, 88, 4, 32); - _disabledCharGrid = _screen->encodeShape(4, 88, 4, 32); - _blackBoxSmallGrid = _screen->encodeShape(9, 88, 2, 8); - _weaponSlotGrid = _screen->encodeShape(8, 88, 4, 16); - _blackBoxWideGrid = _screen->encodeShape(8, 104, 4, 8); + _sparkShapes[0] = _screen->encodeShape(29, 0, 2, 16, false, _cgaMappingDeco); + _sparkShapes[1] = _screen->encodeShape(31, 0, 2, 16, false, _cgaMappingDeco); + _sparkShapes[2] = _screen->encodeShape(33, 0, 2, 16, false, _cgaMappingDeco); + _deadCharShape = _screen->encodeShape(0, 88, 4, 32, false, _cgaMappingDeco); + _disabledCharGrid = _screen->encodeShape(4, 88, 4, 32, false, _cgaMappingDeco); + _blackBoxSmallGrid = _screen->encodeShape(9, 88, 2, 8, false, _cgaMappingDeco); + _weaponSlotGrid = _screen->encodeShape(8, 88, 4, 16, false, _cgaMappingDeco); + _blackBoxWideGrid = _screen->encodeShape(8, 104, 4, 8, false, _cgaMappingDeco); static const uint8 dHeight[] = { 17, 10, 10 }; static const uint8 dY[] = { 120, 137, 147 }; @@ -726,7 +730,7 @@ void EoBCoreEngine::loadItemsAndDecorationsShapes() { _compassShapes = new const uint8*[12]; for (int y = 0; y < 3; y++) { for (int x = 0; x < 4; x++) - _compassShapes[(y << 2) + x] = _screen->encodeShape(x * 3, dY[y], 3, dHeight[y]); + _compassShapes[(y << 2) + x] = _screen->encodeShape(x * 3, dY[y], 3, dHeight[y], false, _cgaMappingDeco); } } @@ -1197,7 +1201,7 @@ void EoBCoreEngine::initNpc(int npcIndex) { _screen->loadShapeSetBitmap(_flags.gameID == GI_EOB2 ? "OUTPORTS" : "OUTTAKE", 3, 3); _screen->_curPage = 2; - c->faceShape = _screen->encodeShape(npcIndex << 2, _flags.gameID == GI_EOB2 ? 0 : 160, 4, 32, true); + c->faceShape = _screen->encodeShape(npcIndex << 2, _flags.gameID == GI_EOB2 ? 0 : 160, 4, 32, true, _cgaMappingDefault); _screen->_curPage = 0; } @@ -1679,13 +1683,13 @@ void EoBCoreEngine::seq_portal() { _screen->loadShapeSetBitmap("PORTALA", 5, 3); for (int i = 0; i < 5; i++) { - shapes1[i] = _screen->encodeShape(i * 3, 0, 3, 75); - shapes2[i] = _screen->encodeShape(i * 3, 80, 3, 75); - shapes3[i] = _screen->encodeShape(15, i * 18, 15, 18); + shapes1[i] = _screen->encodeShape(i * 3, 0, 3, 75, false, _cgaMappingDefault); + shapes2[i] = _screen->encodeShape(i * 3, 80, 3, 75, false, _cgaMappingDefault); + shapes3[i] = _screen->encodeShape(15, i * 18, 15, 18, false, _cgaMappingDefault); } - shape0 = _screen->encodeShape(30, 0, 8, 77); - _screen->loadEoBBitmap("PORTALB", 0, 5, 3, 2); + shape0 = _screen->encodeShape(30, 0, 8, 77, false, _cgaMappingDefault); + _screen->loadEoBBitmap("PORTALB", _cgaMappingDefault, 5, 3, 2); snd_playSoundEffect(33); snd_playSoundEffect(19); diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index dff2427ddb..49589c809c 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -31,7 +31,7 @@ namespace Kyra { -struct EoBShapeDef { +struct DarkMoonShapeDef { int16 index; uint8 x, y, w, h; }; @@ -577,7 +577,7 @@ protected: void readLevelFileData(int level); Common::String initLevelData(int sub); void addLevelItems(); - void loadVcnData(const char *file, const char * /*nextFile*/); + void loadVcnData(const char *file, const uint8 *cgaMapping); void loadBlockProperties(const char *mazFile); const uint8 *getBlockFileData(int levelIndex = 0); Common::String getBlockFileName(int levelIndex, int sub); @@ -834,6 +834,17 @@ protected: Common::Error loadGameState(int slot); Common::Error saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail); + const uint8 *_cgaMappingDefault; + const uint8 *_cgaMappingAlt; + const uint8 *_cgaMappingInv; + const uint8 *_cgaMappingItemsL; + const uint8 *_cgaMappingItemsS; + const uint8 *_cgaMappingThrown; + const uint8 *_cgaMappingIcons; + const uint8 *_cgaMappingDeco; + const uint8 *_cgaMappingLevel[5]; + const uint8 *_cgaLevelMappingIndex; + // Default parameters will import all present original save files and push them to the top of the save dialog. bool importOriginalSaveFile(int destSlot, const char *sourceFile = 0); Common::String readOriginalSaveFile(Common::String &file); diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index b89a6d7293..2fdfb0c011 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -47,7 +47,7 @@ Button *EoBCoreEngine::gui_getButton(Button *buttonList, int index) { } void EoBCoreEngine::gui_drawPlayField(bool refresh) { - _screen->loadEoBBitmap("PLAYFLD", 0, 5, 3, 2); + _screen->loadEoBBitmap("PLAYFLD", _cgaMappingDeco, 5, 3, 2); int cp = _screen->setCurPage(2); gui_drawCompass(true); @@ -60,11 +60,11 @@ void EoBCoreEngine::gui_drawPlayField(bool refresh) { if (!_loading) _screen->updateScreen(); - _screen->loadEoBBitmap("INVENT", 0, 5, 3, 2); + _screen->loadEoBBitmap("INVENT", _cgaMappingInv, 5, 3, 2); } void EoBCoreEngine::gui_restorePlayField() { - loadVcnData(0, 0); + loadVcnData(0, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); _screen->_curPage = 0; gui_drawPlayField(true); gui_drawAllCharPortraitsWithStats(); @@ -1891,7 +1891,7 @@ void GUI_EoB::simpleMenu_setup(int sd, int maxItem, const char *const *strings, for (int i = 0; i < _menuNumItems; i++) { int item = simpleMenu_getMenuItem(i, menuItemsMask, itemOffset); int ty = y + i * (lineSpacing + _screen->getFontHeight()); - _screen->printShadedText(strings[item], x, ty, dm->unkA, 0); + _screen->printShadedText(strings[item], x, ty, (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : dm->unkA, 0); if (item == v) _screen->printText(strings[item], x, ty, dm->unkC, 0); } @@ -1944,7 +1944,7 @@ int GUI_EoB::simpleMenu_process(int sd, const char *const *strings, void *b, int } if (newItem != currentItem) { - _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, itemOffset)], x, y + currentItem * lineH , dm->unkA, 0); + _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, itemOffset)], x, y + currentItem * lineH, (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : dm->unkA, 0); _screen->printText(strings[simpleMenu_getMenuItem(newItem, menuItemsMask, itemOffset)], x, y + newItem * lineH , dm->unkC, 0); _screen->updateScreen(); } diff --git a/engines/kyra/kyra_rpg.cpp b/engines/kyra/kyra_rpg.cpp index b28292562a..8c9a1ec835 100644 --- a/engines/kyra/kyra_rpg.cpp +++ b/engines/kyra/kyra_rpg.cpp @@ -45,7 +45,7 @@ KyraRpgEngine::KyraRpgEngine(OSystem *system, const GameFlags &flags) : KyraEngi _vcnBlocks = 0; _vcfBlocks = 0; _vcnShift = 0; - _vcnExpTable = 0; + _vcnColTable = 0; _vmpPtr = 0; _blockBrightness = _wllVcnOffset = 0; _blockDrawingBuffer = 0; @@ -123,7 +123,7 @@ KyraRpgEngine::~KyraRpgEngine() { delete[] _wllWallFlags; delete[] _vmpPtr; - delete[] _vcnExpTable; + delete[] _vcnColTable; delete[] _vcnBlocks; delete[] _vcfBlocks; delete[] _vcnShift; @@ -173,9 +173,9 @@ Common::Error KyraRpgEngine::init() { _lvlShapeLeftRight = new int16[36]; memset(_lvlShapeLeftRight, 0, 36 * sizeof(int16)); - _vcnExpTable = new uint8[128]; + _vcnColTable = new uint8[128]; for (int i = 0; i < 128; i++) - _vcnExpTable[i] = i & 0x0f; + _vcnColTable[i] = i & 0x0f; _doorShapes = new uint8*[6]; memset(_doorShapes, 0, 6 * sizeof(uint8 *)); diff --git a/engines/kyra/kyra_rpg.h b/engines/kyra/kyra_rpg.h index b606963d8a..6a71239250 100644 --- a/engines/kyra/kyra_rpg.h +++ b/engines/kyra/kyra_rpg.h @@ -225,7 +225,7 @@ protected: uint8 *_vcnBlocks; uint8 *_vcfBlocks; uint8 *_vcnShift; - uint8 *_vcnExpTable; + uint8 *_vcnColTable; uint16 *_blockDrawingBuffer; uint8 *_sceneWindowBuffer; uint8 _blockBrightness; diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 7167d41550..0f7da7673b 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -42,6 +42,8 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) _emc = 0; _debugger = 0; + _configRenderMode = Common::kRenderDefault; + if (_flags.platform == Common::kPlatformAmiga) _gameSpeed = 50; else @@ -163,6 +165,9 @@ Common::Error KyraEngine_v1::init() { if (_sound) _sound->updateVolumeSettings(); + if (ConfMan.hasKey("render_mode")) + _configRenderMode = Common::parseRenderMode(ConfMan.get("render_mode")); + _res = new Resource(this); assert(_res); _res->reset(); diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 04bfab2cb8..2c2901a753 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -306,6 +306,8 @@ protected: bool _configSounds; uint8 _configVoice; + Common::RenderMode _configRenderMode; + // game speed virtual bool skipFlag() const; virtual void resetSkipFlag(bool removeEvent = true); diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 5de1577943..84592880e1 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -517,9 +517,23 @@ enum KyraResources { kEoB1EnemyMageSfx, kEoB1BeholderSpellList, kEoB1BeholderSfx, - kEoB1TurnUndeadString, + kEoB1CgaMappingDefault, + kEoB1CgaMappingAlt, + kEoB1CgaMappingInv, + kEoB1CgaMappingItemsL, + kEoB1CgaMappingItemsS, + kEoB1CgaMappingThrown, + kEoB1CgaMappingIcons, + kEoB1CgaMappingDeco, + kEoB1CgaLevelMappingIndex, + kEoB1CgaMappingLevel0, + kEoB1CgaMappingLevel1, + kEoB1CgaMappingLevel2, + kEoB1CgaMappingLevel3, + kEoB1CgaMappingLevel4, + kEoB1NpcShpData, kEoB1NpcSubShpIndex1, kEoB1NpcSubShpIndex2, @@ -548,50 +562,50 @@ enum KyraResources { kEoB2IntroStrings, kEoB2IntroCPSFiles, - kEoB2IntroSeqData00, - kEoB2IntroSeqData01, - kEoB2IntroSeqData02, - kEoB2IntroSeqData03, - kEoB2IntroSeqData04, - kEoB2IntroSeqData05, - kEoB2IntroSeqData06, - kEoB2IntroSeqData07, - kEoB2IntroSeqData08, - kEoB2IntroSeqData09, - kEoB2IntroSeqData10, - kEoB2IntroSeqData11, - kEoB2IntroSeqData12, - kEoB2IntroSeqData13, - kEoB2IntroSeqData14, - kEoB2IntroSeqData15, - kEoB2IntroSeqData16, - kEoB2IntroSeqData17, - kEoB2IntroSeqData18, - kEoB2IntroSeqData19, - kEoB2IntroSeqData20, - kEoB2IntroSeqData21, - kEoB2IntroSeqData22, - kEoB2IntroSeqData23, - kEoB2IntroSeqData24, - kEoB2IntroSeqData25, - kEoB2IntroSeqData26, - kEoB2IntroSeqData27, - kEoB2IntroSeqData28, - kEoB2IntroSeqData29, - kEoB2IntroSeqData30, - kEoB2IntroSeqData31, - kEoB2IntroSeqData32, - kEoB2IntroSeqData33, - kEoB2IntroSeqData34, - kEoB2IntroSeqData35, - kEoB2IntroSeqData36, - kEoB2IntroSeqData37, - kEoB2IntroSeqData38, - kEoB2IntroSeqData39, - kEoB2IntroSeqData40, - kEoB2IntroSeqData41, - kEoB2IntroSeqData42, - kEoB2IntroSeqData43, + kEob2IntroAnimData00, + kEob2IntroAnimData01, + kEob2IntroAnimData02, + kEob2IntroAnimData03, + kEob2IntroAnimData04, + kEob2IntroAnimData05, + kEob2IntroAnimData06, + kEob2IntroAnimData07, + kEob2IntroAnimData08, + kEob2IntroAnimData09, + kEob2IntroAnimData10, + kEob2IntroAnimData11, + kEob2IntroAnimData12, + kEob2IntroAnimData13, + kEob2IntroAnimData14, + kEob2IntroAnimData15, + kEob2IntroAnimData16, + kEob2IntroAnimData17, + kEob2IntroAnimData18, + kEob2IntroAnimData19, + kEob2IntroAnimData20, + kEob2IntroAnimData21, + kEob2IntroAnimData22, + kEob2IntroAnimData23, + kEob2IntroAnimData24, + kEob2IntroAnimData25, + kEob2IntroAnimData26, + kEob2IntroAnimData27, + kEob2IntroAnimData28, + kEob2IntroAnimData29, + kEob2IntroAnimData30, + kEob2IntroAnimData31, + kEob2IntroAnimData32, + kEob2IntroAnimData33, + kEob2IntroAnimData34, + kEob2IntroAnimData35, + kEob2IntroAnimData36, + kEob2IntroAnimData37, + kEob2IntroAnimData38, + kEob2IntroAnimData39, + kEob2IntroAnimData40, + kEob2IntroAnimData41, + kEob2IntroAnimData42, + kEob2IntroAnimData43, kEoB2IntroShapes00, kEoB2IntroShapes01, kEoB2IntroShapes04, @@ -600,27 +614,27 @@ enum KyraResources { kEoB2FinaleStrings, kEoB2CreditsData, kEoB2FinaleCPSFiles, - kEoB2FinaleSeqData00, - kEoB2FinaleSeqData01, - kEoB2FinaleSeqData02, - kEoB2FinaleSeqData03, - kEoB2FinaleSeqData04, - kEoB2FinaleSeqData05, - kEoB2FinaleSeqData06, - kEoB2FinaleSeqData07, - kEoB2FinaleSeqData08, - kEoB2FinaleSeqData09, - kEoB2FinaleSeqData10, - kEoB2FinaleSeqData11, - kEoB2FinaleSeqData12, - kEoB2FinaleSeqData13, - kEoB2FinaleSeqData14, - kEoB2FinaleSeqData15, - kEoB2FinaleSeqData16, - kEoB2FinaleSeqData17, - kEoB2FinaleSeqData18, - kEoB2FinaleSeqData19, - kEoB2FinaleSeqData20, + kEob2FinaleAnimData00, + kEob2FinaleAnimData01, + kEob2FinaleAnimData02, + kEob2FinaleAnimData03, + kEob2FinaleAnimData04, + kEob2FinaleAnimData05, + kEob2FinaleAnimData06, + kEob2FinaleAnimData07, + kEob2FinaleAnimData08, + kEob2FinaleAnimData09, + kEob2FinaleAnimData10, + kEob2FinaleAnimData11, + kEob2FinaleAnimData12, + kEob2FinaleAnimData13, + kEob2FinaleAnimData14, + kEob2FinaleAnimData15, + kEob2FinaleAnimData16, + kEob2FinaleAnimData17, + kEob2FinaleAnimData18, + kEob2FinaleAnimData19, + kEob2FinaleAnimData20, kEoB2FinaleShapes00, kEoB2FinaleShapes03, kEoB2FinaleShapes07, @@ -757,8 +771,8 @@ public: const LoLButtonDef *loadButtonDefs(int id, int &entries); #endif // ENABLE_LOL #ifdef ENABLE_EOB - const EoBSequenceStep *loadEoB2SeqData(int id, int &entries); - const EoBShapeDef *loadEoB2ShapeData(int id, int &entries); + const DarkMoonAnimCommand *loadEoB2SeqData(int id, int &entries); + const DarkMoonShapeDef *loadEoB2ShapeData(int id, int &entries); const EoBCharacter *loadEoBNpcData(int id, int &entries); #endif // ENABLE_EOB diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 9f9476d0dc..7f20c124ff 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -110,7 +110,7 @@ Common::Error EoBCoreEngine::loadGameState(int slot) { EoBCharacter *c = &_characters[i]; if (!c->flags || c->portrait < 0) continue; - c->faceShape = _screen->encodeShape((c->portrait % 10) << 2, (c->portrait / 10) << 5, 4, 32, true); + c->faceShape = _screen->encodeShape((c->portrait % 10) << 2, (c->portrait / 10) << 5, 4, 32, true, _cgaMappingDefault); } _screen->loadShapeSetBitmap(_flags.gameID == GI_EOB2 ? "OUTPORTS" : "OUTTAKE", 3, 3); @@ -118,7 +118,7 @@ Common::Error EoBCoreEngine::loadGameState(int slot) { EoBCharacter *c = &_characters[i]; if (!c->flags || c->portrait >= 0) continue; - c->faceShape = _screen->encodeShape((-(c->portrait + 1)) << 2, _flags.gameID == GI_EOB2 ? 0 : 160, 4, 32, true); + c->faceShape = _screen->encodeShape((-(c->portrait + 1)) << 2, _flags.gameID == GI_EOB2 ? 0 : 160, 4, 32, true, _cgaMappingDefault); } _screen->_curPage = 0; diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index 3d615e966a..2a59a97cc1 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -86,8 +86,8 @@ void EoBCoreEngine::loadLevel(int level, int sub) { pos += 2; } - loadVcnData(gfxFile.c_str(), 0); - _screen->loadEoBBitmap("INVENT", 0, 5, 3, 2); + loadVcnData(gfxFile.c_str(), (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[level - 1]] : 0); + _screen->loadEoBBitmap("INVENT", _cgaMappingInv, 5, 3, 2); delayUntil(end); snd_stopSound(); @@ -142,7 +142,8 @@ Common::String EoBCoreEngine::initLevelData(int sub) { loadBlockProperties((const char *)pos); pos += slen; - Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("%s.VMP", (const char *)pos)); + const char *vmpPattern = (_flags.gameID == GI_EOB1 && (_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA)) ? "%s.EMP" : "%s.VMP"; + Common::SeekableReadStream *s = _res->createReadStream(Common::String::format(vmpPattern, (const char *)pos)); uint16 size = s->readUint16LE(); delete[] _vmpPtr; _vmpPtr = new uint16[size]; @@ -150,12 +151,14 @@ Common::String EoBCoreEngine::initLevelData(int sub) { _vmpPtr[i] = s->readUint16LE(); delete s; - Common::String tmpStr = Common::String::format("%s.PAL", (const char *)pos); + const char *paletteFilePattern = (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA) ? "%s.EGA" : "%s.PAL"; + + Common::String tmpStr = Common::String::format(paletteFilePattern, (const char *)pos); _curGfxFile = (const char *)pos; pos += slen; if (*pos++ != 0xff && _flags.gameID == GI_EOB2) { - tmpStr = Common::String::format("%s.PAL", (const char *)pos); + tmpStr = Common::String::format(paletteFilePattern, (const char *)pos); pos += 13; } @@ -165,21 +168,24 @@ Common::String EoBCoreEngine::initLevelData(int sub) { _screen->setShapeFadeMode(1, false); } - _screen->loadPalette(tmpStr.c_str(), _screen->getPalette(0)); + if (_flags.gameID == GI_EOB2 || _configRenderMode != Common::kRenderEGA) + _screen->loadPalette(tmpStr.c_str(), _screen->getPalette(0)); - Palette backupPal(256); - backupPal.copy(_screen->getPalette(0), 224, 32, 224); - _screen->getPalette(0).fill(224, 32, 0x3f); - uint8 *src = _screen->getPalette(0).getData(); + if (_configRenderMode != Common::kRenderCGA) { + Palette backupPal(256); + backupPal.copy(_screen->getPalette(0), 224, 32, 224); + _screen->getPalette(0).fill(224, 32, 0x3f); + uint8 *src = _screen->getPalette(0).getData(); - _screen->createFadeTable(src, _screen->getFadeTable(0), 4, 75); // green - _screen->createFadeTable(src, _screen->getFadeTable(1), 12, 200); // black - _screen->createFadeTable(src, _screen->getFadeTable(2), 10, 85); // blue - _screen->createFadeTable(src, _screen->getFadeTable(3), 11, 125); // light blue + _screen->createFadeTable(src, _screen->getFadeTable(0), 4, 75); // green + _screen->createFadeTable(src, _screen->getFadeTable(1), 12, 200); // black + _screen->createFadeTable(src, _screen->getFadeTable(2), 10, 85); // blue + _screen->createFadeTable(src, _screen->getFadeTable(3), 11, 125); // light blue - _screen->getPalette(0).copy(backupPal, 224, 32, 224); - _screen->createFadeTable(src, _screen->getFadeTable(4), 12, 85); // grey (shadow) - _screen->setFadeTableIndex(4); + _screen->getPalette(0).copy(backupPal, 224, 32, 224); + _screen->createFadeTable(src, _screen->getFadeTable(4), 12, 85); // grey (shadow) + _screen->setFadeTableIndex(4); + } } if (_flags.gameID == GI_EOB2) { @@ -267,15 +273,17 @@ void EoBCoreEngine::addLevelItems() { } } -void EoBCoreEngine::loadVcnData(const char *file, const char * /*nextFile*/) { +void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) { if (file) strcpy(_lastBlockDataFile, file); - _screen->loadBitmap(Common::String::format("%s.VCN", _lastBlockDataFile).c_str(), 3, 3, 0); - const uint8 *v = _screen->getCPagePtr(2); + const char *filePattern = (_flags.gameID == GI_EOB1 && (_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA)) ? "%s.ECN" : "%s.VCN"; + _screen->loadBitmap(Common::String::format(filePattern, _lastBlockDataFile).c_str(), 3, 3, 0); + const uint8 *v = _screen->getCPagePtr(3); uint32 tlen = READ_LE_UINT16(v) << 5; v += 2; - memcpy(_vcnExpTable, v, 32); + if (!(_flags.gameID == GI_EOB1 && (_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA))) + memcpy(_vcnColTable, v, 32); v += 32; delete[] _vcnBlocks; _vcnBlocks = new uint8[tlen]; @@ -301,7 +309,7 @@ const uint8 *EoBCoreEngine::getBlockFileData(int) { Common::SeekableReadStream *s = _res->createReadStream(_curBlockFile); _screen->loadFileDataToPage(s, 15, s->size()); delete s; - return _screen->getCPagePtr(14); + return _screen->getCPagePtr(15); } Common::String EoBCoreEngine::getBlockFileName(int levelIndex, int sub) { @@ -400,7 +408,7 @@ void EoBCoreEngine::assignWallsAndDecorations(int wallIndex, int vmpIndex, int d if (r->w == 0 || r->h == 0) error("Error trying to make decoration %d (x: %d, y: %d, w: %d, h: %d)", decIndex, r->x, r->y, r->w, r->h); - _levelDecorationShapes[t] = _screen->encodeShape(r->x, r->y, r->w, r->h); + _levelDecorationShapes[t] = _screen->encodeShape(r->x, r->y, r->w, r->h, false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); } decIndex = _levelDecorationProperties[_mappedDecorationsCount++].next; diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp index 796db9a340..79884718d7 100644 --- a/engines/kyra/scene_lol.cpp +++ b/engines/kyra/scene_lol.cpp @@ -358,7 +358,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight memcpy(_vcnShift, v, tlen); v += tlen; - memcpy(_vcnExpTable, v, 128); + memcpy(_vcnColTable, v, 128); v += 128; if (_lastOverridePalFilePtr) { @@ -451,7 +451,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight for (int i = 0; i < 8; i++) { uint8 *pl = _screen->getLevelOverlay(7 - i); for (int ii = 0; ii < 16; ii++) - _vcnExpTable[(i << 4) + ii] = pl[(ii << 4) | ii]; + _vcnColTable[(i << 4) + ii] = pl[(ii << 4) | ii]; } } diff --git a/engines/kyra/scene_rpg.cpp b/engines/kyra/scene_rpg.cpp index 07a7a879b1..55d02d8da1 100644 --- a/engines/kyra/scene_rpg.cpp +++ b/engines/kyra/scene_rpg.cpp @@ -389,8 +389,8 @@ void KyraRpgEngine::drawVcnBlocks() { src += 3; for (int blockX = 0; blockX < 4; blockX++) { uint8 t = *src--; - *d++ = _vcnExpTable[((t & 0x0f) + wllVcnOffset) | shift]; - *d++ = _vcnExpTable[((t >> 4) + wllVcnOffset) | shift]; + *d++ = _vcnColTable[((t & 0x0f) + wllVcnOffset) | shift]; + *d++ = _vcnColTable[((t >> 4) + wllVcnOffset) | shift]; } src += 5; d += 168; @@ -399,8 +399,8 @@ void KyraRpgEngine::drawVcnBlocks() { for (int blockY = 0; blockY < 8; blockY++) { for (int blockX = 0; blockX < 4; blockX++) { uint8 t = *src++; - *d++ = _vcnExpTable[((t >> 4) + wllVcnOffset) | shift]; - *d++ = _vcnExpTable[((t & 0x0f) + wllVcnOffset) | shift]; + *d++ = _vcnColTable[((t >> 4) + wllVcnOffset) | shift]; + *d++ = _vcnColTable[((t & 0x0f) + wllVcnOffset) | shift]; } d += 168; } @@ -424,8 +424,8 @@ void KyraRpgEngine::drawVcnBlocks() { src += 3; for (int blockX = 0; blockX < 4; blockX++) { uint8 t = *src--; - uint8 h = _vcnExpTable[((t & 0x0f) + wllVcnRmdOffset) | shift]; - uint8 l = _vcnExpTable[((t >> 4) + wllVcnRmdOffset) | shift]; + uint8 h = _vcnColTable[((t & 0x0f) + wllVcnRmdOffset) | shift]; + uint8 l = _vcnColTable[((t >> 4) + wllVcnRmdOffset) | shift]; if (h) *d = h; d++; @@ -440,8 +440,8 @@ void KyraRpgEngine::drawVcnBlocks() { for (int blockY = 0; blockY < 8; blockY++) { for (int blockX = 0; blockX < 4; blockX++) { uint8 t = *src++; - uint8 h = _vcnExpTable[((t >> 4) + wllVcnRmdOffset) | shift]; - uint8 l = _vcnExpTable[((t & 0x0f) + wllVcnRmdOffset) | shift]; + uint8 h = _vcnColTable[((t >> 4) + wllVcnRmdOffset) | shift]; + uint8 l = _vcnColTable[((t & 0x0f) + wllVcnRmdOffset) | shift]; if (h) *d = h; d++; diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 6a76cfd0d5..ebf7835bfd 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -27,6 +27,7 @@ #include "common/endian.h" #include "common/memstream.h" #include "common/system.h" +#include "common/config-manager.h" #include "engines/util.h" @@ -49,6 +50,9 @@ Screen::Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, co memset(_fonts, 0, sizeof(_fonts)); + _renderMode = Common::kRenderDefault; + _cgaDrawCharDitheringTable = 0; + _currentFont = FID_8_FNT; _paletteChanged = true; _curDim = 0; @@ -84,6 +88,10 @@ bool Screen::init() { _useSJIS = false; _use16ColorMode = _vm->gameFlags().use16ColorMode; _isAmiga = (_vm->gameFlags().platform == Common::kPlatformAmiga); + + if (ConfMan.hasKey("render_mode")) + _renderMode = Common::parseRenderMode(ConfMan.get("render_mode")); + memset(_fonts, 0, sizeof(_fonts)); if (_vm->gameFlags().useHiResOverlay) { @@ -110,15 +118,33 @@ bool Screen::init() { } _curPage = 0; - uint8 *pagePtr = new uint8[SCREEN_PAGE_SIZE * 8]; - for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) - _pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr + (pageNum >> 1) * SCREEN_PAGE_SIZE; - memset(pagePtr, 0, SCREEN_PAGE_SIZE * 8); + + int numPages = SCREEN_PAGE_NUM / 2; + // CGA and EGA modes use additional pages to do the CGA/EGA specific graphics conversions. + if (_renderMode == Common::kRenderEGA || _renderMode == Common::kRenderCGA) + numPages += 4; + + uint8 *pagePtr = new uint8[numPages * SCREEN_PAGE_SIZE]; + memset(pagePtr, 0, numPages * SCREEN_PAGE_SIZE); + + if (_renderMode == Common::kRenderEGA || _renderMode == Common::kRenderCGA) { + // Unlike VGA mode the odd and even page numbers do not always point to the same buffers. + // Instead, the odd pages are used for CGA/EGA specific graphics conversions. + int pageNum = 0; + for (; pageNum < 8; pageNum++) + _pagePtrs[pageNum] = pagePtr + pageNum * SCREEN_PAGE_SIZE; + for (; pageNum < SCREEN_PAGE_NUM; pageNum += 2) + _pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr + (pageNum / 2) * SCREEN_PAGE_SIZE; + } else { + for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) + _pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr + (pageNum / 2) * SCREEN_PAGE_SIZE; + } memset(_shapePages, 0, sizeof(_shapePages)); const int paletteCount = _isAmiga ? 13 : 4; - const int numColors = _use16ColorMode ? 16 : (_isAmiga ? 32 : 256); + // We allow 256 color palettes in EGA mode, since original EOB II code does the same and requires it + const int numColors = _use16ColorMode ? 16 : (_isAmiga ? 32 : (_renderMode == Common::kRenderCGA ? 4 : 256)); _interfacePaletteEnabled = false; @@ -131,6 +157,13 @@ bool Screen::init() { assert(_palettes[i]); } + // Setup CGA colors (if CGA mode is selected) + if (_renderMode == Common::kRenderCGA) { + Palette pal(4); + pal.setCGAPalette(1, Palette::kIntensityHigh); + Screen::setScreenPalette(pal); + } + _internFadePalette = new Palette(numColors); assert(_internFadePalette); @@ -618,8 +651,14 @@ void Screen::fadeToBlack(int delay, const UpdateFunctor *upFunc) { } void Screen::fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc) { + if (_renderMode == Common::kRenderEGA) + setScreenPalette(pal); + updateScreen(); + if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA) + return; + int diff = 0, delayInc = 0; getFadeParams(pal, delay, delayInc, diff); @@ -1126,7 +1165,7 @@ bool Screen::loadFont(FontId fontId, const char *filename) { fnt = new AMIGAFont(); #ifdef ENABLE_EOB else if (_vm->game() == GI_EOB1 || _vm->game() == GI_EOB2) - fnt = new OldDOSFont(); + fnt = new OldDOSFont(_renderMode, _cgaDrawCharDitheringTable); #endif // ENABLE_EOB else fnt = new DOSFont(); @@ -3013,6 +3052,9 @@ void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, Palette } bool Screen::loadPalette(const char *filename, Palette &pal) { + if (_renderMode == Common::kRenderCGA) + return true; + Common::SeekableReadStream *stream = _vm->resource()->createReadStream(filename); if (!stream) @@ -3029,6 +3071,17 @@ bool Screen::loadPalette(const char *filename, Palette &pal) { } else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode) { numCols = stream->size() / Palette::kPC98BytesPerColor; pal.loadPC98Palette(*stream, 0, MIN(maxCols, numCols)); + } else if (_renderMode == Common::kRenderEGA) { + // EOB II checks the number of palette bytes to distinguish between real EGA palettes + // and normal palettes (which are used to generate a color map). + if (stream->size() == 16) { + numCols = 16; + pal.loadEGAPalette(*stream, 0, 16); + } else { + numCols = stream->size() / Palette::kVGABytesPerColor; + pal.loadVGAPalette(*stream, 0, numCols); + } + } else { numCols = stream->size() / Palette::kVGABytesPerColor; pal.loadVGAPalette(*stream, 0, MIN(maxCols, numCols)); @@ -3076,7 +3129,14 @@ void Screen::loadPalette(const byte *data, Palette &pal, int bytes) { pal.loadAmigaPalette(stream, 0, stream.size() / Palette::kAmigaBytesPerColor); else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode) pal.loadPC98Palette(stream, 0, stream.size() / Palette::kPC98BytesPerColor); - else + else if (_renderMode == Common::kRenderEGA) { + // EOB II checks the number of palette bytes to distinguish between real EGA palettes + // and normal palettes (which are used to generate a color map). + if (stream.size() == 16) + pal.loadEGAPalette(stream, 0, stream.size()); + else + pal.loadVGAPalette(stream, 0, stream.size() / Palette::kVGABytesPerColor); + } else pal.loadVGAPalette(stream, 0, stream.size() / Palette::kVGABytesPerColor); } @@ -3553,6 +3613,24 @@ void Palette::loadVGAPalette(Common::ReadStream &stream, int startIndex, int col *pos++ = stream.readByte() & 0x3f; } +void Palette::loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors) { + assert(startIndex + colors <= 16); + + uint8 *dst = _palData + startIndex * 3; + for (int i = 0; i < colors; i++) { + uint8 index = stream.readByte(); + assert(index < _egaNumColors); + memcpy(dst, &_egaColors[index * 3], 3); + dst += 3; + } +} + +void Palette::setCGAPalette(int palIndex, CGAIntensity intensity) { + assert(_numColors == _cgaNumColors); + assert(!(palIndex & ~1)); + memcpy(_palData, _cgaColors[palIndex * 2 + intensity], _numColors * 3); +} + void Palette::loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors) { assert(startIndex + colors <= _numColors); @@ -3629,4 +3707,22 @@ uint8 *Palette::fetchRealPalette() const { return buffer; } +const uint8 Palette::_egaColors[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0x00, 0xAA, 0xAA, + 0xAA, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0xAA, 0x55, 0x00, 0xAA, 0xAA, 0xAA, + 0x55, 0x55, 0x55, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0x55, 0xFF, 0xFF, + 0xFF, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, 0xFF +}; + +const int Palette::_egaNumColors = ARRAYSIZE(_egaColors) / 3; + +const uint8 Palette::_cgaColors[4][12] = { + { 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x2A, 0x00, 0x00, 0x2A, 0x15, 0x00 }, + { 0x00, 0x00, 0x00, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x15, 0x3F, 0x3F, 0x15 }, + { 0x00, 0x00, 0x00, 0x00, 0x2A, 0x2A, 0x2A, 0x00, 0x2A, 0x2A, 0x2A, 0x2A }, + { 0x00, 0x00, 0x00, 0x15, 0x3F, 0x3F, 0x3F, 0x15, 0x3F, 0x3F, 0x3F, 0x3F } +}; + +const int Palette::_cgaNumColors = ARRAYSIZE(_cgaColors[0]) / 3; + } // End of namespace Kyra diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 62ea35af9e..fcb5ef2be4 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -145,8 +145,8 @@ private: */ class OldDOSFont : public Font { public: - OldDOSFont(); - ~OldDOSFont() { unload(); } + OldDOSFont(Common::RenderMode mode, const uint16 *cgaDitheringTable); + ~OldDOSFont(); bool load(Common::SeekableReadStream &file); int getHeight() const { return _height; } @@ -165,6 +165,9 @@ private: const uint8 *_colorMap; int _numGlyphs; + + Common::RenderMode _renderMode; + const uint16 *_cgaDitheringTable; }; #endif // ENABLE_EOB @@ -252,6 +255,21 @@ public: void loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors); /** + * Load a EGA palette from the given stream. + */ + void loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors); + + /** + * Set default CGA palette. We only need the cyan/magenta/grey mode. + */ + enum CGAIntensity { + kIntensityLow = 0, + kIntensityHigh = 1 + }; + + void setCGAPalette(int palIndex, CGAIntensity intensity); + + /** * Load a AMIGA palette from the given stream. */ void loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors); @@ -325,9 +343,15 @@ public: */ uint8 *getData() { return _palData; } const uint8 *getData() const { return _palData; } + private: uint8 *_palData; const int _numColors; + + static const uint8 _egaColors[]; + static const int _egaNumColors; + static const uint8 _cgaColors[4][12]; + static const int _cgaNumColors; }; class Screen { @@ -480,9 +504,9 @@ public: // misc void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip=false); - bool loadPalette(const char *filename, Palette &pal); + virtual bool loadPalette(const char *filename, Palette &pal); bool loadPaletteTable(const char *filename, int firstPalette); - void loadPalette(const byte *data, Palette &pal, int bytes); + virtual void loadPalette(const byte *data, Palette &pal, int bytes); void setAnimBlockPtr(int size); @@ -550,6 +574,8 @@ protected: bool _useSJIS; bool _use16ColorMode; bool _isAmiga; + Common::RenderMode _renderMode; + uint16 *_cgaDrawCharDitheringTable; uint8 _sjisInvisibleColor; diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index 6b1128bdfd..aa94114dfc 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -33,6 +33,7 @@ #include "common/system.h" #include "graphics/cursorman.h" +#include "graphics/palette.h" namespace Kyra { @@ -49,29 +50,66 @@ Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system, _dsRem = 0; _dsScaleTmp = 0; _gfxMaxY = 0; + _egaColorMap = 0; + _egaPixelValueTable = 0; + _cgaMappingDefault = 0; + _cgaDitheringTables[0] = _cgaDitheringTables[1] = 0; + _useHiResEGADithering = false; } Screen_EoB::~Screen_EoB() { delete[] _fadeData; delete[] _dsTempPage; + delete[] _egaColorMap; + delete[] _egaPixelValueTable; + delete[] _cgaDitheringTables[0]; + delete[] _cgaDitheringTables[1]; + delete[] _cgaDrawCharDitheringTable; } bool Screen_EoB::init() { if (Screen::init()) { int temp; _gfxMaxY = _vm->staticres()->loadRawData(kEoBBaseExpObjectY, temp); - _fadeData = _vm->resource()->fileData("FADING.DAT", 0); + + if (_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) + _fadeData = _vm->resource()->fileData("FADING.DAT", 0); if (!_fadeData) { _fadeData = new uint8[0x700]; memset(_fadeData, 0, 0x700); - uint8 *pal = _vm->resource()->fileData("palette1.pal", 0); // EGA: palette0.pal - for (int i = 0; i < 7; i++) - createFadeTable(pal, &_fadeData[i << 8], 18, (i + 1) * 36); - delete[] pal; + if (_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) { + uint8 *pal = _vm->resource()->fileData("PALETTE1.PAL", 0); + for (int i = 0; i < 7; i++) + createFadeTable(pal, &_fadeData[i << 8], 18, (i + 1) * 36); + delete[] pal; + } } _dsTempPage = new uint8[6000]; + if (_renderMode == Common::kRenderEGA) { + _egaColorMap = new uint8[256]; + _egaPixelValueTable = new uint8[256]; + for (int i = 0; i < 256; i++) { + _egaColorMap[i] = i & 0x0f; + _egaPixelValueTable[i] = i & 0x0f; + } + + if (_vm->game() == GI_EOB2) + _useHiResEGADithering = true; + } else if (_renderMode == Common::kRenderCGA) { + _cgaMappingDefault = _vm->staticres()->loadRawData(kEoB1CgaMappingDefault, temp); + _cgaDitheringTables[0] = new uint16[256]; + memset(_cgaDitheringTables[0], 0, 256 * sizeof(uint16)); + _cgaDitheringTables[1] = new uint16[256]; + memset(_cgaDitheringTables[1], 0, 256 * sizeof(uint16)); + _cgaDrawCharDitheringTable = new uint16[256]; + memset(_cgaDrawCharDitheringTable, 0, 256 * sizeof(uint16)); + + static const uint bits[] = { 0, 3, 12, 15 }; + for (int i = 0; i < 256; i++) + WRITE_BE_UINT16(&_cgaDrawCharDitheringTable[i], (bits[i & 3] << 8) | (bits[(i >> 2) & 3] << 12) | (bits[(i >> 4) & 3] << 0) | (bits[(i >> 6) & 3] << 4)); + } return true; } @@ -121,12 +159,13 @@ void Screen_EoB::printShadedText(const char *string, int x, int y, int col1, int } void Screen_EoB::loadShapeSetBitmap(const char *file, int tempPage, int destPage) { - loadEoBBitmap(file, 0, tempPage, destPage, -1); + loadEoBBitmap(file, _cgaMappingDefault, tempPage, destPage, -1); _curPage = 2; } -void Screen_EoB::loadEoBBitmap(const char *file, const uint8 *ditheringData, int tempPage, int destPage, int copyToPage) { - Common::String tmp = Common::String::format("%s.CPS", file); +void Screen_EoB::loadEoBBitmap(const char *file, const uint8 *cgaMapping, int tempPage, int destPage, int convertToPage) { + const char *filePattern = (_vm->game() == GI_EOB1 && (_renderMode == Common::kRenderEGA || _renderMode == Common::kRenderCGA)) ? "%s.EGA" : "%s.CPS"; + Common::String tmp = Common::String::format(filePattern, file); Common::SeekableReadStream *s = _vm->resource()->createReadStream(tmp); bool loadAlternative = false; if (s) { @@ -149,28 +188,124 @@ void Screen_EoB::loadEoBBitmap(const char *file, const uint8 *ditheringData, int tmp.setChar('X', 0); s = _vm->resource()->createReadStream(tmp); if (!s) - error("Screen_EoB::loadEoBBitmap(): CPS file loading failed."); + error("Screen_EoB::loadEoBBitmap(): Failed to load file '%s'", file); s->seek(768); loadFileDataToPage(s, destPage, 64000); delete s; } } - if (copyToPage == -1) { + if (convertToPage == -1) { return; - } else if (copyToPage == 0) { - copyPage(destPage, 2); + } else if (convertToPage == 2 && _renderMode == Common::kRenderCGA) { + convertPage(destPage, 4, cgaMapping); + copyRegion(0, 0, 0, 0, 320, 200, 4, 2, Screen::CR_NO_P_CHECK); + } else if (convertToPage == 0) { + convertPage(destPage, 2, cgaMapping); copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); } else { - copyPage(destPage, copyToPage); + convertPage(destPage, convertToPage, cgaMapping); + } +} + +void Screen_EoB::convertPage(int srcPage, int dstPage, const uint8 *cgaMapping) { + uint8 *src = getPagePtr(srcPage); + uint8 *dst = getPagePtr(dstPage); + if (src == dst) + return; + + if (_renderMode == Common::kRenderCGA) { + generateCGADitheringTables(cgaMapping); + uint16 *d = (uint16*)dst; + uint8 tblSwitch = 0; + for (int height = SCREEN_H; height; height--) { + const uint16 *table = _cgaDitheringTables[(tblSwitch++) & 1]; + for (int width = SCREEN_W / 2; width; width--) { + *d++ = table[((src[0] & 0x0f) << 4) | (src[1] & 0x0f)]; + src += 2; + } + } + + if (dstPage == 0 || dstPage == 1) + _forceFullUpdate = true; + + } else if (_renderMode == Common::kRenderEGA) { + uint32 len = SCREEN_W * SCREEN_H; + if (_useHiResEGADithering) { + while (len--) { + uint8 col = _egaColorMap[*src++] & 0x0f; + *dst++ = col; + + /*for (int i = 4; i; i--) { + uint8 col = _egaColorMap[*src++]; + + }*/ + } + } else { + while (len--) + *dst++ = *src++ & 0x0f; + } + + if (dstPage == 0 || dstPage == 1) + _forceFullUpdate = true; + } else { + copyPage(srcPage, dstPage); + } +} + +void Screen_EoB::setScreenPalette(const Palette &pal) { + if (_renderMode == Common::kRenderEGA && _egaColorMap && pal.getNumColors() != 16) { + const uint8 *src = pal.getData(); + uint8 *dst = _egaColorMap; + + for (int i = 256; i; i--) { + uint8 r = *src++; + uint8 g = *src++; + uint8 b = *src++; + + uint8 col = 0; + uint16 min = 11907; + + for (int ii = 256; ii; ii--) { + const uint8 *palEntry = _egaMatchTable + (ii - 1) * 3; + if (*palEntry == 0xff) + continue; + + int e_r = palEntry[0]; + e_r -= r; + int e_g = palEntry[1]; + e_g -= g; + int e_b = palEntry[2]; + e_b -= b; + + int s = (e_r * e_r) + (e_g * e_g) + (e_b * e_b); + + if (s < min) { + min = s; + col = ii - 1; + } + } + *dst++ = col; + } + + memset(_egaPixelValueTable, 0, 256); + for (int i = 0; i < 256; i++) + _egaPixelValueTable[_egaColorMap[i]] = i; + + } else if (_renderMode == Common::kRenderEGA) { + _screenPalette->copy(pal); + _system->getPaletteManager()->setPalette(_screenPalette->getData(), 0, _screenPalette->getNumColors()); + + } else if (_renderMode != Common::kRenderCGA) { + Screen::setScreenPalette(pal); } } -uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4bitEncoding) { +uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4bitEncoding, const uint8 *cgaMapping) { uint8 *shp = 0; uint16 shapesize = 0; - uint8 *srcPage = getPagePtr(_curPage) + y * 320 + (x << 3); + uint8 *srcPage = getPagePtr(_curPage | 1) + y * 320 + (x << 3); uint8 *src = srcPage; if (no4bitEncoding) { @@ -206,7 +341,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4b *dst++ = (w & 0xff); *dst++ = (h & 0xff); - srcPage = getPagePtr(_curPage) + y * 320 + (x << 3); + srcPage = getPagePtr(_curPage | 1) + y * 320 + (x << 3); src = srcPage; h1 = h; @@ -255,7 +390,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4b uint8 *pal = dst; dst += 0x10; - srcPage = getPagePtr(_curPage) + y * 320 + (x << 3); + srcPage = getPagePtr(_curPage | 1) + y * 320 + (x << 3); src = srcPage; nib = col = 0; @@ -1096,12 +1231,74 @@ bool Screen_EoB::posWithinRect(int posX, int posY, int x1, int y1, int x2, int y return true; } -OldDOSFont::OldDOSFont() { +void Screen_EoB::generateCGADitheringTables(const uint8 *mappingData) { + for (int i = 0; i < 256; i++) { + WRITE_BE_UINT16(&_cgaDitheringTables[0][i], (mappingData[i >> 4] << 8) | mappingData[(i & 0x0f) + 16]); + WRITE_BE_UINT16(&_cgaDitheringTables[1][i], (mappingData[(i >> 4) + 16] << 8) | mappingData[i & 0x0f]); + } +} + +const uint8 Screen_EoB::_egaMatchTable[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x00, 0x1E, 0x1E, 0x1E, 0x00, 0x00, 0x1E, + 0x00, 0x1E, 0x1E, 0x0F, 0x00, 0x1E, 0x1E, 0x1E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x2D, 0x0F, 0x2D, + 0x0F, 0x0F, 0x2D, 0x2D, 0x2D, 0x0F, 0x0F, 0x2D, 0x0F, 0x2D, 0x2D, 0x2D, 0x0F, 0x2D, 0x2D, 0x2D, + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x2A, 0x00, 0x1E, 0x1E, 0x00, 0x1E, 0x2A, 0x1E, 0x00, 0x1E, 0x1E, + 0x00, 0x2A, 0x1E, 0x0F, 0x1E, 0x1E, 0x1E, 0x2A, 0x0F, 0x0F, 0x21, 0x0F, 0x0F, 0x36, 0x0F, 0x2D, + 0x21, 0x0F, 0x2D, 0x36, 0x2D, 0x0F, 0x21, 0x2D, 0x0F, 0x36, 0x2D, 0x2D, 0x21, 0x2D, 0x2D, 0x36, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x2A, 0x00, 0x00, 0x2A, 0x1E, 0x1E, 0x1E, 0x00, 0x1E, + 0x1E, 0x1E, 0x1E, 0x21, 0x00, 0x1E, 0x2A, 0x1E, 0x0F, 0x21, 0x0F, 0x0F, 0x21, 0x2D, 0x0F, 0x36, + 0x0F, 0x0F, 0x36, 0x2D, 0x2D, 0x21, 0x0F, 0x2D, 0x21, 0x2D, 0x2D, 0x36, 0x0F, 0x2D, 0x36, 0x2D, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x2A, 0x2A, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x2A, 0x1E, 0x21, 0x1E, 0x1E, 0x2A, 0x2A, 0x0F, 0x21, 0x21, 0x0F, 0x21, 0x36, 0x0F, 0x36, + 0x21, 0x0F, 0x36, 0x36, 0x2D, 0x21, 0x21, 0x2D, 0x21, 0x36, 0x2D, 0x36, 0x21, 0x2D, 0x36, 0x36, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2A, 0x00, 0x00, 0x2A, + 0x00, 0x1E, 0x2A, 0x0F, 0x00, 0x2A, 0x1E, 0x1E, 0x21, 0x0F, 0x0F, 0x21, 0x0F, 0x2D, 0x21, 0x2D, + 0x0F, 0x21, 0x2D, 0x2D, 0x36, 0x0F, 0x0F, 0x36, 0x0F, 0x2D, 0x36, 0x2D, 0x0F, 0x36, 0x2D, 0x2D, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2A, + 0x00, 0x2A, 0x2A, 0x0F, 0x1E, 0x2A, 0x1E, 0x2A, 0x21, 0x0F, 0x21, 0x21, 0x0F, 0x36, 0x21, 0x2D, + 0x21, 0x21, 0x2D, 0x36, 0x36, 0x0F, 0x21, 0x36, 0x0F, 0x36, 0x36, 0x2D, 0x21, 0x36, 0x2D, 0x36, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x2A, 0x15, 0x00, 0x2A, 0x21, 0x1E, 0x21, 0x15, 0x0F, 0x21, 0x15, 0x2D, 0x21, 0x2F, + 0x0F, 0x21, 0x2F, 0x2D, 0x36, 0x15, 0x0F, 0x36, 0x15, 0x2D, 0x36, 0x2F, 0x0F, 0x36, 0x2F, 0x2D, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2A, 0x2A, 0x2A, 0x21, 0x21, 0x21, 0x21, 0x21, 0x36, 0x21, 0x36, + 0x21, 0x21, 0x36, 0x36, 0x36, 0x21, 0x21, 0x36, 0x21, 0x36, 0x36, 0x36, 0x21, 0x36, 0x36, 0x36, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x15, 0x15, 0x15, 0x15, 0x2F, 0x15, 0x2F, + 0x15, 0x15, 0x2F, 0x2F, 0x2F, 0x15, 0x15, 0x2F, 0x15, 0x2F, 0x2F, 0x2F, 0x15, 0x2F, 0x2F, 0x2F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x15, 0x3F, 0x15, 0x2F, + 0x2F, 0x15, 0x2F, 0x3F, 0x2F, 0x15, 0x2F, 0x2F, 0x15, 0x3F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x3F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x3F, + 0x15, 0x15, 0x3F, 0x2F, 0x2F, 0x2F, 0x15, 0x2F, 0x2F, 0x2F, 0x2F, 0x3F, 0x15, 0x2F, 0x3F, 0x2F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x15, 0x3F, 0x3F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x3F, 0x2F, 0x3F, 0x2F, 0x2F, 0x3F, 0x3F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x15, 0x15, 0x3F, 0x15, 0x2F, 0x3F, 0x2F, 0x15, 0x3F, 0x2F, 0x2F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x15, 0x3F, 0x3F, 0x2F, 0x2F, 0x3F, 0x2F, 0x3F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, 0x15, 0x3F, 0x3F, 0x2F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F +}; + +OldDOSFont::OldDOSFont(Common::RenderMode mode, const uint16 *cgaDitheringTable) : _renderMode(mode), _cgaDitheringTable(cgaDitheringTable) { _data = 0; _width = _height = _numGlyphs = 0; _bitmapOffsets = 0; } +OldDOSFont::~OldDOSFont() { + unload(); +} + bool OldDOSFont::load(Common::SeekableReadStream &file) { unload(); @@ -1192,36 +1389,87 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { uint8 color1 = _colorMap[1]; uint8 color2 = _colorMap[0]; + static const uint16 cgaColorMask[] = { 0, 0x5555, 0xAAAA, 0xFFFF }; + uint16 cgaMask1 = cgaColorMask[color1 & 3]; + uint16 cgaMask2 = cgaColorMask[color2 & 3]; + int cH = _height; while (cH--) { int cW = w; + uint8 last = 0; const uint8 *mtbl = _width == 8 ? renderMaskTable8 : renderMaskTable6; - for (bool runWidthLoop = true; runWidthLoop;) { + if (_renderMode == Common::kRenderCGA) { uint8 s = *src++; uint8 m = *mtbl++; - for (uint8 i = 0x80; i; i >>= 1) { - if (!(m & i)) { - runWidthLoop = false; - break; - } + uint8 in = s | last; + uint16 cmp1 = 0; + uint16 cmp2 = 0; + + if (color1) { + in &= m; + cmp1 = _cgaDitheringTable[in]; + } - if (s & i) { - if (color1) - *dst = color1; - } else if (color2) { - *dst = color2; - } - dst++; + if (color2) { + in = ~in & m; + cmp2 = _cgaDitheringTable[in]; } - if (cW) - cW--; - else - runWidthLoop = false; - } + uint16 cDst = 0; + uint8 sh = 14; + for (int i = 0; i < _width; i++) { + cDst |= ((dst[i] & 3) << sh); + sh -= 2; + } + uint16 out = (~(cmp1 | cmp2) & cDst) | (cmp1 & cgaMask1) | (cmp2 & cgaMask2); + + sh = 14; + for (int i = 0; i < _width; i++) { + *dst++ = (out >> sh) & 3; + sh -= 2; + } + + last = s; + } else { + for (bool runWidthLoop = true; runWidthLoop;) { + uint8 s = *src++; + uint8 m = *mtbl++; + + for (uint8 i = 0x80; i; i >>= 1) { + if (!(m & i)) { + runWidthLoop = false; + break; + } + + if (_renderMode == Common::kRenderCGA) { + uint8 in = s | last; + if (s & i) { + if (color1) + *dst = color1; + } else if (color2) { + *dst = color2; + } + last = s; + } else { + if (s & i) { + if (color1) + *dst = color1; + } else if (color2) { + *dst = color2; + } + } + dst++; + } + + if (cW) + cW--; + else + runWidthLoop = false; + } + } dst += pitch; } } diff --git a/engines/kyra/screen_eob.h b/engines/kyra/screen_eob.h index 7040177266..1b55806b8b 100644 --- a/engines/kyra/screen_eob.h +++ b/engines/kyra/screen_eob.h @@ -45,10 +45,14 @@ public: void loadFileDataToPage(Common::SeekableReadStream *s, int pageNum, uint32 size); void printShadedText(const char *string, int x, int y, int col1, int col2); - void loadEoBBitmap(const char *file, const uint8 *ditheringData, int tempPage, int destPage, int copyToPage); + void loadEoBBitmap(const char *file, const uint8 *cgaMapping, int tempPage, int destPage, int convertToPage); void loadShapeSetBitmap(const char *file, int tempPage, int destPage); - uint8 *encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4bitEncoding = false); + void convertPage(int srcPage, int dstPage, const uint8 *cgaMapping); + + void setScreenPalette(const Palette &pal); + + uint8 *encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4bitEncoding = false, const uint8 *cgaMapping = 0); void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd = -1, int flags = 0, ...); const uint8 *scaleShape(const uint8 *shapeData, int blockDistance); const uint8 *scaleShapeStep(const uint8 *shp); @@ -77,6 +81,8 @@ private: void scaleShapeProcessLine(uint8 *&dst, const uint8 *&src); bool posWithinRect(int posX, int posY, int x1, int y1, int x2, int y2); + void generateCGADitheringTables(const uint8 *mappingData); + int _dsDiv, _dsRem, _dsScaleTmp; int16 _gfxX, _gfxY; uint8 _gfxCol; @@ -90,6 +96,14 @@ private: uint8 *_dsTempPage; + uint16 *_cgaDitheringTables[2]; + const uint8 *_cgaMappingDefault; + + uint8 *_egaColorMap; + uint8 *_egaPixelValueTable; + bool _useHiResEGADithering; + + static const uint8 _egaMatchTable[]; static const ScreenDim _screenDimTable[]; static const int _screenDimTableCount; }; diff --git a/engines/kyra/sequences_darkmoon.cpp b/engines/kyra/sequences_darkmoon.cpp index f0d4a01486..d4f5c847fd 100644 --- a/engines/kyra/sequences_darkmoon.cpp +++ b/engines/kyra/sequences_darkmoon.cpp @@ -41,11 +41,22 @@ public: kFinale }; - DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine *vm, Screen_EoB *screen, Mode mode, const char *const *strings, const char *const *cpsFiles, const char *const *palFiles, const EoBShapeDef **shapeDefList, const EoBSequenceStep **seqList); + struct Config { + Config(Mode m, const char *const *str, const char *const *cps, const char *const *pal, const DarkMoonShapeDef **shp, const DarkMoonAnimCommand **anim, bool paletteFading) : mode(m), strings(str), cpsFiles(cps), palFiles(pal), shapeDefs(shp), animData(anim), palFading(paletteFading) {} + Mode mode; + const char *const *strings; + const char *const *cpsFiles; + const char *const *palFiles; + const DarkMoonShapeDef **shapeDefs; + const DarkMoonAnimCommand **animData; + bool palFading; + }; + + DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine *vm, Screen_EoB *screen, const Config *config); ~DarkmoonSequenceHelper(); void loadScene(int index, int pageNum); - void runSequence(int index, int del = -1); + void animCommand(int index, int del = -1); void printText(int index, int color); void fadeText(); @@ -68,13 +79,7 @@ private: OSystem *_system; DarkMoonEngine *_vm; Screen_EoB *_screen; - Mode _mode; - - const char *const *_strings; - const char *const *_cpsFiles; - const char *const *_palFiles; - const EoBShapeDef **_shapeDefs; - const EoBSequenceStep **_seqData; + const Config *_config; Palette *_palettes[12]; @@ -103,10 +108,14 @@ int DarkMoonEngine::mainMenu() { _screen->loadFileDataToPage(s, 3, 64000); delete s; } else { - _screen->loadBitmap("MENU.CPS", 3, 2, &_screen->getPalette(0)); + _screen->loadBitmap("MENU.CPS", 3, 3, &_screen->getPalette(0)); } + if (_configRenderMode == Common::kRenderEGA) + _screen->loadPalette("MENU.EGA", _screen->getPalette(0)); + _screen->setScreenPalette(_screen->getPalette(0)); + _screen->convertPage(3, 2, 0); of = _screen->setFont(Screen::FID_6_FNT); op = _screen->setCurPage(2); @@ -167,7 +176,8 @@ int DarkMoonEngine::mainMenuLoop() { } void DarkMoonEngine::seq_playIntro() { - DarkmoonSequenceHelper sq(_system, this, _screen, DarkmoonSequenceHelper::kIntro, _introStrings, _cpsFilesIntro, _palFilesIntro, _shapesIntro, _seqIntro); + DarkmoonSequenceHelper::Config config(DarkmoonSequenceHelper::kIntro, _introStrings, _cpsFilesIntro, _configRenderMode == Common::kRenderEGA ? _palFilesIntroEGA : _palFilesIntroVGA, _shapesIntro, _animIntro, false); + DarkmoonSequenceHelper sq(_system, this, _screen, &config); _screen->setCurPage(0); _screen->clearCurPage(); @@ -192,24 +202,24 @@ void DarkMoonEngine::seq_playIntro() { removeInputTop(); sq.delay(18); - sq.runSequence(3, 18); - sq.runSequence(6, 18); - sq.runSequence(0); + sq.animCommand(3, 18); + sq.animCommand(6, 18); + sq.animCommand(0); sq.waitForSongNotifier(1); - sq.runSequence(11); - sq.runSequence(7, 6); - sq.runSequence(2, 6); + sq.animCommand(_configRenderMode == Common::kRenderEGA ? 12 : 11); + sq.animCommand(7, 6); + sq.animCommand(2, 6); sq.waitForSongNotifier(2); - sq.runSequence(38); - sq.runSequence(3); - sq.runSequence(8); - sq.runSequence(1, 10); - sq.runSequence(0, 6); - sq.runSequence(2); + sq.animCommand(_configRenderMode == Common::kRenderEGA ? 39 : 38); + sq.animCommand(3); + sq.animCommand(8); + sq.animCommand(1, 10); + sq.animCommand(0, 6); + sq.animCommand(2); sq.waitForSongNotifier(3); @@ -218,22 +228,22 @@ void DarkMoonEngine::seq_playIntro() { _screen->setClearScreenDim(17); _screen->setCurPage(0); - sq.runSequence(40); - sq.runSequence(7, 18); + sq.animCommand(_configRenderMode == Common::kRenderEGA ? 41 : 40); + sq.animCommand(7, 18); sq.printText(0, 16); // You were settling... - sq.runSequence(7, 90); + sq.animCommand(7, 90); sq.fadeText(); sq.printText(1, 16); // Then a note was slipped to you - sq.runSequence(8); - sq.runSequence(2, 72); + sq.animCommand(8); + sq.animCommand(2, 72); sq.fadeText(); sq.printText(2, 16); // It was from your friend Khelben Blackstaff... - sq.runSequence(2); - sq.runSequence(6, 36); - sq.runSequence(3); + sq.animCommand(2); + sq.animCommand(6, 36); + sq.animCommand(3); sq.fadeText(); sq.printText(3, 16); // The message was urgent. @@ -243,19 +253,33 @@ void DarkMoonEngine::seq_playIntro() { // intro scroll if (!skipFlag() && !shouldQuit()) { - for (int i = 0; i < 280; i += 3) { - uint32 endtime = _system->getMillis() + _tickLength; - _screen->copyRegion(11, 8, 8, 8, 301, 128, 0, 0, Screen::CR_NO_P_CHECK); - _screen->copyRegion(i, 0, 309, 8, 3, 128, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); - if (i == 96) - sq.runSequence(42); - delayUntil(endtime); + if (_configRenderMode == Common::kRenderEGA) { + for (int i = 0; i < 35; i++) { + uint32 endtime = _system->getMillis() + 2 * _tickLength; + _screen->copyRegion(16, 8, 8, 8, 296, 128, 0, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(i << 3, 0, 304, 8, 8, 128, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + if (i == 12) + sq.animCommand(42); + else if (i == 25) + snd_playSoundEffect(11); + delayUntil(endtime); + } + } else { + for (int i = 0; i < 280; i += 3) { + uint32 endtime = _system->getMillis() + _tickLength; + _screen->copyRegion(11, 8, 8, 8, 301, 128, 0, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(i, 0, 309, 8, 3, 128, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + if (i == 96) + sq.animCommand(42); + delayUntil(endtime); + } } } _screen->copyRegion(8, 8, 0, 0, 304, 128, 0, 2, Screen::CR_NO_P_CHECK); - sq.runSequence(4); + sq.animCommand(4); sq.fadeText(); sq.delay(10); @@ -268,22 +292,22 @@ void DarkMoonEngine::seq_playIntro() { sq.loadScene(3, 2); sq.delay(54); - sq.runSequence(13); + sq.animCommand(13); _screen->copyRegion(104, 16, 96, 8, 120, 100, 0, 2, Screen::CR_NO_P_CHECK); sq.fadeText(); sq.printText(5, 15); // Welcome, please come in - sq.runSequence(10); - sq.runSequence(10); - sq.runSequence(9); - sq.runSequence(9); + sq.animCommand(10); + sq.animCommand(10); + sq.animCommand(9); + sq.animCommand(9); sq.fadeText(); sq.printText(6, 15); // Khelben awaits you in his study for (int i = 0; i < 3; i++) - sq.runSequence(10); - sq.runSequence(9); - sq.runSequence(14); + sq.animCommand(10); + sq.animCommand(9); + sq.animCommand(14); sq.loadScene(5, 2); sq.waitForSongNotifier(5); @@ -293,45 +317,50 @@ void DarkMoonEngine::seq_playIntro() { _screen->updateScreen(); for (int i = 0; i < 6; i++) - sq.runSequence(15); + sq.animCommand(15); + + if (_configRenderMode == Common::kRenderEGA && !skipFlag() && !shouldQuit()) { + _screen->loadPalette("INTRO.EGA", _screen->getPalette(0)); + _screen->setScreenPalette(_screen->getPalette(0)); + } sq.loadScene(6, 2); sq.loadScene(7, 2); _screen->clearCurPage(); sq.update(2); - sq.runSequence(16); + sq.animCommand(16); sq.printText(7, 15); // Thank you for coming so quickly - sq.runSequence(16); - sq.runSequence(17); + sq.animCommand(16); + sq.animCommand(17); for (int i = 0; i < 3; i++) - sq.runSequence(16); + sq.animCommand(16); sq.fadeText(); - sq.runSequence(16); + sq.animCommand(16); sq.loadScene(8, 2); sq.update(2); - sq.runSequence(32); + sq.animCommand(32); sq.printText(8, 15); // I am troubled my friend - sq.runSequence(33); - sq.runSequence(33); + sq.animCommand(33); + sq.animCommand(33); for (int i = 0; i < 4; i++) - sq.runSequence(32); + sq.animCommand(32); sq.fadeText(); sq.printText(9, 15); // Ancient evil stirs in the Temple Darkmoon - sq.runSequence(33); - sq.runSequence(43); - sq.runSequence(33); + sq.animCommand(33); + sq.animCommand(43); + sq.animCommand(33); for (int i = 0; i < 3; i++) - sq.runSequence(32); + sq.animCommand(32); sq.fadeText(); sq.printText(10, 15); // I fear for the safety of our city for (int i = 0; i < 4; i++) - sq.runSequence(33); - sq.runSequence(32); - sq.runSequence(32); + sq.animCommand(33); + sq.animCommand(32); + sq.animCommand(32); sq.loadScene(9, 2); sq.fadeText(); @@ -339,67 +368,67 @@ void DarkMoonEngine::seq_playIntro() { sq.waitForSongNotifier(6); sq.update(2); - sq.runSequence(34); + sq.animCommand(34); sq.printText(11, 15); // I need your help for (int i = 0; i < 3; i++) - sq.runSequence(34); - sq.runSequence(35); + sq.animCommand(34); + sq.animCommand(35); for (int i = 0; i < 4; i++) - sq.runSequence(34); + sq.animCommand(34); sq.fadeText(); sq.loadScene(12, 2); sq.update(2); sq.loadScene(6, 2); - sq.runSequence(18); + sq.animCommand(18); sq.printText(12, 15); // Three nights ago I sent forth a scout - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(22); - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(18); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(22); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(18); sq.fadeText(); sq.printText(13, 15); // She has not yet returned - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(23); - sq.runSequence(24); - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(17); - sq.runSequence(18); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(23); + sq.animCommand(24); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(17); + sq.animCommand(18); sq.fadeText(); sq.printText(14, 15); // I fear for her safety - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(20); - sq.runSequence(18); - sq.runSequence(25); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(20); + sq.animCommand(18); + sq.animCommand(25); + sq.animCommand(18); + sq.animCommand(18); sq.fadeText(); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(18); + sq.animCommand(18); sq.printText(15, 15); // Take this coin - sq.runSequence(28); - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(28); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(18); + sq.animCommand(18); sq.fadeText(); sq.loadScene(10, 2); _screen->clearCurPage(); _screen->updateScreen(); - sq.runSequence(37, 18); - sq.runSequence(36, 36); + sq.animCommand(37, 18); + sq.animCommand(36, 36); sq.loadScene(12, 2); _screen->clearCurPage(); @@ -407,44 +436,44 @@ void DarkMoonEngine::seq_playIntro() { sq.loadScene(11, 2); sq.printText(16, 15); // I will use it to contact you - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(20); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(20); + sq.animCommand(18); + sq.animCommand(18); sq.fadeText(); sq.printText(17, 15); // You must act quickly - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(18); + sq.animCommand(18); sq.fadeText(); - sq.runSequence(18); + sq.animCommand(18); sq.printText(18, 15); // I will teleport you near Darkmoon - sq.runSequence(20); - sq.runSequence(27); - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(18); - sq.runSequence(18); + sq.animCommand(20); + sq.animCommand(27); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(18); + sq.animCommand(18); sq.fadeText(); - sq.runSequence(18); + sq.animCommand(18); sq.printText(19, 15); // May luck be with you my friend - sq.runSequence(19); - sq.runSequence(19); - sq.runSequence(20); - sq.runSequence(18); + sq.animCommand(19); + sq.animCommand(19); + sq.animCommand(20); + sq.animCommand(18); sq.fadeText(); - sq.runSequence(29); + sq.animCommand(29); sq.waitForSongNotifier(7); - sq.runSequence(30); - sq.runSequence(31); + sq.animCommand(30); + sq.animCommand(31); sq.waitForSongNotifier(8, true); @@ -454,17 +483,21 @@ void DarkMoonEngine::seq_playIntro() { _screen->setScreenDim(17); _screen->clearCurDim(); snd_playSoundEffect(14); - sq.fadePalette(10, 1); + + if (_configRenderMode != Common::kRenderEGA) + sq.fadePalette(10, 1); _screen->setClearScreenDim(18); sq.delay(6); - sq.fadePalette(9, 1); + if (_configRenderMode != Common::kRenderEGA) + sq.fadePalette(9, 1); _screen->clearCurPage(); } sq.fadePalette(9, 10); } void DarkMoonEngine::seq_playFinale() { - DarkmoonSequenceHelper sq(_system, this, _screen, DarkmoonSequenceHelper::kFinale, _finaleStrings, _cpsFilesFinale, _palFilesFinale, _shapesFinale, _seqFinale); + DarkmoonSequenceHelper::Config config(DarkmoonSequenceHelper::kFinale, _finaleStrings, _cpsFilesFinale, _configRenderMode == Common::kRenderEGA ? _palFilesFinaleEGA : _palFilesFinaleVGA, _shapesFinale, _animFinale, true); + DarkmoonSequenceHelper sq(_system, this, _screen, &config); _screen->setCurPage(0); _screen->setFont(Screen::FID_8_FNT); @@ -485,76 +518,76 @@ void DarkMoonEngine::seq_playFinale() { sq.loadScene(1, 2); - sq.runSequence(0); - sq.runSequence(0); + sq.animCommand(0); + sq.animCommand(0); for (int i = 0; i < 3; i++) - sq.runSequence(2); - sq.runSequence(1); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(2); + sq.animCommand(1); + sq.animCommand(2); + sq.animCommand(2); sq.printText(0, 10); // Finally, Dran has been defeated for (int i = 0; i < 7; i++) - sq.runSequence(2); + sq.animCommand(2); sq.fadeText(); - sq.runSequence(2); + sq.animCommand(2); sq.waitForSongNotifier(1); sq.printText(1, 10); // Suddenly, your friend Khelben appears - sq.runSequence(4); + sq.animCommand(4); for (int i = 0; i < 3; i++) - sq.runSequence(2); + sq.animCommand(2); sq.fadeText(); sq.printText(2, 15); // Greetings, my victorious friends for (int i = 0; i < 4; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); - sq.runSequence(6); + sq.animCommand(6); sq.printText(3, 15); // You have defeated Dran for (int i = 0; i < 5; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.printText(4, 15); // I did not know Dran was a dragon for (int i = 0; i < 4; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.printText(5, 15); // He must have been over 300 years old for (int i = 0; i < 4; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.printText(6, 15); // His power is gone for (int i = 0; i < 3; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.printText(7, 15); // But Darkmoon is still a source of great evil for (int i = 0; i < 4; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.printText(8, 15); // And many of his minions remain for (int i = 0; i < 4; i++) - sq.runSequence(5); - sq.runSequence(2); - sq.runSequence(2); + sq.animCommand(5); + sq.animCommand(2); + sq.animCommand(2); sq.fadeText(); sq.loadScene(2, 2); @@ -563,29 +596,32 @@ void DarkMoonEngine::seq_playFinale() { _screen->copyRegion(8, 8, 0, 0, 304, 128, 0, 2, Screen::CR_NO_P_CHECK); sq.printText(9, 15); // Now we must leave this place - sq.runSequence(7); - sq.runSequence(8); - sq.runSequence(7); - sq.runSequence(7, 36); + sq.animCommand(7); + sq.animCommand(8); + sq.animCommand(7); + sq.animCommand(7, 36); sq.fadeText(); sq.printText(10, 15); // So my forces can destroy it.. for (int i = 0; i < 3; i++) - sq.runSequence(7); - sq.runSequence(8); - sq.runSequence(7); - sq.runSequence(7, 36); - sq.runSequence(8, 18); + sq.animCommand(7); + sq.animCommand(8); + sq.animCommand(7); + sq.animCommand(7, 36); + sq.animCommand(8, 18); sq.fadeText(); sq.printText(11, 15); // Follow me - sq.runSequence(7, 18); - sq.runSequence(9, 18); - sq.runSequence(8, 18); + sq.animCommand(7, 18); + sq.animCommand(9, 18); + sq.animCommand(8, 18); sq.fadeText(); sq.loadScene(7, 2); - sq.copyPalette(3, 0); + + if (_configRenderMode != Common::kRenderEGA) + sq.copyPalette(3, 0); + sq.loadScene(4, 2); sq.waitForSongNotifier(2); @@ -607,23 +643,23 @@ void DarkMoonEngine::seq_playFinale() { snd_playSoundEffect(7); sq.delay(8); - sq.runSequence(10); - sq.runSequence(13); + sq.animCommand(10); + sq.animCommand(13); sq.initDelayedPaletteFade(4, 1); - sq.runSequence(14); - sq.runSequence(13); - sq.runSequence(14); - sq.runSequence(14); - sq.runSequence(13); + sq.animCommand(14); + sq.animCommand(13); + sq.animCommand(14); + sq.animCommand(14); + sq.animCommand(13); sq.initDelayedPaletteFade(2, 1); - sq.runSequence(15); - sq.runSequence(14); - sq.runSequence(13); - sq.runSequence(15); - sq.runSequence(15); - sq.runSequence(11); + sq.animCommand(15); + sq.animCommand(14); + sq.animCommand(13); + sq.animCommand(15); + sq.animCommand(15); + sq.animCommand(11); sq.printText(13, 10); // The temple's evil is very strong sq.delay(72); @@ -639,22 +675,22 @@ void DarkMoonEngine::seq_playFinale() { snd_playSoundEffect(7); sq.delay(8); - sq.runSequence(10); + sq.animCommand(10); sq.initDelayedPaletteFade(5, 1); - sq.runSequence(13); - sq.runSequence(14); - sq.runSequence(13); - sq.runSequence(14); - sq.runSequence(13); - sq.runSequence(13); - sq.runSequence(14); - sq.runSequence(14); - sq.runSequence(13); - sq.runSequence(12); + sq.animCommand(13); + sq.animCommand(14); + sq.animCommand(13); + sq.animCommand(14); + sq.animCommand(13); + sq.animCommand(13); + sq.animCommand(14); + sq.animCommand(14); + sq.animCommand(13); + sq.animCommand(12); for (int i = 0; i < 4; i++) - sq.runSequence(16); - sq.runSequence(17); - sq.runSequence(18); + sq.animCommand(16); + sq.animCommand(17); + sq.animCommand(18); sq.printText(15, 10); // The temple ceases to exist sq.initDelayedPaletteFade(6, 1); @@ -672,40 +708,43 @@ void DarkMoonEngine::seq_playFinale() { if (!skipFlag() && !shouldQuit()) snd_playSoundEffect(6); - if (!skipFlag() && !shouldQuit()) + if (!skipFlag() && !shouldQuit()) { + if (_configRenderMode != Common::kRenderEGA) + sq.setPaletteWithoutTextColor(0); _screen->crossFadeRegion(0, 0, 8, 8, 304, 128, 2, 0); + } sq.delay(18); sq.printText(16, 15); // My friends, our work is done - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(19, 36); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(19, 36); if (!skipFlag() && !shouldQuit()) snd_playSoundEffect(12); sq.fadeText(); sq.printText(17, 15); // Thank you - sq.runSequence(19); - sq.runSequence(20, 36); + sq.animCommand(19); + sq.animCommand(20, 36); sq.fadeText(); sq.printText(18, 15); // You have earned my deepest respect if (!skipFlag() && !shouldQuit()) snd_playSoundEffect(11); - sq.runSequence(20); - sq.runSequence(19); - sq.runSequence(19); + sq.animCommand(20); + sq.animCommand(19); + sq.animCommand(19); if (!skipFlag() && !shouldQuit()) snd_playSoundEffect(11); sq.delay(36); sq.fadeText(); sq.printText(19, 15); // We will remember you always - sq.runSequence(19); - sq.runSequence(19, 18); + sq.animCommand(19); + sq.animCommand(19, 18); if (!skipFlag() && !shouldQuit()) snd_playSoundEffect(11); - sq.runSequence(20, 18); + sq.animCommand(20, 18); sq.fadeText(); sq.delay(28); @@ -718,6 +757,8 @@ void DarkMoonEngine::seq_playFinale() { _screen->copyRegion(0, 0, 8, 8, 304, 128, 2, 0, Screen::CR_NO_P_CHECK); } else { snd_playSoundEffect(6); + if (_configRenderMode != Common::kRenderEGA) + sq.setPaletteWithoutTextColor(0); _screen->crossFadeRegion(0, 0, 8, 8, 304, 128, 2, 0); } @@ -756,8 +797,10 @@ void DarkMoonEngine::seq_playFinale() { resetSkipFlag(true); - sq.setPalette(11); - sq.fadePalette(9, 10); + if (_configRenderMode != Common::kRenderEGA) { + sq.setPalette(11); + sq.fadePalette(9, 10); + } _screen->clearCurPage(); sq.loadScene(11, 2); @@ -912,15 +955,15 @@ void DarkMoonEngine::seq_playCredits(DarkmoonSequenceHelper *sq, const uint8 *da delete[] items[i].str; } -DarkmoonSequenceHelper::DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine *vm, Screen_EoB *screen, Mode mode, const char *const *strings, const char *const *cpsFiles, const char *const *palFiles, const EoBShapeDef **shapeDefList, const EoBSequenceStep **seqList) : - _system(system), _vm(vm), _screen(screen), _mode(mode), _strings(strings), _cpsFiles(cpsFiles), _palFiles(palFiles), _shapeDefs(shapeDefList), _seqData(seqList) { +DarkmoonSequenceHelper::DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine *vm, Screen_EoB *screen, const Config *config) : + _system(system), _vm(vm), _screen(screen), _config(config) { - for (int i = 0; _palFiles[i]; i++) { + for (int i = 0; _config->palFiles[i]; i++) { if (i < 4) _palettes[i] = &_screen->getPalette(i); else _palettes[i] = new Palette(256); - _screen->loadPalette(_palFiles[i], *_palettes[i]); + _screen->loadPalette(_config->palFiles[i], *_palettes[i]); } _palettes[9] = new Palette(256); @@ -946,7 +989,7 @@ DarkmoonSequenceHelper::DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine * } DarkmoonSequenceHelper::~DarkmoonSequenceHelper() { - for (int i = 4; _palFiles[i]; i++) + for (int i = 4; _config->palFiles[i]; i++) delete _palettes[i]; delete _palettes[9]; delete _palettes[10]; @@ -967,12 +1010,22 @@ DarkmoonSequenceHelper::~DarkmoonSequenceHelper() { void DarkmoonSequenceHelper::loadScene(int index, int pageNum) { char file[13]; - strcpy(file, _cpsFiles[index]); + strcpy(file, _config->cpsFiles[index]); Common::SeekableReadStream *s = _vm->resource()->createReadStream(file); - if (s && file[0] != 'X') { + uint32 chunkID = 0; + if (s) { + chunkID = s->readUint32LE(); + s->seek(0); + } + + if (s && chunkID == MKTAG('F', 'O', 'R', 'M')) { + // The original code also handles files with FORM chunks and ILBM and PBM sub chunks. This will probably be necessary for Amiga versions. + // The DOS versions do not need this, but still have the code for it. We error out for now. + error("DarkmoonSequenceHelper::loadScene(): CPS file loading failure in scene %d - unhandled FORM chunk encountered", index); + } else if (s && file[0] != 'X') { delete s; - _screen->loadBitmap(_cpsFiles[index], pageNum | 1, pageNum | 1, _palettes[0]); + _screen->loadBitmap(_config->cpsFiles[index], pageNum | 1, pageNum | 1, _palettes[0]); } else { if (!s) { file[0] = 'X'; @@ -982,7 +1035,7 @@ void DarkmoonSequenceHelper::loadScene(int index, int pageNum) { if (!s) error("DarkmoonSequenceHelper::loadScene(): CPS file loading failure in scene %d", index); - if (_mode == kFinale) + if (_config->mode == kFinale) s->read(_palettes[0]->getData(), 768); else s->seek(768); @@ -992,8 +1045,8 @@ void DarkmoonSequenceHelper::loadScene(int index, int pageNum) { int cp = _screen->setCurPage(pageNum); - if (_shapeDefs[index]) { - for (const EoBShapeDef *df = _shapeDefs[index]; df->w; df++) { + if (_config->shapeDefs[index]) { + for (const DarkMoonShapeDef *df = _config->shapeDefs[index]; df->w; df++) { uint16 shapeIndex = (df->index < 0) ? df->index * -1 : df->index; if (_shapes[shapeIndex]) delete[] _shapes[shapeIndex]; @@ -1002,20 +1055,24 @@ void DarkmoonSequenceHelper::loadScene(int index, int pageNum) { } _screen->setCurPage(cp); - _screen->copyPage(pageNum | 1, pageNum); + + if (_vm->_configRenderMode == Common::kRenderEGA) + setPalette(0); + + _screen->convertPage(pageNum | 1, pageNum, 0); if ((pageNum == 0 || pageNum == 1) && !_vm->skipFlag() && !_vm->shouldQuit()) _screen->updateScreen(); } -void DarkmoonSequenceHelper::runSequence(int index, int del) { +void DarkmoonSequenceHelper::animCommand(int index, int del) { if (_vm->skipFlag() || _vm->shouldQuit()) return; uint32 end = 0; - for (const EoBSequenceStep *s = _seqData[index]; s->command != 0xff && !_vm->skipFlag() && !_vm->shouldQuit(); s++) { - int palIndex = _mode == kFinale ? (s->pal + 1) : s->pal; + for (const DarkMoonAnimCommand *s = _config->animData[index]; s->command != 0xff && !_vm->skipFlag() && !_vm->shouldQuit(); s++) { + int palIndex = _config->mode == kFinale ? (s->pal + 1) : s->pal; int x = s->x1; int y = s->y1; int x2 = 0; @@ -1025,10 +1082,10 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) { switch (s->command) { case 0: // flash palette - if (s->pal) + if (_vm->_configRenderMode != Common::kRenderEGA && s->pal) setPaletteWithoutTextColor(palIndex); delay(s->delay); - if (_mode == kIntro && s->pal) + if (_vm->_configRenderMode != Common::kRenderEGA && _config->mode == kIntro && s->pal) setPaletteWithoutTextColor(0); break; @@ -1037,7 +1094,7 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) { shapeW = _shapes[s->obj][2]; shapeH = _shapes[s->obj][3]; - if (_mode == kFinale) { + if (_config->mode == kFinale) { _screen->setScreenDim(18); x -= (_screen->_curDim->sx << 3); y -= _screen->_curDim->sy; @@ -1047,17 +1104,17 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) { x2 = x; } - _screen->drawShape(0, _shapes[s->obj], x, y, _mode == kIntro ? 0 : 18); + _screen->drawShape(0, _shapes[s->obj], x, y, _config->mode == kIntro ? 0 : 18); - if (s->pal) + if (_vm->_configRenderMode != Common::kRenderEGA && s->pal) setPaletteWithoutTextColor(palIndex); else _screen->updateScreen(); delay(s->delay); - if (_mode == kIntro) { - if (s->pal) + if (_config->mode == kIntro) { + if (_vm->_configRenderMode != Common::kRenderEGA && s->pal) setPaletteWithoutTextColor(0); _screen->copyRegion(x - 8, y - 8, x, y, (shapeW + 1) << 3, shapeH, 2, 0, Screen::CR_NO_P_CHECK); } else { @@ -1071,50 +1128,59 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) { // draw shape _screen->drawShape(_screen->_curPage, _shapes[s->obj], x, y, 0); - if (s->pal) + if (_vm->_configRenderMode != Common::kRenderEGA && s->pal) setPaletteWithoutTextColor(palIndex); else if (!_screen->_curPage) _screen->updateScreen(); delay(s->delay); - if (_mode == kIntro && s->pal) + if (_vm->_configRenderMode != Common::kRenderEGA && _config->mode == kIntro && s->pal) setPaletteWithoutTextColor(0); break; case 3: case 4: // fade shape in or out or restore background - if (_mode == kFinale) + if (_config->mode == kFinale) break; - _screen->setShapeFadeMode(0, true); - _screen->setShapeFadeMode(1, true); + if (_vm->_configRenderMode == Common::kRenderEGA) { + if (palIndex) + _screen->drawShape(0, _shapes[s->obj], s->x1, y, 0); + else + _screen->copyRegion(s->x1 - 8, s->y1 - 8, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + delay(s->delay /** 7*/); + } else { + _screen->setShapeFadeMode(0, true); + _screen->setShapeFadeMode(1, true); - end = _system->getMillis() + s->delay * _vm->tickLength(); + end = _system->getMillis() + s->delay * _vm->tickLength(); - if (palIndex) { - _screen->setFadeTableIndex(palIndex - 1); + if (palIndex) { + _screen->setFadeTableIndex(palIndex - 1); - _screen->copyRegion(s->x1 - 8, s->y1 - 8, 0, 0, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 4, Screen::CR_NO_P_CHECK); - _screen->drawShape(4, _shapes[s->obj], s->x1 & 7, 0, 0); - _screen->copyRegion(0, 0, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 4, 0, Screen::CR_NO_P_CHECK); - } else { - _screen->copyRegion(s->x1 - 8, s->y1 - 8, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 0, Screen::CR_NO_P_CHECK); - } - _screen->updateScreen(); + _screen->copyRegion(s->x1 - 8, s->y1 - 8, 0, 0, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 4, Screen::CR_NO_P_CHECK); + _screen->drawShape(4, _shapes[s->obj], s->x1 & 7, 0, 0); + _screen->copyRegion(0, 0, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 4, 0, Screen::CR_NO_P_CHECK); + } else { + _screen->copyRegion(s->x1 - 8, s->y1 - 8, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 0, Screen::CR_NO_P_CHECK); + } + _screen->updateScreen(); - _vm->delayUntil(end); - _screen->setShapeFadeMode(0, false); - _screen->setShapeFadeMode(1, false); + _vm->delayUntil(end); + _screen->setShapeFadeMode(0, false); + _screen->setShapeFadeMode(1, false); + } break; case 5: // copy region - if (_mode == kFinale && s->pal) + if (_config->mode == kFinale && s->pal) setPaletteWithoutTextColor(palIndex); - _screen->copyRegion(s->x2 << 3, s->y2, s->x1, s->y1, s->w << 3, s->h, (s->obj && _mode == kFinale) ? 6 : 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(s->x2 << 3, s->y2, s->x1, s->y1, s->w << 3, s->h, (s->obj && _config->mode == kFinale) ? 6 : 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); delay(s->delay); break; @@ -1125,8 +1191,15 @@ void DarkmoonSequenceHelper::runSequence(int index, int del) { _vm->snd_playSoundEffect(s->obj); break; + case 7: + // restore background (only used in EGA mode) + delay(s->delay); + _screen->copyRegion(s->x1 - 8, s->y1 - 8, s->x1, s->y1, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + break; + default: - error("DarkmoonSequenceHelper::runSequence(): Unknown animation opcode encountered."); + error("DarkmoonSequenceHelper::animCommand(): Unknown animation opcode encountered."); break; } } @@ -1140,12 +1213,17 @@ void DarkmoonSequenceHelper::printText(int index, int color) { return; _screen->setClearScreenDim(17); - _palettes[0]->copy(*_palettes[0], color, 1, 255); - setPalette(0); + uint8 col1 = 15; + + if (_vm->_configRenderMode != Common::kRenderEGA) { + _palettes[0]->copy(*_palettes[0], color, 1, 255); + setPalette(0); + col1 = 255; + } - char *temp = new char[strlen(_strings[index]) + 1]; + char *temp = new char[strlen(_config->strings[index]) + 1]; char *str = temp; - strcpy(str, _strings[index]); + strcpy(str, _config->strings[index]); const ScreenDim *dm = _screen->_curDim; @@ -1156,7 +1234,7 @@ void DarkmoonSequenceHelper::printText(int index, int color) { *cr = 0; uint32 len = strlen(str); - _screen->printText(str, (dm->sx + ((dm->w - len) >> 1)) << 3, dm->sy + yOffs, 255, dm->unkA); + _screen->printText(str, (dm->sx + ((dm->w - len) >> 1)) << 3, dm->sy + yOffs, col1, dm->unkA); if (cr) { *cr = 13; @@ -1173,8 +1251,8 @@ void DarkmoonSequenceHelper::printText(int index, int color) { void DarkmoonSequenceHelper::fadeText() { if (_vm->skipFlag() || _vm->shouldQuit()) return; - - _screen->fadeTextColor(_palettes[0], 255, 8); + if (_vm->_configRenderMode != Common::kRenderEGA) + _screen->fadeTextColor(_palettes[0], 255, 8); _screen->clearCurDim(); } @@ -1183,11 +1261,13 @@ void DarkmoonSequenceHelper::update(int srcPage) { return; _screen->copyRegion(0, 0, 8, 8, 304, 128, srcPage, 0, Screen::CR_NO_P_CHECK); - setPaletteWithoutTextColor(0); + + if (_vm->_configRenderMode != Common::kRenderEGA) + setPaletteWithoutTextColor(0); } void DarkmoonSequenceHelper::setPaletteWithoutTextColor(int index) { - if (_vm->skipFlag() || _vm->shouldQuit()) + if (_vm->_configRenderMode == Common::kRenderEGA || _vm->skipFlag() || _vm->shouldQuit()) return; if (!memcmp(_palettes[11]->getData(), _palettes[index]->getData(), 765)) @@ -1198,6 +1278,7 @@ void DarkmoonSequenceHelper::setPaletteWithoutTextColor(int index) { setPalette(11); _screen->updateScreen(); + _system->delayMillis(10); } void DarkmoonSequenceHelper::setPalette(int index) { @@ -1207,8 +1288,12 @@ void DarkmoonSequenceHelper::setPalette(int index) { void DarkmoonSequenceHelper::fadePalette(int index, int del) { if (_vm->skipFlag() || _vm->shouldQuit()) return; - - _screen->fadePalette(*_palettes[index], del * _vm->tickLength()); + if (_vm->_configRenderMode == Common::kRenderEGA) { + setPalette(index); + _screen->updateScreen(); + } else { + _screen->fadePalette(*_palettes[index], del * _vm->tickLength()); + } } void DarkmoonSequenceHelper::copyPalette(int srcIndex, int destIndex) { @@ -1227,7 +1312,7 @@ bool DarkmoonSequenceHelper::processDelayedPaletteFade() { if (_vm->skipFlag() || _vm->shouldQuit()) return true; - if (!_fadePalRate || (_system->getMillis() <= _fadePalTimer)) + if (_vm->_configRenderMode == Common::kRenderEGA || !_fadePalRate || (_system->getMillis() <= _fadePalTimer)) return false; if (_screen->delayedFadePalStep(_palettes[_fadePalIndex], _palettes[0], _fadePalRate)) { @@ -1246,7 +1331,7 @@ void DarkmoonSequenceHelper::delay(uint32 ticks) { uint32 end = _system->getMillis() + ticks * _vm->_tickLength; - if (_mode == kFinale) { + if (_config->palFading) { do { if (processDelayedPaletteFade()) break; @@ -1263,11 +1348,11 @@ void DarkmoonSequenceHelper::waitForSongNotifier(int index, bool introUpdateAnim int seq = 0; while (_vm->sound()->checkTrigger() < index && !(_vm->skipFlag() || _vm->shouldQuit())) { if (introUpdateAnim) { - runSequence(30 | seq); + animCommand(30 | seq); seq ^= 1; } - if (_mode == kFinale) + if (_config->palFading) processDelayedPaletteFade(); _vm->updateInput(); diff --git a/engines/kyra/sequences_eob.cpp b/engines/kyra/sequences_eob.cpp index f18c67f659..195c44ea2a 100644 --- a/engines/kyra/sequences_eob.cpp +++ b/engines/kyra/sequences_eob.cpp @@ -110,7 +110,8 @@ void EoBIntroPlayer::start() { if (!_vm->shouldQuit() && !_vm->skipFlag()) { _vm->snd_playSong(2); - _screen->loadBitmap("TITLE-V.CMP", 5, 3, 0); + _screen->loadBitmap((_vm->_configRenderMode == Common::kRenderCGA || _vm->_configRenderMode == Common::kRenderEGA) ? "TITLE-E.CMP" : "TITLE-V.CMP", 3, 5, 0); + _screen->convertPage(5, 2, _vm->_cgaMappingDefault); _screen->crossFadeRegion(0, 0, 0, 0, 320, 200, 2, 0); _vm->delay(120 * _vm->_tickLength); } @@ -121,7 +122,8 @@ void EoBIntroPlayer::start() { _screen->loadFileDataToPage(s, 6, s->size() - 768); delete s; } else { - _screen->loadBitmap("TEXT.CMP", 3, 6, 0); + _screen->loadBitmap("TEXT.CMP", 3, 5, 0); + _screen->convertPage(5, 6, _vm->_cgaMappingAlt); } tower(); @@ -139,8 +141,9 @@ void EoBIntroPlayer::start() { void EoBIntroPlayer::openingCredits() { loadAndSetPalette(_filesOpening[5]); + _screen->loadBitmap(_filesOpening[4], 5, 3, 0); - _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->convertPage(3, 0, _vm->_cgaMappingAlt); _screen->updateScreen(); _vm->snd_playSong(1); @@ -149,7 +152,8 @@ void EoBIntroPlayer::openingCredits() { for (int i = 0; i < 4 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { _screen->loadBitmap(_filesOpening[i], 5, 3, 0); uint32 nextFrameTimer = _vm->_system->getMillis() + _openingFrmDelay[i + 1] * _vm->_tickLength; - _screen->crossFadeRegion(0, 50, 0, 50, 320, 102, 2, 0); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); + _screen->crossFadeRegion(0, 50, 0, 50, 320, 102, 4, 0); _vm->delayUntil(nextFrameTimer); } } @@ -160,8 +164,8 @@ void EoBIntroPlayer::tower() { _screen->loadBitmap(_filesTower[1], 5, 3, 0); _screen->setCurPage(2); - uint8 *shp = _screen->encodeShape(0, 0, 16, 56, true); - _screen->copyPage(3, 4); + uint8 *shp = _screen->encodeShape(0, 0, 16, 56, true, _vm->_cgaMappingAlt); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _screen->clearCurPage(); for (int i = 0; i < 200; i += 64) @@ -236,19 +240,19 @@ void EoBIntroPlayer::orb() { uint8 *shp[5]; _screen->loadBitmap(_filesOrb[0], 5, 3, 0); _screen->setCurPage(2); - shp[4] = _screen->encodeShape(0, 0, 20, 136, true); + shp[4] = _screen->encodeShape(0, 0, 20, 136, true, _vm->_cgaMappingAlt); _screen->loadBitmap(_filesOrb[1], 5, 3, 0); - shp[3] = _screen->encodeShape(16, 0, 16, 104, true); + shp[3] = _screen->encodeShape(16, 0, 16, 104, true, _vm->_cgaMappingAlt); _screen->fillRect(0, 0, 127, 103, 12); for (int i = 1; i < 4; i++) { copyBlurRegion(128, 0, 0, 0, 128, 104, i); - shp[3 - i] = _screen->encodeShape(0, 0, 16, 104, true); + shp[3 - i] = _screen->encodeShape(0, 0, 16, 104, true, _vm->_cgaMappingAlt); } _screen->fillRect(0, 0, 159, 135, 12); _screen->setCurPage(0); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _screen->clearCurPage(); _vm->snd_playSoundEffect(6); @@ -297,14 +301,14 @@ void EoBIntroPlayer::waterdeepEntry() { loadAndSetPalette(_filesWdEntry[0]); _screen->loadBitmap(_filesWdEntry[1], 5, 3, 0); _screen->setCurPage(2); - shp[3] = _screen->encodeShape(0, 0, 20, 136, true); + shp[3] = _screen->encodeShape(0, 0, 20, 136, true, _vm->_cgaMappingAlt); for (int i = 1; i < 4; i++) { copyBlurRegion(0, 0, 0, 0, 160, 136, i); - shp[3 - i] = _screen->encodeShape(0, 0, 20, 136, true); + shp[3 - i] = _screen->encodeShape(0, 0, 20, 136, true, _vm->_cgaMappingAlt); } _screen->setCurPage(0); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _screen->fillRect(0, 168, 319, 199, 12, 0); _vm->snd_playSoundEffect(6); @@ -321,18 +325,18 @@ void EoBIntroPlayer::waterdeepEntry() { _vm->delay(50 * _vm->_tickLength); _screen->setCurPage(2); - shp[0] = _screen->encodeShape(20, 0, 20, 136, true); + shp[0] = _screen->encodeShape(20, 0, 20, 136, true, _vm->_cgaMappingAlt); _screen->loadBitmap(_filesWdEntry[2], 5, 3, 0); - shp[1] = _screen->encodeShape(0, 0, 20, 136, true); - shp[2] = _screen->encodeShape(20, 0, 20, 136, true); + shp[1] = _screen->encodeShape(0, 0, 20, 136, true, _vm->_cgaMappingAlt); + shp[2] = _screen->encodeShape(20, 0, 20, 136, true, _vm->_cgaMappingAlt); _screen->loadBitmap(_filesWdEntry[3], 5, 3, 0); for (int i = 0; i < 31; i++) - shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true); + shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true, _vm->_cgaMappingAlt); for (int i = 0; i < 3; i++) - shp3[i] = _screen->encodeShape(5 * i, 152, 5, 32, true); + shp3[i] = _screen->encodeShape(5 * i, 152, 5, 32, true, _vm->_cgaMappingAlt); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); for (int i = 0; i < 3 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; @@ -391,7 +395,7 @@ void EoBIntroPlayer::king() { return; _screen->loadBitmap(_filesKing[0], 5, 3, 0); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); int x = 15; int y = 14; @@ -428,7 +432,7 @@ void EoBIntroPlayer::king() { _screen->loadBitmap(_filesKing[1], 5, 3, 0); _screen->setCurPage(2); for (int i = 0; i < 4; i++) { - shp[i] = _screen->encodeShape(advEncX[i], 0, advEncW[i], 98, true); + shp[i] = _screen->encodeShape(advEncX[i], 0, advEncW[i], 98, true, _vm->_cgaMappingAlt); dy[i] = 180 + ((_vm->_rnd.getRandomNumber(255) & 3) << 3); stepY[i] = (i * 5) & 3; } @@ -477,8 +481,8 @@ void EoBIntroPlayer::hands() { return; _screen->setCurPage(2); - uint8 *shp1 = _screen->encodeShape(0, 140, 21, 60, true); - uint8 *shp2 = _screen->encodeShape(21, 140, 12, 60, true); + uint8 *shp1 = _screen->encodeShape(0, 140, 21, 60, true, _vm->_cgaMappingAlt); + uint8 *shp2 = _screen->encodeShape(21, 140, 12, 60, true, _vm->_cgaMappingAlt); _screen->loadBitmap(_filesHands[0], 3, 5, 0); _screen->fillRect(0, 160, 319, 199, 12, 0); @@ -509,9 +513,9 @@ void EoBIntroPlayer::hands() { _vm->delay(15 * _vm->_tickLength); _screen->setCurPage(4); - shp1 = _screen->encodeShape(17, 0, 11, 120, true); - shp2 = _screen->encodeShape(28, 112, 1, 31, true); - uint8 *shp3 = _screen->encodeShape(9, 138, 14, 54, true); + shp1 = _screen->encodeShape(17, 0, 11, 120, true, _vm->_cgaMappingAlt); + shp2 = _screen->encodeShape(28, 112, 1, 31, true, _vm->_cgaMappingAlt); + uint8 *shp3 = _screen->encodeShape(9, 138, 14, 54, true, _vm->_cgaMappingAlt); _screen->setCurPage(2); _screen->fillRect(0, 0, 135, 63, 157); @@ -549,8 +553,8 @@ void EoBIntroPlayer::hands() { _vm->delay(15 * _vm->_tickLength); _screen->setCurPage(4); - shp1 = _screen->encodeShape(0, 0, 17, 136, true); - shp2 = _screen->encodeShape(0, 136, 9, 48, true); + shp1 = _screen->encodeShape(0, 0, 17, 136, true, _vm->_cgaMappingAlt); + shp2 = _screen->encodeShape(0, 136, 9, 48, true, _vm->_cgaMappingAlt); _screen->setCurPage(2); _screen->fillRect(0, 0, 143, 95, 157); @@ -576,8 +580,8 @@ void EoBIntroPlayer::hands() { _vm->delay(30 * _vm->_tickLength); _screen->setCurPage(4); - shp1 = _screen->encodeShape(28, 0, 11, 40, true); - shp2 = _screen->encodeShape(28, 40, 10, 72, true); + shp1 = _screen->encodeShape(28, 0, 11, 40, true, _vm->_cgaMappingAlt); + shp2 = _screen->encodeShape(28, 40, 10, 72, true, _vm->_cgaMappingAlt); _screen->setCurPage(2); _screen->fillRect(0, 0, 87, 112, 157); @@ -622,11 +626,11 @@ void EoBIntroPlayer::waterdeepExit() { _screen->loadBitmap(_filesWdExit[0], 5, 3, 0); _screen->setCurPage(2); for (int i = 0; i < 31; i++) - shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true); + shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true, _vm->_cgaMappingAlt); for (int i = 0; i < 3; i++) - shp3[i] = _screen->encodeShape(5 * i + 15, 152, 5, 32, true); - uint8 *shp1 = _screen->encodeShape(31, 136, 5, 32, true); - _screen->copyPage(3, 4); + shp3[i] = _screen->encodeShape(5 * i + 15, 152, 5, 32, true, _vm->_cgaMappingAlt); + uint8 *shp1 = _screen->encodeShape(31, 136, 5, 32, true, _vm->_cgaMappingAlt); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _screen->copyRegion(0, 0, 0, 136, 48, 36, 4, 4, Screen::CR_NO_P_CHECK); _screen->fillRect(0, 168, 319, 199, 12, 0); _screen->copyRegion(160, 0, 80, 24, 160, 136, 4, 0, Screen::CR_NO_P_CHECK); @@ -676,7 +680,7 @@ void EoBIntroPlayer::waterdeepExit() { loadAndSetPalette(_filesWdExit[1]); _screen->loadBitmap(_filesWdExit[2], 3, 5, 0); - _screen->copyPage(5, 2); + _screen->convertPage(5, 2, _vm->_cgaMappingAlt); whirlTransition(); _vm->delay(6 * _vm->_tickLength); @@ -717,7 +721,7 @@ void EoBIntroPlayer::waterdeepExit() { } _screen->loadBitmap(_filesWdExit[3], 3, 5, 0); - _screen->copyPage(5, 2); + _screen->convertPage(5, 2, _vm->_cgaMappingAlt); _vm->delay(30 * _vm->_tickLength); _screen->setCurPage(0); _screen->fillRect(0, 16, 319, 31, 12); @@ -733,8 +737,8 @@ void EoBIntroPlayer::tunnel() { return; _screen->setCurPage(4); - uint8 *shp2 = _screen->encodeShape(20, 0, 20, 120, true); - uint8 *shp1 = _screen->encodeShape(0, 0, 20, 120, true); + uint8 *shp2 = _screen->encodeShape(20, 0, 20, 120, true, _vm->_cgaMappingAlt); + uint8 *shp1 = _screen->encodeShape(0, 0, 20, 120, true, _vm->_cgaMappingAlt); _vm->drawBlockObject(1, 4, shp2, 160, 0, 0); _vm->drawBlockObject(1, 4, shp1, 0, 0, 0); delete[] shp1; @@ -771,7 +775,7 @@ void EoBIntroPlayer::tunnel() { _screen->copyRegion(0, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); _screen->loadBitmap(_filesTunnel[0], 5, 3, 0); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _screen->updateScreen(); _vm->delay(40 * _vm->_tickLength); @@ -808,7 +812,7 @@ void EoBIntroPlayer::tunnel() { _vm->delay(40 * _vm->_tickLength); _screen->loadBitmap(_filesTunnel[1], 5, 3, 0); - _screen->copyPage(3, 4); + _screen->convertPage(3, 4, _vm->_cgaMappingAlt); _vm->snd_playSoundEffect(6); _screen->copyRegion(0, 0, 80, 32, 160, 120, 4, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); @@ -825,6 +829,8 @@ void EoBIntroPlayer::tunnel() { } void EoBIntroPlayer::loadAndSetPalette(const char *filename) { + if (_vm->_configRenderMode == Common::kRenderCGA || _vm->_configRenderMode == Common::kRenderEGA) + return; _screen->loadPalette(filename, _screen->getPalette(0)); _screen->getPalette(0).fill(0, 1, 0); _screen->setScreenPalette(_screen->getPalette(0)); @@ -975,8 +981,9 @@ int EoBEngine::mainMenu() { while (menuChoice >= 0 && !shouldQuit()) { switch (menuChoice) { case 0: { - _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); - _screen->loadEoBBitmap("INTRO", 0, 5, 3, 2); + if (_configRenderMode != Common::kRenderEGA) + _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); + _screen->loadEoBBitmap("INTRO", _cgaMappingDefault, 5, 3, 2); _screen->setScreenPalette(_screen->getPalette(0)); _screen->_curPage = 2; of = _screen->setFont(Screen::FID_6_FNT); @@ -984,8 +991,8 @@ int EoBEngine::mainMenu() { _screen->printText(versionString.c_str(), 280 - versionString.size() * 6, 153, _screen->getPagePixel(2, 0, 0), 0); _screen->setFont(of); _screen->fillRect(0, 159, 319, 199, _screen->getPagePixel(2, 0, 0)); - gui_drawBox(77, 165, 173, 29, 13, 14, 12); - gui_drawBox(76, 164, 175, 31, 13, 14, -1); + gui_drawBox(77, 165, 173, 29, 14, 13, 12); + gui_drawBox(76, 164, 175, 31, 14, 13, -1); _screen->_curPage = 0; _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); @@ -996,7 +1003,6 @@ int EoBEngine::mainMenu() { case 1: // load game in progress - // menuChoice = -1; break; @@ -1089,10 +1095,10 @@ void EoBEngine::seq_xdeath() { _screen->loadShapeSetBitmap("XDEATH2", 5, 3); for (int i = 0; i < 4; i++) - shapes1[i] = _screen->encodeShape(i / 2 * 14, i / 2 * 88, 14, 88, true); + shapes1[i] = _screen->encodeShape(i / 2 * 14, i / 2 * 88, 14, 88, true, _cgaMappingDefault); _screen->loadShapeSetBitmap("XDEATH3", 5, 3); - shapes2 = _screen->encodeShape(22, 0, 16, 95, true); - _screen->loadEoBBitmap("XDEATH1", 0, 5, 3, -1); + shapes2 = _screen->encodeShape(22, 0, 16, 95, true, _cgaMappingDefault); + _screen->loadEoBBitmap("XDEATH1", _cgaMappingDefault, 5, 3, -1); _screen->setCurPage(0); for (int i = 0; i < 10; i++) { diff --git a/engines/kyra/sprites_eob.cpp b/engines/kyra/sprites_eob.cpp index 360d31458a..9e450a5ac7 100644 --- a/engines/kyra/sprites_eob.cpp +++ b/engines/kyra/sprites_eob.cpp @@ -37,7 +37,7 @@ void EoBCoreEngine::loadMonsterShapes(const char *filename, int monsterIndex, bo const uint16 *enc = &_encodeMonsterShpTable[encodeTableIndex << 2]; for (int i = 0; i < 6; i++, enc += 4) - _monsterShapes[monsterIndex + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3]); + _monsterShapes[monsterIndex + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, _cgaMappingDefault); generateMonsterPalettes(filename, monsterIndex); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 99ad6ea7aa..2be25ce093 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -38,7 +38,7 @@ namespace Kyra { -#define RESFILE_VERSION 80 +#define RESFILE_VERSION 81 namespace { bool checkKyraDat(Common::SeekableReadStream *file) { diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index a65ade7aee..5e28757978 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -28,12 +28,12 @@ namespace Kyra { #ifdef ENABLE_EOB -const EoBSequenceStep *StaticResource::loadEoB2SeqData(int id, int &entries) { - return (const EoBSequenceStep *)getData(id, kEoB2SequenceData, entries); +const DarkMoonAnimCommand *StaticResource::loadEoB2SeqData(int id, int &entries) { + return (const DarkMoonAnimCommand *)getData(id, kEoB2SequenceData, entries); } -const EoBShapeDef *StaticResource::loadEoB2ShapeData(int id, int &entries) { - return (const EoBShapeDef *)getData(id, kEoB2ShapeData, entries); +const DarkMoonShapeDef *StaticResource::loadEoB2ShapeData(int id, int &entries) { + return (const DarkMoonShapeDef *)getData(id, kEoB2ShapeData, entries); } const EoBCharacter *StaticResource::loadEoBNpcData(int id, int &entries) { @@ -43,7 +43,7 @@ const EoBCharacter *StaticResource::loadEoBNpcData(int id, int &entries) { bool StaticResource::loadEoB2SeqData(Common::SeekableReadStream &stream, void *&ptr, int &size) { size = stream.size() / 11; - EoBSequenceStep *s = new EoBSequenceStep[size]; + DarkMoonAnimCommand *s = new DarkMoonAnimCommand[size]; for (int i = 0; i < size; i++) { s[i].command = stream.readByte(); @@ -65,7 +65,7 @@ bool StaticResource::loadEoB2SeqData(Common::SeekableReadStream &stream, void *& bool StaticResource::loadEoB2ShapeData(Common::SeekableReadStream &stream, void *&ptr, int &size) { size = stream.size() / 6; - EoBShapeDef *s = new EoBShapeDef[size]; + DarkMoonShapeDef *s = new DarkMoonShapeDef[size]; for (int i = 0; i < size; i++) { s[i].index = stream.readSint16BE(); @@ -127,14 +127,14 @@ bool StaticResource::loadEoBNpcData(Common::SeekableReadStream &stream, void *&p } void StaticResource::freeEoB2SeqData(void *&ptr, int &size) { - EoBSequenceStep *d = (EoBSequenceStep *)ptr; + DarkMoonAnimCommand *d = (DarkMoonAnimCommand *)ptr; delete[] d; ptr = 0; size = 0; } void StaticResource::freeEoB2ShapeData(void *&ptr, int &size) { - EoBShapeDef *d = (EoBShapeDef *)ptr; + DarkMoonShapeDef *d = (DarkMoonShapeDef *)ptr; delete[] d; ptr = 0; size = 0; @@ -1035,6 +1035,18 @@ void EoBEngine::initStaticResource() { _beholderSpellList = _staticres->loadRawData(kEoB1BeholderSpellList, temp); _beholderSfx = _staticres->loadRawData(kEoB1BeholderSfx, temp); + _cgaMappingDefault = _staticres->loadRawData(kEoB1CgaMappingDefault, temp); + _cgaMappingAlt = _staticres->loadRawData(kEoB1CgaMappingAlt, temp); + _cgaMappingInv = _staticres->loadRawData(kEoB1CgaMappingInv, temp); + _cgaMappingItemsL = _staticres->loadRawData(kEoB1CgaMappingItemsL, temp); + _cgaMappingItemsS = _staticres->loadRawData(kEoB1CgaMappingItemsS, temp); + _cgaMappingThrown = _staticres->loadRawData(kEoB1CgaMappingThrown, temp); + _cgaMappingIcons = _staticres->loadRawData(kEoB1CgaMappingIcons, temp); + _cgaMappingDeco = _staticres->loadRawData(kEoB1CgaMappingDeco, temp); + _cgaLevelMappingIndex = _staticres->loadRawData(kEoB1CgaLevelMappingIndex, temp); + for (int i = 0; i < 5; i++) + _cgaMappingLevel[i] = _staticres->loadRawData(kEoB1CgaMappingLevel0 + i, temp); + _turnUndeadString = _staticres->loadStrings(kEoB1TurnUndeadString, temp); _npcShpData = _staticres->loadRawData(kEoB1NpcShpData, temp); @@ -1174,18 +1186,22 @@ const KyraRpgGUISettings EoBEngine::_guiSettings = { { 135, 130, 132, 133, 133, 17, 23, 20, 184, 177, 180, 184, 177, 180 } }; +const uint8 EoBEngine::_egaDefaultPalette[] = { + 0, 5, 3, 2, 10, 14, 12, 6, 4, 11, 9, 1, 0, 8, 7, 15 +}; + void DarkMoonEngine::initStaticResource() { int temp; _mainMenuStrings = _staticres->loadStrings(kEoB2MainMenuStrings, temp); _introStrings = _staticres->loadStrings(kEoB2IntroStrings, temp); _cpsFilesIntro = _staticres->loadStrings(kEoB2IntroCPSFiles, temp); - _seqIntro = new const EoBSequenceStep*[44]; + _animIntro = new const DarkMoonAnimCommand*[44]; for (int i = 0; i < 44; i++) - _seqIntro[i] = _staticres->loadEoB2SeqData(kEoB2IntroSeqData00 + i, temp); + _animIntro[i] = _staticres->loadEoB2SeqData(kEob2IntroAnimData00 + i, temp); - _shapesIntro = new const EoBShapeDef*[13]; - memset(_shapesIntro, 0, sizeof(EoBShapeDef *) * 13); + _shapesIntro = new const DarkMoonShapeDef*[13]; + memset(_shapesIntro, 0, sizeof(DarkMoonShapeDef*) * 13); _shapesIntro[0] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes00, temp); _shapesIntro[1] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes01, temp); _shapesIntro[4] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes04, temp); @@ -1195,12 +1211,12 @@ void DarkMoonEngine::initStaticResource() { _creditsData = _staticres->loadRawData(kEoB2CreditsData, temp); _cpsFilesFinale = _staticres->loadStrings(kEoB2FinaleCPSFiles, temp); - _seqFinale = new const EoBSequenceStep*[21]; + _animFinale = new const DarkMoonAnimCommand*[21]; for (int i = 0; i < 21; i++) - _seqFinale[i] = _staticres->loadEoB2SeqData(kEoB2FinaleSeqData00 + i, temp); + _animFinale[i] = _staticres->loadEoB2SeqData(kEob2FinaleAnimData00 + i, temp); - _shapesFinale = new const EoBShapeDef*[13]; - memset(_shapesFinale, 0, sizeof(EoBShapeDef *) * 13); + _shapesFinale = new const DarkMoonShapeDef*[13]; + memset(_shapesFinale, 0, sizeof(DarkMoonShapeDef*) * 13); _shapesFinale[0] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes00, temp); _shapesFinale[3] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes03, temp); _shapesFinale[7] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes07, temp); @@ -1275,15 +1291,23 @@ void DarkMoonEngine::initSpells() { } } -const char *DarkMoonEngine::_palFilesIntro[] = { - "PALETTE1.PAL", // EGA: palette0.pal +const char *DarkMoonEngine::_palFilesIntroVGA[] = { + "PALETTE1.PAL", + "PALETTE3.PAL", + "PALETTE2.PAL", + "PALETTE4.PAL", + 0 +}; + +const char *DarkMoonEngine::_palFilesIntroEGA[] = { + "PALETTE0.PAL", "PALETTE3.PAL", "PALETTE2.PAL", "PALETTE4.PAL", 0 }; -const char *DarkMoonEngine::_palFilesFinale[] = { +const char *DarkMoonEngine::_palFilesFinaleVGA[] = { "FINALE_0.PAL", "FINALE_0.PAL", "FINALE_1.PAL", @@ -1296,11 +1320,28 @@ const char *DarkMoonEngine::_palFilesFinale[] = { 0 }; +const char *DarkMoonEngine::_palFilesFinaleEGA[] = { + "FINALE_0.PAL", + "FINALE_0.PAL", + "FINALE_1.PAL", + "FINALE_2.PAL", + "FINALE_3.PAL", + "FINALE_4.PAL", + "FINALE_5.PAL", + "FINALE_0.PAL", + "FINALE_0.PAL", + 0 +}; + const KyraRpgGUISettings DarkMoonEngine::_guiSettings = { { 9, 15, 95, 9, 7, { 221, 76 }, { 189, 162 }, { 95, 95 } }, { 186, 181, 183, 133, 184, 17, 23, 20, 186, 181, 183, 182, 177, 180 } }; +const uint8 DarkMoonEngine::_egaDefaultPalette[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 +}; + #endif // ENABLE_EOB } // End of namespace Kyra |