diff options
author | Max Horn | 2005-04-17 23:19:16 +0000 |
---|---|---|
committer | Max Horn | 2005-04-17 23:19:16 +0000 |
commit | 96e40213efc65644c3685ca543f6ddbc05a27d87 (patch) | |
tree | 4d648d30e1e100841127adbe7fd6c1bfcb2a904e /scumm | |
parent | c4e7f403f8b36c4c0437b6fa911f383dfa0770ab (diff) | |
download | scummvm-rg350-96e40213efc65644c3685ca543f6ddbc05a27d87.tar.gz scummvm-rg350-96e40213efc65644c3685ca543f6ddbc05a27d87.tar.bz2 scummvm-rg350-96e40213efc65644c3685ca543f6ddbc05a27d87.zip |
New virtual method getObjectIdFromOBIM
svn-id: r17660
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/cursor.cpp | 22 | ||||
-rw-r--r-- | scumm/intern.h | 8 | ||||
-rw-r--r-- | scumm/object.cpp | 52 | ||||
-rw-r--r-- | scumm/object.h | 1 | ||||
-rw-r--r-- | scumm/scumm.h | 2 |
5 files changed, 45 insertions, 40 deletions
diff --git a/scumm/cursor.cpp b/scumm/cursor.cpp index 9d025c6e60..8f49b9f624 100644 --- a/scumm/cursor.cpp +++ b/scumm/cursor.cpp @@ -157,26 +157,28 @@ void ScummEngine_v6::setCursorFromImg(uint img, uint room, uint imgindex) { const byte *dataptr, *bomp; uint32 size; FindObjectInRoom foir; + const ImageHeader *imhd; if (room == (uint) - 1) room = getObjectRoom(img); findObjectInRoom(&foir, foCodeHeader | foImageHeader | foCheckAlreadyLoaded, img, room); + imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), foir.obim); if (_version == 8) { - setCursorHotspot(READ_LE_UINT32(&foir.imhd->v8.hotspot[0].x), - READ_LE_UINT32(&foir.imhd->v8.hotspot[0].y)); - w = READ_LE_UINT32(&foir.imhd->v8.width) / 8; - h = READ_LE_UINT32(&foir.imhd->v8.height) / 8; + setCursorHotspot(READ_LE_UINT32(&imhd->v8.hotspot[0].x), + READ_LE_UINT32(&imhd->v8.hotspot[0].y)); + w = READ_LE_UINT32(&imhd->v8.width) / 8; + h = READ_LE_UINT32(&imhd->v8.height) / 8; } else if (_version == 7) { - setCursorHotspot(READ_LE_UINT16(&foir.imhd->v7.hotspot[0].x), - READ_LE_UINT16(&foir.imhd->v7.hotspot[0].y)); - w = READ_LE_UINT16(&foir.imhd->v7.width) / 8; - h = READ_LE_UINT16(&foir.imhd->v7.height) / 8; + setCursorHotspot(READ_LE_UINT16(&imhd->v7.hotspot[0].x), + READ_LE_UINT16(&imhd->v7.hotspot[0].y)); + w = READ_LE_UINT16(&imhd->v7.width) / 8; + h = READ_LE_UINT16(&imhd->v7.height) / 8; } else { if (!(_features & GF_HUMONGOUS)) - setCursorHotspot(READ_LE_UINT16(&foir.imhd->old.hotspot[0].x), - READ_LE_UINT16(&foir.imhd->old.hotspot[0].y)); + setCursorHotspot(READ_LE_UINT16(&imhd->old.hotspot[0].x), + READ_LE_UINT16(&imhd->old.hotspot[0].y)); w = READ_LE_UINT16(&foir.cdhd->v6.w) / 8; h = READ_LE_UINT16(&foir.cdhd->v6.h) / 8; } diff --git a/scumm/intern.h b/scumm/intern.h index 53944e7430..792f68abec 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -1203,6 +1203,8 @@ protected: virtual void setCameraFollows(Actor *a); virtual void moveCamera(); virtual void panCameraTo(int x, int y); + + virtual int getObjectIdFromOBIM(const byte *obim); }; class ScummEngine_v8 : public ScummEngine_v7 { @@ -1214,7 +1216,9 @@ protected: }; const OpcodeEntryV8 *_opcodesV8; - + + ObjectIDMap _objectIDMap; + public: ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v7(detector, syst, gs, md5sum) {} @@ -1236,6 +1240,8 @@ protected: virtual int readVar(uint var); virtual void writeVar(uint var, int value); + virtual int getObjectIdFromOBIM(const byte *obim); + /* Version 8 script opcodes */ void o8_mod(); void o8_wait(); diff --git a/scumm/object.cpp b/scumm/object.cpp index 23c4ec7f0d..c239c650ab 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -546,7 +546,6 @@ void ScummEngine::loadRoomObjects() { const byte *ptr; uint16 obim_id; const byte *room, *searchptr, *rootptr; - const ImageHeader *imhd; const CodeHeader *cdhd; CHECK_HEAP @@ -599,15 +598,7 @@ void ScummEngine::loadRoomObjects() { if (ptr == NULL) error("Room %d missing image blocks(s)", _roomResource); - imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), ptr); - if (_version == 8) - // In V8, IMHD has no obj_id, but rather a name string. We map the name - // back to an object id using a table derived from the DOBJ resource. - obim_id = _objectIDMap[imhd->v8.name]; - else if (_version == 7) - obim_id = READ_LE_UINT16(&imhd->v7.obj_id); - else - obim_id = READ_LE_UINT16(&imhd->old.obj_id); + obim_id = getObjectIdFromOBIM(ptr); for (j = 1; j < _numLocalObjects; j++) { if (_objs[j].obj_nr == obim_id) @@ -1128,9 +1119,8 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, const CodeHeader *cdhd; int i, numobj; const byte *roomptr, *obcdptr, *obimptr, *searchptr; - const ImageHeader *imhd; int id2; - int id3; + int obim_id; if (findWhat & foCheckAlreadyLoaded && getObjectIndex(id) != -1) { if (_features & GF_OLD_BUNDLE) { @@ -1143,7 +1133,6 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, assert(obcdptr); fo->obim = obimptr = obcdptr + READ_BE_UINT32(obcdptr + 4); fo->cdhd = (const CodeHeader *)findResourceData(MKID('CDHD'), obcdptr); - fo->imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obimptr); return; } @@ -1187,7 +1176,6 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, } if (findWhat & foImageHeader) { fo->obim = obimptr; - fo->imhd = NULL; } break; } @@ -1235,21 +1223,10 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, obimptr = obims.findNext(MKID('OBIM')); if (obimptr == NULL) error("findObjectInRoom: Not enough image blocks in room %d", room); - imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obimptr); - if (_features & GF_SMALL_HEADER) - id3 = READ_LE_UINT16(obimptr + 6); - else if (_version == 8) - // In V8, IMHD has no obj_id, but rather a name string. We map the name - // back to an object id using a table derived from the DOBJ resource. - id3 = _objectIDMap[imhd->v8.name]; - else if (_version == 7) - id3 = READ_LE_UINT16(&imhd->v7.obj_id); - else - id3 = READ_LE_UINT16(&imhd->old.obj_id); + obim_id = getObjectIdFromOBIM(obimptr); - if (id3 == (uint16)id) { + if (obim_id == (uint16)id) { fo->obim = obimptr; - fo->imhd = imhd; break; } } @@ -1258,6 +1235,27 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, } } +int ScummEngine_v8::getObjectIdFromOBIM(const byte *obim) { + // In V8, IMHD has no obj_id, but rather a name string. We map the name + // back to an object id using a table derived from the DOBJ resource. + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obim); + return _objectIDMap[imhd->v8.name]; +} + +int ScummEngine_v7::getObjectIdFromOBIM(const byte *obim) { + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obim); + return READ_LE_UINT16(&imhd->v7.obj_id); +} + +int ScummEngine::getObjectIdFromOBIM(const byte *obim) { + if (_features & GF_SMALL_HEADER) + return READ_LE_UINT16(obim + 6); + + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obim); + return READ_LE_UINT16(&imhd->old.obj_id); +} + + int ScummEngine::getInventorySlot() { int i; for (i = 0; i < _numInventory; i++) { diff --git a/scumm/object.h b/scumm/object.h index 78cfc811ff..a50933c3d5 100644 --- a/scumm/object.h +++ b/scumm/object.h @@ -165,7 +165,6 @@ struct ImageHeader { /* file format */ struct FindObjectInRoom { const CodeHeader *cdhd; const byte *obcd; - const ImageHeader *imhd; const byte *obim; const byte *roomptr; }; diff --git a/scumm/scumm.h b/scumm/scumm.h index 35da5caa02..4935af2ada 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -744,7 +744,6 @@ public: protected: byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable; - ObjectIDMap _objectIDMap; int _numObjectsInRoom; virtual void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL); @@ -794,6 +793,7 @@ protected: byte *getOBCDFromObject(int obj); const byte *getOBIMFromObject(const ObjectData &od); const byte *getObjectImage(const byte *ptr, int state); + virtual int getObjectIdFromOBIM(const byte *obim); int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f); |