diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 486542b104f..cea086a5b69 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -571,23 +571,23 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { }; const SaveLoadEntry stringTabEntries[] = { - // Then backup/restore of a StringTab entry becomes a one liner. + // Then _default/restore of a StringTab entry becomes a one liner. MKLINE(StringTab, xpos, sleInt16, VER(8)), - MKLINE(StringTab, backup.xpos, sleInt16, VER(8)), + MKLINE(StringTab, _default.xpos, sleInt16, VER(8)), MKLINE(StringTab, ypos, sleInt16, VER(8)), - MKLINE(StringTab, backup.ypos, sleInt16, VER(8)), + MKLINE(StringTab, _default.ypos, sleInt16, VER(8)), MKLINE(StringTab, right, sleInt16, VER(8)), - MKLINE(StringTab, backup.right, sleInt16, VER(8)), + MKLINE(StringTab, _default.right, sleInt16, VER(8)), MKLINE(StringTab, color, sleInt8, VER(8)), - MKLINE(StringTab, backup.color, sleInt8, VER(8)), + MKLINE(StringTab, _default.color, sleInt8, VER(8)), MKLINE(StringTab, charset, sleInt8, VER(8)), - MKLINE(StringTab, backup.charset, sleInt8, VER(8)), + MKLINE(StringTab, _default.charset, sleInt8, VER(8)), MKLINE(StringTab, center, sleByte, VER(8)), - MKLINE(StringTab, backup.center, sleByte, VER(8)), + MKLINE(StringTab, _default.center, sleByte, VER(8)), MKLINE(StringTab, overhead, sleByte, VER(8)), - MKLINE(StringTab, backup.overhead, sleByte, VER(8)), + MKLINE(StringTab, _default.overhead, sleByte, VER(8)), MKLINE(StringTab, no_talk_anim, sleByte, VER(8)), - MKLINE(StringTab, backup.no_talk_anim, sleByte, VER(8)), + MKLINE(StringTab, _default.no_talk_anim, sleByte, VER(8)), MKEND() }; diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 9133d95ad22..30de09802c5 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].backup.charset; + vs->charset_nr = _string[0]._default.charset; vs->curmode = 1; vs->saveid = 0; vs->key = 0; diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index f1813377c71..6eeb983eeef 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].backup.charset][i] = (unsigned char)table[i]; + _charsetColorMap[i] = _charsetData[_string[1]._default.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].backup.charset; + vs->charset_nr = _string[0]._default.charset; vs->curmode = 0; vs->saveid = 0; vs->key = 0; @@ -2616,7 +2616,7 @@ void ScummEngine_v5::decodeParseString() { textSlot = 0; } - _string[textSlot].restoreString(); + _string[textSlot].loadDefault(); 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].backup.xpos = _string[textSlot].xpos; - _string[textSlot].backup.ypos = _string[textSlot].ypos; - _string[textSlot].backup.color = _string[textSlot].color; + _string[textSlot]._default.xpos = _string[textSlot].xpos; + _string[textSlot]._default.ypos = _string[textSlot].ypos; + _string[textSlot]._default.color = _string[textSlot].color; } return; default: @@ -2720,7 +2720,7 @@ void ScummEngine_v5::decodeParseString() { } } - _string[textSlot].backupString(); + _string[textSlot].saveDefault(); } void ScummEngine_v5::o5_oldRoomEffect() { diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 5306c9be72a..169e6ae12e3 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].backup.charset][i] = (unsigned char)args[i]; + _charsetColorMap[i] = _charsetData[_string[1]._default.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].backup.charset; + vs->charset_nr = _string[0]._default.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(); - _string[0].restoreString(); + _string[0].loadDefault(); actorTalk(_scriptPointer); _scriptPointer += resStrLen(_scriptPointer) + 1; @@ -3119,12 +3119,12 @@ void ScummEngine_v6::decodeParseString(int m, int n) { break; case 0xFE: - _string[m].restoreString(); + _string[m].loadDefault(); if (n) _actorToPrintStrFor = pop(); break; case 0xFF: - _string[m].backupString(); + _string[m].saveDefault(); break; default: error("decodeParseString: default case 0x%x", b); diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 9116436fb4e..9e0b52a22f1 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -754,7 +754,7 @@ void ScummEngine_v6he::o6_verbOps() { vs->hicolor = 0; vs->dimcolor = 8; vs->type = kTextVerbType; - vs->charset_nr = _string[0].backup.charset; + vs->charset_nr = _string[0]._default.charset; vs->curmode = 0; vs->saveid = 0; vs->key = 0; @@ -1463,12 +1463,12 @@ void ScummEngine_v6he::decodeParseString(int m, int n) { warning("decodeParseString case 0xF9 stub"); break; case 0xFE: - _string[m].restoreString(); + _string[m].loadDefault(); if (n) _actorToPrintStrFor = pop(); break; case 0xFF: - _string[m].backupString(); + _string[m].saveDefault(); break; default: error("decodeParseString: default case 0x%x", b); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 7a86e404e87..de7467bc0fd 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -472,12 +472,12 @@ void ScummEngine_v8::decodeParseString(int m, int n) { switch (b) { case 0xC8: // SO_PRINT_BASEOP - _string[m].restoreString(); + _string[m].loadDefault(); if (n) _actorToPrintStrFor = pop(); break; case 0xC9: // SO_PRINT_END - _string[m].backupString(); + _string[m].saveDefault(); break; case 0xCA: // SO_PRINT_AT _string[m].ypos = pop(); @@ -762,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].backup.charset][i] = (unsigned char)args[i]; + _charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i]; break; case 0xE9: // SO_CURSOR_PUT { @@ -1144,7 +1144,7 @@ void ScummEngine_v8::o8_verbOps() { vs->hicolor = 0; vs->dimcolor = 8; vs->type = kTextVerbType; - vs->charset_nr = _string[0].backup.charset; + vs->charset_nr = _string[0]._default.charset; vs->curmode = 0; vs->saveid = 0; vs->key = 0; diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 780282ed6ac..d9a7ebba915 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -1132,16 +1132,16 @@ void ScummEngine::scummInit() { for (i = 0; i < 6; i++) { if (_version == 3) { // FIXME - what is this? - _string[i].backup.xpos = 0; - _string[i].backup.ypos = 0; + _string[i]._default.xpos = 0; + _string[i]._default.ypos = 0; } else { - _string[i].backup.xpos = 2; - _string[i].backup.ypos = 5; + _string[i]._default.xpos = 2; + _string[i]._default.ypos = 5; } - _string[i].backup.right = _screenWidth - 1; - _string[i].backup.color = 0xF; - _string[i].backup.center = 0; - _string[i].backup.charset = 0; + _string[i]._default.right = _screenWidth - 1; + _string[i]._default.color = 0xF; + _string[i]._default.center = 0; + _string[i]._default.charset = 0; } // all keys are released diff --git a/scumm/scumm.h b/scumm/scumm.h index 9808d12582f..e7971cb5869 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -264,16 +264,19 @@ struct StringSlot { }; struct StringTab : StringSlot { - StringSlot backup; + // The 'default' values for this string slot. This is used so that the + // string slot can temporarily be set to different values, and then be + // easily reset to a previously set default. + StringSlot _default; - void backupString() { + void saveDefault() { StringSlot &s = *this; - backup = s; + _default = s; } - void restoreString() { + void loadDefault() { StringSlot &s = *this; - s = backup; + s = _default; } }; diff --git a/scumm/string.cpp b/scumm/string.cpp index 78537774944..01748f16137 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -598,8 +598,8 @@ void ScummEngine::initCharset(int charsetno) { if (!getResourceAddress(rtCharset, charsetno)) loadCharset(charsetno); - _string[0].backup.charset = charsetno; - _string[1].backup.charset = charsetno; + _string[0]._default.charset = charsetno; + _string[1]._default.charset = charsetno; for (i = 0; i < 16; i++) _charsetColorMap[i] = _charsetData[charsetno][i];