[Scummvm-git-logs] scummvm master -> 9de5e09070a3d3acd1b307c8bfd28ac6755e7e9f
neuromancer
noreply at scummvm.org
Tue Oct 15 19:27:31 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:
9de5e09070 FREESCAPE: refactoring font handling for amiga/atari
Commit: 9de5e09070a3d3acd1b307c8bfd28ac6755e7e9f
https://github.com/scummvm/scummvm/commit/9de5e09070a3d3acd1b307c8bfd28ac6755e7e9f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-15T21:29:04+02:00
Commit Message:
FREESCAPE: refactoring font handling for amiga/atari
Changed paths:
engines/freescape/font.cpp
engines/freescape/freescape.h
engines/freescape/games/dark/amiga.cpp
engines/freescape/games/dark/atari.cpp
engines/freescape/games/dark/dark.h
diff --git a/engines/freescape/font.cpp b/engines/freescape/font.cpp
index dc937446aab..0487cc678f7 100644
--- a/engines/freescape/font.cpp
+++ b/engines/freescape/font.cpp
@@ -136,7 +136,7 @@ Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getChars(Common::Seek
return chars;
}
-Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getCharsAmigaAtari(Common::SeekableReadStream *file, int offset, int charsNumber) {
+Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getCharsAmigaAtariInternal(int sizeX, int sizeY, int additional, int m1, int m2, Common::SeekableReadStream *file, int offset, int charsNumber) {
file->seek(offset);
int fontSize = 4654;
@@ -146,15 +146,8 @@ Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getCharsAmigaAtari(Co
Common::BitArray font;
font.set_size(8 * fontSize);
font.set_bits(fontBuffer);
-
Common::Array<Graphics::ManagedSurface *> chars;
- int sizeX = 8;
- int sizeY = 8;
- int additional = isEclipse() ? 0 : 1;
- int m1 = isDriller() ? 33 : 16;
- int m2 = isDriller() ? 32 : 16;
-
for (int c = 0; c < charsNumber - 1; c++) {
int position = 8 * (m1*c + 1);
Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
@@ -171,9 +164,14 @@ Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getCharsAmigaAtari(Co
}
chars.push_back(surface);
}
+ free(fontBuffer);
return chars;
}
+Common::Array<Graphics::ManagedSurface *> FreescapeEngine::getCharsAmigaAtari(Common::SeekableReadStream *file, int offset, int charsNumber) {
+ return getCharsAmigaAtariInternal(8, 8, isEclipse() ? 0 : 1, isDriller() ? 33 : 16, isDriller() ? 32 : 16, file, offset, charsNumber);
+}
+
void FreescapeEngine::drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset) {
Common::String ustr = str;
ustr.toUppercase();
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 1621dfc7430..29f3745db58 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -511,6 +511,7 @@ public:
void loadFonts(Common::SeekableReadStream *file, int offset);
void loadFonts(byte *font, int charNumber);
Common::Array<Graphics::ManagedSurface *> getChars(Common::SeekableReadStream *file, int offset, int charsNumber);
+ Common::Array<Graphics::ManagedSurface *> getCharsAmigaAtariInternal(int sizeX, int sizeY, int additional, int m1, int m2, Common::SeekableReadStream *file, int offset, int charsNumber);
Common::Array<Graphics::ManagedSurface *> getCharsAmigaAtari(Common::SeekableReadStream *file, int offset, int charsNumber);
Common::StringArray _currentAreaMessages;
Common::StringArray _currentEphymeralMessages;
diff --git a/engines/freescape/games/dark/amiga.cpp b/engines/freescape/games/dark/amiga.cpp
index 52212a0a05e..1771cb09c22 100644
--- a/engines/freescape/games/dark/amiga.cpp
+++ b/engines/freescape/games/dark/amiga.cpp
@@ -99,60 +99,25 @@ void DarkEngine::initAmigaAtari() {
void DarkEngine::drawString(const DarkFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface) {
if (!_fontLoaded)
return;
- /*Common::String ustr = str;
- ustr.toUppercase();
- int multiplier1 = 0;
- int multiplier2 = 0;
- int sizeX = 0;
- int sizeY = 0;
- int sep = 0;
-
- switch (size) {
- case kDarkFontBig:
- multiplier1 = 16;
- multiplier2 = 16;
- sizeY = 8;
- sizeX = 8;
- sep = 8;
- _font = _fontBig;
- break;
- case kDarkFontMedium:
- multiplier1 = 10;
- multiplier2 = 8;
- sizeY = 8;
- sizeX = 8;
- sep = 8;
- _font = _fontMedium;
- break;
- case kDarkFontSmall:
- multiplier1 = 10;
- multiplier2 = 16;
- sizeY = 5;
- sizeX = 8;
- sep = 4;
- _font = _fontSmall;
- break;
- default:
- error("Invalid font size %d", size);
- break;
+ Font *font = nullptr;
+
+ if (size == kDarkFontBig) {
+ font = &_fontBig;
+ } else if (size == kDarkFontMedium) {
+ font = &_fontMedium;
+ } else if (size == kDarkFontSmall) {
+ font = &_fontSmall;
+ } else {
+ error("Invalid font size %d", size);
+ return;
}
- for (uint32 c = 0; c < ustr.size(); c++) {
- assert(ustr[c] >= 32);
- int position = 8 * (multiplier1*(ustr[c] - 32));
- for (int j = 0; j < sizeY; j++) {
- for (int i = 0; i < sizeX; i++) {
- if (_font.get(position + j * multiplier2 + i)) {
- surface->setPixel(x + 8 - i + sep * c, y + j, primaryColor);
- }*/ /*else if (_font.get(position + j * multiplier2 + i)) {
- surface->setPixel(x + 8 - i + 8 * c, y + j, primaryColor);
- }*/ /*else {
- surface->setPixel(x + 8 - i + sep * c, y + j, backColor);
- }
- }
- }
- }*/
+ Common::String ustr = str;
+ ustr.toUppercase();
+ font->setBackground(backColor);
+ font->setSecondaryColor(secondaryColor);
+ font->drawString(surface, ustr, x, y, _screenW, primaryColor);
}
} // End of namespace Freescape
diff --git a/engines/freescape/games/dark/atari.cpp b/engines/freescape/games/dark/atari.cpp
index 5a47940356d..b70f396f8ff 100644
--- a/engines/freescape/games/dark/atari.cpp
+++ b/engines/freescape/games/dark/atari.cpp
@@ -58,10 +58,19 @@ void DarkEngine::loadAssetsAtariFullGame() {
parseAmigaAtariHeader(stream);
_border = loadAndConvertNeoImage(stream, 0xd710);
- /*loadFonts(stream, 0xd06b, _fontBig);
- loadFonts(stream, 0xd49a, _fontMedium);
- loadFonts(stream, 0xd49b, _fontSmall);*/
+ Common::Array<Graphics::ManagedSurface *> chars;
+ chars = getCharsAmigaAtari(stream, 0xd06a, 85);
+ _fontBig = Font(chars);
+
+ chars = getCharsAmigaAtariInternal(8, 8, 0, 10, 8, stream, 0xd49a, 85);
+ _fontMedium = Font(chars);
+
+ chars = getCharsAmigaAtariInternal(8, 5, 0, 10, 16, stream, 0xd49a, 85);
+ _fontSmall = Font(chars);
+ _fontSmall.setCharWidth(4);
+
+ _fontLoaded = true;
load8bitBinary(stream, 0x20918, 16);
loadMessagesVariableSize(stream, 0x3f6f, 66);
loadPalettes(stream, 0x204d6);
diff --git a/engines/freescape/games/dark/dark.h b/engines/freescape/games/dark/dark.h
index cb923e617c2..f1901c22345 100644
--- a/engines/freescape/games/dark/dark.h
+++ b/engines/freescape/games/dark/dark.h
@@ -92,10 +92,9 @@ public:
void drawCPCUI(Graphics::Surface *surface) override;
void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
- Common::BitArray _fontBig;
- Common::BitArray _fontMedium;
- Common::BitArray _fontSmall;
-
+ Font _fontBig;
+ Font _fontMedium;
+ Font _fontSmall;
int _soundIndexRestoreECD;
void drawString(const DarkFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface);
More information about the Scummvm-git-logs
mailing list