aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2004-09-14 15:06:02 +0000
committerTravis Howell2004-09-14 15:06:02 +0000
commit167f5d543f57e7856c003d488c7f56650c54e24e (patch)
tree78f99ad0c404baeb0c956bcd1120f3a63cd9c22b /scumm
parent8e1d3aa939d76cd91cbeb5544674da627ffb6428 (diff)
downloadscummvm-rg350-167f5d543f57e7856c003d488c7f56650c54e24e.tar.gz
scummvm-rg350-167f5d543f57e7856c003d488c7f56650c54e24e.tar.bz2
scummvm-rg350-167f5d543f57e7856c003d488c7f56650c54e24e.zip
Save polygons
Move findObject changes to HE72 svn-id: r15118
Diffstat (limited to 'scumm')
-rw-r--r--scumm/intern.h5
-rw-r--r--scumm/saveload.cpp22
-rw-r--r--scumm/saveload.h2
-rw-r--r--scumm/script_v72he.cpp47
-rw-r--r--scumm/script_v7he.cpp41
-rw-r--r--scumm/script_v80he.cpp4
-rw-r--r--scumm/script_v90he.cpp4
-rw-r--r--scumm/scumm.cpp1
-rw-r--r--scumm/scumm.h1
-rw-r--r--scumm/vars.cpp1
10 files changed, 78 insertions, 50 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index f4fdd8f915..42cc694e71 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -631,7 +631,6 @@ protected:
void o7_pickupObject();
void o7_getActorRoom();
void o7_resourceRoutines();
- void o7_findObject();
void o7_quitPauseRestart();
void o7_kernelSetFunctions();
void o7_unknownED();
@@ -709,6 +708,7 @@ protected:
void drawWizImage(int restype, int resnum, int state, int x1, int y1, int flags);
void flushWizBuffer();
+ int findObject(int x, int y, int *args);
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
void copyScriptString(byte *dst);
@@ -724,7 +724,7 @@ protected:
void o72_wordArrayIndexedWrite();
void o72_compareStackList();
void o72_unknown50();
- void o72_findObject();
+ void o72_findObjectWithClassOf();
void o72_wordArrayInc();
void o72_objectX();
void o72_objectY();
@@ -740,6 +740,7 @@ protected:
void o72_getNumFreeArrays();
void o72_actorOps();
void o72_verbOps();
+ void o72_findObject();
void o72_arrayOps();
void o72_dimArray();
void o72_dim2dimArray();
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 131fd5b299..7e120277b7 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -364,6 +364,27 @@ bool ScummEngine::getSavegameName(int slot, char *desc) {
}
void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
+ const SaveLoadEntry polygonEntries[] = {
+ MKLINE(WizPolygon, vert[0].x, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[0].y, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[1].x, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[1].y, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[2].x, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[2].y, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[3].x, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[3].y, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[4].x, sleInt16, VER(40)),
+ MKLINE(WizPolygon, vert[4].y, sleInt16, VER(40)),
+ MKLINE(WizPolygon, bound.left, sleInt16, VER(40)),
+ MKLINE(WizPolygon, bound.top, sleInt16, VER(40)),
+ MKLINE(WizPolygon, bound.right, sleInt16, VER(40)),
+ MKLINE(WizPolygon, bound.bottom, sleInt16, VER(40)),
+ MKLINE(WizPolygon, id, sleInt16, VER(40)),
+ MKLINE(WizPolygon, numVerts, sleInt16, VER(40)),
+ MKLINE(WizPolygon, flag, sleByte, VER(40)),
+ MKEND()
+ };
+
const SaveLoadEntry objectEntries[] = {
MKLINE(ObjectData, OBIMoffset, sleUint32, VER(8)),
MKLINE(ObjectData, OBCDoffset, sleUint32, VER(8)),
@@ -696,6 +717,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
else
s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
+ s->saveLoadArrayOf(_WizPolygons, 200, sizeof(_WizPolygons[0]), polygonEntries);
s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
if (s->isLoading() && savegameVersion < VER(13)) {
// Since roughly v13 of the save games, the objs storage has changed a bit
diff --git a/scumm/saveload.h b/scumm/saveload.h
index 2ed1a87f1f..93f46307eb 100644
--- a/scumm/saveload.h
+++ b/scumm/saveload.h
@@ -32,7 +32,7 @@ namespace Scumm {
// Can be useful for other ports too :)
#define VER(x) x
-#define CURRENT_VER 39
+#define CURRENT_VER 40
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp
index 9cb40b2d18..a2ebe964ac 100644
--- a/scumm/script_v72he.cpp
+++ b/scumm/script_v72he.cpp
@@ -147,7 +147,7 @@ void ScummEngine_v72he::setupOpcodes() {
/* 50 */
OPCODE(o72_unknown50),
OPCODE(o6_invalid),
- OPCODE(o72_findObject),
+ OPCODE(o72_findObjectWithClassOf),
OPCODE(o72_wordArrayInc),
/* 54 */
OPCODE(o72_objectX),
@@ -245,7 +245,7 @@ void ScummEngine_v72he::setupOpcodes() {
OPCODE(o72_verbOps),
OPCODE(o6_getActorFromXY),
/* A0 */
- OPCODE(o6_findObject),
+ OPCODE(o72_findObject),
OPCODE(o6_pseudoRoom),
OPCODE(o6_getActorElevation),
OPCODE(o6_getVerbEntrypoint),
@@ -565,6 +565,38 @@ void ScummEngine_v72he::decodeScriptString(byte *dst, bool scriptString) {
*dst = 0;
}
+int ScummEngine_v72he::findObject(int x, int y, int *args) {
+ int i, b;
+ byte a;
+ const int mask = 0xF;
+
+ for (i = 1; i < _numLocalObjects; i++) {
+ if ((_objs[i].obj_nr < 1) || getClass(_objs[i].obj_nr, kObjectClassUntouchable))
+ continue;
+
+ if (polygonDefined(_objs[i].obj_nr))
+ if (polygonHit(_objs[i].obj_nr, x, y) != 0)
+ return _objs[i].obj_nr;
+
+ //if (VAR(VAR_POLYGONS_ONLY))
+ // continue;
+
+ b = i;
+ do {
+ a = _objs[b].parentstate;
+ b = _objs[b].parent;
+ if (b == 0) {
+ if (_objs[i].x_pos <= x && _objs[i].width + _objs[i].x_pos > x &&
+ _objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y)
+ return _objs[i].obj_nr;
+ break;
+ }
+ } while ((_objs[b].state & mask) == a);
+ }
+
+ return 0;
+}
+
const byte *ScummEngine_v72he::findWrappedBlock(uint32 tag, const byte *ptr, int state, bool errorFlag) {
if (READ_UINT32(ptr) == MKID('MULT')) {
error("findWrappedBlock: multi blocks aren't implemented");
@@ -644,13 +676,13 @@ void ScummEngine_v72he::o72_unknown50() {
VAR(VAR_OVERRIDE) = 0;
}
-void ScummEngine_v72he::o72_findObject() {
+void ScummEngine_v72he::o72_findObjectWithClassOf() {
int args[16];
getStackList(args, ARRAYSIZE(args));
int y = pop();
int x = pop();
- int r = findObject(x, y);
+ int r = findObject(x, y, args);
push(r);
}
@@ -1145,6 +1177,13 @@ void ScummEngine_v72he::o72_verbOps() {
}
}
+void ScummEngine_v72he::o72_findObject() {
+ int y = pop();
+ int x = pop();
+ int r = findObject(x, y, 0);
+ push(r);
+}
+
void ScummEngine_v72he::o72_arrayOps() {
byte subOp = fetchScriptByte();
int array = fetchScriptWord();
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index 5cbc6fc342..e72fadd1a2 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -246,7 +246,7 @@ void ScummEngine_v7he::setupOpcodes() {
OPCODE(o6_verbOps),
OPCODE(o6_getActorFromXY),
/* A0 */
- OPCODE(o7_findObject),
+ OPCODE(o6_findObject),
OPCODE(o6_pseudoRoom),
OPCODE(o6_getActorElevation),
OPCODE(o6_getVerbEntrypoint),
@@ -699,43 +699,6 @@ void ScummEngine_v7he::o7_resourceRoutines() {
}
}
-void ScummEngine_v7he::o7_findObject() {
- int i, b;
- byte a;
- const int mask = 0xF;
-
- int y = pop();
- int x = pop();
-
-
- for (i = 1; i < _numLocalObjects; i++) {
- if ((_objs[i].obj_nr < 1) || getClass(_objs[i].obj_nr, kObjectClassUntouchable))
- continue;
-
- if (polygonDefined(_objs[i].obj_nr)) {
- if (polygonHit(_objs[i].obj_nr, x, y) != 0) {
- push(_objs[i].obj_nr);
- return;
- }
- }
-
- b = i;
- do {
- a = _objs[b].parentstate;
- b = _objs[b].parent;
- if (b == 0) {
- if (_objs[i].x_pos <= x && _objs[i].width + _objs[i].x_pos > x &&
- _objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y) {
- push(_objs[i].obj_nr);
- return;
- }
- break;
- }
- } while ((_objs[b].state & mask) == a);
- }
- push(0);;
-}
-
void ScummEngine_v7he::o7_quitPauseRestart() {
byte subOp = fetchScriptByte();
int par1;
@@ -1098,8 +1061,8 @@ void ScummEngine::polygonStore(int id, bool flag, int vert1x, int vert1y, int ve
_WizPolygons[i].vert[3].y = vert4y;
_WizPolygons[i].vert[4].x = vert1x;
_WizPolygons[i].vert[4].y = vert1y;
- _WizPolygons[i].numVerts = 5;
_WizPolygons[i].id = id;
+ _WizPolygons[i].numVerts = 5;
_WizPolygons[i].flag = flag;
_WizPolygons[i].bound.left = 10000;
diff --git a/scumm/script_v80he.cpp b/scumm/script_v80he.cpp
index e4029b847e..28723ef884 100644
--- a/scumm/script_v80he.cpp
+++ b/scumm/script_v80he.cpp
@@ -147,7 +147,7 @@ void ScummEngine_v80he::setupOpcodes() {
/* 50 */
OPCODE(o72_unknown50),
OPCODE(o6_invalid),
- OPCODE(o72_findObject),
+ OPCODE(o72_findObjectWithClassOf),
OPCODE(o72_wordArrayInc),
/* 54 */
OPCODE(o72_objectX),
@@ -245,7 +245,7 @@ void ScummEngine_v80he::setupOpcodes() {
OPCODE(o72_verbOps),
OPCODE(o6_getActorFromXY),
/* A0 */
- OPCODE(o7_findObject),
+ OPCODE(o72_findObject),
OPCODE(o6_pseudoRoom),
OPCODE(o6_getActorElevation),
OPCODE(o6_getVerbEntrypoint),
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 0c4cc8d241..fbb82f37c6 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -147,7 +147,7 @@ void ScummEngine_v90he::setupOpcodes() {
/* 50 */
OPCODE(o72_unknown50),
OPCODE(o6_invalid),
- OPCODE(o72_findObject),
+ OPCODE(o72_findObjectWithClassOf),
OPCODE(o72_wordArrayInc),
/* 54 */
OPCODE(o72_objectX),
@@ -245,7 +245,7 @@ void ScummEngine_v90he::setupOpcodes() {
OPCODE(o90_unknown9E),
OPCODE(o6_getActorFromXY),
/* A0 */
- OPCODE(o7_findObject),
+ OPCODE(o72_findObject),
OPCODE(o6_pseudoRoom),
OPCODE(o6_getActorElevation),
OPCODE(o6_getVerbEntrypoint),
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 79502e4fa1..8eb9b13839 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -845,6 +845,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
VAR_NUM_CHARSETS = 0xFF;
VAR_NUM_GLOBAL_OBJS = 0xFF;
VAR_NUM_SPRITES = 0xFF;
+ VAR_POLYGONS_ONLY = 0xFF;
VAR_WINDOWS_VERSION = 0xFF;
// Use g_scumm from error() ONLY
diff --git a/scumm/scumm.h b/scumm/scumm.h
index cf9684a3c3..bfbdf8f2a0 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -1326,6 +1326,7 @@ public:
byte VAR_NUM_CHARSETS;
byte VAR_NUM_GLOBAL_OBJS;
byte VAR_NUM_SPRITES;
+ byte VAR_POLYGONS_ONLY;
byte VAR_WINDOWS_VERSION;
};
diff --git a/scumm/vars.cpp b/scumm/vars.cpp
index 4e3c8add63..068232fffd 100644
--- a/scumm/vars.cpp
+++ b/scumm/vars.cpp
@@ -255,6 +255,7 @@ void ScummEngine_v72he::setupScummVars() {
VAR_NUM_IMAGES = 72;
VAR_NUM_CHARSETS = 73;
VAR_NUM_GLOBAL_OBJS = 74;
+ VAR_POLYGONS_ONLY = 76;
if (_heversion >= 80)
VAR_WINDOWS_VERSION = 79;