aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/actor.cpp4
-rw-r--r--scumm/script_v2.cpp7
-rw-r--r--scumm/script_v5.cpp15
-rw-r--r--scumm/script_v6.cpp27
-rw-r--r--scumm/script_v6he.cpp48
-rw-r--r--scumm/script_v8.cpp16
-rw-r--r--scumm/scumm.h8
-rw-r--r--scumm/string.cpp12
-rw-r--r--scumm/verbs.cpp29
9 files changed, 79 insertions, 87 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 6523f67916..e2cb63d552 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -1144,10 +1144,10 @@ int ScummEngine::getActorFromPos(int x, int y) {
return 0;
}
-void ScummEngine::actorTalk() {
+void ScummEngine::actorTalk(const byte *msg) {
Actor *a;
- _messagePtr = addMessageToStack(_messagePtr, _charsetBuffer, sizeof(_charsetBuffer));
+ _messagePtr = addMessageToStack(msg, _charsetBuffer, sizeof(_charsetBuffer));
// FIXME: Workaround for bugs #770039 and #770049
if (_gameId == GID_LOOM || _gameId == GID_LOOM256) {
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 5eae8ebc77..28a73a0b16 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -428,8 +428,7 @@ void ScummEngine_v2::decodeParseString() {
_string[textSlot].color = v1_mm_actor_speech_color[_actorToPrintStrFor];
}
- _messagePtr = buffer;
- actorTalk();
+ actorTalk(buffer);
}
int ScummEngine_v2::readVar(uint var) {
@@ -1055,15 +1054,13 @@ void ScummEngine_v2::o2_drawSentence() {
ptr++;
}
- _messagePtr = (byte*)sentence;
-
sentenceline.top = virtscr[2].topline;
sentenceline.bottom = virtscr[2].topline + 8;
sentenceline.left = 0;
sentenceline.right = 319;
restoreBG(sentenceline);
- drawString(2);
+ drawString(2, (byte*)sentence);
}
void ScummEngine_v2::o2_ifClassOfIs() {
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index cb57dd9478..2f294568c2 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -2702,6 +2702,7 @@ int ScummEngine_v5::getWordVararg(int *ptr) {
void ScummEngine_v5::decodeParseString() {
int textSlot;
+ const byte *msg;
switch (_actorToPrintStrFor) {
case 252:
@@ -2784,19 +2785,21 @@ void ScummEngine_v5::decodeParseString() {
}
break;
case 15: // SO_TEXTSTRING
- _messagePtr = _scriptPointer;
+ msg = _scriptPointer;
+ _scriptPointer += resStrLen(_scriptPointer)+ 1;
+
switch (textSlot) {
case 0:
- actorTalk();
+ actorTalk(msg);
break;
case 1:
- drawString(1);
+ drawString(1, msg);
break;
case 2:
- unkMessage1();
+ unkMessage1(msg);
break;
case 3:
- unkMessage2();
+ unkMessage2(msg);
break;
}
@@ -2812,8 +2815,6 @@ void ScummEngine_v5::decodeParseString() {
_string[textSlot].t_ypos = _string[textSlot].ypos;
_string[textSlot].t_color = _string[textSlot].color;
}
-
- _scriptPointer = _messagePtr;
return;
default:
warning("ScummEngine_v5::decodeParseString: Unhandled case %d", _opcode & 0xF);
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index 42f00c92c5..4dc25063fc 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -2319,11 +2319,11 @@ void ScummEngine_v6::o6_printEgo() {
void ScummEngine_v6::o6_talkActor() {
_actorToPrintStrFor = pop();
- _messagePtr = translateTextAndPlaySpeech(_scriptPointer);
+ const byte *msg = translateTextAndPlaySpeech(_scriptPointer);
_scriptPointer += resStrLen(_scriptPointer) + 1;
setStringVars(0);
- actorTalk();
+ actorTalk(msg);
}
void ScummEngine_v6::o6_talkEgo() {
@@ -2507,9 +2507,8 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
case 17:{
const byte *message;
byte buf_input[300], buf_output[300];
- _messagePtr = getStringAddressVar(VAR_STRING2DRAW);
message = buf_input;
- addMessageToStack(_messagePtr, buf_input, sizeof(buf_input));
+ addMessageToStack(getStringAddressVar(VAR_STRING2DRAW), buf_input, sizeof(buf_input));
if ((_gameId == GID_DIG) && !(_features & GF_DEMO)) {
byte buf_trans[300];
char *t_ptr = (char *)buf_input;
@@ -3115,6 +3114,7 @@ void ScummEngine_v6::o6_setBoxSet() {
void ScummEngine_v6::decodeParseString(int m, int n) {
byte b;
+ const byte *msg;
b = fetchScriptByte();
@@ -3149,29 +3149,30 @@ void ScummEngine_v6::decodeParseString(int m, int n) {
_string[m].no_talk_anim = true;
break;
case 75: // SO_TEXTSTRING
- _messagePtr = translateTextAndPlaySpeech(_scriptPointer);
- _scriptPointer += resStrLen(_scriptPointer)+ 1;
+ msg = translateTextAndPlaySpeech(_scriptPointer);
+ _scriptPointer += resStrLen(_scriptPointer) + 1;
switch (m) {
case 0:
- actorTalk();
+ actorTalk(msg);
break;
case 1:
- drawString(1);
+ drawString(1, msg);
break;
case 2:
- unkMessage1();
+ unkMessage1(msg);
break;
case 3:
- unkMessage2();
+ unkMessage2(msg);
break;
}
- return;
+
+ break;
case 0xFE:
setStringVars(m);
if (n)
_actorToPrintStrFor = pop();
- return;
+ break;
case 0xFF:
_string[m].t_xpos = _string[m].xpos;
_string[m].t_ypos = _string[m].ypos;
@@ -3181,7 +3182,7 @@ void ScummEngine_v6::decodeParseString(int m, int n) {
_string[m].t_right = _string[m].right;
_string[m].t_color = _string[m].color;
_string[m].t_charset = _string[m].charset;
- return;
+ break;
default:
error("decodeParseString: default case 0x%x", b);
}
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index e006b05721..377f8834ef 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -955,8 +955,7 @@ void ScummEngine_v6he::o6_openFile() {
int mode, len, slot, l, r;
byte filename[100];
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename, sizeof(filename));
+ addMessageToStack(_scriptPointer, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1002,8 +1001,7 @@ void ScummEngine_v6he::o6_deleteFile() {
int len, r;
byte filename[100];
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename, sizeof(filename));
+ addMessageToStack(_scriptPointer, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1020,8 +1018,7 @@ void ScummEngine_v6he::o6_rename() {
int len, r1, r2;
byte filename[100],filename2[100];
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename, sizeof(filename));
+ addMessageToStack(_scriptPointer, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1031,8 +1028,7 @@ void ScummEngine_v6he::o6_rename() {
break;
}
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename2, sizeof(filename2));
+ addMessageToStack(_scriptPointer, filename2, sizeof(filename2));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1340,22 +1336,19 @@ void ScummEngine_v6he::o6_unknownF4() {
switch (b) {
case 1:
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename1, sizeof(filename1));
+ addMessageToStack(_scriptPointer, filename1, sizeof(filename1));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
+ debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, filename1);
break;
case 2:
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename1, sizeof(filename1));
+ addMessageToStack(_scriptPointer, filename1, sizeof(filename1));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename2, sizeof(filename2));
+ addMessageToStack(_scriptPointer, filename2, sizeof(filename2));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1371,8 +1364,7 @@ void ScummEngine_v6he::o6_unknownF9() {
int len, r;
byte filename[100];
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr, filename, sizeof(filename));
+ addMessageToStack(_scriptPointer, filename, sizeof(filename));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1413,6 +1405,7 @@ void ScummEngine_v6he::o6_unknownFB() {
void ScummEngine_v6he::decodeParseString(int m, int n) {
byte b;
int c;
+ const byte *msg;
b = fetchScriptByte();
@@ -1447,24 +1440,25 @@ void ScummEngine_v6he::decodeParseString(int m, int n) {
_string[m].no_talk_anim = true;
break;
case 75: // SO_TEXTSTRING
- _messagePtr = translateTextAndPlaySpeech(_scriptPointer);
- _scriptPointer += resStrLen(_scriptPointer)+ 1;
+ msg = translateTextAndPlaySpeech(_scriptPointer);
+ _scriptPointer += resStrLen(_scriptPointer) + 1;
switch (m) {
case 0:
- actorTalk();
+ actorTalk(msg);
break;
case 1:
- drawString(1);
+ drawString(1, msg);
break;
case 2:
- unkMessage1();
+ unkMessage1(msg);
break;
case 3:
- unkMessage2();
+ unkMessage2(msg);
break;
}
- return;
+
+ break;
case 0xF9:
c = pop();
if (c == 1) {
@@ -1475,12 +1469,12 @@ void ScummEngine_v6he::decodeParseString(int m, int n) {
getStackList(args, ARRAYSIZE(args));
}
warning("decodeParseString case 0xF9 stub");
- return;
+ break;
case 0xFE:
setStringVars(m);
if (n)
_actorToPrintStrFor = pop();
- return;
+ break;
case 0xFF:
_string[m].t_xpos = _string[m].xpos;
_string[m].t_ypos = _string[m].ypos;
@@ -1490,7 +1484,7 @@ void ScummEngine_v6he::decodeParseString(int m, int n) {
_string[m].t_right = _string[m].right;
_string[m].t_color = _string[m].color;
_string[m].t_charset = _string[m].charset;
- return;
+ break;
default:
error("decodeParseString: default case 0x%x", b);
}
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 29d49a0213..dde8b6b269 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -467,6 +467,7 @@ void ScummEngine_v8::writeVar(uint var, int value) {
void ScummEngine_v8::decodeParseString(int m, int n) {
byte b;
+ const byte *msg;
b = fetchScriptByte();
@@ -513,29 +514,30 @@ void ScummEngine_v8::decodeParseString(int m, int n) {
_string[m].no_talk_anim = true;
break;
case 0xD1: // SO_PRINT_STRING
- _messagePtr = translateTextAndPlaySpeech(_scriptPointer);
- _scriptPointer += resStrLen(_scriptPointer)+ 1;
+ msg = translateTextAndPlaySpeech(_scriptPointer);
+ _scriptPointer += resStrLen(_scriptPointer) + 1;
switch (m) {
case 0:
- actorTalk();
+ actorTalk(msg);
break;
case 1:
- drawString(1);
+ drawString(1, msg);
break;
case 2:
- unkMessage1();
+ unkMessage1(msg);
break;
case 3:
- unkMessage2();
+ unkMessage2(msg);
break;
case 5:{
byte buffer[256];
- addMessageToStack(_messagePtr, buffer, sizeof(buffer));
+ addMessageToStack(msg, buffer, sizeof(buffer));
enqueueText(buffer, _string[m].xpos, _string[m].ypos, _string[m].color, _string[m].charset, _string[m].center);
}
break;
}
+
break;
case 0xD2: // SO_PRINT_WRAP Set print wordwrap
//warning("decodeParseString: SO_PRINT_WRAP");
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 6a6facc48f..aeee376cbe 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -775,7 +775,7 @@ public:
SentenceTab _sentence[NUM_SENTENCE];
StringTab _string[6];
int16 _talkDelay;
- void actorTalk();
+ void actorTalk(const byte *msg);
void stopTalk();
int talkingActor(); // Wrapper around VAR_TALK_ACTOR for V1 Maniac
void talkingActor(int variable);
@@ -1063,14 +1063,14 @@ protected:
void initCharset(int charset);
void CHARSET_1();
- void drawString(int a);
+ void drawString(int a, const byte *msg);
const byte *addMessageToStack(const byte *msg, byte *dstBuffer, int dstBufferSize);
void addIntToStack(int var);
void addVerbToStack(int var);
void addNameToStack(int var);
void addStringToStack(int var);
- void unkMessage1();
- void unkMessage2();
+ void unkMessage1(const byte *msg);
+ void unkMessage2(const byte *msg);
public:
void clearMsgQueue(); // Used by Actor::putActor
protected:
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 16115a43fe..a184ca8abf 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -46,9 +46,9 @@ void ScummEngine::setStringVars(int slot) {
st->charset = st->t_charset;
}
-void ScummEngine::unkMessage1() {
+void ScummEngine::unkMessage1(const byte *msg) {
byte buffer[100];
- _messagePtr = addMessageToStack(_messagePtr, buffer, sizeof(buffer));
+ _messagePtr = addMessageToStack(msg, buffer, sizeof(buffer));
// if ((_gameId == GID_CMI) && _debugMode) { // In CMI, unkMessage1 is used for printDebug output
if ((buffer[0] != 0xFF) && _debugMode) {
@@ -71,13 +71,13 @@ void ScummEngine::unkMessage1() {
}
}
-void ScummEngine::unkMessage2() {
+void ScummEngine::unkMessage2(const byte *msg) {
// Original COMI used different code at this point.
// Seemed to use blastText for the messages
byte buf[100];
const byte *tmp;
- tmp = _messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
+ tmp = _messagePtr = addMessageToStack(msg, buf, sizeof(buf));
if (_string[3].color == 0)
_string[3].color = 4;
@@ -339,14 +339,14 @@ void ScummEngine::CHARSET_1() {
_charset->_mask = _charset->_str;
}
-void ScummEngine::drawString(int a) {
+void ScummEngine::drawString(int a, const byte *msg) {
byte buf[256];
byte *space;
int i, c;
byte fontHeight = 0;
uint color;
- _messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
+ _messagePtr = addMessageToStack(msg, buf, sizeof(buf));
_charset->_top = _string[a].ypos + _screenTop;
_charset->_startLeft = _charset->_left = _string[a].xpos;
diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp
index b5e1b235c9..98af117a6b 100644
--- a/scumm/verbs.cpp
+++ b/scumm/verbs.cpp
@@ -228,18 +228,18 @@ void ScummEngine::redrawV2Inventory() {
_string[1].xpos = v2_mouseover_boxes[i].rect.left;
_string[1].color = v2_mouseover_boxes[i].color;
- _messagePtr = getObjOrActorName(obj);
- assert(_messagePtr);
+
+ const byte *tmp = getObjOrActorName(obj);
+ assert(tmp);
// Prevent inventory entries from overflowing by truncating the text
// after 144/8 = 18 chars
byte msg[18 + 1];
msg[18] = 0;
- strncpy((char *)msg, (const char *)_messagePtr, 18);
- _messagePtr = msg;
+ strncpy((char *)msg, (const char *)tmp, 18);
// Draw it
- drawString(1);
+ drawString(1, msg);
}
@@ -248,8 +248,7 @@ void ScummEngine::redrawV2Inventory() {
_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].rect.left;
_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + vs->topline;
_string[1].color = v2_mouseover_boxes[kInventoryUpArrow].color;
- _messagePtr = (const byte *)" \1\2";
- drawString(1);
+ drawString(1, (const byte *)" \1\2");
}
// If necessary, draw "down" arrow
@@ -257,8 +256,7 @@ void ScummEngine::redrawV2Inventory() {
_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].rect.left;
_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + vs->topline;
_string[1].color = v2_mouseover_boxes[kInventoryDownArrow].color;
- _messagePtr = (const byte *)" \3\4";
- drawString(1);
+ drawString(1, (const byte *)" \3\4");
}
}
@@ -397,19 +395,18 @@ void ScummEngine::drawVerb(int verb, int mode) {
verb += _inventoryOffset;
*/
- _messagePtr = getResourceAddress(rtVerb, verb);
- if (!_messagePtr)
+ const byte *msg = getResourceAddress(rtVerb, verb);
+ if (!msg)
return;
- assert(_messagePtr);
- if ((_version == 8) && (_messagePtr[0] == '/')) {
- translateText(_messagePtr, _transText);
- _messagePtr = _transText;
+ if ((_version == 8) && (msg[0] == '/')) {
+ translateText(msg, _transText);
+ msg = _transText;
}
tmp = _charset->_center;
_charset->_center = 0;
- drawString(4);
+ drawString(4, msg);
_charset->_center = tmp;
vs->curRect.right = _charset->_str.right;