diff options
Diffstat (limited to 'engines/gob/inter_v2.cpp')
-rw-r--r-- | engines/gob/inter_v2.cpp | 187 |
1 files changed, 185 insertions, 2 deletions
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 6b7a4f03bd..3aa7ad1664 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -124,6 +124,7 @@ void Inter_v2::setupOpcodesFunc() { OPCODEFUNC(0x18, o2_addHotspot); OPCODEFUNC(0x19, o2_removeHotspot); + OPCODEFUNC(0x1A, o2_getTotTextItemPart); OPCODEFUNC(0x25, o2_goblinFunc); @@ -1195,6 +1196,188 @@ void Inter_v2::o2_removeHotspot(OpFuncParams ¶ms) { _vm->_game->_hotspots->remove((stateType2 << 12) + id); } +void Inter_v2::o2_getTotTextItemPart(OpFuncParams ¶ms) { + byte *totData; + int16 totTextItem; + int16 part, curPart = 0; + int16 offX = 0, offY = 0; + int16 collId = 0, collCmd; + uint32 stringStartVar, stringVar; + bool end; + + totTextItem = _vm->_game->_script->readInt16(); + stringStartVar = _vm->_game->_script->readVarIndex(); + part = _vm->_game->_script->readValExpr(); + + stringVar = stringStartVar; + if (part == -1) { + warning("o2_getTotTextItemPart, part == -1"); + _vm->_draw->_hotspotText = GET_VARO_STR(stringVar); + } + + WRITE_VARO_UINT8(stringVar, 0); + + TextItem *textItem = _vm->_game->_resources->getTextItem(totTextItem); + if (!textItem) + return; + + totData = textItem->getData(); + + // Skip background rectangles + while (((int16) READ_LE_UINT16(totData)) != -1) + totData += 9; + totData += 2; + + while (*totData != 1) { + switch (*totData) { + case 2: + case 5: + totData++; + offX = READ_LE_UINT16(totData); + offY = READ_LE_UINT16(totData + 2); + totData += 4; + break; + + case 3: + case 4: + totData += 2; + break; + + case 6: + totData++; + + collCmd = *totData++; + if (collCmd & 0x80) { + collId = READ_LE_UINT16(totData); + totData += 2; + } + + // Skip collision coordinates + if (collCmd & 0x40) + totData += 8; + + if ((collCmd & 0x8F) && ((-collId - 1) == part)) { + int n = 0; + + while (1) { + if ((*totData < 1) || (*totData > 7)) { + if (*totData >= 32) { + WRITE_VARO_UINT8(stringVar++, *totData++); + n++; + } else + totData++; + continue; + } + + if ((n != 0) || (*totData == 1) || + (*totData == 6) || (*totData == 7)) { + WRITE_VARO_UINT8(stringVar, 0); + delete textItem; + return; + } + + switch (*totData) { + case 2: + case 5: + totData += 5; + break; + + case 3: + case 4: + totData += 2; + break; + } + } + + } + break; + + case 7: + case 8: + case 9: + totData++; + break; + + case 10: + if (curPart == part) { + WRITE_VARO_UINT8(stringVar++, 0xFF); + WRITE_VARO_UINT16(stringVar, offX); + WRITE_VARO_UINT16(stringVar + 2, offY); + WRITE_VARO_UINT16(stringVar + 4, + totData - _vm->_game->_resources->getTexts()); + WRITE_VARO_UINT8(stringVar + 6, 0); + delete textItem; + return; + } + + end = false; + while (!end) { + switch (*totData) { + case 2: + case 5: + if (ABS(offY - READ_LE_UINT16(totData + 3)) > 1) + end = true; + else + totData += 5; + break; + + case 3: + totData += 2; + break; + + case 10: + totData += totData[1] * 2 + 2; + break; + + default: + if (*totData < 32) + end = true; + while (*totData >= 32) + totData++; + break; + } + } + + if (part >= 0) + curPart++; + break; + + default: + while (1) { + + while (*totData >= 32) + WRITE_VARO_UINT8(stringVar++, *totData++); + WRITE_VARO_UINT8(stringVar, 0); + + if (((*totData != 2) && (*totData != 5)) || + (ABS(offY - READ_LE_UINT16(totData + 3)) > 1)) { + + if (curPart == part) { + delete textItem; + return; + } + + stringVar = stringStartVar; + WRITE_VARO_UINT8(stringVar, 0); + + while (*totData >= 32) + totData++; + + if (part >= 0) + curPart++; + break; + + } else + totData += 5; + + } + break; + } + } + + delete textItem; +} + void Inter_v2::o2_goblinFunc(OpFuncParams ¶ms) { OpGobParams gobParams; int16 cmd; |