[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.56,1.57 boxes.cpp,1.8,1.9 saveload.cpp,1.42,1.43 saveload.h,1.8,1.9 script_v8.cpp,2.111,2.112 scumm.h,1.128,1.129 scummvm.cpp,2.35,2.36
Max Horn
fingolfin at users.sourceforge.net
Sun Jan 12 17:30:11 CET 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv24718
Modified Files:
actor.cpp boxes.cpp saveload.cpp saveload.h script_v8.cpp
scumm.h scummvm.cpp
Log Message:
added V8 scaling code
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- actor.cpp 7 Jan 2003 20:21:39 -0000 1.56
+++ actor.cpp 13 Jan 2003 01:29:44 -0000 1.57
@@ -354,7 +354,6 @@
void Actor::setupActorScale()
{
uint16 scale;
- byte *resptr;
if (_vm->_features & GF_NO_SCALLING) {
scalex = 0xFF;
@@ -368,20 +367,7 @@
if (_vm->getBoxFlags(walkbox) & kBoxPlayerOnly)
return;
- scale = _vm->getBoxScale(walkbox);
-
- if (scale & 0x8000) {
- scale = (scale & 0x7FFF) + 1;
- resptr = _vm->getResourceAddress(rtScaleTable, scale);
- if (resptr == NULL)
- error("Scale table %d not defined", scale);
- int theY = y;
- if (theY >= _vm->_realHeight)
- theY = _vm->_realHeight - 1;
- else if (theY < 0)
- theY = 0;
- scale = resptr[theY];
- }
+ scale = _vm->getScale(walkbox, x, y);
// FIXME - Hack for The Dig 'Tomb' (room 88)
// Otherwise walking to the far-left door causes the actor
@@ -400,15 +386,21 @@
// When standing at the bottom of the ladder, Ben's Y position is
// 356, and by the looks of it he ought to be unscaled there.
- if (scale == 1 && _vm->_currentRoom == 76) {
+ if (_vm->_gameId == GID_FT && scale == 1 && _vm->_currentRoom == 76) {
scale = 0xff;
if (y < 356)
scale -= 2 * (356 - y);
}
- if (scale > 255)
- warning("Actor %d at %d, scale %d out of range", number, y, scale);
-
+ if (scale > 255) {
+ if (_vm->_features & GF_AFTER_V8) {
+ // In COMI, the scale values often are bigger than 255;
+ // however, the original engine seems to just cap them at 255,
+ // hence we do the same (the result looks correct, too);
+ scale = 255;
+ } else
+ warning("Actor %d at %d, scale %d out of range", number, y, scale);
+ }
scalex = (byte)scale;
scaley = (byte)scale;
}
Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- boxes.cpp 30 Dec 2002 21:56:56 -0000 1.8
+++ boxes.cpp 13 Jan 2003 01:29:44 -0000 1.9
@@ -50,7 +50,7 @@
int32 llx, lly;
uint32 mask; // FIXME - is 'mask' really here?
uint32 flags; // FIXME - is 'flags' really here?
- uint32 unk1;
+ uint32 scaleSlot;
uint32 scale;
uint32 unk2;
uint32 unk3;
@@ -126,6 +126,59 @@
b->v8.scale = TO_LE_32(scale);
else
b->old.scale = TO_LE_16(scale);
+}
+
+int Scumm::getScale(int box, int x, int y)
+{
+ Box *ptr = getBoxBaseAddr(box);
+ assert(ptr);
+
+ if (_features & GF_AFTER_V8) {
+ int slot = FROM_LE_32(ptr->v8.scaleSlot);
+ if (slot) {
+ assert(0 <= slot && slot < 20);
+ int scaleX = 0, scaleY = 0;
+ ScaleSlot &s = _scaleSlots[slot];
+
+ if (s.y1 == s.y2 && s.x1 == s.x2)
+ error("Invalid scale slot %d", slot);
+
+ if (s.y1 != s.y2) {
+ if (y < 0)
+ y = 0;
+
+ scaleY = (s.scale2 - s.scale1) * (y - s.y1) / (s.y2 - s.y1) + s.scale1;
+ if (s.x1 == s.x2) {
+ return scaleY;
+ }
+ }
+
+ scaleX = (s.scale2 - s.scale1) * (x - s.x1) / (s.x2 - s.x1) + s.scale1;
+
+ if (s.y1 == s.y2) {
+ return scaleX;
+ } else {
+ return (scaleX + scaleY - s.x1) / 2;
+ }
+ } else
+ return FROM_LE_32(ptr->v8.scale);
+ } else {
+ uint16 scale = FROM_LE_16(ptr->old.scale);
+
+ if (scale & 0x8000) {
+ scale = (scale & 0x7FFF) + 1;
+ byte *resptr = getResourceAddress(rtScaleTable, scale);
+ if (resptr == NULL)
+ error("Scale table %d not defined", scale);
+ if (y >= _realHeight)
+ y = _realHeight - 1;
+ else if (y < 0)
+ y = 0;
+ scale = resptr[y];
+ }
+
+ return scale;
+ }
}
int Scumm::getBoxScale(int box)
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- saveload.cpp 9 Jan 2003 22:53:21 -0000 1.42
+++ saveload.cpp 13 Jan 2003 01:29:44 -0000 1.43
@@ -532,6 +532,16 @@
MKEND()
};
+ const SaveLoadEntry scaleSlotsEntries[] = {
+ MKLINE(ScaleSlot, x1, sleUint16, VER_V13),
+ MKLINE(ScaleSlot, y1, sleUint16, VER_V13),
+ MKLINE(ScaleSlot, scale1, sleUint16, VER_V13),
+ MKLINE(ScaleSlot, x2, sleUint16, VER_V13),
+ MKLINE(ScaleSlot, y2, sleUint16, VER_V13),
+ MKLINE(ScaleSlot, scale2, sleUint16, VER_V13),
+ MKEND()
+ };
+
int i, j;
int var120Backup;
int var98Backup;
@@ -563,6 +573,9 @@
/* XXX: next time save game format changes, Fingolfin wants to revise StringTab - contact him */
s->saveLoadArrayOf(_string, 6, sizeof(_string[0]), stringTabEntries);
s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]), colorCycleEntries);
+
+ if (savegameVersion >= VER_V13)
+ s->saveLoadArrayOf(_scaleSlots, 20, sizeof(_scaleSlots[0]), scaleSlotsEntries);
for (i = rtFirst; i <= rtLast; i++)
if (res.mode[i] == 0)
Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- saveload.h 9 Jan 2003 22:53:21 -0000 1.8
+++ saveload.h 13 Jan 2003 01:29:44 -0000 1.9
@@ -25,14 +25,17 @@
// Support for "old" savegames (made with 2501 CVS build)
// Can be useful for other ports too :)
-#define VER_V12 12
-#define VER_V11 11
-#define VER_V10 10
-#define VER_V9 9
-#define VER_V8 8
-#define VER_V7 7
+enum {
+ VER_V7 = 7,
+ VER_V8,
+ VER_V9,
+ VER_V10,
+ VER_V11,
+ VER_V12,
+ VER_V13
+};
-#define CURRENT_VER VER_V12
+#define CURRENT_VER VER_V13
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.111
retrieving revision 2.112
diff -u -d -r2.111 -r2.112
--- script_v8.cpp 12 Jan 2003 21:13:22 -0000 2.111
+++ script_v8.cpp 13 Jan 2003 01:29:45 -0000 2.112
@@ -1378,6 +1378,7 @@
break;
case 21: // setScaleSlot
warning("o8_kernelSetFunctions: setScaleSlot(%d, %d, %d, %d, %d, %d, %d)", args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+ setScaleSlot(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
break;
case 22: // setBannerColors
// warning("o8_kernelSetFunctions: setBannerColors(%d, %d, %d, %d)", args[1], args[2], args[3], args[4]);
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- scumm.h 12 Jan 2003 07:30:17 -0000 1.128
+++ scumm.h 13 Jan 2003 01:29:45 -0000 1.129
@@ -378,7 +378,6 @@
byte _numObjectsInRoom;
int8 _userPut;
int _resourceHeaderSize;
- void setScaleItem(int slot, int a, int b, int c, int d);
void clearClickedStatus();
void startManiac();
@@ -854,6 +853,19 @@
Box *getBoxBaseAddr(int box);
byte getBoxFlags(int box);
int getBoxScale(int box);
+
+ int getScale(int box, int x, int y);
+ void setScaleItem(int slot, int a, int b, int c, int d);
+
+ // V8 scaling stuff: should be in V8 class
+ struct ScaleSlot {
+ int x1, y1, scale1;
+ int x2, y2, scale2;
+ };
+ ScaleSlot _scaleSlots[20]; // FIXME - not sure if this limit is right, but based on my observations it is
+ void setScaleSlot(int slot, int x1, int y1, int scale1, int x2, int y2, int scale2);
+
+
byte getNumBoxes();
byte *getBoxMatrixBaseAddr();
int getPathToDestBox(byte from, byte to);
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.35
retrieving revision 2.36
diff -u -d -r2.35 -r2.36
--- scummvm.cpp 12 Jan 2003 16:34:05 -0000 2.35
+++ scummvm.cpp 13 Jan 2003 01:29:45 -0000 2.36
@@ -835,14 +835,11 @@
offs = ptr - roomptr;
if (_features & GF_AFTER_V8) {
for (i = 1; i < _maxScaleTable; i++, offs += 16) {
- int a = READ_LE_UINT32(roomptr + offs);
- int b = READ_LE_UINT32(roomptr + offs + 4);
- int c = READ_LE_UINT32(roomptr + offs + 8);
- int d = READ_LE_UINT32(roomptr + offs + 12);
- if (a || b || c || d) {
- setScaleItem(i, b, a, d, c);
- roomptr = getResourceAddress(rtRoom, _roomResource);
- }
+ int scale1 = READ_LE_UINT32(roomptr + offs);
+ int y1 = READ_LE_UINT32(roomptr + offs + 4);
+ int scale2 = READ_LE_UINT32(roomptr + offs + 8);
+ int y2 = READ_LE_UINT32(roomptr + offs + 12);
+ setScaleSlot(i, 0, y1, scale1, 0, y2, scale2);
}
} else {
for (i = 1; i < _maxScaleTable; i++, offs += 8) {
@@ -979,6 +976,16 @@
*ptr++ = tmp;
cur += amounttoadd;
}
+}
+
+void Scumm::setScaleSlot(int slot, int x1, int y1, int scale1, int x2, int y2, int scale2)
+{
+ _scaleSlots[slot].x2 = x2;
+ _scaleSlots[slot].y2 = y2;
+ _scaleSlots[slot].scale2 = scale2;
+ _scaleSlots[slot].x1 = x1;
+ _scaleSlots[slot].y1 = y1;
+ _scaleSlots[slot].scale1 = scale1;
}
void Scumm::dumpResource(char *tag, int idx, byte *ptr)
More information about the Scummvm-git-logs
mailing list