[Scummvm-git-logs] scummvm master -> 133a2dc9b6baee91a5c45e74f41f7ebd6303567c
neuromancer
noreply at scummvm.org
Thu May 9 06:31:16 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9646dd5638 FREESCAPE: improved rendering of floors
aac1e51e5b FREESCAPE: improved rendering of planar over planar
ebc0c06096 FREESCAPE: only add a floor if needed
133a2dc9b6 FREESCAPE: file structure for castle
Commit: 9646dd563800d35d625f4e589260846326d229ff
https://github.com/scummvm/scummvm/commit/9646dd563800d35d625f4e589260846326d229ff
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-05-09T08:31:57+02:00
Commit Message:
FREESCAPE: improved rendering of floors
Changed paths:
engines/freescape/area.cpp
engines/freescape/gfx.h
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl.h
engines/freescape/gfx_opengl_shaders.cpp
engines/freescape/gfx_opengl_shaders.h
engines/freescape/gfx_tinygl.cpp
engines/freescape/gfx_tinygl.h
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 364523534d0..71e80c43c63 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -227,9 +227,15 @@ void Area::draw(Freescape::Renderer *gfx, uint32 animationTicks, Math::Vector3d
assert(_drawableObjects.size() > 0);
ObjectArray planarObjects;
ObjectArray nonPlanarObjects;
+ Object *floor = nullptr;
for (auto &obj : _drawableObjects) {
if (!obj->isDestroyed() && !obj->isInvisible()) {
+ if (obj->getObjectID() == 0 && _groundColor < 255 && _skyColor < 255) {
+ floor = obj;
+ continue;
+ }
+
if (obj->getType() == ObjectType::kGroupType) {
drawGroup(gfx, (Group *)obj, runAnimation);
continue;
@@ -242,6 +248,12 @@ void Area::draw(Freescape::Renderer *gfx, uint32 animationTicks, Math::Vector3d
}
}
+ if (floor) {
+ gfx->depthTesting(false);
+ floor->draw(gfx);
+ gfx->depthTesting(true);
+ }
+
Common::HashMap<Object *, float> offsetMap;
for (auto &planar : planarObjects)
offsetMap[planar] = 0;
@@ -472,7 +484,7 @@ void Area::addFloor() {
id,
0, // flags
Math::Vector3d(-maxSize, -3, -maxSize), // Position
- Math::Vector3d(maxSize * 4, 1, maxSize * 4), // size
+ Math::Vector3d(maxSize * 4, 3, maxSize * 4), // size
gColors,
nullptr,
nullptr,
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 40b6bc9d008..297c2e9fd89 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -74,6 +74,7 @@ public:
*/
virtual void flipBuffer() {}
virtual void useColor(uint8 r, uint8 g, uint8 b) = 0;
+ virtual void depthTesting(bool enabled) {};
virtual void polygonOffset(bool enabled) = 0;
virtual Texture *createTexture(const Graphics::Surface *surface) = 0;
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index d004f5f7ef6..68bd519273c 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -435,6 +435,14 @@ void OpenGLRenderer::renderFace(const Common::Array<Math::Vector3d> &vertices) {
glDisableClientState(GL_VERTEX_ARRAY);
}
+void OpenGLRenderer::depthTesting(bool enabled) {
+ if (enabled) {
+ glEnable(GL_DEPTH_TEST);
+ } else {
+ glDisable(GL_DEPTH_TEST);
+ }
+};
+
void OpenGLRenderer::polygonOffset(bool enabled) {
if (enabled) {
glEnable(GL_POLYGON_OFFSET_FILL);
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 6cdd5a10552..9ea1ddc5e29 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -94,6 +94,7 @@ public:
virtual void polygonOffset(bool enabled) override;
virtual void setStippleData(byte *data) override;
virtual void useStipple(bool enabled) override;
+ virtual void depthTesting(bool enabled) override;
Texture *createTexture(const Graphics::Surface *surface) override;
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 142859a2754..39c27d5d305 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -434,6 +434,14 @@ void OpenGLShaderRenderer::renderFace(const Common::Array<Math::Vector3d> &verti
glDrawArrays(GL_TRIANGLES, 0, vi + 3);
}
+void OpenGLShaderRenderer::depthTesting(bool enabled) {
+ if (enabled) {
+ glEnable(GL_DEPTH_TEST);
+ } else {
+ glDisable(GL_DEPTH_TEST);
+ }
+};
+
void OpenGLShaderRenderer::polygonOffset(bool enabled) {
if (enabled) {
glEnable(GL_POLYGON_OFFSET_FILL);
diff --git a/engines/freescape/gfx_opengl_shaders.h b/engines/freescape/gfx_opengl_shaders.h
index 889fa7934ab..030ac6aa6fa 100644
--- a/engines/freescape/gfx_opengl_shaders.h
+++ b/engines/freescape/gfx_opengl_shaders.h
@@ -73,6 +73,8 @@ public:
virtual void useColor(uint8 r, uint8 g, uint8 b) override;
virtual void polygonOffset(bool enabled) override;
+ virtual void depthTesting(bool enabled) override;
+
virtual void setStippleData(byte *data) override;
virtual void useStipple(bool enabled) override;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index 259c642c92f..28ebc619400 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -240,6 +240,14 @@ void TinyGLRenderer::renderFace(const Common::Array<Math::Vector3d> &vertices) {
tglDisableClientState(TGL_VERTEX_ARRAY);
}
+void TinyGLRenderer::depthTesting(bool enabled) {
+ if (enabled) {
+ tglEnable(TGL_DEPTH_TEST);
+ } else {
+ tglDisable(TGL_DEPTH_TEST);
+ }
+};
+
void TinyGLRenderer::polygonOffset(bool enabled) {
if (enabled) {
tglEnable(TGL_POLYGON_OFFSET_FILL);
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index ac7461091cb..f9e12a37f66 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -54,6 +54,7 @@ public:
virtual void useColor(uint8 r, uint8 g, uint8 b) override;
virtual void polygonOffset(bool enabled) override;
+ virtual void depthTesting(bool enabled) override;
Texture *createTexture(const Graphics::Surface *surface) override;
void freeTexture(Texture *texture) override;
Commit: aac1e51e5b204754cf0d401dea87084a454309b6
https://github.com/scummvm/scummvm/commit/aac1e51e5b204754cf0d401dea87084a454309b6
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-05-09T08:31:57+02:00
Commit Message:
FREESCAPE: improved rendering of planar over planar
Changed paths:
engines/freescape/area.cpp
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 71e80c43c63..9d103d82d93 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -288,6 +288,57 @@ void Area::draw(Freescape::Renderer *gfx, uint32 animationTicks, Math::Vector3d
}
}
+ for (auto &planar : planarObjects) {
+ Math::Vector3d centerPlanar = planar->_boundingBox.getMin() + planar->_boundingBox.getMax();
+ centerPlanar /= 2;
+ Math::Vector3d distance;
+ for (auto &object : planarObjects) {
+ if (object == planar)
+ continue;
+
+ distance = object->_boundingBox.distance(centerPlanar);
+ if (distance.length() > 0)
+ continue;
+
+ if (planar->getSize().x() == 0) {
+ if (object->getSize().x() > 0)
+ continue;
+ } else if (planar->getSize().y() == 0) {
+ if (object->getSize().y() > 0)
+ continue;
+ } else if (planar->getSize().z() == 0) {
+ if (object->getSize().z() > 0)
+ continue;
+ } else
+ continue;
+
+ //debug("planar object %d collides with planar object %d", planar->getObjectID(), object->getObjectID());
+ if (offsetMap[planar] == offsetMap[object] && offsetMap[object] != 0) {
+ // Nothing to do?
+ } else if (offsetMap[planar] == offsetMap[object] && offsetMap[object] == 0) {
+ float offset = 1.0;
+ if (planar->getSize().x() == 0) {
+ if (object->getOrigin().x() < centerPlanar.x())
+ offsetMap[planar] = -offset;
+ else
+ offsetMap[planar] = offset;
+ } else if (planar->getSize().y() == 0) {
+ if (object->getOrigin().y() < centerPlanar.y())
+ offsetMap[planar] = -offset;
+ else
+ offsetMap[planar] = offset;
+ } else if (planar->getSize().z() == 0) {
+ if (object->getOrigin().z() < centerPlanar.z())
+ offsetMap[planar] = -offset;
+ else
+ offsetMap[planar] = offset;
+ } else
+ ; //It was not really planar?!
+ }
+ }
+ }
+
+
for (auto &pair : offsetMap) {
pair._key->draw(gfx, pair._value);
}
Commit: ebc0c060969075079957173b45ee666aaba3498f
https://github.com/scummvm/scummvm/commit/ebc0c060969075079957173b45ee666aaba3498f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-05-09T08:31:57+02:00
Commit Message:
FREESCAPE: only add a floor if needed
Changed paths:
engines/freescape/area.cpp
engines/freescape/games/castle/castle.cpp
engines/freescape/games/eclipse/eclipse.cpp
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 9d103d82d93..ee5ac8c9867 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -546,7 +546,6 @@ void Area::addFloor() {
void Area::addStructure(Area *global) {
if (!global || !_entrancesByID->contains(255)) {
- addFloor();
return;
}
GlobalStructure *rs = (GlobalStructure *)(*_entrancesByID)[255];
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index ef6e61db99e..dc71505fd06 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -189,6 +189,7 @@ void CastleEngine::loadAssetsDOSFullGame() {
for (auto &it : _areaMap)
it._value->addStructure(_areaMap[255]);
+ _areaMap[1]->addFloor();
_areaMap[2]->addFloor();
delete stream;
} else
@@ -271,6 +272,7 @@ void CastleEngine::loadAssetsAmigaDemo() {
for (auto &it : _areaMap)
it._value->addStructure(_areaMap[255]);
+ _areaMap[1]->addFloor();
_areaMap[2]->addFloor();
}
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index fcb28d43bdd..13ebc7c3bdf 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -91,6 +91,8 @@ void EclipseEngine::loadAssets() {
//_noEnergyMessage = _messagesList[16];
_fallenMessage = _messagesList[3];
_crushedMessage = _messagesList[2];
+ _areaMap[1]->addFloor();
+ _areaMap[51]->addFloor();
}
bool EclipseEngine::checkIfGameEnded() {
Commit: 133a2dc9b6baee91a5c45e74f41f7ebd6303567c
https://github.com/scummvm/scummvm/commit/133a2dc9b6baee91a5c45e74f41f7ebd6303567c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-05-09T08:31:58+02:00
Commit Message:
FREESCAPE: file structure for castle
Changed paths:
A engines/freescape/games/castle/amiga.cpp
A engines/freescape/games/castle/dos.cpp
engines/freescape/games/castle/castle.cpp
engines/freescape/games/castle/castle.h
engines/freescape/module.mk
diff --git a/engines/freescape/games/castle/amiga.cpp b/engines/freescape/games/castle/amiga.cpp
new file mode 100644
index 00000000000..65a70078637
--- /dev/null
+++ b/engines/freescape/games/castle/amiga.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "common/memstream.h"
+
+#include "freescape/freescape.h"
+#include "freescape/games/castle/castle.h"
+#include "freescape/language/8bitDetokeniser.h"
+
+namespace Freescape {
+
+void CastleEngine::loadAssetsAmigaDemo() {
+ Common::File file;
+ file.open("x");
+ if (!file.isOpen())
+ error("Failed to open 'x' file");
+
+ loadMessagesVariableSize(&file, 0x8bb2, 164);
+ load8bitBinary(&file, 0x162a6, 16);
+ loadPalettes(&file, 0x151a6);
+
+ file.seek(0x2be96); // Area 255
+ _areaMap[255] = load8bitArea(&file, 16);
+ file.close();
+
+ _areaMap[2]->_groundColor = 1;
+ for (auto &it : _areaMap)
+ it._value->addStructure(_areaMap[255]);
+
+ _areaMap[1]->addFloor();
+ _areaMap[2]->addFloor();
+}
+
+} // End of namespace Freescape
\ No newline at end of file
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index dc71505fd06..2487889b14b 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -37,6 +37,7 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
_playerWidth = 8;
_playerDepth = 8;
_stepUpDistance = 32;
+ _maxFallingDistance = 8192;
_option = nullptr;
}
@@ -109,174 +110,6 @@ byte kFreescapeCastleFont[] = {
0x7f, 0x87, 0x0e, 0x1c, 0x38, 0x71, 0xfd, 0xe6,
};
-Common::SeekableReadStream *CastleEngine::decryptFile(const Common::Path &filename) {
- Common::File file;
- file.open(filename);
- if (!file.isOpen())
- error("Failed to open %s", filename.toString().c_str());
-
- int size = file.size();
- byte *encryptedBuffer = (byte *)malloc(size);
- file.read(encryptedBuffer, size);
- file.close();
-
- int seed = 24;
- for (int i = 0; i < size; i++) {
- encryptedBuffer[i] ^= seed;
- seed = (seed + 1) & 0xff;
- }
-
- return (new Common::MemoryReadStream(encryptedBuffer, size));
-}
-
-extern byte kEGADefaultPalette[16][3];
-extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
-
-void CastleEngine::loadAssetsDOSFullGame() {
- Common::File file;
- Common::SeekableReadStream *stream = nullptr;
-
- if (_renderMode == Common::kRenderEGA) {
- _viewArea = Common::Rect(40, 33, 280, 152);
-
- file.open("CME.EXE");
- stream = unpackEXE(file);
- if (stream) {
- loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
- }
-
- delete stream;
- file.close();
-
- file.open("CMLE.DAT");
- _title = load8bitBinImage(&file, 0x0);
- _title->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- file.open("CMOE.DAT");
- _option = load8bitBinImage(&file, 0x0);
- _option->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- file.open("CME.DAT");
- _border = load8bitBinImage(&file, 0x0);
- _border->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- switch (_language) {
- case Common::ES_ESP:
- stream = decryptFile("CMLS");
- break;
- case Common::FR_FRA:
- stream = decryptFile("CMLF");
- break;
- case Common::DE_DEU:
- stream = decryptFile("CMLG");
- break;
- case Common::EN_ANY:
- stream = decryptFile("CMLE");
- break;
- default:
- error("Invalid or unsupported language: %x", _language);
- }
-
- loadFonts(kFreescapeCastleFont, 59);
- loadMessagesVariableSize(stream, 0x11, 164);
- delete stream;
-
- stream = decryptFile("CMEDF");
- load8bitBinary(stream, 0, 16);
- for (auto &it : _areaMap)
- it._value->addStructure(_areaMap[255]);
-
- _areaMap[1]->addFloor();
- _areaMap[2]->addFloor();
- delete stream;
- } else
- error("Not implemented yet");
-
- for (auto &it : _areaMap) {
- for (auto &sensor : it._value->getSensors()) {
- if (sensor->getObjectID() == 125)
- _areaMap[it._key]->addGroupFromArea(195, _areaMap[255]);
- else if (sensor->getObjectID() == 126)
- _areaMap[it._key]->addGroupFromArea(191, _areaMap[255]);
- else if (sensor->getObjectID() == 127)
- _areaMap[it._key]->addGroupFromArea(182, _areaMap[255]);
- else
- debugC(1, kFreescapeDebugParser, "Sensor %d in area %d", sensor->getObjectID(), it._key);
- }
- }
- // CPC
- // file = gameDir.createReadStreamForMember("cm.bin");
- // if (file == nullptr)
- // error("Failed to open cm.bin");
- // load8bitBinary(file, 0x791a, 16);
-}
-
-void CastleEngine::loadAssetsDOSDemo() {
- Common::File file;
- Common::SeekableReadStream *stream = nullptr;
-
- if (_renderMode == Common::kRenderEGA) {
- _viewArea = Common::Rect(40, 33, 280, 152);
-
- file.open("CMLE.DAT");
- _title = load8bitBinImage(&file, 0x0);
- _title->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- file.open("CMOE.DAT");
- _option = load8bitBinImage(&file, 0x0);
- _option->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- file.open("CME.DAT");
- _border = load8bitBinImage(&file, 0x0);
- _border->setPalette((byte *)&kEGADefaultPalette, 0, 16);
- file.close();
-
- stream = decryptFile("CMLD"); // Only english
-
- loadFonts(kFreescapeCastleFont, 59);
- loadMessagesVariableSize(stream, 0x11, 164);
- delete stream;
-
- stream = decryptFile("CDEDF");
- load8bitBinary(stream, 0, 16);
- for (auto &it : _areaMap)
- it._value->addStructure(_areaMap[255]);
-
- _areaMap[2]->addFloor();
- delete stream;
- } else
- error("Not implemented yet");
-}
-
-void CastleEngine::loadAssetsAmigaDemo() {
- Common::File file;
- file.open("x");
- if (!file.isOpen())
- error("Failed to open 'x' file");
-
- loadMessagesVariableSize(&file, 0x8bb2, 164);
- load8bitBinary(&file, 0x162a6, 16);
- loadPalettes(&file, 0x151a6);
-
- file.seek(0x2be96); // Area 255
- _areaMap[255] = load8bitArea(&file, 16);
- file.close();
-
-
- _areaMap[2]->_groundColor = 1;
- for (auto &it : _areaMap)
- it._value->addStructure(_areaMap[255]);
-
- _areaMap[1]->addFloor();
- _areaMap[2]->addFloor();
-}
-
-
void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
debugC(1, kFreescapeDebugMove, "Jumping to area: %d, entrance: %d", areaID, entranceID);
@@ -320,32 +153,6 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
resetInput();
}
-void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
- uint32 color = 10;
- uint8 r, g, b;
-
- _gfx->readFromPalette(color, r, g, b);
- uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
-
- color = 0;
-
- _gfx->readFromPalette(color, r, g, b);
- uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
-
- Common::Rect backRect(97, 181, 232, 190);
- surface->fillRect(backRect, back);
-
- Common::String message;
- int deadline;
- getLatestMessages(message, deadline);
- if (deadline <= _countdown) {
- drawStringInSurface(message, 97, 182, front, back, surface);
- _temporaryMessages.push_back(message);
- _temporaryMessageDeadlines.push_back(deadline);
- } else
- drawStringInSurface(_currentArea->_name, 97, 182, front, back, surface);
-}
-
void CastleEngine::initGameState() {
FreescapeEngine::initGameState();
_playerHeightNumber = 1;
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index b675ed057be..d127b9b2f6e 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -43,4 +43,6 @@ private:
Common::SeekableReadStream *decryptFile(const Common::Path &filename);
};
+extern byte kFreescapeCastleFont[];
+
}
\ No newline at end of file
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
new file mode 100644
index 00000000000..d9243f89b46
--- /dev/null
+++ b/engines/freescape/games/castle/dos.cpp
@@ -0,0 +1,201 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "common/memstream.h"
+
+#include "freescape/freescape.h"
+#include "freescape/games/castle/castle.h"
+#include "freescape/language/8bitDetokeniser.h"
+
+namespace Freescape {
+
+Common::SeekableReadStream *CastleEngine::decryptFile(const Common::Path &filename) {
+ Common::File file;
+ file.open(filename);
+ if (!file.isOpen())
+ error("Failed to open %s", filename.toString().c_str());
+
+ int size = file.size();
+ byte *encryptedBuffer = (byte *)malloc(size);
+ file.read(encryptedBuffer, size);
+ file.close();
+
+ int seed = 24;
+ for (int i = 0; i < size; i++) {
+ encryptedBuffer[i] ^= seed;
+ seed = (seed + 1) & 0xff;
+ }
+
+ return (new Common::MemoryReadStream(encryptedBuffer, size));
+}
+
+extern byte kEGADefaultPalette[16][3];
+extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
+
+void CastleEngine::loadAssetsDOSFullGame() {
+ Common::File file;
+ Common::SeekableReadStream *stream = nullptr;
+
+ if (_renderMode == Common::kRenderEGA) {
+ _viewArea = Common::Rect(40, 33, 280, 152);
+
+ file.open("CME.EXE");
+ stream = unpackEXE(file);
+ if (stream) {
+ loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
+ }
+
+ delete stream;
+ file.close();
+
+ file.open("CMLE.DAT");
+ _title = load8bitBinImage(&file, 0x0);
+ _title->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ file.open("CMOE.DAT");
+ _option = load8bitBinImage(&file, 0x0);
+ _option->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ file.open("CME.DAT");
+ _border = load8bitBinImage(&file, 0x0);
+ _border->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ switch (_language) {
+ case Common::ES_ESP:
+ stream = decryptFile("CMLS");
+ break;
+ case Common::FR_FRA:
+ stream = decryptFile("CMLF");
+ break;
+ case Common::DE_DEU:
+ stream = decryptFile("CMLG");
+ break;
+ case Common::EN_ANY:
+ stream = decryptFile("CMLE");
+ break;
+ default:
+ error("Invalid or unsupported language: %x", _language);
+ }
+
+ loadFonts(kFreescapeCastleFont, 59);
+ loadMessagesVariableSize(stream, 0x11, 164);
+ delete stream;
+
+ stream = decryptFile("CMEDF");
+ load8bitBinary(stream, 0, 16);
+ for (auto &it : _areaMap)
+ it._value->addStructure(_areaMap[255]);
+
+ _areaMap[1]->addFloor();
+ _areaMap[2]->addFloor();
+ delete stream;
+ } else
+ error("Not implemented yet");
+
+ for (auto &it : _areaMap) {
+ for (auto &sensor : it._value->getSensors()) {
+ if (sensor->getObjectID() == 125)
+ _areaMap[it._key]->addGroupFromArea(195, _areaMap[255]);
+ else if (sensor->getObjectID() == 126)
+ _areaMap[it._key]->addGroupFromArea(191, _areaMap[255]);
+ else if (sensor->getObjectID() == 127)
+ _areaMap[it._key]->addGroupFromArea(182, _areaMap[255]);
+ else
+ debugC(1, kFreescapeDebugParser, "Sensor %d in area %d", sensor->getObjectID(), it._key);
+ }
+ }
+ // CPC
+ // file = gameDir.createReadStreamForMember("cm.bin");
+ // if (file == nullptr)
+ // error("Failed to open cm.bin");
+ // load8bitBinary(file, 0x791a, 16);
+}
+
+void CastleEngine::loadAssetsDOSDemo() {
+ Common::File file;
+ Common::SeekableReadStream *stream = nullptr;
+
+ if (_renderMode == Common::kRenderEGA) {
+ _viewArea = Common::Rect(40, 33, 280, 152);
+
+ file.open("CMLE.DAT");
+ _title = load8bitBinImage(&file, 0x0);
+ _title->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ file.open("CMOE.DAT");
+ _option = load8bitBinImage(&file, 0x0);
+ _option->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ file.open("CME.DAT");
+ _border = load8bitBinImage(&file, 0x0);
+ _border->setPalette((byte *)&kEGADefaultPalette, 0, 16);
+ file.close();
+
+ stream = decryptFile("CMLD"); // Only english
+
+ loadFonts(kFreescapeCastleFont, 59);
+ loadMessagesVariableSize(stream, 0x11, 164);
+ delete stream;
+
+ stream = decryptFile("CDEDF");
+ load8bitBinary(stream, 0, 16);
+ for (auto &it : _areaMap)
+ it._value->addStructure(_areaMap[255]);
+
+ _areaMap[2]->addFloor();
+ delete stream;
+ } else
+ error("Not implemented yet");
+}
+
+void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
+ uint32 color = 10;
+ uint8 r, g, b;
+
+ _gfx->readFromPalette(color, r, g, b);
+ uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+ color = 0;
+
+ _gfx->readFromPalette(color, r, g, b);
+ uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+ Common::Rect backRect(97, 181, 232, 190);
+ surface->fillRect(backRect, back);
+
+ Common::String message;
+ int deadline;
+ getLatestMessages(message, deadline);
+ if (deadline <= _countdown) {
+ drawStringInSurface(message, 97, 182, front, back, surface);
+ _temporaryMessages.push_back(message);
+ _temporaryMessageDeadlines.push_back(deadline);
+ } else
+ drawStringInSurface(_currentArea->_name, 97, 182, front, back, surface);
+}
+
+} // End of namespace Freescape
diff --git a/engines/freescape/module.mk b/engines/freescape/module.mk
index e4df9695d3c..df4c96fb3e4 100644
--- a/engines/freescape/module.mk
+++ b/engines/freescape/module.mk
@@ -7,6 +7,8 @@ MODULE_OBJS := \
demo.o \
freescape.o \
games/castle/castle.o \
+ games/castle/amiga.o \
+ games/castle/dos.o \
games/dark/amiga.o \
games/dark/atari.o \
games/dark/cpc.o \
More information about the Scummvm-git-logs
mailing list