From 559ac7b842740275c82188ec04291d37e209db47 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 24 Dec 2002 04:02:21 +0000 Subject: changed lots of stuff to read data in the V8 format; more changes still needed, and one open problem: V8 IMHD has no obj_id, we need to work around that somehow, not yet sure what the correct way is (two find out, we either need to get into a state where this actually matters, so that we can do trial & error, or we need a disassmbly) svn-id: r6094 --- scumm/object.cpp | 135 +++++++++++++++++++++++++++++++++--------------------- scumm/scummvm.cpp | 44 +++++++++++++----- 2 files changed, 116 insertions(+), 63 deletions(-) (limited to 'scumm') diff --git a/scumm/object.cpp b/scumm/object.cpp index e4c15dd380..50f940c3ac 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -196,7 +196,10 @@ void Scumm::getObjectXYPos(int object, int &x, int &y, int &dir) } assert(ptr); imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr); - if (_features & GF_AFTER_V7) { + if (_features & GF_AFTER_V8) { + x = od->x_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].x); + y = od->y_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].y); + } else if (_features & GF_AFTER_V7) { x = od->x_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].x); y = od->y_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].y); } else { @@ -402,7 +405,9 @@ void Scumm::loadRoomObjects() CHECK_HEAP room = getResourceAddress(rtRoom, _roomResource); roomhdr = (RoomHeader *)findResourceData(MKID('RMHD'), room); - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) + _numObjectsInRoom = READ_LE_UINT32(&(roomhdr->v8.numObjects)); + else if (_features & GF_AFTER_V7) _numObjectsInRoom = READ_LE_UINT16(&(roomhdr->v7.numObjects)); else _numObjectsInRoom = READ_LE_UINT16(&(roomhdr->old.numObjects)); @@ -447,7 +452,11 @@ void Scumm::loadRoomObjects() error("Room %d missing image blocks(s)", _roomResource); imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr); - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) + // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string + obim_id = 0; +// obim_id = READ_LE_UINT32(&imhd->v8.obj_id); + else if (_features & GF_AFTER_V7) obim_id = READ_LE_UINT16(&imhd->v7.obj_id); else obim_id = READ_LE_UINT16(&imhd->old.obj_id); @@ -564,42 +573,23 @@ void Scumm::setupRoomObject(ObjectData *od, byte *room) } cdhd = (CodeHeader *)findResourceData(MKID('CDHD'), room + od->offs_obcd_to_room); - if (_features & GF_AFTER_V7) + + if (_features & GF_AFTER_V8) { + od->obj_nr = READ_LE_UINT16(&(cdhd->v7.obj_id)); + + od->parent = cdhd->v7.parent; + od->parentstate = cdhd->v7.parentstate; + + imhd = (ImageHeader *)findResourceData(MKID('IMHD'), room + od->offs_obim_to_room); + od->x_pos = READ_LE_UINT32(&imhd->v8.x_pos); + od->y_pos = READ_LE_UINT32(&imhd->v8.y_pos); + od->width = READ_LE_UINT32(&imhd->v8.width); + od->height = READ_LE_UINT32(&imhd->v8.height); + od->actordir = READ_LE_UINT32(&imhd->v8.actordir); + + } else if (_features & GF_AFTER_V7) { od->obj_nr = READ_LE_UINT16(&(cdhd->v7.obj_id)); - else if (_features & GF_AFTER_V6) - od->obj_nr = READ_LE_UINT16(&(cdhd->v6.obj_id)); - else - od->obj_nr = READ_LE_UINT16(&(cdhd->v5.obj_id)); - if (!(_features & GF_AFTER_V7)) { - if (_features & GF_AFTER_V6) { - od->width = READ_LE_UINT16(&cdhd->v6.w); - od->height = READ_LE_UINT16(&cdhd->v6.h); - od->x_pos = ((int16)READ_LE_UINT16(&cdhd->v6.x)); - od->y_pos = ((int16)READ_LE_UINT16(&cdhd->v6.y)); - if (cdhd->v6.flags == 0x80) { - od->parentstate = 1; - } else { - od->parentstate = (cdhd->v6.flags & 0xF); - } - od->parent = cdhd->v6.parent; - od->actordir = cdhd->v6.actordir; - } else { - od->width = cdhd->v5.w << 3; - od->height = cdhd->v5.h << 3; - od->x_pos = cdhd->v5.x << 3; - od->y_pos = cdhd->v5.y << 3; - if (cdhd->v5.flags == 0x80) { - od->parentstate = 1; - } else { - od->parentstate = (cdhd->v5.flags & 0xF); - } - od->parent = cdhd->v5.parent; - od->walk_x = READ_LE_UINT16(&cdhd->v5.walk_x); - od->walk_y = READ_LE_UINT16(&cdhd->v5.walk_y); - od->actordir = cdhd->v5.actordir; - } - } else { od->parent = cdhd->v7.parent; od->parentstate = cdhd->v7.parentstate; @@ -610,7 +600,38 @@ void Scumm::setupRoomObject(ObjectData *od, byte *room) od->height = READ_LE_UINT16(&imhd->v7.height); od->actordir = READ_LE_UINT16(&imhd->v7.actordir); + } else if (_features & GF_AFTER_V6) { + od->obj_nr = READ_LE_UINT16(&(cdhd->v6.obj_id)); + + od->width = READ_LE_UINT16(&cdhd->v6.w); + od->height = READ_LE_UINT16(&cdhd->v6.h); + od->x_pos = ((int16)READ_LE_UINT16(&cdhd->v6.x)); + od->y_pos = ((int16)READ_LE_UINT16(&cdhd->v6.y)); + if (cdhd->v6.flags == 0x80) { + od->parentstate = 1; + } else { + od->parentstate = (cdhd->v6.flags & 0xF); + } + od->parent = cdhd->v6.parent; + od->actordir = cdhd->v6.actordir; + } else { + od->obj_nr = READ_LE_UINT16(&(cdhd->v5.obj_id)); + + od->width = cdhd->v5.w << 3; + od->height = cdhd->v5.h << 3; + od->x_pos = cdhd->v5.x << 3; + od->y_pos = cdhd->v5.y << 3; + if (cdhd->v5.flags == 0x80) { + od->parentstate = 1; + } else { + od->parentstate = (cdhd->v5.flags & 0xF); + } + od->parent = cdhd->v5.parent; + od->walk_x = READ_LE_UINT16(&cdhd->v5.walk_x); + od->walk_y = READ_LE_UINT16(&cdhd->v5.walk_y); + od->actordir = cdhd->v5.actordir; } + od->fl_object_index = 0; } @@ -810,7 +831,8 @@ void Scumm::addObjectToInventory(uint obj, uint room) memcpy(getResourceAddress(rtInventory, slot), obcdptr, size); } -CHECK_HEAP} + CHECK_HEAP +} void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint room) { @@ -837,7 +859,9 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint roomhdr = (RoomHeader *)findResourceData(MKID('RMHD'), roomptr); - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) + numobj = READ_LE_UINT32(&(roomhdr->v8.numObjects)); + else if (_features & GF_AFTER_V7) numobj = READ_LE_UINT16(&(roomhdr->v7.numObjects)); else numobj = READ_LE_UINT16(&(roomhdr->old.numObjects)); @@ -864,7 +888,11 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint } } else { cdhd = (CodeHeader *)findResourceData(MKID('CDHD'), obcdptr); - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) + // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string + id2 = 0; +// id2 = READ_LE_UINT32(&(cdhd->v8.obj_id)); + else if (_features & GF_AFTER_V7) id2 = READ_LE_UINT16(&(cdhd->v7.obj_id)); else if (_features & GF_AFTER_V6) id2 = READ_LE_UINT16(&(cdhd->v6.obj_id)); @@ -900,7 +928,11 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint break; } } else { - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) + // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string + id3 = 0; +// id3 = READ_LE_UINT32(&imhd->v8.obj_id); + else if (_features & GF_AFTER_V7) id3 = READ_LE_UINT16(&imhd->v7.obj_id); else id3 = READ_LE_UINT16(&imhd->old.obj_id); @@ -1111,20 +1143,21 @@ void Scumm::setCursorImg(uint img, uint room, uint imgindex) findObjectInRoom(&foir, foCodeHeader | foImageHeader | foCheckAlreadyLoaded, img, room); - if (_features & GF_AFTER_V7) + if (_features & GF_AFTER_V8) { + setCursorHotspot2(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) >> 3; + h = READ_LE_UINT32(&foir.imhd->v8.height) >> 3; + } else if (_features & GF_AFTER_V7) { setCursorHotspot2(READ_LE_UINT16(&foir.imhd->v7.hotspot[0].x), - READ_LE_UINT16(&foir.imhd->v7.hotspot[0].y)); - else + READ_LE_UINT16(&foir.imhd->v7.hotspot[0].y)); + w = READ_LE_UINT16(&foir.imhd->v7.width) >> 3; + h = READ_LE_UINT16(&foir.imhd->v7.height) >> 3; + } else { setCursorHotspot2(READ_LE_UINT16(&foir.imhd->old.hotspot[0].x), - READ_LE_UINT16(&foir.imhd->old.hotspot[0].y)); - - - if (!(_features & GF_AFTER_V7)) { + READ_LE_UINT16(&foir.imhd->old.hotspot[0].y)); w = READ_LE_UINT16(&foir.cdhd->v6.w) >> 3; h = READ_LE_UINT16(&foir.cdhd->v6.h) >> 3; - } else { - w = READ_LE_UINT16(&foir.imhd->v7.width) >> 3; - h = READ_LE_UINT16(&foir.imhd->v7.height) >> 3; } dataptr = findResource(IMxx_tags[imgindex], foir.obim); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index f782041223..f829eba34e 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -727,7 +727,10 @@ void Scumm::initRoomSubBlocks() rmhd = (RoomHeader *)findResourceData(MKID('RMHD'), roomptr); - if (_features & GF_AFTER_V7) { + if (_features & GF_AFTER_V8) { + _scrWidth = READ_LE_UINT32(&(rmhd->v8.width)); + _scrHeight = READ_LE_UINT32(&(rmhd->v8.height)); + } else if (_features & GF_AFTER_V7) { _scrWidth = READ_LE_UINT16(&(rmhd->v7.width)); _scrHeight = READ_LE_UINT16(&(rmhd->v7.height)); } else { @@ -747,7 +750,7 @@ void Scumm::initRoomSubBlocks() if (ptr) { _EXCD_offs = ptr - roomptr; #ifdef DUMP_SCRIPTS - dumpResource("exit-", _roomResource, ptr - _resourceHeaderSize); + dumpResource("exit-", _roomResource, ptr - _resourceHeaderSize); #endif } @@ -755,7 +758,7 @@ void Scumm::initRoomSubBlocks() if (ptr) { _ENCD_offs = ptr - roomptr; #ifdef DUMP_SCRIPTS - dumpResource("entry-", _roomResource, ptr - _resourceHeaderSize); + dumpResource("entry-", _roomResource, ptr - _resourceHeaderSize); #endif } @@ -804,14 +807,27 @@ void Scumm::initRoomSubBlocks() ptr = findResourceData(MKID('SCAL'), roomptr); if (ptr) { offs = ptr - roomptr; - for (i = 1; i < _maxScaleTable; i++, offs += 8) { - int a = READ_LE_UINT16(roomptr + offs); - int b = READ_LE_UINT16(roomptr + offs + 2); - int c = READ_LE_UINT16(roomptr + offs + 4); - int d = READ_LE_UINT16(roomptr + offs + 6); - if (a || b || c || d) { - setScaleItem(i, b, a, d, c); - roomptr = getResourceAddress(rtRoom, _roomResource); + if (_features & GF_AFTER_V7) { + 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); + } + } + } else { + for (i = 1; i < _maxScaleTable; i++, offs += 8) { + int a = READ_LE_UINT16(roomptr + offs); + int b = READ_LE_UINT16(roomptr + offs + 2); + int c = READ_LE_UINT16(roomptr + offs + 4); + int d = READ_LE_UINT16(roomptr + offs + 6); + if (a || b || c || d) { + setScaleItem(i, b, a, d, c); + roomptr = getResourceAddress(rtRoom, _roomResource); + } } } } @@ -839,7 +855,11 @@ void Scumm::initRoomSubBlocks() ptr += _resourceHeaderSize; /* skip tag & size */ - if (_features & GF_AFTER_V7) { + if (_features & GF_AFTER_V8) { + id = READ_LE_UINT32(ptr); + checkRange(NUM_LOCALSCRIPT + _numGlobalScripts, _numGlobalScripts, id, "Invalid local script %d"); + _localScriptList[id - _numGlobalScripts] = ptr + 4 - roomptr; + } else if (_features & GF_AFTER_V7) { id = READ_LE_UINT16(ptr); checkRange(NUM_LOCALSCRIPT + _numGlobalScripts, _numGlobalScripts, id, "Invalid local script %d"); _localScriptList[id - _numGlobalScripts] = ptr + 2 - roomptr; -- cgit v1.2.3