Use the setBitFlag() and getBitFlag() functions, instead of manipulating

_bitArray[] directly. This kind of change is, of course, rather error-prone. I
hope I haven't introduced any regressions.

svn-id: r21622
This commit is contained in:
Torbjörn Andersson 2006-04-05 00:37:42 +00:00
parent ab49a04331
commit 7bcd0ba4dc
5 changed files with 44 additions and 55 deletions

View File

@ -890,20 +890,17 @@ int SimonEngine::runScript() {
break;
case 153:{ /* set bit */
uint bit = getVarOrByte();
_bitArray[bit / 16] |= 1 << (bit & 15);
setBitFlag(getVarOrByte(), true);
break;
}
case 154:{ /* clear bit */
uint bit = getVarOrByte();
_bitArray[bit / 16] &= ~(1 << (bit & 15));
setBitFlag(getVarOrByte(), false);
break;
}
case 155:{ /* is bit clear */
uint bit = getVarOrByte();
condition = (_bitArray[bit / 16] & (1 << (bit & 15))) == 0;
condition = !getBitFlag(getVarOrByte());
}
break;
@ -912,7 +909,7 @@ int SimonEngine::runScript() {
if (getGameType() == GType_SIMON1 && _subroutine == 2962 && bit == 63) {
bit = 50;
}
condition = (_bitArray[bit / 16] & (1 << (bit & 15))) != 0;
condition = getBitFlag(bit);
}
break;
@ -984,26 +981,22 @@ int SimonEngine::runScript() {
} break;
case 166:{ /* set bit2 */
uint bit = getVarOrByte();
_bitArray[(bit / 16) + 16] |= 1 << (bit & 15);
setBitFlag(256 + getVarOrByte(), true);
}
break;
case 167:{ /* clear bit2 */
uint bit = getVarOrByte();
_bitArray[(bit / 16) + 16] &= ~(1 << (bit & 15));
setBitFlag(256 + getVarOrByte(), false);
}
break;
case 168:{ /* is bit2 clear */
uint bit = getVarOrByte();
condition = (_bitArray[(bit / 16) + 16] & (1 << (bit & 15))) == 0;
condition = !getBitFlag(256 + getVarOrByte());
}
break;
case 169:{ /* is bit2 set */
uint bit = getVarOrByte();
condition = (_bitArray[(bit / 16) + 16] & (1 << (bit & 15))) != 0;
condition = getBitFlag(256 + getVarOrByte());
}
break;
@ -1174,7 +1167,7 @@ int SimonEngine::runScript() {
// Feeble opcodes
case 191:
if (_bitArray[5] & 0x0008) {
if (getBitFlag(83)) {
_PVCount1 = 0;
_GPVCount1 = 0;
} else {
@ -1188,7 +1181,7 @@ int SimonEngine::runScript() {
uint8 b = getVarOrByte();
uint8 c = getVarOrByte();
uint8 d = getVarOrByte();
if (_bitArray[5] & 0x0008) {
if (getBitFlag(83)) {
_pathValues1[_PVCount1++] = a;
_pathValues1[_PVCount1++] = b;
_pathValues1[_PVCount1++] = c;
@ -1223,26 +1216,22 @@ int SimonEngine::runScript() {
break;
case 196:{ /* set bit3 */
uint bit = getVarOrByte();
_bitArray[(bit / 16) + 32] |= 1 << (bit & 15);
setBitFlag(512 + getVarOrByte(), true);
}
break;
case 197:{ /* clear bit3 */
uint bit = getVarOrByte();
_bitArray[(bit / 16) + 32] &= ~(1 << (bit & 15));
setBitFlag(512 + getVarOrByte(), false);
}
break;
case 198:{ /* is bit3 clear */
uint bit = getVarOrByte();
condition = (_bitArray[(bit / 16) + 32] & (1 << (bit & 15))) == 0;
condition = !getBitFlag(512 + getVarOrByte());
}
break;
case 199:{ /* is bit3 set */
uint bit = getVarOrByte();
condition = (_bitArray[(bit / 16) + 32] & (1 << (bit & 15))) != 0;
condition = getBitFlag(512 + getVarOrByte());
}
break;

View File

@ -45,7 +45,7 @@ void SimonEngine::checkLinkBox() { // Check for boxes spilling over to next row
}
void SimonEngine::hyperLinkOn(uint16 x) {
if ((_bitArray[3] & (1 << 3)) == 0)
if (!getBitFlag(51))
return;
_hyperLink = x;
@ -55,7 +55,7 @@ void SimonEngine::hyperLinkOn(uint16 x) {
void SimonEngine::hyperLinkOff() {
if ((_bitArray[3] & (1 << 3)) == 0)
if (!getBitFlag(51))
return;
_variableArray[52] = _textWindow->x + _textWindow->textColumn - _variableArray[50];
@ -110,11 +110,11 @@ void SimonEngine::oracleTextUp() {
linksUp();
}
scrollOracleUp();
_bitArray[5] |= (1 << 14);
setBitFlag(94, true);
sub = getSubroutineByID(_variableArray[104]);
if(sub)
startSubroutineEx(sub);
_bitArray[5] &= ~(1 << 14);
setBitFlag(94, false);
bltOracleText();
}
if (_currentBoxNumber != 600 || _leftButtonDown)
@ -144,11 +144,11 @@ void SimonEngine::oracleTextDown() {
linksDown();
}
scrollOracleDown();
_bitArray[5] |= (1 << 13);
setBitFlag(93, true);
sub = getSubroutineByID(_variableArray[104]);
if (sub)
startSubroutineEx(sub);
_bitArray[5] &= ~(1 << 13);
setBitFlag(93, false);
bltOracleText();
}
if (_currentBoxNumber != 600 || _leftButtonDown)

View File

@ -1708,19 +1708,19 @@ void SimonEngine::handle_mouse_moved() {
}
if (getGameType() == GType_FF) {
if (_bitArray[6] & 0x8) { // Oracle
if (getBitFlag(99)) { // Oracle
if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
_bitArray[6] |= 0x4;
setBitFlag(98, true);
} else {
if (_bitArray[6] & 0x4) {
if (getBitFlag(98)) {
_variableArray[254] = 63;
}
}
} else if (_bitArray[5] & 0x0100) { // Close Up
} else if (getBitFlag(88)) { // Close Up
if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
_bitArray[5] |= 0x80;
setBitFlag(87, true);
} else {
if (_bitArray[5] & 0x80) {
if (getBitFlag(87)) {
_variableArray[254] = 75;
}
}
@ -1733,7 +1733,7 @@ void SimonEngine::handle_mouse_moved() {
}
if (getGameType() == GType_SIMON2) {
if (_bitArray[4] & 0x8000) {
if (getBitFlag(79)) {
if (!_vgaVar9) {
if (_mouseX >= 630 / 2 || _mouseX < 9)
goto get_out2;
@ -2702,7 +2702,7 @@ void SimonEngine::add_vga_timer(uint num, const byte *code_ptr, uint cur_sprite,
}
void SimonEngine::o_mouseOn() {
if (getGameType() == GType_SIMON2 && _bitArray[4] & 0x8000)
if (getGameType() == GType_SIMON2 && getBitFlag(79))
_mouseCursor = 0;
_mouseHideCount = 0;
}
@ -3482,8 +3482,8 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) {
if (speech_id == 9999) {
if (_subtitles)
return;
if (!(_bitArray[0] & 0x4000) && !(_bitArray[1] & 0x1000)) {
_bitArray[0] |= 0x4000;
if (!getBitFlag(14) && !getBitFlag(28)) {
setBitFlag(14, true);
_variableArray[100] = 15;
loadSprite(4, 1, 130, 0, 0, 0);
o_waitForSync(130);
@ -3503,8 +3503,8 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) {
if (speech_id == 0xFFFF) {
if (_subtitles)
return;
if (!(_bitArray[0] & 0x4000) && !(_bitArray[1] & 0x1000)) {
_bitArray[0] |= 0x4000;
if (!getBitFlag(14) && !getBitFlag(28)) {
setBitFlag(14, true);
_variableArray[100] = 5;
loadSprite(4, 1, 30, 0, 0, 0);
o_waitForSync(130);
@ -3602,7 +3602,7 @@ void SimonEngine::printText(uint vgaSpriteId, uint color, const char *string, in
render_string(vgaSpriteId, color, width, height, convertedString);
int b = 4;
if (!(_bitArray[8] & 0x20))
if (!getBitFlag(133))
b = 3;
x /= 8;
@ -4212,7 +4212,7 @@ void SimonEngine::delay(uint amount) {
break;
case OSystem::EVENT_LBUTTONDOWN:
if (getGameType() == GType_FF)
_bitArray[5] |= 0x0200;
setBitFlag(89, true);
_leftButtonDown++;
#if defined (_WIN32_WCE) || defined(PALMOS_MODE)
_sdlMouseX = event.mouse.x;
@ -4221,11 +4221,11 @@ void SimonEngine::delay(uint amount) {
break;
case OSystem::EVENT_LBUTTONUP:
if (getGameType() == GType_FF)
_bitArray[5] &= ~0x0200;
setBitFlag(89, false);
break;
case OSystem::EVENT_RBUTTONDOWN:
if (getGameType() == GType_FF)
_bitArray[5] &= ~0x1000;
setBitFlag(92, false);
if (getGameType() == GType_SIMON2 || getGameType() == GType_FF)
_rightButtonDown++;
else

View File

@ -193,7 +193,7 @@ void SimonEngine::defocusHitarea() {
HitArea *ha;
if (getGameType() == GType_SIMON2) {
if (_bitArray[4] & 0x8000) {
if (getBitFlag(79)) {
o_sync(202);
_lastHitArea2Ptr = NULL;
return;
@ -295,7 +295,7 @@ void SimonEngine::hitareaChangedHelper() {
FillOrCopyStruct *fcs;
if (getGameType() == GType_SIMON2) {
if (_bitArray[4] & 0x8000)
if (getBitFlag(79))
return;
}
@ -418,7 +418,7 @@ void SimonEngine::resetVerbs() {
if (getGameType() == GType_SIMON2) {
id = 2;
if (!(_bitArray[4] & 0x8000))
if (!getBitFlag(79))
id = (_mouseY >= 136) ? 102 : 101;
} else {
id = (_mouseY >= 136) ? 102 : 101;
@ -620,7 +620,7 @@ void SimonEngine::setup_hitarea_from_pos(uint x, uint y, uint mode) {
const uint16 y_ = y;
if (getGameType() == GType_SIMON2) {
if (_bitArray[4] & 0x8000 || y < 134) {
if (getBitFlag(79) || y < 134) {
x_ += _scrollX * 8;
}
}
@ -692,7 +692,7 @@ bool SimonEngine::hitarea_proc_2(uint a) {
const byte *string_ptr;
if (getGameType() == GType_SIMON2) {
if (_bitArray[4] & 0x8000) {
if (getBitFlag(79)) {
Subroutine *sub;
_variableArray[84] = a;
sub = getSubroutineByID(5003);

View File

@ -1251,7 +1251,7 @@ void SimonEngine::drawImages(VC10_state *state) {
}
/* vc10_helper_4 */
} else {
if (getGameType() == GType_SIMON2 && state->flags & kDFUseFrontBuf && _bitArray[10] & 0x800) {
if (getGameType() == GType_SIMON2 && state->flags & kDFUseFrontBuf && getBitFlag(171)) {
state->surf_addr = state->surf2_addr;
state->surf_pitch = state->surf2_pitch;
}
@ -1704,7 +1704,7 @@ void SimonEngine::vc40() {
uint var = vcReadNextWord();
int16 value = vcReadVar(var) + vcReadNextWord();
if ((getGameType() == GType_SIMON2) && var == 15 && !(_bitArray[5] & 1)) {
if ((getGameType() == GType_SIMON2) && var == 15 && !getBitFlag(80)) {
int16 tmp;
if (_scrollCount != 0) {
@ -1733,7 +1733,7 @@ void SimonEngine::vc41() {
uint var = vcReadNextWord();
int16 value = vcReadVar(var) - vcReadNextWord();
if ((getGameType() == GType_SIMON2) && var == 15 && !(_bitArray[5] & 1)) {
if ((getGameType() == GType_SIMON2) && var == 15 && !getBitFlag(80)) {
int16 tmp;
if (_scrollCount != 0) {