Skip to content

Commit

Permalink
Implemented support for zoneQuery (Operation Stealth specific).
Browse files Browse the repository at this point in the history
Fixed opcodes (related to zoneQuery):
- 0x08: o1_checkCollision
- 0x9A: o2_wasZoneChecked
NOTE: Savegame support for the zoneQuery data is broken

svn-id: r32790
  • Loading branch information
Kari Salminen committed Jun 25, 2008
1 parent dee147e commit 1339a55
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 7 additions & 0 deletions engines/cine/main_loop.cpp
Expand Up @@ -235,6 +235,13 @@ void CineEngine::mainLoop(int bootScriptIdx) {
do {
stopMusicAfterFadeOut();
di = executePlayerInput();

// Clear the zoneQuery table (Operation Stealth specific)
if (g_cine->getGameType() == Cine::GType_OS) {
for (uint i = 0; i < NUM_MAX_ZONE; i++) {
zoneQuery[i] = 0;
}
}

processSeqList();
executeList1();
Expand Down
20 changes: 17 additions & 3 deletions engines/cine/script_fw.cpp
Expand Up @@ -1764,18 +1764,32 @@ int16 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneI
int16 lx = objectTable[objIdx].x + x;
int16 ly = objectTable[objIdx].y + y;
int16 idx;
int16 result = 0;

for (int16 i = 0; i < numZones; i++) {
idx = getZoneFromPositionRaw(page3Raw, lx + i, ly, 320);

assert(idx >= 0 && idx <= NUM_MAX_ZONE);
assert(idx >= 0 && idx < NUM_MAX_ZONE);

// The zoneQuery table is updated here only in Operation Stealth
if (g_cine->getGameType() == Cine::GType_OS) {
if (zoneData[idx] >= 0 && zoneData[idx] < NUM_MAX_ZONE) {
zoneQuery[zoneData[idx]]++;
}
}

if (zoneData[idx] == zoneIdx) {
return 1;
result = 1;
// Future Wars breaks out early on the first match, but
// Operation Stealth doesn't because it needs to update
// the zoneQuery table for the whole loop's period.
if (g_cine->getGameType() == Cine::GType_FW) {
break;
}
}
}

return 0;
return result;
}

uint16 compareVars(int16 a, int16 b) {
Expand Down
3 changes: 1 addition & 2 deletions engines/cine/script_os.cpp
Expand Up @@ -654,8 +654,7 @@ int FWScript::o2_loadBg() {
*/
int FWScript::o2_wasZoneChecked() {
byte param = getNextByte();
// FIXME: Using a wrong table here, it's not zoneData we want, but something else (zoneQuery)
_compare = (param < 16 && zoneData[param]);
_compare = (param < NUM_MAX_ZONE && zoneQuery[param]) ? 1 : 0;
debugC(5, kCineDebugScript, "Line: %d: o2_wasZoneChecked(%d)", _line, param);
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions engines/cine/various.cpp
Expand Up @@ -112,6 +112,7 @@ int16 objListTab[20];

uint16 exitEngine;
uint16 zoneData[NUM_MAX_ZONE];
uint16 zoneQuery[NUM_MAX_ZONE]; //!< Only exists in Operation Stealth


void stopMusicAfterFadeOut(void) {
Expand Down Expand Up @@ -391,6 +392,7 @@ bool brokenSave(Common::InSaveFile &fHandle) {
}

/*! \todo Implement Operation Stealth loading, this is obviously Future Wars only
* \todo Add support for loading the zoneQuery table (Operation Stealth specific)
*/
bool CineEngine::makeLoad(char *saveName) {
int16 i;
Expand Down Expand Up @@ -588,6 +590,8 @@ bool CineEngine::makeLoad(char *saveName) {
return true;
}

/*! \todo Add support for saving the zoneQuery table (Operation Stealth specific)
*/
void makeSave(char *saveFileName) {
int16 i;
Common::OutSaveFile *fHandle;
Expand Down
1 change: 1 addition & 0 deletions engines/cine/various.h
Expand Up @@ -130,6 +130,7 @@ struct SelectedObjStruct {

#define NUM_MAX_ZONE 16
extern uint16 zoneData[NUM_MAX_ZONE];
extern uint16 zoneQuery[NUM_MAX_ZONE];

void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 param5);

Expand Down

0 comments on commit 1339a55

Please sign in to comment.