[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.246,2.247 script_v72he.cpp,2.89,2.90 script_v7he.cpp,2.77,2.78 script_v80he.cpp,2.17,2.18 script_v90he.cpp,2.29,2.30 scumm.cpp,1.195,1.196 scumm.h,1.477,1.478
Eugene Sandulenko
sev at users.sourceforge.net
Mon Sep 13 16:25:04 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19273
Modified Files:
intern.h script_v72he.cpp script_v7he.cpp script_v80he.cpp
script_v90he.cpp scumm.cpp scumm.h
Log Message:
Implemented formerly known unknownFB and unknownFC.
ScummEngine_v7he::polygonContains() is still buggy and prevents whole
thing from working.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.246
retrieving revision 2.247
diff -u -d -r2.246 -r2.247
--- intern.h 13 Sep 2004 18:01:25 -0000 2.246
+++ intern.h 13 Sep 2004 23:24:36 -0000 2.247
@@ -620,6 +620,12 @@
int getCharsetOffsets(int chr);
void arrrays_unk2(int dst, int src, int len2, int len);
+ void polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y,
+ int vert3x, int vert3y, int vert4x, int vert4y);
+ void polygonErase(int fromId, int toId);
+ bool polygonContains(WizPolygon &pol, int x, int y);
+
+
/* HE version 70 script opcodes */
void o7_cursorCommand();
void o7_startSound();
@@ -637,8 +643,8 @@
void o7_unknownF6();
void o7_setFilePath();
void o7_unknownFA();
- void o7_unknownFB();
- void o7_unknownFC();
+ void o7_polygonOps();
+ void o7_polygonHit();
};
class ScummEngine_v72he : public ScummEngine_v7he {
@@ -786,7 +792,6 @@
void loadImgSpot(int resId, int state, Common::Point &spot);
void loadWizCursor(int resId, int resType, bool state);
-
/* HE version 80 script opcodes */
void o80_unknown45();
Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.89
retrieving revision 2.90
diff -u -d -r2.89 -r2.90
--- script_v72he.cpp 13 Sep 2004 13:52:08 -0000 2.89
+++ script_v72he.cpp 13 Sep 2004 23:24:36 -0000 2.90
@@ -358,9 +358,9 @@
OPCODE(o72_unknownF8),
OPCODE(o72_setFilePath),
OPCODE(o72_unknownFA),
- OPCODE(o7_unknownFB),
+ OPCODE(o7_polygonOps),
/* FC */
- OPCODE(o7_unknownFC),
+ OPCODE(o7_polygonHit),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.77
retrieving revision 2.78
diff -u -d -r2.77 -r2.78
--- script_v7he.cpp 13 Sep 2004 04:45:21 -0000 2.77
+++ script_v7he.cpp 13 Sep 2004 23:24:36 -0000 2.78
@@ -359,9 +359,9 @@
OPCODE(o6_invalid),
OPCODE(o7_setFilePath),
OPCODE(o7_unknownFA),
- OPCODE(o7_unknownFB),
+ OPCODE(o7_polygonOps),
/* FC */
- OPCODE(o7_unknownFC),
+ OPCODE(o7_polygonHit),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
@@ -1001,54 +1001,126 @@
_scriptPointer += len + 1;
}
-void ScummEngine_v7he::o7_unknownFB() {
- int a, b, c, d, e, f, g, h, i;
- byte subOp = fetchScriptByte();
+void ScummEngine_v7he::o7_polygonOps() {
+ byte b;
+ b = fetchScriptByte();
+ int vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y;
+ int id;
+ int fromId, toId;
- switch (subOp) {
+ switch (b) {
case 246:
- a = pop();
- b = pop();
- c = pop();
- d = pop();
- e = pop();
- f = pop();
- g = pop();
- h = pop();
- i = pop();
- debug(1,"o7_unknownFB case 246 stub (%d, %d, %d, %d, %d, %d, %d, %d, %d)", a, b, c, d, e, f, g, h, i);
+ case 248:
+ vert4y = pop();
+ vert4x = pop();
+ vert3y = pop();
+ vert3x = pop();
+ vert2y = pop();
+ vert2x = pop();
+ vert1y = pop();
+ vert1x = pop();
+ id = pop();
+
+ polygonStore(id, (b == 248), vert1x, vert1y, vert2x, vert2y, vert3x, vert3y,
+ vert4x, vert4y);
break;
case 247:
- a = pop();
- b = pop();
- debug(1,"o7_unknownFB case 247 stub (%d, %d)", a, b);
- break;
- case 248:
- a = pop();
- b = pop();
- c = pop();
- d = pop();
- e = pop();
- f = pop();
- g = pop();
- h = pop();
- i = pop();
- debug(1,"o7_unknownFB case 248 stub (%d, %d, %d, %d, %d, %d, %d, %d, %d)", a, b, c, d, e, f, g, h, i);
+ toId = pop();
+ fromId = pop();
+
+ polygonErase(fromId, toId);
break;
- default:
- error("o7_unknownFB: default case %d", subOp);
}
}
-void ScummEngine_v7he::o7_unknownFC() {
+void ScummEngine_v7he::polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x,
+ int vert2y, int vert3x, int vert3y, int vert4x, int vert4y) {
+ int i;
+
+ debug(1, "polygonStore(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d", id, flag, vert1x,
+ vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
+
+ for (i = 0; i < _WizNumPolygons; i++)
+ if (_WizPolygons[i].id == 0)
+ break;
+
+ if (i == _WizNumPolygons) {
+ error("ScummEngine_v7he::polygonStore: out of polygon slot, max = %d",
+ _WizNumPolygons);
+ }
+
+ _WizPolygons[i].vert[0].x = vert1x;
+ _WizPolygons[i].vert[0].y = vert1y;
+ _WizPolygons[i].vert[1].x = vert2x;
+ _WizPolygons[i].vert[1].y = vert2y;
+ _WizPolygons[i].vert[2].x = vert3x;
+ _WizPolygons[i].vert[2].y = vert3y;
+ _WizPolygons[i].vert[3].x = vert4x;
+ _WizPolygons[i].vert[3].y = vert4y;
+ _WizPolygons[i].vert[4].x = vert1x;
+ _WizPolygons[i].vert[4].y = vert1y;
+ _WizPolygons[i].id = id;
+ _WizPolygons[i].flag = flag;
+
+ _WizPolygons[i].bound.left = 10000;
+ _WizPolygons[i].bound.top = 10000;
+ _WizPolygons[i].bound.right = -10000;
+ _WizPolygons[i].bound.bottom = -10000;
+
+ for (int j = 0; j < 4; j++) {
+ _WizPolygons[i].bound.left = MIN(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].x);
+ _WizPolygons[i].bound.top = MIN(_WizPolygons[i].bound.top, _WizPolygons[i].vert[j].y);
+ _WizPolygons[i].bound.right = MAX(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].x);
+ _WizPolygons[i].bound.bottom = MAX(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].y);
+ }
+}
+
+void ScummEngine_v7he::polygonErase(int fromId, int toId) {
+ for (int i = 0; i < _WizNumPolygons; i++) {
+ if (_WizPolygons[i].id >= fromId && _WizPolygons[i].id <= toId)
+ memset(&_WizPolygons[i], 0, sizeof(WizPolygon));
+ }
+}
+
+void ScummEngine_v7he::o7_polygonHit() {
// Checks virtual mouse x/y co-ordinates when in verb/inventory area
// Maybe checks for polygons ?
int y = pop();
int x = pop();
- int r = findObject(x, y);
- push(r);
- debug(1,"o7_unknownFC (x %d, y %d) stub", x, y);
+ debug(1, "o7_polygonHit(%d, %d)", x, y);
+
+ for (int i = 0; i < _WizNumPolygons; i++) {
+ if (_WizPolygons[i].bound.contains(x, y)) {
+ if (polygonContains(_WizPolygons[i], x, y)) {
+ push(_WizPolygons[i].id);
+ return;
+ }
+ }
+ }
+
+ push(0);
+}
+
+bool ScummEngine_v7he::polygonContains(WizPolygon &pol, int x, int y) {
+ int pi = pol.numVerts - 1;
+ bool diry = (y < pol.vert[pi].y);
+ bool curdir;
+ bool r = false;
+
+ for (int i = 0; i < pol.numVerts; i++) {
+ curdir = (y <= pol.vert[i].y);
+
+ if (curdir != diry) {
+ if (((pol.vert[pi].y - pol.vert[i].y) * (pol.vert[i].x - x) <=
+ (pol.vert[pi].x - pol.vert[i].x) * (pol.vert[pi].y - y)) == diry)
+ r = r ? false : true;
+ }
+
+ pi = i;
+ diry = curdir;
+ }
+ return r;
}
} // End of namespace Scumm
Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -d -r2.17 -r2.18
--- script_v80he.cpp 13 Sep 2004 18:01:25 -0000 2.17
+++ script_v80he.cpp 13 Sep 2004 23:24:36 -0000 2.18
@@ -358,9 +358,9 @@
OPCODE(o72_unknownF8),
OPCODE(o72_setFilePath),
OPCODE(o72_unknownFA),
- OPCODE(o7_unknownFB),
+ OPCODE(o7_polygonOps),
/* FC */
- OPCODE(o7_unknownFC),
+ OPCODE(o7_polygonHit),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.29
retrieving revision 2.30
diff -u -d -r2.29 -r2.30
--- script_v90he.cpp 13 Sep 2004 05:25:35 -0000 2.29
+++ script_v90he.cpp 13 Sep 2004 23:24:36 -0000 2.30
@@ -358,9 +358,9 @@
OPCODE(o72_unknownF8),
OPCODE(o72_setFilePath),
OPCODE(o72_unknownFA),
- OPCODE(o7_unknownFB),
+ OPCODE(o7_polygonOps),
/* FC */
- OPCODE(o7_unknownFC),
+ OPCODE(o7_polygonHit),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- scumm.cpp 13 Sep 2004 02:09:35 -0000 1.195
+++ scumm.cpp 13 Sep 2004 23:24:36 -0000 1.196
@@ -679,6 +679,8 @@
_costumeRenderer = NULL;
_2byteFontPtr = 0;
_V1_talkingActor = 0;
+ _WizNumPolygons = 200; // Used as constant in original
+ _WizPolygons = NULL;
_actorClipOverride.top = 0;
_actorClipOverride.bottom = 479;
@@ -1391,6 +1393,13 @@
for (i = 0; i < 512; i++)
_keyDownMap[i] = false;
+ if (_heversion >= 70) {
+ if (_WizPolygons)
+ free (_WizPolygons);
+
+ _WizPolygons = (WizPolygon *)calloc(_WizNumPolygons, sizeof(WizPolygon));
+ }
+
initScummVars();
_lastSaveTime = _system->get_msecs();
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.477
retrieving revision 1.478
diff -u -d -r1.477 -r1.478
--- scumm.h 10 Sep 2004 12:13:03 -0000 1.477
+++ scumm.h 13 Sep 2004 23:24:36 -0000 1.478
@@ -320,6 +320,14 @@
int32 offset;
};
+struct WizPolygon {
+ Common::Point vert[5];
+ Common::Rect bound;
+ int id;
+ int numVerts;
+ bool flag;
+};
+
class ScummEngine : public Engine {
friend class ScummDebugger;
friend class SmushPlayer;
@@ -651,6 +659,8 @@
uint32 *_HEV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
+ int _WizNumPolygons;
+ WizPolygon *_WizPolygons;
void allocateArrays();
void openRoom(int room);
More information about the Scummvm-git-logs
mailing list