diff options
author | Max Horn | 2004-09-18 20:50:15 +0000 |
---|---|---|
committer | Max Horn | 2004-09-18 20:50:15 +0000 |
commit | 3552024aa97d07f634aece9b43b36ffc3ddbc068 (patch) | |
tree | f1a239782e23a06593e217380d5cd76331611eae | |
parent | 58c574d7cc82ff342d9f176d60ef6236e9d7926b (diff) | |
download | scummvm-rg350-3552024aa97d07f634aece9b43b36ffc3ddbc068.tar.gz scummvm-rg350-3552024aa97d07f634aece9b43b36ffc3ddbc068.tar.bz2 scummvm-rg350-3552024aa97d07f634aece9b43b36ffc3ddbc068.zip |
Added ScummEngine::printString() convenience method; changed enqueueText to call addMessageToStack
svn-id: r15170
-rw-r--r-- | scumm/script_v5.cpp | 17 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 26 | ||||
-rw-r--r-- | scumm/script_v6he.cpp | 36 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 47 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 24 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/string.cpp | 22 |
7 files changed, 41 insertions, 133 deletions
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 96625e2e09..017f9baaee 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -2608,7 +2608,6 @@ int ScummEngine_v5::getWordVararg(int *ptr) { void ScummEngine_v5::decodeParseString() { int textSlot; - const byte *msg; switch (_actorToPrintStrFor) { case 252: @@ -2691,23 +2690,9 @@ void ScummEngine_v5::decodeParseString() { } break; case 15: // SO_TEXTSTRING - msg = _scriptPointer; + printString(textSlot, _scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; - switch (textSlot) { - case 0: - actorTalk(msg); - break; - case 1: - drawString(1, msg); - break; - case 2: - unkMessage1(msg); - break; - case 3: - unkMessage2(msg); - break; - } // In SCUMM V1-V3, there were no 'default' values for the text slot // values. Hence to achieve correct behaviour, we have to keep the diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 60172ec1f4..b35bbfbabb 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2537,13 +2537,9 @@ void ScummEngine_v6::o6_kernelSetFunctions() { _smushFrameRate = args[1]; break; case 16: - case 17:{ - byte buf_input[300]; - const byte *message = getStringAddressVar(VAR_STRING2DRAW); - - addMessageToStack(message, buf_input, sizeof(buf_input)); - enqueueText(buf_input, args[3], args[4], args[2], args[1], true); - break;} + case 17: + enqueueText(getStringAddressVar(VAR_STRING2DRAW), args[3], args[4], args[2], args[1], true); + break; case 20: // it's used for turn on/off 'RadioChatter' effect for voice in the dig, but i's not needed break; @@ -3152,22 +3148,8 @@ void ScummEngine_v6::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 75: // SO_TEXTSTRING - switch (m) { - case 0: - actorTalk(_scriptPointer); - break; - case 1: - drawString(1, _scriptPointer); - break; - case 2: - unkMessage1(_scriptPointer); - break; - case 3: - unkMessage2(_scriptPointer); - break; - } + printString(m, _scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; - break; case 0xFE: _string[m].loadDefault(); diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 9b7e684084..c45ed38ddc 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -567,7 +567,7 @@ void ScummEngine_v6he::swapObjects(int object1, int object2) { stopObjectScript(object1); stopObjectScript(object2); - struct ObjectData tmpOd; + ObjectData tmpOd; memcpy(&tmpOd, &_objs[idx1], sizeof(tmpOd)); memcpy(&_objs[idx1], &_objs[idx2], sizeof(tmpOd)); @@ -1150,6 +1150,8 @@ void ScummEngine_v6he::o6_soundOps() { // See also o6_startSound(). _sound->setOverrideFreq(arg); break; + default: + error("o6_soundOps: default case 0x%x", subOp); } } @@ -1171,19 +1173,7 @@ void ScummEngine_v6he::o6_seekFilePos() { offset = pop(); slot = pop(); - switch (mode) { - case 1: - seekFilePos(slot, offset, 0); - break; - case 2: - seekFilePos(slot, offset, 1); - break; - case 3: - seekFilePos(slot, offset, 2); - break; - default: - break; - } + seekFilePos(slot, offset, mode - 1); } void ScummEngine_v6he::seekFilePos(int slot, int offset, int mode) { @@ -1200,6 +1190,8 @@ void ScummEngine_v6he::seekFilePos(int slot, int offset, int mode) { case 2: _hFileTable[slot].seek(offset, SEEK_END); break; + default: + error("seekFilePos: default case 0x%x", mode); } } @@ -1299,22 +1291,8 @@ void ScummEngine_v6he::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 75: // SO_TEXTSTRING - switch (m) { - case 0: - actorTalk(_scriptPointer); - break; - case 1: - drawString(1, _scriptPointer); - break; - case 2: - unkMessage1(_scriptPointer); - break; - case 3: - unkMessage2(_scriptPointer); - break; - } + printString(m, _scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; - break; case 0xF9: color = pop(); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 9798c90642..b872dd1c43 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -2089,59 +2089,18 @@ void ScummEngine_v72he::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 75: // SO_TEXTSTRING - switch (m) { - case 0: - actorTalk(_scriptPointer); - break; - case 1: - drawString(1, _scriptPointer); - break; - case 2: - unkMessage1(_scriptPointer); - break; - case 3: - unkMessage2(_scriptPointer); - break; - } + printString(m, _scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; - break; case 194: decodeScriptString(name, true); - switch (m) { - case 0: - actorTalk(name); - break; - case 1: - drawString(1, name); - break; - case 2: - unkMessage1(name); - break; - case 3: - unkMessage2(name); - break; - } + printString(m, name); break; case 0xE1: ptr = getResourceAddress(rtTalkie, pop()); size = READ_BE_UINT32(ptr + 12); memcpy(name, ptr + 16, size); - - switch (m) { - case 0: - actorTalk(name); - break; - case 1: - drawString(1, name); - break; - case 2: - unkMessage1(name); - break; - case 3: - unkMessage2(name); - break; - } + printString(m, name); break; case 0xF9: color = pop(); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 5f924163e6..f5f2b8e77c 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -499,26 +499,10 @@ void ScummEngine_v8::decodeParseString(int m, int n) { _string[m].no_talk_anim = true; break; case 0xD1: // SO_PRINT_STRING - switch (m) { - case 0: - actorTalk(_scriptPointer); - break; - case 1: - drawString(1, _scriptPointer); - break; - case 2: - unkMessage1(_scriptPointer); - break; - case 3: - unkMessage2(_scriptPointer); - break; - case 5:{ - byte buffer[256]; - addMessageToStack(_scriptPointer, buffer, sizeof(buffer)); - enqueueText(buffer, _string[m].xpos, _string[m].ypos, _string[m].color, _string[m].charset, _string[m].center); - } - break; - } + if (m == 5) + enqueueText(_scriptPointer, _string[m].xpos, _string[m].ypos, _string[m].color, _string[m].charset, _string[m].center); + else + printString(m, _scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; break; diff --git a/scumm/scumm.h b/scumm/scumm.h index d151a71a13..b649539525 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -1162,6 +1162,8 @@ protected: void initCharset(int charset); + void printString(int m, const byte *msg); + void CHARSET_1(); void drawString(int a, const byte *msg); void unkMessage1(const byte *msg); diff --git a/scumm/string.cpp b/scumm/string.cpp index 782f60796d..a5a377574f 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -34,6 +34,24 @@ namespace Scumm { +void ScummEngine::printString(int m, const byte *msg) { + switch (m) { + case 0: + actorTalk(msg); + break; + case 1: + drawString(1, msg); + break; + case 2: + unkMessage1(msg); + break; + case 3: + unkMessage2(msg); + break; + } +} + + void ScummEngine::unkMessage1(const byte *msg) { byte buffer[100]; addMessageToStack(msg, buffer, sizeof(buffer)); @@ -660,8 +678,8 @@ void ScummEngine::initCharset(int charsetno) { void ScummEngine::enqueueText(const byte *text, int x, int y, byte color, byte charset, bool center) { BlastText &bt = _blastTextQueue[_blastTextQueuePos++]; assert(_blastTextQueuePos <= ARRAYSIZE(_blastTextQueue)); - - strcpy((char *)bt.text, (const char *)text); + + addMessageToStack(text, bt.text, sizeof(bt.text)); bt.xpos = x; bt.ypos = y; bt.color = color; |