[Scummvm-git-logs] scummvm master -> 3d3a02483bcc254284b72282692b9710c59a90ee
phcoder
noreply at scummvm.org
Tue Jan 17 22:17:13 UTC 2023
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e70e91a8e2 NEVERHOOD: Add leftmost and rightmost pixel outline in subtitles
0ca10425b6 NEVERHOOD: Offset fonts when using left-centered nhc translations
de56f3f6be NEVERHOOD: Implement cheat framework and "itsshowtime" cheat
3d3a02483b NEVERHOOD: Fix subtitle outline color
Commit: e70e91a8e2b0f625517f70c560b9764f414389dc
https://github.com/scummvm/scummvm/commit/e70e91a8e2b0f625517f70c560b9764f414389dc
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-18T01:17:07+03:00
Commit Message:
NEVERHOOD: Add leftmost and rightmost pixel outline in subtitles
Changed paths:
engines/neverhood/subtitles.cpp
diff --git a/engines/neverhood/subtitles.cpp b/engines/neverhood/subtitles.cpp
index b94b41e1863..1ecb986d003 100644
--- a/engines/neverhood/subtitles.cpp
+++ b/engines/neverhood/subtitles.cpp
@@ -32,10 +32,10 @@ void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const Sub
byte *dest0 = (byte*)surf->getBasePtr(0, 0);
- int lastx = MIN<int>(str.size() * SubtitlePlayer::kSubtitleCharWidth + x0, surf->w);
+ int lastx = MIN<int>(str.size() * SubtitlePlayer::kSubtitleCharWidth + x0 + 1, surf->w);
for (int16 yc = 0; yc < SubtitlePlayer::kSubtitleCharHeight; yc++) {
byte *dest = dest0 + yc * surf->pitch;
- memset(dest, SubtitlePlayer::kSubtitleAlpha, x0);
+ memset(dest, SubtitlePlayer::kSubtitleAlpha, x0 + 2);
memset(dest + lastx, SubtitlePlayer::kSubtitleAlpha, surf->w - lastx);
}
@@ -44,14 +44,21 @@ void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const Sub
byte *dest = dest0 + i * SubtitlePlayer::kSubtitleCharWidth + x0;
for (int16 yc = 0; yc < SubtitlePlayer::kSubtitleCharHeight; yc++) {
byte *row = dest;
+
+ // Outline of leftmost pixel
+ if (*row == SubtitlePlayer::kSubtitleAlpha && (subfont[c].bitmap[yc] & 0x80))
+ *row = 0x00;
+ row++;
for (int16 xc = 0; xc < SubtitlePlayer::kSubtitleCharWidth; xc++, row++) {
if ((subfont[c].bitmap[yc] << xc) & 0x80)
*row = 0xff;
else if ((subfont[c].outline[yc] << xc) & 0x80)
*row = 0x00;
- else
+ else if (xc != 0)
*row = SubtitlePlayer::kSubtitleAlpha;
}
+ // Outline of rightmost pixel
+ *row = (subfont[c].bitmap[yc] & 0x1) ? 0x00 : SubtitlePlayer::kSubtitleAlpha;
dest += surf->pitch;
}
}
@@ -102,9 +109,9 @@ void SubtitlePlayer::renderFrame(uint frameNumber, int centerX) {
if (frameNumber < _subtitles[i].fromFrame || frameNumber > _subtitles[i].toFrame)
continue;
Common::String curStr = _subtitles[i].text;
- if ((int)curStr.size() > screenWidth / SubtitlePlayer::kSubtitleCharWidth)
+ if ((int)curStr.size() > (screenWidth - 2) / SubtitlePlayer::kSubtitleCharWidth)
curStr = curStr.substr(0, screenWidth / SubtitlePlayer::kSubtitleCharWidth - 3) + "...";
- int width = curStr.size() * SubtitlePlayer::kSubtitleCharWidth;
+ int width = curStr.size() * SubtitlePlayer::kSubtitleCharWidth + 2;
int startX = MAX(MIN(centerX - width / 2, screenWidth - width), 0);
if (_subtitles[i].isTop) {
Commit: 0ca10425b6fa5e8d7813e4d2ef36cfcce09ed1ca
https://github.com/scummvm/scummvm/commit/0ca10425b6fa5e8d7813e4d2ef36cfcce09ed1ca
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-18T01:17:07+03:00
Commit Message:
NEVERHOOD: Offset fonts when using left-centered nhc translations
Changed paths:
engines/neverhood/modules/module1000.cpp
engines/neverhood/modules/module2200.cpp
engines/neverhood/neverhood.cpp
engines/neverhood/neverhood.h
engines/neverhood/resourceman.cpp
engines/neverhood/resourceman.h
diff --git a/engines/neverhood/modules/module1000.cpp b/engines/neverhood/modules/module1000.cpp
index 23892efd79f..0963aa55673 100644
--- a/engines/neverhood/modules/module1000.cpp
+++ b/engines/neverhood/modules/module1000.cpp
@@ -668,12 +668,16 @@ void Scene1005::drawTextToBackground() {
} else {
TextResource textResource(_vm);
const char *textStart, *textEnd;
- int16 y = 36;
+ int16 x = 188, y = 36;
FontSurface *fontSurface = FontSurface::createFontSurface(_vm, getGlobalVar(V_ENTRANCE_OPEN) ? 0x283CE401 : 0xC6604282);
textResource.load(0x80283101);
textStart = textResource.getString(textIndex, textEnd);
+ if (_vm->shouldOffsetFontNhc()) {
+ x += 15;
+ y += 18;
+ }
while (textStart < textEnd) {
- fontSurface->drawString(_background->getSurface(), 188, y, (const byte*)textStart);
+ fontSurface->drawString(_background->getSurface(), x, y, (const byte*)textStart);
y += 36;
textStart += strlen(textStart) + 1;
}
diff --git a/engines/neverhood/modules/module2200.cpp b/engines/neverhood/modules/module2200.cpp
index 85f5134df54..81f74588c4c 100644
--- a/engines/neverhood/modules/module2200.cpp
+++ b/engines/neverhood/modules/module2200.cpp
@@ -1455,7 +1455,11 @@ void Scene2208::drawRow(int16 rowIndex) {
_background->getSurface()->copyFrom(_backgroundSurface->getSurface(), 0, y, sourceRect);
if (rowIndex < (int)_strings.size()) {
const char *text = _strings[rowIndex];
- _fontSurface->drawString(_background->getSurface(), 95, y, (const byte*)text);
+ int16 x = 95;
+ if (_vm->shouldOffsetFontNhc()) {
+ x += 15;
+ }
+ _fontSurface->drawString(_background->getSurface(), x, y, (const byte*)text);
}
}
}
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 90a9f5b13b8..b6cfc2c99b8 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -47,7 +47,7 @@
namespace Neverhood {
NeverhoodEngine::NeverhoodEngine(OSystem *syst, const ADGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _haveSubtitles(false) {
+ Engine(syst), _gameDescription(gameDesc), _haveSubtitles(false), _nhcOffsetFont(false) {
// Setup mixer
if (!_mixer->isReady()) {
warning("Sound initialization failed.");
@@ -102,6 +102,16 @@ Common::Error NeverhoodEngine::run() {
Common::String nhcFile = ConfMan.get("nhc_file");
if (!nhcFile.empty() && _res->addNhcArchive("language/" + nhcFile + ".nhc")) {
+ uint32 fontSpecHash = calcHash("asRecFont");
+ if (_res->nhcExists(fontSpecHash, kResTypeData)) {
+ DataResource fontData(this);
+ fontData.load(fontSpecHash);
+
+ _nhcOffsetFont = (fontData.getPoint(calcHash("meNumRows")).x == 14
+ && fontData.getPoint(calcHash("meFirstChar")).x == 32
+ && fontData.getPoint(calcHash("meCharHeight")).x == 34
+ && fontData.getPointArray(calcHash("meTracking"))->size() == 224);
+ }
if (ConfMan.getBool("subtitles")) {
Common::SeekableReadStream *s = _res->createNhcStream(0x544E4F46, kResNhcTypeSubFont);
if (s && s->size() >= 4096) {
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index 5b13eefe831..5f9a4f54b4e 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -138,6 +138,7 @@ public:
void toggleSoundUpdate(bool state) { _updateSound = state; }
void toggleMusic(bool state) { _enableMusic = state; }
bool musicIsEnabled() { return _enableMusic; }
+ bool shouldOffsetFontNhc() const { return _nhcOffsetFont; }
const SubtitleGlyph *getSubfont() const {
return _haveSubtitles ? _subFont : nullptr;
@@ -146,6 +147,7 @@ public:
private:
bool _updateSound;
bool _enableMusic;
+ bool _nhcOffsetFont;
SubtitleGlyph _subFont[256];
bool _haveSubtitles;
diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp
index 2f0394f9873..8269a17caa6 100644
--- a/engines/neverhood/resourceman.cpp
+++ b/engines/neverhood/resourceman.cpp
@@ -122,6 +122,15 @@ Common::SeekableReadStream *ResourceMan::createNhcStream(uint32 fileHash, uint32
return nullptr;
}
+bool ResourceMan::nhcExists(uint32 fileHash, uint32 type) {
+ ResourceFileEntry *entry = findEntry(fileHash);
+ if (!entry)
+ return false;
+ if (entry->nhcArchiveEntry && entry->nhcArchive && entry->nhcArchiveEntry->type == type)
+ return true;
+ return false;
+}
+
void ResourceMan::queryResource(uint32 fileHash, ResourceHandle &resourceHandle) {
ResourceFileEntry *firstEntry;
resourceHandle._resourceFileEntry = findEntry(fileHash, &firstEntry);
diff --git a/engines/neverhood/resourceman.h b/engines/neverhood/resourceman.h
index ad7c5313940..aeda82a9621 100644
--- a/engines/neverhood/resourceman.h
+++ b/engines/neverhood/resourceman.h
@@ -114,6 +114,7 @@ public:
ResourceFileEntry *findEntry(uint32 fileHash, ResourceFileEntry **firstEntry = NULL);
Common::SeekableReadStream *createStream(uint32 fileHash);
Common::SeekableReadStream *createNhcStream(uint32 fileHash, uint32 type);
+ bool nhcExists(uint32 fileHash, uint32 type);
const ResourceFileEntry& getEntry(uint index) { return _entries[index]; }
uint getEntryCount() { return _entries.size(); }
void queryResource(uint32 fileHash, ResourceHandle &resourceHandle);
Commit: de56f3f6be0eb6d5b77baa80a8cb56f6787fcaac
https://github.com/scummvm/scummvm/commit/de56f3f6be0eb6d5b77baa80a8cb56f6787fcaac
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-18T01:17:07+03:00
Commit Message:
NEVERHOOD: Implement cheat framework and "itsshowtime" cheat
Changed paths:
engines/neverhood/diskplayerscene.cpp
engines/neverhood/gamemodule.cpp
engines/neverhood/gamemodule.h
engines/neverhood/messages.h
diff --git a/engines/neverhood/diskplayerscene.cpp b/engines/neverhood/diskplayerscene.cpp
index 7570af8b6b9..6a92dd96570 100644
--- a/engines/neverhood/diskplayerscene.cpp
+++ b/engines/neverhood/diskplayerscene.cpp
@@ -464,6 +464,13 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam ¶m,
}
}
break;
+ case NM_CHEAT:
+ if (param.asInteger() == 0x2C034A29 && !_dropKey && !_hasAllDisks) { // "itsshowtime"
+ for (uint i = 0; i < 20; i++)
+ setSubVar(VA_HAS_TAPE, i, 1);
+ sendMessage(_parentModule, 0x1009, 0);
+ }
+ break;
case NM_ANIMATION_UPDATE:
tuneIn();
break;
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 23bfe51eb3d..e10e61e0dd0 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -142,6 +142,17 @@ void GameModule::handleAsciiKey(char key) {
debug(2, "GameModule::handleAsciiKey()");
sendMessage(_childObject, 0x000A, (uint32)key);
}
+
+ if (key == '\n' || key == '\r') {
+ if (!_currentCheat.empty() && _childObject) {
+ uint32 cheatHash = calcHash(_currentCheat.c_str());
+ debug(2, "GameModule: cheat=\"%s\" (0x%08x)", _currentCheat.c_str(), cheatHash);
+ sendMessage(_childObject, NM_CHEAT, cheatHash);
+ } else if (!_currentCheat.empty())
+ debug(2, "GameModule: cheat=\"%s\" but no child", _currentCheat.c_str());
+ _currentCheat.clear();
+ } else if (key)
+ _currentCheat += key;
}
void GameModule::handleKeyDown(Common::KeyCode keyCode) {
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 46f1a24c86f..52eae03358f 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -68,6 +68,7 @@ protected:
bool _restartGameRequested;
bool _canRequestMainMenu;
bool _mainMenuRequested;
+ Common::String _currentCheat;
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
void createModuleByHash(uint32 nameHash);
void updateModule();
diff --git a/engines/neverhood/messages.h b/engines/neverhood/messages.h
index 9dea95cabc2..470ee96e779 100644
--- a/engines/neverhood/messages.h
+++ b/engines/neverhood/messages.h
@@ -32,6 +32,7 @@ enum NeverhoodMessage {
NM_MOUSE_SHOW = 0x101E,
NM_KEYPRESS_SPACE = 0x0009,
NM_KEYPRESS_ESC = 0x000C,
+ NM_CHEAT = 0x000D,
NM_ANIMATION_START = 0x100D,
NM_SCENE_LEAVE = 0x1019,
NM_PRIORITY_CHANGE = 0x1022,
Commit: 3d3a02483bcc254284b72282692b9710c59a90ee
https://github.com/scummvm/scummvm/commit/3d3a02483bcc254284b72282692b9710c59a90ee
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-18T01:17:07+03:00
Commit Message:
NEVERHOOD: Fix subtitle outline color
Changed paths:
engines/neverhood/smackerplayer.cpp
engines/neverhood/sprite.cpp
engines/neverhood/subtitles.cpp
engines/neverhood/subtitles.h
diff --git a/engines/neverhood/smackerplayer.cpp b/engines/neverhood/smackerplayer.cpp
index 2f460854f02..a992e8514de 100644
--- a/engines/neverhood/smackerplayer.cpp
+++ b/engines/neverhood/smackerplayer.cpp
@@ -46,7 +46,7 @@ void SmackerSurface::draw() {
subDrawRect.y = _drawRect.y + _drawRect.height - 17;
subDrawRect.width = _drawRect.width;
subDrawRect.height = 16;
- _vm->_screen->drawSurface2(bottom, subDrawRect, _clipRect, true, ++_version, nullptr, _subtitles->kSubtitleAlpha);
+ _vm->_screen->drawSurface2(bottom, subDrawRect, _clipRect, true, ++_version, nullptr, _subtitles->getSubtitleAlpha());
}
const Graphics::Surface *top = _subtitles->getTopSubs();
if (top) {
@@ -55,7 +55,7 @@ void SmackerSurface::draw() {
subDrawRect.y = _drawRect.y + 1;
subDrawRect.width = _drawRect.width;
subDrawRect.height = 16;
- _vm->_screen->drawSurface2(top, subDrawRect, _clipRect, true, ++_version, nullptr, _subtitles->kSubtitleAlpha);
+ _vm->_screen->drawSurface2(top, subDrawRect, _clipRect, true, ++_version, nullptr, _subtitles->getSubtitleAlpha());
}
}
}
@@ -103,7 +103,7 @@ void SmackerDoubleSurface::draw() {
subDrawRect.y = _drawRect.y + _drawRect.height * 2 - 34;
subDrawRect.width = _drawRect.width;
subDrawRect.height = 16;
- _vm->_screen->drawDoubleSurface2Alpha(bottom, subDrawRect, _subtitles->kSubtitleAlpha);
+ _vm->_screen->drawDoubleSurface2Alpha(bottom, subDrawRect, _subtitles->getSubtitleAlpha());
}
const Graphics::Surface *top = _subtitles->getTopSubs();
if (top) {
@@ -112,7 +112,7 @@ void SmackerDoubleSurface::draw() {
subDrawRect.y = _drawRect.y + 2;
subDrawRect.width = _drawRect.width;
subDrawRect.height = 16;
- _vm->_screen->drawDoubleSurface2Alpha(top, subDrawRect, _subtitles->kSubtitleAlpha);
+ _vm->_screen->drawDoubleSurface2Alpha(top, subDrawRect, _subtitles->getSubtitleAlpha());
}
}
}
diff --git a/engines/neverhood/sprite.cpp b/engines/neverhood/sprite.cpp
index 808c3a953f3..4f36dd0fa81 100644
--- a/engines/neverhood/sprite.cpp
+++ b/engines/neverhood/sprite.cpp
@@ -418,7 +418,7 @@ void AnimatedSprite::AnimatedSpriteSubtitles::draw() {
_backref->_subtitles->renderFrame(_backref->_currFrameIndex, subCenterX - getDrawRect().x);
const Graphics::Surface *bottom = _backref->_subtitles->getBottomSubs();
if (bottom) {
- _vm->_screen->drawSurface2(bottom, _drawRect, _clipRect, true, ++_version, nullptr, _backref->_subtitles->kSubtitleAlpha);
+ _vm->_screen->drawSurface2(bottom, _drawRect, _clipRect, true, ++_version, nullptr, _backref->_subtitles->getSubtitleAlpha());
}
if (_backref->_subtitles->getTopSubs())
warning("Top subs are unsupported");
diff --git a/engines/neverhood/subtitles.cpp b/engines/neverhood/subtitles.cpp
index 1ecb986d003..e25ad88bdef 100644
--- a/engines/neverhood/subtitles.cpp
+++ b/engines/neverhood/subtitles.cpp
@@ -19,14 +19,18 @@
*
*/
+#include "graphics/palette.h"
+
#include "neverhood/resource.h"
#include "neverhood/resourceman.h"
+#include "neverhood/screen.h"
#include "neverhood/subtitles.h"
namespace Neverhood {
namespace {
-void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const SubtitleGlyph *subfont, int x0) {
+void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const SubtitleGlyph *subfont,
+ int x0, byte outlineColor, byte alphaColor) {
if (!surf || surf->h < SubtitlePlayer::kSubtitleCharHeight || !subfont)
return;
@@ -35,8 +39,8 @@ void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const Sub
int lastx = MIN<int>(str.size() * SubtitlePlayer::kSubtitleCharWidth + x0 + 1, surf->w);
for (int16 yc = 0; yc < SubtitlePlayer::kSubtitleCharHeight; yc++) {
byte *dest = dest0 + yc * surf->pitch;
- memset(dest, SubtitlePlayer::kSubtitleAlpha, x0 + 2);
- memset(dest + lastx, SubtitlePlayer::kSubtitleAlpha, surf->w - lastx);
+ memset(dest, alphaColor, x0 + 2);
+ memset(dest + lastx, alphaColor, surf->w - lastx);
}
for (int i = 0; i < (int)str.size() && i * SubtitlePlayer::kSubtitleCharWidth < surf->w; i++) {
@@ -46,19 +50,19 @@ void drawSubtitles(Graphics::Surface *surf, const Common::String &str, const Sub
byte *row = dest;
// Outline of leftmost pixel
- if (*row == SubtitlePlayer::kSubtitleAlpha && (subfont[c].bitmap[yc] & 0x80))
- *row = 0x00;
+ if (*row == alphaColor && (subfont[c].bitmap[yc] & 0x80))
+ *row = outlineColor;
row++;
for (int16 xc = 0; xc < SubtitlePlayer::kSubtitleCharWidth; xc++, row++) {
if ((subfont[c].bitmap[yc] << xc) & 0x80)
*row = 0xff;
else if ((subfont[c].outline[yc] << xc) & 0x80)
- *row = 0x00;
+ *row = outlineColor;
else if (xc != 0)
- *row = SubtitlePlayer::kSubtitleAlpha;
+ *row = alphaColor;
}
// Outline of rightmost pixel
- *row = (subfont[c].bitmap[yc] & 0x1) ? 0x00 : SubtitlePlayer::kSubtitleAlpha;
+ *row = (subfont[c].bitmap[yc] & 0x1) ? outlineColor : alphaColor;
dest += surf->pitch;
}
}
@@ -104,6 +108,14 @@ void SubtitlePlayer::renderFrame(uint frameNumber, int centerX) {
_haveBottomSubs = false;
_haveTopSubs = false;
+ Graphics::PaletteLookup palLookup(_vm->_screen->getPaletteData(), 256);
+
+ byte outlineColor = palLookup.findBestColor(0, 0, 0);
+ _alphaColor = 0x77;
+
+ if (_alphaColor == outlineColor)
+ _alphaColor++;
+
// TODO: Optimize this
for (uint i = 0; i < _subtitles.size(); i++) {
if (frameNumber < _subtitles[i].fromFrame || frameNumber > _subtitles[i].toFrame)
@@ -115,10 +127,10 @@ void SubtitlePlayer::renderFrame(uint frameNumber, int centerX) {
int startX = MAX(MIN(centerX - width / 2, screenWidth - width), 0);
if (_subtitles[i].isTop) {
- drawSubtitles(&_topSubs, curStr, subFont, startX);
+ drawSubtitles(&_topSubs, curStr, subFont, startX, outlineColor, _alphaColor);
_haveTopSubs = true;
} else {
- drawSubtitles(&_bottomSubs, curStr, subFont, startX);
+ drawSubtitles(&_bottomSubs, curStr, subFont, startX, outlineColor, _alphaColor);
_haveBottomSubs = true;
}
}
diff --git a/engines/neverhood/subtitles.h b/engines/neverhood/subtitles.h
index 3cd4d656aee..216d85255f5 100644
--- a/engines/neverhood/subtitles.h
+++ b/engines/neverhood/subtitles.h
@@ -43,8 +43,8 @@ public:
const Graphics::Surface *getBottomSubs() const { return _haveBottomSubs ? &_bottomSubs : nullptr; }
const Graphics::Surface *getTopSubs() const { return _haveTopSubs ? &_topSubs : nullptr; }
bool isValid() const { return _isValid && !_subtitles.empty(); }
+ byte getSubtitleAlpha() const { return _alphaColor; }
- static const byte kSubtitleAlpha = 0x77;
static const int kSubtitleCharHeight = 16;
static const int kSubtitleCharWidth = 8;
@@ -57,6 +57,7 @@ private:
bool _haveBottomSubs;
bool _haveTopSubs;
int64 _currentFrame;
+ byte _alphaColor;
};
} // End of namespace Neverhood
More information about the Scummvm-git-logs
mailing list