diff options
-rw-r--r-- | scumm/object.cpp | 17 | ||||
-rw-r--r-- | scumm/object.h | 2 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 17 | ||||
-rw-r--r-- | scumm/scumm.h | 1 |
4 files changed, 32 insertions, 5 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp index adaecfc2ed..237eb06f22 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -168,6 +168,23 @@ int ScummEngine::getObjectIndex(int object) const { return -1; } +int ScummEngine::getObjectImageCount(int object) { + const byte *ptr; + const ImageHeader *imhd; + int count, objnum; + + objnum = getObjectIndex(object); + if (objnum == -1) + error("getObjectImageCount: object %d not in memory", object); + + ptr = getOBIMFromObject(_objs[objnum]); + imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), ptr); + + count = READ_LE_UINT32(&imhd->v8.image_count); + debug(1, "getObjectImageCount: image count %d", count); + return count; +} + int ScummEngine::whereIsObject(int object) const { int i; diff --git a/scumm/object.h b/scumm/object.h index 1ee876e51b..ac8b4ab4cd 100644 --- a/scumm/object.h +++ b/scumm/object.h @@ -131,7 +131,7 @@ struct ImageHeader { /* file format */ char name[32]; // | uint32 unk_1[2]; // always 0 ? v uint32 version; // 801; 801; 801; 801; 801; 801; 801 - uint32 unk_2; // 0; 0; 0; 0; 0: 1; 2 + uint32 image_count; // 0; 0; 0; 0; 0: 1; 2 uint32 x_pos; // 0; 184; 264; 336; 450; 272; 0 uint32 y_pos; // 0; 272; 248; 216; 168; 320; 0 uint32 width; // 64; 128; 120; 128; 80; 48; 80 diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index de7467bc0f..7fa51a71cf 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1582,6 +1582,7 @@ void ScummEngine_v8::o8_drawObject() { int x = pop(); int obj = pop(); int objnum = getObjectIndex(obj); + int imagecount; ObjectData *od; if (!objnum) @@ -1595,10 +1596,18 @@ void ScummEngine_v8::o8_drawObject() { addObjectToDrawQue(objnum); - if (state == 255 || state == 254) - warning("o8_drawObject(%d, %d, %d, %d): extended attributes unimplemented", x, y, objnum, state); - else - warning("o8_drawObject(%d, %d, %d, %d)", x, y, objnum, state); + if (state == 255) { + state = getState(obj); + imagecount = getObjectImageCount(obj); + + if (imagecount != state) + state++; + else + state = 1; + } + + if (state == 254) + state = _rnd.getRandomNumber(getObjectImageCount(obj)); putState(obj, state); } diff --git a/scumm/scumm.h b/scumm/scumm.h index 3da44b7d6c..09de29ccab 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -723,6 +723,7 @@ protected: int getObjOldDir(int obj); int getObjNewDir(int obj); int getObjectIndex(int object) const; + int getObjectImageCount(int object); int whereIsObject(int object) const; int findObject(int x, int y); void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room); |