[Scummvm-git-logs] scummvm master -> 85f63350ba99f70d4cc5554e127f4fa2c9bbe215
AndywinXp
noreply at scummvm.org
Thu Sep 28 22:01:57 UTC 2023
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:
85f63350ba SWORD1: PSX: Implement (mostly) accurate text positioning
Commit: 85f63350ba99f70d4cc5554e127f4fa2c9bbe215
https://github.com/scummvm/scummvm/commit/85f63350ba99f70d4cc5554e127f4fa2c9bbe215
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-29T00:01:52+02:00
Commit Message:
SWORD1: PSX: Implement (mostly) accurate text positioning
I say "mostly" because I still have off-by-one positioning inaccuracies,
and navigating the PSX disasm is very tiresome... I'm not even sure
we are rendering sprites in the correct position anymore... Argh!
Changed paths:
engines/sword1/logic.cpp
engines/sword1/text.cpp
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index 7131676caa7..1e9dc750d52 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -1206,7 +1206,11 @@ int Logic::fnISpeak(Object *cpt, int32 id, int32 cdt, int32 textNo, int32 spr, i
// now set text coords, above the player, usually
int textMargin = SwordEngine::_systemVars.isDemo ? 5 : 3; // distance kept from edges of screen
- int aboveHead = SwordEngine::_systemVars.isDemo ? 10 : 20; // distance kept above talking sprite
+
+ if (SwordEngine::isPsx())
+ textMargin = 33;
+
+ int aboveHead = (SwordEngine::_systemVars.isDemo || SwordEngine::isPsx()) ? 10 : 20; // distance kept above talking sprite
uint16 textX, textY;
if (((id == GEORGE) || ((id == NICO) && (_scriptVars[SCREEN] == 10))) && (!cpt->o_anim_resource)) {
// if George is doing Voice-Over text (centered at the bottom of the screen)
diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp
index 84b87b7307b..fd578b8411f 100644
--- a/engines/sword1/text.cpp
+++ b/engines/sword1/text.cpp
@@ -61,6 +61,10 @@ Text::Text(SwordEngine *vm, Logic *pLogic, ObjectMan *pObjMan, ResMan *pResMan,
}
_charHeight = _resMan->getUint16(_resMan->fetchFrame(_font, 0)->height); // all chars have the same height
+
+ if (SwordEngine::isPsx())
+ _charHeight /= 2;
+
for (int i = 0; i < MAX_TEXT_OBS; i++)
_textBlocks[i] = NULL;
}
@@ -98,6 +102,11 @@ void Text::makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8
sprWidth = lines[lineCnt].width;
uint16 sprHeight = _charHeight * numLines;
+ if (SwordEngine::isPsx()) {
+ sprHeight = 2 * _charHeight * numLines - 4 * (numLines - 1);
+ sprWidth = (sprWidth + 1) & 0xFFFE;
+ }
+
uint32 sprSize = sprWidth * sprHeight;
assert(!_textBlocks[slot]); // if this triggers, the speechDriver failed to call Text::releaseText.
_textBlocks[slot] = (FrameHeader *)malloc(sprSize + sizeof(FrameHeader));
@@ -133,8 +142,8 @@ void Text::makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8
curTextLine++; // skip space at the end of the line
text += lines[lineCnt].length + 1;
- if (SwordEngine::isPsx()) //Chars are half height in psx version
- linePtr += (_charHeight / 2) * sprWidth;
+ if (SwordEngine::isPsx())
+ linePtr += (_charHeight - 4) * sprWidth;
else
linePtr += _charHeight * sprWidth;
}
@@ -148,8 +157,11 @@ uint16 Text::charWidth(uint8 ch) {
uint16 Text::analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *line) {
uint16 lineNo = 0;
-
bool firstWord = true;
+
+ if (SwordEngine::isPsx())
+ maxWidth = 254;
+
while (*text) {
uint16 wordWidth = 0;
uint16 wordLength = 0;
More information about the Scummvm-git-logs
mailing list