aboutsummaryrefslogtreecommitdiff
path: root/engines/simon
diff options
context:
space:
mode:
authorTravis Howell2006-04-21 06:37:28 +0000
committerTravis Howell2006-04-21 06:37:28 +0000
commit061063189ffc7ed0055cd88f3086dc0e236e2e68 (patch)
tree36b1f09a09bfb8d1e308e5d75a90f798d0e22107 /engines/simon
parent6b7a37d71cd368cafd0821450639ec0cc0544f83 (diff)
downloadscummvm-rg350-061063189ffc7ed0055cd88f3086dc0e236e2e68.tar.gz
scummvm-rg350-061063189ffc7ed0055cd88f3086dc0e236e2e68.tar.bz2
scummvm-rg350-061063189ffc7ed0055cd88f3086dc0e236e2e68.zip
Split bitArrays into three separate arrays, like original. Also fixing load/save issue with bitArrayThree been off by one
svn-id: r22067
Diffstat (limited to 'engines/simon')
-rw-r--r--engines/simon/items.cpp24
-rw-r--r--engines/simon/saveload.cpp24
-rw-r--r--engines/simon/simon.cpp2
-rw-r--r--engines/simon/simon.h4
4 files changed, 37 insertions, 17 deletions
diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp
index d973bb86b6..03a7f90527 100644
--- a/engines/simon/items.cpp
+++ b/engines/simon/items.cpp
@@ -1365,22 +1365,26 @@ void SimonEngine::o_isAdjNoun() {
void SimonEngine::o_b2Set() {
// 166: set bit2
- setBitFlag(256 + getVarOrByte(), true);
+ uint bit = getVarOrByte();
+ _bitArrayTwo[bit / 16] |= (1 << (bit & 15));
}
void SimonEngine::o_b2Clear() {
// 167: clear bit2
- setBitFlag(256 + getVarOrByte(), false);
+ uint bit = getVarOrByte();
+ _bitArrayTwo[bit / 16] &= ~(1 << (bit & 15));
}
void SimonEngine::o_b2Zero() {
// 168: is bit2 clear
- setScriptCondition(!getBitFlag(256 + getVarOrByte()));
+ uint bit = getVarOrByte();
+ setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) == 0);
}
void SimonEngine::o_b2NotZero() {
// 169: is bit2 set
- setScriptCondition(getBitFlag(256 + getVarOrByte()));
+ uint bit = getVarOrByte();
+ setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) != 0);
}
void SimonEngine::o_lockZones() {
@@ -2090,22 +2094,26 @@ void SimonEngine::o3_setColour() {
void SimonEngine::o3_b3Set() {
// 196: set bit3
- setBitFlag(512 + getVarOrByte(), true);
+ uint bit = getVarOrByte();
+ _bitArrayThree[bit / 16] |= (1 << (bit & 15));
}
void SimonEngine::o3_b3Clear() {
// 197: clear bit3
- setBitFlag(512 + getVarOrByte(), false);
+ uint bit = getVarOrByte();
+ _bitArrayThree[bit / 16] &= ~(1 << (bit & 15));
}
void SimonEngine::o3_b3Zero() {
// 198: is bit3 clear
- setScriptCondition(!getBitFlag(512 + getVarOrByte()));
+ uint bit = getVarOrByte();
+ setScriptCondition((_bitArrayThree[bit / 16] & (1 << (bit & 15))) == 0);
}
void SimonEngine::o3_b3NotZero() {
// 199: is bit3 set
- setScriptCondition(getBitFlag(512 + getVarOrByte()));
+ uint bit = getVarOrByte();
+ setScriptCondition((_bitArrayThree[bit / 16] & (1 << (bit & 15))) != 0);
}
// -----------------------------------------------------------------------
diff --git a/engines/simon/saveload.cpp b/engines/simon/saveload.cpp
index ee05b6df63..86097ebe2f 100644
--- a/engines/simon/saveload.cpp
+++ b/engines/simon/saveload.cpp
@@ -558,14 +558,18 @@ bool SimonEngine::saveGame(uint slot, char *caption) {
f->writeUint16BE(itemPtrToID(_itemStore[i]));
}
- // Write the bits in array 1 & 2
- for (i = 0; i != 32; i++)
+ // Write the bits in array 1
+ for (i = 0; i != 16; i++)
f->writeUint16BE(_bitArray[i]);
+ // Write the bits in array 2
+ for (i = 0; i != 16; i++)
+ f->writeUint16BE(_bitArrayTwo[i]);
+
// Write the bits in array 3
if (getGameType() == GType_FF) {
- for (i = 33; i != 48; i++)
- f->writeUint16BE(_bitArray[i]);
+ for (i = 0; i != 16; i++)
+ f->writeUint16BE(_bitArrayThree[i]);
}
f->flush();
@@ -688,14 +692,18 @@ bool SimonEngine::loadGame(uint slot) {
_itemStore[i] = derefItem(f->readUint16BE());
}
- // Read the bits in array 1 & 2
- for (i = 0; i != 32; i++)
+ // Read the bits in array 1
+ for (i = 0; i != 16; i++)
_bitArray[i] = f->readUint16BE();
+ // Read the bits in array 2
+ for (i = 0; i != 16; i++)
+ _bitArrayTwo[i] = f->readUint16BE();
+
// Read the bits in array 3
if (getGameType() == GType_FF) {
- for (i = 33; i != 48; i++)
- _bitArray[i] = f->readUint16BE();
+ for (i = 0; i != 16; i++)
+ _bitArrayThree[i] = f->readUint16BE();
}
if (f->ioFailed()) {
diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp
index aefb9080ac..a9f3bed8a3 100644
--- a/engines/simon/simon.cpp
+++ b/engines/simon/simon.cpp
@@ -347,6 +347,8 @@ SimonEngine::SimonEngine(OSystem *syst)
memset(_speechIdArray4, 0, sizeof(_speechIdArray4));
memset(_bitArray, 0, sizeof(_bitArray));
+ memset(_bitArrayTwo, 0, sizeof(_bitArrayTwo));
+ memset(_bitArrayThree, 0, sizeof(_bitArrayThree));
memset(_variableArray, 0, sizeof(_variableArray));
memset(_variableArray2, 0, sizeof(_variableArray2));
diff --git a/engines/simon/simon.h b/engines/simon/simon.h
index ffde748c37..2fd6cf720b 100644
--- a/engines/simon/simon.h
+++ b/engines/simon/simon.h
@@ -384,7 +384,9 @@ protected:
uint16 _stringIdArray3[40];
uint16 _speechIdArray4[40];
- uint16 _bitArray[48];
+ uint16 _bitArray[16];
+ uint16 _bitArrayTwo[16];
+ uint16 _bitArrayThree[16];
int16 _variableArray[256];
int16 _variableArray2[256];
int16 *_variableArrayPtr;