[Scummvm-git-logs] scummvm master -> 53547384a78f2b85d3975ac765d56324bafc0122
mduggan
noreply at scummvm.org
Sat Feb 1 00:25:23 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0fc24869f6 DGDS: Refactor to use references more
53547384a7 DGDS: Fix EGA palette loading for Heart of China
Commit: 0fc24869f6872892828eddd7bc3afe2918799221
https://github.com/scummvm/scummvm/commit/0fc24869f6872892828eddd7bc3afe2918799221
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-02-01T11:24:43+11:00
Commit Message:
DGDS: Refactor to use references more
Changed paths:
engines/dgds/dgds.cpp
engines/dgds/head.cpp
engines/dgds/head.h
engines/dgds/scene.cpp
engines/dgds/scene.h
diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 1b453d9d378..c9875d36cd3 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -775,17 +775,17 @@ Common::Error DgdsEngine::run() {
bool haveActiveDialog = _scene->checkDialogActive();
if (_debugShowHotAreas)
- _scene->drawDebugHotAreas(&_compositionBuffer);
+ _scene->drawDebugHotAreas(_compositionBuffer);
if (getGameId() == GID_WILLY) {
if (!justChangedScene1())
- _scene->drawAndUpdateHeads(&_compositionBuffer);
+ _scene->drawAndUpdateHeads(_compositionBuffer);
_scene->drawAndUpdateDialogs(&_compositionBuffer);
_scene->updateHotAreasFromDynamicRects();
} else {
_scene->drawAndUpdateDialogs(&_compositionBuffer);
if (!justChangedScene1())
- _scene->drawAndUpdateHeads(&_compositionBuffer);
+ _scene->drawAndUpdateHeads(_compositionBuffer);
}
dumpFrame(_compositionBuffer, "comp-with-dlg");
diff --git a/engines/dgds/head.cpp b/engines/dgds/head.cpp
index ba129c3a569..67e02a4193f 100644
--- a/engines/dgds/head.cpp
+++ b/engines/dgds/head.cpp
@@ -32,7 +32,7 @@
namespace Dgds {
-void TalkDataHead::drawHead(Graphics::ManagedSurface *dst, const TalkData &data) const {
+void TalkDataHead::drawHead(Graphics::ManagedSurface &dst, const TalkData &data) const {
uint drawtype = _drawType ? _drawType : 1;
// Use specific head shape if available (eg, in Willy Beamish), if not use talk data shape
Common::SharedPtr<Image> img = _shape;
@@ -58,40 +58,40 @@ void TalkDataHead::drawHead(Graphics::ManagedSurface *dst, const TalkData &data)
}
}
-void TalkDataHead::drawHeadType1(Graphics::ManagedSurface *dst, const Image &img) const {
+void TalkDataHead::drawHeadType1(Graphics::ManagedSurface &dst, const Image &img) const {
Common::Rect r = _rect.toCommonRect();
- dst->fillRect(r, _drawCol);
+ dst.fillRect(r, _drawCol);
r.grow(-1);
- dst->fillRect(r, _drawCol == 0 ? 15 : 0);
+ dst.fillRect(r, _drawCol == 0 ? 15 : 0);
r.left += 2;
r.top += 2;
const int x = _rect.x;
const int y = _rect.y;
if (img.isLoaded()) {
for (const auto &frame : _headFrames) {
- img.drawBitmap(frame._frameNo & 0xff, x + frame._xoff, y + frame._yoff, r, *dst);
+ img.drawBitmap(frame._frameNo & 0xff, x + frame._xoff, y + frame._yoff, r, dst);
}
}
}
-void TalkDataHead::drawHeadType2(Graphics::ManagedSurface *dst, const Image &img) const {
+void TalkDataHead::drawHeadType2(Graphics::ManagedSurface &dst, const Image &img) const {
if (!img.isLoaded())
return;
const Common::Rect r = _rect.toCommonRect();
for (const auto &frame : _headFrames) {
- img.drawBitmap(frame._frameNo & 0xff, r.left + frame._xoff, r.top + frame._yoff, r, *dst);
+ img.drawBitmap(frame._frameNo & 0xff, r.left + frame._xoff, r.top + frame._yoff, r, dst);
}
}
-void TalkDataHead::drawHeadType3Beamish(Graphics::ManagedSurface *dst, const TalkData &data) const {
+void TalkDataHead::drawHeadType3Beamish(Graphics::ManagedSurface &dst, const TalkData &data) const {
const Common::Rect r = _rect.toCommonRect();
// Note: only really need the 1px border here but just fill the box.
- dst->fillRect(r, 8);
+ dst.fillRect(r, 8);
Common::Rect fillRect(r);
fillRect.grow(-1);
- dst->fillRect(fillRect, _drawCol);
+ dst.fillRect(fillRect, _drawCol);
for (const auto &frame : _headFrames) {
int frameNo = frame._frameNo & 0x7fff;
@@ -109,21 +109,21 @@ void TalkDataHead::drawHeadType3Beamish(Graphics::ManagedSurface *dst, const Tal
if (frame._flipFlags & 2)
flip = static_cast<ImageFlipMode>(flip & kImageFlipV);
- img->drawBitmap(frameNo, r.left + frame._xoff, r.top + frame._yoff, fillRect, *dst);
+ img->drawBitmap(frameNo, r.left + frame._xoff, r.top + frame._yoff, fillRect, dst);
}
}
-void TalkDataHead::drawHeadType3(Graphics::ManagedSurface *dst, const Image &img) const {
+void TalkDataHead::drawHeadType3(Graphics::ManagedSurface &dst, const Image &img) const {
Common::Rect r = _rect.toCommonRect();
- dst->fillRect(r, 0);
+ dst.fillRect(r, 0);
if (!img.isLoaded())
return;
for (const auto &frame : _headFrames) {
int frameNo = frame._frameNo;
if (frameNo < img.loadedFrameCount())
- img.drawBitmap(frameNo, r.left + frame._xoff, r.top + frame._yoff, r, *dst);
+ img.drawBitmap(frameNo, r.left + frame._xoff, r.top + frame._yoff, r, dst);
else
- dst->fillRect(r, 4);
+ dst.fillRect(r, 4);
}
}
@@ -152,7 +152,7 @@ void TalkData::clearVisibleHeads() {
}
}
-void TalkData::drawAndUpdateVisibleHeads(Graphics::ManagedSurface *dst) {
+void TalkData::drawAndUpdateVisibleHeads(Graphics::ManagedSurface &dst) {
for (auto &h : _heads) {
if (h._flags & kHeadFlagVisible) {
if (!(h._flags & kHeadFlagOpening)) {
diff --git a/engines/dgds/head.h b/engines/dgds/head.h
index 5446945cdf8..2e5517e122a 100644
--- a/engines/dgds/head.h
+++ b/engines/dgds/head.h
@@ -72,11 +72,11 @@ public:
void clearHead();
- void drawHead(Graphics::ManagedSurface *dst, const TalkData &data) const;
- void drawHeadType1(Graphics::ManagedSurface *dst, const Image &img) const;
- void drawHeadType2(Graphics::ManagedSurface *dst, const Image &img) const;
- void drawHeadType3(Graphics::ManagedSurface *dst, const Image &img) const;
- void drawHeadType3Beamish(Graphics::ManagedSurface *dst, const TalkData &data) const;
+ void drawHead(Graphics::ManagedSurface &dst, const TalkData &data) const;
+ void drawHeadType1(Graphics::ManagedSurface &dst, const Image &img) const;
+ void drawHeadType2(Graphics::ManagedSurface &dst, const Image &img) const;
+ void drawHeadType3(Graphics::ManagedSurface &dst, const Image &img) const;
+ void drawHeadType3Beamish(Graphics::ManagedSurface &dst, const TalkData &data) const;
uint16 _num;
uint16 _drawType;
@@ -101,7 +101,7 @@ public:
Common::String _bmpFile;
void clearVisibleHeads();
- void drawAndUpdateVisibleHeads(Graphics::ManagedSurface *dst);
+ void drawAndUpdateVisibleHeads(Graphics::ManagedSurface &dst);
bool hasVisibleHead() const;
};
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 32d72ce6fe9..ce0a9a3b095 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -877,7 +877,7 @@ void SDSScene::clearVisibleTalkers() {
}
}
-void SDSScene::drawAndUpdateHeads(Graphics::ManagedSurface *dst) {
+void SDSScene::drawAndUpdateHeads(Graphics::ManagedSurface &dst) {
for (auto &tds : _talkData) {
tds.drawAndUpdateVisibleHeads(dst);
}
@@ -1680,7 +1680,7 @@ void SDSScene::activateChoice() {
_shouldClearDlg = true;
}
-void SDSScene::drawDebugHotAreas(Graphics::ManagedSurface *dst) const {
+void SDSScene::drawDebugHotAreas(Graphics::ManagedSurface &dst) const {
const DgdsPal &pal = DgdsEngine::getInstance()->getGamePals()->getCurPal();
byte redish = pal.findBestColor(0xff, 0, 0);
byte greenish = pal.findBestColor(0, 0xff, 0);
@@ -1690,10 +1690,10 @@ void SDSScene::drawDebugHotAreas(Graphics::ManagedSurface *dst) const {
uint32 color = enabled ? greenish : redish;
g_system->getPaletteManager();
const Common::Rect &r = area._rect.toCommonRect();
- dst->drawLine(r.left, r.top, r.right, r.top, color);
- dst->drawLine(r.left, r.top, r.left, r.bottom, color);
- dst->drawLine(r.left, r.bottom, r.right, r.bottom, color);
- dst->drawLine(r.right, r.top, r.right, r.bottom, color);
+ dst.drawLine(r.left, r.top, r.right, r.top, color);
+ dst.drawLine(r.left, r.top, r.left, r.bottom, color);
+ dst.drawLine(r.left, r.bottom, r.right, r.bottom, color);
+ dst.drawLine(r.right, r.top, r.right, r.bottom, color);
}
}
diff --git a/engines/dgds/scene.h b/engines/dgds/scene.h
index ed0f35a1e1e..fced475bbcf 100644
--- a/engines/dgds/scene.h
+++ b/engines/dgds/scene.h
@@ -321,7 +321,7 @@ public:
bool freeTalkData(uint16 num);
void clearVisibleTalkers();
bool loadTalkDataAndSetFlags(uint16 talknum, uint16 headnum);
- void drawAndUpdateHeads(Graphics::ManagedSurface *dst);
+ void drawAndUpdateHeads(Graphics::ManagedSurface &dst);
bool hasVisibleHead() const;
// dragon-specific scene ops
@@ -338,7 +338,7 @@ public:
void updateHotAreasFromDynamicRects();
void setDynamicSceneRect(int16 num, int16 x, int16 y, int16 width, int16 height);
void setSceneNum(int16 num) { _num = num; }
- void drawDebugHotAreas(Graphics::ManagedSurface *dst) const;
+ void drawDebugHotAreas(Graphics::ManagedSurface &dst) const;
void setIgnoreMouseUp() { _ignoreMouseUp = true; }
void setShouldClearDlg() { _shouldClearDlg = true; }
Commit: 53547384a78f2b85d3975ac765d56324bafc0122
https://github.com/scummvm/scummvm/commit/53547384a78f2b85d3975ac765d56324bafc0122
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-02-01T11:24:43+11:00
Commit Message:
DGDS: Fix EGA palette loading for Heart of China
Changed paths:
engines/dgds/game_palettes.cpp
diff --git a/engines/dgds/game_palettes.cpp b/engines/dgds/game_palettes.cpp
index c6998c2a5eb..53608762831 100644
--- a/engines/dgds/game_palettes.cpp
+++ b/engines/dgds/game_palettes.cpp
@@ -20,6 +20,7 @@
*/
#include "common/system.h"
+#include "common/debug.h"
#include "graphics/paletteman.h"
#include "dgds/game_palettes.h"
@@ -29,21 +30,11 @@
namespace Dgds {
static const byte EGA_COLORS[16][3] = {
- { 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 },
+ { 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 },
};
@@ -78,6 +69,8 @@ int GamePalettes::loadPalette(const Common::String &filename) {
if (chunk.isSection(ID_PAL)) {
assert(chunk.isContainer());
} else if (chunk.isSection(ID_VGA)) {
+ if (chunk.getSize() != 768)
+ error("VGA palette in %s should be 768 bytes long, got %d", filename.c_str(), chunk.getSize());
for (uint k = 0; k < 256; k++) {
byte r = chunkStream->readByte() << 2;
byte g = chunkStream->readByte() << 2;
@@ -87,6 +80,7 @@ int GamePalettes::loadPalette(const Common::String &filename) {
break;
} else if (chunk.isSection(ID_EGA)) {
if (chunk.getSize() > 20) {
+ // Dragon style EGA palette
for (uint k = 0; k < chunk.getSize() / 2; k++) {
byte egaCol = (chunkStream->readUint16LE() & 0xF);
byte r = EGA_COLORS[egaCol][0];
@@ -95,17 +89,22 @@ int GamePalettes::loadPalette(const Common::String &filename) {
pal.set(k, r, g, b);
}
} else {
- for (uint k = 0; k < chunk.getSize(); k++) {
+ // HoC style EGA palette
+ for (uint k = 0; k < MIN(chunk.getSize(), (uint32)16); k++) {
byte egaCol = (chunkStream->readByte());
- byte r = EGA_COLORS[egaCol][0];
- byte g = EGA_COLORS[egaCol][1];
- byte b = EGA_COLORS[egaCol][2];
+ // For some reason bit 5 means bit 4 as
+ // offset into the palette
+ if (egaCol & 0x10)
+ egaCol -= 8;
+ byte r = EGA_COLORS[egaCol % 16][0];
+ byte g = EGA_COLORS[egaCol % 16][1];
+ byte b = EGA_COLORS[egaCol % 16][2];
pal.set(k, r, g, b);
}
}
break;
} else if (chunk.isSection(ID_CGA)) {
- warning("Skipping CGA palette data");
+ debug(1, "Skipping CGA palette data");
} else {
error("Unknown Palette chunk in %s: %s size %d", filename.c_str(), chunk.getIdStr(), chunk.getSize());
}
More information about the Scummvm-git-logs
mailing list