mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
Add some work on text output in FF
svn-id: r21656
This commit is contained in:
+28
-11
@@ -89,7 +89,7 @@ void SimonEngine::print_char_helper_6(uint i) {
|
||||
}
|
||||
}
|
||||
|
||||
void SimonEngine::render_string_amiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt) {
|
||||
void SimonEngine::renderStringAmiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt) {
|
||||
VgaPointersEntry *vpe = &_vgaBufferPointers[2];
|
||||
byte *src, *dst, *dst_org, chr;
|
||||
uint count;
|
||||
@@ -180,9 +180,10 @@ void SimonEngine::render_string_amiga(uint vga_sprite_id, uint color, uint width
|
||||
}
|
||||
}
|
||||
|
||||
void SimonEngine::render_string(uint vga_sprite_id, uint color, uint width, uint height, const char *txt) {
|
||||
void SimonEngine::renderString(uint vga_sprite_id, uint color, uint width, uint height, const char *txt) {
|
||||
VgaPointersEntry *vpe = &_vgaBufferPointers[2];
|
||||
byte *src, *dst, *p, *dst_org, chr;
|
||||
const int textHeight = (getGameType() == GType_FF) ? 15: 10;
|
||||
uint count;
|
||||
|
||||
if (vga_sprite_id >= 100) {
|
||||
@@ -198,10 +199,15 @@ void SimonEngine::render_string(uint vga_sprite_id, uint color, uint width, uint
|
||||
|
||||
p = dst + vga_sprite_id * 8;
|
||||
|
||||
WRITE_BE_UINT16(p + 4, height);
|
||||
WRITE_BE_UINT16(p + 6, width);
|
||||
|
||||
dst += READ_BE_UINT32(p);
|
||||
if (getGameType() == GType_FF) {
|
||||
WRITE_LE_UINT16(p + 4, height);
|
||||
WRITE_LE_UINT16(p + 6, width);
|
||||
dst += READ_LE_UINT32(p);
|
||||
} else {
|
||||
WRITE_BE_UINT16(p + 4, height);
|
||||
WRITE_BE_UINT16(p + 6, width);
|
||||
dst += READ_BE_UINT32(p);
|
||||
}
|
||||
|
||||
memset(dst, 0, count);
|
||||
if (_language == Common::HB_ISR)
|
||||
@@ -210,15 +216,26 @@ void SimonEngine::render_string(uint vga_sprite_id, uint color, uint width, uint
|
||||
dst_org = dst;
|
||||
while ((chr = *txt++) != 0) {
|
||||
if (chr == 10) {
|
||||
dst_org += width * 10;
|
||||
dst_org += width * textHeight;
|
||||
dst = dst_org;
|
||||
} else if ((chr -= ' ') == 0) {
|
||||
dst += (_language == Common::HB_ISR ? -6 : 6); // Hebrew moves to the left, all others to the right
|
||||
} else {
|
||||
byte *img_hdr = src + 48 + chr * 4;
|
||||
uint img_height = img_hdr[2];
|
||||
uint img_width = img_hdr[3], i;
|
||||
byte *img = src + READ_LE_UINT16(img_hdr);
|
||||
byte *img_hdr, *img;
|
||||
uint i, img_width, img_height;
|
||||
|
||||
if (getGameType() == GType_FF) {
|
||||
img_hdr = src + 96 + chr * 8;
|
||||
img_height = READ_LE_UINT16(img_hdr + 4);
|
||||
img_width = READ_LE_UINT16(img_hdr + 6);
|
||||
img = src + READ_LE_UINT32(img_hdr);
|
||||
} else {
|
||||
img_hdr = src + 48 + chr * 4;
|
||||
img_height = img_hdr[2];
|
||||
img_width = img_hdr[3];
|
||||
img = src + READ_LE_UINT16(img_hdr);
|
||||
}
|
||||
|
||||
if (_language == Common::HB_ISR)
|
||||
dst -= img_width - 1; // For Hebrew, move from right edge to left edge of image.
|
||||
byte *cur_dst = dst;
|
||||
|
||||
+13
-16
@@ -1255,7 +1255,7 @@ void SimonEngine::o1_scnTxtLongText(bool &cond, int &ret) {
|
||||
if (_speech && speechId != 0)
|
||||
playSpeech(speechId, vgaSpriteId);
|
||||
if (string_ptr != NULL && _subtitles)
|
||||
printText(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
||||
printScreenText(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
||||
}
|
||||
|
||||
void SimonEngine::o1_mouseOn(bool &cond, int &ret) {
|
||||
@@ -1318,7 +1318,14 @@ void SimonEngine::o2_printLongText(bool &cond, int &ret) {
|
||||
|
||||
void SimonEngine::o2_rescan(bool &cond, int &ret) {
|
||||
// 83: restart subroutine
|
||||
o_83_helper();
|
||||
if (_exitCutscene) {
|
||||
if (getBitFlag(9)) {
|
||||
endCutscene();
|
||||
}
|
||||
} else {
|
||||
processSpecialKeys();
|
||||
}
|
||||
|
||||
ret = -10;
|
||||
}
|
||||
|
||||
@@ -1379,9 +1386,9 @@ void SimonEngine::o3_jumpOut(bool &cond, int &ret) {
|
||||
|
||||
void SimonEngine::o3_printLongText(bool &cond, int &ret) {
|
||||
// 70: show string from array
|
||||
int tmp = getVarOrByte();
|
||||
const char *str = (const char *)getStringPtrByID(_stringIdArray3[tmp]);
|
||||
showMessageFormat("%d. %s\n", tmp, str);
|
||||
int num = getVarOrByte();
|
||||
const char *str = (const char *)getStringPtrByID(_stringIdArray3[num]);
|
||||
printInteractText(num, str);
|
||||
}
|
||||
|
||||
void SimonEngine::o3_oracleTextDown(bool &cond, int &ret) {
|
||||
@@ -1644,16 +1651,6 @@ bool SimonEngine::checkIfToRunSubroutineLine(SubroutineLine *sl, Subroutine *sub
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimonEngine::o_83_helper() {
|
||||
if (_exitCutscene) {
|
||||
if (getBitFlag(9)) {
|
||||
endCutscene();
|
||||
}
|
||||
} else {
|
||||
processSpecialKeys();
|
||||
}
|
||||
}
|
||||
|
||||
void SimonEngine::o_waitForMark(uint i) {
|
||||
_exitCutscene = false;
|
||||
while (!(_marks & (1 << i))) {
|
||||
@@ -1781,7 +1778,7 @@ void SimonEngine::o_inventory_descriptions() {
|
||||
string_ptr = buf;
|
||||
}
|
||||
if (string_ptr != NULL)
|
||||
printText(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
||||
printScreenText(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ MODULE_OBJS := \
|
||||
saveload.o \
|
||||
simon.o \
|
||||
sound.o \
|
||||
string.o \
|
||||
verb.o \
|
||||
vga.o \
|
||||
|
||||
|
||||
+4
-90
@@ -252,6 +252,7 @@ SimonEngine::SimonEngine(OSystem *syst)
|
||||
_speech = true;
|
||||
_subtitles = true;
|
||||
_fade = true;
|
||||
_animatePointer = 0;
|
||||
_mouseCursor = 0;
|
||||
_mouseAnim = 0;
|
||||
_mouseAnimMax = 0;
|
||||
@@ -444,6 +445,7 @@ SimonEngine::SimonEngine(OSystem *syst)
|
||||
_saveLoadFlag = false;
|
||||
|
||||
_hyperLink = 0;
|
||||
_interactY = 0;
|
||||
_oracleMaxScrollY = 0;
|
||||
_noOracleScroll = 0;
|
||||
|
||||
@@ -1586,7 +1588,7 @@ void SimonEngine::setup_cond_c_helper() {
|
||||
animMax = 9;
|
||||
}
|
||||
|
||||
//_animatePointer = 0;
|
||||
_animatePointer = 0;
|
||||
_mouseCursor = cursor;
|
||||
_mouseAnimMax = animMax;
|
||||
_mouseAnim = 1;
|
||||
@@ -2151,7 +2153,7 @@ void SimonEngine::o_printStr() {
|
||||
o_kill_sprite_simon2(2, vgaSpriteId + 2);
|
||||
|
||||
if (string_ptr != NULL && (speech_id == 0 || _subtitles))
|
||||
printText(vgaSpriteId, color, (const char *)string_ptr, tl->x, tl->y, tl->width);
|
||||
printScreenText(vgaSpriteId, color, (const char *)string_ptr, tl->x, tl->y, tl->width);
|
||||
|
||||
}
|
||||
|
||||
@@ -3345,94 +3347,6 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) {
|
||||
}
|
||||
}
|
||||
|
||||
void SimonEngine::printText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) {
|
||||
// FIXME
|
||||
if (getGameType() == GType_FF)
|
||||
return;
|
||||
|
||||
char convertedString[320];
|
||||
char *convertedString2 = convertedString;
|
||||
int16 height, talkDelay;
|
||||
int stringLength = strlen(string);
|
||||
int padding, lettersPerRow, lettersPerRowJustified;
|
||||
const int textHeight = 10;
|
||||
|
||||
height = textHeight;
|
||||
lettersPerRow = width / 6;
|
||||
lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1;
|
||||
|
||||
talkDelay = (stringLength + 3) / 3;
|
||||
if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) {
|
||||
if (_variableArray[141] == 0)
|
||||
_variableArray[141] = 9;
|
||||
_variableArray[85] = _variableArray[141] * talkDelay;
|
||||
} else {
|
||||
if (_variableArray[86] == 0)
|
||||
talkDelay /= 2;
|
||||
if (_variableArray[86] == 2)
|
||||
talkDelay *= 2;
|
||||
_variableArray[85] = talkDelay * 5;
|
||||
}
|
||||
|
||||
assert(stringLength > 0);
|
||||
while (stringLength > 0) {
|
||||
int pos = 0;
|
||||
if (stringLength > lettersPerRow) {
|
||||
int removeLastWord = 0;
|
||||
if (lettersPerRow > lettersPerRowJustified) {
|
||||
pos = lettersPerRowJustified;
|
||||
while (string[pos] != ' ')
|
||||
pos++;
|
||||
if (pos > lettersPerRow)
|
||||
removeLastWord = 1;
|
||||
}
|
||||
if (lettersPerRow <= lettersPerRowJustified || removeLastWord) {
|
||||
pos = lettersPerRow;
|
||||
while (string[pos] != ' ' && pos > 0)
|
||||
pos--;
|
||||
}
|
||||
height += textHeight;
|
||||
y -= textHeight;
|
||||
} else
|
||||
pos = stringLength;
|
||||
padding = (lettersPerRow - pos) % 2 ?
|
||||
(lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2;
|
||||
while (padding--)
|
||||
*convertedString2++ = ' ';
|
||||
stringLength -= pos;
|
||||
while (pos--)
|
||||
*convertedString2++ = *string++;
|
||||
*convertedString2++ = '\n';
|
||||
string++; // skip space
|
||||
stringLength--; // skip space
|
||||
}
|
||||
*(convertedString2 - 1) = '\0';
|
||||
|
||||
if (getGameType() == GType_SIMON1)
|
||||
o_kill_sprite_simon1(vgaSpriteId + 199);
|
||||
else
|
||||
o_kill_sprite_simon2(2, vgaSpriteId);
|
||||
|
||||
color = color * 3 + 192;
|
||||
if (getPlatform() == Common::kPlatformAmiga)
|
||||
render_string_amiga(vgaSpriteId, color, width, height, convertedString);
|
||||
else
|
||||
render_string(vgaSpriteId, color, width, height, convertedString);
|
||||
|
||||
int b = 4;
|
||||
if (!getBitFlag(133))
|
||||
b = 3;
|
||||
|
||||
x /= 8;
|
||||
if (y < 2)
|
||||
y = 2;
|
||||
|
||||
if (getGameType() == GType_SIMON1)
|
||||
loadSprite(b, 2, vgaSpriteId + 199, x, y, 12);
|
||||
else
|
||||
loadSprite(b, 2, vgaSpriteId, x, y, 12);
|
||||
}
|
||||
|
||||
// Thanks to Stuart Caie for providing the original
|
||||
// C conversion upon which this decruncher is based.
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ protected:
|
||||
bool _speech;
|
||||
bool _subtitles;
|
||||
bool _fade;
|
||||
byte _animatePointer;
|
||||
byte _mouseCursor;
|
||||
byte _mouseAnim;
|
||||
byte _mouseAnimMax;
|
||||
@@ -273,7 +274,8 @@ protected:
|
||||
|
||||
uint16 _hyperLink, _newLines;
|
||||
uint16 _oracleMaxScrollY, _noOracleScroll;
|
||||
|
||||
uint16 _interactY;
|
||||
|
||||
int16 _scriptVerb, _scriptNoun1, _scriptNoun2;
|
||||
int16 _scriptAdj1, _scriptAdj2;
|
||||
|
||||
@@ -648,6 +650,7 @@ protected:
|
||||
void printVerbOf(uint hitarea_id);
|
||||
HitArea *findHitAreaByID(uint hitarea_id);
|
||||
|
||||
void printInteractText(uint16 num, const char *string);
|
||||
void showActionString(const byte *string);
|
||||
void videoPutchar(WindowBlock *window, byte c, byte b = 0);
|
||||
void clearWindow(WindowBlock *window);
|
||||
@@ -659,8 +662,8 @@ protected:
|
||||
|
||||
void setup_hitarea_from_pos(uint x, uint y, uint mode);
|
||||
void displayName(HitArea * ha);
|
||||
bool printTextOf(uint a);
|
||||
bool printNameOf(Item *item);
|
||||
bool printTextOf(uint a, uint x, uint y);
|
||||
bool printNameOf(Item *item, uint x, uint y);
|
||||
void displayBoxStars();
|
||||
void hitarea_stuff();
|
||||
|
||||
@@ -695,11 +698,11 @@ protected:
|
||||
void loadSprite(uint windowNum, uint vga_res, uint vga_sprite_id, uint x, uint y, uint palette);
|
||||
void o_defineWindow(uint a, uint b, uint c, uint d, uint e, uint f, uint g, uint h);
|
||||
void playSpeech(uint speech_id, uint vga_sprite_id);
|
||||
void printText(uint vga_sprite_id, uint color, const char *string_ptr, int16 x, int16 y, int16 width);
|
||||
void printScreenText(uint vga_sprite_id, uint color, const char *string_ptr, int16 x, int16 y, int16 width);
|
||||
WindowBlock *openWindow(uint x, uint y, uint w, uint h, uint flags, uint fill_color, uint text_color);
|
||||
|
||||
void render_string_amiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt);
|
||||
void render_string(uint vga_sprite_id, uint color, uint width, uint height, const char *txt);
|
||||
void renderStringAmiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt);
|
||||
void renderString(uint vga_sprite_id, uint color, uint width, uint height, const char *txt);
|
||||
|
||||
void setArrowHitAreas(WindowBlock *window, uint num);
|
||||
|
||||
@@ -1082,7 +1085,6 @@ protected:
|
||||
void delay(uint delay);
|
||||
void pause();
|
||||
|
||||
void o_83_helper();
|
||||
void o_waitForMark(uint i);
|
||||
void scrollEvent();
|
||||
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2006 The ScummVM project
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/stdafx.h"
|
||||
|
||||
#include "simon/simon.h"
|
||||
#include "simon/intern.h"
|
||||
|
||||
namespace Simon {
|
||||
|
||||
static const byte charWidth[226] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 6, 2, 4, 8, 6,10, 9, 2,
|
||||
4, 4, 6, 6, 3, 4, 2, 3, 6, 4,
|
||||
6, 6, 7, 6, 6, 6, 6, 6, 2, 3,
|
||||
7, 7, 7, 6,11, 8, 7, 8, 8, 7,
|
||||
6, 9, 8, 2, 6, 7, 6,10, 8, 9,
|
||||
7, 9, 7, 7, 8, 8, 8,12, 8, 8,
|
||||
7, 3, 3, 3, 6, 8, 3, 7, 7, 6,
|
||||
7, 7, 4, 7, 6, 2, 3, 6, 2,10,
|
||||
6, 7, 7, 7, 5, 6, 4, 7, 7,10,
|
||||
6, 6, 6, 0, 0, 0, 0, 0, 8, 6,
|
||||
7, 7, 7, 7, 7, 6, 7, 7, 7, 4,
|
||||
4, 3, 8, 8, 7, 0, 0, 7, 7, 7,
|
||||
6, 6, 6, 9, 8, 0, 0, 0, 0, 0,
|
||||
7, 3, 7, 6, 6, 8, 0, 6, 0, 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 7
|
||||
};
|
||||
|
||||
static int getPixelLength(const char *string, int16 width) {
|
||||
int pixels = 0;
|
||||
while (*string != 0) {
|
||||
byte chr = *string;
|
||||
if ((pixels + charWidth[chr]) > width)
|
||||
break;
|
||||
pixels += charWidth[chr];
|
||||
}
|
||||
return pixels;
|
||||
}
|
||||
|
||||
bool SimonEngine::printTextOf(uint a, uint x, uint y) {
|
||||
const byte *stringPtr;
|
||||
|
||||
if (getGameType() == GType_SIMON2) {
|
||||
if (getBitFlag(79)) {
|
||||
Subroutine *sub;
|
||||
_variableArray[84] = a;
|
||||
sub = getSubroutineByID(5003);
|
||||
if (sub != NULL)
|
||||
startSubroutineEx(sub);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (a >= 20)
|
||||
return false;
|
||||
|
||||
|
||||
stringPtr = getStringPtrByID(_stringIdArray2[a]);
|
||||
if (getGameType() == GType_FF) {
|
||||
uint w = getPixelLength((const char *)stringPtr, 400) + 1;
|
||||
x -= w / 2;
|
||||
printScreenText(6, 0, (const char *)stringPtr, x, y, w);
|
||||
} else {
|
||||
showActionString(stringPtr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimonEngine::printNameOf(Item *item, uint x, uint y) {
|
||||
SubObject *subObject;
|
||||
const byte *stringPtr;
|
||||
|
||||
if (item == 0 || item == _dummyItem2 || item == _dummyItem3)
|
||||
return false;
|
||||
|
||||
subObject = (SubObject *)findChildOfType(item, 2);
|
||||
if (subObject == NULL)
|
||||
return false;
|
||||
|
||||
stringPtr = getStringPtrByID(subObject->objectName);
|
||||
if (getGameType() == GType_FF) {
|
||||
uint w = getPixelLength((const char *)stringPtr, 400) + 1;
|
||||
x -= w / 2;
|
||||
printScreenText(6, 0, (const char *)stringPtr, x, y, w);
|
||||
} else {
|
||||
showActionString(stringPtr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimonEngine::printInteractText(uint16 num, const char *string) {
|
||||
printf("printInteractText: num %d, string %s\n", num, string);
|
||||
|
||||
char convertedString[320];
|
||||
char *convertedString2 = convertedString;
|
||||
const char *string2 = string;
|
||||
uint16 height = 15;
|
||||
uint16 w = 620;
|
||||
uint16 b;
|
||||
uint16 x;
|
||||
int pixels = 0;
|
||||
|
||||
while (1) {
|
||||
pixels = getPixelLength(string, 620);
|
||||
string2 += pixels;
|
||||
if (*string2 == 0x00) {
|
||||
if (w == 620)
|
||||
w = pixels;
|
||||
strcpy(convertedString2, string);
|
||||
break;
|
||||
}
|
||||
while (*string2 != ' ') {
|
||||
byte chr = *string2;
|
||||
pixels -= charWidth[chr];
|
||||
string2--;
|
||||
}
|
||||
if (w == 620)
|
||||
w = pixels;
|
||||
b = string2 - string;
|
||||
strncpy(convertedString2, string, b);
|
||||
convertedString2 += b;
|
||||
*convertedString2++ = '\n';
|
||||
height += 15;
|
||||
string = string2;
|
||||
}
|
||||
|
||||
// ScrollX
|
||||
x = _variableArray[251];
|
||||
x += 20;
|
||||
|
||||
if (num == 1)
|
||||
_interactY = 385;
|
||||
|
||||
// Returned values for box definition
|
||||
_variableArray[51] = x;
|
||||
_variableArray[52] = _interactY;
|
||||
_variableArray[53] = w;
|
||||
_variableArray[54] = height;
|
||||
|
||||
o_kill_sprite_simon2(2, num + 6);
|
||||
renderString(num, 0, w, height, convertedString);
|
||||
loadSprite(4, 2, num + 6, x, _interactY, 12);
|
||||
|
||||
_interactY += height;
|
||||
}
|
||||
|
||||
void SimonEngine::printScreenText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) {
|
||||
char convertedString[320];
|
||||
char *convertedString2 = convertedString;
|
||||
const char *string2 = string;
|
||||
int16 height, talkDelay;
|
||||
int stringLength = strlen(string);
|
||||
int padding, lettersPerRow, lettersPerRowJustified;
|
||||
const int textHeight = (getGameType() == GType_FF) ? 15: 10;
|
||||
|
||||
height = textHeight;
|
||||
lettersPerRow = width / 6;
|
||||
lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1;
|
||||
|
||||
talkDelay = (stringLength + 3) / 3;
|
||||
if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) {
|
||||
if (_variableArray[141] == 0)
|
||||
_variableArray[141] = 9;
|
||||
_variableArray[85] = _variableArray[141] * talkDelay;
|
||||
} else {
|
||||
if (_variableArray[86] == 0)
|
||||
talkDelay /= 2;
|
||||
if (_variableArray[86] == 2)
|
||||
talkDelay *= 2;
|
||||
_variableArray[85] = talkDelay * 5;
|
||||
}
|
||||
|
||||
assert(stringLength > 0);
|
||||
|
||||
if (getGameType() == GType_FF) {
|
||||
uint16 b, spaces;
|
||||
uint16 len = width, pixels = 0;
|
||||
|
||||
while (1) {
|
||||
pixels = getPixelLength(string, len);
|
||||
string2 += pixels;
|
||||
if (*string2 == 0) {
|
||||
spaces = (width - pixels) / 12;
|
||||
if (spaces != 0)
|
||||
spaces--;
|
||||
while (spaces) {
|
||||
*convertedString2++=' ';
|
||||
spaces--;
|
||||
}
|
||||
strcpy(convertedString2, string);
|
||||
break;
|
||||
}
|
||||
while (*string2 != ' ') {
|
||||
byte chr = *string2;
|
||||
pixels -= charWidth[chr];
|
||||
string2--;
|
||||
}
|
||||
spaces = (width - pixels) / 12;
|
||||
if (spaces != 0)
|
||||
spaces--;
|
||||
while (spaces) {
|
||||
*convertedString2++ = ' ';
|
||||
spaces--;
|
||||
}
|
||||
b = string2 - string;
|
||||
strncpy(convertedString2, string, b);
|
||||
convertedString2 += b;
|
||||
*convertedString2++ = '\n';
|
||||
height += textHeight;
|
||||
y -= textHeight;
|
||||
if (y < 2)
|
||||
y = 2;
|
||||
len = pixels;
|
||||
string = string2;
|
||||
}
|
||||
} else {
|
||||
while (stringLength > 0) {
|
||||
int pos = 0;
|
||||
if (stringLength > lettersPerRow) {
|
||||
int removeLastWord = 0;
|
||||
if (lettersPerRow > lettersPerRowJustified) {
|
||||
pos = lettersPerRowJustified;
|
||||
while (string[pos] != ' ')
|
||||
pos++;
|
||||
if (pos > lettersPerRow)
|
||||
removeLastWord = 1;
|
||||
}
|
||||
if (lettersPerRow <= lettersPerRowJustified || removeLastWord) {
|
||||
pos = lettersPerRow;
|
||||
while (string[pos] != ' ' && pos > 0)
|
||||
pos--;
|
||||
}
|
||||
height += textHeight;
|
||||
y -= textHeight;
|
||||
} else
|
||||
pos = stringLength;
|
||||
padding = (lettersPerRow - pos) % 2 ?
|
||||
(lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2;
|
||||
while (padding--)
|
||||
*convertedString2++ = ' ';
|
||||
stringLength -= pos;
|
||||
while (pos--)
|
||||
*convertedString2++ = *string++;
|
||||
*convertedString2++ = '\n';
|
||||
string++; // skip space
|
||||
stringLength--; // skip space
|
||||
}
|
||||
*(convertedString2 - 1) = '\0';
|
||||
}
|
||||
|
||||
if (getGameType() == GType_SIMON1)
|
||||
o_kill_sprite_simon1(vgaSpriteId + 199);
|
||||
else
|
||||
o_kill_sprite_simon2(2, vgaSpriteId);
|
||||
|
||||
if (getGameType() == GType_FF) {
|
||||
renderStringAmiga(1, color, width, height, convertedString);
|
||||
} else {
|
||||
color = color * 3 + 192;
|
||||
if (getPlatform() == Common::kPlatformAmiga)
|
||||
renderStringAmiga(vgaSpriteId, color, width, height, convertedString);
|
||||
else
|
||||
renderString(vgaSpriteId, color, width, height, convertedString);
|
||||
}
|
||||
|
||||
int b = 4;
|
||||
if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
|
||||
if (!getBitFlag(133))
|
||||
b = 3;
|
||||
|
||||
x /= 8;
|
||||
if (y < 2)
|
||||
y = 2;
|
||||
}
|
||||
|
||||
if (getGameType() == GType_SIMON1)
|
||||
loadSprite(b, 2, vgaSpriteId + 199, x, y, 12);
|
||||
else
|
||||
loadSprite(b, 2, vgaSpriteId, x, y, 12);
|
||||
}
|
||||
|
||||
} // End of namespace Simon
|
||||
+33
-40
@@ -195,7 +195,7 @@ void SimonEngine::clearName() {
|
||||
if (getGameType() == GType_FF) {
|
||||
o_kill_sprite_simon2(2, 6);
|
||||
_lastNameOn = NULL;
|
||||
//_animatePointer = 0;
|
||||
_animatePointer = 0;
|
||||
_mouseAnim = 1;
|
||||
return;
|
||||
}
|
||||
@@ -692,51 +692,44 @@ void SimonEngine::setup_hitarea_from_pos(uint x, uint y, uint mode) {
|
||||
|
||||
void SimonEngine::displayName(HitArea *ha) {
|
||||
bool result;
|
||||
int x = 0, y = 0;
|
||||
|
||||
resetNameWindow();
|
||||
if (ha->flags & kBFTextBox) {
|
||||
result = printTextOf(ha->flags / 256);
|
||||
if (getGameType() == GType_FF) {
|
||||
if (ha->flags & kBFHyperBox) {
|
||||
_lastNameOn = ha;
|
||||
return;
|
||||
}
|
||||
if (findHitAreaByID(50))
|
||||
return;
|
||||
|
||||
if (getBitFlag(99))
|
||||
_animatePointer = ((ha->flags & kBFTextBox) != 0);
|
||||
else
|
||||
_animatePointer = 1;
|
||||
|
||||
if (!getBitFlag(99))
|
||||
return;
|
||||
|
||||
y = ha->y;
|
||||
if (getBitFlag(99) && y > 288)
|
||||
y = 288;
|
||||
y -= 17;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
y += 2;
|
||||
x = ha->width / 2 + ha->x;
|
||||
} else {
|
||||
result = printNameOf(ha->item_ptr);
|
||||
resetNameWindow();
|
||||
}
|
||||
|
||||
if (ha->flags & kBFTextBox) {
|
||||
result = printTextOf(ha->flags / 256, x, y);
|
||||
} else {
|
||||
result = printNameOf(ha->item_ptr, x, y);
|
||||
}
|
||||
|
||||
if (result)
|
||||
_lastNameOn = ha;
|
||||
}
|
||||
|
||||
bool SimonEngine::printTextOf(uint a) {
|
||||
if (getGameType() == GType_SIMON2) {
|
||||
if (getBitFlag(79)) {
|
||||
Subroutine *sub;
|
||||
_variableArray[84] = a;
|
||||
sub = getSubroutineByID(5003);
|
||||
if (sub != NULL)
|
||||
startSubroutineEx(sub);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (a >= 20)
|
||||
return false;
|
||||
|
||||
showActionString(getStringPtrByID(_stringIdArray2[a]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimonEngine::printNameOf(Item *item) {
|
||||
SubObject *child2;
|
||||
|
||||
if (item == 0 || item == _dummyItem2 || item == _dummyItem3)
|
||||
return false;
|
||||
|
||||
child2 = (SubObject *)findChildOfType(item, 2);
|
||||
if (child2 == NULL)
|
||||
return false;
|
||||
|
||||
showActionString(getStringPtrByID(child2->objectName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Simon
|
||||
|
||||
Reference in New Issue
Block a user