diff options
author | Max Horn | 2003-05-13 23:33:01 +0000 |
---|---|---|
committer | Max Horn | 2003-05-13 23:33:01 +0000 |
commit | 0ee0e7f6347def3b9b32f62f37584a3a19131913 (patch) | |
tree | f3e48da06db97397210f2c6f85ad1ec1c4024e59 /scumm | |
parent | 796fa748062564b4bf1993b6a150ce1d2da91259 (diff) | |
download | scummvm-rg350-0ee0e7f6347def3b9b32f62f37584a3a19131913.tar.gz scummvm-rg350-0ee0e7f6347def3b9b32f62f37584a3a19131913.tar.bz2 scummvm-rg350-0ee0e7f6347def3b9b32f62f37584a3a19131913.zip |
cleanup
svn-id: r7488
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/dialogs.cpp | 114 | ||||
-rw-r--r-- | scumm/resource.cpp | 6 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 4 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 2 | ||||
-rw-r--r-- | scumm/scumm.h | 75 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 7 |
6 files changed, 61 insertions, 147 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index ef6548839d..435e58a89d 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -142,7 +142,7 @@ static ResString string_map_table_v6[] = { {98, "Play"}, {99, "Cancel"}, {100, "Quit"}, - {101, "Ok"}, + {101, "OK"}, {93, "Game paused"}, }; @@ -155,7 +155,7 @@ static ResString string_map_table_v5[] = { {9, "Play"}, {10, "Cancel"}, {11, "Quit"}, - {12, "Ok"}, + {12, "OK"}, {4, "Game paused"} }; #endif @@ -170,124 +170,36 @@ void ScummDialog::addResText(int x, int y, int w, int h, int resID) { const ScummVM::String ScummDialog::queryResString(int stringno) { - char *result; - int string; + byte *result; if (stringno == 0) return String(); if (_scumm->_features & GF_AFTER_V7) - string = _scumm->readVar(string_map_table_v7[stringno - 1].num); + result = _scumm->getStringAddressVar(string_map_table_v7[stringno - 1].num); else if (_scumm->_features & GF_AFTER_V6) - string = _scumm->readVar(string_map_table_v6[stringno - 1].num); + result = _scumm->getStringAddressVar(string_map_table_v6[stringno - 1].num); else - string = string_map_table_v5[stringno - 1].num; + result = _scumm->getStringAddress(string_map_table_v5[stringno - 1].num); - result = (char *)_scumm->getStringAddress(string); if (result && *result == '/') { byte tmp[256]; - _scumm->translateText((byte *)result, tmp); - strcpy(result, (char *)tmp); + _scumm->translateText(result, tmp); + strcpy((char *)result, (char *)tmp); } - if (!result || *result == '\0') { // Gracelessly degrade to english :) - if (_scumm->_features & GF_AFTER_V6) - result = string_map_table_v6[stringno - 1].string; - else - result = string_map_table_v5[stringno - 1].string; + if (!result || *result == '\0') { // Gracelessly degrade to english :) + return string_map_table_v5[stringno - 1].string; } // Convert to a proper string (take care of FF codes) - int value; byte chr; String tmp; - while ((chr = *result++)) { if (chr == 0xFF) { - chr = *result++; - switch (chr) { - case 4: { // add value - value = _scumm->readVar(READ_LE_UINT16(result)); - if (value < 0) { - tmp += '-'; - value = -value; - } - - int flag = 0; - int max = 10000; - do { - if (value >= max || flag) { - tmp += value / max + '0'; - value %= max; - flag = 1; - } - max /= 10; - if (max == 1) - flag = 1; - } while (max); - result += 2; - break; - } - - case 5: { //add verb - value = _scumm->readVar(READ_LE_UINT16(result)); - int i; - if (!value) - break; - - for (i = 1; i < _scumm->_maxVerbs; i++) { - if (value == _scumm->_verbs[i].verbid && !_scumm->_verbs[i].type && !_scumm->_verbs[i].saveid) { - char *verb = (char *)_scumm->getResourceAddress(rtVerb, i); - if (verb) { - tmp += verb; - } - break; - } - } - result += 2; - break; - } - - case 6: { // add object or actor name - value = _scumm->readVar(READ_LE_UINT16(result)); - if (!value) - break; - - char *name = (char *)_scumm->getObjOrActorName(value); - if (name) { - tmp += name; - } - result += 2; - break; - } - case 7: { // add string - value = READ_LE_UINT16(result); - if (_scumm->_features & GF_AFTER_V6 || _scumm->_gameId == GID_INDY3_256) - value = _scumm->readVar(value); - - if (value) { - char *str = (char *)_scumm->getStringAddress(value); - if (str) { - tmp += str; - } - } - result += 2; - break; - } - // Do these ever occur in the Gui? - case 9: - case 10: - case 12: - case 13: - case 14: - result += 2; - default: - warning("Ignoring unknown resource string of type %d", (int)chr); - } - } else { - if (chr != '@') { - tmp += chr; - } + result += 3; + } else if (chr != '@') { + tmp += chr; } } return tmp; diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 1e070eb601..9b7cc1ce74 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -1627,12 +1627,6 @@ void Scumm::resourceStats() { debug(1, "Total allocated size=%d, locked=%d(%d)\n", _allocatedSize, lockedSize, lockedNum); } -void Scumm::heapClear(int mode) { -} - -void Scumm::unkHeapProc2(int a, int b) { -} - void Scumm::readMAXS() { if (_features & GF_AFTER_V8) { // CMI _fileHandle.seek(50 + 50, SEEK_CUR); // 176 - 8 diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 59aef91b51..d2f9c64f24 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -1601,8 +1601,8 @@ void Scumm_v5::o5_resourceRoutines() { break; case 17: // clear heap - heapClear(0); - unkHeapProc2(0, 0); + //heapClear(0); + //unkHeapProc2(0, 0); break; case 18: // load charset loadCharset(resid); diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index fd44c9617c..a42293c03f 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2519,7 +2519,7 @@ void Scumm_v6::o6_kernelSetFunctions() { enqueueObject(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], 0); break; case 120: - // FIXME: isn't it likely that this does the same as the pre-V7 opcode with the same id? + // FIXME: isn't it likely that this does the same as the pre-V7 opcode with the same id, i.e. swapPalColors? warning("o6_kernelSetFunctions: stub120(%d,%d)", args[1], args[2]); break; case 124: diff --git a/scumm/scumm.h b/scumm/scumm.h index c3a5b895c3..28e40ec4a7 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -297,10 +297,6 @@ public: int32 localvar[NUM_SCRIPT_SLOT][26]; } vm; - struct { - int16 x, y; - } mouse; - // Constructor / Destructor Scumm(GameDetector *detector, OSystem *syst); virtual ~Scumm(); @@ -329,6 +325,7 @@ public: int checkKeyHit(); void convertKeysToClicks(); int getKeyInput(); + void clearClickedStatus(); // Misc utility functions void checkRange(int max, int min, int no, const char *str); @@ -393,8 +390,14 @@ public: #define VAR(x) scummVar(x, #x, __FILE__, __LINE__) inline int32& scummVar(byte var, const char *varName, const char *file, int line) { - if (var == 0xFF) + if (var == 0xFF) { warning("Illegal access to variable %s in file %s, line %d", varName, file, line); + // Return a fake memory location, so that at least no innocent variable + // gets overwritten. + static int32 fake; + fake = 0; + return fake; + } return _scummVars[var]; } @@ -428,28 +431,22 @@ public: protected: int _keyPressed; uint16 _lastKeyHit; - uint16 _mouseButStat; - byte _leftBtnPressed, _rightBtnPressed; + struct { + int16 x, y; + } mouse; int16 _virtual_mouse_x, _virtual_mouse_y; - int _bootParam; - bool _dumpScripts, _hexdumpScripts; - int _showStack; - uint16 _debugMode, _soundCardType; - /* Not sure where this stuff goes */ - uint16 _language; - void startScene(int room, Actor *a, int b); - byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable; - ObjectIDMap _objectIDMap; - byte _numObjectsInRoom; - int8 _userPut; - int _resourceHeaderSize; - void clearClickedStatus(); - void startManiac(); + uint16 _mouseButStat; + byte _leftBtnPressed, _rightBtnPressed; - /* GUI class */ - void drawString(int a); + int _bootParam; // The bootparam, to be passed to the script 1, the bootscript + + // Various options useful for debugging + bool _dumpScripts; + bool _hexdumpScripts; + bool _showStack; + uint16 _debugMode; protected: /* Save/Load class - some of this may be GUI */ @@ -488,9 +485,6 @@ protected: uint32 _maxHeapThreshold, _minHeapThreshold; void lock(int type, int i); void unlock(int type, int i); - void heapClear(int mode); - void unkHeapProc2(int a, int b); - /* Script VM - should be in Script class */ uint32 _localScriptList[NUM_LOCALSCRIPT]; @@ -509,6 +503,9 @@ protected: void initializeLocals(int slot, int *vars); int getScriptSlot(); + void startScene(int room, Actor *a, int b); + void startManiac(); + public: void runScript(int script, int a, int b, int *lvarptr); void stopScriptNr(int script); @@ -528,9 +525,7 @@ protected: void setResult(int result); void push(int a); int pop(); -public: - virtual int readVar(uint var); // FIXME - should be protected, used in scumm/dialogs.cpp -protected: + virtual int readVar(uint var); virtual void writeVar(uint var, int value); void runHook(int i); bool isScriptInUse(int script); @@ -567,6 +562,7 @@ protected: byte _encbyte; File _fileHandle; uint32 _fileOffset; + int _resourceHeaderSize; char *_exe_name; // This is the name we use for opening resource files char *_game_name; // This is the game the user calls it, so use for saving bool _dynamicRoomOffsets; @@ -646,6 +642,11 @@ public: int findInventory(int owner, int index); int getInventoryCount(int owner); +protected: + byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable; + ObjectIDMap _objectIDMap; + byte _numObjectsInRoom; + void setupRoomObject(ObjectData *od, byte *room, byte *searchptr = NULL); void removeObjectFromRoom(int obj); void loadFlObject(uint object, uint room); @@ -654,7 +655,9 @@ public: int findLocalObjectSlot(); void addObjectToInventory(uint obj, uint room); void fixObjectFlags(); - bool getClass(int obj, int cls); +public: + bool getClass(int obj, int cls); // Used in actor.cpp, hence public +protected: void putClass(int obj, int cls, bool set); int getState(int obj); void putState(int obj, int state); @@ -674,7 +677,9 @@ public: int whereIsObject(int object); int findObject(int x, int y); void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room); - int getObjectOrActorXY(int object, int &x, int &y); // Object and Actor... +public: + int getObjectOrActorXY(int object, int &x, int &y); // Used in actor.cpp, hence public +protected: int getObjActToObjActDist(int a, int b); // Not sure how to handle byte *getObjOrActorName(int obj); // these three.. @@ -690,7 +695,9 @@ public: protected: /* Should be in Verb class */ uint16 _verbMouseOver; - int _inventoryOffset; + int _inventoryOffset; + int8 _userPut; + void redrawVerbs(); void checkExecVerbs(); void verbMouseOver(int verb); @@ -998,12 +1005,13 @@ public: int _charsetBufPos; byte _charsetBuffer[512]; - bool _noSubtitles; // Skip all subtitles? + bool _noSubtitles; // Whether to skip all subtitles void initCharset(int charset); void restoreCharsetBg(); bool hasCharsetMask(int x, int y, int x2, int y2); void CHARSET_1(); + void drawString(int a); void drawDescString(byte *msg); byte *addMessageToStack(byte *msg); void addIntToStack(int var); @@ -1019,6 +1027,7 @@ public: byte *_messagePtr; int16 _talkDelay; bool _keepText; + uint16 _language; bool _existLanguageFile; char *_languageBuffer; struct langIndexNode *_languageIndex; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 89fb54ef3d..4c4ce18bdd 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -252,7 +252,6 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _bootParam = 0; _dumpScripts = false; _debugMode = 0; - _soundCardType = 0; _language = 0; _objectOwnerTable = NULL; _objectRoomTable = NULL; @@ -534,9 +533,9 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _lastLoadedRoom = 0; _expire_counter = 0; _dynamicRoomOffsets = 0; - _shakeEnabled = 0; - _hexdumpScripts = 0; - _showStack = 0; + _shakeEnabled = false; + _hexdumpScripts = false; + _showStack = false; if (_gameId == GID_ZAK256) { // FmTowns is 320x240 _screenWidth = 320; |