[Scummvm-git-logs] scummvm master -> 4071d023fb95d22b64d234255a4a6ede8856edcb
athrxx
noreply at scummvm.org
Mon Jul 1 17:28:29 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:
4071d023fb SCI: (CGA/Hercules) - add argument for cropped Hercules image
Commit: 4071d023fb95d22b64d234255a4a6ede8856edcb
https://github.com/scummvm/scummvm/commit/4071d023fb95d22b64d234255a4a6ede8856edcb
Author: athrxx (athrxx at scummvm.org)
Date: 2024-07-01T19:27:24+02:00
Commit Message:
SCI: (CGA/Hercules) - add argument for cropped Hercules image
This is an idea that came up in the PR. It will remove the black border in
Hercules mode. Currently, there is no other way to enable it except in the
code. It could be added as a launcher option, but having a checkbox just
for the case where Hercules mode is enabled might be a bit too much.
I also turned the monochrome colors into an argument to make it more
flexible.
Changed paths:
engines/sci/graphics/gfxdrivers.cpp
engines/sci/graphics/gfxdrivers.h
engines/sci/graphics/screen.cpp
diff --git a/engines/sci/graphics/gfxdrivers.cpp b/engines/sci/graphics/gfxdrivers.cpp
index 0d922517f0c..1747143a8bf 100644
--- a/engines/sci/graphics/gfxdrivers.cpp
+++ b/engines/sci/graphics/gfxdrivers.cpp
@@ -295,11 +295,12 @@ const byte *monochrInit(const char *drvFile, bool &earlyVersion) {
return result;
}
-SCI0_CGABWDriver::SCI0_CGABWDriver() : SCI0_DOSPreVGADriver(2, 640, 400, 1), _monochromePatterns(nullptr), _earlyVersion(false) {
- static const byte monochromePalette[6] = {
- 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF
- };
- assignPalette(monochromePalette);
+SCI0_CGABWDriver::SCI0_CGABWDriver(uint32 monochromeColor) : SCI0_DOSPreVGADriver(2, 640, 400, 1), _monochromePatterns(nullptr), _earlyVersion(false) {
+ _monochromePalette[0] = _monochromePalette[1] = _monochromePalette[2] = 0;
+ _monochromePalette[3] = (monochromeColor >> 16) & 0xff;
+ _monochromePalette[4] = (monochromeColor >> 8) & 0xff;
+ _monochromePalette[5] = monochromeColor & 0xff;
+ assignPalette(_monochromePalette);
if (!(_monochromePatterns = monochrInit(_driverFiles[0], _earlyVersion)) && !(_monochromePatterns = monochrInit(_driverFiles[1], _earlyVersion)))
error("Failed to open '%s' or '%s'", _driverFiles[0], _driverFiles[1]);
@@ -391,14 +392,13 @@ void SCI0_CGABWDriver::clearRect(const Common::Rect &r) const {
const char *SCI0_CGABWDriver::_driverFiles[2] = { "CGA320BW.DRV", "CGA320M.DRV" };
-SCI0_HerculesDriver::SCI0_HerculesDriver(int palIndex) : SCI0_DOSPreVGADriver(2, 720, 350, 0), _monochromePatterns(nullptr) {
- static const byte monochromePalettes[3][6] = {
- { 0x00, 0x00, 0x00, 0xFF, 0xBF, 0x66 }, // Amber
- { 0x00, 0x00, 0x00, 0x66, 0xFF, 0x66 }, // Green
- { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF } // B/W
- };
- assert(palIndex >= 0 && palIndex <= 2);
- assignPalette(monochromePalettes[palIndex]);
+SCI0_HerculesDriver::SCI0_HerculesDriver(uint32 monochromeColor, bool cropImage) : SCI0_DOSPreVGADriver(2, cropImage ? 640 : 720, cropImage ? 300 : 350, 0),
+ _centerX(cropImage ? 0 : 40), _centerY(cropImage ? 0 : 25), _monochromePatterns(nullptr) {
+ _monochromePalette[0] = _monochromePalette[1] = _monochromePalette[2] = 0;
+ _monochromePalette[3] = (monochromeColor >> 16) & 0xff;
+ _monochromePalette[4] = (monochromeColor >> 8) & 0xff;
+ _monochromePalette[5] = monochromeColor & 0xff;
+ assignPalette(_monochromePalette);
bool unused = false;
if (!(_monochromePatterns = monochrInit(_driverFile, unused)))
@@ -444,7 +444,7 @@ void SCI0_HerculesDriver::copyRectToScreen(const byte *src, int pitch, int x, in
}
}
- g_system->copyRectToScreen(_compositeBuffer, w << 1, (x << 1) + 40, y + 25, w << 1, rh);
+ g_system->copyRectToScreen(_compositeBuffer, w << 1, (x << 1) + _centerX, y + _centerY, w << 1, rh);
}
void SCI0_HerculesDriver::replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) {
@@ -478,13 +478,13 @@ void SCI0_HerculesDriver::replaceCursor(const void *cursor, uint w, uint h, int
Common::Point SCI0_HerculesDriver::getMousePos() const {
Common::Point res = GfxDriver::getMousePos();
- res.x = CLIP<int>(res.x - 40, 0, 639) >> 1;
- res.y = CLIP<int>(res.y - 25, 0, 299) * 2 / 3;
+ res.x = CLIP<int>(res.x - _centerX, 0, 639) >> 1;
+ res.y = CLIP<int>(res.y - _centerY, 0, 299) * 2 / 3;
return res;
}
void SCI0_HerculesDriver::clearRect(const Common::Rect &r) const {
- Common::Rect r2((r.left << 1) + 40, (r.top & ~1) * 3 / 2 + (r.top & 1) + 25, (r.right << 1) + 40, (r.bottom & ~1) * 3 / 2 + (r.bottom & 1) + 25);
+ Common::Rect r2((r.left << 1) + _centerX, (r.top & ~1) * 3 / 2 + (r.top & 1) + _centerY, (r.right << 1) + 40, (r.bottom & ~1) * 3 / 2 + (r.bottom & 1) + 25);
GfxDriver::clearRect(r2);
}
diff --git a/engines/sci/graphics/gfxdrivers.h b/engines/sci/graphics/gfxdrivers.h
index 03cff4c6e3c..89010329671 100644
--- a/engines/sci/graphics/gfxdrivers.h
+++ b/engines/sci/graphics/gfxdrivers.h
@@ -91,7 +91,7 @@ private:
class SCI0_CGABWDriver final : public SCI0_DOSPreVGADriver {
public:
- SCI0_CGABWDriver();
+ SCI0_CGABWDriver(uint32 monochromeColor);
~SCI0_CGABWDriver() override;
void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
@@ -99,6 +99,7 @@ public:
void clearRect(const Common::Rect &r) const override;
static bool validateMode() { return checkDriver(_driverFiles, 2); }
private:
+ byte _monochromePalette[6];
const byte *_monochromePatterns;
bool _earlyVersion;
static const char *_driverFiles[2];
@@ -106,7 +107,7 @@ private:
class SCI0_HerculesDriver final : public SCI0_DOSPreVGADriver {
public:
- SCI0_HerculesDriver(int palIndex);
+ SCI0_HerculesDriver(uint32 monochromeColor, bool cropImage);
~SCI0_HerculesDriver() override;
void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) override;
void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
@@ -114,6 +115,9 @@ public:
void clearRect(const Common::Rect &r) const override;
static bool validateMode() { return checkDriver(&_driverFile, 1); }
private:
+ const uint16 _centerX;
+ const uint16 _centerY;
+ byte _monochromePalette[6];
const byte *_monochromePatterns;
static const char *_driverFile;
};
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 4577630ff3b..532aa065351 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -155,11 +155,11 @@ GfxScreen::GfxScreen(ResourceManager *resMan, Common::RenderMode renderMode) : _
_gfxDrv = new SCI0_CGADriver(false);
break;
case Common::kRenderCGA_BW:
- _gfxDrv = new SCI0_CGABWDriver();
+ _gfxDrv = new SCI0_CGABWDriver(0xffffff);
break;
case Common::kRenderHercA:
case Common::kRenderHercG:
- _gfxDrv = new SCI0_HerculesDriver(renderMode == Common::kRenderHercG ? 1 : 0);
+ _gfxDrv = new SCI0_HerculesDriver(renderMode == Common::kRenderHercG ? 0x66ff66 : 0xffbf66, false);
break;
default:
break;
More information about the Scummvm-git-logs
mailing list