[Scummvm-git-logs] scummvm master -> 278a2b300a798b91c4021ec32ff955e372fa100c
bluegr
noreply at scummvm.org
Wed Apr 15 07:37:03 UTC 2026
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
73ffccb453 HDB: Support running with different pixel formats
766cac2402 HDB: Make use of simpleBlitFrom()
278a2b300a HDB: Use Graphic::Screen for tracking updates to _globalSurface
Commit: 73ffccb453cb7f5ed58c9054424389c278a485c9
https://github.com/scummvm/scummvm/commit/73ffccb453cb7f5ed58c9054424389c278a485c9
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-15T10:36:56+03:00
Commit Message:
HDB: Support running with different pixel formats
Changed paths:
engines/hdb/gfx.cpp
engines/hdb/gfx.h
engines/hdb/hdb.cpp
engines/hdb/hdb.h
engines/hdb/menu.cpp
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 82e99e81359..10654c7dcbd 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -40,7 +40,7 @@ Gfx::Gfx() {
_tLookupArray = nullptr;
_starsInfo.active = false;
_gfxCache = new Common::Array<GfxCache *>;
- _globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
+ _globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_screenFormat);
_pointerDisplayable = 1;
_sines = new Math::SineTable(360);
_cosines = new Math::CosineTable(360);
@@ -196,8 +196,8 @@ void Gfx::init() {
_eBottom = g_hdb->_screenHeight;
// Need two main memory screen-sized surfaces for screen fading
- _fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
- _fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
+ _fadeBuffer1.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_screenFormat);
+ _fadeBuffer2.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_screenFormat);
// Load Game Font
if (!loadFont(HDB_FONT))
@@ -351,7 +351,8 @@ double Gfx::getCos(int index) {
return _cosines->at(index);
}
-void Gfx::fillScreen(uint32 color) {
+void Gfx::fillScreen() {
+ uint32 color = _globalSurface.format.RGBToColor(0, 0, 0);
_globalSurface.fillRect(Common::Rect(g_hdb->_screenWidth, g_hdb->_screenHeight), color);
g_system->fillScreen(color);
}
@@ -418,6 +419,45 @@ void Gfx::setFade(bool fadeIn, bool black, int steps) {
_fadeInfo.active = true;
}
+template<typename T>
+static void doFadeBlack(Graphics::ManagedSurface &fadeBuffer, int curStep) {
+ // Black fade
+ for (int y = 0; y < fadeBuffer.h; y++) {
+ T *ptr = (T *)fadeBuffer.getBasePtr(0, y);
+ for (int x = 0; x < fadeBuffer.w; x++) {
+ T value = *ptr;
+ if (value) {
+ uint8 r, g, b;
+ fadeBuffer.format.colorToRGB(value, r, g, b);
+ r = (r * curStep) >> 8;
+ g = (g * curStep) >> 8;
+ b = (b * curStep) >> 8;
+ *ptr = fadeBuffer.format.RGBToColor(r, g, b);
+ }
+ ptr++;
+ }
+ }
+}
+
+template<typename T>
+static void doFadeWhite(Graphics::ManagedSurface &fadeBuffer, int curStep) {
+ // White fade
+ for (int y = 0; y < fadeBuffer.h; y++) {
+ T *ptr = (T *)fadeBuffer.getBasePtr(0, y);
+ for (int x = 0; x < fadeBuffer.w; x++) {
+ T value = *ptr;
+
+ uint8 r, g, b;
+ fadeBuffer.format.colorToRGB(value, r, g, b);
+ r += (255 - r) * (256 - curStep) / 256;
+ g += (255 - g) * (256 - curStep) / 256;
+ b += (255 - b) * (256 - curStep) / 256;
+ *ptr = fadeBuffer.format.RGBToColor(r, g, b);
+ ptr++;
+ }
+ }
+}
+
void Gfx::updateFade() {
if (!_fadeInfo.active && !_fadeInfo.stayFaded)
return;
@@ -427,39 +467,15 @@ void Gfx::updateFade() {
if (g_hdb->isPPC()) {
if (!_fadeInfo.isBlack) {
- // Black fade
- for (int y = 0; y < g_hdb->_screenHeight; y++) {
- uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
- for (int x = 0; x < g_hdb->_screenWidth; x++) {
- uint16 value = *ptr;
- if (value) {
- uint8 r, g, b;
- g_hdb->_format.colorToRGB(value, r, g, b);
- r = (r * _fadeInfo.curStep) >> 8;
- g = (g * _fadeInfo.curStep) >> 8;
- b = (b * _fadeInfo.curStep) >> 8;
- *ptr = g_hdb->_format.RGBToColor(r, g, b);
- }
- ptr++;
- }
- }
-
+ if (_fadeBuffer1.format.bytesPerPixel == 2)
+ doFadeBlack<uint16>(_fadeBuffer1, _fadeInfo.curStep);
+ else if (_fadeBuffer1.format.bytesPerPixel == 4)
+ doFadeBlack<uint32>(_fadeBuffer1, _fadeInfo.curStep);
} else {
- // White fade
- for (int y = 0; y < g_hdb->_screenHeight; y++) {
- uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
- for (int x = 0; x < g_hdb->_screenWidth; x++) {
- uint16 value = *ptr;
-
- uint8 r, g, b;
- g_hdb->_format.colorToRGB(value, r, g, b);
- r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
- g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
- b += (255 - b) * (256 - _fadeInfo.curStep) / 256;
- *ptr = g_hdb->_format.RGBToColor(r, g, b);
- ptr++;
- }
- }
+ if (_fadeBuffer1.format.bytesPerPixel == 2)
+ doFadeWhite<uint16>(_fadeBuffer1, _fadeInfo.curStep);
+ else if (_fadeBuffer1.format.bytesPerPixel == 4)
+ doFadeWhite<uint32>(_fadeBuffer1, _fadeInfo.curStep);
}
if (_fadeInfo.isFadeIn) {
@@ -493,39 +509,15 @@ void Gfx::updateFade() {
// do the actual alphablending
if (!_fadeInfo.isBlack) {
- // Black Fade
-
- for (int y = 0; y < g_hdb->_screenHeight; y++) {
- uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
- for (int x = 0; x < g_hdb->_screenWidth; x++) {
- uint16 value = *ptr;
- if (value) {
- uint8 r, g, b;
- g_hdb->_format.colorToRGB(value, r, g, b);
- r = (r * _fadeInfo.curStep) >> 8;
- g = (g * _fadeInfo.curStep) >> 8;
- b = (b * _fadeInfo.curStep) >> 8;
- *ptr = g_hdb->_format.RGBToColor(r, g, b);
- }
- ptr++;
- }
- }
+ if (_fadeBuffer1.format.bytesPerPixel == 2)
+ doFadeBlack<uint16>(_fadeBuffer1, _fadeInfo.curStep);
+ else if (_fadeBuffer1.format.bytesPerPixel == 4)
+ doFadeBlack<uint32>(_fadeBuffer1, _fadeInfo.curStep);
} else {
- // White Fade
-
- for (int y = 0; y < g_hdb->_screenHeight; y++) {
- uint16 *ptr = (uint16 *)_fadeBuffer1.getBasePtr(0, y);
- for (int x = 0; x < g_hdb->_screenWidth; x++) {
- uint16 value = *ptr;
- uint8 r, g, b;
- g_hdb->_format.colorToRGB(value, r, g, b);
- r += (255 - r) * (256 - _fadeInfo.curStep) / 256;
- g += (255 - g) * (256 - _fadeInfo.curStep) / 256;
- b += (255 - b) * (256 - _fadeInfo.curStep) / 256;
- *ptr = g_hdb->_format.RGBToColor(r, g, b);
- ptr++;
- }
- }
+ if (_fadeBuffer1.format.bytesPerPixel == 2)
+ doFadeWhite<uint16>(_fadeBuffer1, _fadeInfo.curStep);
+ else if (_fadeBuffer1.format.bytesPerPixel == 4)
+ doFadeWhite<uint32>(_fadeBuffer1, _fadeInfo.curStep);
}
_globalSurface.blitFrom(_fadeBuffer1);
@@ -617,11 +609,11 @@ Tile *Gfx::loadIcon(const char *tileName) {
return tile;
}
-void Gfx::setPixel(int x, int y, uint16 color) {
+void Gfx::setPixel(int x, int y, uint32 color) {
if (x < 0 || y < 0 || x >= _globalSurface.w || y >= _globalSurface.h)
return;
- *(uint16 *)_globalSurface.getBasePtr(x, y) = color;
+ _globalSurface.setPixel(x, y, color);
g_system->copyRectToScreen(_globalSurface.getBasePtr(x, y), _globalSurface.pitch, x, y, 1, 1);
}
@@ -822,7 +814,7 @@ void Gfx::setup3DStars() {
_stars3D[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
_stars3D[i].speed = g_hdb->_rnd->getRandomNumber(255);
if (g_hdb->isPPC())
- _stars3D[i].color = g_hdb->_format.RGBToColor(_stars3D[i].speed, _stars3D[i].speed, _stars3D[i].speed);
+ _stars3D[i].color = g_hdb->_screenFormat.RGBToColor(_stars3D[i].speed, _stars3D[i].speed, _stars3D[i].speed);
else {
_stars3D[i].speed >>= 1;
_stars3D[i].color = _stars3D[i].speed / 64;
@@ -836,14 +828,14 @@ void Gfx::setup3DStarsLeft() {
_stars3DSlow[i].y = g_hdb->_rnd->getRandomNumber(g_hdb->_screenHeight - 1);
_stars3DSlow[i].speed = ((double) (1 + g_hdb->_rnd->getRandomNumber(4))) / 6.0;
if (g_hdb->isPPC())
- _stars3DSlow[i].color = g_hdb->_format.RGBToColor((int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250));
+ _stars3DSlow[i].color = g_hdb->_screenFormat.RGBToColor((int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250), (int)(_stars3DSlow[i].speed * 250));
else
_stars3DSlow[i].color = (int) (_stars3DSlow[i].speed * 4.00);
}
}
void Gfx::draw3DStars() {
- fillScreen(0);
+ fillScreen();
for (int i = 0; i < kNum3DStars; i++) {
if (g_hdb->isPPC()) {
setPixel((int)_stars3D[i].x, (int)_stars3D[i].y, _stars3D[i].color);
@@ -859,7 +851,7 @@ void Gfx::draw3DStars() {
}
void Gfx::draw3DStarsLeft() {
- fillScreen(0);
+ fillScreen();
for (int i = 0; i < kNum3DStars; i++) {
if (g_hdb->isPPC())
setPixel((int)_stars3DSlow[i].x, (int)_stars3DSlow[i].y, _stars3DSlow[i].color);
@@ -902,7 +894,7 @@ void Gfx::drawSnow() {
for (int i = 0; i < MAX_SNOW; i++) {
if (g_hdb->isPPC()) {
- uint16 color = g_hdb->_format.RGBToColor(160, 160, 160);
+ uint32 color = g_hdb->_screenFormat.RGBToColor(160, 160, 160);
setPixel((int)_snowInfo.x[i] + 1, (int)_snowInfo.y[i], color);
setPixel((int)_snowInfo.x[i] - 1, (int)_snowInfo.y[i], color);
setPixel((int)_snowInfo.x[i], (int)_snowInfo.y[i] + 1, color);
@@ -964,7 +956,7 @@ bool Gfx::loadFont(const char *string) {
// Position after reading cInfo
int curPos = memoryStream.pos();
- _fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+ _fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_dataFormat);
// Go to character location
memoryStream.seek(startPos + cInfo->offset);
@@ -978,6 +970,8 @@ bool Gfx::loadFont(const char *string) {
}
}
+ _fontSurfaces[i].convertToInPlace(g_hdb->_screenFormat);
+
memoryStream.seek(curPos);
_charInfoBlocks.push_back(cInfo);
@@ -1014,7 +1008,7 @@ bool Gfx::loadFont(const char *string) {
// Position after reading cInfo
int curPos = stream->pos();
- _fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+ _fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_dataFormat);
// Go to character location
stream->seek(startPos + cInfo->offset);
@@ -1027,6 +1021,8 @@ bool Gfx::loadFont(const char *string) {
}
}
+ _fontSurfaces[i].convertToInPlace(g_hdb->_screenFormat);
+
stream->seek(curPos);
_charInfoBlocks.push_back(cInfo);
@@ -1088,7 +1084,8 @@ void Gfx::drawText(const char *string) {
width = kFontSpace;
// Blit the character
- _globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), 0xf81f);
+ const uint32 transColor = _fontSurfaces[c].format.RGBToColor(255, 0, 255);
+ _globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), transColor);
Common::Rect clip(0, 0, width, _fontHeader.height);
clip.moveTo(_cursorX, _cursorY);
@@ -1329,7 +1326,7 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
Picture::Picture() : _width(0), _height(0) {
_name[0] = 0;
- _surface.create(_width, _height, g_hdb->_format);
+ _surface.create(_width, _height, g_hdb->_screenFormat);
}
Picture::~Picture() {
@@ -1344,7 +1341,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
debug(8, "Picture: _name: %s", _name);
if (g_hdb->isPPC()) {
- _surface.create(_width, _height, g_hdb->_format);
+ _surface.create(_width, _height, g_hdb->_dataFormat);
for (int x = 0; x < _width; x++) {
for (int y = 0; y < _height; y++) {
@@ -1355,8 +1352,9 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
}
}
+ _surface.convertToInPlace(g_hdb->_screenFormat);
} else {
- _surface.create(_width, _height, g_hdb->_format);
+ _surface.create(_width, _height, g_hdb->_dataFormat);
stream->readUint32LE(); // Skip Win32 Surface
for (int y = 0; y < _height; y++) {
@@ -1366,6 +1364,8 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
ptr++;
}
}
+
+ _surface.convertToInPlace(g_hdb->_screenFormat);
}
return _surface;
@@ -1385,7 +1385,8 @@ int Picture::draw(int x, int y) {
}
int Picture::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, alpha & 0xff);
+ const uint32 transColor = _surface.format.RGBToColor(255, 0, 255);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), transColor, false, alpha & 0xff);
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
@@ -1399,7 +1400,7 @@ int Picture::drawMasked(int x, int y, int alpha) {
Tile::Tile() : _flags(0) {
_name[0] = 0;
- _surface.create(32, 32, g_hdb->_format);
+ _surface.create(32, 32, g_hdb->_screenFormat);
}
Tile::~Tile() {
@@ -1409,7 +1410,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
_flags = stream->readUint32LE();
stream->read(_name, 64);
- _surface.create(32, 32, g_hdb->_format);
+ _surface.create(32, 32, g_hdb->_dataFormat);
if (g_hdb->isPPC()) {
for (int y = 0; y < 32; y++) {
for (int x = 0; x < 32; x++) {
@@ -1429,6 +1430,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
}
}
}
+ _surface.convertToInPlace(g_hdb->_screenFormat);
return _surface;
}
@@ -1447,7 +1449,8 @@ int Tile::draw(int x, int y) {
}
int Tile::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, alpha & 0xff);
+ const uint32 transColor = _surface.format.RGBToColor(255, 0, 255);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), transColor, false, alpha & 0xff);
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 1db01e6ff45..29068624f50 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -79,7 +79,7 @@ public:
void init();
void save(Common::OutSaveFile *out);
void loadSaveFile(Common::InSaveFile *in);
- void fillScreen(uint32 color);
+ void fillScreen();
void updateVideo();
void setPointerState(int value);
void drawPointer();
@@ -101,7 +101,7 @@ public:
Picture *loadPic(const char *picName);
Tile *loadTile(const char *tileName);
Tile *loadIcon(const char *tileName);
- void setPixel(int x, int y, uint16 color);
+ void setPixel(int x, int y, uint32 color);
Tile *getTile(int index);
void cacheTileSequence(int index, int count);
@@ -186,12 +186,12 @@ private:
struct {
int x, y, speed;
- uint16 color;
+ uint32 color;
} _stars3D[kNum3DStars];
struct {
double x, y, speed;
- uint16 color;
+ uint32 color;
} _stars3DSlow[kNum3DStars];
int _tileSkyStars; // Index of sky_stars tile
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c434e756fd4..b2c9553d326 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -58,7 +58,7 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
_progressY = _screenHeight - 64;
}
- _format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+ _dataFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
_systemInit = false;
_fileMan = nullptr;
@@ -866,7 +866,7 @@ void HDBGame::checkProgress() {
void HDBGame::drawLoadingScreen() {
if (g_hdb->isPPC())
- _gfx->fillScreen(0);
+ _gfx->fillScreen();
else
_loadingScreenGfx->draw(0, 0);
}
@@ -922,13 +922,17 @@ void HDBGame::setInMapName(const char *name) {
Common::Error HDBGame::run() {
+ // Initializes Graphics
+ initGraphics(_screenWidth, _screenHeight, nullptr);
+ _screenFormat = _system->getScreenFormat();
+
+ if (_screenFormat.isCLUT8())
+ return Common::kUnsupportedColorMode;
+
// Initialize System
if (!_systemInit)
init();
- // Initializes Graphics
- initGraphics(_screenWidth, _screenHeight, &_format);
-
start();
#if 0
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index f16b73a7939..87cfdc7f843 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -320,7 +320,8 @@ public:
Save _saveHeader;
bool _gameShutdown;
- Graphics::PixelFormat _format;
+ Graphics::PixelFormat _dataFormat;
+ Graphics::PixelFormat _screenFormat;
Picture *_progressGfx, *_progressMarkGfx;
Picture *_loadingScreenGfx, *_logoGfx;
diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp
index 7d0f00286b1..3fb76341b6c 100644
--- a/engines/hdb/menu.cpp
+++ b/engines/hdb/menu.cpp
@@ -1216,7 +1216,7 @@ void Menu::drawTitle() {
if (g_hdb->_gfx->isFadeActive())
break;
g_hdb->_gfx->turnOffFade();
- g_hdb->_gfx->fillScreen(0);
+ g_hdb->_gfx->fillScreen();
{
_titleCycle++;
_rocketY = g_hdb->_screenHeight; // ycoord
Commit: 766cac2402cc2d6e121877f155309cbfa7b785e0
https://github.com/scummvm/scummvm/commit/766cac2402cc2d6e121877f155309cbfa7b785e0
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-15T10:36:56+03:00
Commit Message:
HDB: Make use of simpleBlitFrom()
Changed paths:
engines/hdb/gfx.cpp
engines/hdb/gfx.h
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 10654c7dcbd..6f3ecb0b379 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -498,13 +498,13 @@ void Gfx::updateFade() {
}
}
} else {
- _fadeBuffer2.blitFrom(_globalSurface);
+ _fadeBuffer2.simpleBlitFrom(_globalSurface);
static int waitAFrame = 0;
do {
// Copy pristine copy of background to modification buffer
- _fadeBuffer1.blitFrom(_fadeBuffer2);
+ _fadeBuffer1.simpleBlitFrom(_fadeBuffer2);
// do the actual alphablending
@@ -520,7 +520,7 @@ void Gfx::updateFade() {
doFadeWhite<uint32>(_fadeBuffer1, _fadeInfo.curStep);
}
- _globalSurface.blitFrom(_fadeBuffer1);
+ _globalSurface.simpleBlitFrom(_fadeBuffer1);
g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
// step the fading values to the next one and
@@ -971,6 +971,7 @@ bool Gfx::loadFont(const char *string) {
}
_fontSurfaces[i].convertToInPlace(g_hdb->_screenFormat);
+ _fontSurfaces[i].setTransparentColor(_fontSurfaces[i].format.RGBToColor(255, 0, 255));
memoryStream.seek(curPos);
@@ -1022,6 +1023,7 @@ bool Gfx::loadFont(const char *string) {
}
_fontSurfaces[i].convertToInPlace(g_hdb->_screenFormat);
+ _fontSurfaces[i].setTransparentColor(_fontSurfaces[i].format.RGBToColor(255, 0, 255));
stream->seek(curPos);
@@ -1084,8 +1086,7 @@ void Gfx::drawText(const char *string) {
width = kFontSpace;
// Blit the character
- const uint32 transColor = _fontSurfaces[c].format.RGBToColor(255, 0, 255);
- _globalSurface.transBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY), transColor);
+ _globalSurface.simpleBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY));
Common::Rect clip(0, 0, width, _fontHeader.height);
clip.moveTo(_cursorX, _cursorY);
@@ -1372,7 +1373,7 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
}
int Picture::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.simpleBlitFrom(_surface, Common::Point(x, y));
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
@@ -1384,9 +1385,10 @@ int Picture::draw(int x, int y) {
return 0;
}
-int Picture::drawMasked(int x, int y, int alpha) {
- const uint32 transColor = _surface.format.RGBToColor(255, 0, 255);
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), transColor, false, alpha & 0xff);
+int Picture::drawMasked(int x, int y, uint8 alpha) {
+ _surface.setTransparentColor(_surface.format.RGBToColor(255, 0, 255));
+ g_hdb->_gfx->_globalSurface.simpleBlitFrom(_surface, Common::Point(x, y), Graphics::FLIP_NONE, false, alpha);
+ _surface.clearTransparentColor();
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
@@ -1436,7 +1438,7 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
}
int Tile::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.simpleBlitFrom(_surface, Common::Point(x, y));
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
@@ -1448,9 +1450,10 @@ int Tile::draw(int x, int y) {
return 0;
}
-int Tile::drawMasked(int x, int y, int alpha) {
- const uint32 transColor = _surface.format.RGBToColor(255, 0, 255);
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), transColor, false, alpha & 0xff);
+int Tile::drawMasked(int x, int y, uint8 alpha) {
+ _surface.setTransparentColor(_surface.format.RGBToColor(255, 0, 255));
+ g_hdb->_gfx->_globalSurface.simpleBlitFrom(_surface, Common::Point(x, y), Graphics::FLIP_NONE, false, alpha);
+ _surface.clearTransparentColor();
Common::Rect clip(_surface.getBounds());
clip.moveTo(x, y);
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 29068624f50..5683f642be6 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -221,7 +221,7 @@ private:
FontInfo _fontHeader;
Common::Array<CharInfo *> _charInfoBlocks;
- Graphics::Surface _fontSurfaces[256];
+ Graphics::ManagedSurface _fontSurfaces[256];
uint16 _fontGfx;
int _eLeft, _eRight, _eTop, _eBottom;
@@ -239,7 +239,7 @@ public:
Graphics::Surface load(Common::SeekableReadStream *stream);
int draw(int x, int y);
- int drawMasked(int x, int y, int alpha = 0xff);
+ int drawMasked(int x, int y, uint8 alpha = 0xff);
int _width, _height;
@@ -261,7 +261,7 @@ public:
Graphics::Surface load(Common::SeekableReadStream *stream);
int draw(int x, int y);
- int drawMasked(int x, int y, int alpha = 0xff);
+ int drawMasked(int x, int y, uint8 alpha = 0xff);
uint32 _flags;
Commit: 278a2b300a798b91c4021ec32ff955e372fa100c
https://github.com/scummvm/scummvm/commit/278a2b300a798b91c4021ec32ff955e372fa100c
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-15T10:36:56+03:00
Commit Message:
HDB: Use Graphic::Screen for tracking updates to _globalSurface
Changed paths:
engines/hdb/gfx.cpp
engines/hdb/gfx.h
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 6f3ecb0b379..eac05672a08 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -36,11 +36,10 @@
namespace HDB {
-Gfx::Gfx() {
+Gfx::Gfx() : _globalSurface(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_screenFormat) {
_tLookupArray = nullptr;
_starsInfo.active = false;
_gfxCache = new Common::Array<GfxCache *>;
- _globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_screenFormat);
_pointerDisplayable = 1;
_sines = new Math::SineTable(360);
_cosines = new Math::CosineTable(360);
@@ -112,7 +111,6 @@ Gfx::~Gfx() {
delete _cosines;
for (int i = 0; i < _fontHeader.numChars; i++)
_fontSurfaces[i].free();
- _globalSurface.free();
for (int i = 0; i < _numTiles; i++) {
delete _tLookupArray[i].tData;
_tLookupArray[i].tData = nullptr;
@@ -354,7 +352,6 @@ double Gfx::getCos(int index) {
void Gfx::fillScreen() {
uint32 color = _globalSurface.format.RGBToColor(0, 0, 0);
_globalSurface.fillRect(Common::Rect(g_hdb->_screenWidth, g_hdb->_screenHeight), color);
- g_system->fillScreen(color);
}
void Gfx::updateVideo() {
@@ -365,15 +362,7 @@ void Gfx::updateVideo() {
g_hdb->checkProgress();
- int left = g_hdb->_screenWidth / 2 - g_hdb->_progressGfx->_width / 2;
-
- Common::Rect clip(g_hdb->_progressGfx->getSurface()->getBounds());
- clip.moveTo(left, g_hdb->_progressY);
- clip.clip(_globalSurface.getBounds());
- if (!clip.isEmpty())
- g_system->copyRectToScreen(_globalSurface.getBasePtr(clip.left, clip.top), _globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
-
- g_system->updateScreen();
+ _globalSurface.update();
}
void Gfx::drawPointer() {
@@ -521,7 +510,6 @@ void Gfx::updateFade() {
}
_globalSurface.simpleBlitFrom(_fadeBuffer1);
- g_system->copyRectToScreen(_globalSurface.getBasePtr(0, 0), _globalSurface.pitch, 0, 0, _globalSurface.w, _globalSurface.h);
// step the fading values to the next one and
// see if we're done yet
@@ -552,7 +540,7 @@ void Gfx::updateFade() {
return;
}
- g_system->updateScreen();
+ _globalSurface.update();
if (g_hdb->getDebug()) {
g_hdb->_frames.push_back(g_system->getMillis());
while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
@@ -614,7 +602,7 @@ void Gfx::setPixel(int x, int y, uint32 color) {
return;
_globalSurface.setPixel(x, y, color);
- g_system->copyRectToScreen(_globalSurface.getBasePtr(x, y), _globalSurface.pitch, x, y, 1, 1);
+ _globalSurface.addDirtyRect(Common::Rect(x, y, x + 1, y + 1));
}
Tile *Gfx::getTile(int index) {
@@ -1088,13 +1076,6 @@ void Gfx::drawText(const char *string) {
// Blit the character
_globalSurface.simpleBlitFrom(_fontSurfaces[c], Common::Point(_cursorX, _cursorY));
- Common::Rect clip(0, 0, width, _fontHeader.height);
- clip.moveTo(_cursorX, _cursorY);
- clip.clip(_globalSurface.getBounds());
- if (!clip.isEmpty()) {
- g_system->copyRectToScreen(_globalSurface.getBasePtr(clip.left, clip.top), _globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
- }
-
// Advance the cursor
_cursorX += width + _fontHeader.kerning + kFontIncrement;
if (_cursorX > g_hdb->_screenWidth) {
@@ -1379,7 +1360,6 @@ int Picture::draw(int x, int y) {
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
- g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
return 1;
}
return 0;
@@ -1394,7 +1374,6 @@ int Picture::drawMasked(int x, int y, uint8 alpha) {
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
- g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
return 1;
}
return 0;
@@ -1444,7 +1423,6 @@ int Tile::draw(int x, int y) {
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
- g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
return 1;
}
return 0;
@@ -1459,7 +1437,6 @@ int Tile::drawMasked(int x, int y, uint8 alpha) {
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
- g_system->copyRectToScreen(g_hdb->_gfx->_globalSurface.getBasePtr(clip.left, clip.top), g_hdb->_gfx->_globalSurface.pitch, clip.left, clip.top, clip.width(), clip.height());
return 1;
}
return 0;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index 5683f642be6..9ffa5d7bc8a 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -23,6 +23,7 @@
#define HDB_GFX_H
#include "graphics/managed_surface.h"
+#include "graphics/screen.h"
namespace Math {
class SineTable;
@@ -74,7 +75,7 @@ public:
Gfx();
~Gfx();
- Graphics::ManagedSurface _globalSurface;
+ Graphics::Screen _globalSurface;
void init();
void save(Common::OutSaveFile *out);
More information about the Scummvm-git-logs
mailing list