mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
Save polygons
Move findObject changes to HE72 svn-id: r15118
This commit is contained in:
parent
8e1d3aa939
commit
167f5d543f
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user