diff options
author | Max Horn | 2003-05-24 22:17:45 +0000 |
---|---|---|
committer | Max Horn | 2003-05-24 22:17:45 +0000 |
commit | 0384d27e83f2943279b8350bef8ddc82619b1eee (patch) | |
tree | 1dc75dc3a78c8c1c8a6ace09f98a7bce5f7f7785 /scumm | |
parent | 4cda099c575e15ff68239746f3b2076b1aad432f (diff) | |
download | scummvm-rg350-0384d27e83f2943279b8350bef8ddc82619b1eee.tar.gz scummvm-rg350-0384d27e83f2943279b8350bef8ddc82619b1eee.tar.bz2 scummvm-rg350-0384d27e83f2943279b8350bef8ddc82619b1eee.zip |
(somewhat hackish) support for COMI CD changing on Mac OS X; reordered stuff in scumm.h
svn-id: r7908
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 11 | ||||
-rw-r--r-- | scumm/scumm.h | 70 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 33 |
3 files changed, 75 insertions, 39 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 167a74a166..054385dfcb 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -205,16 +205,13 @@ void Scumm::readRoomsOffsets() { } bool Scumm::openResourceFile(const char *filename) { - char buf[256]; - debug(9, "openResourceFile(%s)", filename); if (_fileHandle.isOpen() == true) { _fileHandle.close(); } - strcpy(buf, filename); - _fileHandle.open(buf, getGameDataPath(), 1, _encbyte); + _fileHandle.open(filename, getGameDataPath(), 1, _encbyte); return _fileHandle.isOpen(); } @@ -228,7 +225,11 @@ void Scumm::askForDisk(const char *filename, int disknum) { _bundle->closeVoiceFile(); _bundle->closeMusicFile(); - sprintf(buf, "Cannot find file: '%s'\nInsert disc %d into drive %s\nHit Ok to retry, Cancel to exit", filename, disknum, getGameDataPath()); +#ifdef MACOSX + sprintf(buf, "Cannot find file: '%s'\nPlease insert disc %d.\nHit OK to retry, Cancel to exit", filename, disknum); +#else + sprintf(buf, "Cannot find file: '%s'\nInsert disc %d into drive %s\nHit OK to retry, Cancel to exit", filename, disknum, getGameDataPath()); +#endif result = displayError(true, buf); if (result == 2) diff --git a/scumm/scumm.h b/scumm/scumm.h index 1fc1fcbf0f..d716cc3c26 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -331,7 +331,7 @@ public: // Misc utility functions void checkRange(int max, int min, int no, const char *str); const char *getExeName() const { return _exe_name; } - const char *getGameDataPath() const { return _gameDataPath; } + const char *getGameDataPath() const; // Cursor/palette void updateCursor(); @@ -389,7 +389,7 @@ public: // VAR is a wrapper around scummVar, which attempts to include additional // useful information should an illegal var access be detected. #define VAR(x) scummVar(x, #x, __FILE__, __LINE__) - inline int32& scummVar(byte var, const char *varName, const char *file, int line) + int32& scummVar(byte var, const char *varName, const char *file, int line) { if (var == 0xFF) { warning("Illegal access to variable %s in file %s, line %d", varName, file, line); @@ -425,10 +425,12 @@ protected: int _curVerb; int _curVerbSlot; int _curPalIndex; -public: - byte _currentRoom; +public: + byte _currentRoom; // FIXME - should be protected but Actor::isInCurrentRoom uses it + int _roomResource; // FIXME - should be protected but Sound::pauseSounds uses it bool _egoPositioned; // Used by Actor::putActor, hence public + protected: int _keyPressed; uint16 _lastKeyHit; @@ -447,8 +449,7 @@ protected: bool _showStack; uint16 _debugMode; -protected: - /* Save/Load class - some of this may be GUI */ + // Save/Load class - some of this may be GUI byte _saveLoadFlag, _saveLoadSlot; uint32 _lastSaveTime; bool _saveLoadCompatible; @@ -469,11 +470,11 @@ protected: return result; } void saveOrLoad(Serializer *s, uint32 savegameVersion); + void saveLoadResource(Serializer *ser, int type, int index); + void makeSavegameName(char *out, int slot, bool compatible); public: bool getSavegameName(int slot, char *desc, SaveFileManager *mgr); - void makeSavegameName(char *out, int slot, bool compatible); - void saveLoadResource(Serializer *ser, int type, int index); void listSavegames(bool *marks, int num, SaveFileManager *mgr); void requestSave(int slot, const char *name); @@ -508,13 +509,35 @@ protected: public: void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr); void stopScript(int script); + bool isScriptRunning(int script); // FIXME - should be protected, used by Sound::startTalkSound protected: + void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars); void runScriptNested(int script); - void executeScript(); + void executeScript(); void updateScriptPtr(); + void runHook(int i); + void checkAndRunSentenceScript(); + void runExitScript(); + void runEntryScript(); + void runAllScripts(); + void freezeScripts(int scr); + void unfreezeScripts(); + + bool isScriptInUse(int script); + bool isRoomScriptRunning(int script); + + void killAllScriptsExceptCurrent(); + void killScriptsAndResources(); + void decreaseScriptDelay(int amount); + + void stopObjectCode(); + void stopObjectScript(int script); + void getScriptBaseAddress(); void getScriptEntryPoint(); + int getVerbEntrypoint(int obj, int entry); + byte fetchScriptByte(); virtual uint fetchScriptWord(); virtual int fetchScriptWordSigned(); @@ -526,37 +549,18 @@ protected: int pop(); virtual int readVar(uint var); virtual void writeVar(uint var, int value); - void runHook(int i); - bool isScriptInUse(int script); - void freezeScripts(int scr); - void unfreezeScripts(); - void runAllScripts(); void beginCutscene(int *args); void endCutscene(); void abortCutscene(); - void runExitScript(); - void runEntryScript(); - void beginOverride(); void endOverride(); - void killAllScriptsExceptCurrent(); - void killScriptsAndResources(); - void checkAndRunSentenceScript(); - void decreaseScriptDelay(int amount); -public: - bool isScriptRunning(int script); // FIXME - should be protected, used by Sound::startTalkSound -protected: - bool isRoomScriptRunning(int script); + void copyScriptString(byte *dst); int resStrLen(const byte *src) const; void doSentence(int c, int b, int a); void setStringVars(int i); - /* Script VM or Object class? */ - void stopObjectCode(); - void stopObjectScript(int script); - /* Should be in Resource class */ byte _encbyte; File _fileHandle; @@ -578,7 +582,6 @@ protected: void askForDisk(const char *filename, int disknum); bool openResourceFile(const char *filename); -protected: void loadPtrToResource(int type, int i, const byte *ptr); void readResTypeList(int id, uint32 tag, const char *name); char *resTypeFromId(int id); @@ -617,7 +620,6 @@ protected: int _lastLoadedRoom; public: - int _roomResource; // FIXME - should be protected but Sound::pauseSounds accesses it byte *findResourceData(uint32 tag, byte *ptr); int getResourceDataSize(byte *ptr); void dumpResource(char *tag, int index, byte *ptr, int length = -1); @@ -707,10 +709,8 @@ protected: void runInputScript(int a, int cmd, int mode); void restoreVerbBG(int verb); void drawVerbBitmap(int verb, int x, int y); - int getVerbEntrypoint(int obj, int entry); int getVerbSlot(int id, int mode); void killVerb(int slot); - void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars); void setVerbObject(uint room, uint object, uint verb); void checkV2Inventory(int x, int y); @@ -720,15 +720,16 @@ public: /* Should be in Actor class */ Actor *derefActor(int id, const char *errmsg = 0); Actor *derefActorSafe(int id, const char *errmsg); - void showActors(); uint32 *_classData; int getAngleFromPos(int x, int y); +protected: void walkActors(); void playActorSounds(); void setActorRedrawFlags(bool fg, bool bg); + void showActors(); void resetActorBgs(); void processActors(); void processUpperActors(); @@ -737,6 +738,7 @@ public: bool isCostumeInUse(int i); +public: /* Actor talking stuff */ byte _actorToPrintStrFor; int _sentenceNum; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index fd5fa8a79f..bb7db94030 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -42,6 +42,10 @@ #include "gui/message.h" #include "sound/mixer.h" #include "sound/mididrv.h" +#ifdef MACOSX +#include <sys/types.h> +#include <sys/stat.h> +#endif #ifdef _WIN32_WCE extern void drawError(char*); @@ -2006,6 +2010,35 @@ int normalizeAngle(int angle) { return toSimpleDir(1, temp) * 45; } +const char *Scumm::getGameDataPath() const { +#ifdef MACOSX + if (_features & GF_AFTER_V8 && !memcmp(_gameDataPath, "/Volumes/MONKEY3_", 17)) { + // Special case for COMI on Mac OS X. The mount points on OS X depend + // on the volume name. Hence if playing from CD, we'd get a problem. + // So if loading of a resource file fails, we fall back to the (fixed) + // CD mount points (/Volumes/MONKEY3_1 and /Volumes/MONKEY3_2). + // + // The check for whether we play from CD or not is very hackish, though. + static char buf[256]; + struct stat st; + int disk = (_scummVars && _scummVars[VAR_CURRENTDISK] == 2) ? 2 : 1; + sprintf(buf, "/Volumes/MONKEY3_%d", disk); + + if (!stat(buf, &st)) { + return buf; + } + + // Apparently that disk is not inserted. However since many data files + // (fonts, comi.la0) are on both disks, we also try the other CD. + disk = (disk == 1) ? 2 : 1; + sprintf(buf, "/Volumes/MONKEY3_%d", disk); + return buf; + } +#endif + + return _gameDataPath; +} + void Scumm::errorString(const char *buf1, char *buf2) { if (_currentScript != 0xFF) { ScriptSlot *ss = &vm.slot[_currentScript]; |