diff --git a/engines/freescape/area.h b/engines/freescape/area.h index 950854432f9..294b73a5c88 100644 --- a/engines/freescape/area.h +++ b/engines/freescape/area.h @@ -80,6 +80,7 @@ public: uint8 _underFireBackgroundColor; uint8 _inkColor; uint8 _paperColor; + uint8 _extraColor[4]; ColorReMap _colorRemaps; private: diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp index a9fcdb495f8..505c6bfd86a 100644 --- a/engines/freescape/games/castle.cpp +++ b/engines/freescape/games/castle.cpp @@ -194,6 +194,28 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) { _gfx->_keyColor = 0; } else _gfx->_keyColor = 255; + + _lastPosition = _position; + _gameStateVars[0x1f] = 0; + + if (areaID == _startArea && entranceID == _startEntrance) { + _yaw = 310; + _pitch = 0; + } + + debugC(1, kFreescapeDebugMove, "starting player position: %f, %f, %f", _position.x(), _position.y(), _position.z()); + clearTemporalMessages(); + playSound(5, false); + // Ignore sky/ground fields + _gfx->_keyColor = 0; + + _gfx->_colorPair[_currentArea->_underFireBackgroundColor] = _currentArea->_extraColor[0]; + _gfx->_colorPair[_currentArea->_usualBackgroundColor] = _currentArea->_extraColor[1]; + _gfx->_colorPair[_currentArea->_paperColor] = _currentArea->_extraColor[2]; + _gfx->_colorPair[_currentArea->_inkColor] = _currentArea->_extraColor[3]; + + swapPalette(areaID); + resetInput(); } void CastleEngine::drawUI() { diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp index dd891144994..dd2680a18c6 100644 --- a/engines/freescape/gfx.cpp +++ b/engines/freescape/gfx.cpp @@ -361,8 +361,7 @@ bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 & return true; } -bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) { - // assert(index-1 < _colorMap->size()); +uint8 Renderer::mapEGAColor(uint8 index) { byte *entry = (*_colorMap)[index - 1]; uint8 color = 0; uint8 acc = 1; @@ -376,10 +375,23 @@ bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 & entry++; } assert(color < 16); - readFromPalette(color, r1, g1, b1); - r2 = r1; - g2 = g1; - b2 = b1; + return color; +} + +bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) { + uint8 color; + if (_colorPair[index] > 0) { + color = mapEGAColor(_colorPair[index] & 0xf); + readFromPalette(color, r1, g1, b1); + color = mapEGAColor(_colorPair[index] >> 4); + readFromPalette(color, r2, g2, b2); + } else { + color = mapEGAColor(index); + readFromPalette(color, r1, g1, b1); + r2 = r1; + g2 = g1; + b2 = b1; + } return true; } diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h index 0d3acc47099..047cb82589f 100644 --- a/engines/freescape/gfx.h +++ b/engines/freescape/gfx.h @@ -100,6 +100,8 @@ public: // palette void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b); uint8 indexFromColor(uint8 r, uint8 g, uint8 b); + uint8 mapEGAColor(uint8 index); + bool getRGBAt(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple); bool getRGBAtC64(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2); bool getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple); diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp index 47bce668a63..e5265274b59 100644 --- a/engines/freescape/loaders/8bitBinaryLoader.cpp +++ b/engines/freescape/loaders/8bitBinaryLoader.cpp @@ -438,10 +438,12 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco // debug("Condition Ptr: %x", cPtr); debugC(1, kFreescapeDebugParser, "Pos before first object: %lx", file->pos()); + // Driller specific uint8 gasPocketX = 0; uint8 gasPocketY = 0; uint8 gasPocketRadius = 0; - + // Castle specific + uint8 extraColor[4]; if (isEclipse()) { byte idx = file->readByte(); name = idx < 8 ? eclipseRoomName[idx] : eclipseRoomName[8]; @@ -471,10 +473,10 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco } else if (isCastle()) { byte idx = file->readByte(); name = _messagesList[idx + 41]; - debug("byte: %d", file->readByte()); - debug("byte: %d", file->readByte()); - debug("byte: %d", file->readByte()); - debug("byte: %d", file->readByte()); + extraColor[0] = file->readByte(); + extraColor[1] = file->readByte(); + extraColor[2] = file->readByte(); + extraColor[3] = file->readByte(); } debugC(1, kFreescapeDebugParser, "Area name: %s", name.c_str()); @@ -511,11 +513,17 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco area->_scale = scale; area->_skyColor = skyColor; area->_groundColor = groundColor; + area->_inkColor = inkColor; area->_paperColor = paperColor; area->_usualBackgroundColor = usualBackgroundColor; area->_underFireBackgroundColor = underFireBackgroundColor; + area->_extraColor[0] = extraColor[0]; + area->_extraColor[1] = extraColor[1]; + area->_extraColor[2] = extraColor[2]; + area->_extraColor[3] = extraColor[3]; + // Driller specific area->_gasPocketPosition = Common::Point(32 * gasPocketX, 32 * gasPocketY); area->_gasPocketRadius = 32 * gasPocketRadius;