Split bitArrays into three separate arrays, like original. Also fixing load/save issue with bitArrayThree been off by one

svn-id: r22067
This commit is contained in:
Travis Howell 2006-04-21 06:37:28 +00:00
parent 6b7a37d71c
commit 061063189f
4 changed files with 37 additions and 17 deletions

View File

@ -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);
}
// -----------------------------------------------------------------------

View File

@ -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()) {

View File

@ -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));

View File

@ -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;