aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-28 10:29:53 -0800
committerFilippos Karapetis2011-12-28 10:29:53 -0800
commite2aaba4a6913623c00684fbbe38246ac077deccc (patch)
treeaaf69fc0e24d01199a25583c8a438580abbd9873 /engines/dreamweb
parent6a5c75a439ce2e909cd7088380ae9ca8d005b6c3 (diff)
parent13e252ebd09ca6d8ac557f0934c28650a797ffd9 (diff)
downloadscummvm-rg350-e2aaba4a6913623c00684fbbe38246ac077deccc.tar.gz
scummvm-rg350-e2aaba4a6913623c00684fbbe38246ac077deccc.tar.bz2
scummvm-rg350-e2aaba4a6913623c00684fbbe38246ac077deccc.zip
Merge pull request #154 from fingolfin/dreamweb-cleanup
Dreamweb: Mark structs packed, minor tweaks
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/backdrop.cpp4
-rw-r--r--engines/dreamweb/dreamweb.h2
-rw-r--r--engines/dreamweb/monitor.cpp2
-rw-r--r--engines/dreamweb/object.cpp40
-rw-r--r--engines/dreamweb/sprite.cpp23
-rw-r--r--engines/dreamweb/structs.h63
-rw-r--r--engines/dreamweb/stubs.cpp28
-rw-r--r--engines/dreamweb/use.cpp6
8 files changed, 100 insertions, 68 deletions
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index 887da70539..1db2663624 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -126,12 +126,10 @@ void DreamWebEngine::makeBackOb(SetObject *objData, uint16 x, uint16 y) {
}
void DreamWebEngine::showAllObs() {
- const unsigned int count = 128;
-
_setList.clear();
const GraphicsFile &frameBase = _setFrames;
- for (size_t i = 0; i < count; ++i) {
+ for (size_t i = 0; i < 128; ++i) {
SetObject *setEntry = &_setDat[i];
uint16 x, y;
if (getMapAd(setEntry->mapad, &x, &y) == 0)
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 2de29491e5..6ca49b9b6f 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -792,7 +792,7 @@ public:
void findOrMake(uint8 index, uint8 value, uint8 type);
DynObject *getFreeAd(uint8 index);
DynObject *getExAd(uint8 index);
- DynObject *getEitherAdCPP();
+ DynObject *getEitherAd();
void *getAnyAdDir(uint8 index, uint8 flag);
void showWatch();
void showTime();
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index 2464326e7d..256478d09b 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -400,7 +400,7 @@ void DreamWebEngine::loadCart() {
uint16 objectIndex = findSetObject("INTF");
uint16 cartridgeIndex = checkInside(objectIndex, 1);
if (cartridgeIndex != kNumexobjects)
- cartridgeId = getExAd(cartridgeIndex)->id[3] + 1;
+ cartridgeId = getExAd(cartridgeIndex)->objId[3] + 1;
if (cartridgeId == 0)
loadTextFile(_textFile3, "DREAMWEB.T20"); // monitor file 20
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index b39be9cbe1..064e2cab4b 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -57,7 +57,7 @@ void DreamWebEngine::fillRyan() {
}
bool DreamWebEngine::isItWorn(const DynObject *object) {
- return (object->id[0] == 'W'-'A') && (object->id[1] == 'E'-'A');
+ return (object->objId[0] == 'W'-'A') && (object->objId[1] == 'E'-'A');
}
void DreamWebEngine::wornError() {
@@ -74,8 +74,8 @@ void DreamWebEngine::wornError() {
}
void DreamWebEngine::makeWorn(DynObject *object) {
- object->id[0] = 'W'-'A';
- object->id[1] = 'E'-'A';
+ object->objId[0] = 'W'-'A';
+ object->objId[1] = 'E'-'A';
}
void DreamWebEngine::obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
@@ -105,9 +105,9 @@ void DreamWebEngine::obPicture() {
}
void DreamWebEngine::obIcons() {
- uint8 value1, value2;
- getAnyAd(&value1, &value2);
- if (value1 != 0xff) {
+ uint8 slotSize, slotCount;
+ getAnyAd(&slotSize, &slotCount);
+ if (slotSize != 0xff) {
// can open it
showFrame(_icons2, 210, 1, 4, 0);
}
@@ -270,9 +270,9 @@ void DreamWebEngine::getBackFromOb() {
byte DreamWebEngine::getOpenedSlotCount() {
byte obj = _openedOb;
switch (_openedType) {
- case 4:
+ case kExObjectType:
return getExAd(obj)->slotCount;
- case 2:
+ case kFreeObjectType:
return getFreeAd(obj)->slotCount;
default:
return getSetAd(obj)->slotCount;
@@ -282,9 +282,9 @@ byte DreamWebEngine::getOpenedSlotCount() {
byte DreamWebEngine::getOpenedSlotSize() {
byte obj = _openedOb;
switch (_openedType) {
- case 4:
+ case kExObjectType:
return getExAd(obj)->slotSize;
- case 2:
+ case kFreeObjectType:
return getFreeAd(obj)->slotSize;
default:
return getSetAd(obj)->slotSize;
@@ -662,7 +662,7 @@ void DreamWebEngine::dropObject() {
if (_mouseButton == _oldButton || !(_mouseButton & 1))
return;
- if (isItWorn(getEitherAdCPP())) {
+ if (isItWorn(getEitherAd())) {
wornError();
return;
}
@@ -704,7 +704,7 @@ void DreamWebEngine::dropObject() {
bool DreamWebEngine::checkObjectSize() {
byte containerSize = getOpenedSlotSize();
- DynObject *object = getEitherAdCPP();
+ DynObject *object = getEitherAd();
// If there is no size defined for the object in the editor, set its size
// to 6. This could be a bad idea, according to the original source.
byte objectSize = (object->objectSize != 255) ? object->objectSize : 6;
@@ -791,7 +791,7 @@ void DreamWebEngine::swapWithInv() {
ObjectRef objectId = findInvPos();
_itemFrame = objectId._index;
_objectType = objectId._type;
- DynObject *object = getEitherAdCPP();
+ DynObject *object = getEitherAd();
object->mapad[0] = 20;
object->mapad[1] = 255;
byte prevType2 = _objectType;
@@ -799,7 +799,7 @@ void DreamWebEngine::swapWithInv() {
_objectType = prevType;
_itemFrame = prevFrame;
delPointer();
- object = getEitherAdCPP();
+ object = getEitherAd();
object->mapad[0] = 4;
object->mapad[1] = 255;
object->mapad[2] = _lastInvPos;
@@ -845,7 +845,7 @@ void DreamWebEngine::useOpened() {
if (_mouseButton == _oldButton || !(_mouseButton & 1))
return;
- if (isItWorn(getEitherAdCPP())) {
+ if (isItWorn(getEitherAd())) {
wornError();
return;
}
@@ -862,7 +862,7 @@ void DreamWebEngine::useOpened() {
return;
_pickUp = 0;
- DynObject *object = getEitherAdCPP();
+ DynObject *object = getEitherAd();
object->mapad[0] = _openedType;
object->mapad[1] = _openedOb;
object->mapad[2] = _lastInvPos;
@@ -915,7 +915,7 @@ void DreamWebEngine::outOfOpen() {
_objectType = kExObjectType;
}
- DynObject *object = getEitherAdCPP();
+ DynObject *object = getEitherAd();
object->mapad[0] = 20;
object->mapad[1] = 255;
@@ -942,7 +942,7 @@ void DreamWebEngine::swapWithOpen() {
if (_mouseButton == _oldButton || !(_mouseButton & 1))
return;
- if (isItWorn(getEitherAdCPP())) {
+ if (isItWorn(getEitherAd())) {
wornError();
return;
}
@@ -970,7 +970,7 @@ void DreamWebEngine::swapWithOpen() {
_objectType = kExObjectType;
}
- DynObject *object = getEitherAdCPP();
+ DynObject *object = getEitherAd();
object->mapad[0] = 20;
object->mapad[1] = 255;
@@ -978,7 +978,7 @@ void DreamWebEngine::swapWithOpen() {
byte prevFrame2 = _itemFrame;
_objectType = prevType;
_itemFrame = prevFrame;
- object = getEitherAdCPP();
+ object = getEitherAd();
object->mapad[0] = _openedType;
object->mapad[1] = _openedOb;
object->mapad[2] = _lastInvPos;
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 07f391addc..b1aae5adce 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -227,20 +227,29 @@ void DreamWebEngine::backObject(Sprite *sprite) {
}
sprite->delay = objData->delay;
- if (objData->type == 6)
+ switch (objData->type) {
+ case 6:
wideDoor(sprite, objData);
- else if (objData->type == 5)
+ break;
+ case 5:
randomSprite(sprite, objData);
- else if (objData->type == 4)
+ break;
+ case 4:
lockedDoorway(sprite, objData);
- else if (objData->type == 3)
+ break;
+ case 3:
liftSprite(sprite, objData);
- else if (objData->type == 2)
+ break;
+ case 2:
doorway(sprite, objData);
- else if (objData->type == 1)
+ break;
+ case 1:
constant(sprite, objData);
- else
+ break;
+ default:
steady(sprite, objData);
+ break;
+ }
}
void DreamWebEngine::constant(Sprite *sprite, SetObject *objData) {
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index b34715addf..fad2e1b5ae 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -58,6 +58,10 @@ struct RectWithCallback {
}
};
+
+
+#include "common/pack-start.h" // START STRUCT PACKING
+
struct SetObject {
uint8 b0;
uint8 b1;
@@ -71,7 +75,7 @@ struct SetObject {
uint8 b9;
uint8 b10;
uint8 b11;
- uint8 name[4];
+ uint8 objId[4];
uint8 b16;
uint8 index;
uint8 frames[13]; // Table mapping animFrame to sprite frame number
@@ -105,7 +109,7 @@ struct SetObject {
uint8 b57;
uint8 mapad[5];
uint8 b63;
-};
+} PACKED_STRUCT;
struct DynObject {
uint8 currentLocation;
@@ -116,8 +120,8 @@ struct DynObject {
uint8 objectSize; // the size of an object
uint8 turnedOn;
uint8 initialLocation;
- uint8 id[4];
-};
+ uint8 objId[4];
+} PACKED_STRUCT;
struct ObjPos {
uint8 xMin;
@@ -128,7 +132,7 @@ struct ObjPos {
bool contains(uint8 x, uint8 y) const {
return (x >= xMin) && (x < xMax) && (y >= yMin) && (y < yMax);
}
-};
+} PACKED_STRUCT;
struct Frame {
uint8 width;
@@ -138,7 +142,7 @@ struct Frame {
void setPtr(uint16 v) { WRITE_LE_UINT16(&_ptr, v); }
uint8 x;
uint8 y;
-};
+} PACKED_STRUCT;
struct Reel {
uint8 frame_lo;
@@ -148,7 +152,11 @@ struct Reel {
uint8 x;
uint8 y;
uint8 b4;
-};
+} PACKED_STRUCT;
+
+#include "common/pack-end.h" // END STRUCT PACKING
+
+
struct ReelRoutine {
uint8 reallocation;
@@ -167,9 +175,12 @@ struct People {
uint16 _reelPointer;
ReelRoutine *_routinePointer;
uint8 b4;
-
};
+
+
+#include "common/pack-start.h" // START STRUCT PACKING
+
struct Room {
char name[13];
uint8 roomsSample;
@@ -191,7 +202,8 @@ struct Room {
uint8 b29;
uint8 b30;
uint8 realLocation;
-};
+} PACKED_STRUCT;
+
extern const Room g_roomData[];
struct Rain {
@@ -200,14 +212,14 @@ struct Rain {
uint8 size;
uint16 w3;
uint8 b5;
-};
+} PACKED_STRUCT;
struct Change {
uint8 index;
uint8 location;
uint8 value;
uint8 type;
-};
+} PACKED_STRUCT;
struct PathNode {
uint8 x;
@@ -218,17 +230,17 @@ struct PathNode {
uint8 y2;
uint8 on;
uint8 dir;
-};
+} PACKED_STRUCT;
struct PathSegment {
uint8 b0;
uint8 b1;
-};
+} PACKED_STRUCT;
struct RoomPaths {
PathNode nodes[12];
PathSegment segments[24];
-};
+} PACKED_STRUCT;
struct FileHeader {
char _desc[50];
@@ -243,7 +255,7 @@ struct FileHeader {
assert(i < 20);
WRITE_LE_UINT16(&_len[i], length);
}
-};
+} PACKED_STRUCT;
struct Atmosphere {
uint8 _location;
@@ -251,7 +263,11 @@ struct Atmosphere {
uint8 _mapY;
uint8 _sound;
uint8 _repeat;
-};
+} PACKED_STRUCT;
+
+#include "common/pack-end.h" // END STRUCT PACKING
+
+
enum ObjectTypes {
kSetObjectType1 = 1,
@@ -272,16 +288,26 @@ struct ObjectRef {
}
};
+
+
+#include "common/pack-start.h" // START STRUCT PACKING
+
struct BackdropMapFlag {
uint8 _flag;
uint8 _flagEx;
-};
+} PACKED_STRUCT;
struct MapFlag {
uint8 _flag;
uint8 _flagEx;
uint8 _type;
-};
+} PACKED_STRUCT;
+
+#include "common/pack-end.h" // END STRUCT PACKING
+
+
+
+
struct TextFile {
TextFile(unsigned int size = 66) : _size(size), _text(0) { _offsetsLE = new uint16[_size]; }
@@ -393,7 +419,6 @@ struct GameVars {
uint8 _shakeCounter;
};
-
} // End of namespace DreamWeb
#endif
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index d91eb242ff..5fbd601b81 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1034,13 +1034,6 @@ void DreamWebEngine::lockMon() {
}
}
-void DreamWebEngine::clearAndLoad(uint8 *buf, uint8 c,
- unsigned int size, unsigned int maxSize) {
- assert(size <= maxSize);
- memset(buf, c, maxSize);
- readFromFile(buf, size);
-}
-
void DreamWebEngine::startLoading(const Room &room) {
_vars._combatCount = 0;
_roomsSample = room.roomsSample;
@@ -1278,7 +1271,7 @@ DynObject *DreamWebEngine::getExAd(uint8 index) {
return &_exData[index];
}
-DynObject *DreamWebEngine::getEitherAdCPP() {
+DynObject *DreamWebEngine::getEitherAd() {
if (_objectType == kExObjectType)
return getExAd(_itemFrame);
else
@@ -1309,9 +1302,9 @@ void *DreamWebEngine::getAnyAd(uint8 *slotSize, uint8 *slotCount) {
}
void *DreamWebEngine::getAnyAdDir(uint8 index, uint8 flag) {
- if (flag == 4)
+ if (flag == kExObjectType)
return getExAd(index);
- else if (flag == 2)
+ else if (flag == kFreeObjectType)
return getFreeAd(index);
else
return getSetAd(index);
@@ -2107,10 +2100,17 @@ void DreamWebEngine::getRidOfAll() {
_freeDesc.clear();
}
+void DreamWebEngine::clearAndLoad(uint8 *buf, uint8 c,
+ unsigned int size, unsigned int maxSize) {
+ assert(size <= maxSize);
+ memset(buf, c, maxSize);
+ readFromFile(buf, size);
+}
+
// if skipDat, skip clearing and loading Setdat and Freedat
void DreamWebEngine::loadRoomData(const Room &room, bool skipDat) {
- const uint16 kSetdatlen = 64*128;
- const uint16 kFreedatlen = 16*80;
+ const uint16 kSetdatlen = 64*128; // == sizeof(_setDat)
+ const uint16 kFreedatlen = 16*80; // == sizeof(_freeDat)
openFile(room.name);
@@ -3686,7 +3686,7 @@ void DreamWebEngine::purgeAnItem() {
const DynObject *extraObjects = _exData;
for (size_t i = 0; i < kNumexobjects; ++i) {
- if (extraObjects[i].mapad[0] && extraObjects[i].id[0] == 255 &&
+ if (extraObjects[i].mapad[0] && extraObjects[i].objId[0] == 255 &&
extraObjects[i].initialLocation != _realLocation) {
deleteExObject(i);
return;
@@ -3694,7 +3694,7 @@ void DreamWebEngine::purgeAnItem() {
}
for (size_t i = 0; i < kNumexobjects; ++i) {
- if (extraObjects[i].mapad[0] && extraObjects[i].id[0] == 255) {
+ if (extraObjects[i].mapad[0] && extraObjects[i].objId[0] == 255) {
deleteExObject(i);
return;
}
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index 6ab8422075..4259d03657 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -1396,7 +1396,7 @@ void DreamWebEngine::usePipe() {
showPuzText(36, 300);
putBackObStuff();
DynObject *exObject = getExAd(_withObject);
- exObject->id[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
+ exObject->objId[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
return;
} else if (compare(_withObject, _withType, "CUPF")) {
// Already full
@@ -1419,7 +1419,7 @@ void DreamWebEngine::useOpenBox() {
_vars._progressPoints++;
showPuzText(37, 300);
DynObject *exObject = getExAd(_withObject);
- exObject->id[3] = 'E'-'A'; // CUPF (full cup) -> CUPE (empty cup)
+ exObject->objId[3] = 'E'-'A'; // CUPF (full cup) -> CUPE (empty cup)
_vars._watchingTime = 140;
_vars._reelToWatch = 105;
_vars._endWatchReel = 181;
@@ -1449,7 +1449,7 @@ void DreamWebEngine::runTap() {
if (compare(_withObject, _withType, "CUPE")) {
// Fill cup from tap
DynObject *exObject = getExAd(_withObject);
- exObject->id[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
+ exObject->objId[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
playChannel1(8);
showPuzText(57, 300);
putBackObStuff();