aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/cruise/actor.cpp28
-rw-r--r--engines/cruise/cruise.cpp4
-rw-r--r--engines/cruise/cruise.h20
-rw-r--r--engines/cruise/cruise_main.cpp14
-rw-r--r--engines/cruise/ctp.cpp12
-rw-r--r--engines/cruise/ctp.h5
-rw-r--r--engines/cruise/gfxModule.cpp26
-rw-r--r--engines/cruise/perso.cpp11
-rw-r--r--engines/cruise/saveload.cpp4
-rw-r--r--engines/cruise/vars.cpp2
-rw-r--r--engines/cruise/vars.h2
-rw-r--r--engines/cruise/volume.cpp54
12 files changed, 90 insertions, 92 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp
index 81e39600f5..9cbc3dd9ae 100644
--- a/engines/cruise/actor.cpp
+++ b/engines/cruise/actor.cpp
@@ -74,8 +74,8 @@ int flag_aff_chemin;
void getPixel(int x, int y) {
- for (uint i = 0; i < polyStructs->size(); ++i) {
- CtStruct &ct = (*polyStructs)[i];
+ for (uint i = 0; i < _vm->_polyStructs->size(); ++i) {
+ CtStruct &ct = (*_vm->_polyStructs)[i];
numPoly = ct.num;
if (walkboxState[numPoly] == 0 && ct.bounds.contains(x, y)) {
@@ -293,7 +293,7 @@ int point_proche(int16 table[][2]) {
int x1, y1, i, x, y, p;
int d1 = 1000;
- polyStructs = &polyStructNorm;
+ _vm->_polyStructs = &_vm->_polyStructNorm;
if (nclick_noeud == 1) {
x = x_mouse;
@@ -301,19 +301,19 @@ int point_proche(int16 table[][2]) {
x1 = table_ptselect[0][0];
y1 = table_ptselect[0][1];
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
getPixel(x, y);
if (!flag_obstacle) {
- polyStructs = &polyStructNorm;
+ _vm->_polyStructs = &_vm->_polyStructNorm;
getPixel(x, y);
if (flag_obstacle) {
polydroite(x1, y1, x, y);
}
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
}
if (!flag_obstacle) { /* dans flag_obstacle --> couleur du point */
x1 = table_ptselect[0][0];
@@ -325,7 +325,7 @@ int point_proche(int16 table[][2]) {
y_mouse = Y;
}
}
- polyStructs = &polyStructNorm;
+ _vm->_polyStructs = &_vm->_polyStructNorm;
p = -1;
for (i = 0; i < ctp_routeCoordCount; i++) {
@@ -453,7 +453,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
table_ptselect[*nclick][0] = x_mouse;
table_ptselect[*nclick][1] = y_mouse;
(*nclick)++;
- polyStructs = &polyStructNorm;
+ _vm->_polyStructs = &_vm->_polyStructNorm;
if (*nclick == 2) { // second point
x1 = table_ptselect[0][0];
@@ -464,7 +464,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
return;
}
flag_aff_chemin = 1;
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
// can we go there directly ?
polydroite(x1, y1, x2, y2);
@@ -472,7 +472,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
if (!flag_obstacle) {
solution0[0][0] = x1;
solution0[0][1] = y1;
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
poly2(x2, y2, ctp_routeCoords[select_noeud[1]][0],
ctp_routeCoords[select_noeud[1]][1]);
@@ -516,7 +516,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
solution0[++i][1] =
ctp_routeCoords[p1][1];
}
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
poly2(x2, y2,
ctp_routeCoords[select_noeud[1]][0],
ctp_routeCoords[select_noeud[1]][1]);
@@ -541,7 +541,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
while (flag_obstacle && i != d) {
x2 = solution0[i][0];
y2 = solution0[i][1];
- polyStructs = &polyStructExp;
+ _vm->_polyStructs = &_vm->_polyStructExp;
polydroite(x1, y1, x2, y2);
i--;
}
@@ -569,7 +569,7 @@ int16 computePathfinding(MovementEntry &moveInfo, int16 x, int16 y, int16 destX,
persoStruct *perso;
int num;
- if (!polyStruct) {
+ if (!_vm->_polyStruct) {
moveInfo.x = -1;
moveInfo.y = -1;
@@ -621,7 +621,7 @@ int16 computePathfinding(MovementEntry &moveInfo, int16 x, int16 y, int16 destX,
}
nclick_noeud = 0;
- polyStructs = &polyStructNorm;
+ _vm->_polyStructs = &_vm->_polyStructNorm;
flag_aff_chemin = 0;
if (x == destX && y == destY) {
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 2f38aa98ba..3af77f3ef3 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -133,8 +133,8 @@ void CruiseEngine::initialize() {
}
void CruiseEngine::deinitialise() {
- polyStructNorm.clear();
- polyStructExp.clear();
+ _vm->_polyStructNorm.clear();
+ _vm->_polyStructExp.clear();
// Clear any backgrounds
for (int i = 0; i < 8; ++i) {
diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h
index 0428240167..94f5c68ca0 100644
--- a/engines/cruise/cruise.h
+++ b/engines/cruise/cruise.h
@@ -40,10 +40,10 @@
/**
* This is the namespace of the Cruise engine.
*
- * Status of this engine: ???
+ * Status of this engine: Game is completable, engine needs objectifying
*
* Supported games:
- * - ???
+ * - Cruise for a Corpse
*/
namespace Cruise {
@@ -112,6 +112,22 @@ public:
void initAllData();
Common::RandomSource _rnd;
+
+ Common::List<byte *> _memList;
+
+ typedef Common::List<Common::Rect> RectList;
+
+ RectList _dirtyRects;
+ RectList _priorFrameRects;
+
+ Common::File _currentVolumeFile;
+
+ Common::Array<CtStruct> _polyStructNorm;
+ Common::Array<CtStruct> _polyStructExp;
+ Common::Array<CtStruct> *_polyStructs;
+ Common::Array<CtStruct> *_polyStruct;
+
+ Common::File _PAL_file;
};
extern CruiseEngine *_vm;
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index 65d8b57366..aa78f84e3d 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -42,13 +42,11 @@ unsigned int timer = 0;
gfxEntryStruct* linkedMsgList = NULL;
-Common::List<byte *> memList;
-
void MemoryList() {
- if (!memList.empty()) {
+ if (!_vm->_memList.empty()) {
printf("Current list of un-freed memory blocks:\n");
Common::List<byte *>::iterator i;
- for (i = memList.begin(); i != memList.end(); ++i) {
+ for (i = _vm->_memList.begin(); i != _vm->_memList.end(); ++i) {
byte *v = *i;
printf("%s - %d\n", (const char *)(v - 68), *((int32 *)(v - 72)));
}
@@ -73,7 +71,7 @@ void *MemoryAlloc(uint32 size, bool clearFlag, int32 lineNum, const char *fname)
// Add the block to the memory list
result = v + 64 + 8;
- memList.push_back(result);
+ _vm->_memList.push_back(result);
} else
result = (byte *)malloc(size);
@@ -91,7 +89,7 @@ void MemoryFree(void *v) {
byte *p = (byte *)v;
assert(*((uint32 *) (p - 4)) == 0x41424344);
- memList.remove(p);
+ _vm->_memList.remove(p);
free(p - 8 - 64);
} else
free(v);
@@ -105,8 +103,8 @@ void drawBlackSolidBoxSmall() {
void loadPackedFileToMem(int fileIdx, uint8 *buffer) {
changeCursor(CURSOR_DISK);
- currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, SEEK_SET);
- currentVolumeFile.read(buffer, volumePtrToFileDescriptor[fileIdx].size);
+ _vm->_currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, SEEK_SET);
+ _vm->_currentVolumeFile.read(buffer, volumePtrToFileDescriptor[fileIdx].size);
}
int getNumObjectsByClass(int scriptIdx, int param) {
diff --git a/engines/cruise/ctp.cpp b/engines/cruise/ctp.cpp
index 59f3cae942..4f6c21e0e4 100644
--- a/engines/cruise/ctp.cpp
+++ b/engines/cruise/ctp.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "cruise/cruise.h"
#include "cruise/cruise_main.h"
#include "common/endian.h"
#include "common/util.h"
@@ -31,11 +32,6 @@ namespace Cruise {
uint8 *ctpVar17;
-Common::Array<CtStruct> polyStructNorm;
-Common::Array<CtStruct> polyStructExp;
-Common::Array<CtStruct> *polyStructs = NULL;
-Common::Array<CtStruct> *polyStruct = NULL;
-
int currentWalkBoxCenterX;
int currentWalkBoxCenterY;
int currentWalkBoxCenterXBis;
@@ -324,16 +320,16 @@ int initCt(const char *ctpName) {
// Load the polyStructNorm list
for (int i = numberOfWalkboxes - 1; i >= 0; i--) {
- makeCtStruct(polyStructNorm, ctp_walkboxTable, i, 0);
+ makeCtStruct(_vm->_polyStructNorm, ctp_walkboxTable, i, 0);
}
// Load the polyStructExp list
for (int i = numberOfWalkboxes - 1; i >= 0; i--) {
- makeCtStruct(polyStructExp, ctp_walkboxTable, i, walkboxZoom[i] * 20);
+ makeCtStruct(_vm->_polyStructExp, ctp_walkboxTable, i, walkboxZoom[i] * 20);
}
- polyStruct = polyStructs = &polyStructNorm;
+ _vm->_polyStruct = _vm->_polyStructs = &_vm->_polyStructNorm;
return (1);
}
diff --git a/engines/cruise/ctp.h b/engines/cruise/ctp.h
index 6cc5ea48ef..3c6c9582cc 100644
--- a/engines/cruise/ctp.h
+++ b/engines/cruise/ctp.h
@@ -64,11 +64,6 @@ public:
extern uint8 *ctpVar17;
-extern Common::Array<CtStruct> polyStructNorm;
-extern Common::Array<CtStruct> polyStructExp;
-extern Common::Array<CtStruct> *polyStructs;
-extern Common::Array<CtStruct> *polyStruct;
-
int initCt(const char * ctpName);
int computeDistance(int varX, int varY, int paramX, int paramY);
diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp
index dbc8160ac6..4a88e6ed5e 100644
--- a/engines/cruise/gfxModule.cpp
+++ b/engines/cruise/gfxModule.cpp
@@ -43,10 +43,6 @@ palEntry lpalette[256];
int palDirtyMin = 256;
int palDirtyMax = -1;
-typedef Common::List<Common::Rect> RectList;
-RectList _dirtyRects;
-RectList _priorFrameRects;
-
bool _dirtyRectScreen = false;
gfxModuleDataStruct gfxModuleData = {
@@ -238,7 +234,7 @@ void gfxModuleData_flipScreen() {
}
void gfxModuleData_addDirtyRect(const Common::Rect &r) {
- _dirtyRects.push_back(Common::Rect( MAX(r.left, (int16)0), MAX(r.top, (int16)0),
+ _vm->_dirtyRects.push_back(Common::Rect( MAX(r.left, (int16)0), MAX(r.top, (int16)0),
MIN(r.right, (int16)320), MIN(r.bottom, (int16)200)));
}
@@ -255,11 +251,11 @@ static bool unionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const
}
static void mergeClipRects() {
- RectList::iterator rOuter, rInner;
+ CruiseEngine::RectList::iterator rOuter, rInner;
- for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
+ for (rOuter = _vm->_dirtyRects.begin(); rOuter != _vm->_dirtyRects.end(); ++rOuter) {
rInner = rOuter;
- while (++rInner != _dirtyRects.end()) {
+ while (++rInner != _vm->_dirtyRects.end()) {
if ((*rOuter).intersects(*rInner)) {
// these two rectangles overlap, so translate it to a bigger rectangle
@@ -267,7 +263,7 @@ static void mergeClipRects() {
unionRectangle(*rOuter, *rOuter, *rInner);
// remove the inner rect from the list
- _dirtyRects.erase(rInner);
+ _vm->_dirtyRects.erase(rInner);
// move back to beginning of list
rInner = rOuter;
@@ -298,32 +294,32 @@ void gfxModuleData_updateScreen() {
}
void flip() {
- RectList::iterator dr;
+ CruiseEngine::RectList::iterator dr;
// Update the palette
gfxModuleData_updatePalette();
// Make a copy of the prior frame's dirty rects, and then backup the current frame's rects
- RectList tempList = _priorFrameRects;
- _priorFrameRects = _dirtyRects;
+ CruiseEngine::RectList tempList = _vm->_priorFrameRects;
+ _vm->_priorFrameRects = _vm->_dirtyRects;
// Merge the prior frame's dirty rects into the current frame's list
for (dr = tempList.begin(); dr != tempList.end(); ++dr) {
Common::Rect &r = *dr;
- _dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
+ _vm->_dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
}
// Merge any overlapping rects to simplify the drawing process
mergeClipRects();
// Copy any modified areas
- for (dr = _dirtyRects.begin(); dr != _dirtyRects.end(); ++dr) {
+ for (dr = _vm->_dirtyRects.begin(); dr != _vm->_dirtyRects.end(); ++dr) {
Common::Rect &r = *dr;
g_system->copyRectToScreen(globalScreen + 320 * r.top + r.left, 320,
r.left, r.top, r.width(), r.height());
}
- _dirtyRects.clear();
+ _vm->_dirtyRects.clear();
// Allow the screen to update
g_system->updateScreen();
diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp
index 27d3c8cb7d..e86daa5bef 100644
--- a/engines/cruise/perso.cpp
+++ b/engines/cruise/perso.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "cruise/cruise.h"
#include "cruise/cruise_main.h"
#include "common/util.h"
@@ -45,14 +46,14 @@ void freeCTP() {
freePerso(i);
}
- if (polyStruct) {
- polyStructNorm.clear();
- polyStructExp.clear();
- polyStruct = NULL;
+ if (_vm->_polyStruct) {
+ _vm->_polyStructNorm.clear();
+ _vm->_polyStructExp.clear();
+ _vm->_polyStruct = NULL;
}
ctpVar17 = NULL;
- polyStruct = NULL;
+ _vm->_polyStruct = NULL;
strcpy((char *)currentCtpName, "");
}
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp
index 6e50ef8cdb..24ea2facfe 100644
--- a/engines/cruise/saveload.cpp
+++ b/engines/cruise/saveload.cpp
@@ -579,10 +579,10 @@ static void syncPerso(Common::Serializer &s, persoStruct &p) {
}
static void syncCT(Common::Serializer &s) {
- int v = (polyStruct) ? 1 : 0;
+ int v = (_vm->_polyStruct) ? 1 : 0;
s.syncAsSint32LE(v);
if (s.isLoading())
- polyStruct = (v != 0) ? &polyStructNorm : NULL;
+ _vm->_polyStruct = (v != 0) ? &_vm->_polyStructNorm : NULL;
if (v == 0)
// There is no further data to load or save
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index bab5d171fd..c61cedc503 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -64,8 +64,6 @@ int16 autoTrack;
int16 currentDiskNumber = 1;
-Common::File currentVolumeFile;
-
int16 volumeNumEntry;
fileEntry *volumePtrToFileDescriptor = NULL;
diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h
index 3cb09602cc..af39993f2f 100644
--- a/engines/cruise/vars.h
+++ b/engines/cruise/vars.h
@@ -167,8 +167,6 @@ extern int16 autoTrack;
extern int16 currentDiskNumber;
-extern Common::File currentVolumeFile;
-
extern int16 volumeNumEntry;
extern fileEntry *volumePtrToFileDescriptor;
diff --git a/engines/cruise/volume.cpp b/engines/cruise/volume.cpp
index 3b856b4440..5535d5a016 100644
--- a/engines/cruise/volume.cpp
+++ b/engines/cruise/volume.cpp
@@ -23,11 +23,11 @@
*
*/
+#include "cruise/cruise.h"
#include "cruise/cruise_main.h"
namespace Cruise {
-Common::File PAL_file;
uint8 *PAL_ptr = NULL;
int16 numLoadedPal;
@@ -40,25 +40,25 @@ void loadPal(volumeDataStruct *entry) {
#if 0
char name[20];
- if (PAL_file.isOpen())
- PAL_file.close();
+ if (_vm->_PAL_file.isOpen())
+ _vm->_PAL_file.close();
removeExtention(entry->ident, name);
strcat(name, ".PAL");
- if (!PAL_file.open(name))
+ if (!_vm->_PAL_file.open(name))
return;
- numLoadedPal = PAL_file.readSint16BE();
- fileData2 = PAL_file.readSint16BE();
+ numLoadedPal = _vm->_PAL_file.readSint16BE();
+ fileData2 = _vm->_PAL_file.readSint16BE();
PAL_ptr = (uint8 *)MemAlloc(numLoadedPal * fileData2);
#endif
}
void closePal() {
- if (PAL_file.isOpen()) {
- PAL_file.close();
+ if (_vm->_PAL_file.isOpen()) {
+ _vm->_PAL_file.close();
MemFree(PAL_ptr);
PAL_ptr = NULL;
@@ -69,15 +69,15 @@ void closePal() {
}
int closeBase() {
- if (currentVolumeFile.isOpen()) {
- currentVolumeFile.close();
+ if (_vm->_currentVolumeFile.isOpen()) {
+ _vm->_currentVolumeFile.close();
MemFree(volumePtrToFileDescriptor);
strcpy(currentBaseName, "");
}
- if (PAL_file.isOpen()) {
+ if (_vm->_PAL_file.isOpen()) {
closePal();
}
@@ -91,7 +91,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
volumeNumEntry = 0;
volumeNumberOfEntry = 0;
- if (currentVolumeFile.isOpen()) {
+ if (_vm->_currentVolumeFile.isOpen()) {
freeDisk();
}
@@ -99,16 +99,16 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
strcpy(buffer, entry->ident);
- currentVolumeFile.open(buffer);
+ _vm->_currentVolumeFile.open(buffer);
- if (!currentVolumeFile.isOpen()) {
+ if (!_vm->_currentVolumeFile.isOpen()) {
return (-14);
}
changeCursor(CURSOR_DISK);
- volumeNumberOfEntry = currentVolumeFile.readSint16BE();
- volumeSizeOfEntry = currentVolumeFile.readSint16BE();
+ volumeNumberOfEntry = _vm->_currentVolumeFile.readSint16BE();
+ volumeSizeOfEntry = _vm->_currentVolumeFile.readSint16BE();
volumeNumEntry = volumeNumberOfEntry;
@@ -125,11 +125,11 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
}
for (i = 0; i < volumeNumEntry; i++) {
- currentVolumeFile.read(&volumePtrToFileDescriptor[i].name, 14);
- volumePtrToFileDescriptor[i].offset = currentVolumeFile.readSint32BE();
- volumePtrToFileDescriptor[i].size = currentVolumeFile.readSint32BE();
- volumePtrToFileDescriptor[i].extSize = currentVolumeFile.readSint32BE();
- volumePtrToFileDescriptor[i].unk3 = currentVolumeFile.readSint32BE();
+ _vm->_currentVolumeFile.read(&volumePtrToFileDescriptor[i].name, 14);
+ volumePtrToFileDescriptor[i].offset = _vm->_currentVolumeFile.readSint32BE();
+ volumePtrToFileDescriptor[i].size = _vm->_currentVolumeFile.readSint32BE();
+ volumePtrToFileDescriptor[i].extSize = _vm->_currentVolumeFile.readSint32BE();
+ volumePtrToFileDescriptor[i].unk3 = _vm->_currentVolumeFile.readSint32BE();
}
strcpy(currentBaseName, entry->ident);
@@ -178,8 +178,8 @@ int32 findFileInDisksSub1(const char *fileName) {
}
void freeDisk() {
- if (currentVolumeFile.isOpen()) {
- currentVolumeFile.close();
+ if (_vm->_currentVolumeFile.isOpen()) {
+ _vm->_currentVolumeFile.close();
MemFree(volumePtrToFileDescriptor);
}
@@ -194,7 +194,7 @@ void freeDisk() {
int16 findFileInList(char *fileName) {
int i;
- if (!currentVolumeFile.isOpen()) {
+ if (!_vm->_currentVolumeFile.isOpen()) {
return (-1);
}
@@ -248,7 +248,7 @@ int16 findFileInDisks(const char *name) {
if (!volumeDataLoaded) {
debug(1, "CNF wasn't loaded, reading now...");
- if (currentVolumeFile.isOpen()) {
+ if (_vm->_currentVolumeFile.isOpen()) {
askDisk(-1);
freeDisk();
}
@@ -257,7 +257,7 @@ int16 findFileInDisks(const char *name) {
readVolCnf();
}
- if (currentVolumeFile.isOpen()) {
+ if (_vm->_currentVolumeFile.isOpen()) {
askDisk(-1);
}
@@ -274,7 +274,7 @@ int16 findFileInDisks(const char *name) {
debug(1, "File found on disk %d", disk);
- if (currentVolumeFile.isOpen()) {
+ if (_vm->_currentVolumeFile.isOpen()) {
askDisk(-1);
}