[Scummvm-git-logs] scummvm master -> 0633860a5f6202e59962341442212d8fcd551d1f
neuromancer
noreply at scummvm.org
Fri Dec 13 20:10:09 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0633860a5f FREESCAPE: better loading of cpc data from castle
Commit: 0633860a5f6202e59962341442212d8fcd551d1f
https://github.com/scummvm/scummvm/commit/0633860a5f6202e59962341442212d8fcd551d1f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-12-13T21:12:07+01:00
Commit Message:
FREESCAPE: better loading of cpc data from castle
Changed paths:
engines/freescape/games/castle/castle.cpp
engines/freescape/games/castle/cpc.cpp
engines/freescape/games/palettes.cpp
engines/freescape/gfx.cpp
engines/freescape/loaders/8bitBinaryLoader.cpp
engines/freescape/objects/sensor.cpp
engines/freescape/ui.cpp
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index c2e184a2f67..f234955ae90 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -380,8 +380,17 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
(*palette)[5][2] = 0xcc;
}
- if (isSpectrum() || isCPC())
+ if (isSpectrum())
_gfx->_paperColor = 0;
+
+ // Unclear why this is needed
+ if (isCPC()) {
+ for (int i = 0; i < 128; i++) {
+ _gfx->_stipples[2][i] = _gfx->_stipples[11][i];
+ }
+ ColorMap *cm = _gfx->_colorMap;
+ (*cm)[2] = (*cm)[11];
+ }
resetInput();
/*if (entranceID > 0) {
diff --git a/engines/freescape/games/castle/cpc.cpp b/engines/freescape/games/castle/cpc.cpp
index 3f8383899a5..be0146918a8 100644
--- a/engines/freescape/games/castle/cpc.cpp
+++ b/engines/freescape/games/castle/cpc.cpp
@@ -20,6 +20,7 @@
*/
#include "common/file.h"
+#include "common/memstream.h"
#include "freescape/freescape.h"
#include "freescape/games/castle/castle.h"
@@ -38,14 +39,67 @@ void CastleEngine::initCPC() {
_soundIndexAreaChange = 7;
}
-extern byte kCPCPaletteTitleData[4][3];
-extern byte kCPCPaletteBorderData[4][3];
+
+byte kCPCPaletteCastleTitleData[4][3] = {
+ {0x00, 0x00, 0x00},
+ {0x00, 0x00, 0xff},
+ {0xff, 0xff, 0x00},
+ {0xff, 0x00, 0x00},
+};
+
+byte kCPCPaletteCastleBorderData[4][3] = {
+ {0x00, 0x00, 0x00},
+ {0x80, 0x80, 0x80},
+ {0x00, 0x80, 0x00},
+ {0xff, 0xff, 0xff},
+};
+
+// Data for the mountains background. This is not included in the original game for some reason
+// but all the other releases have it. This is coming from the ZX Spectrum version.
+byte mountainsData[288] {
+ 0x06, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
+ 0x00, 0x00, 0x38, 0x01, 0xa0, 0x00, 0x00, 0x00,
+ 0x00, 0x1e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x17,
+ 0x80, 0x00, 0x7c, 0x03, 0xd0, 0x00, 0x00, 0x01,
+ 0x00, 0x3f, 0x5c, 0x80, 0x0, 0x18, 0x0, 0x23,
+ 0xc0, 0x00, 0xfe, 0x0d, 0xfe, 0x6, 0x00, 0x02,
+ 0x80, 0x7e, 0xbe, 0xc0, 0x0, 0x3c, 0x0, 0x47,
+ 0xe0, 0x1, 0x57, 0x56, 0xff, 0xf, 0x80, 0x5,
+ 0x40, 0xf5, 0xfb, 0x40, 0x0, 0x76, 0x0, 0x93,
+ 0xd0, 0xa, 0xab, 0xab, 0xff, 0xaf, 0xc3, 0x2a,
+ 0xa1, 0xeb, 0xfe, 0xa8, 0x0, 0xde, 0x0, 0x21,
+ 0xa8, 0x75, 0x55, 0x41, 0xff, 0xd6, 0xef, 0xd5,
+ 0x53, 0x57, 0xfc, 0x14, 0x1, 0xb7, 0x7, 0x42,
+ 0xd5, 0xea, 0xaa, 0x92, 0xfb, 0x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Common::SeekableReadStream *file, bool mode0);
void CastleEngine::loadAssetsCPCFullGame() {
Common::File file;
- //uint8 r, g, b;
+ uint8 r, g, b;
Common::Array<Graphics::ManagedSurface *> chars;
file.open("CMLOAD.BIN");
@@ -54,7 +108,7 @@ void CastleEngine::loadAssetsCPCFullGame() {
error("Failed to open CMLOAD.BIN");
_title = readCPCImage(&file, true);
- _title->setPalette((byte*)&kCPCPaletteTitleData, 0, 4);
+ _title->setPalette((byte*)&kCPCPaletteCastleTitleData, 0, 4);
file.close();
file.open("CMSCR.BIN");
@@ -63,7 +117,7 @@ void CastleEngine::loadAssetsCPCFullGame() {
error("Failed to open CMSCR.BIN");
_border = readCPCImage(&file, true);
- _border->setPalette((byte*)&kCPCPaletteTitleData, 0, 4);
+ _border->setPalette((byte*)&kCPCPaletteCastleBorderData, 0, 4);
file.close();
file.open("CM.BIN");
@@ -91,11 +145,10 @@ void CastleEngine::loadAssetsCPCFullGame() {
break;*/
case Common::EN_ANY:
- loadRiddles(&file, 0x1b7a + 1 - 4 - 2 - 2 - 9 * 2, 9);
- //assert(0);
+ loadRiddles(&file, 0x1b75 - 2 - 9 * 2, 9);
load8bitBinary(&file, 0x791a, 16);
- file.seek(0x2720);
+ file.seek(0x2724);
for (int i = 0; i < 90; i++) {
Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
surface->create(8, 8, Graphics::PixelFormat::createFormatCLUT8());
@@ -112,6 +165,18 @@ void CastleEngine::loadAssetsCPCFullGame() {
}
loadColorPalette();
+
+ int backgroundWidth = 16;
+ int backgroundHeight = 18;
+ Graphics::ManagedSurface *background = new Graphics::ManagedSurface();
+ background->create(backgroundWidth * 8, backgroundHeight, _gfx->_texturePixelFormat);
+ background->fillRect(Common::Rect(0, 0, backgroundWidth * 8, backgroundHeight), 0);
+ Common::MemoryReadStream mountainsStream(mountainsData, sizeof(mountainsData));
+
+ _gfx->readFromPalette(11, r, g, b);
+ uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+ _background = loadFrame(&mountainsStream, background, backgroundWidth, backgroundHeight, front);
/*_gfx->readFromPalette(2, r, g, b);
uint32 red = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
@@ -179,7 +244,7 @@ void CastleEngine::loadAssetsCPCFullGame() {
_riddleBottomFrame->copyFrom(*tmp);
tmp->free();
delete tmp;
- _riddleBottomFrame->convertToInPlace(_gfx->_texturePixelFormat);
+ _riddleBottomFrame->convertToInPlace(_gfx->_texturePixelFormat);*/
for (auto &it : _areaMap) {
it._value->addStructure(_areaMap[255]);
@@ -202,10 +267,38 @@ void CastleEngine::loadAssetsCPCFullGame() {
debugC(kFreescapeDebugParser, "Discarding condition %s", _conditionSources[0].c_str());
_conditions.remove_at(0);
_conditionSources.remove_at(0);
- }*/
+ }
}
void CastleEngine::drawCPCUI(Graphics::Surface *surface) {
+ uint32 color = _gfx->_paperColor;
+ //uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
+ uint8 r, g, b;
+
+ _gfx->readFromPalette(color, r, g, b);
+ uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+ color = 1;
+
+ _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 = -1;
+ getLatestMessages(message, deadline);
+ if (deadline > 0 && deadline <= _countdown) {
+ drawStringInSurface(message, 97, 182, front, back, surface);
+ _temporaryMessages.push_back(message);
+ _temporaryMessageDeadlines.push_back(deadline);
+ } else {
+ if (_gameStateControl == kFreescapeGameStatePlaying) {
+ drawStringInSurface(_currentArea->_name, 97, 182, front, back, surface);
+ }
+ }
+
/*uint32 color = 5;
uint8 r, g, b;
diff --git a/engines/freescape/games/palettes.cpp b/engines/freescape/games/palettes.cpp
index e3d7973f3e1..5be4e3a5c74 100644
--- a/engines/freescape/games/palettes.cpp
+++ b/engines/freescape/games/palettes.cpp
@@ -109,7 +109,7 @@ byte kDrillerCPCPalette[32][3] = {
{0x00, 0xff, 0xff}, // 27
{0x80, 0x00, 0x00}, // 28
{0x11, 0x22, 0x33},
- {0x11, 0x22, 0x33},
+ {0x80, 0x80, 0x00}, // 30
{0x80, 0x80, 0xff}, // 31
};
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 466ca0e9d37..d1a1cb8199f 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -143,7 +143,7 @@ void Renderer::clearColorPairArray() {
}
void Renderer::fillColorPairArray() {
- for (int i = 4; i < 15; i++) {
+ for (int i = 0; i < 15; i++) {
byte *entry = (*_colorMap)[i];
int c1;
if (_renderMode == Common::kRenderCGA)
@@ -452,24 +452,8 @@ bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
stipple = nullptr;
return true;
}
- readFromPalette(index, r1, g1, b1);
- r2 = r1;
- g2 = g1;
- b2 = b1;
- stipple = nullptr;
- return true;
}
-
assert (_renderMode == Common::kRenderCPC);
- if (index <= 4) { // Solid colors
- selectColorFromFourColorPalette(index - 1, r1, g1, b1);
- r2 = r1;
- g2 = g1;
- b2 = b1;
- stipple = nullptr;
- return true;
- }
-
stipple = (byte *)_stipples[index - 1];
byte *entry = (*_colorMap)[index - 1];
uint8 i1 = getCPCPixel(entry[0], 0, true);
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index d75d0db83b1..9150774bd65 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -633,8 +633,13 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
} else {
uint8 attribute = readField(file, 8);
debugC(1, kFreescapeDebugParser, "Attribute: %x", attribute);
- paperColor = attribute >> 4;
- inkColor = attribute & 0xf;
+ if (isSpectrum()) {
+ paperColor = attribute >> 4;
+ inkColor = attribute & 0xf;
+ } else if (isCPC()) {
+ paperColor = attribute;
+ inkColor = 0xb;
+ }
skyColor = 0;
}
diff --git a/engines/freescape/objects/sensor.cpp b/engines/freescape/objects/sensor.cpp
index c9430e27e13..427bb131180 100644
--- a/engines/freescape/objects/sensor.cpp
+++ b/engines/freescape/objects/sensor.cpp
@@ -38,16 +38,14 @@ Sensor::Sensor(
_origin = origin_;
_rotation = rotation_;
- if (axis_ == 0)
- _size = Math::Vector3d(3, 3, 3);
- else if (axis_ == 0x01 || axis_ == 0x02)
+ if (axis_ == 0x01 || axis_ == 0x02)
_size = Math::Vector3d(0, 3, 3);
else if (axis_ == 0x04 || axis_ == 0x08)
_size = Math::Vector3d(3, 0, 3);
else if (axis_ == 0x10 || axis_ == 0x20)
_size = Math::Vector3d(3, 3, 0);
else
- error("Invalid axis %x", axis_);
+ _size = Math::Vector3d(3, 3, 3);
_colours = new Common::Array<uint8>;
for (int i = 0; i < 6; i++)
_colours->push_back(color_);
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index 3e3a3ac4269..5837cf773cb 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -188,7 +188,7 @@ void FreescapeEngine::borderScreen() {
return;
}
- if (isDOS() || isSpectrum()) {
+ if (isDOS() || isSpectrum() || isCPC()) {
Common::Array<Common::String> lines;
int pad = 25;
if (isDOS()) {
@@ -205,8 +205,8 @@ void FreescapeEngine::borderScreen() {
lines.push_back(centerAndPadString("SPACEBAR: BEGIN MISSION", pad));
lines.push_back("");
lines.push_back(centerAndPadString("COPYRIGHT 1988 INCENTIVE", pad));
- } else if (isSpectrum()) {
- if (isSpectrum() && isCastle())
+ } else if (isSpectrum() || isCPC()) {
+ if (isCastle())
pad = 22;
if (_language == Common::ES_ESP) {
More information about the Scummvm-git-logs
mailing list