[Scummvm-cvs-logs] scummvm master -> 7ce3719587cf370b0172dc06f85ded25b3c1f263
fingolfin
max at quendi.de
Tue Apr 5 15:19:50 CEST 2011
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a12dada822 SCUMM: Fix off-by-one mistakes in out-of-bounds checks; name some constants
55e65cee80 SCUMM: Cleanup
d7a6bf5846 SCUMM: Move ActorHE into its own header, move some HE specific stuff out of scumm.h
fb53303847 SCUMM: Rename InfoStuff to SaveStateMetaInfos
f19b27388c SCUMM: Split ScummEngine::generateFilename, move HE specifics to class ScummEngine_v60he
827561911a SCUMM: Move _heV7DiskOffsets from ScummEngine to ScummEngine_v70he
7ce3719587 SCUMM: Move _heV7RoomIntOffsets from ScummEngine to ScummEngine_v70he
Commit: a12dada82249cb713e2a9162b26ad3207127726c
https://github.com/scummvm/scummvm/commit/a12dada82249cb713e2a9162b26ad3207127726c
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:08-07:00
Commit Message:
SCUMM: Fix off-by-one mistakes in out-of-bounds checks; name some constants
Changed paths:
engines/scumm/script.cpp
engines/scumm/script.h
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index a76461f..c481fb8 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -319,6 +319,9 @@ void ScummEngine::runScriptNested(int script) {
updateScriptPtr();
+ if (vm.numNestedScripts >= kMaxScriptNesting)
+ error("Too many nested scripts");
+
nest = &vm.nest[vm.numNestedScripts];
if (_currentScript == 0xFF) {
@@ -334,9 +337,6 @@ void ScummEngine::runScriptNested(int script) {
vm.numNestedScripts++;
- if (vm.numNestedScripts > ARRAYSIZE(vm.nest))
- error("Too many nested scripts");
-
_currentScript = script;
getScriptBaseAddress();
resetScriptPointer();
@@ -1284,7 +1284,7 @@ void ScummEngine::beginCutscene(int *args) {
vm.slot[scr].cutsceneOverride++;
++vm.cutSceneStackPointer;
- if (vm.cutSceneStackPointer > ARRAYSIZE(vm.cutSceneData))
+ if (vm.cutSceneStackPointer >= kMaxCutsceneNum)
error("Cutscene stack overflow");
vm.cutSceneData[vm.cutSceneStackPointer] = args[0];
@@ -1325,7 +1325,7 @@ void ScummEngine::endCutscene() {
void ScummEngine::abortCutscene() {
const int idx = vm.cutSceneStackPointer;
- assert(0 <= idx && idx < 5);
+ assert(0 <= idx && idx < kMaxCutsceneNum);
uint32 offs = vm.cutScenePtr[idx];
if (offs) {
@@ -1344,7 +1344,7 @@ void ScummEngine::abortCutscene() {
void ScummEngine::beginOverride() {
const int idx = vm.cutSceneStackPointer;
- assert(0 <= idx && idx < 5);
+ assert(0 <= idx && idx < kMaxCutsceneNum);
vm.cutScenePtr[idx] = _scriptPointer - _scriptOrgPointer;
vm.cutSceneScript[idx] = _currentScript;
@@ -1361,7 +1361,7 @@ void ScummEngine::beginOverride() {
void ScummEngine::endOverride() {
const int idx = vm.cutSceneStackPointer;
- assert(0 <= idx && idx < 5);
+ assert(0 <= idx && idx < kMaxCutsceneNum);
vm.cutScenePtr[idx] = 0;
vm.cutSceneScript[idx] = 0;
diff --git a/engines/scumm/script.h b/engines/scumm/script.h
index dbfa263..39d5d80 100644
--- a/engines/scumm/script.h
+++ b/engines/scumm/script.h
@@ -98,16 +98,29 @@ struct NestedScript {
uint8 slot;
};
+enum {
+ /**
+ * The maximal number of cutscenes that can be active
+ * in parallel (i.e. nested).
+ */
+ kMaxCutsceneNum = 5,
+
+ /**
+ * The maximal 'nesting' level for scripts.
+ */
+ kMaxScriptNesting = 15
+};
+
struct VirtualMachineState {
- uint32 cutScenePtr[5];
- byte cutSceneScript[5];
- int16 cutSceneData[5];
+ uint32 cutScenePtr[kMaxCutsceneNum];
+ byte cutSceneScript[kMaxCutsceneNum];
+ int16 cutSceneData[kMaxCutsceneNum];
int16 cutSceneScriptIndex;
byte cutSceneStackPointer;
ScriptSlot slot[NUM_SCRIPT_SLOT];
int32 localvar[NUM_SCRIPT_SLOT][26];
- NestedScript nest[15];
+ NestedScript nest[kMaxScriptNesting];
byte numNestedScripts;
};
Commit: 55e65cee8099d91ae4797f7772cb5e459089892a
https://github.com/scummvm/scummvm/commit/55e65cee8099d91ae4797f7772cb5e459089892a
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:08-07:00
Commit Message:
SCUMM: Cleanup
Changed paths:
engines/scumm/script.cpp
engines/scumm/sound.cpp
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index c481fb8..c6c1f5f 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -261,8 +261,7 @@ void ScummEngine::stopScript(int script) {
/* Stop an object script 'script'*/
void ScummEngine::stopObjectScript(int script) {
ScriptSlot *ss;
- NestedScript *nest;
- int i, num;
+ int i;
if (script == 0)
return;
@@ -282,19 +281,14 @@ void ScummEngine::stopObjectScript(int script) {
}
}
- nest = vm.nest;
- num = vm.numNestedScripts;
-
- while (num > 0) {
- if (nest->number == script &&
- (nest->where == WIO_ROOM || nest->where == WIO_INVENTORY || nest->where == WIO_FLOBJECT)) {
- nukeArrays(nest->slot);
- nest->number = 0xFF;
- nest->slot = 0xFF;
- nest->where = 0xFF;
+ for (i = 0; i < vm.numNestedScripts; ++i) {
+ if (vm.nest[i].number == script &&
+ (vm.nest[i].where == WIO_ROOM || vm.nest[i].where == WIO_INVENTORY || vm.nest[i].where == WIO_FLOBJECT)) {
+ nukeArrays(vm.nest[i].slot);
+ vm.nest[i].number = 0xFF;
+ vm.nest[i].slot = 0xFF;
+ vm.nest[i].where = 0xFF;
}
- nest++;
- num--;
}
}
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index cff1618..0051319 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -195,8 +195,7 @@ void Sound::playSound(int soundID) {
return;
}
- debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID,
- _vm->getResourceRoomNr(rtSound, soundID));
+ debugC(DEBUG_SOUND, "playSound #%d", soundID);
ptr = _vm->getResourceAddress(rtSound, soundID);
@@ -1223,7 +1222,7 @@ int ScummEngine::readSoundResource(int idx) {
if (!dmuFile.open(buffer)) {
error("Can't open music file %s", buffer);
- _res->roomoffs[rtSound][idx] = (uint32)RES_INVALID_OFFSET;
+ _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET;
return 0;
}
dmuFile.seek(4, SEEK_SET);
@@ -1247,7 +1246,7 @@ int ScummEngine::readSoundResource(int idx) {
}
error("Unrecognized base tag 0x%08x in sound %d", basetag, idx);
}
- _res->roomoffs[rtSound][idx] = (uint32)RES_INVALID_OFFSET;
+ _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET;
return 0;
}
@@ -2122,7 +2121,7 @@ int ScummEngine::readSoundResourceSmallHeader(int idx) {
_fileHandle->read(_res->createResource(rtSound, idx, ro_size - 4), ro_size - 4);
return 1;
}
- _res->roomoffs[rtSound][idx] = (uint32)RES_INVALID_OFFSET;
+ _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET;
return 0;
}
Commit: d7a6bf58461ca4d780d354403fc40c9c91f66988
https://github.com/scummvm/scummvm/commit/d7a6bf58461ca4d780d354403fc40c9c91f66988
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:08-07:00
Commit Message:
SCUMM: Move ActorHE into its own header, move some HE specific stuff out of scumm.h
Changed paths:
A engines/scumm/actor_he.h
engines/scumm/actor.cpp
engines/scumm/actor.h
engines/scumm/he/intern_he.h
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 2403d2a..39db47b 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -26,6 +26,7 @@
#include "common/system.h" // for setFocusRectangle/clearFocusRectangle
#include "scumm/scumm.h"
#include "scumm/actor.h"
+#include "scumm/actor_he.h"
#include "scumm/akos.h"
#include "scumm/boxes.h"
#include "scumm/charset.h"
@@ -75,7 +76,7 @@ void ActorHE::initActor(int mode) {
if (_vm->_game.heversion >= 61)
_flip = 0;
- _clipOverride = _vm->_actorClipOverride;
+ _clipOverride = ((ScummEngine_v60he *)_vm)->_actorClipOverride;
_auxBlock.reset();
}
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 98854ec..8e699b5 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -34,7 +34,6 @@
namespace Scumm {
-
enum {
V12_X_MULTIPLIER = 8,
V12_Y_MULTIPLIER = 2,
@@ -315,46 +314,6 @@ protected:
bool findPathTowards(byte box, byte box2, byte box3, Common::Point &foundPath);
};
-class ActorHE : public Actor {
-public:
- ActorHE(ScummEngine *scumm, int id) : Actor(scumm, id) {}
-
- virtual void initActor(int mode);
-
- virtual void hideActor();
-
- void drawActorToBackBuf(int x, int y);
-
- void setHEFlag(int bit, int set);
-
- void setUserCondition(int slot, int set);
- bool isUserConditionSet(int slot) const;
-
- void setTalkCondition(int slot);
- bool isTalkConditionSet(int slot) const;
-
-public:
- /** This rect is used to clip actor drawing. */
- Common::Rect _clipOverride;
-
- bool _heNoTalkAnimation;
- bool _heTalking;
- byte _heFlags;
-
- AuxBlock _auxBlock;
-
- struct {
- int16 posX;
- int16 posY;
- int16 color;
- byte sentence[128];
- } _heTalkQueue[16];
-
-
- virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
- virtual void setActorCostume(int c);
-};
-
class Actor_v3 : public Actor {
public:
Actor_v3(ScummEngine *scumm, int id) : Actor(scumm, id) {}
diff --git a/engines/scumm/actor_he.h b/engines/scumm/actor_he.h
new file mode 100644
index 0000000..bb7bbb6
--- /dev/null
+++ b/engines/scumm/actor_he.h
@@ -0,0 +1,92 @@
+/* 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.
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+
+#ifndef SCUMM_ACTOR_HE_H
+#define SCUMM_ACTOR_HE_H
+
+#include "scumm/actor.h"
+
+namespace Scumm {
+
+struct AuxBlock {
+ bool visible;
+ Common::Rect r;
+
+ void reset() {
+ visible = false;
+ r.left = r.top = 0;
+ r.right = r.bottom = -1;
+ }
+};
+
+struct AuxEntry {
+ int actorNum;
+ int subIndex;
+};
+
+class ActorHE : public Actor {
+public:
+ ActorHE(ScummEngine *scumm, int id) : Actor(scumm, id) {}
+
+ virtual void initActor(int mode);
+
+ virtual void hideActor();
+
+ void drawActorToBackBuf(int x, int y);
+
+ void setHEFlag(int bit, int set);
+
+ void setUserCondition(int slot, int set);
+ bool isUserConditionSet(int slot) const;
+
+ void setTalkCondition(int slot);
+ bool isTalkConditionSet(int slot) const;
+
+public:
+ /** This rect is used to clip actor drawing. */
+ Common::Rect _clipOverride;
+
+ bool _heNoTalkAnimation;
+ bool _heTalking;
+ byte _heFlags;
+
+ AuxBlock _auxBlock;
+
+ struct {
+ int16 posX;
+ int16 posY;
+ int16 color;
+ byte sentence[128];
+ } _heTalkQueue[16];
+
+
+ virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
+ virtual void setActorCostume(int c);
+};
+
+} // End of namespace Scumm
+
+#endif
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 5b59558..c0eaf73 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -31,6 +31,7 @@
#include "scumm/he/floodfill_he.h"
#include "scumm/he/wiz_he.h"
#endif
+#include "scumm/actor_he.h" // For AuxBlock & AuxEntry
namespace Common {
class SeekableReadStream;
@@ -55,7 +56,10 @@ public:
Common::SeekableReadStream *_hInFileTable[17];
Common::WriteStream *_hOutFileTable[17];
+ Common::Rect _actorClipOverride; // HE specific
+
int _heTimers[16];
+
int getHETimer(int timer);
void setHETimer(int timer);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index d22b6ee..7861807 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -320,11 +320,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_V1TalkingActor = 0;
_NESStartStrip = 0;
- _actorClipOverride.top = 0;
- _actorClipOverride.bottom = 480;
- _actorClipOverride.left = 0;
- _actorClipOverride.right = 640;
-
_skipDrawObject = 0;
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
@@ -767,6 +762,12 @@ ScummEngine_v60he::ScummEngine_v60he(OSystem *syst, const DetectorResult &dr)
: ScummEngine_v6(syst, dr) {
memset(_hInFileTable, 0, sizeof(_hInFileTable));
memset(_hOutFileTable, 0, sizeof(_hOutFileTable));
+
+ _actorClipOverride.top = 0;
+ _actorClipOverride.bottom = 480;
+ _actorClipOverride.left = 0;
+ _actorClipOverride.right = 640;
+
memset(_heTimers, 0, sizeof(_heTimers));
if (_game.heversion >= 61)
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 587d1be..86b8276 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -308,22 +308,6 @@ enum WhereIsObject {
WIO_FLOBJECT = 4
};
-struct AuxBlock {
- bool visible;
- Common::Rect r;
-
- void reset() {
- visible = false;
- r.left = r.top = 0;
- r.right = r.bottom = -1;
- }
-};
-
-struct AuxEntry {
- int actorNum;
- int subIndex;
-};
-
// TODO: Rename InfoStuff to something more descriptive
struct InfoStuff {
uint32 date;
@@ -972,8 +956,6 @@ public:
// Generic costume code
bool isCostumeInUse(int i) const;
- Common::Rect _actorClipOverride; // HE specific
-
protected:
/* Should be in Graphics class? */
uint16 _screenB, _screenH;
Commit: fb5330384708a345d0c3728691d3ea36295b29d0
https://github.com/scummvm/scummvm/commit/fb5330384708a345d0c3728691d3ea36295b29d0
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:08-07:00
Commit Message:
SCUMM: Rename InfoStuff to SaveStateMetaInfos
Changed paths:
engines/scumm/detection.cpp
engines/scumm/saveload.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 2a6de98..f7ae50c 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -1186,7 +1186,7 @@ SaveStateDescriptor ScummMetaEngine::querySaveMetaInfos(const char *target, int
desc.setDeletableFlag(true);
desc.setThumbnail(thumbnail);
- InfoStuff infos;
+ SaveStateMetaInfos infos;
memset(&infos, 0, sizeof(infos));
if (ScummEngine::loadInfosFromSlot(target, slot, &infos)) {
int day = (infos.date >> 24) & 0xFF;
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index bdae4c5..fb34255 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -373,7 +373,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
// Since version 56 we save additional information about the creation of
// the save game and the save time.
if (hdr.ver >= VER(56)) {
- InfoStuff infos;
+ SaveStateMetaInfos infos;
if (!loadInfos(in, &infos)) {
warning("Info section could not be found");
delete in;
@@ -703,7 +703,7 @@ Graphics::Surface *ScummEngine::loadThumbnailFromSlot(const char *target, int sl
return thumb;
}
-bool ScummEngine::loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff) {
+bool ScummEngine::loadInfosFromSlot(const char *target, int slot, SaveStateMetaInfos *stuff) {
Common::SeekableReadStream *in;
SaveGameHeader hdr;
@@ -741,8 +741,8 @@ bool ScummEngine::loadInfosFromSlot(const char *target, int slot, InfoStuff *stu
return true;
}
-bool ScummEngine::loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff) {
- memset(stuff, 0, sizeof(InfoStuff));
+bool ScummEngine::loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos *stuff) {
+ memset(stuff, 0, sizeof(SaveStateMetaInfos));
SaveInfoSection section;
section.type = file->readUint32BE();
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 86b8276..23e6b7b 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -308,8 +308,7 @@ enum WhereIsObject {
WIO_FLOBJECT = 4
};
-// TODO: Rename InfoStuff to something more descriptive
-struct InfoStuff {
+struct SaveStateMetaInfos {
uint32 date;
uint16 time;
uint32 playtime;
@@ -678,11 +677,11 @@ public:
}
static Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot);
- static bool loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff);
+ static bool loadInfosFromSlot(const char *target, int slot, SaveStateMetaInfos *stuff);
protected:
void saveInfos(Common::WriteStream* file);
- static bool loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff);
+ static bool loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos *stuff);
protected:
/* Script VM - should be in Script class */
Commit: f19b27388cb5e07b307eed21a1302d961c01ba1c
https://github.com/scummvm/scummvm/commit/f19b27388cb5e07b307eed21a1302d961c01ba1c
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:09-07:00
Commit Message:
SCUMM: Split ScummEngine::generateFilename, move HE specifics to class ScummEngine_v60he
Changed paths:
engines/scumm/detection.cpp
engines/scumm/he/intern_he.h
engines/scumm/scumm.h
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index f7ae50c..f0f9c7c 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -77,8 +77,6 @@ Common::String ScummEngine::generateFilename(const int room) const {
snprintf(buf, sizeof(buf), "disk%02d.lec", diskNumber);
}
} else {
- char id = 0;
-
switch (_filenamePattern.genMethod) {
case kGenDiskNum:
snprintf(buf, sizeof(buf), _filenamePattern.pattern, diskNumber);
@@ -88,59 +86,6 @@ Common::String ScummEngine::generateFilename(const int room) const {
snprintf(buf, sizeof(buf), _filenamePattern.pattern, room);
break;
- case kGenHEMac:
- case kGenHEMacNoParens:
- case kGenHEPC:
- if (room < 0) {
- id = '0' - room;
- } else if (_game.heversion >= 98) {
- int disk = 0;
- if (_heV7DiskOffsets)
- disk = _heV7DiskOffsets[room];
-
- switch (disk) {
- case 2:
- id = 'b';
- // Special cases for Blue's games, which share common (b) files
- if (_game.id == GID_BIRTHDAY && !(_game.features & GF_DEMO))
- strcpy(buf, "Blue'sBirthday.(b)");
- else if (_game.id == GID_TREASUREHUNT)
- strcpy(buf, "Blue'sTreasureHunt.(b)");
- else
- snprintf(buf, sizeof(buf), "%s.(b)", _filenamePattern.pattern);
- break;
- case 1:
- id = 'a';
- snprintf(buf, sizeof(buf), "%s.(a)", _filenamePattern.pattern);
- break;
- default:
- id = '0';
- snprintf(buf, sizeof(buf), "%s.he0", _filenamePattern.pattern);
- }
- } else if (_game.heversion >= 70) {
- id = (room == 0) ? '0' : '1';
- } else {
- id = diskNumber + '0';
- }
-
- if (_filenamePattern.genMethod == kGenHEPC) {
- // For HE >= 98, we already called snprintf above.
- if (_game.heversion < 98 || room < 0)
- snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id);
- } else {
- if (id == '3') { // special case for cursors
- // For mac they're stored in game binary
- strncpy(buf, _filenamePattern.pattern, sizeof(buf));
- } else {
- if (_filenamePattern.genMethod == kGenHEMac)
- snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id);
- else
- snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id);
- }
- }
-
- break;
-
case kGenUnchanged:
strncpy(buf, _filenamePattern.pattern, sizeof(buf));
break;
@@ -153,6 +98,73 @@ Common::String ScummEngine::generateFilename(const int room) const {
return buf;
}
+Common::String ScummEngine_v60he::generateFilename(const int room) const {
+ char buf[128];
+ char id = 0;
+
+ switch (_filenamePattern.genMethod) {
+ case kGenHEMac:
+ case kGenHEMacNoParens:
+ case kGenHEPC:
+ if (room < 0) {
+ id = '0' - room;
+ } else if (_game.heversion >= 98) {
+ int disk = 0;
+ if (_heV7DiskOffsets)
+ disk = _heV7DiskOffsets[room];
+
+ switch (disk) {
+ case 2:
+ id = 'b';
+ // Special cases for Blue's games, which share common (b) files
+ if (_game.id == GID_BIRTHDAY && !(_game.features & GF_DEMO))
+ strcpy(buf, "Blue'sBirthday.(b)");
+ else if (_game.id == GID_TREASUREHUNT)
+ strcpy(buf, "Blue'sTreasureHunt.(b)");
+ else
+ snprintf(buf, sizeof(buf), "%s.(b)", _filenamePattern.pattern);
+ break;
+ case 1:
+ id = 'a';
+ snprintf(buf, sizeof(buf), "%s.(a)", _filenamePattern.pattern);
+ break;
+ default:
+ id = '0';
+ snprintf(buf, sizeof(buf), "%s.he0", _filenamePattern.pattern);
+ }
+ } else if (_game.heversion >= 70) {
+ id = (room == 0) ? '0' : '1';
+ } else {
+ const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0;
+ id = diskNumber + '0';
+ }
+
+ if (_filenamePattern.genMethod == kGenHEPC) {
+ // For HE >= 98, we already called snprintf above.
+ if (_game.heversion < 98 || room < 0)
+ snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id);
+ } else {
+ if (id == '3') { // special case for cursors
+ // For mac they're stored in game binary
+ strncpy(buf, _filenamePattern.pattern, sizeof(buf));
+ } else {
+ if (_filenamePattern.genMethod == kGenHEMac)
+ snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id);
+ else
+ snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id);
+ }
+ }
+
+ break;
+
+ default:
+ // Fallback to original method
+ return ScummEngine::generateFilename(room);
+ }
+
+ return buf;
+}
+
static Common::String generateFilenameForDetection(const char *pattern, FilenameGenMethod genMethod) {
char buf[128];
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index c0eaf73..92a8ca9 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -67,6 +67,8 @@ public:
ScummEngine_v60he(OSystem *syst, const DetectorResult &dr);
~ScummEngine_v60he();
+ virtual Common::String generateFilename(const int room) const;
+
virtual void resetScumm();
protected:
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 23e6b7b..f26385a 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -613,7 +613,7 @@ public:
FilenamePattern _filenamePattern;
- Common::String generateFilename(const int room) const;
+ virtual Common::String generateFilename(const int room) const;
protected:
Common::KeyState _keyPressed;
Commit: 827561911ac8ca8136ee062908717225947596ea
https://github.com/scummvm/scummvm/commit/827561911ac8ca8136ee062908717225947596ea
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:09-07:00
Commit Message:
SCUMM: Move _heV7DiskOffsets from ScummEngine to ScummEngine_v70he
Changed paths:
engines/scumm/detection.cpp
engines/scumm/he/intern_he.h
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index f0f9c7c..87ec7b8 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -108,7 +108,44 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const {
case kGenHEPC:
if (room < 0) {
id = '0' - room;
- } else if (_game.heversion >= 98) {
+ } else {
+ const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0;
+ id = diskNumber + '0';
+ }
+
+ if (_filenamePattern.genMethod == kGenHEPC) {
+ snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id);
+ } else {
+ if (id == '3') { // special case for cursors
+ // For mac they're stored in game binary
+ strncpy(buf, _filenamePattern.pattern, sizeof(buf));
+ } else {
+ if (_filenamePattern.genMethod == kGenHEMac)
+ snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id);
+ else
+ snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id);
+ }
+ }
+
+ break;
+
+ default:
+ // Fallback to parent method
+ return ScummEngine::generateFilename(room);
+ }
+
+ return buf;
+}
+
+Common::String ScummEngine_v70he::generateFilename(const int room) const {
+ char buf[128];
+ char id = 0;
+
+ switch (_filenamePattern.genMethod) {
+ case kGenHEMac:
+ case kGenHEMacNoParens:
+ case kGenHEPC:
+ if (_game.heversion >= 98 && room >= 0) {
int disk = 0;
if (_heV7DiskOffsets)
disk = _heV7DiskOffsets[room];
@@ -132,11 +169,10 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const {
id = '0';
snprintf(buf, sizeof(buf), "%s.he0", _filenamePattern.pattern);
}
- } else if (_game.heversion >= 70) {
- id = (room == 0) ? '0' : '1';
+ } else if (room < 0) {
+ id = '0' - room;
} else {
- const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0;
- id = diskNumber + '0';
+ id = (room == 0) ? '0' : '1';
}
if (_filenamePattern.genMethod == kGenHEPC) {
@@ -158,8 +194,8 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const {
break;
default:
- // Fallback to original method
- return ScummEngine::generateFilename(room);
+ // Fallback to parent method
+ return ScummEngine_v60he::generateFilename(room);
}
return buf;
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 92a8ca9..96807cc 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -113,6 +113,7 @@ class ScummEngine_v70he : public ScummEngine_v60he {
protected:
ResExtractor *_resExtractor;
+ byte *_heV7DiskOffsets;
byte *_heV7RoomOffsets;
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq;
@@ -124,6 +125,8 @@ public:
ScummEngine_v70he(OSystem *syst, const DetectorResult &dr);
~ScummEngine_v70he();
+ virtual Common::String generateFilename(const int room) const;
+
void restoreBackgroundHE(Common::Rect rect, int dirtybit = 0);
protected:
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 7861807..bd8b3e5 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -201,7 +201,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_bootParam = 0;
_dumpScripts = false;
_debugMode = 0;
- _heV7DiskOffsets = NULL;
_heV7RoomIntOffsets = NULL;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
@@ -788,6 +787,7 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
else
_resExtractor = new Win32ResExtractor(this);
+ _heV7DiskOffsets = NULL;
_heV7RoomOffsets = NULL;
_heSndSoundId = 0;
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index f26385a..43c86cd 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -773,7 +773,6 @@ public:
protected:
int _resourceHeaderSize;
byte _resourceMapper[128];
- byte *_heV7DiskOffsets;
uint32 *_heV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
Commit: 7ce3719587cf370b0172dc06f85ded25b3c1f263
https://github.com/scummvm/scummvm/commit/7ce3719587cf370b0172dc06f85ded25b3c1f263
Author: Max Horn (max at quendi.de)
Date: 2011-04-05T06:18:09-07:00
Commit Message:
SCUMM: Move _heV7RoomIntOffsets from ScummEngine to ScummEngine_v70he
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/sprite_he.cpp
engines/scumm/resource.cpp
engines/scumm/resource_v3.cpp
engines/scumm/resource_v4.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
engines/scumm/scumm_v3.h
engines/scumm/scumm_v4.h
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 96807cc..830e940 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -115,6 +115,7 @@ protected:
byte *_heV7DiskOffsets;
byte *_heV7RoomOffsets;
+ uint32 *_heV7RoomIntOffsets;
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq;
@@ -130,6 +131,9 @@ public:
void restoreBackgroundHE(Common::Rect rect, int dirtybit = 0);
protected:
+ virtual void allocateArrays();
+ virtual int readResTypeList(int id);
+ virtual uint32 getResourceRoomOffset(int type, int idx);
virtual void setupOpcodes();
virtual void setupScummVars();
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 5f751d8..c66eed6 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -46,7 +46,7 @@ Sprite::~Sprite() {
}
void ScummEngine_v90he::allocateArrays() {
- ScummEngine::allocateArrays();
+ ScummEngine_v70he::allocateArrays();
_sprite->allocTables(_numSprites, MAX(64, _numSprites / 4), 64);
}
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 5aae59d..5bc643a 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -167,8 +167,6 @@ void ScummEngine::deleteRoomOffsets() {
/** Read room offsets */
void ScummEngine::readRoomsOffsets() {
- int num, room;
-
debug(9, "readRoomOffsets()");
if (_game.features & GF_SMALL_HEADER) {
@@ -177,13 +175,12 @@ void ScummEngine::readRoomsOffsets() {
_fileHandle->seek(16, SEEK_SET);
}
- num = _fileHandle->readByte();
+ int num = _fileHandle->readByte();
while (num--) {
- room = _fileHandle->readByte();
+ int room = _fileHandle->readByte();
+ int offset = _fileHandle->readUint32LE();
if (_res->roomoffs[rtRoom][room] != RES_INVALID_OFFSET) {
- _res->roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
- } else {
- _fileHandle->readUint32LE();
+ _res->roomoffs[rtRoom][room] = offset;
}
}
}
@@ -491,7 +488,7 @@ void ScummEngine::readArrayFromIndexFile() {
error("readArrayFromIndexFile() not supported in pre-V6 games");
}
-void ScummEngine::readResTypeList(int id) {
+int ScummEngine::readResTypeList(int id) {
int num;
int i;
@@ -511,16 +508,27 @@ void ScummEngine::readResTypeList(int id) {
}
for (i = 0; i < num; i++) {
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
-
- if (id == rtRoom && _game.heversion >= 70)
- _heV7RoomIntOffsets[i] = _res->roomoffs[id][i];
}
- if (_game.heversion >= 70) {
+ return num;
+}
+
+int ScummEngine_v70he::readResTypeList(int id) {
+ int num;
+ int i;
+
+ num = ScummEngine::readResTypeList(id);
+
+ if (id == rtRoom)
for (i = 0; i < num; i++) {
- _res->globsize[id][i] = _fileHandle->readUint32LE();
+ _heV7RoomIntOffsets[i] = _res->roomoffs[rtRoom][i];
}
+
+ for (i = 0; i < num; i++) {
+ _res->globsize[id][i] = _fileHandle->readUint32LE();
}
+
+ return num;
}
void ResourceManager::allocResTypeData(int id, uint32 tag, int num_, const char *name_, int mode_) {
@@ -635,18 +643,9 @@ int ScummEngine::loadResource(int type, int idx) {
if (roomNr == 0)
roomNr = _roomResource;
- if (type == rtRoom) {
- if (_game.version == 8)
- fileOffs = 8;
- else if (_game.heversion >= 70)
- fileOffs = _heV7RoomIntOffsets[idx];
- else
- fileOffs = 0;
- } else {
- fileOffs = _res->roomoffs[type][idx];
- if (fileOffs == RES_INVALID_OFFSET)
- return 0;
- }
+ fileOffs = getResourceRoomOffset(type, idx);
+ if (fileOffs == RES_INVALID_OFFSET)
+ return 0;
openRoom(roomNr);
@@ -691,13 +690,11 @@ int ScummEngine::loadResource(int type, int idx) {
dumpResource("script-", idx, getResourceAddress(rtScript, idx));
}
- if (!_fileHandle->err() && !_fileHandle->eos()) {
- return 1;
+ if (_fileHandle->err() || _fileHandle->eos()) {
+ error("Cannot read resource");
}
- _res->nukeResource(type, idx);
-
- error("Cannot read resource");
+ return 1;
}
int ScummEngine::getResourceRoomNr(int type, int idx) {
@@ -706,6 +703,20 @@ int ScummEngine::getResourceRoomNr(int type, int idx) {
return _res->roomno[type][idx];
}
+uint32 ScummEngine::getResourceRoomOffset(int type, int idx) {
+ if (type == rtRoom) {
+ return (_game.version == 8) ? 8 : 0;
+ }
+ return _res->roomoffs[type][idx];
+}
+
+uint32 ScummEngine_v70he::getResourceRoomOffset(int type, int idx) {
+ if (type == rtRoom) {
+ return _heV7RoomIntOffsets[idx];
+ }
+ return _res->roomoffs[type][idx];
+}
+
int ScummEngine::getResourceSize(int type, int idx) {
byte *ptr = getResourceAddress(type, idx);
assert(ptr);
@@ -1295,13 +1306,16 @@ void ScummEngine::allocateArrays() {
_res->allocResTypeData(rtMatrix, 0, 10, "boxes", 0);
_res->allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1);
_res->allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1);
+}
- if (_game.heversion >= 70) {
- _res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
- _heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
- }
+void ScummEngine_v70he::allocateArrays() {
+ ScummEngine::allocateArrays();
+
+ _res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
+ _heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
}
+
void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int length) {
char buf[256];
Common::DumpFile out;
diff --git a/engines/scumm/resource_v3.cpp b/engines/scumm/resource_v3.cpp
index 0728395..5f23720 100644
--- a/engines/scumm/resource_v3.cpp
+++ b/engines/scumm/resource_v3.cpp
@@ -32,7 +32,7 @@ namespace Scumm {
extern const char *resTypeFromId(int id);
-void ScummEngine_v3old::readResTypeList(int id) {
+int ScummEngine_v3old::readResTypeList(int id) {
int num;
int i;
@@ -57,6 +57,8 @@ void ScummEngine_v3old::readResTypeList(int id) {
if (_res->roomoffs[id][i] == 0xFFFF)
_res->roomoffs[id][i] = (uint32)RES_INVALID_OFFSET;
}
+
+ return num;
}
void ScummEngine_v3old::readIndexFile() {
diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp
index 808fcbd..b1d9849 100644
--- a/engines/scumm/resource_v4.cpp
+++ b/engines/scumm/resource_v4.cpp
@@ -33,7 +33,7 @@ namespace Scumm {
extern const char *resTypeFromId(int id);
-void ScummEngine_v4::readResTypeList(int id) {
+int ScummEngine_v4::readResTypeList(int id) {
int num;
int i;
@@ -49,6 +49,8 @@ void ScummEngine_v4::readResTypeList(int id) {
_res->roomno[id][i] = _fileHandle->readByte();
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
}
+
+ return num;
}
void ScummEngine_v4::readIndexFile() {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index bd8b3e5..7b98c86 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -201,7 +201,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_bootParam = 0;
_dumpScripts = false;
_debugMode = 0;
- _heV7RoomIntOffsets = NULL;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
_objectStateTable = NULL;
@@ -789,6 +788,7 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
_heV7DiskOffsets = NULL;
_heV7RoomOffsets = NULL;
+ _heV7RoomIntOffsets = NULL;
_heSndSoundId = 0;
_heSndOffset = 0;
@@ -805,8 +805,8 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
ScummEngine_v70he::~ScummEngine_v70he() {
delete _resExtractor;
free(_heV7DiskOffsets);
- free(_heV7RoomIntOffsets);
free(_heV7RoomOffsets);
+ free(_heV7RoomIntOffsets);
free(_storedFlObjects);
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 43c86cd..f3af84b 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -773,7 +773,6 @@ public:
protected:
int _resourceHeaderSize;
byte _resourceMapper[128];
- uint32 *_heV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
@@ -786,11 +785,13 @@ protected:
bool openResourceFile(const Common::String &filename, byte encByte); // TODO: Use Common::String
void loadPtrToResource(int type, int i, const byte *ptr);
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
// void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode);
// byte *createResource(int type, int index, uint32 size);
int loadResource(int type, int i);
// void nukeResource(int type, int i);
+ int getResourceRoomNr(int type, int idx);
+ virtual uint32 getResourceRoomOffset(int type, int idx);
int getResourceSize(int type, int idx);
public:
@@ -798,7 +799,6 @@ public:
virtual byte *getStringAddress(int i);
byte *getStringAddressVar(int i);
void ensureResourceLoaded(int type, int i);
- int getResourceRoomNr(int type, int index);
protected:
int readSoundResource(int index);
diff --git a/engines/scumm/scumm_v3.h b/engines/scumm/scumm_v3.h
index abe75cd..6e8d593 100644
--- a/engines/scumm/scumm_v3.h
+++ b/engines/scumm/scumm_v3.h
@@ -62,7 +62,7 @@ public:
ScummEngine_v3old(OSystem *syst, const DetectorResult &dr);
protected:
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
virtual void readIndexFile();
virtual void setupRoomSubBlocks();
virtual void resetRoomSubBlocks();
diff --git a/engines/scumm/scumm_v4.h b/engines/scumm/scumm_v4.h
index be3f6cb..653cfc2 100644
--- a/engines/scumm/scumm_v4.h
+++ b/engines/scumm/scumm_v4.h
@@ -59,7 +59,7 @@ protected:
virtual void scummLoop_handleSaveLoad();
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
virtual void readIndexFile();
virtual void loadCharset(int no);
virtual void resetRoomObjects();
More information about the Scummvm-git-logs
mailing list