[Scummvm-git-logs] scummvm master -> 7c30bcf36127f4a44d131feed6bb8b7eb0c8c48a
neuromancer
noreply at scummvm.org
Mon Jun 3 07:37:04 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:
7c30bcf361 FREESCAPE: refactor loadFonts for dark side amiga/atari
Commit: 7c30bcf36127f4a44d131feed6bb8b7eb0c8c48a
https://github.com/scummvm/scummvm/commit/7c30bcf36127f4a44d131feed6bb8b7eb0c8c48a
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-06-03T09:37:24+02:00
Commit Message:
FREESCAPE: refactor loadFonts for dark side amiga/atari
Changed paths:
engines/freescape/games/dark/amiga.cpp
engines/freescape/games/dark/atari.cpp
engines/freescape/games/dark/dark.h
diff --git a/engines/freescape/games/dark/amiga.cpp b/engines/freescape/games/dark/amiga.cpp
index 96595a30844..672d3f46307 100644
--- a/engines/freescape/games/dark/amiga.cpp
+++ b/engines/freescape/games/dark/amiga.cpp
@@ -156,25 +156,25 @@ void DarkEngine::drawAmigaAtariSTUI(Graphics::Surface *surface) {
int score = _gameStateVars[k8bitVariableScore];
int ecds = _gameStateVars[kVariableActiveECDs];
- drawStringSmallInSurface(Common::String::format("%04d", int(2 * _position.x())), 18, 178, red, red, black, surface);
- drawStringSmallInSurface(Common::String::format("%04d", int(2 * _position.z())), 18, 184, red, red, black, surface);
- drawStringSmallInSurface(Common::String::format("%04d", int(2 * _position.y())), 18, 190, red, red, black, surface);
+ drawString(kDarkFontSmall, Common::String::format("%04d", int(2 * _position.x())), 18, 178, red, red, black, surface);
+ drawString(kDarkFontSmall, Common::String::format("%04d", int(2 * _position.z())), 18, 184, red, red, black, surface);
+ drawString(kDarkFontSmall, Common::String::format("%04d", int(2 * _position.y())), 18, 190, red, red, black, surface);
- drawStringBigInSurface(Common::String::format("%02d", int(_angleRotations[_angleRotationIndex])), 73, 178, red, red, black, surface);
- drawStringBigInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 73, 186, red, red, black, surface);
- drawStringBigInSurface(Common::String::format("%07d", score), 93, 16, yellow, orange, black, surface);
- drawStringBigInSurface(Common::String::format("%3d%%", ecds), 181, 16, yellow, orange, black, surface);
+ drawString(kDarkFontBig, Common::String::format("%02d", int(_angleRotations[_angleRotationIndex])), 73, 178, red, red, black, surface);
+ drawString(kDarkFontBig, Common::String::format("%3d", _playerSteps[_playerStepIndex]), 73, 186, red, red, black, surface);
+ drawString(kDarkFontBig, Common::String::format("%07d", score), 93, 16, yellow, orange, black, surface);
+ drawString(kDarkFontBig, Common::String::format("%3d%%", ecds), 181, 16, yellow, orange, black, surface);
Common::String message;
int deadline;
getLatestMessages(message, deadline);
if (deadline <= _countdown) {
- drawStringSmallInSurface(message, 32, 156, white, white, transparent, surface);
+ drawString(kDarkFontSmall, message, 32, 156, white, white, transparent, surface);
_temporaryMessages.push_back(message);
_temporaryMessageDeadlines.push_back(deadline);
}
- drawStringSmallInSurface(centerAndPadString(_currentArea->_name, 26), 32, 150, white, white, transparent, surface);
+ drawString(kDarkFontSmall, centerAndPadString(_currentArea->_name, 26), 32, 150, white, white, transparent, surface);
drawBinaryClock(surface, 6, 110, white, grey);
}
@@ -182,87 +182,63 @@ void DarkEngine::initAmigaAtari() {
_viewArea = Common::Rect(32, 33, 287, 130);
}
-void DarkEngine::drawStringMediumInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset) {
+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;
-
- _font = _fontMedium;
-
- Common::String ustr = str;
- ustr.toUppercase();
-
- int multiplier1 = 10;
-
- for (uint32 c = 0; c < ustr.size(); c++) {
- assert(ustr[c] >= 32);
- int position = 8 * (multiplier1*(offset + ustr[c] - 32) + 1);
- for (int j = 0; j < 8; j++) {
- for (int i = 0; i < 8; i++) {
- /*if (_font.get(position + j * multiplier2 + i + 8)) {
- surface->setPixel(x + 8 - i + 8 * c, y + j, secondaryColor);
- } else*/ if (_font.get(position + j * 8 + i + 8)) {
- surface->setPixel(x + 8 - i + 8 * c, y + j, primaryColor);
- } else {
- surface->setPixel(x + 8 - i + 8 * c, y + j, backColor);
- }
- }
- }
- }
-}
-
-void DarkEngine::drawStringSmallInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset) {
- if (!_fontLoaded)
- return;
-
Common::String ustr = str;
ustr.toUppercase();
- int multiplier1 = 10;
- int multiplier2 = 16;
-
- for (uint32 c = 0; c < ustr.size(); c++) {
- assert(ustr[c] >= 32);
- int position = 8 * (multiplier1*(offset + ustr[c] - 32));
-
- for (int j = 0; j < 5; j++) {
- for (int i = 0; i < 8; i++) {
- if (_fontSmall.get(position + j * multiplier2 + i)) {
- surface->setPixel(x + 8 - i + 4 * 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 + 4 * c, y + j, backColor);
- }
- }
- }
+ 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;
}
-}
-
-void DarkEngine::drawStringBigInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset) {
- if (!_fontLoaded)
- return;
- Common::String ustr = str;
- ustr.toUppercase();
-
- int multiplier1 = 16;
- int multiplier2 = 16;
for (uint32 c = 0; c < ustr.size(); c++) {
assert(ustr[c] >= 32);
- int position = 8 * (multiplier1*(offset + ustr[c] - 32) + 1);
- for (int j = 0; j < 8; j++) {
- for (int i = 0; i < 8; i++) {
- if (_fontBig.get(position + j * multiplier2 + i + 8)) {
- surface->setPixel(x + 8 - i + 8 * c, y + j, secondaryColor);
+ 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 + 8 * c, y + j, backColor);
+ surface->setPixel(x + 8 - i + sep * c, y + j, backColor);
}
}
}
}
}
-
} // End of namespace Freescape
diff --git a/engines/freescape/games/dark/atari.cpp b/engines/freescape/games/dark/atari.cpp
index 4a7a049dcff..8c5d0492b3e 100644
--- a/engines/freescape/games/dark/atari.cpp
+++ b/engines/freescape/games/dark/atari.cpp
@@ -32,8 +32,8 @@ void DarkEngine::loadAssetsAtariFullGame() {
parseAmigaAtariHeader(stream);
_border = loadAndConvertNeoImage(stream, 0xd710);
- loadFonts(stream, 0xd06a, _fontBig); //0x7f0);
- loadFonts(stream, 0xd499, _fontMedium);
+ loadFonts(stream, 0xd06b, _fontBig);
+ loadFonts(stream, 0xd49a, _fontMedium);
loadFonts(stream, 0xd49b, _fontSmall);
load8bitBinary(stream, 0x20918, 16);
diff --git a/engines/freescape/games/dark/dark.h b/engines/freescape/games/dark/dark.h
index 081c45b7490..76ef91693da 100644
--- a/engines/freescape/games/dark/dark.h
+++ b/engines/freescape/games/dark/dark.h
@@ -37,6 +37,12 @@ struct ECD {
int _id;
};
+enum DarkFontSize {
+ kDarkFontSmall,
+ kDarkFontMedium,
+ kDarkFontBig,
+};
+
class DarkEngine : public FreescapeEngine {
public:
DarkEngine(OSystem *syst, const ADGameDescription *gd);
@@ -91,10 +97,7 @@ public:
Common::BitArray _fontMedium;
Common::BitArray _fontSmall;
- void drawStringMediumInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
- void drawStringSmallInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
- void drawStringBigInSurface(const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
-
+ void drawString(const DarkFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface);
void drawInfoMenu() override;
Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
More information about the Scummvm-git-logs
mailing list