aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-04-03 19:41:31 +0000
committerMax Horn2004-04-03 19:41:31 +0000
commit6aa6b49ed57cc5900baaff6698bad062ea2f198b (patch)
treea52cb80d6b9345d39f779ea2fab58462ead47892
parent8f6ae7973e895e40ecbf84afa95a0aa81508113b (diff)
downloadscummvm-rg350-6aa6b49ed57cc5900baaff6698bad062ea2f198b.tar.gz
scummvm-rg350-6aa6b49ed57cc5900baaff6698bad062ea2f198b.tar.bz2
scummvm-rg350-6aa6b49ed57cc5900baaff6698bad062ea2f198b.zip
cleanup StringTab stuff
svn-id: r13448
-rw-r--r--scumm/saveload.cpp20
-rw-r--r--scumm/script_v2.cpp2
-rw-r--r--scumm/script_v5.cpp20
-rw-r--r--scumm/script_v6.cpp17
-rw-r--r--scumm/script_v6he.cpp13
-rw-r--r--scumm/script_v8.cpp15
-rw-r--r--scumm/scumm.cpp16
-rw-r--r--scumm/scumm.h37
-rw-r--r--scumm/string.cpp16
9 files changed, 62 insertions, 94 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 6ec5243d11..e174aadf4c 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -573,27 +573,23 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
};
const SaveLoadEntry stringTabEntries[] = {
- // TODO - It makes no sense to have all these t_* fields in StringTab
- // Rather let's dump them all when the save game format changes, and
- // keep two StringTab objects where we have one now: a "normal" one,
- // and a temporar y"t_" one.
// Then backup/restore of a StringTab entry becomes a one liner.
MKLINE(StringTab, xpos, sleInt16, VER(8)),
- MKLINE(StringTab, t_xpos, sleInt16, VER(8)),
+ MKLINE(StringTab, backup.xpos, sleInt16, VER(8)),
MKLINE(StringTab, ypos, sleInt16, VER(8)),
- MKLINE(StringTab, t_ypos, sleInt16, VER(8)),
+ MKLINE(StringTab, backup.ypos, sleInt16, VER(8)),
MKLINE(StringTab, right, sleInt16, VER(8)),
- MKLINE(StringTab, t_right, sleInt16, VER(8)),
+ MKLINE(StringTab, backup.right, sleInt16, VER(8)),
MKLINE(StringTab, color, sleInt8, VER(8)),
- MKLINE(StringTab, t_color, sleInt8, VER(8)),
+ MKLINE(StringTab, backup.color, sleInt8, VER(8)),
MKLINE(StringTab, charset, sleInt8, VER(8)),
- MKLINE(StringTab, t_charset, sleInt8, VER(8)),
+ MKLINE(StringTab, backup.charset, sleInt8, VER(8)),
MKLINE(StringTab, center, sleByte, VER(8)),
- MKLINE(StringTab, t_center, sleByte, VER(8)),
+ MKLINE(StringTab, backup.center, sleByte, VER(8)),
MKLINE(StringTab, overhead, sleByte, VER(8)),
- MKLINE(StringTab, t_overhead, sleByte, VER(8)),
+ MKLINE(StringTab, backup.overhead, sleByte, VER(8)),
MKLINE(StringTab, no_talk_anim, sleByte, VER(8)),
- MKLINE(StringTab, t_no_talk_anim, sleByte, VER(8)),
+ MKLINE(StringTab, backup.no_talk_anim, sleByte, VER(8)),
MKEND()
};
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index c3d3d1b398..9133d95ad2 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -847,7 +847,7 @@ void ScummEngine_v2::o2_verbOps() {
vs->dimcolor = 8;
}
vs->type = kTextVerbType;
- vs->charset_nr = _string[0].t_charset;
+ vs->charset_nr = _string[0].backup.charset;
vs->curmode = 1;
vs->saveid = 0;
vs->key = 0;
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 146a16cad0..f1813377c7 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -707,7 +707,7 @@ void ScummEngine_v5::o5_cursorCommand() {
} else {
getWordVararg(table);
for (i = 0; i < 16; i++)
- _charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)table[i];
+ _charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)table[i];
}
break;
}
@@ -2405,7 +2405,7 @@ void ScummEngine_v5::o5_verbOps() {
vs->hicolor = (_version == 3) ? 14 : 0;
vs->dimcolor = 8;
vs->type = kTextVerbType;
- vs->charset_nr = _string[0].t_charset;
+ vs->charset_nr = _string[0].backup.charset;
vs->curmode = 0;
vs->saveid = 0;
vs->key = 0;
@@ -2616,7 +2616,7 @@ void ScummEngine_v5::decodeParseString() {
textSlot = 0;
}
- setStringVars(textSlot);
+ _string[textSlot].restoreString();
while ((_opcode = fetchScriptByte()) != 0xFF) {
switch (_opcode & 0xF) {
@@ -2709,9 +2709,9 @@ void ScummEngine_v5::decodeParseString() {
// speaks during the intro are put at position 0,0.
// In addition, Loom needs to remember the text colour.
if (_gameId == GID_LOOM || _gameId == GID_INDY3) {
- _string[textSlot].t_xpos = _string[textSlot].xpos;
- _string[textSlot].t_ypos = _string[textSlot].ypos;
- _string[textSlot].t_color = _string[textSlot].color;
+ _string[textSlot].backup.xpos = _string[textSlot].xpos;
+ _string[textSlot].backup.ypos = _string[textSlot].ypos;
+ _string[textSlot].backup.color = _string[textSlot].color;
}
return;
default:
@@ -2720,13 +2720,7 @@ void ScummEngine_v5::decodeParseString() {
}
}
- _string[textSlot].t_xpos = _string[textSlot].xpos;
- _string[textSlot].t_ypos = _string[textSlot].ypos;
- _string[textSlot].t_center = _string[textSlot].center;
- _string[textSlot].t_overhead = _string[textSlot].overhead;
- _string[textSlot].t_right = _string[textSlot].right;
- _string[textSlot].t_color = _string[textSlot].color;
- _string[textSlot].t_charset = _string[textSlot].charset;
+ _string[textSlot].backupString();
}
void ScummEngine_v5::o5_oldRoomEffect() {
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index 76f9b8c162..5306c9be72 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -949,7 +949,7 @@ void ScummEngine_v6::o6_cursorCommand() {
case 0x9D: // SO_CHARSET_COLOR
getStackList(args, ARRAYSIZE(args));
for (i = 0; i < 16; i++)
- _charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)args[i];
+ _charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)args[i];
break;
case 0xD6: // SO_CURSOR_TRANSPARENT Set cursor transparent color
makeCursorColorTransparent(pop());
@@ -1925,7 +1925,7 @@ void ScummEngine_v6::o6_verbOps() {
vs->hicolor = 0;
vs->dimcolor = 8;
vs->type = kTextVerbType;
- vs->charset_nr = _string[0].t_charset;
+ vs->charset_nr = _string[0].backup.charset;
vs->curmode = 0;
vs->saveid = 0;
vs->key = 0;
@@ -2294,7 +2294,7 @@ void ScummEngine_v6::o6_printEgo() {
void ScummEngine_v6::o6_talkActor() {
_actorToPrintStrFor = pop();
- setStringVars(0);
+ _string[0].restoreString();
actorTalk(_scriptPointer);
_scriptPointer += resStrLen(_scriptPointer) + 1;
@@ -3119,19 +3119,12 @@ void ScummEngine_v6::decodeParseString(int m, int n) {
break;
case 0xFE:
- setStringVars(m);
+ _string[m].restoreString();
if (n)
_actorToPrintStrFor = pop();
break;
case 0xFF:
- _string[m].t_xpos = _string[m].xpos;
- _string[m].t_ypos = _string[m].ypos;
- _string[m].t_center = _string[m].center;
- _string[m].t_overhead = _string[m].overhead;
- _string[m].t_no_talk_anim = _string[m].no_talk_anim;
- _string[m].t_right = _string[m].right;
- _string[m].t_color = _string[m].color;
- _string[m].t_charset = _string[m].charset;
+ _string[m].backupString();
break;
default:
error("decodeParseString: default case 0x%x", b);
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index 4919276558..a551a6b42c 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -756,7 +756,7 @@ void ScummEngine_v6he::o6_verbOps() {
vs->hicolor = 0;
vs->dimcolor = 8;
vs->type = kTextVerbType;
- vs->charset_nr = _string[0].t_charset;
+ vs->charset_nr = _string[0].backup.charset;
vs->curmode = 0;
vs->saveid = 0;
vs->key = 0;
@@ -1468,19 +1468,12 @@ void ScummEngine_v6he::decodeParseString(int m, int n) {
warning("decodeParseString case 0xF9 stub");
break;
case 0xFE:
- setStringVars(m);
+ _string[m].restoreString();
if (n)
_actorToPrintStrFor = pop();
break;
case 0xFF:
- _string[m].t_xpos = _string[m].xpos;
- _string[m].t_ypos = _string[m].ypos;
- _string[m].t_center = _string[m].center;
- _string[m].t_overhead = _string[m].overhead;
- _string[m].t_no_talk_anim = _string[m].no_talk_anim;
- _string[m].t_right = _string[m].right;
- _string[m].t_color = _string[m].color;
- _string[m].t_charset = _string[m].charset;
+ _string[m].backupString();
break;
default:
error("decodeParseString: default case 0x%x", b);
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 92ef66d155..743c751f34 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -472,19 +472,12 @@ void ScummEngine_v8::decodeParseString(int m, int n) {
switch (b) {
case 0xC8: // SO_PRINT_BASEOP
- setStringVars(m);
+ _string[m].restoreString();
if (n)
_actorToPrintStrFor = pop();
break;
case 0xC9: // SO_PRINT_END
- _string[m].t_xpos = _string[m].xpos;
- _string[m].t_ypos = _string[m].ypos;
- _string[m].t_center = _string[m].center;
- _string[m].t_overhead = _string[m].overhead;
- _string[m].t_no_talk_anim = _string[m].no_talk_anim;
- _string[m].t_right = _string[m].right;
- _string[m].t_color = _string[m].color;
- _string[m].t_charset = _string[m].charset;
+ _string[m].backupString();
break;
case 0xCA: // SO_PRINT_AT
_string[m].ypos = pop();
@@ -769,7 +762,7 @@ void ScummEngine_v8::o8_cursorCommand() {
case 0xE8: // SO_CHARSET_COLOR
getStackList(args, ARRAYSIZE(args));
for (i = 0; i < 16; i++)
- _charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)args[i];
+ _charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)args[i];
break;
case 0xE9: // SO_CURSOR_PUT
{
@@ -1151,7 +1144,7 @@ void ScummEngine_v8::o8_verbOps() {
vs->hicolor = 0;
vs->dimcolor = 8;
vs->type = kTextVerbType;
- vs->charset_nr = _string[0].t_charset;
+ vs->charset_nr = _string[0].backup.charset;
vs->curmode = 0;
vs->saveid = 0;
vs->key = 0;
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 2cdac222a8..b8f69454a2 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1128,16 +1128,16 @@ void ScummEngine::scummInit() {
for (i = 0; i < 6; i++) {
if (_version == 3) { // FIXME - what is this?
- _string[i].t_xpos = 0;
- _string[i].t_ypos = 0;
+ _string[i].backup.xpos = 0;
+ _string[i].backup.ypos = 0;
} else {
- _string[i].t_xpos = 2;
- _string[i].t_ypos = 5;
+ _string[i].backup.xpos = 2;
+ _string[i].backup.ypos = 5;
}
- _string[i].t_right = _screenWidth - 1;
- _string[i].t_color = 0xF;
- _string[i].t_center = 0;
- _string[i].t_charset = 0;
+ _string[i].backup.right = _screenWidth - 1;
+ _string[i].backup.color = 0xF;
+ _string[i].backup.center = 0;
+ _string[i].backup.charset = 0;
}
// all keys are released
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 40ea703584..164058c475 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -252,21 +252,33 @@ struct SentenceTab {
uint8 freezeCount;
};
-// TODO / FIXME: next time save game format changes, Fingolfin would like to
-// revise StringTab. In particular, all t_* fields can be removed, making some
-// code a bit cleaner & easier to understand.
-struct StringTab {
- int16 t_xpos, t_ypos;
- int16 t_right;
- int16 xpos, ypos;
+struct StringSlot {
+ int16 xpos;
+ int16 ypos;
int16 right;
- byte color, t_color;
- byte charset, t_charset;
- bool center, t_center;
- bool overhead, t_overhead;
- bool no_talk_anim, t_no_talk_anim;
+ byte color;
+ byte charset;
+ bool center;
+ bool overhead;
+ bool no_talk_anim;
+};
+
+struct StringTab : StringSlot {
+ StringSlot backup;
+
+ void backupString() {
+ StringSlot &s = *this;
+ backup = s;
+ }
+
+ void restoreString() {
+ StringSlot &s = *this;
+ s = backup;
+ }
};
+
+
enum WhereIsObject {
WIO_NOT_FOUND = -1,
WIO_INVENTORY = 0,
@@ -582,7 +594,6 @@ protected:
void copyScriptString(byte *dst);
int resStrLen(const byte *src) const;
void doSentence(int c, int b, int a);
- void setStringVars(int i);
/* Should be in Resource class */
File _fileHandle;
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 868e252e44..6de1c157f1 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -34,18 +34,6 @@
namespace Scumm {
-void ScummEngine::setStringVars(int slot) {
- StringTab *st = &_string[slot];
- st->xpos = st->t_xpos;
- st->ypos = st->t_ypos;
- st->center = st->t_center;
- st->overhead = st->t_overhead;
- st->no_talk_anim = st->t_no_talk_anim;
- st->right = st->t_right;
- st->color = st->t_color;
- st->charset = st->t_charset;
-}
-
void ScummEngine::unkMessage1(const byte *msg) {
byte buffer[100];
addMessageToStack(msg, buffer, sizeof(buffer));
@@ -616,8 +604,8 @@ void ScummEngine::initCharset(int charsetno) {
if (!getResourceAddress(rtCharset, charsetno))
loadCharset(charsetno);
- _string[0].t_charset = charsetno;
- _string[1].t_charset = charsetno;
+ _string[0].backup.charset = charsetno;
+ _string[1].backup.charset = charsetno;
for (i = 0; i < 16; i++)
_charsetColorMap[i] = _charsetData[charsetno][i];