Skip to content

Commit

Permalink
Implemented resetGfxEntityEntry and made it used where appropriate (T…
Browse files Browse the repository at this point in the history
…he function wasn't very easy to reverse engineer so it may have flaws still, but let's hope it doesn't ;-)).

svn-id: r32848
  • Loading branch information
Kari Salminen committed Jun 30, 2008
1 parent 2779b85 commit ecbf8d5
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 77 deletions.
17 changes: 12 additions & 5 deletions engines/cine/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint1
objectTable[objIdx].mask = param3;
objectTable[objIdx].frame = param4;

if (removeOverlay(objIdx, 0)) {
addOverlay(objIdx, 0);
if (g_cine->getGameType() == Cine::GType_OS) {
resetGfxEntityEntry(objIdx);
} else { // Future Wars
if (removeOverlay(objIdx, 0)) {
addOverlay(objIdx, 0);
}
}
}

Expand Down Expand Up @@ -208,9 +212,12 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) {
case 3:
objectTable[objIdx].mask = newValue;

// TODO: Check this part against disassembly
if (removeOverlay(objIdx, 0)) {
addOverlay(objIdx, 0);
if (g_cine->getGameType() == Cine::GType_OS) { // Operation Stealth specific
resetGfxEntityEntry(objIdx);
} else { // Future Wars specific
if (removeOverlay(objIdx, 0)) {
addOverlay(objIdx, 0);
}
}
break;
case 4:
Expand Down
118 changes: 46 additions & 72 deletions engines/cine/various.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,78 +1682,6 @@ uint16 computeMove2(SeqListElement &element) {
return returnVar;
}

// sort all the gfx stuff...

void resetGfxEntityEntry(uint16 objIdx) {
#if 0
overlayHeadElement* tempHead = &overlayHead;
byte* var_16 = NULL;
uint16 var_10 = 0;
uint16 var_12 = 0;
overlayHeadElement* currentHead = tempHead->next;
byte* var_1A = NULL;
overlayHeadElement* var1E = &overlayHead;

while (currentHead) {
tempHead2 = currentHead->next;

if (currentHead->objIdx == objIdx && currentHead->type!=2 && currentHead->type!=3 && currentHead->type!=0x14) {
tempHead->next = tempHead2;

if (tempHead2) {
tempHead2->previous = currentHead->previous;
} else {
seqVar0 = currentHead->previous;
}

var_22 = var_16;

if (!var_22) {
// todo: goto?
}

var_22->previous = currentHead;
} else {
}

if (currentHead->type == 0x14) {
} else {
}

if (currentHead->type == 0x2 || currentHead->type == 0x3) {
si = 10000;
} else {
si = objectTable[currentHead->objIdx];
}

if (objectTable[objIdx]>si) {
var1E = currentHead;
}

tempHead = tempHead->next;

}

if (var_1A) {
currentHead = var_16;
var_22 = var_1E->next;
var_1E->next = currentHead;
var_1A->next = var_22;

if (var_1E != &gfxEntityHead) {
currentHead->previous = var_1E;
}

if (!var_22) {
seqVar0 = var_1A;
} else {
var_22->previous = var_1A;
}

}
#endif
}

uint16 addAni(uint16 param1, uint16 objIdx, const byte *ptr, SeqListElement &element, uint16 param3, int16 *param4) {
const byte *currentPtr = ptr;
const byte *ptrData;
Expand Down Expand Up @@ -1795,6 +1723,52 @@ uint16 addAni(uint16 param1, uint16 objIdx, const byte *ptr, SeqListElement &ele
return 1;
}

/*!
* Permutates the overlay list into a different order according to some logic.
* \todo Check this function for correctness (Wasn't very easy to reverse engineer so there may be errors)
*/
void resetGfxEntityEntry(uint16 objIdx) {
Common::List<overlay>::iterator it, bObjsCutPoint;
Common::List<overlay> aReverseObjs, bObjs;
bool foundCutPoint = false;

// Go through the overlay list and partition the whole list into two categories (Type A and type B objects)
for (it = overlayList.begin(); it != overlayList.end(); ++it) {
if (it->objIdx == objIdx && it->type != 2 && it->type != 3) { // Type A object
aReverseObjs.push_front(*it);
} else { // Type B object
bObjs.push_back(*it);
uint16 objectMask;
if (it->type == 2 || it->type == 3) {
objectMask = 10000;
} else {
objectMask = objectTable[it->objIdx].mask;
}

if (objectTable[objIdx].mask > objectMask) { // Check for B objects' cut point
bObjsCutPoint = bObjs.reverse_begin();
foundCutPoint = true;
}
}
}

// Recreate the overlay list in a different order.
overlayList.clear();
if (foundCutPoint) {
// If a cut point was found the order is:
// B objects before the cut point, the cut point, A objects in reverse order, B objects after cut point.
++bObjsCutPoint; // Include the cut point in the first list insertion
overlayList.insert(overlayList.end(), bObjs.begin(), bObjsCutPoint);
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
overlayList.insert(overlayList.end(), bObjsCutPoint, bObjs.end());
} else {
// If no cut point was found the order is:
// A objects in reverse order, B objects.
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
overlayList.insert(overlayList.end(), bObjs.begin(), bObjs.end());
}
}

void processSeqListElement(SeqListElement &element) {
int16 x = objectTable[element.objIdx].x;
int16 y = objectTable[element.objIdx].y;
Expand Down
2 changes: 2 additions & 0 deletions engines/cine/various.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, i
void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4);
void processSeqList(void);

void resetGfxEntityEntry(uint16 objIdx);

bool makeTextEntryMenu(const char *caption, char *string, int strLen, int y);

} // End of namespace Cine
Expand Down

0 comments on commit ecbf8d5

Please sign in to comment.