[Scummvm-git-logs] scummvm master -> 5a4b48a2c0fd70c304fa236f858db11f1ec26681
neuromancer
noreply at scummvm.org
Thu Oct 3 18:18:12 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
dc48952124 FREESCAPE: fix font loading for castle
5f1e07952d FREESCAPE: correctly show riddle fonts in castle for dos
5a4b48a2c0 NEWS: Added freescape changes
Commit: dc4895212477e4acc37f62d220c1b4061764daa5
https://github.com/scummvm/scummvm/commit/dc4895212477e4acc37f62d220c1b4061764daa5
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-03T20:19:06+02:00
Commit Message:
FREESCAPE: fix font loading for castle
Changed paths:
engines/freescape/font.cpp
engines/freescape/font.h
engines/freescape/games/castle/dos.cpp
engines/freescape/games/castle/zx.cpp
diff --git a/engines/freescape/font.cpp b/engines/freescape/font.cpp
index c4dd5b03169..891db20012e 100644
--- a/engines/freescape/font.cpp
+++ b/engines/freescape/font.cpp
@@ -28,6 +28,7 @@ Font::Font() {
_backgroundColor = 0;
_secondaryColor = 0;
_kerningOffset = 0;
+ _charWidth = 0;
_chars.clear();
}
@@ -36,6 +37,7 @@ Font::Font(Common::Array<Graphics::ManagedSurface *> &chars) {
_backgroundColor = 0;
_secondaryColor = 0;
_kerningOffset = 0;
+ _charWidth = 8;
}
Font::~Font() {
@@ -46,7 +48,7 @@ Font::~Font() {
}
int Font::getCharWidth(uint32 chr) const {
- return 8;
+ return _charWidth;
}
int Font::getMaxCharWidth() const {
diff --git a/engines/freescape/font.h b/engines/freescape/font.h
index 8582707737e..cea0e5ca9bc 100644
--- a/engines/freescape/font.h
+++ b/engines/freescape/font.h
@@ -42,6 +42,7 @@ public:
int getCharWidth(uint32 chr) const override;
int getKerningOffset(uint32 left, uint32 right) const override { return _kerningOffset; }
void setKernelingOffset(int offset) { _kerningOffset = offset; }
+ void setCharWidth(int width) { _charWidth = width; }
void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
@@ -51,6 +52,7 @@ private:
uint32 _backgroundColor;
uint32 _secondaryColor;
int _kerningOffset;
+ int _charWidth;
};
} // End of namespace Freescape
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index f9d9256b50f..fff4e7fc6d4 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -52,42 +52,6 @@ Common::SeekableReadStream *CastleEngine::decryptFile(const Common::Path &filena
extern byte kEGADefaultPalette[16][3];
extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
-void CastleEngine::loadDOSFonts(Common::SeekableReadStream *file, int pos) {
- /*file->seek(pos);
- byte *bufferPlane1 = (byte *)malloc(sizeof(byte) * 59 * 8);
- byte *bufferPlane2 = (byte *)malloc(sizeof(byte) * 59 * 8);
- byte *bufferPlane3 = (byte *)malloc(sizeof(byte) * 59 * 8);
-
- for (int i = 0; i < 59 * 8; i++) {
- //debug("%lx", file->pos());
- for (int j = 0; j < 4; j++) {
- uint16 c = readField(file, 16);
- assert(c < 256);
- if (j == 1) {
- bufferPlane1[i] = c;
- } else if (j == 2) {
- bufferPlane2[i] = c;
- } else if (j == 3) {
- bufferPlane3[i] = c;
- }
- }
- //debugN("\n");
- }
- //debug("%" PRIx64, file->pos());
- _fontPlane1.set_size(64 * 59);
- _fontPlane1.set_bits(bufferPlane1);
-
- _fontPlane2.set_size(64 * 59);
- _fontPlane2.set_bits(bufferPlane2);
-
- _fontPlane3.set_size(64 * 59);
- _fontPlane3.set_bits(bufferPlane3);
- _fontLoaded = true;
- free(bufferPlane1);
- free(bufferPlane2);
- free(bufferPlane3);*/
-}
-
Graphics::ManagedSurface *CastleEngine::loadFrameFromPlanes(Common::SeekableReadStream *file, int widthInBytes, int height) {
Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
surface->create(widthInBytes * 8 / 4, height, Graphics::PixelFormat::createFormatCLUT8());
@@ -170,7 +134,6 @@ void CastleEngine::loadAssetsDOSFullGame() {
stream = unpackEXE(file);
if (stream) {
loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
- loadDOSFonts(stream, 0x29696);
stream->seek(0x197c0);
_endGameBackgroundFrame = loadFrameFromPlanes(stream, 112, 108);
@@ -248,6 +211,8 @@ void CastleEngine::loadAssetsDOSFullGame() {
chars[i]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
}
_font = Font(chars);
+ _font.setCharWidth(8 + 1);
+ _fontLoaded = true;
// No header
// Another thunder frame?
@@ -326,7 +291,7 @@ void CastleEngine::loadAssetsDOSDemo() {
stream = unpackEXE(file);
if (stream) {
loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
- loadDOSFonts(stream, 0x293f6);
+ //loadDOSFonts(stream, 0x293f6);
stream->seek(0x197c0 - 0x2a0);
_endGameBackgroundFrame = loadFrameFromPlanes(stream, 112, 108);
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index c77c226a2d6..df054decbcb 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -127,6 +127,7 @@ void CastleEngine::loadAssetsZXFullGame() {
chars.push_back(loadFrame(&file, surface, 1, 8, 1));
}
_font = Font(chars);
+ _fontLoaded = true;
break;
case Common::EN_ANY:
@@ -142,6 +143,7 @@ void CastleEngine::loadAssetsZXFullGame() {
chars.push_back(loadFrame(&file, surface, 1, 8, 1));
}
_font = Font(chars);
+ _fontLoaded = true;
break;
default:
Commit: 5f1e07952d1754efeb5489a4b55f0e84e484cd29
https://github.com/scummvm/scummvm/commit/5f1e07952d1754efeb5489a4b55f0e84e484cd29
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-03T20:19:06+02:00
Commit Message:
FREESCAPE: correctly show riddle fonts in castle for dos
Changed paths:
engines/freescape/font.cpp
engines/freescape/games/castle/castle.cpp
engines/freescape/games/castle/castle.h
engines/freescape/games/castle/dos.cpp
diff --git a/engines/freescape/font.cpp b/engines/freescape/font.cpp
index 891db20012e..d3ff8a883fe 100644
--- a/engines/freescape/font.cpp
+++ b/engines/freescape/font.cpp
@@ -88,9 +88,10 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
{ rs, gs, bs },
};
- surface.convertToInPlace(dst->format, (byte *)palette, 3);
+ if (surface.format != dst->format)
+ surface.convertToInPlace(dst->format, (byte *)palette, 3);
- if (_backgroundColor == 0 )
+ if (_backgroundColor == dst->format.ARGBToColor(0x00, 0x00, 0x00, 0x00))
dst->copyRectToSurfaceWithKey(surface, x, y, Common::Rect(0, 0, 8, surface.h), dst->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00));
else
dst->copyRectToSurface(surface, x, y, Common::Rect(0, 0, 8, surface.h));
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index ec4e97f408f..5a0497befcc 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -718,26 +718,17 @@ void CastleEngine::loadRiddles(Common::SeekableReadStream *file, int offset, int
void CastleEngine::drawFullscreenRiddleAndWait(uint16 riddle) {
_savedScreen = _gfx->getScreenshot();
int frontColor = 6;
- int backColor = 0;
switch (_renderMode) {
- case Common::kRenderCPC:
- backColor = 14;
- break;
- case Common::kRenderCGA:
- backColor = 1;
- break;
case Common::kRenderZX:
- backColor = 0;
frontColor = 7;
break;
default:
- backColor = 14;
+ break;
}
uint8 r, g, b;
_gfx->readFromPalette(frontColor, r, g, b);
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
- _gfx->readFromPalette(backColor, r, g, b);
- uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+ uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
Graphics::Surface *surface = new Graphics::Surface();
surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
@@ -771,7 +762,7 @@ void CastleEngine::drawFullscreenRiddleAndWait(uint16 riddle) {
drawBorder();
if (_currentArea)
drawUI();
- drawRiddle(riddle, front, back, surface);
+ drawRiddle(riddle, front, transparent, surface);
_gfx->flipBuffer();
g_system->updateScreen();
g_system->delayMillis(15); // try to target ~60 FPS
@@ -817,31 +808,22 @@ void CastleEngine::drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics
for (int i = 0; i < int(riddleMessages.size()); i++) {
x = x + riddleMessages[i]._dx;
y = y + riddleMessages[i]._dy;
- drawStringInSurface(riddleMessages[i]._text, x, y, front, back, surface);
+ drawRiddleStringInSurface(riddleMessages[i]._text, x, y, front, back, surface);
}
drawFullscreenSurface(surface);
}
-/*void CastleEngine::drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset) {
- if (isSpectrum() || isCPC()) {
- FreescapeEngine::drawStringInSurface(str, x, y, fontColor, backColor, surface, offset);
- return;
+void CastleEngine::drawRiddleStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface) {
+ Common::String ustr = str;
+ ustr.toUppercase();
+ if (isDOS()) {
+ _fontRiddle.setBackground(backColor);
+ _fontRiddle.drawString(surface, ustr, x, y, _screenW, fontColor);
+ } else {
+ _font.setBackground(backColor);
+ _font.drawString(surface, ustr, x, y, _screenW, fontColor);
}
-
- uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
- uint32 yellow = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0xFF, 0x00);
- //uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x80, 0x00);
-
- _font = _fontPlane1;
- FreescapeEngine::drawStringInSurface(str, x, y, fontColor, backColor, surface, offset);
-
- _font = _fontPlane2;
- FreescapeEngine::drawStringInSurface(str, x, y, yellow, transparent, surface, offset);
-
- _font = Common::BitArray();
- //_font = _fontPlane3;
- //FreescapeEngine::drawStringInSurface(str, x, y, transparent, green, surface, offset);
-}*/
+}
void CastleEngine::drawEnergyMeter(Graphics::Surface *surface, Common::Point origin) {
if (!_strenghtBackgroundFrame)
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index c831708adb1..f1f1b12dd8f 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -89,8 +89,7 @@ public:
Common::BitArray _fontPlane2;
Common::BitArray _fontPlane3;
- //void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
- //void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
+ void drawRiddleStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface);
Graphics::ManagedSurface *loadFrameWithHeaderDOS(Common::SeekableReadStream *file);
Common::Array <Graphics::ManagedSurface *>loadFramesWithHeaderDOS(Common::SeekableReadStream *file, int numFrames);
@@ -136,6 +135,7 @@ private:
void tryToCollectKey();
void addGhosts();
Texture *_optionTexture;
+ Font _fontRiddle;
};
}
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index fff4e7fc6d4..df6ae8c765f 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -52,6 +52,25 @@ Common::SeekableReadStream *CastleEngine::decryptFile(const Common::Path &filena
extern byte kEGADefaultPalette[16][3];
extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
+byte kEGARiddleFontPalette[16][3] = {
+ {0x00, 0x00, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00},
+ {0xaa, 0x55, 0x00}
+};
+
Graphics::ManagedSurface *CastleEngine::loadFrameFromPlanes(Common::SeekableReadStream *file, int widthInBytes, int height) {
Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
surface->create(widthInBytes * 8 / 4, height, Graphics::PixelFormat::createFormatCLUT8());
@@ -206,12 +225,25 @@ void CastleEngine::loadAssetsDOSFullGame() {
stream->seek(0x29696);
Common::Array<Graphics::ManagedSurface *> chars;
+ Common::Array<Graphics::ManagedSurface *> charsRiddle;
for (int i = 0; i < 90; i++) {
- chars.push_back(loadFrameFromPlanes(stream, 8, 8));
+ Graphics::ManagedSurface *img = loadFrameFromPlanes(stream, 8, 8);
+ Graphics::ManagedSurface *imgRiddle = new Graphics::ManagedSurface();
+ imgRiddle->copyFrom(*img);
+
+ chars.push_back(img);
chars[i]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
+ charsRiddle.push_back(imgRiddle);
+ charsRiddle[i]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGARiddleFontPalette, 16);
}
_font = Font(chars);
_font.setCharWidth(8 + 1);
+ //_font.setTransparentColor(_gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00));
+
+ _fontRiddle = Font(charsRiddle);
+ _fontRiddle.setCharWidth(8 + 1);
+ //_fontRiddle.setTransparentColor(_gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00));
_fontLoaded = true;
// No header
Commit: 5a4b48a2c0fd70c304fa236f858db11f1ec26681
https://github.com/scummvm/scummvm/commit/5a4b48a2c0fd70c304fa236f858db11f1ec26681
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-03T20:19:06+02:00
Commit Message:
NEWS: Added freescape changes
Changed paths:
NEWS.md
diff --git a/NEWS.md b/NEWS.md
index f162fc8aa40..5fc5c0ab258 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -35,6 +35,7 @@ For a more comprehensive changelog of the latest experimental code, see:
- Added "authentic graphics" mode.
- Fixed several glitches in the different render modes.
- Refactored sound handling for different games.
+ - Refactored font handling to use common classes.
- Improved keymapper support coverage.
MM:
More information about the Scummvm-git-logs
mailing list