2002-06-29 16:23:33 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2002-06-29 16:23:33 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-06-29 16:23:33 +00:00
|
|
|
*
|
2006-02-11 12:46:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-06-29 16:23:33 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Resource file routines for Simon1/Simon2
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2002-11-10 15:24:17 +00:00
|
|
|
#include "common/file.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "simon/simon.h"
|
|
|
|
#include "simon/intern.h"
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2003-10-03 19:42:27 +00:00
|
|
|
namespace Simon {
|
|
|
|
|
2005-10-12 00:35:54 +00:00
|
|
|
// Script opcodes to load into memory
|
2002-07-07 19:06:48 +00:00
|
|
|
static const char *const opcode_arg_table_simon1win[256] = {
|
|
|
|
" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
|
2002-07-07 19:08:28 +00:00
|
|
|
"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
|
|
|
|
"II ", "I ", "I ", "II ", "II ", "IBB ", "BIB ", "BB ", "B ", "BI ", "IB ", "B ", "B ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BN ", "BN ", "BB ", "BB ", "BN ", "BB ", "BN ", "B ", "I ", "IB ",
|
|
|
|
"IB ", "II ", "I ", "I ", "IN ", "B ", "T ", "T ", "NNNNNB ", "BT ", "BTS ", "T ", " ", "B ",
|
|
|
|
"N ", "IBN ", "I ", "I ", "I ", "NN ", " ", " ", "IT ", "II ", "I ", "B ", " ", "IB ", "IBB ",
|
|
|
|
"IIB ", "T ", " ", " ", "IB ", "IB ", "IB ", "B ", "BB ", "IBB ", "NB ", "N ", "NBNNN ", "N ",
|
|
|
|
" ", "BNNNNNN ", "B ", " ", "B ", "B ", "BB ", "NNNNNIN ", "N ", "N ", "N ", "NNN ", "NBNN ",
|
|
|
|
"IBNN ", "IB ", "IB ", "IB ", "IB ", "N ", "N ", "N ", "BI ", " ", " ", "N ", "I ", "IBB ",
|
|
|
|
"NN ", "N ", "N ", "Ban ", "BB ", " ", " ", " ", " ", "IB ", "B ", " ", "II ", " ", "BI ", "N ",
|
|
|
|
"I ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "BI ", "BB ", "B ", "B ", "B ", "B ",
|
|
|
|
"IBB ", "IBN ", "IB ", "B ", "BNBN ", "BBTS ", "N ", " ", "Ian ", "B ", "B ", "B ", "B ", "T ",
|
|
|
|
"T ", "B ", " ", "I ", " ", " ", "BBI ", "NNBB ", "BBB ", " ", " ", " ", " ", "N ", "N ", " ",
|
|
|
|
" ",
|
2002-06-29 16:23:33 +00:00
|
|
|
};
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
static const char *const opcode_arg_table_simon1dos[256] = {
|
|
|
|
" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
|
2002-07-07 19:08:28 +00:00
|
|
|
"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
|
|
|
|
"II ", "I ", "I ", "II ", "II ", "IBB ", "BIB ", "BB ", "B ", "BI ", "IB ", "B ", "B ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BN ", "BN ", "BB ", "BB ", "BN ", "BB ", "BN ", "B ", "I ", "IB ",
|
|
|
|
"IB ", "II ", "I ", "I ", "IN ", "B ", "T ", "T ", "NNNNNB ", "BT ", "BT ", "T ", " ", "B ",
|
|
|
|
"N ", "IBN ", "I ", "I ", "I ", "NN ", " ", " ", "IT ", "II ", "I ", "B ", " ", "IB ", "IBB ",
|
|
|
|
"IIB ", "T ", " ", " ", "IB ", "IB ", "IB ", "B ", "BB ", "IBB ", "NB ", "N ", "NBNNN ", "N ",
|
|
|
|
" ", "BNNNNNN ", "B ", " ", "B ", "B ", "BB ", "NNNNNIN ", "N ", "N ", "N ", "NNN ", "NBNN ",
|
|
|
|
"IBNN ", "IB ", "IB ", "IB ", "IB ", "N ", "N ", "N ", "BI ", " ", " ", "N ", "I ", "IBB ",
|
|
|
|
"NN ", "N ", "N ", "Ban ", "BB ", " ", " ", " ", " ", "IB ", "B ", " ", "II ", " ", "BI ", "N ",
|
|
|
|
"I ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "BI ", "BB ", "B ", "B ", "B ", "B ",
|
|
|
|
"IBB ", "IBN ", "IB ", "B ", "BNBN ", "BBT ", "N ", " ", "Ian ", "B ", "B ", "B ", "B ", "T ",
|
|
|
|
"T ", "B ", " ", "I ", " ", " ", "BBI ", "NNBB ", "BBB ", " ", " ", " ", " ", "N ", "N ", " ",
|
|
|
|
" ",
|
2002-06-29 16:23:33 +00:00
|
|
|
};
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
static const char *const opcode_arg_table_simon2win[256] = {
|
|
|
|
" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
|
2002-07-07 19:08:28 +00:00
|
|
|
"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
|
|
|
|
"II ", "I ", "I ", "II ", "II ", "IBB ", "BIB ", "BB ", "B ", "BI ", "IB ", "B ", "B ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BN ", "BN ", "BB ", "BB ", "BN ", "BB ", "BN ", "B ", "I ", "IB ",
|
|
|
|
"IB ", "II ", "I ", "I ", "IN ", "B ", "T ", "T ", "NNNNNB ", "BT ", "BTS ", "T ", " ", "B ",
|
|
|
|
"N ", "IBN ", "I ", "I ", "I ", "NN ", " ", " ", "IT ", "II ", "I ", "B ", " ", "IB ", "IBB ",
|
|
|
|
"IIB ", "T ", " ", " ", "IB ", "IB ", "IB ", "B ", "BB ", "IBB ", "NB ", "N ", "NNBNNN ", "NN ",
|
|
|
|
" ", "BNNNNNN ", "B ", " ", "B ", "B ", "BB ", "NNNNNIN ", "N ", "N ", "N ", "NNN ", "NBNN ",
|
|
|
|
"IBNN ", "IB ", "IB ", "IB ", "IB ", "N ", "N ", "N ", "BI ", " ", " ", "N ", "I ", "IBB ",
|
|
|
|
"NNB ", "N ", "N ", "Ban ", "BB ", " ", " ", " ", " ", "IB ", "B ", " ", "II ", " ", "BI ",
|
|
|
|
"N ", "I ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "BI ", "BB ", "B ", "B ", "B ",
|
|
|
|
"B ", "IBB ", "IBN ", "IB ", "B ", "BNBN ", "BBTS ", "N ", " ", "Ian ", "B ", "B ", "B ", "B ",
|
|
|
|
"T ", "T ", "B ", " ", "I ", " ", " ", "BBI ", "NNBB ", "BBB ", " ", " ", " ", " ", "N ", "N ",
|
|
|
|
" ", " ", "BT ", " ", "B "
|
2002-07-07 19:06:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const opcode_arg_table_simon2dos[256] = {
|
|
|
|
" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
|
2002-07-07 19:08:28 +00:00
|
|
|
"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
|
|
|
|
"II ", "I ", "I ", "II ", "II ", "IBB ", "BIB ", "BB ", "B ", "BI ", "IB ", "B ", "B ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BN ", "BN ", "BB ", "BB ", "BN ", "BB ", "BN ", "B ", "I ", "IB ",
|
|
|
|
"IB ", "II ", "I ", "I ", "IN ", "B ", "T ", "T ", "NNNNNB ", "BT ", "BT ", "T ", " ", "B ",
|
|
|
|
"N ", "IBN ", "I ", "I ", "I ", "NN ", " ", " ", "IT ", "II ", "I ", "B ", " ", "IB ", "IBB ",
|
|
|
|
"IIB ", "T ", " ", " ", "IB ", "IB ", "IB ", "B ", "BB ", "IBB ", "NB ", "N ", "NNBNNN ", "NN ",
|
|
|
|
" ", "BNNNNNN ", "B ", " ", "B ", "B ", "BB ", "NNNNNIN ", "N ", "N ", "N ", "NNN ", "NBNN ",
|
|
|
|
"IBNN ", "IB ", "IB ", "IB ", "IB ", "N ", "N ", "N ", "BI ", " ", " ", "N ", "I ", "IBB ",
|
|
|
|
"NNB ", "N ", "N ", "Ban ", "BB ", " ", " ", " ", " ", "IB ", "B ", " ", "II ", " ", "BI ",
|
|
|
|
"N ", "I ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "BI ", "BB ", "B ", "B ", "B ",
|
|
|
|
"B ", "IBB ", "IBN ", "IB ", "B ", "BNBN ", "BBT ", "N ", " ", "Ian ", "B ", "B ", "B ", "B ",
|
|
|
|
"T ", "T ", "B ", " ", "I ", " ", " ", "BBI ", "NNBB ", "BBB ", " ", " ", " ", " ", "N ", "N ",
|
|
|
|
" ", " ", "BT ", " ", "B "
|
2002-07-07 19:06:48 +00:00
|
|
|
};
|
|
|
|
|
2005-10-06 14:34:24 +00:00
|
|
|
static const char *const opcode_arg_table_feeblefiles[256] = {
|
|
|
|
" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
|
|
|
|
"II ", "I ", "I ", "II ", "II ", "IBB ", "BIB ", "BB ", "B ", "BI ", "IB ", "B ", "B ", "BN ",
|
|
|
|
"BN ", "BN ", "BB ", "BB ", "BN ", "BN ", "BB ", "BB ", "BN ", "BB ", "BN ", "B ", "I ", "IB ",
|
|
|
|
"IB ", "II ", "I ", "I ", "IN ", "B ", "T ", "T ", "NNNNNB ", "BT ", "BTS ", "T ", " ", "B ",
|
|
|
|
"N ", "IBN ", "I ", "I ", "I ", "NN ", " ", " ", "IT ", "II ", "I ", "B ", " ", "IB ", "IBB ",
|
|
|
|
"IIB ", "T ", " ", " ", "IB ", "IB ", "IB ", "B ", "BB ", "IBB ", "NB ", "N ", "NNBNNN ", "NN ",
|
|
|
|
" ", "BNNNNNN ", "B ", " ", "B ", "B ", "BB ", "NNNNNIN ", "N ", "N ", "N ", "NNN ", "NBNN ",
|
|
|
|
"IBNN ", "IB ", "IB ", "IB ", "IB ", "N ", "N ", "N ", "BI ", " ", " ", "N ", "I ", "IBB ",
|
|
|
|
"NNB ", "N ", "N ", "Ban ", " ", " ", " ", " ", " ", "IB ", "B ", " ", "II ", " ", "BI ",
|
|
|
|
"N ", "I ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "IB ", "BI ", "BB ", "B ", "B ", "B ",
|
|
|
|
"B ", "IBB ", "IBN ", "IB ", "B ", "BNNN ", "BBTS ", "N ", " ", "Ian ", "B ", "B ", "B ", "B ",
|
|
|
|
"T ", "N ", " ", " ", "I ", " ", " ", "BBI ", "NNBB ", "BBB ", " ", " ", "T ", " ", "N ", "N ",
|
|
|
|
" ", " ", "BT ", " ", "B ", " ", "BBBB ", " ", " ", "BBBB ", "B ", "B ", "B ", "B "
|
|
|
|
};
|
|
|
|
|
2005-11-10 01:18:09 +00:00
|
|
|
uint16 SimonEngine::to16Wrapper(uint value) {
|
2005-11-12 06:01:24 +00:00
|
|
|
if (getGameType() == GType_FF)
|
2005-11-10 01:18:09 +00:00
|
|
|
return TO_LE_16(value);
|
|
|
|
else
|
|
|
|
return TO_BE_16(value);
|
|
|
|
}
|
|
|
|
|
2005-10-12 00:35:54 +00:00
|
|
|
uint16 SimonEngine::readUint16Wrapper(const void *src) {
|
2005-11-12 06:01:24 +00:00
|
|
|
if (getGameType() == GType_FF)
|
2005-10-12 00:35:54 +00:00
|
|
|
return READ_LE_UINT16(src);
|
|
|
|
else
|
|
|
|
return READ_BE_UINT16(src);
|
|
|
|
}
|
|
|
|
|
2006-04-07 14:27:28 +00:00
|
|
|
uint32 SimonEngine::readUint32Wrapper(const void *src) {
|
|
|
|
if (getGameType() == GType_FF)
|
|
|
|
return READ_LE_UINT32(src);
|
|
|
|
else
|
|
|
|
return READ_BE_UINT32(src);
|
|
|
|
}
|
|
|
|
|
2006-03-22 06:21:17 +00:00
|
|
|
void SimonEngine::loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &srcSize, uint32 &dstSize) {
|
|
|
|
Common::File in;
|
|
|
|
|
|
|
|
int offsSize = (getPlatform() == Common::kPlatformAmiga) ? 16 : 12;
|
|
|
|
|
|
|
|
/* read offsets from index */
|
|
|
|
in.open(filename);
|
|
|
|
if (in.isOpen() == false) {
|
|
|
|
error("Can't open index file '%s'", filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
in.seek(number * offsSize, SEEK_SET);
|
|
|
|
offset = in.readUint32LE();
|
|
|
|
dstSize = in.readUint32LE();
|
|
|
|
srcSize = in.readUint32LE();
|
|
|
|
file = in.readUint32LE();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
|
2003-06-01 09:41:56 +00:00
|
|
|
void SimonEngine::loadGamePcFile(const char *filename) {
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File in;
|
2002-06-29 16:23:33 +00:00
|
|
|
int num_inited_objects;
|
|
|
|
int i, file_size;
|
|
|
|
|
|
|
|
/* read main gamepc file */
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open(filename);
|
2003-06-14 14:58:08 +00:00
|
|
|
if (in.isOpen() == false) {
|
2002-12-10 09:50:22 +00:00
|
|
|
char *filename2;
|
2003-03-25 12:25:06 +00:00
|
|
|
filename2 = (char *)malloc(strlen(filename) + 2);
|
2002-12-08 23:06:11 +00:00
|
|
|
strcpy(filename2, filename);
|
|
|
|
strcat(filename2, ".");
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open(filename2);
|
2002-12-10 09:50:22 +00:00
|
|
|
free(filename2);
|
2003-06-14 14:58:08 +00:00
|
|
|
if (in.isOpen() == false)
|
2003-01-03 10:36:13 +00:00
|
|
|
error("Can't open gamepc file '%s' or '%s.'", gss->gamepc_filename, gss->gamepc_filename);
|
2002-12-08 23:06:11 +00:00
|
|
|
}
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2003-06-14 14:58:08 +00:00
|
|
|
num_inited_objects = allocGamePcVars(&in);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
createPlayer();
|
2003-06-14 14:58:08 +00:00
|
|
|
readGamePcText(&in);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 2; i < num_inited_objects; i++) {
|
2005-05-06 11:37:33 +00:00
|
|
|
readItemFromGamePc(&in, _itemArrayPtr[i]);
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
|
|
|
|
2003-06-14 14:58:08 +00:00
|
|
|
readSubroutineBlock(&in);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2003-06-14 14:58:08 +00:00
|
|
|
in.close();
|
2002-06-29 16:23:33 +00:00
|
|
|
|
|
|
|
/* Read list of TABLE resources */
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open("TBLLIST");
|
2003-06-14 14:58:08 +00:00
|
|
|
if (in.isOpen() == false) {
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open("TBLLIST.");
|
2003-06-14 14:58:08 +00:00
|
|
|
if (in.isOpen() == false)
|
2003-01-03 10:36:13 +00:00
|
|
|
error("Can't open table resources file 'TBLLIST' or 'TBLLIST.'");
|
2002-12-08 23:06:11 +00:00
|
|
|
}
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2003-06-14 14:58:08 +00:00
|
|
|
file_size = in.size();
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_tblList = (byte *)malloc(file_size);
|
|
|
|
if (_tblList == NULL)
|
2002-06-29 16:23:33 +00:00
|
|
|
error("Out of memory for strip table list");
|
2005-05-06 11:37:33 +00:00
|
|
|
in.read(_tblList, file_size);
|
2003-06-14 14:58:08 +00:00
|
|
|
in.close();
|
2002-06-29 16:23:33 +00:00
|
|
|
|
|
|
|
/* Remember the current state */
|
2005-05-06 11:37:33 +00:00
|
|
|
_subroutineListOrg = _subroutineList;
|
|
|
|
_tablesHeapPtrOrg = _tablesHeapPtr;
|
|
|
|
_tablesHeapCurPosOrg = _tablesHeapCurPos;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2005-11-12 06:01:24 +00:00
|
|
|
if (getGameType() == GType_FF)
|
2005-10-06 14:34:24 +00:00
|
|
|
return;
|
|
|
|
|
2002-06-29 16:23:33 +00:00
|
|
|
/* Read list of TEXT resources */
|
2005-11-12 06:01:24 +00:00
|
|
|
if (getPlatform() == Common::kPlatformAcorn)
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open("STRIPPED");
|
2003-09-24 06:19:30 +00:00
|
|
|
else
|
2004-06-27 22:14:35 +00:00
|
|
|
in.open("STRIPPED.TXT");
|
2003-06-14 14:58:08 +00:00
|
|
|
if (in.isOpen() == false)
|
2003-01-03 10:36:13 +00:00
|
|
|
error("Can't open text resources file 'STRIPPED.TXT'");
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2003-06-14 14:58:08 +00:00
|
|
|
file_size = in.size();
|
2005-05-06 11:37:33 +00:00
|
|
|
_strippedTxtMem = (byte *)malloc(file_size);
|
|
|
|
if (_strippedTxtMem == NULL)
|
2002-06-29 16:23:33 +00:00
|
|
|
error("Out of memory for strip text list");
|
2005-05-06 11:37:33 +00:00
|
|
|
in.read(_strippedTxtMem, file_size);
|
2003-06-14 14:58:08 +00:00
|
|
|
in.close();
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
void SimonEngine::readGamePcText(Common::File *in) {
|
2002-06-29 16:23:33 +00:00
|
|
|
uint text_size;
|
|
|
|
byte *text_mem;
|
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
_textSize = text_size = in->readUint32BE();
|
2002-07-07 19:06:48 +00:00
|
|
|
text_mem = (byte *)malloc(text_size);
|
2002-06-29 16:23:33 +00:00
|
|
|
if (text_mem == NULL)
|
|
|
|
error("Out of text memory");
|
|
|
|
|
2002-09-16 08:22:30 +00:00
|
|
|
in->read(text_mem, text_size);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2005-05-06 11:37:33 +00:00
|
|
|
setupStringTable(text_mem, _stringTabNum);
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
void SimonEngine::readItemFromGamePc(Common::File *in, Item *item) {
|
2002-06-29 16:23:33 +00:00
|
|
|
uint32 type;
|
|
|
|
|
2005-10-03 14:08:07 +00:00
|
|
|
item->adjective = in->readUint16BE();
|
|
|
|
item->noun = in->readUint16BE();
|
|
|
|
item->state = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
item->sibling = (uint16)fileReadItemID(in);
|
|
|
|
item->child = (uint16)fileReadItemID(in);
|
|
|
|
item->parent = (uint16)fileReadItemID(in);
|
2002-10-21 13:23:25 +00:00
|
|
|
in->readUint16BE();
|
2005-10-03 14:08:07 +00:00
|
|
|
item->classFlags = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
item->children = NULL;
|
|
|
|
|
2002-10-21 13:23:25 +00:00
|
|
|
type = in->readUint32BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
while (type) {
|
2002-10-21 13:23:25 +00:00
|
|
|
type = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
if (type != 0)
|
|
|
|
readItemChildren(in, item, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
void SimonEngine::readItemChildren(Common::File *in, Item *item, uint type) {
|
2002-06-29 16:23:33 +00:00
|
|
|
if (type == 1) {
|
2002-10-21 13:23:25 +00:00
|
|
|
uint fr1 = in->readUint16BE();
|
|
|
|
uint fr2 = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
uint i, size;
|
|
|
|
uint j, k;
|
2006-04-06 14:01:52 +00:00
|
|
|
SubRoom *subRoom;
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
size = SubRoom_SIZE;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 0, j = fr2; i != 6; i++, j >>= 2)
|
|
|
|
if (j & 3)
|
2006-04-06 14:01:52 +00:00
|
|
|
size += sizeof(subRoom->roomExit[0]);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
subRoom = (SubRoom *)allocateChildBlock(item, 1, size);
|
|
|
|
subRoom->subroutine_id = fr1;
|
|
|
|
subRoom->roomExitStates = fr2;
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = k = 0, j = fr2; i != 6; i++, j >>= 2)
|
|
|
|
if (j & 3)
|
2006-04-06 14:01:52 +00:00
|
|
|
subRoom->roomExit[k++] = (uint16)fileReadItemID(in);
|
2002-06-29 16:23:33 +00:00
|
|
|
} else if (type == 2) {
|
2002-10-21 13:23:25 +00:00
|
|
|
uint32 fr = in->readUint32BE();
|
2002-07-07 19:06:48 +00:00
|
|
|
uint i, k, size;
|
2006-04-06 14:01:52 +00:00
|
|
|
SubObject *subObject;
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
size = SubObject_SIZE;
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 0; i != 16; i++)
|
|
|
|
if (fr & (1 << i))
|
2006-04-06 14:01:52 +00:00
|
|
|
size += sizeof(subObject->objectFlagValue[0]);
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
subObject = (SubObject *)allocateChildBlock(item, 2, size);
|
|
|
|
subObject->objectFlags = fr;
|
2002-06-29 16:23:33 +00:00
|
|
|
|
|
|
|
k = 0;
|
|
|
|
if (fr & 1) {
|
2006-04-06 14:01:52 +00:00
|
|
|
subObject->objectFlagValue[k++] = (uint16)in->readUint32BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
2002-07-07 19:06:48 +00:00
|
|
|
for (i = 1; i != 16; i++)
|
|
|
|
if (fr & (1 << i))
|
2006-04-06 14:01:52 +00:00
|
|
|
subObject->objectFlagValue[k++] = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
|
2006-04-06 14:01:52 +00:00
|
|
|
subObject->objectName = (uint16)in->readUint32BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
} else {
|
2005-10-09 09:03:37 +00:00
|
|
|
error("readItemChildren: invalid type %d", type);
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
uint fileReadItemID(Common::File *in) {
|
2002-10-21 13:23:25 +00:00
|
|
|
uint32 val = in->readUint32BE();
|
2002-07-07 19:06:48 +00:00
|
|
|
if (val == 0xFFFFFFFF)
|
2002-06-29 16:23:33 +00:00
|
|
|
return 0;
|
|
|
|
return val + 2;
|
|
|
|
}
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
byte *SimonEngine::readSingleOpcode(Common::File *in, byte *ptr) {
|
2002-07-07 19:06:48 +00:00
|
|
|
int i, l;
|
2002-06-29 16:23:33 +00:00
|
|
|
const char *string_ptr;
|
|
|
|
uint val;
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
const char *const *table;
|
|
|
|
|
2005-11-12 06:01:24 +00:00
|
|
|
if (getGameType() == GType_FF) {
|
2005-10-06 14:34:24 +00:00
|
|
|
table = opcode_arg_table_feeblefiles;
|
2005-11-12 06:01:24 +00:00
|
|
|
} else if ((getGameType() == GType_SIMON2) && (getFeatures() & GF_TALKIE))
|
2002-07-07 19:06:48 +00:00
|
|
|
table = opcode_arg_table_simon2win;
|
2005-11-12 06:01:24 +00:00
|
|
|
else if (getGameType() == GType_SIMON2)
|
2003-09-25 04:32:28 +00:00
|
|
|
table = opcode_arg_table_simon2dos;
|
2005-11-12 06:01:24 +00:00
|
|
|
else if (getFeatures() & GF_TALKIE)
|
2003-09-25 04:32:28 +00:00
|
|
|
table = opcode_arg_table_simon1win;
|
|
|
|
else
|
2002-10-24 09:40:20 +00:00
|
|
|
table = opcode_arg_table_simon1dos;
|
2002-06-29 16:23:33 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
string_ptr = table[*ptr++];
|
|
|
|
if (!string_ptr)
|
|
|
|
error("Unable to locate opcode table. Perhaps you are using the wrong game target?");
|
|
|
|
|
2002-07-07 19:06:48 +00:00
|
|
|
for (;;) {
|
2002-06-29 16:23:33 +00:00
|
|
|
if (string_ptr[i] == ' ')
|
|
|
|
return ptr;
|
|
|
|
|
|
|
|
l = string_ptr[i++];
|
2002-07-07 19:06:48 +00:00
|
|
|
switch (l) {
|
2002-06-29 16:23:33 +00:00
|
|
|
case 'N':
|
|
|
|
case 'S':
|
|
|
|
case 'a':
|
|
|
|
case 'n':
|
|
|
|
case 'p':
|
|
|
|
case 'v':
|
2002-10-21 13:23:25 +00:00
|
|
|
val = in->readUint16BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
*ptr++ = val >> 8;
|
|
|
|
*ptr++ = val & 255;
|
|
|
|
break;
|
2002-07-07 19:06:48 +00:00
|
|
|
|
2002-06-29 16:23:33 +00:00
|
|
|
case 'B':
|
2002-09-16 08:22:30 +00:00
|
|
|
*ptr++ = in->readByte();
|
2002-06-29 16:23:33 +00:00
|
|
|
if (ptr[-1] == 0xFF) {
|
2002-09-16 08:22:30 +00:00
|
|
|
*ptr++ = in->readByte();
|
2002-06-29 16:23:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I':
|
2002-10-21 13:23:25 +00:00
|
|
|
val = in->readUint16BE();
|
2002-07-07 19:06:48 +00:00
|
|
|
switch (val) {
|
|
|
|
case 1:
|
|
|
|
val = 0xFFFF;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
val = 0xFFFD;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
val = 0xFFFB;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
val = 0xFFF9;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
val = 0xFFF7;
|
|
|
|
break;
|
2002-06-29 16:23:33 +00:00
|
|
|
default:
|
|
|
|
val = fileReadItemID(in);;
|
|
|
|
}
|
|
|
|
*ptr++ = val >> 8;
|
|
|
|
*ptr++ = val & 255;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
2002-10-21 13:23:25 +00:00
|
|
|
val = in->readUint16BE();
|
2002-07-07 19:06:48 +00:00
|
|
|
switch (val) {
|
2002-06-29 16:23:33 +00:00
|
|
|
case 0:
|
|
|
|
val = 0xFFFF;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
val = 0xFFFD;
|
|
|
|
break;
|
|
|
|
default:
|
2002-10-21 13:23:25 +00:00
|
|
|
val = (uint16)in->readUint32BE();
|
2002-06-29 16:23:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
*ptr++ = val >> 8;
|
|
|
|
*ptr++ = val & 255;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Bad cmd table entry %c", l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-03 19:42:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Simon
|