2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-04-10 01:23:33 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-10 01:23:33 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-11-13 19:41:35 +00:00
|
|
|
#include "common/system.h"
|
2005-04-10 01:23:33 +00:00
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/boxes.h"
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/intern_he.h"
|
2006-02-04 12:11:10 +00:00
|
|
|
#endif
|
2005-04-10 01:23:33 +00:00
|
|
|
#include "scumm/object.h"
|
|
|
|
#include "scumm/resource.h"
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v3.h"
|
2005-04-10 01:23:33 +00:00
|
|
|
#include "scumm/sound.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
#include "scumm/util.h"
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
namespace Scumm {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start a 'scene' by loading the specified room with the given main actor.
|
|
|
|
* The actor is placed next to the object indicated by objectNr.
|
|
|
|
*/
|
|
|
|
void ScummEngine::startScene(int room, Actor *a, int objectNr) {
|
|
|
|
int i, where;
|
|
|
|
|
|
|
|
debugC(DEBUG_GENERAL, "Loading room %d", room);
|
|
|
|
|
|
|
|
stopTalk();
|
|
|
|
|
|
|
|
fadeOut(_switchRoomEffect2);
|
|
|
|
_newEffect = _switchRoomEffect;
|
|
|
|
|
2009-09-11 10:13:54 +00:00
|
|
|
ScriptSlot *ss = &vm.slot[_currentScript];
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
if (_currentScript != 0xFF) {
|
|
|
|
if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (ss->cutsceneOverride && _game.version >= 5)
|
2005-04-10 01:23:33 +00:00
|
|
|
error("Object %d stopped with active cutscene/override in exit", ss->number);
|
|
|
|
|
|
|
|
nukeArrays(_currentScript);
|
|
|
|
_currentScript = 0xFF;
|
|
|
|
} else if (ss->where == WIO_LOCAL) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (ss->cutsceneOverride && _game.version >= 5)
|
2005-04-10 01:23:33 +00:00
|
|
|
error("Script %d stopped with active cutscene/override in exit", ss->number);
|
|
|
|
|
|
|
|
nukeArrays(_currentScript);
|
|
|
|
_currentScript = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-23 09:53:56 +00:00
|
|
|
if (VAR_NEW_ROOM != 0xFF)
|
|
|
|
VAR(VAR_NEW_ROOM) = room;
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
runExitScript();
|
|
|
|
|
|
|
|
killScriptsAndResources();
|
2010-04-04 09:36:10 +00:00
|
|
|
if (_game.version >= 4 && _game.heversion <= 62)
|
2005-04-10 01:23:33 +00:00
|
|
|
stopCycle(0);
|
2006-02-28 23:02:15 +00:00
|
|
|
|
|
|
|
if (_game.id == GID_SAMNMAX) {
|
|
|
|
// WORKAROUND bug #85373 SAM: Overlapping music at Bigfoot convention
|
|
|
|
// Added sound queue processing between execution of exit
|
2007-09-19 08:40:12 +00:00
|
|
|
// script and entry script. In the case of this bug, the
|
|
|
|
// entry script required that the iMuse state be fully up
|
2009-09-11 10:13:54 +00:00
|
|
|
// to date, including last-moment changes from the previous
|
2006-02-28 23:02:15 +00:00
|
|
|
// exit script.
|
|
|
|
_sound->processSound();
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-28 22:34:56 +00:00
|
|
|
clearDrawQueues();
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
// For HE80+ games
|
|
|
|
for (i = 0; i < _numRoomVariables; i++)
|
|
|
|
_roomVars[i] = 0;
|
|
|
|
nukeArrays(0xFF);
|
|
|
|
|
|
|
|
for (i = 1; i < _numActors; i++) {
|
2006-12-25 15:03:36 +00:00
|
|
|
_actors[i]->hideActor();
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2005-04-10 01:23:33 +00:00
|
|
|
// Set the shadow palette(s) to all black. This fixes
|
|
|
|
// bug #795940, and actually makes some sense (after all,
|
|
|
|
// shadows tend to be rather black, don't they? ;-)
|
|
|
|
memset(_shadowPalette, 0, NUM_SHADOW_PALETTE * 256);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
_roomPalette[i] = i;
|
|
|
|
if (_shadowPalette)
|
|
|
|
_shadowPalette[i] = i;
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_SMALL_HEADER)
|
2005-04-10 01:23:33 +00:00
|
|
|
setDirtyColors(0, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
VAR(VAR_ROOM) = room;
|
|
|
|
_fullRedraw = true;
|
|
|
|
|
2011-05-12 13:03:58 +00:00
|
|
|
_res->increaseResourceCounters();
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
_currentRoom = room;
|
|
|
|
VAR(VAR_ROOM) = room;
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (room >= 0x80 && _game.version < 7 && _game.heversion <= 71)
|
2005-04-10 01:23:33 +00:00
|
|
|
_roomResource = _resourceMapper[room & 0x7F];
|
|
|
|
else
|
|
|
|
_roomResource = room;
|
|
|
|
|
|
|
|
if (VAR_ROOM_RESOURCE != 0xFF)
|
|
|
|
VAR(VAR_ROOM_RESOURCE) = _roomResource;
|
|
|
|
|
|
|
|
if (room != 0)
|
|
|
|
ensureResourceLoaded(rtRoom, room);
|
|
|
|
|
|
|
|
clearRoomObjects();
|
|
|
|
|
|
|
|
if (_currentRoom == 0) {
|
|
|
|
_ENCD_offs = _EXCD_offs = 0;
|
|
|
|
_numObjectsInRoom = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
setupRoomSubBlocks();
|
|
|
|
resetRoomSubBlocks();
|
2005-04-10 01:23:33 +00:00
|
|
|
|
2005-04-26 10:58:49 +00:00
|
|
|
initBGBuffers(_roomHeight);
|
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
resetRoomObjects();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-10 01:23:33 +00:00
|
|
|
if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) {
|
|
|
|
VAR(VAR_ROOM_WIDTH) = _roomWidth;
|
|
|
|
VAR(VAR_ROOM_HEIGHT) = _roomHeight;
|
|
|
|
}
|
|
|
|
|
2006-03-14 12:06:37 +00:00
|
|
|
if (VAR_CAMERA_MIN_X != 0xFF)
|
|
|
|
VAR(VAR_CAMERA_MIN_X) = _screenWidth / 2;
|
|
|
|
if (VAR_CAMERA_MAX_X != 0xFF)
|
|
|
|
VAR(VAR_CAMERA_MAX_X) = _roomWidth - (_screenWidth / 2);
|
2005-04-10 01:23:33 +00:00
|
|
|
|
2007-02-10 02:05:59 +00:00
|
|
|
if (_game.version >= 7) {
|
2005-04-10 01:23:33 +00:00
|
|
|
VAR(VAR_CAMERA_MIN_Y) = _screenHeight / 2;
|
|
|
|
VAR(VAR_CAMERA_MAX_Y) = _roomHeight - (_screenHeight / 2);
|
|
|
|
setCameraAt(_screenWidth / 2, _screenHeight / 2);
|
|
|
|
} else {
|
|
|
|
camera._mode = kNormalCameraMode;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version > 2)
|
2005-04-10 01:23:33 +00:00
|
|
|
camera._cur.x = camera._dest.x = _screenWidth / 2;
|
|
|
|
camera._cur.y = camera._dest.y = _screenHeight / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_roomResource == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 5 && a) {
|
2005-04-10 01:23:33 +00:00
|
|
|
where = whereIsObject(objectNr);
|
|
|
|
if (where != WIO_ROOM && where != WIO_FLOBJECT)
|
|
|
|
error("startScene: Object %d is not in room %d", objectNr,
|
|
|
|
_currentRoom);
|
|
|
|
int x, y, dir;
|
|
|
|
getObjectXYPos(objectNr, x, y, dir);
|
|
|
|
a->putActor(x, y, _currentRoom);
|
|
|
|
a->setDirection(dir + 180);
|
|
|
|
a->stopActorMoving();
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_SAMNMAX) {
|
2006-11-19 00:39:48 +00:00
|
|
|
camera._cur.x = camera._dest.x = a->getPos().x;
|
|
|
|
setCameraAt(a->getPos().x, a->getPos().y);
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showActors();
|
|
|
|
|
|
|
|
_egoPositioned = false;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2010-10-05 19:04:52 +00:00
|
|
|
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
towns_resetPalCycleFields();
|
2010-10-05 19:04:52 +00:00
|
|
|
#endif
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
|
2005-04-10 01:23:33 +00:00
|
|
|
runEntryScript();
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version >= 1 && _game.version <= 2) {
|
2005-04-10 01:23:33 +00:00
|
|
|
runScript(5, 0, 0, 0);
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.version >= 5 && _game.version <= 6) {
|
2005-04-10 01:23:33 +00:00
|
|
|
if (a && !_egoPositioned) {
|
|
|
|
int x, y;
|
|
|
|
getObjectXYPos(objectNr, x, y);
|
|
|
|
a->putActor(x, y, _currentRoom);
|
|
|
|
a->_moving = 0;
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.version >= 7) {
|
2005-04-10 01:23:33 +00:00
|
|
|
if (camera._follows) {
|
|
|
|
a = derefActor(camera._follows, "startScene: follows");
|
2006-11-19 00:39:48 +00:00
|
|
|
setCameraAt(a->getPos().x, a->getPos().y);
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_doEffect = true;
|
2007-11-13 19:41:35 +00:00
|
|
|
|
|
|
|
// Hint the backend about the virtual keyboard during copy protection screens
|
|
|
|
if (_game.id == GID_MONKEY2) {
|
|
|
|
if (_system->getFeatureState(OSystem::kFeatureVirtualKeyboard)) {
|
|
|
|
if (room != 108)
|
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
|
|
|
} else if (room == 108)
|
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
|
|
|
} else if (_game.id == GID_MONKEY_EGA) { // this is my estimation that the room code is 90 (untested)
|
|
|
|
if (_system->getFeatureState(OSystem::kFeatureVirtualKeyboard)) {
|
|
|
|
if (room != 90)
|
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
|
|
|
} else if (room == 90)
|
|
|
|
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
|
|
|
|
}
|
|
|
|
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 10:58:49 +00:00
|
|
|
/**
|
|
|
|
* Init some static room data after a room has been loaded.
|
|
|
|
* E.g. the room dimension, the offset to the graphics data, the room scripts,
|
2005-07-30 21:11:48 +00:00
|
|
|
* the offset to the room palette and other things which won't be changed
|
2005-04-26 10:58:49 +00:00
|
|
|
* late on.
|
|
|
|
* So it is possible to call this after loading a savegame.
|
|
|
|
*/
|
2006-04-29 16:24:39 +00:00
|
|
|
void ScummEngine::setupRoomSubBlocks() {
|
2005-04-10 01:23:33 +00:00
|
|
|
int i;
|
|
|
|
const byte *ptr;
|
|
|
|
byte *roomptr, *searchptr, *roomResPtr = 0;
|
|
|
|
const RoomHeader *rmhd;
|
|
|
|
|
|
|
|
_ENCD_offs = 0;
|
|
|
|
_EXCD_offs = 0;
|
|
|
|
_EPAL_offs = 0;
|
|
|
|
_CLUT_offs = 0;
|
|
|
|
_PALS_offs = 0;
|
|
|
|
|
|
|
|
// Determine the room and room script base address
|
|
|
|
roomResPtr = roomptr = getResourceAddress(rtRoom, _roomResource);
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8)
|
2005-04-10 01:23:33 +00:00
|
|
|
roomResPtr = getResourceAddress(rtRoomScripts, _roomResource);
|
|
|
|
if (!roomptr || !roomResPtr)
|
|
|
|
error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Determine the room dimensions (width/height)
|
|
|
|
//
|
2011-04-12 14:53:15 +00:00
|
|
|
rmhd = (const RoomHeader *)findResourceData(MKTAG('R','M','H','D'), roomptr);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_roomWidth = READ_LE_UINT32(&(rmhd->v8.width));
|
|
|
|
_roomHeight = READ_LE_UINT32(&(rmhd->v8.height));
|
2005-04-10 01:42:00 +00:00
|
|
|
_numObjectsInRoom = (byte)READ_LE_UINT32(&(rmhd->v8.numObjects));
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.version == 7) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_roomWidth = READ_LE_UINT16(&(rmhd->v7.width));
|
|
|
|
_roomHeight = READ_LE_UINT16(&(rmhd->v7.height));
|
2005-04-10 01:42:00 +00:00
|
|
|
_numObjectsInRoom = (byte)READ_LE_UINT16(&(rmhd->v7.numObjects));
|
2005-04-10 01:23:33 +00:00
|
|
|
} else {
|
|
|
|
_roomWidth = READ_LE_UINT16(&(rmhd->old.width));
|
|
|
|
_roomHeight = READ_LE_UINT16(&(rmhd->old.height));
|
2005-04-10 01:42:00 +00:00
|
|
|
_numObjectsInRoom = (byte)READ_LE_UINT16(&(rmhd->old.numObjects));
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Find the room image data
|
|
|
|
//
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_IM00_offs = getObjectImage(roomptr, 1) - roomptr;
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.features & GF_SMALL_HEADER) {
|
2011-04-12 14:53:15 +00:00
|
|
|
_IM00_offs = findResourceData(MKTAG('I','M','0','0'), roomptr) - roomptr;
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.heversion >= 70) {
|
2005-04-10 01:23:33 +00:00
|
|
|
byte *roomImagePtr = getResourceAddress(rtRoomImage, _roomResource);
|
2011-04-12 14:53:15 +00:00
|
|
|
_IM00_offs = findResource(MKTAG('I','M','0','0'), roomImagePtr) - roomImagePtr;
|
2005-04-10 01:23:33 +00:00
|
|
|
} else {
|
2011-04-12 14:53:15 +00:00
|
|
|
_IM00_offs = findResource(MKTAG('I','M','0','0'), findResource(MKTAG('R','M','I','M'), roomptr)) - roomptr;
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Look for an exit script
|
|
|
|
//
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('E','X','C','D'), roomResPtr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr)
|
|
|
|
_EXCD_offs = ptr - roomResPtr;
|
|
|
|
if (_dumpScripts && _EXCD_offs)
|
|
|
|
dumpResource("exit-", _roomResource, roomResPtr + _EXCD_offs - _resourceHeaderSize, -1);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Look for an entry script
|
|
|
|
//
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('E','N','C','D'), roomResPtr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr)
|
|
|
|
_ENCD_offs = ptr - roomResPtr;
|
|
|
|
if (_dumpScripts && _ENCD_offs)
|
|
|
|
dumpResource("entry-", _roomResource, roomResPtr + _ENCD_offs - _resourceHeaderSize, -1);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup local scripts
|
|
|
|
//
|
|
|
|
|
|
|
|
// Determine the room script base address
|
|
|
|
roomResPtr = roomptr = getResourceAddress(rtRoom, _roomResource);
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8)
|
2005-04-10 01:23:33 +00:00
|
|
|
roomResPtr = getResourceAddress(rtRoomScripts, _roomResource);
|
|
|
|
searchptr = roomResPtr;
|
|
|
|
|
|
|
|
memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_SMALL_HEADER) {
|
2005-04-10 01:23:33 +00:00
|
|
|
ResourceIterator localScriptIterator(searchptr, true);
|
2011-04-12 14:53:15 +00:00
|
|
|
while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) {
|
2005-04-10 01:23:33 +00:00
|
|
|
int id = 0;
|
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
|
|
|
id = ptr[0];
|
|
|
|
|
|
|
|
if (_dumpScripts) {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
dumpResource(buf, id, ptr - _resourceHeaderSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 1 - roomptr;
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.heversion >= 90) {
|
2005-04-10 01:23:33 +00:00
|
|
|
ResourceIterator localScriptIterator2(searchptr, false);
|
2011-04-12 14:53:15 +00:00
|
|
|
while ((ptr = localScriptIterator2.findNext(MKTAG('L','S','C','2'))) != NULL) {
|
2005-04-10 01:23:33 +00:00
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
|
|
|
|
|
|
|
id = READ_LE_UINT32(ptr);
|
|
|
|
|
2006-09-16 13:38:43 +00:00
|
|
|
assertRange(_numGlobalScripts, id, _numLocalScripts + _numGlobalScripts, "local script");
|
2005-04-10 01:23:33 +00:00
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 4 - roomResPtr;
|
|
|
|
|
|
|
|
if (_dumpScripts) {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
dumpResource(buf, id, ptr - _resourceHeaderSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceIterator localScriptIterator(searchptr, false);
|
2011-04-12 14:53:15 +00:00
|
|
|
while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) {
|
2005-04-10 01:23:33 +00:00
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
|
|
|
|
|
|
|
id = ptr[0];
|
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 1 - roomResPtr;
|
|
|
|
|
|
|
|
if (_dumpScripts) {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
dumpResource(buf, id, ptr - _resourceHeaderSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ResourceIterator localScriptIterator(searchptr, false);
|
2011-04-12 14:53:15 +00:00
|
|
|
while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) {
|
2005-04-10 01:23:33 +00:00
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8) {
|
2005-04-10 01:23:33 +00:00
|
|
|
id = READ_LE_UINT32(ptr);
|
2006-09-16 13:38:43 +00:00
|
|
|
assertRange(_numGlobalScripts, id, _numLocalScripts + _numGlobalScripts, "local script");
|
2005-04-10 01:23:33 +00:00
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 4 - roomResPtr;
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.version == 7) {
|
2005-04-10 01:23:33 +00:00
|
|
|
id = READ_LE_UINT16(ptr);
|
2006-09-16 13:38:43 +00:00
|
|
|
assertRange(_numGlobalScripts, id, _numLocalScripts + _numGlobalScripts, "local script");
|
2005-04-10 01:23:33 +00:00
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 2 - roomResPtr;
|
|
|
|
} else {
|
|
|
|
id = ptr[0];
|
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = ptr + 1 - roomResPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_dumpScripts) {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
dumpResource(buf, id, ptr - _resourceHeaderSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Locate the EGA palette (currently unused).
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('E','P','A','L'), roomptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr)
|
|
|
|
_EPAL_offs = ptr - roomptr;
|
|
|
|
|
|
|
|
// Locate the standard room palette (for V3-V5 games).
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('C','L','U','T'), roomptr);
|
2005-04-26 14:24:29 +00:00
|
|
|
if (ptr)
|
2005-04-10 01:23:33 +00:00
|
|
|
_CLUT_offs = ptr - roomptr;
|
|
|
|
|
|
|
|
// Locate the standard room palettes (for V6+ games).
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 6) {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResource(MKTAG('P','A','L','S'), roomptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr) {
|
|
|
|
_PALS_offs = ptr - roomptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transparent color
|
2005-05-11 13:02:40 +00:00
|
|
|
byte trans;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8)
|
2005-05-11 13:02:40 +00:00
|
|
|
trans = (byte)READ_LE_UINT32(&(rmhd->v8.transparency));
|
2005-04-10 01:23:33 +00:00
|
|
|
else {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('T','R','N','S'), roomptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr)
|
2005-05-11 13:02:40 +00:00
|
|
|
trans = ptr[0];
|
2005-04-10 01:23:33 +00:00
|
|
|
else
|
2005-05-11 13:02:40 +00:00
|
|
|
trans = 255;
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Actor Palette in HE 70 games
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.heversion == 70) {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('R','E','M','P'), roomptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr) {
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
_HEV7ActorPalette[i] = *ptr++;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
_HEV7ActorPalette[i] = i;
|
|
|
|
}
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
|
|
|
|
2006-02-05 15:48:46 +00:00
|
|
|
// WORKAROUND bug #1074444: The dreaded DOTT "Can't get teeth" bug
|
|
|
|
// makes it impossible to go on playing w/o cheating in some way.
|
|
|
|
// It's not quite clear what causes it, but the effect is that object
|
|
|
|
// 182, the teeth, are still in class 32 (kObjectClassUntouchable),
|
|
|
|
// when they shouldn't be. Luckily, bitvar69 is set to 1 if and only if
|
|
|
|
// the teeth are trapped and have not yet been taken by the player. So
|
|
|
|
// we can make use of that fact to fix the object class of obj 182.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_TENTACLE && _roomResource == 26 && readVar(0x8000 + 69)
|
2006-02-05 15:48:46 +00:00
|
|
|
&& getClass(182, kObjectClassUntouchable)) {
|
|
|
|
putClass(182, kObjectClassUntouchable, 0);
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-09-18 22:22:35 +00:00
|
|
|
_gdi->roomChanged(roomptr);
|
|
|
|
_gdi->setTransparentColor(trans);
|
2005-04-26 10:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init some dynamic room data after a room has been loaded.
|
|
|
|
* E.g. the initial box data is loaded, the initial palette is set etc.
|
|
|
|
* All of the things setup in here can be modified later on by scripts.
|
|
|
|
* So it is not appropriate to call it after loading a savegame.
|
|
|
|
*/
|
2006-04-29 16:24:39 +00:00
|
|
|
void ScummEngine::resetRoomSubBlocks() {
|
2011-05-13 12:12:00 +00:00
|
|
|
ResId i;
|
2005-04-26 10:58:49 +00:00
|
|
|
const byte *ptr;
|
|
|
|
byte *roomptr;
|
|
|
|
|
|
|
|
// Determine the room and room script base address
|
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
if (!roomptr)
|
|
|
|
error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Load box data
|
|
|
|
//
|
|
|
|
memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
|
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->nukeResource(rtMatrix, 1);
|
|
|
|
_res->nukeResource(rtMatrix, 2);
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_SMALL_HEADER) {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('B','O','X','D'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
if (ptr) {
|
|
|
|
byte numOfBoxes = *ptr;
|
|
|
|
int size;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 3)
|
2005-04-26 10:58:49 +00:00
|
|
|
size = numOfBoxes * SIZEOF_BOX_V3 + 1;
|
|
|
|
else
|
|
|
|
size = numOfBoxes * SIZEOF_BOX + 1;
|
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 2, size);
|
2005-04-26 10:58:49 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
|
|
|
|
ptr += size;
|
|
|
|
|
|
|
|
size = getResourceDataSize(ptr - size - _resourceHeaderSize) - size;
|
|
|
|
if (size > 0) { // do this :)
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 1, size);
|
2005-04-26 10:58:49 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('B','O','X','D'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
if (ptr) {
|
|
|
|
int size = getResourceDataSize(ptr);
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 2, size);
|
2005-04-26 10:58:49 +00:00
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('B','O','X','D'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
|
|
|
|
}
|
|
|
|
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('B','O','X','M'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
if (ptr) {
|
|
|
|
int size = getResourceDataSize(ptr);
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 1, size);
|
2005-04-26 10:58:49 +00:00
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('B','O','X','M'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Load scale data
|
|
|
|
//
|
2011-05-13 12:48:01 +00:00
|
|
|
for (i = 1; i < _res->_types[rtScaleTable].size(); i++)
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->nukeResource(rtScaleTable, i);
|
2005-04-26 10:58:49 +00:00
|
|
|
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('S','C','A','L'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
if (ptr) {
|
|
|
|
int s1, s2, y1, y2;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8) {
|
2011-05-13 12:48:01 +00:00
|
|
|
for (i = 1; i < _res->_types[rtScaleTable].size(); i++, ptr += 16) {
|
2005-04-26 10:58:49 +00:00
|
|
|
s1 = READ_LE_UINT32(ptr);
|
|
|
|
y1 = READ_LE_UINT32(ptr + 4);
|
|
|
|
s2 = READ_LE_UINT32(ptr + 8);
|
|
|
|
y2 = READ_LE_UINT32(ptr + 12);
|
|
|
|
setScaleSlot(i, 0, y1, s1, 0, y2, s2);
|
|
|
|
}
|
|
|
|
} else {
|
2011-05-13 12:48:01 +00:00
|
|
|
for (i = 1; i < _res->_types[rtScaleTable].size(); i++, ptr += 8) {
|
2005-04-26 10:58:49 +00:00
|
|
|
s1 = READ_LE_UINT16(ptr);
|
|
|
|
y1 = READ_LE_UINT16(ptr + 2);
|
|
|
|
s2 = READ_LE_UINT16(ptr + 4);
|
|
|
|
y2 = READ_LE_UINT16(ptr + 6);
|
|
|
|
if (s1 || y1 || s2 || y2) {
|
|
|
|
setScaleSlot(i, 0, y1, s1, 0, y2, s2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Color cycling
|
|
|
|
// HE 7.0 games load resources but don't use them.
|
2010-04-04 09:36:10 +00:00
|
|
|
if (_game.version >= 4 && _game.heversion <= 62) {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('C','Y','C','L'), roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
if (ptr) {
|
|
|
|
initCycl(ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2005-04-10 01:23:33 +00:00
|
|
|
// Polygons in HE 80+ games
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.heversion >= 80) {
|
2011-04-12 14:53:15 +00:00
|
|
|
ptr = findResourceData(MKTAG('P','O','L','D'), roomptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
if (ptr) {
|
2007-12-27 11:40:29 +00:00
|
|
|
((ScummEngine_v71he *)this)->_wiz->polygonLoad(ptr);
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-14 14:06:37 +00:00
|
|
|
#endif
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
if (_PALS_offs || _CLUT_offs)
|
2006-11-04 22:59:56 +00:00
|
|
|
setCurrentPalette(0);
|
2005-04-10 01:23:33 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 10:58:49 +00:00
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
void ScummEngine_v3old::setupRoomSubBlocks() {
|
2005-04-10 01:23:33 +00:00
|
|
|
const byte *ptr;
|
2011-03-29 19:55:21 +00:00
|
|
|
byte *roomptr;
|
2005-04-10 01:23:33 +00:00
|
|
|
const RoomHeader *rmhd;
|
|
|
|
|
|
|
|
_ENCD_offs = 0;
|
|
|
|
_EXCD_offs = 0;
|
|
|
|
_EPAL_offs = 0;
|
|
|
|
_CLUT_offs = 0;
|
|
|
|
_PALS_offs = 0;
|
|
|
|
|
|
|
|
// Determine the room and room script base address
|
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
if (!roomptr)
|
|
|
|
error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Determine the room dimensions (width/height)
|
|
|
|
//
|
|
|
|
rmhd = (const RoomHeader *)(roomptr + 4);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version <= 1) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.platform == Common::kPlatformNES) {
|
2005-04-10 22:43:46 +00:00
|
|
|
_roomWidth = READ_LE_UINT16(&(rmhd->old.width)) * 8;
|
|
|
|
_roomHeight = READ_LE_UINT16(&(rmhd->old.height)) * 8;
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
// HACK: To let our code work normal with narrow rooms we
|
|
|
|
// adjust width. It will render garbage on right edge but we do
|
|
|
|
// not render it anyway
|
|
|
|
if (_roomWidth < 32 * 8)
|
|
|
|
_roomWidth = 32 * 8;
|
|
|
|
} else {
|
|
|
|
_roomWidth = roomptr[4] * 8;
|
|
|
|
_roomHeight = roomptr[5] * 8;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_roomWidth = READ_LE_UINT16(&(rmhd->old.width));
|
|
|
|
_roomHeight = READ_LE_UINT16(&(rmhd->old.height));
|
|
|
|
}
|
2005-04-10 01:42:00 +00:00
|
|
|
_numObjectsInRoom = roomptr[20];
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Find the room image data
|
|
|
|
//
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version <= 1) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_IM00_offs = 0;
|
|
|
|
} else {
|
|
|
|
_IM00_offs = READ_LE_UINT16(roomptr + 0x0A);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Look for an exit script
|
|
|
|
//
|
|
|
|
int EXCD_len = -1;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_EXCD_offs = READ_LE_UINT16(roomptr + 0x18);
|
|
|
|
EXCD_len = READ_LE_UINT16(roomptr + 0x1A) - _EXCD_offs + _resourceHeaderSize; // HACK
|
|
|
|
} else {
|
|
|
|
_EXCD_offs = READ_LE_UINT16(roomptr + 0x19);
|
|
|
|
EXCD_len = READ_LE_UINT16(roomptr + 0x1B) - _EXCD_offs + _resourceHeaderSize; // HACK
|
|
|
|
}
|
|
|
|
if (_dumpScripts && _EXCD_offs)
|
|
|
|
dumpResource("exit-", _roomResource, roomptr + _EXCD_offs - _resourceHeaderSize, EXCD_len);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Look for an entry script
|
|
|
|
//
|
|
|
|
int ENCD_len = -1;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2) {
|
2005-04-10 01:23:33 +00:00
|
|
|
_ENCD_offs = READ_LE_UINT16(roomptr + 0x1A);
|
|
|
|
ENCD_len = READ_LE_UINT16(roomptr) - _ENCD_offs + _resourceHeaderSize; // HACK
|
|
|
|
} else {
|
|
|
|
_ENCD_offs = READ_LE_UINT16(roomptr + 0x1B);
|
|
|
|
// FIXME - the following is a hack which assumes that immediately after
|
|
|
|
// the entry script the first local script follows.
|
|
|
|
int num_objects = *(roomptr + 20);
|
|
|
|
int num_sounds = *(roomptr + 23);
|
|
|
|
int num_scripts = *(roomptr + 24);
|
|
|
|
ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
|
|
|
|
ENCD_len = READ_LE_UINT16(ptr + 1) - _ENCD_offs + _resourceHeaderSize; // HACK
|
|
|
|
}
|
|
|
|
if (_dumpScripts && _ENCD_offs)
|
|
|
|
dumpResource("entry-", _roomResource, roomptr + _ENCD_offs - _resourceHeaderSize, ENCD_len);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup local scripts
|
|
|
|
//
|
|
|
|
|
|
|
|
// Determine the room script base address
|
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
|
|
|
|
memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
|
|
|
|
|
|
|
|
int num_objects = *(roomptr + 20);
|
|
|
|
int num_sounds;
|
|
|
|
int num_scripts;
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2) {
|
2005-04-10 01:23:33 +00:00
|
|
|
num_sounds = *(roomptr + 22);
|
|
|
|
num_scripts = *(roomptr + 23);
|
|
|
|
ptr = roomptr + 28 + num_objects * 4;
|
|
|
|
while (num_sounds--)
|
|
|
|
loadResource(rtSound, *ptr++);
|
|
|
|
while (num_scripts--)
|
|
|
|
loadResource(rtScript, *ptr++);
|
2006-02-20 16:51:30 +00:00
|
|
|
} else /* if (_game.version == 3) */ {
|
2005-04-10 01:23:33 +00:00
|
|
|
num_sounds = *(roomptr + 23);
|
|
|
|
num_scripts = *(roomptr + 24);
|
|
|
|
ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
|
|
|
|
while (*ptr) {
|
|
|
|
int id = *ptr;
|
|
|
|
|
|
|
|
_localScriptOffsets[id - _numGlobalScripts] = READ_LE_UINT16(ptr + 1);
|
|
|
|
ptr += 3;
|
|
|
|
|
|
|
|
if (_dumpScripts) {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
|
|
|
|
// HACK: to determine the sizes of the local scripts, we assume that
|
|
|
|
// a) their order in the data file is the same as in the index
|
|
|
|
// b) the last script at the same time is the last item in the room "header"
|
|
|
|
int len = - (int)_localScriptOffsets[id - _numGlobalScripts] + _resourceHeaderSize;
|
|
|
|
if (*ptr)
|
|
|
|
len += READ_LE_UINT16(ptr + 1);
|
|
|
|
else
|
|
|
|
len += READ_LE_UINT16(roomptr);
|
|
|
|
dumpResource(buf, id, roomptr + _localScriptOffsets[id - _numGlobalScripts] - _resourceHeaderSize, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-18 22:22:35 +00:00
|
|
|
_gdi->roomChanged(roomptr);
|
2005-04-26 10:58:49 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 16:24:39 +00:00
|
|
|
void ScummEngine_v3old::resetRoomSubBlocks() {
|
2005-04-26 10:58:49 +00:00
|
|
|
const byte *ptr;
|
|
|
|
byte *roomptr;
|
|
|
|
|
|
|
|
// Determine the room and room script base address
|
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
if (!roomptr)
|
|
|
|
error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
|
|
|
|
|
|
|
|
// Reset room color for V1 zak
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version <= 1)
|
2005-04-26 10:58:49 +00:00
|
|
|
_roomPalette[0] = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Load box data
|
|
|
|
//
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->nukeResource(rtMatrix, 1);
|
|
|
|
_res->nukeResource(rtMatrix, 2);
|
2005-04-26 10:58:49 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2)
|
2005-04-26 10:58:49 +00:00
|
|
|
ptr = roomptr + *(roomptr + 0x15);
|
|
|
|
else
|
|
|
|
ptr = roomptr + READ_LE_UINT16(roomptr + 0x15);
|
|
|
|
if (ptr) {
|
2006-03-05 03:46:41 +00:00
|
|
|
byte numOfBoxes = 0;
|
2005-04-26 10:58:49 +00:00
|
|
|
int size;
|
|
|
|
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version == 0) {
|
2006-03-05 03:46:41 +00:00
|
|
|
// Count number of boxes
|
|
|
|
while (*ptr != 0xFF) {
|
|
|
|
numOfBoxes++;
|
|
|
|
ptr += 5;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-03-05 03:46:41 +00:00
|
|
|
ptr = roomptr + *(roomptr + 0x15);
|
|
|
|
size = numOfBoxes * SIZEOF_BOX_C64 + 1;
|
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 2, size + 1);
|
2006-03-05 03:46:41 +00:00
|
|
|
getResourceAddress(rtMatrix, 2)[0] = numOfBoxes;
|
|
|
|
memcpy(getResourceAddress(rtMatrix, 2) + 1, ptr, size);
|
|
|
|
} else {
|
|
|
|
numOfBoxes = *ptr;
|
|
|
|
if (_game.version <= 2)
|
|
|
|
size = numOfBoxes * SIZEOF_BOX_V2 + 1;
|
|
|
|
else
|
|
|
|
size = numOfBoxes * SIZEOF_BOX_V3 + 1;
|
|
|
|
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 2, size);
|
2006-03-05 03:46:41 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
|
|
|
|
}
|
|
|
|
|
2005-04-26 10:58:49 +00:00
|
|
|
ptr += size;
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version == 0) {
|
2006-03-05 03:46:41 +00:00
|
|
|
const byte *tmp = ptr;
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
// Compute matrix size
|
2011-05-13 12:12:00 +00:00
|
|
|
for (int i = 0; i < numOfBoxes; i++) {
|
2006-03-05 03:46:41 +00:00
|
|
|
while (*tmp != 0xFF) {
|
|
|
|
size++;
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
size++;
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
} else if (_game.version <= 2) {
|
2005-04-26 10:58:49 +00:00
|
|
|
size = numOfBoxes * (numOfBoxes + 1);
|
|
|
|
} else {
|
|
|
|
// FIXME. This is an evil HACK!!!
|
|
|
|
size = (READ_LE_UINT16(roomptr + 0x0A) - READ_LE_UINT16(roomptr + 0x15)) - size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size > 0) { // do this :)
|
2006-09-17 20:36:48 +00:00
|
|
|
_res->createResource(rtMatrix, 1, size);
|
2005-04-26 10:58:49 +00:00
|
|
|
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// No scale data in old bundle games
|
|
|
|
//
|
2011-05-13 12:48:01 +00:00
|
|
|
for (ResId id = 1; id < _res->_types[rtScaleTable].size(); id++)
|
2011-05-13 12:12:00 +00:00
|
|
|
_res->nukeResource(rtScaleTable, id);
|
2005-04-10 01:23:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Scumm
|