From 5de19ecb28d51ce4b7aa973ea643c73448751ef1 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 7 Feb 2009 03:36:36 +0000 Subject: Cleanup. svn-id: r36232 --- engines/agos/agos.cpp | 50 +++++++++++------------ engines/agos/agos.h | 97 ++++++++++++++++++++++----------------------- engines/agos/debug.cpp | 60 ++++++++++++++-------------- engines/agos/debugger.cpp | 2 +- engines/agos/gfx.cpp | 36 ++++++++--------- engines/agos/input.cpp | 8 ++-- engines/agos/res.cpp | 32 +++++++-------- engines/agos/saveload.cpp | 2 +- engines/agos/script.cpp | 8 ++-- engines/agos/script_e2.cpp | 2 +- engines/agos/string.cpp | 18 ++++----- engines/agos/subroutine.cpp | 20 +++++----- engines/agos/vga.cpp | 24 +++++------ engines/agos/vga.h | 4 +- engines/agos/vga_s2.cpp | 2 +- 15 files changed, 179 insertions(+), 186 deletions(-) diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index bfb66cd973..63d6d063d6 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -92,7 +92,7 @@ AGOSEngine_Elvira1::AGOSEngine_Elvira1(OSystem *system) AGOSEngine::AGOSEngine(OSystem *syst) : Engine(syst) { _vcPtr = 0; - _vc_get_out_of_code = 0; + _vcGetOutOfCode = 0; _gameOffsetsPtr = 0; _debugger = 0; @@ -128,7 +128,7 @@ AGOSEngine::AGOSEngine(OSystem *syst) _textSize = 0; _stringTabNum = 0; _stringTabPos = 0; - _stringtab_numalloc = 0; + _stringTabSize = 0; _stringTabPtr = 0; _itemArrayPtr = 0; @@ -166,7 +166,6 @@ AGOSEngine::AGOSEngine(OSystem *syst) _subroutineListOrg = 0; _subroutineList = 0; - _subroutine = 0; _dxSurfacePitch = 0; @@ -192,10 +191,10 @@ AGOSEngine::AGOSEngine(OSystem *syst) _backFlag = 0; _debugMode = 0; - _startMainScript = false; - _continousMainScript = false; - _startVgaScript = false; - _continousVgaScript = false; + _dumpScripts = false; + _dumpOpcodes = false; + _dumpVgaScripts = false; + _dumpVgaOpcodes = false; _dumpImages = false; _copyProtection = false; @@ -242,8 +241,8 @@ AGOSEngine::AGOSEngine(OSystem *syst) _objectItem = 0; _currentPlayer = 0; - _iOverflow = 0; - _nameLocked = 0; + _iOverflow = false; + _nameLocked = false; _hitAreaObjectItem = 0; _lastHitArea = 0; _lastNameOn = 0; @@ -258,11 +257,11 @@ AGOSEngine::AGOSEngine(OSystem *syst) _defaultVerb = 0; _mouseHideCount = 0; - _dragAccept = 0; - _dragFlag = 0; + _dragAccept = false; + _dragEnd = false; + _dragFlag = false; _dragMode = 0; _dragCount = 0; - _dragEnd = 0; _lastClickRem = 0; _windowNum = 0; @@ -308,7 +307,7 @@ AGOSEngine::AGOSEngine(OSystem *syst) _fastFadeOutFlag = 0; _exitCutscene = 0; _paletteFlag = 0; - _bottomPalette = 0; + _bottomPalette = false; _picture8600 = 0; _soundFileId = 0; @@ -389,8 +388,8 @@ AGOSEngine::AGOSEngine(OSystem *syst) _superRoomNumber = 0; _wallOn = 0; + _boxCR = false; _boxLineCount = 0; - _boxCR = 0; memset(_boxBuffer, 0, sizeof(_boxBuffer)); _boxBufferPtr = _boxBuffer; @@ -550,11 +549,6 @@ Common::Error AGOSEngine::init() { initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP); - // Setup mixer - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) || (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) || ((getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformAcorn) || @@ -586,6 +580,9 @@ Common::Error AGOSEngine::init() { _driver = NULL; } + // Setup mixer + syncSoundSettings(); + // allocate buffers _backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1); @@ -657,17 +654,15 @@ Common::Error AGOSEngine::init() { } // TODO: Use special debug levels instead of the following hack. - // Also, the current variable names (_continousMainScript, ...) - // are not very suggestive. _debugMode = (gDebugLevel >= 0); if (gDebugLevel == 2) - _continousMainScript = true; + _dumpOpcodes = true; if (gDebugLevel == 3) - _continousVgaScript = true; + _dumpVgaOpcodes = true; if (gDebugLevel == 4) - _startMainScript = true; + _dumpScripts = true; if (gDebugLevel == 5) - _startVgaScript = true; + _dumpVgaScripts = true; return Common::kNoError; } @@ -882,7 +877,6 @@ void AGOSEngine::setupGame() { } AGOSEngine::~AGOSEngine() { - // Sync with AGOSEngine::shutdown() // In Simon 2, this gets deleted along with _sound further down if (getGameType() != GType_SIMON2) delete _gameFile; @@ -1036,7 +1030,9 @@ void AGOSEngine::syncSoundSettings() { _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); + + if (_midiEnabled) + _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); } } // End of namespace AGOS diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 124dc48691..c10112a22b 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -175,7 +175,7 @@ class AGOSEngine : public Engine { public: virtual void setupOpcodes(); - int _numOpcodes, _opcode; + uint16 _numOpcodes, _opcode; typedef void (AGOSEngine::*VgaOpcodeProc) (); @@ -201,7 +201,7 @@ protected: void playSting(uint16 a); const byte *_vcPtr; /* video code ptr */ - uint16 _vc_get_out_of_code; + uint16 _vcGetOutOfCode; uint32 *_gameOffsetsPtr; @@ -231,13 +231,13 @@ protected: byte *_strippedTxtMem; byte *_textMem; - uint _textSize; - uint _stringTabNum, _stringTabPos, _stringtab_numalloc; + uint32 _textSize; + uint32 _stringTabNum, _stringTabPos, _stringTabSize; byte **_stringTabPtr; Item **_itemArrayPtr; - uint _itemArraySize; - uint _itemArrayInited; + uint32 _itemArraySize; + uint32 _itemArrayInited; Common::Array _itemHeap; @@ -246,7 +246,7 @@ protected: const byte *_codePtr; byte **_localStringtable; - uint _stringIdLocalMin, _stringIdLocalMax; + uint16 _stringIdLocalMin, _stringIdLocalMax; RoomState *_roomStates; uint16 _numRoomStates; @@ -257,17 +257,16 @@ protected: byte *_xtblList; byte *_xtablesHeapPtrOrg; - uint _xtablesHeapCurPosOrg; + uint32 _xtablesHeapCurPosOrg; Subroutine *_xsubroutineListOrg; byte *_tblList; byte *_tablesHeapPtr, *_tablesHeapPtrOrg, *_tablesheapPtrNew; - uint _tablesHeapSize, _tablesHeapCurPos, _tablesHeapCurPosOrg; - uint _tablesHeapCurPosNew; + uint32 _tablesHeapSize, _tablesHeapCurPos, _tablesHeapCurPosOrg; + uint32 _tablesHeapCurPosNew; Subroutine *_subroutineListOrg; Subroutine *_subroutineList; - uint _subroutine; uint16 _dxSurfacePitch; @@ -280,7 +279,7 @@ protected: bool _scriptVar2; bool _runScriptReturn1; bool _runScriptCondition[40]; - int _runScriptReturn[40]; + int16 _runScriptReturn[40]; bool _skipVgaWait; bool _noParentNotify; bool _beardLoaded; @@ -297,10 +296,10 @@ protected: uint16 _language; bool _copyProtection; bool _pause; - bool _startMainScript; - bool _continousMainScript; - bool _startVgaScript; - bool _continousVgaScript; + bool _dumpScripts; + bool _dumpOpcodes; + bool _dumpVgaScripts; + bool _dumpVgaOpcodes; bool _dumpImages; bool _speech; bool _subtitles; @@ -314,20 +313,20 @@ protected: const byte *_scrollImage; byte _boxStarHeight; + bool _boxCR; char _boxBuffer[310]; char *_boxBufferPtr; int _boxLineCount; int _lineCounts[6]; char *_linePtrs[6]; - int _boxCR; SubroutineLine *_classLine; - uint _classMask, _classMode1, _classMode2; + int16 _classMask, _classMode1, _classMode2; Item *_findNextPtr; Subroutine *_currentTable; SubroutineLine *_currentLine; - int _agosMenu; + uint8 _agosMenu; byte _textMenu[10]; uint16 _currentRoom, _superRoomNumber; uint8 _wallOn; @@ -352,17 +351,17 @@ protected: Item *_hitAreaSubjectItem; HitArea *_currentBox, *_currentVerbBox, *_lastVerbOn; uint16 _currentBoxNum; - uint _needHitAreaRecalc; - uint _verbHitArea; + uint16 _needHitAreaRecalc; + uint16 _verbHitArea; uint16 _defaultVerb; - uint _iOverflow; - uint _nameLocked; - - uint _dragAccept; - uint _dragFlag; - uint _dragMode; - uint _dragCount; - uint _dragEnd; + bool _iOverflow; + bool _nameLocked; + + bool _dragAccept; + bool _dragEnd; + bool _dragFlag; + uint8 _dragMode; + uint8 _dragCount; HitArea *_lastClickRem; uint16 _windowNum; @@ -370,7 +369,7 @@ protected: int16 _printCharCurPos, _printCharMaxPos, _printCharPixelCount; uint16 _numLettersToPrint; - uint _numTextBoxes; + uint8 _numTextBoxes; uint32 getTime() const; @@ -390,7 +389,7 @@ protected: byte _mouseAnim, _mouseAnimMax, _mouseCursor; byte _currentMouseAnim, _currentMouseCursor; byte _oldMouseAnimMax, _oldMouseCursor; - uint _mouseHideCount; + uint16 _mouseHideCount; bool _mouseToggle; byte _leftButtonDown; @@ -409,18 +408,18 @@ protected: bool _fastFadeOutFlag; byte _paletteFlag; - int _bottomPalette; - uint _fastFadeCount; + bool _bottomPalette; + uint16 _fastFadeCount; volatile uint16 _fastFadeInFlag; - int _screenWidth, _screenHeight; + uint16 _screenWidth, _screenHeight; uint16 _noOverWrite; bool _rejectBlock; bool _exitCutscene, _picture8600; - uint _soundFileId; + uint16 _soundFileId; int16 _lastMusicPlayed; int16 _nextMusicToPlay; @@ -428,7 +427,7 @@ protected: bool _showMessageFlag; bool _newDirtyClip; - uint _copyScnFlag, _vgaSpriteChanged; + uint16 _copyScnFlag, _vgaSpriteChanged; byte *_block, *_blockEnd; byte *_vgaMemPtr, *_vgaMemEnd, *_vgaMemBase; @@ -558,9 +557,9 @@ protected: Debugger *_debugger; - uint _saveGameNameLen; - uint _saveLoadRowCurPos; - uint _numSaveGameRows; + uint8 _saveGameNameLen; + uint16 _saveLoadRowCurPos; + uint16 _numSaveGameRows; bool _saveDialogFlag; bool _saveOrLoad; bool _saveLoadEdit; @@ -632,7 +631,7 @@ protected: byte *readSingleOpcode(Common::SeekableReadStream *in, byte *ptr); void readSubroutineBlock(Common::SeekableReadStream *in); - Subroutine *getSubroutineByID(uint subroutine_id); + Subroutine *getSubroutineByID(uint subroutineId); /* used in debugger */ void dumpAllSubroutines(); @@ -676,7 +675,7 @@ protected: const byte *getLocalStringByID(uint16 stringId); uint getNextStringID(); - void addTimeEvent(uint16 timeout, uint16 subroutine_id); + void addTimeEvent(uint16 timeout, uint16 subroutineId); void delTimeEvent(TimeEvent *te); Item *findInByClass(Item *i, int16 m); @@ -1184,13 +1183,13 @@ protected: void clearSurfaces(); void displayScreen(); - void dumpVideoScript(const byte *src, bool one_opcode_only); + void dumpVideoScript(const byte *src, bool singeOpcode); virtual void dumpVgaFile(const byte *vga); - void dumpVgaScript(const byte *ptr, uint res, uint id); - void dumpVgaScriptAlways(const byte *ptr, uint res, uint id); + void dumpVgaScript(const byte *ptr, uint16 res, uint16 id); + void dumpVgaScriptAlways(const byte *ptr, uint16 res, uint16 id); void dumpVgaBitmaps(const byte *vga, byte *vga1, int res); void dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base); - void dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, byte base); + void dumpBitmap(const char *filename, const byte *offs, uint16 w, uint16 h, int flags, const byte *palette, byte base); void fillBackFromBackGround(uint16 height, uint16 width); void fillBackFromFront(); @@ -1202,8 +1201,8 @@ protected: void quickLoadOrSave(); - byte *vc10_uncompressFlip(const byte *src, uint w, uint h); - byte *vc10_flip(const byte *src, uint w, uint h); + byte *vc10_uncompressFlip(const byte *src, uint16 w, uint16 h); + byte *vc10_flip(const byte *src, uint16 w, uint16 h); Item *getNextItemPtrStrange(); @@ -1229,8 +1228,8 @@ protected: void waitForMark(uint i); void scrollScreen(); - void decodeColumn(byte *dst, const byte *src, int height); - void decodeRow(byte *dst, const byte *src, int width); + void decodeColumn(byte *dst, const byte *src, uint16 height); + void decodeRow(byte *dst, const byte *src, uint16 width); void hitarea_stuff_helper_2(); void fastFadeIn(); void slowFadeIn(); diff --git a/engines/agos/debug.cpp b/engines/agos/debug.cpp index db881a0049..069af828c3 100644 --- a/engines/agos/debug.cpp +++ b/engines/agos/debug.cpp @@ -34,7 +34,7 @@ namespace AGOS { const byte *AGOSEngine::dumpOpcode(const byte *p) { - uint opcode; + uint16 opcode; const char *s, *st; if (getGameType() == GType_ELVIRA1) { @@ -54,10 +54,10 @@ const byte *AGOSEngine::dumpOpcode(const byte *p) { st = s = feeblefiles_opcodeNameTable[opcode]; } else if (getGameType() == GType_SIMON2 && getFeatures() & GF_TALKIE) { st = s = simon2talkie_opcodeNameTable[opcode]; - } else if (getFeatures() & GF_TALKIE) { - st = s = simon1talkie_opcodeNameTable[opcode]; } else if (getGameType() == GType_SIMON2) { st = s = simon2dos_opcodeNameTable[opcode]; + } else if (getFeatures() & GF_TALKIE) { + st = s = simon1talkie_opcodeNameTable[opcode]; } else if (getGameType() == GType_SIMON1) { st = s = simon1dos_opcodeNameTable[opcode]; } else if (getGameType() == GType_WW) { @@ -207,8 +207,8 @@ void AGOSEngine::dumpAllSubroutines() { } } -void AGOSEngine::dumpVideoScript(const byte *src, bool one_opcode_only) { - uint opcode; +void AGOSEngine::dumpVideoScript(const byte *src, bool singeOpcode) { + uint16 opcode; const char *str, *strn; do { @@ -281,14 +281,14 @@ void AGOSEngine::dumpVideoScript(const byte *src, bool one_opcode_only) { } printf("\n"); - } while (!one_opcode_only); + } while (!singeOpcode); } -void AGOSEngine::dumpVgaScript(const byte *ptr, uint res, uint id) { +void AGOSEngine::dumpVgaScript(const byte *ptr, uint16 res, uint16 id) { dumpVgaScriptAlways(ptr, res, id); } -void AGOSEngine::dumpVgaScriptAlways(const byte *ptr, uint res, uint id) { +void AGOSEngine::dumpVgaScriptAlways(const byte *ptr, uint16 res, uint16 id) { printf("; address=%x, vgafile=%d vgasprite=%d\n", (unsigned int)(ptr - _vgaBufferPointers[res].vgaFile1), res, id); dumpVideoScript(ptr, false); @@ -298,15 +298,15 @@ void AGOSEngine::dumpVgaScriptAlways(const byte *ptr, uint res, uint id) { void AGOSEngine_Feeble::dumpVgaFile(const byte *vga) { const byte *pp; const byte *p; - int count; + int16 count; pp = vga; p = pp + READ_LE_UINT16(pp + 2); - count = READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->animationCount); - p = pp + READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->animationTable); + count = READ_LE_UINT16(&((const VgaFile1Header_Feeble *) p)->animationCount); + p = pp + READ_LE_UINT16(&((const VgaFile1Header_Feeble *) p)->animationTable); while (--count >= 0) { - int id = READ_LE_UINT16(&((const AnimationHeader_Feeble *) p)->id); + uint16 id = READ_LE_UINT16(&((const AnimationHeader_Feeble *) p)->id); dumpVgaScriptAlways(vga + READ_LE_UINT16(&((const AnimationHeader_Feeble *) p)->scriptOffs), id / 100, id); p += sizeof(AnimationHeader_Feeble); @@ -314,11 +314,11 @@ void AGOSEngine_Feeble::dumpVgaFile(const byte *vga) { pp = vga; p = pp + READ_LE_UINT16(pp + 2); - count = READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->imageCount); - p = pp + READ_LE_UINT16(&((const VgaFileHeader2_Feeble *) p)->imageTable); + count = READ_LE_UINT16(&((const VgaFile1Header_Feeble *) p)->imageCount); + p = pp + READ_LE_UINT16(&((const VgaFile1Header_Feeble *) p)->imageTable); while (--count >= 0) { - int id = READ_LE_UINT16(&((const ImageHeader_Feeble *) p)->id); + uint16 id = READ_LE_UINT16(&((const ImageHeader_Feeble *) p)->id); dumpVgaScriptAlways(vga + READ_LE_UINT16(&((const ImageHeader_Feeble *) p)->scriptOffs), id / 100, id); p += sizeof(ImageHeader_Feeble); @@ -328,15 +328,15 @@ void AGOSEngine_Feeble::dumpVgaFile(const byte *vga) { void AGOSEngine_Simon1::dumpVgaFile(const byte *vga) { const byte *pp; const byte *p; - int count; + int16 count; pp = vga; p = pp + READ_BE_UINT16(pp + 4); - count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationCount); - p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationTable); + count = READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->animationCount); + p = pp + READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->animationTable); while (--count >= 0) { - int id = READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->id); + uint16 id = READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->id); dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->scriptOffs), id / 100, id); p += sizeof(AnimationHeader_Simon); @@ -344,11 +344,11 @@ void AGOSEngine_Simon1::dumpVgaFile(const byte *vga) { pp = vga; p = pp + READ_BE_UINT16(pp + 4); - count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageCount); - p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageTable); + count = READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->imageCount); + p = pp + READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->imageTable); while (--count >= 0) { - int id = READ_BE_UINT16(&((const ImageHeader_Simon *) p)->id); + uint16 id = READ_BE_UINT16(&((const ImageHeader_Simon *) p)->id); dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const ImageHeader_Simon *) p)->scriptOffs), id / 100, id); p += sizeof(ImageHeader_Simon); @@ -358,15 +358,15 @@ void AGOSEngine_Simon1::dumpVgaFile(const byte *vga) { void AGOSEngine::dumpVgaFile(const byte *vga) { const byte *pp; const byte *p; - int count; + int16 count; pp = vga; p = pp + READ_BE_UINT16(pp + 10) + 20; - count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationCount); - p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->animationTable); + count = READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->animationCount); + p = pp + READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->animationTable); while (--count >= 0) { - int id = READ_BE_UINT16(&((const AnimationHeader_WW *) p)->id); + uint16 id = READ_BE_UINT16(&((const AnimationHeader_WW *) p)->id); dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const AnimationHeader_WW *) p)->scriptOffs), id / 100, id); p += sizeof(AnimationHeader_WW); @@ -374,11 +374,11 @@ void AGOSEngine::dumpVgaFile(const byte *vga) { pp = vga; p = pp + READ_BE_UINT16(pp + 10) + 20; - count = READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageCount); - p = pp + READ_BE_UINT16(&((const VgaFileHeader2_Common *) p)->imageTable); + count = READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->imageCount); + p = pp + READ_BE_UINT16(&((const VgaFile1Header_Common *) p)->imageTable); while (--count >= 0) { - int id = READ_BE_UINT16(&((const ImageHeader_WW *) p)->id); + uint16 id = READ_BE_UINT16(&((const ImageHeader_WW *) p)->id); dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const ImageHeader_WW *) p)->scriptOffs), id / 100, id); p += sizeof(ImageHeader_WW); @@ -436,7 +436,7 @@ void dumpBMP(const char *filename, int w, int h, const byte *bytes, const uint32 } } -void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, +void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, uint16 w, uint16 h, int flags, const byte *palette, byte base) { if (getGameType() != GType_FF && getGameType() != GType_PP) diff --git a/engines/agos/debugger.cpp b/engines/agos/debugger.cpp index c60ebb7693..578475bf78 100644 --- a/engines/agos/debugger.cpp +++ b/engines/agos/debugger.cpp @@ -210,7 +210,7 @@ bool Debugger::Cmd_StartSubroutine(int argc, const char **argv) { if (sub != NULL) _vm->startSubroutine(sub); } else - DebugPrintf("Subroutine %d\n", _vm->_subroutine); + DebugPrintf("Subroutine %d\n", _vm->_currentTable->id); return true; } diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 39e6e12d9a..b90889f460 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -84,8 +84,8 @@ void vc10_skip_cols(VC10_state *vs) { } } -void AGOSEngine::decodeColumn(byte *dst, const byte *src, int height) { - const uint pitch = _dxSurfacePitch; +void AGOSEngine::decodeColumn(byte *dst, const byte *src, uint16 height) { + const uint16 pitch = _dxSurfacePitch; int8 reps = (int8)0x80; byte color; byte *dstPtr = dst; @@ -128,8 +128,8 @@ void AGOSEngine::decodeColumn(byte *dst, const byte *src, int height) { } } -void AGOSEngine::decodeRow(byte *dst, const byte *src, int width) { - const uint pitch = _dxSurfacePitch; +void AGOSEngine::decodeRow(byte *dst, const byte *src, uint16 width) { + const uint16 pitch = _dxSurfacePitch; int8 reps = (int8)0x80; byte color; byte *dstPtr = dst; @@ -1083,8 +1083,8 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i pp = _curVgaFile1; if (getGameType() == GType_FF || getGameType() == GType_PP) { p = pp + READ_LE_UINT16(pp + 2); - count = READ_LE_UINT16(&((VgaFileHeader2_Feeble *) p)->animationCount); - p = pp + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) p)->animationTable); + count = READ_LE_UINT16(&((VgaFile1Header_Feeble *) p)->animationCount); + p = pp + READ_LE_UINT16(&((VgaFile1Header_Feeble *) p)->animationTable); while (count--) { if (READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->id) == vgaSpriteId) @@ -1094,8 +1094,8 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i assert(READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->id) == vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { p = pp + READ_BE_UINT16(pp + 4); - count = READ_BE_UINT16(&((VgaFileHeader2_Common *) p)->animationCount); - p = pp + READ_BE_UINT16(&((VgaFileHeader2_Common *) p)->animationTable); + count = READ_BE_UINT16(&((VgaFile1Header_Common *) p)->animationCount); + p = pp + READ_BE_UINT16(&((VgaFile1Header_Common *) p)->animationTable); while (count--) { if (READ_BE_UINT16(&((AnimationHeader_Simon *) p)->id) == vgaSpriteId) @@ -1108,8 +1108,8 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i p = pp + READ_BE_UINT16(pp + 10); p += 20; - count = READ_BE_UINT16(&((VgaFileHeader2_Common *) p)->animationCount); - p = pp + READ_BE_UINT16(&((VgaFileHeader2_Common *) p)->animationTable); + count = READ_BE_UINT16(&((VgaFile1Header_Common *) p)->animationCount); + p = pp + READ_BE_UINT16(&((VgaFile1Header_Common *) p)->animationTable); while (count--) { if (READ_BE_UINT16(&((AnimationHeader_WW *) p)->id) == vgaSpriteId) @@ -1139,7 +1139,7 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i } #endif - if (_startVgaScript) { + if (_dumpVgaScripts) { if (getGameType() == GType_FF || getGameType() == GType_PP) { dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { @@ -1194,8 +1194,8 @@ void AGOSEngine::setImage(uint16 vgaSpriteId, bool vgaScript) { bb = _curVgaFile1; if (getGameType() == GType_FF || getGameType() == GType_PP) { b = bb + READ_LE_UINT16(bb + 2); - count = READ_LE_UINT16(&((VgaFileHeader2_Feeble *) b)->imageCount); - b = bb + READ_LE_UINT16(&((VgaFileHeader2_Feeble *) b)->imageTable); + count = READ_LE_UINT16(&((VgaFile1Header_Feeble *) b)->imageCount); + b = bb + READ_LE_UINT16(&((VgaFile1Header_Feeble *) b)->imageTable); while (count--) { if (READ_LE_UINT16(&((ImageHeader_Feeble *) b)->id) == vgaSpriteId) @@ -1205,8 +1205,8 @@ void AGOSEngine::setImage(uint16 vgaSpriteId, bool vgaScript) { assert(READ_LE_UINT16(&((ImageHeader_Feeble *) b)->id) == vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { b = bb + READ_BE_UINT16(bb + 4); - count = READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->imageCount); - b = bb + READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->imageTable); + count = READ_BE_UINT16(&((VgaFile1Header_Common *) b)->imageCount); + b = bb + READ_BE_UINT16(&((VgaFile1Header_Common *) b)->imageTable); while (count--) { if (READ_BE_UINT16(&((ImageHeader_Simon *) b)->id) == vgaSpriteId) @@ -1221,8 +1221,8 @@ void AGOSEngine::setImage(uint16 vgaSpriteId, bool vgaScript) { b = bb + READ_BE_UINT16(bb + 10); b += 20; - count = READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->imageCount); - b = bb + READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->imageTable); + count = READ_BE_UINT16(&((VgaFile1Header_Common *) b)->imageCount); + b = bb + READ_BE_UINT16(&((VgaFile1Header_Common *) b)->imageTable); while (count--) { if (READ_BE_UINT16(&((ImageHeader_WW *) b)->id) == vgaSpriteId) @@ -1235,7 +1235,7 @@ void AGOSEngine::setImage(uint16 vgaSpriteId, bool vgaScript) { clearVideoWindow(_windowNum, READ_BE_UINT16(&((ImageHeader_WW *) b)->color)); } - if (_startVgaScript) { + if (_dumpVgaScripts) { if (getGameType() == GType_FF || getGameType() == GType_PP) { dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble*)b)->scriptOffs), zoneNum, vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 33701e4933..5ad678b05f 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -598,19 +598,19 @@ bool AGOSEngine::processSpecialKeys() { break; case Common::KEYCODE_r: if (_debugMode) - _startMainScript ^= 1; + _dumpScripts ^= 1; break; case Common::KEYCODE_o: if (_debugMode) - _continousMainScript ^= 1; + _dumpOpcodes ^= 1; break; case Common::KEYCODE_a: if (_debugMode) - _startVgaScript ^= 1; + _dumpVgaScripts ^= 1; break; case Common::KEYCODE_g: if (_debugMode) - _continousVgaScript ^= 1; + _dumpVgaOpcodes ^= 1; break; case Common::KEYCODE_d: if (_debugMode) diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index b3dc1e7a56..a33a16bbc9 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -110,43 +110,43 @@ void AGOSEngine::loadOffsets(const char *filename, int number, uint32 &file, uin } int AGOSEngine::allocGamePcVars(Common::SeekableReadStream *in) { - uint item_array_size, item_array_inited, stringtable_num; + uint32 itemArraySize, itemArrayInited, stringTableNum; uint32 version; - uint i; + uint32 i; - item_array_size = in->readUint32BE(); + itemArraySize = in->readUint32BE(); version = in->readUint32BE(); - item_array_inited = in->readUint32BE(); - stringtable_num = in->readUint32BE(); + itemArrayInited = in->readUint32BE(); + stringTableNum = in->readUint32BE(); // First two items are predefined if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) { - item_array_size += 2; - item_array_inited = item_array_size; + itemArraySize += 2; + itemArrayInited = itemArraySize; } else { - item_array_inited += 2; - item_array_size += 2; + itemArrayInited += 2; + itemArraySize += 2; } if (version != 0x80) error("allocGamePcVars: Not a runtime database"); - _itemArrayPtr = (Item **)calloc(item_array_size, sizeof(Item *)); + _itemArrayPtr = (Item **)calloc(itemArraySize, sizeof(Item *)); if (_itemArrayPtr == NULL) error("allocGamePcVars: Out of memory for Item array"); - _itemArraySize = item_array_size; - _itemArrayInited = item_array_inited; + _itemArraySize = itemArraySize; + _itemArrayInited = itemArrayInited; - for (i = 1; i < item_array_inited; i++) { + for (i = 1; i < itemArrayInited; i++) { _itemArrayPtr[i] = (Item *)allocateItem(sizeof(Item)); } // The rest is cleared automatically by calloc - allocateStringTable(stringtable_num + 10); - _stringTabNum = stringtable_num; + allocateStringTable(stringTableNum + 10); + _stringTabNum = stringTableNum; - return item_array_inited; + return itemArrayInited; } void AGOSEngine::loadGamePcFile() { diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index dffa33612f..0a55071d26 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -581,7 +581,7 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { void AGOSEngine_Simon1::listSaveGames(char *dst) { Common::InSaveFile *in; - uint i, slot, lastSlot; + uint16 i, slot, lastSlot; disableFileBoxes(); diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index edbb3a7a72..5eb864d40b 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -845,9 +845,9 @@ void AGOSEngine::o_freezeZones() { // 138: freeze zones freezeBottom(); - if (!_copyProtection && !(getFeatures() & GF_TALKIE)) { - if ((getGameType() == GType_SIMON1 && _subroutine == 2924) || - (getGameType() == GType_SIMON2 && _subroutine == 1322)) { + if (!_copyProtection && !(getFeatures() & GF_TALKIE) && _currentTable) { + if ((getGameType() == GType_SIMON1 && _currentTable->id == 2924) || + (getGameType() == GType_SIMON2 && _currentTable->id == 1322)) { _variableArray[134] = 3; _variableArray[135] = 3; setBitFlag(135, 1); @@ -978,7 +978,7 @@ int AGOSEngine::runScript() { return 1; do { - if (_continousMainScript) + if (_dumpOpcodes) dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index 1b203a4e72..e5680abf7e 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -469,7 +469,7 @@ void AGOSEngine_Elvira2::oe2_bNotZero() { uint bit = getVarWrapper(); // WORKAROUND: Enable copy protection again, in cracked version. - if (getGameType() == GType_SIMON1 && _subroutine == 2962 && bit == 63) { + if (getGameType() == GType_SIMON1 && _currentTable && _currentTable->id == 2962 && bit == 63) { bit = 50; } diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index 7643f7f49f..3c651cce0c 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -170,7 +170,7 @@ TextLocation *AGOSEngine::getTextLocation(uint a) { void AGOSEngine::allocateStringTable(int num) { _stringTabPtr = (byte **)calloc(num, sizeof(byte *)); _stringTabPos = 0; - _stringtab_numalloc = num; + _stringTabSize = num; } void AGOSEngine::setupStringTable(byte *mem, int num) { @@ -283,7 +283,7 @@ void AGOSEngine::loadTextIntoMem(uint16 stringId) { byte *p; char filename[30]; int i; - uint base_min = 0x8000, base_max, size; + uint16 baseMin = 0x8000, baseMax, size; _tablesHeapPtr = _tablesheapPtrNew; _tablesHeapCurPos = _tablesHeapCurPosNew; @@ -301,22 +301,22 @@ void AGOSEngine::loadTextIntoMem(uint16 stringId) { sprintf(filename, "%s.DAT", filename); } - base_max = (p[0] * 256) | p[1]; + baseMax = (p[0] * 256) | p[1]; p += 2; - if (stringId < base_max) { - _stringIdLocalMin = base_min; - _stringIdLocalMax = base_max; + if (stringId < baseMax) { + _stringIdLocalMin = baseMin; + _stringIdLocalMax = baseMax; _localStringtable = (byte **)_tablesHeapPtr; - size = (base_max - base_min + 1) * sizeof(byte *); + size = (baseMax - baseMin + 1) * sizeof(byte *); _tablesHeapPtr += size; _tablesHeapCurPos += size; size = loadTextFile(filename, _tablesHeapPtr); - setupLocalStringTable(_tablesHeapPtr, base_max - base_min + 1); + setupLocalStringTable(_tablesHeapPtr, baseMax - baseMin + 1); _tablesHeapPtr += size; _tablesHeapCurPos += size; @@ -327,7 +327,7 @@ void AGOSEngine::loadTextIntoMem(uint16 stringId) { return; } - base_min = base_max; + baseMin = baseMax; } error("loadTextIntoMem: didn't find %d", stringId); diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index 897842f0dc..3ff34cdc6f 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -193,31 +193,29 @@ static const char *const opcodeArgTable_puzzlepack[256] = { " ", " ", "BT ", " ", "B ", " ", "BBBB ", " ", " ", "BBBB ", "B ", "B ", "B ", "B " }; -Subroutine *AGOSEngine::getSubroutineByID(uint subroutine_id) { +Subroutine *AGOSEngine::getSubroutineByID(uint subroutineId) { Subroutine *cur; - _subroutine = subroutine_id; - for (cur = _subroutineList; cur; cur = cur->next) { - if (cur->id == subroutine_id) + if (cur->id == subroutineId) return cur; } - if (loadXTablesIntoMem(subroutine_id)) { + if (loadXTablesIntoMem(subroutineId)) { for (cur = _subroutineList; cur; cur = cur->next) { - if (cur->id == subroutine_id) + if (cur->id == subroutineId) return cur; } } - if (loadTablesIntoMem(subroutine_id)) { + if (loadTablesIntoMem(subroutineId)) { for (cur = _subroutineList; cur; cur = cur->next) { - if (cur->id == subroutine_id) + if (cur->id == subroutineId) return cur; } } - debug(0,"getSubroutineByID: subroutine %d not found", subroutine_id); + debug(0,"getSubroutineByID: subroutine %d not found", subroutineId); return NULL; } @@ -534,7 +532,7 @@ int AGOSEngine::startSubroutine(Subroutine *sub) { _classMode1 = 0; _classMode2 = 0; - if (_startMainScript) + if (_dumpScripts) dumpSubroutine(sub); if (++_recursionDepth > 40) @@ -568,7 +566,7 @@ restart: else _codePtr += 8; - if (_continousMainScript) + if (_dumpOpcodes) printf("; %d\n", sub->id); result = runScript(); if (result != 0) { diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index 5120573249..af0c7cba1b 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -152,8 +152,8 @@ void AGOSEngine::runVgaScript() { for (;;) { uint opcode; - if (_continousVgaScript) { - if (_vcPtr != (const byte *)&_vc_get_out_of_code) { + if (_dumpVgaOpcodes) { + if (_vcPtr != (const byte *)&_vcGetOutOfCode) { printf("%.5d %.5X: %5d %4d ", _vgaTickCounter, (unsigned int)(_vcPtr - _curVgaFile1), _vgaCurSpriteId, _vgaCurZoneNum); dumpVideoScript(_vcPtr, true); } @@ -367,7 +367,7 @@ void AGOSEngine::vcSkipNextInstruction() { _vcPtr += opcodeParamLenElvira1[opcode]; } - if (_continousVgaScript) + if (_dumpVgaOpcodes) printf("; skipped\n"); } @@ -472,7 +472,7 @@ void AGOSEngine::vc9_ifObjectStateIs() { vcSkipNextInstruction(); } -byte *AGOSEngine::vc10_uncompressFlip(const byte *src, uint w, uint h) { +byte *AGOSEngine::vc10_uncompressFlip(const byte *src, uint16 w, uint16 h) { w *= 8; byte *dst, *dstPtr, *srcPtr; @@ -539,7 +539,7 @@ byte *AGOSEngine::vc10_uncompressFlip(const byte *src, uint w, uint h) { return _videoBuf1; } -byte *AGOSEngine::vc10_flip(const byte *src, uint w, uint h) { +byte *AGOSEngine::vc10_flip(const byte *src, uint16 w, uint16 h) { byte *dstPtr; uint i; @@ -717,7 +717,7 @@ void AGOSEngine::vc12_delay() { num += _vgaBaseDelay; addVgaEvent(num, ANIMATE_EVENT, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; } void AGOSEngine::vc13_addToSpriteX() { @@ -770,7 +770,7 @@ void AGOSEngine::vc16_waitSync() { vfs->id = _vgaCurSpriteId; vfs->zoneNum = _vgaCurZoneNum; - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; } void AGOSEngine::checkWaitEndTable() { @@ -801,7 +801,7 @@ void AGOSEngine::vc17_waitEnd() { vfs->codePtr = _vcPtr; vfs->id = _vgaCurSpriteId; vfs->zoneNum = _vgaCurZoneNum; - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; } } @@ -818,8 +818,8 @@ void AGOSEngine::vc19_loop() { b = _curVgaFile1 + READ_BE_UINT16(bb + 10); b += 20; - count = READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->animationCount); - b = bb + READ_BE_UINT16(&((VgaFileHeader2_Common *) b)->animationTable); + count = READ_BE_UINT16(&((VgaFile1Header_Common *) b)->animationCount); + b = bb + READ_BE_UINT16(&((VgaFile1Header_Common *) b)->animationTable); while (count--) { if (READ_BE_UINT16(&((AnimationHeader_WW *) b)->id) == _vgaCurSpriteId) @@ -975,7 +975,7 @@ void AGOSEngine::vc25_halt_sprite() { memcpy(vsp, vsp + 1, sizeof(VgaSprite)); vsp++; } - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; dirtyBackGround(); _vgaSpriteChanged++; @@ -1295,7 +1295,7 @@ void AGOSEngine::vc42_delayIfNotEQ() { uint16 val = vcReadVar(vcReadNextWord()); if (val != vcReadNextWord()) { addVgaEvent(_frameCount + 1, ANIMATE_EVENT, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum); - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; } } diff --git a/engines/agos/vga.h b/engines/agos/vga.h index 1994f59f7f..2a2056ca7b 100644 --- a/engines/agos/vga.h +++ b/engines/agos/vga.h @@ -31,7 +31,7 @@ namespace AGOS { #include "common/pack-start.h" // START STRUCT PACKING // Feeble Files -struct VgaFileHeader2_Feeble { +struct VgaFile1Header_Feeble { uint16 imageCount; uint16 x_2; uint16 animationCount; @@ -86,7 +86,7 @@ struct AnimationHeader_WW { } PACKED_STRUCT; // Common -struct VgaFileHeader2_Common { +struct VgaFile1Header_Common { uint16 x_1; uint16 imageCount; uint16 x_2; diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp index 82f0811811..e823a43852 100644 --- a/engines/agos/vga_s2.cpp +++ b/engines/agos/vga_s2.cpp @@ -61,7 +61,7 @@ void AGOSEngine::vc56_delayLong() { } addVgaEvent(num + _vgaBaseDelay, ANIMATE_EVENT, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum); - _vcPtr = (byte *)&_vc_get_out_of_code; + _vcPtr = (byte *)&_vcGetOutOfCode; } void AGOSEngine::vc58_changePriority() { -- cgit v1.2.3