2002-06-29 16:11:13 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2001-2005 The ScummVM project
|
2002-06-29 16:11:13 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Item script opcodes for Simon1/Simon2
|
2002-12-02 00:05:05 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
#include "stdafx.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "simon/simon.h"
|
|
|
|
#include "simon/intern.h"
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
|
|
|
|
2005-03-26 14:09:21 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
extern bool isSmartphone(void);
|
|
|
|
#endif
|
|
|
|
|
2003-10-03 19:42:27 +00:00
|
|
|
namespace Simon {
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
int SimonEngine::runScript() {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte opcode;
|
|
|
|
bool flag, condition;
|
|
|
|
|
|
|
|
do {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_continousMainScript)
|
|
|
|
dumpOpcode(_codePtr);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
opcode = getByte();
|
2002-07-07 19:06:48 +00:00
|
|
|
if (opcode == 0xFF)
|
2002-06-29 16:11:13 +00:00
|
|
|
return 0;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_runScriptReturn1)
|
2002-07-07 19:06:48 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Invert condition? */
|
|
|
|
flag = false;
|
|
|
|
if (opcode == 0) {
|
|
|
|
flag = true;
|
|
|
|
opcode = getByte();
|
|
|
|
if (opcode == 0xFF)
|
|
|
|
return 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
condition = true;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
switch (opcode) {
|
|
|
|
case 1:{ /* ptrA parent is */
|
|
|
|
condition = (getItem1Ptr()->parent == getNextItemID());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 2:{ /* ptrA parent is not */
|
|
|
|
condition = (getItem1Ptr()->parent != getNextItemID());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 5:{ /* parent is 1 */
|
|
|
|
condition = (getNextItemPtr()->parent == getItem1ID());
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 6:{ /* parent isnot 1 */
|
|
|
|
condition = (getNextItemPtr()->parent != getItem1ID());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 7:{ /* parent is */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
condition = (item->parent == getNextItemID());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 11:{ /* is zero */
|
|
|
|
condition = (getNextVarContents() == 0);
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 12:{ /* isnot zero */
|
|
|
|
condition = (getNextVarContents() != 0);
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 13:{ /* equal */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp == getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 14:{ /* not equal */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp != getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 15:{ /* is greater */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp > getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 16:{ /* is less */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp < getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 17:{ /* is eq f */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp == getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 18:{ /* is not equal f */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp != getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 19:{ /* is greater f */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp < getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 20:{ /* is less f */
|
|
|
|
uint tmp = getNextVarContents();
|
|
|
|
condition = (tmp > getNextVarContents());
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
case 23:{
|
|
|
|
condition = o_unk_23(getVarOrWord());
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 25:{ /* has child of type 1 */
|
|
|
|
condition = hasChildOfType1(getNextItemPtr());
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
case 26:{ /* has child of type 2 */
|
|
|
|
condition = hasChildOfType2(getNextItemPtr());
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
case 27:{ /* item unk3 is */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
condition = ((uint) item->unk3 == getVarOrWord());
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
case 28:{ /* item has prop */
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
byte num = getVarOrByte();
|
|
|
|
condition = child != NULL && (child->avail_props & (1 << num)) != 0;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 31:{ /* set no parent */
|
|
|
|
setItemParent(getNextItemPtr(), NULL);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 33:{ /* set item parent */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
setItemParent(item, getNextItemPtr());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 36:{ /* copy var */
|
|
|
|
uint value = getNextVarContents();
|
|
|
|
writeNextVarContents(value);
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 41:{ /* zero var */
|
|
|
|
writeNextVarContents(0);
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 42:{ /* set var */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 43:{ /* add */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) + getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 44:{ /* sub */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) - getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 45:{ /* add f */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) + getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 46:{ /* sub f */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) - getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 47:{ /* mul */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) * getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 48:{ /* div */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
int value = getVarOrWord();
|
|
|
|
if (value == 0)
|
|
|
|
error("Division by zero in div");
|
|
|
|
writeVariable(var, readVariable(var) / value);
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 49:{ /* mul f */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
writeVariable(var, readVariable(var) * getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 50:{ /* div f */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
int value = getNextVarContents();
|
|
|
|
if (value == 0)
|
|
|
|
error("Division by zero in div f");
|
|
|
|
writeVariable(var, readVariable(var) / value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 51:{ /* mod */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
int value = getVarOrWord();
|
|
|
|
if (value == 0)
|
|
|
|
error("Division by zero in mod");
|
|
|
|
writeVariable(var, readVariable(var) % value);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 52:{ /* mod f */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
int value = getNextVarContents();
|
|
|
|
if (value == 0)
|
|
|
|
error("Division by zero in mod f");
|
|
|
|
writeVariable(var, readVariable(var) % value);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 53:{ /* random */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
uint value = (uint16)getVarOrWord();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-05-26 08:45:31 +00:00
|
|
|
// Disable random in simon1amiga for now
|
|
|
|
// Since copy protection screen is currently unreadable
|
|
|
|
if (_game == GAME_SIMON1AMIGA)
|
|
|
|
writeVariable(var, 4);
|
|
|
|
else
|
|
|
|
writeVariable(var, _rnd.getRandomNumber(value - 1));
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 55:{ /* set itemA parent */
|
|
|
|
setItemParent(getItem1Ptr(), getNextItemPtr());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 56:{ /* set child2 fr bit */
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
int value = getVarOrByte();
|
|
|
|
if (child != NULL && value >= 0x10)
|
|
|
|
child->avail_props |= 1 << value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 57:{ /* clear child2 fr bit */
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
int value = getVarOrByte();
|
|
|
|
if (child != NULL && value >= 0x10)
|
|
|
|
child->avail_props &= ~(1 << value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 58:{ /* make siblings */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
setItemParent(item, derefItem(getNextItemPtr()->parent));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 59:{ /* item inc unk3 */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
if (item->unk3 <= 30000)
|
|
|
|
setItemUnk3(item, item->unk3 + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 60:{ /* item dec unk3 */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
if (item->unk3 >= 0)
|
|
|
|
setItemUnk3(item, item->unk3 - 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 61:{ /* item set unk3 */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
int value = getVarOrWord();
|
|
|
|
if (value < 0)
|
|
|
|
value = 0;
|
|
|
|
if (value > 30000)
|
|
|
|
value = 30000;
|
|
|
|
setItemUnk3(item, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 62:{ /* show int */
|
|
|
|
showMessageFormat("%d", getNextVarContents());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 63:{ /* show string nl */
|
|
|
|
showMessageFormat("%s\n", getStringPtrByID(getNextStringID()));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 64:{ /* show string */
|
|
|
|
showMessageFormat("%s", getStringPtrByID(getNextStringID()));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 65:{ /* add hit area */
|
|
|
|
int id = getVarOrWord();
|
|
|
|
int x = getVarOrWord();
|
|
|
|
int y = getVarOrWord();
|
|
|
|
int w = getVarOrWord();
|
|
|
|
int h = getVarOrWord();
|
|
|
|
int number = getVarOrByte();
|
|
|
|
if (number < 20)
|
2005-05-06 11:37:33 +00:00
|
|
|
addNewHitArea(id, x, y, w, h, (number << 8) + 129, 0xD0, _dummyItem2);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 66:{ /* set item name */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint var = getVarOrByte();
|
|
|
|
uint string_id = getNextStringID();
|
|
|
|
if (var < 20)
|
2005-05-06 11:37:33 +00:00
|
|
|
_stringIdArray2[var] = string_id;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 67:{ /* set item description */
|
2002-12-04 22:40:16 +00:00
|
|
|
uint var = getVarOrByte();
|
|
|
|
uint string_id = getNextStringID();
|
2003-07-20 15:17:11 +00:00
|
|
|
if (_game & GF_TALKIE) {
|
2003-12-01 05:22:04 +00:00
|
|
|
uint speech_id = getNextWord();
|
2003-07-20 15:17:11 +00:00
|
|
|
if (var < 20) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_stringIdArray3[var] = string_id;
|
|
|
|
_speechIdArray4[var] = speech_id;
|
2003-07-20 15:17:11 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-12-18 09:04:13 +00:00
|
|
|
if (var < 20) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_stringIdArray3[var] = string_id;
|
2003-12-18 09:04:13 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 68:{ /* exit interpreter */
|
2003-05-29 06:06:32 +00:00
|
|
|
shutdown();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 69:{ /* return 1 */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 70:{ /* show string from array */
|
2005-05-06 11:37:33 +00:00
|
|
|
const char *str = (const char *)getStringPtrByID(_stringIdArray3[getVarOrByte()]);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-07-07 19:06:48 +00:00
|
|
|
writeVariable(51, strlen(str) / 53 * 8 + 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
showMessageFormat("%s\n", str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 71:{ /* start subroutine */
|
|
|
|
Subroutine *sub = getSubroutineByID(getVarOrWord());
|
|
|
|
if (sub != NULL)
|
|
|
|
startSubroutine(sub);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 76:{ /* add timeout */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint timeout = getVarOrWord();
|
|
|
|
addTimeEvent(timeout, getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 77:{ /* has item minus 1 */
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = _subjectItem != NULL;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 78:{ /* has item minus 3 */
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = _objectItem != NULL;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 79:{ /* childstruct fr2 is */
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
uint string_id = getNextStringID();
|
|
|
|
condition = (child != NULL) && child->string_id == string_id;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 80:{ /* item equal */
|
|
|
|
condition = getNextItemPtr() == getNextItemPtr();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-20 15:17:11 +00:00
|
|
|
case 82:{ /* dummy opcode */
|
2002-07-07 19:06:48 +00:00
|
|
|
getVarOrByte();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 83:{ /* restart subroutine */
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2)
|
2002-12-03 05:34:55 +00:00
|
|
|
o_83_helper();
|
2002-07-07 19:06:48 +00:00
|
|
|
return -10;
|
|
|
|
}
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 87:{ /* dummy opcode */
|
2002-07-07 19:06:48 +00:00
|
|
|
getNextStringID();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
case 88:{ /* or_lockWord */
|
|
|
|
_lockWord |= 0x10;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 89:{ /* and lock word */
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord &= ~0x10;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 90:{ /* set minusitem to parent */
|
|
|
|
Item *item = derefItem(getNextItemPtr()->parent);
|
|
|
|
switch (getVarOrByte()) {
|
|
|
|
case 0:
|
2005-05-06 11:37:33 +00:00
|
|
|
_objectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2005-05-06 11:37:33 +00:00
|
|
|
_subjectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("set minusitem to parent, invalid subcode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 91:{ /* set minusitem to sibling */
|
|
|
|
Item *item = derefItem(getNextItemPtr()->sibling);
|
|
|
|
switch (getVarOrByte()) {
|
|
|
|
case 0:
|
2005-05-06 11:37:33 +00:00
|
|
|
_objectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2005-05-06 11:37:33 +00:00
|
|
|
_subjectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("set minusitem to sibling, invalid subcode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 92:{ /* set minusitem to child */
|
|
|
|
Item *item = derefItem(getNextItemPtr()->child);
|
|
|
|
switch (getVarOrByte()) {
|
|
|
|
case 0:
|
2005-05-06 11:37:33 +00:00
|
|
|
_objectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2005-05-06 11:37:33 +00:00
|
|
|
_subjectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("set minusitem to child, invalid subcode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 96:{
|
|
|
|
uint val = getVarOrWord();
|
|
|
|
o_set_video_mode(getVarOrByte(), val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 97:{ /* load vga */
|
|
|
|
ensureVgaResLoadedC(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 98:{ /* start vga */
|
2005-05-06 12:23:19 +00:00
|
|
|
uint vga_res, vgaSpriteId, paletteMode, x, y, base_color;
|
|
|
|
if (_game & GF_SIMON2) {
|
|
|
|
vga_res = getVarOrWord();
|
|
|
|
vgaSpriteId = getVarOrWord();
|
2002-07-07 19:06:48 +00:00
|
|
|
} else {
|
2005-05-06 12:23:19 +00:00
|
|
|
vgaSpriteId = getVarOrWord();
|
|
|
|
vga_res = vgaSpriteId / 100;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
2005-05-06 12:23:19 +00:00
|
|
|
paletteMode = getVarOrByte();
|
|
|
|
x = getVarOrWord();
|
|
|
|
y = getVarOrWord();
|
|
|
|
base_color = getVarOrWord();
|
2005-05-06 13:22:48 +00:00
|
|
|
loadSprite(paletteMode, vga_res, vgaSpriteId, x, y, base_color);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-05-24 12:26:28 +00:00
|
|
|
case 99:{ /* kill sprite */
|
2005-05-06 12:23:19 +00:00
|
|
|
if (_game & GF_SIMON1) {
|
2003-05-24 12:26:28 +00:00
|
|
|
o_kill_sprite_simon1(getVarOrWord());
|
2002-07-07 19:06:48 +00:00
|
|
|
} else {
|
|
|
|
uint a = getVarOrWord();
|
|
|
|
uint b = getVarOrWord();
|
2003-05-24 12:26:28 +00:00
|
|
|
o_kill_sprite_simon2(a, b);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 100:{ /* vga reset */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_vga_reset();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 101:{
|
|
|
|
uint a = getVarOrByte();
|
|
|
|
uint b = getVarOrWord();
|
|
|
|
uint c = getVarOrWord();
|
|
|
|
uint d = getVarOrWord();
|
|
|
|
uint e = getVarOrWord();
|
|
|
|
uint f = getVarOrWord();
|
|
|
|
uint g = getVarOrWord();
|
|
|
|
o_unk26_helper(a, b, c, d, e, f, g, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 102:{
|
|
|
|
fcs_unk_2(getVarOrByte() & 7);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 103:{
|
|
|
|
o_unk_103();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 104:{
|
|
|
|
fcs_delete(getVarOrByte() & 7);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 107:{ /* add item hitarea */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint flags = 0;
|
|
|
|
uint id = getVarOrWord();
|
|
|
|
uint params = id / 1000;
|
|
|
|
uint x, y, w, h, unk3;
|
|
|
|
Item *item;
|
|
|
|
|
|
|
|
id = id % 1000;
|
|
|
|
|
|
|
|
if (params & 1)
|
|
|
|
flags |= 8;
|
|
|
|
if (params & 2)
|
|
|
|
flags |= 4;
|
|
|
|
if (params & 4)
|
|
|
|
flags |= 0x80;
|
|
|
|
if (params & 8)
|
|
|
|
flags |= 1;
|
|
|
|
if (params & 16)
|
|
|
|
flags |= 0x10;
|
|
|
|
|
|
|
|
x = getVarOrWord();
|
|
|
|
y = getVarOrWord();
|
|
|
|
w = getVarOrWord();
|
|
|
|
h = getVarOrWord();
|
|
|
|
item = getNextItemPtrStrange();
|
|
|
|
unk3 = getVarOrWord();
|
|
|
|
if (x >= 1000) {
|
|
|
|
unk3 += 0x4000;
|
|
|
|
x -= 1000;
|
|
|
|
}
|
|
|
|
addNewHitArea(id, x, y, w, h, flags, unk3, item);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 108:{ /* delete hitarea */
|
|
|
|
delete_hitarea(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 109:{ /* clear hitarea bit 0x40 */
|
|
|
|
clear_hitarea_bit_0x40(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 110:{ /* set hitarea bit 0x40 */
|
|
|
|
set_hitarea_bit_0x40(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 111:{ /* set hitarea xy */
|
|
|
|
uint hitarea_id = getVarOrWord();
|
|
|
|
uint x = getVarOrWord();
|
|
|
|
uint y = getVarOrWord();
|
|
|
|
set_hitarea_x_y(hitarea_id, x, y);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 114:{
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
uint fcs_index = getVarOrByte();
|
|
|
|
lock();
|
|
|
|
fcs_unk_proc_1(fcs_index, item, 0, 0);
|
|
|
|
unlock();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 115:{ /* item has flag */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
condition = (item->unk4 & (1 << getVarOrByte())) != 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 116:{ /* item set flag */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
item->unk4 |= (1 << getVarOrByte());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 117:{ /* item clear flag */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
item->unk4 &= ~(1 << getVarOrByte());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 119:{ /* wait vga */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint var = getVarOrWord();
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptVar2 = (var == 200);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (var != 200 || !_skipVgaWait)
|
2002-07-07 19:06:48 +00:00
|
|
|
o_wait_for_vga(var);
|
2005-05-06 11:37:33 +00:00
|
|
|
_skipVgaWait = false;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 120:{
|
|
|
|
o_unk_120(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 121:{ /* set vga item */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint slot = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
_vcItemArray[slot] = getNextItemPtr();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 125:{ /* item is sibling with item 1 */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
condition = (getItem1Ptr()->parent == item->parent);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 126:{
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
uint fcs_index = getVarOrByte();
|
|
|
|
uint a = 1 << getVarOrByte();
|
|
|
|
lock();
|
|
|
|
fcs_unk_proc_1(fcs_index, item, 1, a);
|
|
|
|
unlock();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 127:{ /* deals with music */
|
2003-05-21 05:12:04 +00:00
|
|
|
o_play_music_resource();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 128:{ /* dummy instruction */
|
2002-07-07 19:06:48 +00:00
|
|
|
getVarOrWord();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 129:{ /* dummy instruction */
|
2002-07-07 19:06:48 +00:00
|
|
|
getVarOrWord();
|
|
|
|
condition = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 130:{ /* set script cond */
|
2003-10-21 11:41:33 +00:00
|
|
|
uint var = getVarOrByte();
|
2002-12-04 22:40:16 +00:00
|
|
|
getNextWord();
|
2003-10-21 11:41:33 +00:00
|
|
|
if (var == 1)
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptCondB = getNextWord();
|
2002-12-04 22:40:16 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptCondC = getNextWord();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 132:{ /* save game */
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
2002-07-07 19:06:48 +00:00
|
|
|
o_save_game();
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 133:{ /* load game */
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
2002-07-07 19:06:48 +00:00
|
|
|
o_load_game();
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 134:{ /* dummy opcode? */
|
2003-05-20 09:25:45 +00:00
|
|
|
midi.stop();
|
2005-05-06 11:37:33 +00:00
|
|
|
_lastMusicPlayed = -1;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 135:{ /* quit if user presses y */
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
2002-11-17 15:15:26 +00:00
|
|
|
o_quit_if_user_presses_y();
|
2004-02-24 22:39:42 +00:00
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 136:{ /* set var to item unk3 */
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
writeNextVarContents(item->unk3);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 137:{
|
|
|
|
o_unk_137(getVarOrByte());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 138:{ /* vga pointer op 4 */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_unk_138();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 139:{ /* set parent special */
|
2002-07-07 19:06:48 +00:00
|
|
|
Item *item = getNextItemPtr();
|
2005-05-06 11:37:33 +00:00
|
|
|
_noParentNotify = true;
|
2002-07-07 19:06:48 +00:00
|
|
|
setItemParent(item, getNextItemPtr());
|
2005-05-06 11:37:33 +00:00
|
|
|
_noParentNotify = false;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 140:{ /* del te and add one */
|
2002-07-07 19:06:48 +00:00
|
|
|
killAllTimers();
|
|
|
|
addTimeEvent(3, 0xA0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 141:{ /* set m1 or m3 */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint which = getVarOrByte();
|
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
if (which == 1) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_subjectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
} else {
|
2005-05-06 11:37:33 +00:00
|
|
|
_objectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 142:{ /* is hitarea 0x40 clear */
|
2002-07-07 19:06:48 +00:00
|
|
|
condition = is_hitarea_0x40_clear(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 143:{ /* start item sub */
|
2002-10-30 23:52:19 +00:00
|
|
|
Child1 *child = (Child1 *)findChildOfType(getNextItemPtr(), 1);
|
2002-07-07 19:06:48 +00:00
|
|
|
if (child != NULL) {
|
|
|
|
Subroutine *sub = getSubroutineByID(child->subroutine_id);
|
|
|
|
if (sub)
|
|
|
|
startSubroutine(sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 151:{ /* set array6 to item */
|
|
|
|
uint var = getVarOrByte();
|
|
|
|
Item *item = getNextItemPtr();
|
2005-05-06 11:37:33 +00:00
|
|
|
_itemArray6[var] = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 152:{ /* set m1 or m3 to array6 */
|
2005-05-06 11:37:33 +00:00
|
|
|
Item *item = _itemArray6[getVarOrByte()];
|
2002-07-07 19:06:48 +00:00
|
|
|
uint var = getVarOrByte();
|
|
|
|
if (var == 1) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_subjectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
} else {
|
2005-05-06 11:37:33 +00:00
|
|
|
_objectItem = item;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 153:{ /* set bit */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
_bitArray[bit >> 4] |= 1 << (bit & 15);
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 154:{ /* clear bit */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
_bitArray[bit >> 4] &= ~(1 << (bit & 15));
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 155:{ /* is bit clear? */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = (_bitArray[bit >> 4] & (1 << (bit & 15))) == 0;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 156:{ /* is bit set? */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = (_bitArray[bit >> 4] & (1 << (bit & 15))) != 0;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
case 157:{ /* get item int prop */
|
|
|
|
Item *item = getNextItemPtr();
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(item, 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
uint prop = getVarOrByte();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (child != NULL && child->avail_props & (1 << prop) && prop < 16) {
|
|
|
|
uint offs = getOffsetOfChild2Param(child, 1 << prop);
|
|
|
|
writeNextVarContents(child->array[offs]);
|
|
|
|
} else {
|
|
|
|
writeNextVarContents(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 158:{ /* set item prop */
|
|
|
|
Item *item = getNextItemPtr();
|
2002-10-30 23:52:19 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(item, 2);
|
2002-07-07 19:06:48 +00:00
|
|
|
uint prop = getVarOrByte();
|
|
|
|
int value = getVarOrWord();
|
|
|
|
|
|
|
|
if (child != NULL && child->avail_props & (1 << prop) && prop < 16) {
|
|
|
|
uint offs = getOffsetOfChild2Param(child, 1 << prop);
|
|
|
|
child->array[offs] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 160:{
|
|
|
|
o_unk_160(getVarOrByte());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 161:{ /* setup text */
|
2004-03-14 17:50:40 +00:00
|
|
|
TextLocation *tl = getTextLocation(getVarOrByte());
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2004-03-14 17:50:40 +00:00
|
|
|
tl->x = getVarOrWord();
|
|
|
|
tl->y = getVarOrByte();
|
|
|
|
tl->width = getVarOrWord();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 11:42:00 +00:00
|
|
|
case 162:{ /* print string */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_print_str();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-20 07:27:28 +00:00
|
|
|
case 163:{ /* play sound */
|
2003-07-21 16:25:16 +00:00
|
|
|
o_play_sound(getVarOrWord());
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 164:{
|
2005-05-06 11:37:33 +00:00
|
|
|
_showPreposition = true;
|
2002-07-07 19:06:48 +00:00
|
|
|
o_setup_cond_c();
|
2005-05-06 11:37:33 +00:00
|
|
|
_showPreposition = false;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 165:{ /* item unk1 unk2 is */
|
2002-07-07 19:06:48 +00:00
|
|
|
Item *item = getNextItemPtr();
|
|
|
|
int16 a = getNextWord(), b = getNextWord();
|
|
|
|
condition = (item->unk2 == a && item->unk1 == b);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 166:{ /* set bit2 */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
_bitArray[(bit >> 4) + 16] |= 1 << (bit & 15);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 167:{ /* clear bit2 */
|
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
_bitArray[(bit >> 4) + 16] &= ~(1 << (bit & 15));
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 168:{ /* is bit2 clear */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = (_bitArray[(bit >> 4) + 16] & (1 << (bit & 15))) == 0;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 169:{ /* is bit2 set */
|
2002-07-07 19:06:48 +00:00
|
|
|
uint bit = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = (_bitArray[(bit >> 4) + 16] & (1 << (bit & 15))) != 0;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 175:{ /* vga pointer op 1 */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_unk_175();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 176:{ /* vga pointer op 2 */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_unk_176();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-05-30 09:39:21 +00:00
|
|
|
case 177:{ /* inventory descriptions */
|
2003-05-30 07:46:45 +00:00
|
|
|
o_inventory_descriptions();
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 178:{ /* path find */
|
|
|
|
uint a = getVarOrWord();
|
|
|
|
uint b = getVarOrWord();
|
|
|
|
uint c = getVarOrByte();
|
|
|
|
uint d = getVarOrByte();
|
|
|
|
o_pathfind(a, b, c, d);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-07-21 16:25:16 +00:00
|
|
|
case 179:{ /* conversation responses */
|
2005-05-06 12:23:19 +00:00
|
|
|
uint vgaSpriteId = getVarOrByte(); /* and room descriptions */
|
2003-10-21 10:14:42 +00:00
|
|
|
uint color = getVarOrByte();
|
|
|
|
uint string_id = getVarOrByte();
|
|
|
|
uint speech_id = 0;
|
2002-12-05 22:57:12 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
const char *string_ptr = (const char *)getStringPtrByID(_stringIdArray3[string_id]);
|
2005-05-06 12:23:19 +00:00
|
|
|
TextLocation *tl = getTextLocation(vgaSpriteId);
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_TALKIE)
|
2005-05-06 11:37:33 +00:00
|
|
|
speech_id = _speechIdArray4[string_id];
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-10-30 01:05:08 +00:00
|
|
|
if (_speech && speech_id != 0)
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_speech(speech_id, vgaSpriteId);
|
2003-10-26 05:31:36 +00:00
|
|
|
if (string_ptr != NULL && _subtitles)
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_text(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 180:{ /* force unlock */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_force_unlock();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 181:{ /* force lock */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_force_lock();
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2002-07-07 19:06:48 +00:00
|
|
|
fcs_unk_2(1);
|
|
|
|
showMessageFormat("\xC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 182:{ /* read vgares 328 */
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
|
|
|
o_read_vgares_328();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 183:{ /* read vgares 23 */
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
|
|
|
o_read_vgares_23();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 184:{ /* clear vgapointer entry */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_clear_vgapointer_entry(getVarOrWord());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-05-30 09:39:21 +00:00
|
|
|
case 185:{ /* midi sfx file number */
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
2005-05-06 11:37:33 +00:00
|
|
|
_soundFileId = getVarOrWord();
|
2003-07-21 04:00:04 +00:00
|
|
|
if (_game == GAME_SIMON1CD32) {
|
|
|
|
char buf[10];
|
2005-05-06 11:37:33 +00:00
|
|
|
sprintf(buf, "%d%s", _soundFileId, "Effects");
|
2004-06-27 22:14:35 +00:00
|
|
|
_sound->readSfxFile(buf);
|
2005-05-06 11:37:33 +00:00
|
|
|
sprintf(buf, "%d%s", _soundFileId, "simon");
|
2004-06-27 22:14:35 +00:00
|
|
|
_sound->readVoiceFile(buf);
|
2003-07-21 04:00:04 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 186:{ /* vga pointer op 3 */
|
2002-07-07 19:06:48 +00:00
|
|
|
o_unk_186();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 187:{ /* fade to black */
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
|
|
|
o_fade_to_black();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-29 12:01:03 +00:00
|
|
|
case 188: /* string2 is */
|
2005-05-06 12:23:19 +00:00
|
|
|
if (_game & GF_SIMON1)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
|
|
|
{
|
|
|
|
uint i = getVarOrByte();
|
|
|
|
uint str = getNextStringID();
|
2005-05-06 11:37:33 +00:00
|
|
|
condition = (str < 20 && _stringIdArray2[i] == str);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-05-30 09:39:21 +00:00
|
|
|
case 189:{ /* clear_op189_flag */
|
2005-05-06 12:23:19 +00:00
|
|
|
if (_game & GF_SIMON1)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
2005-05-06 11:37:33 +00:00
|
|
|
_op189Flags = 0;
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 190:{
|
|
|
|
uint i;
|
2005-05-06 12:23:19 +00:00
|
|
|
if (_game & GF_SIMON1)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto invalid_opcode;
|
|
|
|
i = getVarOrByte();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (!(_op189Flags & (1 << i)))
|
2002-07-07 19:06:48 +00:00
|
|
|
o_190_helper(i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
invalid_opcode:;
|
|
|
|
error("Invalid opcode '%d'", opcode);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} while (condition != flag);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
int SimonEngine::startSubroutine(Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
int result = -1;
|
|
|
|
SubroutineLine *sl;
|
2004-12-18 02:08:32 +00:00
|
|
|
const byte *old_code_ptr;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_startMainScript)
|
2002-11-20 06:33:12 +00:00
|
|
|
dumpSubroutine(sub);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
old_code_ptr = _codePtr;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (++_recursionDepth > 40)
|
2002-06-29 16:11:13 +00:00
|
|
|
error("Recursion error");
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
sl = (SubroutineLine *)((byte *)sub + sub->first);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
while ((byte *)sl != (byte *)sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (checkIfToRunSubroutineLine(sl, sub)) {
|
|
|
|
result = 0;
|
2005-05-06 11:37:33 +00:00
|
|
|
_codePtr = (byte *)sl;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (sub->id)
|
2005-05-06 11:37:33 +00:00
|
|
|
_codePtr += 2;
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_codePtr += 8;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_continousMainScript)
|
|
|
|
fprintf(_dumpFile, "; %d\n", sub->id);
|
2002-06-29 16:11:13 +00:00
|
|
|
result = runScript();
|
|
|
|
if (result != 0) {
|
|
|
|
/* result -10 means restart subroutine */
|
|
|
|
if (result == -10) {
|
2002-07-07 19:06:48 +00:00
|
|
|
delay(0); /* maybe leave control to the VGA */
|
|
|
|
sl = (SubroutineLine *)((byte *)sub + sub->first);
|
2002-06-29 16:11:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
sl = (SubroutineLine *)((byte *)sub + sl->next);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_codePtr = old_code_ptr;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_recursionDepth--;
|
2002-06-29 16:11:13 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
int SimonEngine::startSubroutineEx(Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
return startSubroutine(sub);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
bool SimonEngine::checkIfToRunSubroutineLine(SubroutineLine *sl, Subroutine *sub) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (sub->id)
|
|
|
|
return true;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (sl->cond_a != -1 && sl->cond_a != _scriptCondA &&
|
|
|
|
(sl->cond_a != -2 || _scriptCondA != -1))
|
2002-06-29 16:11:13 +00:00
|
|
|
return false;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (sl->cond_b != -1 && sl->cond_b != _scriptCondB &&
|
|
|
|
(sl->cond_b != -2 || _scriptCondB != -1))
|
2002-06-29 16:11:13 +00:00
|
|
|
return false;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (sl->cond_c != -1 && sl->cond_c != _scriptCondC &&
|
|
|
|
(sl->cond_c != -2 || _scriptCondC != -1))
|
2002-06-29 16:11:13 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_83_helper() {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_exitCutscene) {
|
2002-12-03 05:34:55 +00:00
|
|
|
if (vc_get_bit(9)) {
|
|
|
|
startSubroutine170();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
processSpecialKeys();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_190_helper(uint i) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_exitCutscene = false;
|
|
|
|
while (!(_op189Flags & (1 << i))) {
|
|
|
|
if (_exitCutscene) {
|
2002-12-03 05:34:55 +00:00
|
|
|
if (vc_get_bit(9)) {
|
|
|
|
startSubroutine170();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
processSpecialKeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
delay(10);
|
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
bool SimonEngine::o_unk_23(uint a) {
|
2002-06-29 16:11:13 +00:00
|
|
|
if (a == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (a == 100)
|
|
|
|
return 1;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
a += _scriptUnk1;
|
2002-07-07 19:06:48 +00:00
|
|
|
if (a <= 0) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptUnk1 = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-12-05 22:57:12 +00:00
|
|
|
if ((uint)_rnd.getRandomNumber(99) < a) {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_scriptUnk1 <= 0)
|
|
|
|
_scriptUnk1 -= 5;
|
2002-06-29 16:11:13 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptUnk1 = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_scriptUnk1 >= 0)
|
|
|
|
_scriptUnk1 += 5;
|
2002-06-29 16:11:13 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_scriptUnk1 = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_inventory_descriptions() {
|
2005-05-06 12:23:19 +00:00
|
|
|
uint vgaSpriteId = getVarOrByte();
|
2003-10-21 10:14:42 +00:00
|
|
|
uint color = getVarOrByte();
|
|
|
|
const char *string_ptr = NULL;
|
2004-03-14 17:50:40 +00:00
|
|
|
TextLocation *tl = NULL;
|
2003-01-29 11:31:10 +00:00
|
|
|
char buf[256];
|
|
|
|
|
2002-12-12 11:07:01 +00:00
|
|
|
Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
|
2003-01-29 11:31:10 +00:00
|
|
|
if (child != NULL && child->avail_props & 1) {
|
2003-10-21 10:14:42 +00:00
|
|
|
string_ptr = (const char *)getStringPtrByID(child->array[0]);
|
2005-05-06 12:23:19 +00:00
|
|
|
tl = getTextLocation(vgaSpriteId);
|
2003-01-29 11:31:10 +00:00
|
|
|
}
|
|
|
|
|
2003-09-25 04:23:07 +00:00
|
|
|
if ((_game & GF_SIMON2) && (_game & GF_TALKIE)) {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (child != NULL && child->avail_props & 0x200) {
|
2003-12-06 02:08:51 +00:00
|
|
|
uint speech_id = child->array[getOffsetOfChild2Param(child, 0x200)];
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (child->avail_props & 0x100) {
|
2003-12-06 02:08:51 +00:00
|
|
|
uint speech_id_offs = child->array[getOffsetOfChild2Param(child, 0x100)];
|
|
|
|
|
|
|
|
if (speech_id == 116)
|
|
|
|
speech_id = speech_id_offs + 115;
|
|
|
|
if (speech_id == 92)
|
|
|
|
speech_id = speech_id_offs + 98;
|
|
|
|
if (speech_id == 99)
|
|
|
|
speech_id = 9;
|
|
|
|
if (speech_id == 97) {
|
|
|
|
switch (speech_id_offs) {
|
2002-07-07 19:06:48 +00:00
|
|
|
case 12:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 109;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 14:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 108;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 18:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 107;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 20:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 106;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 22:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 105;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 28:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 104;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 90:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 103;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 92:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 102;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
|
|
|
case 100:
|
2003-12-06 02:08:51 +00:00
|
|
|
speech_id = 51;
|
2002-07-07 19:06:48 +00:00
|
|
|
break;
|
2002-06-29 16:11:13 +00:00
|
|
|
default:
|
2003-12-06 02:08:51 +00:00
|
|
|
error("o_177: invalid case %d", speech_id_offs);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-30 01:05:08 +00:00
|
|
|
if (_speech)
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_speech(speech_id, vgaSpriteId);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-09-25 04:23:07 +00:00
|
|
|
} else if (_game & GF_TALKIE) {
|
|
|
|
if (child != NULL && child->avail_props & 0x200) {
|
|
|
|
uint offs = getOffsetOfChild2Param(child, 0x200);
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_speech(child->array[offs], vgaSpriteId);
|
2003-09-25 04:23:07 +00:00
|
|
|
} else if (child != NULL && child->avail_props & 0x100) {
|
|
|
|
uint offs = getOffsetOfChild2Param(child, 0x100);
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_speech(child->array[offs] + 3550, vgaSpriteId);
|
2003-09-25 04:23:07 +00:00
|
|
|
}
|
2003-01-29 11:31:10 +00:00
|
|
|
}
|
2003-09-25 04:23:07 +00:00
|
|
|
|
2003-03-07 12:29:33 +00:00
|
|
|
if (child != NULL && (child->avail_props & 1) && _subtitles) {
|
2002-07-07 19:06:48 +00:00
|
|
|
if (child->avail_props & 0x100) {
|
2003-10-21 10:14:42 +00:00
|
|
|
sprintf(buf, "%d%s", child->array[getOffsetOfChild2Param(child, 0x100)], string_ptr);
|
|
|
|
string_ptr = buf;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
2003-10-21 10:14:42 +00:00
|
|
|
if (string_ptr != NULL)
|
2005-05-06 12:23:19 +00:00
|
|
|
talk_with_text(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_quit_if_user_presses_y() {
|
2002-11-17 15:15:26 +00:00
|
|
|
for (;;) {
|
2002-12-07 13:05:58 +00:00
|
|
|
delay(1);
|
2005-03-26 14:09:21 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
if (isSmartphone()) {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed) {
|
|
|
|
if (_keyPressed == 13)
|
2005-03-26 14:09:21 +00:00
|
|
|
shutdown();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 'f' && _language == 20) // Hebrew
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 's' && _language == 5) // Spanish
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 's' && _language == 3) // Italian
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 'o' && _language == 2) // French
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 'j' && _language == 1) // German
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 'y' && _language == 0) // English
|
2003-05-29 06:05:34 +00:00
|
|
|
shutdown();
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 'n')
|
2003-02-05 09:29:37 +00:00
|
|
|
goto get_out;
|
2002-11-17 15:15:26 +00:00
|
|
|
}
|
2002-12-07 13:05:58 +00:00
|
|
|
get_out:;
|
2002-11-17 15:15:26 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_137(uint fcs_index) {
|
2002-06-29 16:11:13 +00:00
|
|
|
FillOrCopyStruct *fcs;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
fcs = _fcsPtrArray3[fcs_index & 7];
|
2002-06-29 16:11:13 +00:00
|
|
|
if (fcs->fcs_data == NULL)
|
|
|
|
return;
|
|
|
|
fcs_unk_proc_1(fcs_index, fcs->fcs_data->item_ptr, fcs->fcs_data->unk1, fcs->fcs_data->unk2);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_138() {
|
2005-05-06 11:37:33 +00:00
|
|
|
_vgaBufStart = _vgaBufFreeStart;
|
|
|
|
_vgaFileBufOrg = _vgaBufFreeStart;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_186() {
|
2005-05-06 11:37:33 +00:00
|
|
|
_vgaBufFreeStart = _vgaFileBufOrg2;
|
|
|
|
_vgaBufStart = _vgaFileBufOrg2;
|
|
|
|
_vgaFileBufOrg = _vgaFileBufOrg2;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_175() {
|
2005-05-06 11:37:33 +00:00
|
|
|
_vgaBufStart = _vgaBufFreeStart;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_176() {
|
2005-05-06 11:37:33 +00:00
|
|
|
_vgaBufFreeStart = _vgaFileBufOrg;
|
|
|
|
_vgaBufStart = _vgaFileBufOrg;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
int SimonEngine::o_unk_132_helper(bool *b, char *buf) {
|
2002-06-29 16:11:13 +00:00
|
|
|
HitArea *ha;
|
|
|
|
*b = true;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (!_saveLoadFlag) {
|
2002-07-07 19:06:48 +00:00
|
|
|
strange_jump:;
|
2005-05-06 11:37:33 +00:00
|
|
|
_saveLoadFlag = false;
|
2002-06-29 16:11:13 +00:00
|
|
|
savegame_dialog(buf);
|
2002-07-07 19:06:48 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
start_over:;
|
2005-05-06 11:37:33 +00:00
|
|
|
_keyPressed = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-07-21 04:00:04 +00:00
|
|
|
if (_game == GAME_SIMON1CD32)
|
|
|
|
goto start_over_3;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
start_over_2:;
|
2005-05-06 11:37:33 +00:00
|
|
|
_lastHitArea = _lastHitArea3 = 0;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
do {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed != 0) {
|
|
|
|
if (_saveLoadFlag) {
|
2002-07-07 19:06:48 +00:00
|
|
|
*b = false;
|
2005-05-06 11:37:33 +00:00
|
|
|
return _keyPressed;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
goto start_over;
|
|
|
|
}
|
|
|
|
delay(100);
|
2005-05-06 11:37:33 +00:00
|
|
|
} while (_lastHitArea3 == 0);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
ha = _lastHitArea;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (ha == NULL || ha->id < 205)
|
|
|
|
goto start_over_2;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
if (ha->id == 205)
|
|
|
|
return ha->id;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
if (ha->id == 206) {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_saveLoadRowCurPos == 1)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto start_over_2;
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_saveLoadRowCurPos < 7)
|
|
|
|
_saveLoadRowCurPos = 1;
|
2002-07-07 19:06:48 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_saveLoadRowCurPos -= 6;
|
2002-06-29 16:11:13 +00:00
|
|
|
|
|
|
|
goto strange_jump;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
if (ha->id == 207) {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (!_saveDialogFlag)
|
2002-07-07 19:06:48 +00:00
|
|
|
goto start_over_2;
|
2005-05-06 11:37:33 +00:00
|
|
|
_saveLoadRowCurPos += 6;
|
|
|
|
if (_saveLoadRowCurPos >= _numSaveGameRows)
|
|
|
|
_saveLoadRowCurPos = _numSaveGameRows;
|
2002-06-29 16:11:13 +00:00
|
|
|
goto strange_jump;
|
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
|
|
|
|
if (ha->id >= 214)
|
|
|
|
goto start_over_2;
|
2002-06-29 16:11:13 +00:00
|
|
|
return ha->id - 208;
|
2003-07-21 04:00:04 +00:00
|
|
|
|
|
|
|
//FIXME Hack to allow load and save file selection in simon1cd32
|
|
|
|
// Uses the follow keys for moving around
|
|
|
|
// 1 - 6 to select slot to load/save
|
|
|
|
// Up Arrow to move up slots
|
|
|
|
// Down Arrow to move down slots
|
|
|
|
// X to exit
|
|
|
|
start_over_3:;
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_saveLoadFlag) {
|
2003-07-21 04:00:04 +00:00
|
|
|
*b = false;
|
|
|
|
delay(1);
|
2005-05-06 11:37:33 +00:00
|
|
|
return _keyPressed;
|
2003-07-21 04:00:04 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 17) {
|
|
|
|
if (_saveLoadRowCurPos == 1)
|
2003-07-21 04:00:04 +00:00
|
|
|
goto start_over_3;
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_saveLoadRowCurPos < 7)
|
|
|
|
_saveLoadRowCurPos = 1;
|
2003-07-21 04:00:04 +00:00
|
|
|
else
|
2005-05-06 11:37:33 +00:00
|
|
|
_saveLoadRowCurPos -= 6;
|
2003-07-21 04:00:04 +00:00
|
|
|
|
|
|
|
goto strange_jump;
|
|
|
|
}
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 18) {
|
|
|
|
if (!_saveDialogFlag)
|
2003-07-21 04:00:04 +00:00
|
|
|
goto start_over_3;
|
2005-05-06 11:37:33 +00:00
|
|
|
_saveLoadRowCurPos += 6;
|
|
|
|
if (_saveLoadRowCurPos >= _numSaveGameRows)
|
|
|
|
_saveLoadRowCurPos = _numSaveGameRows;
|
2003-07-21 04:00:04 +00:00
|
|
|
goto strange_jump;
|
|
|
|
}
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed == 120)
|
2003-07-21 04:00:04 +00:00
|
|
|
return 205;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_keyPressed > 48 && _keyPressed < 55) {
|
|
|
|
return _keyPressed - 49;
|
2003-07-21 04:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delay(1);
|
|
|
|
goto start_over_3;
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_132_helper_3() {
|
2002-07-07 19:06:48 +00:00
|
|
|
for (int i = 208; i != 208 + 6; i++)
|
2002-06-29 16:11:13 +00:00
|
|
|
set_hitarea_bit_0x40(i);
|
|
|
|
}
|
|
|
|
|
2003-10-21 09:43:37 +00:00
|
|
|
void SimonEngine::o_clear_character(FillOrCopyStruct *fcs, int x, byte b) {
|
2002-06-29 16:11:13 +00:00
|
|
|
byte old_text;
|
|
|
|
|
2003-10-21 06:35:19 +00:00
|
|
|
video_putchar(fcs, x, b);
|
2002-06-29 16:11:13 +00:00
|
|
|
old_text = fcs->text_color;
|
|
|
|
fcs->text_color = fcs->fill_color;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2003-09-26 05:34:52 +00:00
|
|
|
if (_language == 20) { //Hebrew
|
|
|
|
x = 128;
|
|
|
|
} else {
|
|
|
|
x += 120;
|
|
|
|
if (x != 128)
|
|
|
|
x = 129;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
video_putchar(fcs, x);
|
|
|
|
|
|
|
|
fcs->text_color = old_text;
|
|
|
|
video_putchar(fcs, 8);
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_play_music_resource() {
|
2003-05-21 00:44:37 +00:00
|
|
|
int music = getVarOrWord();
|
|
|
|
int track = getVarOrWord();
|
|
|
|
|
|
|
|
// Jamieson630:
|
|
|
|
// This appears to be a "load or play music" command.
|
|
|
|
// The music resource is specified, and optionally
|
|
|
|
// a track as well. Normally we see two calls being
|
|
|
|
// made, one to load the resource and another to
|
|
|
|
// actually start a track (so the resource is
|
|
|
|
// effectively preloaded so there's no latency when
|
|
|
|
// starting playback).
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2003-05-21 04:36:09 +00:00
|
|
|
int loop = getVarOrByte();
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2003-05-21 04:36:09 +00:00
|
|
|
midi.setLoop (loop != 0);
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_lastMusicPlayed != music)
|
|
|
|
_nextMusicToPlay = music;
|
2003-05-22 00:00:42 +00:00
|
|
|
else
|
|
|
|
midi.startTrack (track);
|
2002-06-29 16:11:13 +00:00
|
|
|
} else {
|
2005-05-06 11:37:33 +00:00
|
|
|
if (music != _lastMusicPlayed) {
|
|
|
|
_lastMusicPlayed = music;
|
2003-05-21 05:12:04 +00:00
|
|
|
loadMusic (music);
|
2003-05-21 06:13:47 +00:00
|
|
|
midi.startTrack (track);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_120(uint a) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 id = TO_BE_16(a);
|
2003-03-01 22:52:49 +00:00
|
|
|
if (_game & GF_SIMON2) {
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord |= 0x8000;
|
|
|
|
_vcPtr = (byte *)&id;
|
2005-05-06 13:22:48 +00:00
|
|
|
vc15_wakeup_id();
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord &= ~0x8000;
|
2002-12-22 03:54:51 +00:00
|
|
|
} else {
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord |= 0x4000;
|
|
|
|
_vcPtr = (byte *)&id;
|
2005-05-06 13:22:48 +00:00
|
|
|
vc15_wakeup_id();
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord &= ~0x4000;
|
2002-12-22 03:54:51 +00:00
|
|
|
}
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-10-21 10:34:56 +00:00
|
|
|
void SimonEngine::o_play_sound(uint sound_id) {
|
2003-01-03 12:06:30 +00:00
|
|
|
if (_game == GAME_SIMON1DOS)
|
2003-10-21 10:34:56 +00:00
|
|
|
playSting(sound_id);
|
2003-01-03 12:06:30 +00:00
|
|
|
else
|
2003-10-21 10:34:56 +00:00
|
|
|
_sound->playEffects(sound_id);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_160(uint a) {
|
2005-05-06 11:37:33 +00:00
|
|
|
fcs_setTextColor(_fcsPtrArray3[_fcsUnk1], a);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk_103() {
|
2002-06-29 16:11:13 +00:00
|
|
|
lock();
|
2005-05-06 11:37:33 +00:00
|
|
|
fcs_unk1(_fcsUnk1);
|
2002-06-29 16:11:13 +00:00
|
|
|
showMessageFormat("\x0C");
|
|
|
|
unlock();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_kill_sprite_simon1(uint a) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 b = TO_BE_16(a);
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord |= 0x4000;
|
|
|
|
_vcPtr = (byte *)&b;
|
2005-05-06 13:22:48 +00:00
|
|
|
vc60_killSprite();
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord &= ~0x4000;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_kill_sprite_simon2(uint a, uint b) {
|
2002-06-29 16:11:13 +00:00
|
|
|
uint16 items[2];
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:11:13 +00:00
|
|
|
items[0] = TO_BE_16(a);
|
2002-08-11 09:05:30 +00:00
|
|
|
items[1] = TO_BE_16(b);
|
2002-06-29 16:11:13 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord |= 0x8000;
|
|
|
|
_vcPtr = (byte *)&items;
|
2005-05-06 13:22:48 +00:00
|
|
|
vc60_killSprite();
|
2005-05-06 11:37:33 +00:00
|
|
|
_lockWord &= ~0x8000;
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* OK */
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::o_unk26_helper(uint a, uint b, uint c, uint d, uint e, uint f, uint g, uint h) {
|
2002-06-29 16:11:13 +00:00
|
|
|
a &= 7;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (_fcsPtrArray3[a])
|
2002-06-29 16:11:13 +00:00
|
|
|
fcs_delete(a);
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_fcsPtrArray3[a] = fcs_alloc(b, c, d, e, f, g, h);
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
if (a == _fcsUnk1) {
|
|
|
|
_fcsPtr1 = _fcsPtrArray3[a];
|
|
|
|
showmessage_helper_3(_fcsPtr1->textLength, _fcsPtr1->textMaxLength);
|
2002-06-29 16:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-03 19:42:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Simon
|