Added ScummEngine::printString() convenience method; changed enqueueText to call addMessageToStack

svn-id: r15170
This commit is contained in:
Max Horn 2004-09-18 20:50:15 +00:00
parent 58c574d7cc
commit 3552024aa9
7 changed files with 41 additions and 133 deletions

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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;