diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/animator_v1.cpp | 85 | ||||
-rw-r--r-- | engines/kyra/debugger.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/kyra.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/resource.cpp | 22 | ||||
-rw-r--r-- | engines/kyra/resource.h | 22 | ||||
-rw-r--r-- | engines/kyra/saveload_v1.cpp | 23 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 246 | ||||
-rw-r--r-- | engines/kyra/screen_v2.cpp | 55 | ||||
-rw-r--r-- | engines/kyra/script.cpp | 36 | ||||
-rw-r--r-- | engines/kyra/script_v1.cpp | 94 | ||||
-rw-r--r-- | engines/kyra/seqplayer.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/sound.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sound.h | 2 | ||||
-rw-r--r-- | engines/kyra/sound_adlib.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/sound_towns.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sprites.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 68 | ||||
-rw-r--r-- | engines/kyra/text.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/vqa.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/wsamovie.cpp | 68 |
20 files changed, 404 insertions, 407 deletions
diff --git a/engines/kyra/animator_v1.cpp b/engines/kyra/animator_v1.cpp index 4169b59a36..82b7e34dbe 100644 --- a/engines/kyra/animator_v1.cpp +++ b/engines/kyra/animator_v1.cpp @@ -23,7 +23,6 @@ * */ -#include "common/stdafx.h" #include "common/endian.h" #include "kyra/kyra_v1.h" @@ -88,7 +87,7 @@ void ScreenAnimator::initAnimStateList() { animStates[0].height = 48; animStates[0].width2 = 4; animStates[0].height2 = 3; - + for (int i = 1; i <= 4; ++i) { animStates[i].index = i; animStates[i].active = 0; @@ -100,13 +99,13 @@ void ScreenAnimator::initAnimStateList() { animStates[i].width2 = 4; animStates[i].height2 = 3; } - + for (int i = 5; i < 16; ++i) { animStates[i].index = i; animStates[i].active = 0; animStates[i].flags = 0; } - + for (int i = 16; i < 28; ++i) { animStates[i].index = i; animStates[i].flags = 0; @@ -157,7 +156,7 @@ void ScreenAnimator::restoreAllObjectBackgrounds() { debugC(9, kDebugLevelAnimator, "ScreenAnimator::restoreAllObjectBackground()"); AnimObject *curObject = _objectQueue; _screen->_curPage = 2; - + while (curObject) { if (curObject->active && !curObject->disable) { preserveOrRestoreBackground(curObject, true); @@ -166,7 +165,7 @@ void ScreenAnimator::restoreAllObjectBackgrounds() { } curObject = curObject->nextAnimObject; } - + _screen->_curPage = 0; } @@ -174,7 +173,7 @@ void ScreenAnimator::preserveAnyChangedBackgrounds() { debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAnyChangedBackgrounds()"); AnimObject *curObject = _objectQueue; _screen->_curPage = 2; - + while (curObject) { if (curObject->active && !curObject->disable && curObject->bkgdChangeFlag) { preserveOrRestoreBackground(curObject, false); @@ -182,14 +181,14 @@ void ScreenAnimator::preserveAnyChangedBackgrounds() { } curObject = curObject->nextAnimObject; } - + _screen->_curPage = 0; } void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) { debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore); int x = 0, y = 0, width = obj->width, height = obj->height; - + if (restore) { x = obj->x2 >> 3; y = obj->y2; @@ -197,14 +196,14 @@ void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) x = obj->x1 >> 3; y = obj->y1; } - + if (x < 0) x = 0; if (y < 0) y = 0; - + int temp; - + temp = x + width; if (temp >= 39) x = 39 - width; @@ -234,7 +233,7 @@ void ScreenAnimator::prepDrawAllObjects() { if (curObject->active) { int xpos = curObject->x1; int ypos = curObject->y1; - + int drawLayer = 0; if (!(curObject->flags & 0x800)) drawLayer = 7; @@ -242,7 +241,7 @@ void ScreenAnimator::prepDrawAllObjects() { drawLayer = 0; else drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY); - + // talking head functionallity if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) { const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 }; @@ -266,14 +265,14 @@ void ScreenAnimator::prepDrawAllObjects() { } else { temp2 = 1; } - + if (!temp2) shapesIndex = -1; } - + xpos = curObject->x1; ypos = curObject->y1; - + int tempX = 0, tempY = 0; if (curObject->flags & 0x1) { tempX = (xOffsetTable1[curObject->index] * _brandonScaleX) >> 8; @@ -285,22 +284,22 @@ void ScreenAnimator::prepDrawAllObjects() { tempY = (tempY * _brandonScaleY) >> 8; xpos += tempX; ypos += tempY; - + if (_vm->_scaleMode && _brandonScaleX != 256) ++xpos; - + if (curObject->index == 0 && shapesIndex != -1) { if (!(_vm->_brandonStatusBit & 2)) { flagUnk3 = 0x100; if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000)) flagUnk3 = 0; - + int tempFlags = 0; if (flagUnk3 & 0x100) { tempFlags = curObject->flags & 1; tempFlags |= 0x800 | flagUnk1 | 0x100; } - + if (!(flagUnk3 & 0x100) && (flagUnk2 & 0x4000)) { tempFlags = curObject->flags & 1; tempFlags |= 0x900 | flagUnk1 | 0x4000; @@ -310,7 +309,7 @@ void ScreenAnimator::prepDrawAllObjects() { tempFlags = curObject->flags & 1; tempFlags |= 0x900 | flagUnk1; } - + _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY); } } @@ -319,25 +318,25 @@ void ScreenAnimator::prepDrawAllObjects() { int tempFlags = 0; if (curObject->flags & 1) tempFlags = 1; - _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer); + _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer); } } } } - + xpos = curObject->x1; ypos = curObject->y1; - + curObject->flags |= 0x800; if (curObject->index == 0) { flagUnk3 = 0x100; - + if (flagUnk1 & 0x200 || flagUnk2 & 0x4000) flagUnk3 = 0; - + if (_vm->_brandonStatusBit & 2) curObject->flags &= 0xFFFFFFFE; - + if (!_vm->_scaleMode) { if (flagUnk3 & 0x100) _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x100, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer); @@ -375,7 +374,7 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { ypos = curObject->y1 - curObject->height2; width = curObject->width + (curObject->width2>>3) + 2; height = curObject->height + curObject->height2*2; - + if (xpos < 1) xpos = 1; else if (xpos > 39) @@ -383,7 +382,7 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { if (xpos + width > 39) width = 39 - xpos; - + if (ypos < 8) ypos = 8; else if (ypos > 136) @@ -391,7 +390,7 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { if (ypos + height > 136) height = 136 - ypos; - + _screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0, Screen::CR_CLIPPED); curObject->refreshFlag = 0; _updateScreen = true; @@ -416,15 +415,15 @@ void ScreenAnimator::updateAllObjectShapes() { void ScreenAnimator::animRemoveGameItem(int index) { debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d)", index); restoreAllObjectBackgrounds(); - + AnimObject *animObj = &_items[index]; animObj->sceneAnimPtr = 0; animObj->animFrameNumber = -1; animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; + animObj->bkgdChangeFlag = 1; updateAllObjectShapes(); animObj->active = 0; - + objectRemoveQueue(_objectQueue, animObj); } @@ -459,7 +458,7 @@ void ScreenAnimator::animAddNPC(int character) { restoreAllObjectBackgrounds(); AnimObject *animObj = &_actors[character]; const Character *ch = &_vm->_characterList[character]; - + animObj->active = 1; animObj->refreshFlag = 1; animObj->bkgdChangeFlag = 1; @@ -491,13 +490,13 @@ AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem prev = cur; cur = temp; } - + if (cur == queue) { if (!cur) return 0; return cur->nextAnimObject; } - + if (!cur->nextAnimObject) { if (cur == rem) { if (!prev) @@ -509,7 +508,7 @@ AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem if (cur == rem) prev->nextAnimObject = rem->nextAnimObject; } - + return queue; } @@ -534,7 +533,7 @@ AnimObject *ScreenAnimator::objectQueue(AnimObject *queue, AnimObject *add) { prev = cur; cur = temp; } - + if (add->drawY <= cur->drawY) { prev->nextAnimObject = add; add->nextAnimObject = cur; @@ -617,7 +616,7 @@ void ScreenAnimator::animRefreshNPC(int character) { animObj->flags |= 1; else if (facing >= 5 && facing <= 7) animObj->flags &= 0xFFFFFFFE; - + animObj->drawY = ch->y1; animObj->sceneAnimPtr = _vm->shapes()[ch->currentAnimFrame]; animObj->animFrameNumber = ch->currentAnimFrame; @@ -640,14 +639,14 @@ void ScreenAnimator::animRefreshNPC(int character) { } } } - + int xOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset; int yOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset; - + if (_vm->_scaleMode) { animObj->x1 = ch->x1; animObj->y1 = ch->y1; - + int newScale = _vm->_scaleTable[ch->y1]; _brandonScaleX = newScale; _brandonScaleY = newScale; diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index 152dc21c61..b9be7edf86 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/config-manager.h" #include "common/system.h" #include "kyra/debugger.h" @@ -82,7 +82,7 @@ bool Debugger_v1::cmd_enterRoom(int argc, const char **argv) { _vm->_system->hideOverlay(); _vm->_currentCharacter->facing = direction; - + _vm->enterNewScene(room, _vm->_currentCharacter->facing, 0, 0, 1); _vm->_screen->_mouseLockCount = 0; @@ -97,7 +97,7 @@ bool Debugger_v1::cmd_enterRoom(int argc, const char **argv) { bool Debugger_v1::cmd_listRooms(int argc, const char **argv) { for (int i = 0; i < _vm->_roomTableSize; i++) { DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]); - if (!(i % 8)) + if (!(i % 8)) DebugPrintf("\n"); } DebugPrintf("\n"); @@ -108,7 +108,7 @@ bool Debugger_v1::cmd_listRooms(int argc, const char **argv) { bool Debugger_v1::cmd_listFlags(int argc, const char **argv) { for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) { DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i)); - if (!(i % 10)) + if (!(i % 10)) DebugPrintf("\n"); } DebugPrintf("\n"); @@ -122,7 +122,7 @@ bool Debugger_v1::cmd_toggleFlag(int argc, const char **argv) { _vm->resetGameFlag(flag); else _vm->setGameFlag(flag); - DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag)); + DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag)); } else { DebugPrintf("Syntax: toggleflag <flag>\n"); } @@ -133,7 +133,7 @@ bool Debugger_v1::cmd_toggleFlag(int argc, const char **argv) { bool Debugger_v1::cmd_queryFlag(int argc, const char **argv) { if (argc > 1) { uint flag = atoi(argv[1]); - DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag)); + DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag)); } else { DebugPrintf("Syntax: queryflag <flag>\n"); } @@ -152,8 +152,8 @@ bool Debugger_v1::cmd_setTimerCountdown(int argc, const char **argv) { if (argc > 2) { uint timer = atoi(argv[1]); uint countdown = atoi(argv[2]); - _vm->timer()->setCountdown(timer, countdown); - DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->timer()->getDelay(timer)); + _vm->timer()->setCountdown(timer, countdown); + DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->timer()->getDelay(timer)); } else { DebugPrintf("Syntax: settimercountdown <timer> <countdown>\n"); } @@ -176,7 +176,7 @@ bool Debugger_v1::cmd_giveItem(int argc, const char **argv) { } else { DebugPrintf("Syntax: give <itemid>\n"); } - + return true; } } // End of namespace Kyra diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 0c2524327e..6fdeaac2a6 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/config-manager.h" @@ -48,15 +48,15 @@ KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) _staticres = 0; _timer = 0; _scriptInterpreter = 0; - + _flags = flags; _gameSpeed = 60; _tickLength = (uint8)(1000.0 / _gameSpeed); - + _quitFlag = false; - + _skipFlag = false; - + memset(_flagsTable, 0, sizeof(_flagsTable)); // sets up all engine specific debug levels @@ -81,7 +81,7 @@ int KyraEngine::init() { _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")); - + // for now we prefer Adlib over native MIDI int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); @@ -112,7 +112,7 @@ int KyraEngine::init() { // C55 appears to be XMIDI for General MIDI instruments soundMidiPc->setUseC55(_flags.gameID == GI_KYRA2 && !native_mt32); - + // Unlike some SCUMM games, it's not that the MIDI sounds are // missing. It's just that at least at the time of writing they // are decidedly inferior to the Adlib ones. @@ -120,7 +120,7 @@ int KyraEngine::init() { if (midiDriver != MD_ADLIB && ConfMan.getBool("multi_midi")) { SoundAdlibPC *adlib = new SoundAdlibPC(this, _mixer); assert(adlib); - + _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); assert(_sound); } @@ -138,7 +138,7 @@ int KyraEngine::init() { assert(_timer); _scriptInterpreter = new ScriptHelper(this); assert(_scriptInterpreter); - + setupOpcodeTable(); _lang = 0; diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 32c090dc57..4171e89f5b 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/config-manager.h" #include "common/endian.h" #include "common/file.h" @@ -137,7 +137,7 @@ bool Resource::loadPakFile(const Common::String &filename) { const bool isKyraDat = filename.equalsIgnoreCase("KYRA.DAT"); uint32 size = 0; - + Common::File handle; if (!getFileHandle(filename.c_str(), &size, handle)) { (!isKyraDat ? error : warning)("couldn't load file: '%s'", filename.c_str()); @@ -233,7 +233,7 @@ bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &fileh if ((*start)->getFileHandle(fileHash, filehandle)) { uint32 tSize = (*start)->getFileSize(fileHash); - + if (!tSize) continue; @@ -243,7 +243,7 @@ bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &fileh return true; } } - + return false; } @@ -258,7 +258,7 @@ uint32 Resource::getFileSize(const char *file) const { continue; uint32 size = (*start)->getFileSize(fileHash); - + if (size) return size; } @@ -313,22 +313,22 @@ PAKFile::PAKFile(const char *file, const char *physfile, Common::File &pakfile, PakChunk chunk; uint8 buffer[64]; uint32 nameLength; - + // Move to the position of the next file entry pakfile.seek(pos); - + // Read in the header if (pakfile.read(&buffer, 64) < 5) { warning("PAK file '%s' is corrupted", file); return; } - + // Quit now if we encounter an empty string if (!(*((const char*)buffer))) break; chunk._name = Common::hashit_lower((const char*)buffer); - nameLength = strlen((const char*)buffer) + 1; + nameLength = strlen((const char*)buffer) + 1; if (nameLength > 60) { warning("PAK file '%s' is corrupted", file); @@ -361,7 +361,7 @@ PAKFile::PAKFile(const char *file, const char *physfile, Common::File &pakfile, pos += nameLength + 4; } - _open = true; + _open = true; _filename = Common::hashit_lower(file); _physfile = physfile; _physOffset = off; @@ -506,7 +506,7 @@ bool INSFile::getFileHandle(uint hash, Common::File &filehandle) const { if (file == _files.end()) return false; - if (!filehandle.open(_physfile)) + if (!filehandle.open(_physfile)) return false; filehandle.seek(file->_start, SEEK_CUR); diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 139a7fa72c..96d6a9908e 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -26,7 +26,7 @@ #ifndef KYRA_RESOURCE_H #define KYRA_RESOURCE_H -#include "common/stdafx.h" + #include "common/scummsys.h" #include "common/str.h" #include "common/file.h" @@ -65,7 +65,7 @@ class PAKFile : public ResourceFile { uint _name; uint32 _start; uint32 _size; - + operator uint() const { return _name; } }; @@ -93,7 +93,7 @@ class INSFile : public ResourceFile { uint _name; uint32 _start; uint32 _size; - + operator uint() const { return _name; } }; public: @@ -115,7 +115,7 @@ class Resource { public: Resource(KyraEngine *vm); ~Resource(); - + bool loadPakFile(const Common::String &filename); void unloadPakFile(const Common::String &filename); bool isInPakList(const Common::String &filename) const; @@ -126,7 +126,7 @@ public: // it is possible that the needed file is embedded in the returned handle bool getFileHandle(const char *file, uint32 *size, Common::File &filehandle); - bool loadFileToBuf(const char *file, void *buf, uint32 maxSize); + bool loadFileToBuf(const char *file, void *buf, uint32 maxSize); protected: typedef Common::List<ResourceFile*>::iterator ResIterator; @@ -167,7 +167,7 @@ enum kKyraResources { kRoomList, kCharacterImageFilenames, - + kItemNames, kTakenStrings, kPlacedStrings, @@ -190,7 +190,7 @@ enum kKyraResources { kVeryCleverString, kNewGameString, - + kDefaultShapes, kHealing1Shapes, kHealing2Shapes, @@ -208,10 +208,10 @@ enum kKyraResources { kGUIStrings, kConfigStrings, - + kKyra1TownsSFXTable, kCreditsStrings, - + kMaxResIDs }; @@ -222,7 +222,7 @@ class StaticResource { public: StaticResource(KyraEngine *vm) : _vm(vm), _resList(), _fileLoader(0), _builtIn(0), _filenameTable(0) {} ~StaticResource() { deinit(); } - + static bool checkKyraDat(); bool init(); @@ -259,7 +259,7 @@ private: bool loadShapeTable(const char *filename, void *&ptr, int &size); bool loadRoomTable(const char *filename, void *&ptr, int &size); bool loadPaletteTable(const char *filename, void *&ptr, int &size); - + void freeRawData(void *&ptr, int &size); void freeStringTable(void *&ptr, int &size); void freeShapeTable(void *&ptr, int &size); diff --git a/engines/kyra/saveload_v1.cpp b/engines/kyra/saveload_v1.cpp index e9001968e9..185b13c175 100644 --- a/engines/kyra/saveload_v1.cpp +++ b/engines/kyra/saveload_v1.cpp @@ -23,7 +23,6 @@ * */ -#include "common/stdafx.h" #include "common/endian.h" #include "common/savefile.h" #include "common/system.h" @@ -70,7 +69,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { delete in; return; } - + char saveName[31]; in->read(saveName, 31); @@ -129,7 +128,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { _marbleVaseItem = in->readSint16BE(); _itemInHand = in->readByte(); - + for (int i = 0; i < 4; ++i) _birthstoneGemTable[i] = in->readByte(); for (int i = 0; i < 3; ++i) @@ -139,7 +138,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { _cauldronState = in->readByte(); for (int i = 0; i < 2; ++i) _crystalState[i] = in->readByte(); - + _brandonStatusBit = in->readUint16BE(); _brandonStatusBit0x02Flag = in->readByte(); _brandonStatusBit0x20Flag = in->readByte(); @@ -188,7 +187,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { // Version 4 stored settings in the savegame. As of version 5, they are // handled by the config manager. - + if (version == 4) { in->readByte(); // Text speed in->readByte(); // Walk speed @@ -205,7 +204,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { // so if it's out of bounds we just set it to 0. if (_curSfxFile >= _soundFilesTownsCount || _curSfxFile < 0) _curSfxFile = 0; - + if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) _sound->loadSoundFile(_curSfxFile); } @@ -231,7 +230,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { _animator->_noDrawShapesFlag = 1; enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); _animator->_noDrawShapesFlag = 0; - + _currentCharacter->x1 = brandonX; _currentCharacter->y1 = brandonY; _animator->animRefreshNPC(0); @@ -242,7 +241,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); _screen->_disableScreen = false; _screen->updateScreen(); - + _abortWalkFlag = true; _abortWalkFlag2 = false; _mousePressFlag = false; @@ -295,10 +294,10 @@ void KyraEngine_v1::saveGame(const char *fileName, const char *saveName) { //out->writeUint16BE(_characterList[i].field_20); //out->writeUint16BE(_characterList[i].field_23); } - + out->writeSint16BE(_marbleVaseItem); out->writeByte(_itemInHand); - + for (int i = 0; i < 4; ++i) out->writeByte(_birthstoneGemTable[i]); for (int i = 0; i < 3; ++i) @@ -308,7 +307,7 @@ void KyraEngine_v1::saveGame(const char *fileName, const char *saveName) { out->writeByte(_cauldronState); for (int i = 0; i < 2; ++i) out->writeByte(_crystalState[i]); - + out->writeUint16BE(_brandonStatusBit); out->writeByte(_brandonStatusBit0x02Flag); out->writeByte(_brandonStatusBit0x20Flag); @@ -334,7 +333,7 @@ void KyraEngine_v1::saveGame(const char *fileName, const char *saveName) { } // room table terminator out->writeUint16BE(0xFFFF); - + out->writeSint16BE(_lastMusicCommand); out->writeByte(_curSfxFile); diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index a7e9c90824..b6003ff388 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/system.h" #include "graphics/cursorman.h" @@ -71,7 +71,7 @@ Screen::~Screen() { delete [] _saveLoadPage[i]; _saveLoadPage[i] = 0; } - + for (int i = 0; i < ARRAYSIZE(_saveLoadPageOvl); ++i) { delete [] _saveLoadPageOvl[i]; _saveLoadPageOvl[i] = 0; @@ -79,7 +79,7 @@ Screen::~Screen() { delete [] _unkPtr1; delete [] _unkPtr2; - + delete [] _dirtyRects; } @@ -171,7 +171,7 @@ bool Screen::init() { _animBlockSize = 0; _mouseLockCount = 1; CursorMan.showMouse(false); - + _bitBlitRects = new Rect[BITBLIT_RECTS]; assert(_bitBlitRects); memset(_bitBlitRects, 0, sizeof(Rect)*BITBLIT_RECTS); @@ -185,7 +185,7 @@ bool Screen::init() { _unkPtr2 = new uint8[getRectSize(1, 144)]; assert(_unkPtr2); memset(_unkPtr2, 0, getRectSize(1, 144)); - + _forceFullUpdate = false; _numDirtyRects = 0; _dirtyRects = new Rect[kMaxDirtyRects]; @@ -464,8 +464,8 @@ void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) { dstPage += SCREEN_W; } addDirtyRect(0, y, SCREEN_W, h); - // This would remove the text in the end sequence of - // the FM-Towns version. + // This would remove the text in the end sequence of + // the FM-Towns version. // Since this method is just used for the Seqplayer // this shouldn't be a problem anywhere else, so it's // safe to disable the call here. @@ -474,7 +474,7 @@ void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) { void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage, int flags) { debugC(9, kDebugLevelScreen, "Screen::copyRegion(%d, %d, %d, %d, %d, %d, %d, %d, %d)", x1, y1, x2, y2, w, h, srcPage, dstPage, flags); - + if (flags & CR_CLIPPED) { if (x2 < 0) { if (x2 <= -w) @@ -505,7 +505,7 @@ void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPag const uint8 *src = getPagePtr(srcPage) + y1 * SCREEN_W + x1; assert(x2 + w <= SCREEN_W && y2 + h <= SCREEN_H); uint8 *dst = getPagePtr(dstPage) + y2 * SCREEN_W + x2; - + if (dstPage == 0 || dstPage == 1) addDirtyRect(x2, y2, w, h); @@ -548,7 +548,7 @@ void Screen::copyPage(uint8 srcPage, uint8 dstPage) { uint8 *dst = getPagePtr(dstPage); memcpy(dst, src, SCREEN_W * SCREEN_H); copyOverlayRegion(0, 0, 0, 0, SCREEN_W, SCREEN_H, srcPage, dstPage); - + if (dstPage == 0 || dstPage == 1) _forceFullUpdate = true; } @@ -556,10 +556,10 @@ void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint debugC(9, kDebugLevelScreen, "Screen::copyBlockToPage(%d, %d, %d, %d, %d, %p)", pageNum, x, y, w, h, (const void *)src); assert(x >= 0 && x < Screen::SCREEN_W && y >= 0 && y < Screen::SCREEN_H); uint8 *dst = getPagePtr(pageNum) + y * SCREEN_W + x; - + if (pageNum == 0 || pageNum == 1) addDirtyRect(x, y, w, h); - + clearOverlayRect(pageNum, x, y, w, h); while (h--) { @@ -572,7 +572,7 @@ void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint void Screen::copyFromCurPageBlock(int x, int y, int w, int h, const uint8 *src) { debugC(9, kDebugLevelScreen, "Screen::copyFromCurPageBlock(%d, %d, %d, %d, %p)", x, y, w, h, (const void *)src); if (x < 0) - x = 0; + x = 0; else if (x >= 40) return; @@ -588,12 +588,12 @@ void Screen::copyFromCurPageBlock(int x, int y, int w, int h, const uint8 *src) h = 200 - y; uint8 *dst = getPagePtr(_curPage) + y * SCREEN_W + x * 8; - + if (_curPage == 0 || _curPage == 1) addDirtyRect(x*8, y, w*8, h); - + clearOverlayRect(_curPage, x*8, y, w*8, h); - + while (h--) { memcpy(dst, src, w*8); dst += SCREEN_W; @@ -605,7 +605,7 @@ void Screen::copyCurPageBlock(int x, int y, int w, int h, uint8 *dst) { debugC(9, kDebugLevelScreen, "Screen::copyCurPageBlock(%d, %d, %d, %d, %p)", x, y, w, h, (const void *)dst); assert(dst); if (x < 0) - x = 0; + x = 0; else if (x >= 40) return; @@ -640,7 +640,7 @@ void Screen::shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPag int i = _vm->_rnd.getRandomNumber(w - 1); SWAP(x_offs[x], x_offs[i]); } - + assert(sy >= 0 && h <= SCREEN_H); int y; uint8 y_offs[SCREEN_H]; @@ -692,12 +692,12 @@ void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum) pageNum = _curPage; uint8 *dst = getPagePtr(pageNum) + y1 * SCREEN_W + x1; - + if (pageNum == 0 || pageNum == 1) addDirtyRect(x1, y1, x2-x1+1, y2-y1+1); clearOverlayRect(pageNum, x1, y1, x2-x1+1, y2-y1+1); - + for (; y1 <= y2; ++y1) { memset(dst, color, x2 - x1 + 1); dst += SCREEN_W; @@ -781,7 +781,7 @@ void Screen::drawLine(bool vertical, int x, int y, int length, int color) { assert((x + length) <= SCREEN_W); memset(ptr, color, length); } - + if (_curPage == 0 || _curPage == 1) addDirtyRect(x, y, (vertical) ? 1 : length, (vertical) ? length : 1); @@ -914,11 +914,11 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 cmap[0] = color2; cmap[1] = color1; setTextColor(cmap, 0, 1); - + Font *fnt = &_fonts[_currentFont]; const uint8 charHeightFnt = *(fnt->fontData + fnt->charSizeOffset + 4); uint8 charHeight = 0; - + if (x < 0) x = 0; else if (x >= SCREEN_W) @@ -982,10 +982,10 @@ void Screen::drawCharANSI(uint8 c, int x, int y) { uint8 charH1 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2); uint8 charH2 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2 + 1); charH0 -= charH1 + charH2; - + const uint8 *src = fnt->fontData + bitmapOffset; const int pitch = SCREEN_W - charWidth; - + while (charH1--) { uint8 col = _textColorsMap[0]; for (int i = 0; i < charWidth; ++i) { @@ -995,7 +995,7 @@ void Screen::drawCharANSI(uint8 c, int x, int y) { } dst += pitch; } - + while (charH2--) { uint8 b = 0; for (int i = 0; i < charWidth; ++i) { @@ -1013,7 +1013,7 @@ void Screen::drawCharANSI(uint8 c, int x, int y) { } dst += pitch; } - + while (charH0--) { uint8 col = _textColorsMap[0]; for (int i = 0; i < charWidth; ++i) { @@ -1023,7 +1023,7 @@ void Screen::drawCharANSI(uint8 c, int x, int y) { } dst += pitch; } - + if (_curPage == 0 || _curPage == 1) addDirtyRect(x, y, charWidth, *(fnt->fontData + fnt->charSizeOffset + 4)); } @@ -1041,7 +1041,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int return; va_list args; va_start(args, flags); - + static int drawShapeVar1 = 0; static int drawShapeVar2[] = { 1, 3, 2, 5, 4, 3, 2, 1 @@ -1049,14 +1049,14 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int static int drawShapeVar3 = 1; static int drawShapeVar4 = 0; static int drawShapeVar5 = 0; - + uint8 *table = 0; int tableLoopCount = 0; int drawLayer = 0; uint8 *table2 = 0; uint8 *table3 = 0; uint8 *table4 = 0; - + if (flags & 0x8000) table2 = va_arg(args, uint8*); @@ -1096,15 +1096,15 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int scale_w = 0x100; scale_h = 0x100; } - + int ppc = (flags >> 8) & 0x3F; - + const uint8 *src = shapeData; if (_vm->gameFlags().useAltShapeHeader) src += 2; uint16 shapeFlags = READ_LE_UINT16(src); src += 2; - + int shapeHeight = *src++; int scaledShapeHeight = (shapeHeight * scale_h) >> 8; if (scaledShapeHeight == 0) { @@ -1123,9 +1123,9 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int x -= scaledShapeWidth >> 1; y -= scaledShapeHeight >> 1; } - + src += 3; - + uint16 frameSize = READ_LE_UINT16(src); src += 2; if ((shapeFlags & 1) || (flags & 0x400)) src += 0x10; @@ -1134,7 +1134,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int decodeFrame4(src, _animBlockPtr, frameSize); src = _animBlockPtr; } - + int shapeSize = shapeWidth * shapeHeight; if (_decodeShapeBufferSize < shapeSize) { delete [] _decodeShapeBuffer; @@ -1149,12 +1149,12 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } memset(_decodeShapeBuffer, 0, _decodeShapeBufferSize); uint8 *decodedShapeFrame = _decodeShapeBuffer; - + // only used if shapeFlag & 1 is NOT zero const uint8 *colorTable = shapeData + 10; if (_vm->gameFlags().useAltShapeHeader) colorTable += 2; - + for (int j = 0; j < shapeHeight; ++j) { uint8 *dsbNextLine = decodedShapeFrame + shapeWidth; int count = shapeWidth; @@ -1177,7 +1177,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } decodedShapeFrame = dsbNextLine; } - + uint16 sx1 = _screenDimTable[sd].sx * 8; uint16 sy1 = _screenDimTable[sd].sy; uint16 sx2 = sx1 + _screenDimTable[sd].w * 8; @@ -1186,7 +1186,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int x += sx1; y += sy1; } - + int x1, x2; if (x >= 0) { x1 = 0; @@ -1201,7 +1201,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int if (x2 > sx2) x2 = sx2; } - + int y1, y2; if (y >= 0) { y1 = 0; @@ -1222,7 +1222,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int if (pageNum == 0 || pageNum == 1) addDirtyRect(x, y, x2-x1, y2-y1); clearOverlayRect(pageNum, x, y, x2-x1, y2-y1); - + int scaleYTable[SCREEN_H]; assert(y1 >= 0 && y2 < SCREEN_H); for (y = y1; y < y2; ++y) @@ -1232,13 +1232,13 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int assert(x1 >= 0 && x2 < SCREEN_W); for (x = x1; x < x2; ++x) scaleXTable[x] = (x << 8) / scale_w; - + const uint8 *shapeBuffer = _decodeShapeBuffer; if (flags & DSF_Y_FLIPPED) shapeBuffer += shapeWidth * (shapeHeight - 1); if (flags & DSF_X_FLIPPED) shapeBuffer += shapeWidth - 1; - + for (y = y1; y < y2; ++y) { uint8 *dstNextLine = dst + SCREEN_W; int j = scaleYTable[y]; @@ -1350,7 +1350,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 15: case 11: { int offset = dst - dstStart; @@ -1426,7 +1426,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 17: { for (int i = 0; i < tableLoopCount; ++i) color = table[color]; @@ -1470,7 +1470,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 20: { color = table2[color]; uint8 newColor = table3[color]; @@ -1480,7 +1480,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 21: { color = table2[color]; for (int i = 0; i < tableLoopCount; ++i) @@ -1493,7 +1493,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 22: { int temp = drawShapeVar4 + drawShapeVar5; if (temp & 0xFF00) { @@ -1517,7 +1517,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int } } break; - + case 24: { int offset = dst - dstStart; uint8 pixel = *(_shapePages[0] + offset); @@ -1579,7 +1579,7 @@ uint Screen::decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize) { uint8 code = *src++; if (!(code & 0x80)) { // 8th bit isn't set - int len = MIN(count, (code >> 4) + 3); //upper half of code is the length + int len = MIN(count, (code >> 4) + 3); //upper half of code is the length int offs = ((code & 0xF) << 8) | *src++; //lower half of code as byte 2 of offset. const uint8 *dstOffs = dst - offs; while (len--) @@ -1683,7 +1683,7 @@ void Screen::wrapped_decodeFrameDelta(uint8 *dst, const uint8 *src) { void Screen::decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch, bool noXor) { debugC(9, kDebugLevelScreen, "Screen::decodeFrameDeltaPage(%p, %p, %d, %d)", (const void *)dst, (const void *)src, pitch, noXor); - + if (noXor) { wrapped_decodeFrameDeltaPage<true>(dst, src, pitch); } else { @@ -1713,7 +1713,7 @@ void Screen::convertAmigaGfx(uint8 *data, int w, int h, bool offscreen) { *dst4++ = *src++; *dst5++ = *src++; } - + curLine += 40; } } else { @@ -1749,7 +1749,7 @@ void Screen::convertAmigaMsc(uint8 *data) { d = (plane4[i] |= d); d = (plane3[i] |= d); d = (plane2[i] |= d); - d = (plane1[i] |= d); + d = (plane1[i] |= d); } byte dst[320*144]; memset(dst, 0, sizeof(dst)); @@ -1797,7 +1797,7 @@ void Screen::wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitc code -= 0x80; if (code != 0) { dst += code; - + count += code; while (count >= pitch) { count -= pitch; @@ -1841,14 +1841,14 @@ void Screen::wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitc } } else { dst += subcode; - + count += subcode; while (count >= pitch) { count -= pitch; dstNext += SCREEN_W; dst = dstNext + count; } - + } } } else { @@ -1882,38 +1882,38 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { while (xpos) { uint8 value = *tmp++; --xpos; - + if (!value) { shapeSize += 2; int16 curX = xpos; bool skip = false; - + while (xpos) { value = *tmp++; --xpos; - + if (value) { skip = true; break; } } - + if (!skip) ++curX; - + curX -= xpos; shapeSize -= curX; - + while (curX > 0xFF) { curX -= 0xFF; shapeSize += 2; } } } - + tmp = start + SCREEN_W; } - + int16 shapeSize2 = shapeSize; if (_vm->gameFlags().useAltShapeHeader) shapeSize += 12; @@ -1922,14 +1922,14 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { if (flags & 1) shapeSize += 16; - - static uint8 table[274]; + + static uint8 table[274]; int tableIndex = 0; - + uint8 *newShape = 0; newShape = new uint8[shapeSize+16]; assert(newShape); - + byte *dst = newShape; if (_vm->gameFlags().useAltShapeHeader) @@ -1948,7 +1948,7 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { memset(table, 0, sizeof(uint8)*274); tableIndex = 1; } - + for (int ypos = h; ypos > 0; --ypos) { uint8 *srcBackUp = src; xpos = w; @@ -1974,7 +1974,7 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { } else { int16 temp = 1; --xpos; - + while (xpos) { if (*src) break; @@ -1982,13 +1982,13 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { ++temp; --xpos; } - + while (temp > 0xFF) { *dst++ = 0; *dst++ = 0xFF; temp -= 0xFF; } - + if (temp & 0xFF) { *dst++ = 0; *dst++ = temp & 0xFF; @@ -1997,7 +1997,7 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { } src = srcBackUp + SCREEN_W; } - + if (!(flags & 2)) { if (shapeSize > _animBlockSize) { dst = newShape; @@ -2018,7 +2018,7 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { uint8 *shapePtrBackUp = src; dst = _animBlockPtr; memcpy(dst, src, shapeSize2); - + int16 size = encodeShapeAndCalculateSize(_animBlockPtr, shapePtrBackUp, shapeSize2); if (size > shapeSize2) { shapeSize -= shapeSize2 - size; @@ -2038,12 +2038,12 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { } } } - + dst = newShape; if (_vm->gameFlags().useAltShapeHeader) dst += 2; WRITE_LE_UINT16((dst + 6), shapeSize); - + if (flags & 1) { dst = newShape + 10; if (_vm->gameFlags().useAltShapeHeader) @@ -2051,7 +2051,7 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { src = &table[0x100]; memcpy(dst, src, sizeof(uint8)*16); } - + return newShape; } @@ -2063,21 +2063,21 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { byte *toPtr = to; byte *fromPtr = from; byte *toPtr2 = to; - + *to++ = 0x81; *to++ = *from++; - + while (from < fromPtrEnd) { byte *curToPtr = to; to = fromPtr; int size = 1; - + while (true) { byte curPixel = *from; if (curPixel == *(from+0x40)) { byte *toBackUp = to; to = from; - + for (int i = 0; i < (fromPtrEnd - from); ++i) { if (*to++ != curPixel) break; @@ -2098,7 +2098,7 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { to = toBackUp; } } - + bool breakLoop = false; while (true) { if ((from - to) == 0) { @@ -2112,7 +2112,7 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { if (*to == curPixel) { if (*(from+size-1) == *(to+size-2)) break; - + byte *fromBackUp = from; byte *toBackUp = to; --to; @@ -2135,11 +2135,11 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { break; } } - + if (breakLoop) break; } - + to = curToPtr; if (size > 2) { uint16 word = 0; @@ -2154,14 +2154,14 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { continue; } } - + if (size > 0x40) { *to++ = 0xFF; WRITE_LE_UINT16(to, size); to += 2; } else { *to++ = ((size & 0xFF) - 3) | 0xC0; } - + word = tempPtr - fromPtr; WRITE_LE_UINT16(to, word); to += 2; from += size; @@ -2171,19 +2171,19 @@ int16 Screen::encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size_to) { toPtr2 = to; *to++ = 0x80; } - + if (*toPtr2 == 0xBF) { toPtr2 = to; *to++ = 0x80; } - + ++(*toPtr2); *to++ = *from++; - skipPixel = true; + skipPixel = true; } } *to++ = 0x80; - + return (to - toPtr); } @@ -2192,12 +2192,12 @@ int Screen::getRectSize(int x, int y) { x = 1; else if (x > 40) x = 40; - + if (y < 1) y = 1; else if (y > 200) y = 200; - + return ((x*y) << 3); } @@ -2280,7 +2280,7 @@ void Screen::copyScreenFromRect(int x, int y, int w, int h, const uint8 *ptr) { src += w; dst += SCREEN_W; } - + addDirtyRect(x, y, w, h); clearOverlayRect(0, x, y, w, h); } @@ -2302,7 +2302,7 @@ uint8 *Screen::getPalette(int num) { assert(num >= 0 && num < (_vm->gameFlags().platform == Common::kPlatformAmiga ? 6 : 4)); if (num == 0) return _currentPalette; - + return _palettes[num-1]; } @@ -2479,30 +2479,30 @@ int Screen::getDrawLayer2(int x, int y, int height) { int xpos = x - 8; int ypos = y - 1; int layer = 1; - + for (int useX = xpos; useX < xpos + 16; ++useX) { for (int useY = ypos - height; useY < ypos; ++useY) { int tempLayer = getShapeFlag2(useX, useY); if (tempLayer > layer) layer = tempLayer; - + if (tempLayer >= 7) return 7; } - } + } return layer; } void Screen::copyBackgroundBlock(int x, int page, int flag) { debugC(9, kDebugLevelScreen, "Screen::copyBackgroundBlock(%d, %d, %d)", x, page, flag); - + if (x < 1) return; - + int height = 128; if (flag) - height += 8; + height += 8; if (!(x & 1)) ++x; if (x == 19) @@ -2512,7 +2512,7 @@ void Screen::copyBackgroundBlock(int x, int page, int flag) { uint8 *ptr2 = _unkPtr2; int oldVideoPage = _curPage; _curPage = page; - + int curX = x; hideMouse(); copyRegionToBuffer(_curPage, 8, 8, 8, height, ptr2); @@ -2542,7 +2542,7 @@ void Screen::copyBackgroundBlock2(int x) { void Screen::shakeScreen(int times) { debugC(9, kDebugLevelScreen, "Screen::shakeScreen(%d)", times); - + while (times--) { // seems to be 1 line (320 pixels) offset in the original // 4 looks more like dosbox though, maybe check this again @@ -2569,7 +2569,7 @@ void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, uint8 * if (palData && palSize) { debugC(9, kDebugLevelMain,"Loading a palette of size %i from %s", palSize, filename); - loadPalette(srcData + 10, palData, palSize); + loadPalette(srcData + 10, palData, palSize); } uint8 *srcPtr = srcData + 10 + palSize; @@ -2655,7 +2655,7 @@ void Screen::addDirtyRect(int x, int y, int w, int h) { _forceFullUpdate = true; return; } - + if (w == 0 || h == 0 || x >= SCREEN_W || y >= SCREEN_H || x + w < 0 || y + h < 0) return; @@ -2674,7 +2674,7 @@ void Screen::addDirtyRect(int x, int y, int w, int h) { if (y + h >= 200) h = 200 - y; - + Rect &cur = _dirtyRects[_numDirtyRects++]; cur.x = x; cur.x2 = w; @@ -2840,7 +2840,7 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { memset(_sjisTempPage2, 0x80, 324); memset(_sjisSourceChar, 0, 36); memcpy(_sjisSourceChar, _sjisFontData + 0x20 * SJIStoFMTChunk(c & 0xff, c >> 8), 0x20); - + if (_curPage == 0 || _curPage == 1) addDirtyRect(x, y, SJIS_CHARSIZE >> 1, SJIS_CHARSIZE >> 1); @@ -2855,7 +2855,7 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { destPage += y * 640 + x; uint8 *src = 0, *dst = 0; - + if (color2 != 0x80) { // draw color2 shadow src = _sjisSourceChar; @@ -2866,13 +2866,13 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { dst += 2; src += 2; *dst++ = 0; } - + src = _sjisTempPage2; dst = _sjisTempPage; memset(dst, 0, 60); for (int i = 0; i < 48; i++) *dst++ |= *src++; - + src = _sjisTempPage2; dst = _sjisTempPage + 3; for (int i = 0; i < 48; i++) @@ -2923,20 +2923,20 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { if (color2 & 0xff00) { height -= 3; width--; - dst += 0x13; + dst += 0x13; } - + for (int i = 0; i < height; i++) { uint8 rs = *src++; for (int ii = 0; ii < 8; ii++) { if (rs & 0x80) *dst = (color2 & 0xff); - rs <<= 1; + rs <<= 1; dst++; if (!--width) { width = SJIS_CHARSIZE; - if (color2 & 0xff00) { + if (color2 & 0xff00) { width--; dst++; } @@ -2966,28 +2966,28 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { if (color1 & 0xff00) { height -= 3; width--; - dst += 0x13; + dst += 0x13; } - + for (int i = 0; i < height; i++) { uint8 rs = *src++; for (int ii = 0; ii < 8; ii++) { if (rs & 0x80) *dst = (color1 & 0xff); - rs <<= 1; + rs <<= 1; dst++; if (!--width) { width = SJIS_CHARSIZE; - if (color1 & 0xff00) { + if (color1 & 0xff00) { width--; dst++; } break; } } - } - + } + // copy char to surface src = _sjisTempPage2; dst = destPage; @@ -2997,7 +2997,7 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { for (int ii = 0; ii < SJIS_CHARSIZE; ii++) { if (*src != 0x80) *dst = *src; - src++; + src++; dst++; } dst += pitch; diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 83c75585a8..73fa29a4b9 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -23,7 +23,6 @@ * */ -#include "common/stdafx.h" #include "common/endian.h" #include "kyra/kyra_v2.h" @@ -66,8 +65,8 @@ void Screen_v2::k2IntroFadeToGrey(int delay) { for (int i = 0; i <= 50; ++i) { if (i <= 8 || i >= 30) { - _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + - _currentPalette[3 * i + 1] + + _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + + _currentPalette[3 * i + 1] + _currentPalette[3 * i + 2]) / 3; _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; @@ -77,8 +76,8 @@ void Screen_v2::k2IntroFadeToGrey(int delay) { // color 71 is the same in both the overview and closeup scenes // Converting it to greyscale makes the trees in the closeup look dull for (int i = 71; i < 200; ++i) { - _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + - _currentPalette[3 * i + 1] + + _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + + _currentPalette[3 * i + 1] + _currentPalette[3 * i + 2]) / 3; _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; @@ -143,17 +142,17 @@ void Screen_v2::copyWsaRect(int x, int y, int w, int h, int dimState, int plotFu dstPtr += y * SCREEN_W + x; uint8 *dst = dstPtr; - + if (_curPage == 0 || _curPage == 1) addDirtyRect(x, y, w, h); - + clearOverlayRect(_curPage, x, y, w, h); temp = h; while (h--) { src += srcOffset; int cW = w; - + switch (plotFunc) { case 0: memcpy(dst, src, cW); @@ -270,14 +269,14 @@ uint16 Screen_v2::getShapeSize(const uint8 *shp) { uint8 *Screen_v2::makeShapeCopy(const uint8 *src, int index) { debugC(9, kDebugLevelScreen, "Screen_v2::makeShapeCopy(%p, %d)", (const void *)src, index); - + const uint8 *shape = getPtrToShape(src, index); int size = getShapeSize(shape); uint8 *copy = new uint8[size]; assert(copy); memcpy(copy, shape, size); - + return copy; } @@ -290,7 +289,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, va_list args; va_start(args, flags); - + static int drawShapeVar1 = 0; static int drawShapeVar2[] = { 1, 3, 2, 5, 4, 3, 2, 1 @@ -298,14 +297,14 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, static int drawShapeVar3 = 1; static int drawShapeVar4 = 0; static int drawShapeVar5 = 0; - + uint8 *table = 0; int tableLoopCount = 0; int drawLayer = 0; const uint8 *table2 = 0; uint8 *table3 = 0; uint8 *table4 = 0; - + if (flags & 0x8000) { table2 = va_arg(args, uint8*); } @@ -340,12 +339,12 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, scale_w = 0x100; scale_h = 0x100; } - + int ppc = (flags >> 8) & 0x3F; - + const uint8 *src = shape; uint16 shapeFlags = READ_LE_UINT16(src); src += 2; - + int shapeHeight = *src++; int scaledShapeHeight = (shapeHeight * scale_h) >> 8; if (scaledShapeHeight == 0) { @@ -364,9 +363,9 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, x -= scaledShapeWidth >> 1; y -= scaledShapeHeight >> 1; } - + src += 3; - + uint16 frameSize = READ_LE_UINT16(src); src += 2; int colorTableColors = 0x10; @@ -383,7 +382,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, decodeFrame4(src, _animBlockPtr, frameSize); src = _animBlockPtr; } - + int shapeSize = shapeWidth * shapeHeight; if (_decodeShapeBufferSize < shapeSize) { delete [] _decodeShapeBuffer; @@ -397,7 +396,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, } memset(_decodeShapeBuffer, 0, _decodeShapeBufferSize); uint8 *decodedShapeFrame = _decodeShapeBuffer; - + for (int j = 0; j < shapeHeight; ++j) { uint8 *dsbNextLine = decodedShapeFrame + shapeWidth; int count = shapeWidth; @@ -414,7 +413,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, } decodedShapeFrame = dsbNextLine; } - + uint16 sx1 = getScreenDim(sd)->sx << 3; uint16 sy1 = getScreenDim(sd)->sy; uint16 sx2 = sx1 + (getScreenDim(sd)->w << 3); @@ -423,7 +422,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, x += sx1; y += sy1; } - + int x1, x2; if (x >= 0) { x1 = 0; @@ -440,7 +439,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, x2 = sx2; } } - + int y1, y2; if (y >= 0) { y1 = 0; @@ -460,7 +459,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, uint8 *dst = getPagePtr(page) + y * 320 + x; uint8 *dstStart = getPagePtr(page); - + int scaleYTable[200]; for (y = y1; y < y2; ++y) { scaleYTable[y] = (y << 8) / scale_h; @@ -469,7 +468,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, for (x = x1; x < x2; ++x) { scaleXTable[x] = (x << 8) / scale_w; } - + const uint8 *shapeBuffer = _decodeShapeBuffer; if (flags & 0x02) { shapeBuffer += shapeWidth * (shapeHeight - 1); @@ -477,7 +476,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, if (flags & 0x01) { shapeBuffer += shapeWidth - 1; } - + for (y = y1; y < y2; ++y) { uint8 *dstNextLine = dst + 320; int j = scaleYTable[y]; @@ -542,11 +541,11 @@ int Screen_v2::getLayer(int x, int y) { y = 0; else if (y >= 144) y = 143; - + uint8 pixel = *(getCPagePtr(5) + y * 320 + x); pixel &= 0x7F; pixel >>= 3; - + if (pixel < 1) pixel = 1; else if (pixel > 15) diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index 0778e1abd6..0f8de17174 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/stream.h" #include "common/util.h" @@ -76,13 +76,13 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons error("Couldn't open script file '%s'", filename); return false; } - + uint32 formBlockSize = file.getFORMBlockSize(); if (formBlockSize == (uint32)-1) { error("No FORM chunk found in file: '%s'", filename); return false; } - + uint32 chunkSize = file.getIFFBlockSize(TEXT_CHUNK); if (chunkSize != (uint32)-1) { scriptData->text = new byte[chunkSize]; @@ -93,7 +93,7 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons return false; } } - + chunkSize = file.getIFFBlockSize(ORDR_CHUNK); if (chunkSize == (uint32)-1) { unloadScript(scriptData); @@ -112,7 +112,7 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons while (chunkSize--) scriptData->ordr[chunkSize] = READ_BE_UINT16(&scriptData->ordr[chunkSize]); - + chunkSize = file.getIFFBlockSize(DATA_CHUNK); if (chunkSize == (uint32)-1) { unloadScript(scriptData); @@ -145,8 +145,8 @@ void ScriptHelper::unloadScript(ScriptData *data) { delete [] data->text; delete [] data->ordr; delete [] data->data; - - data->text = 0; + + data->text = 0; data->ordr = data->data = 0; } @@ -187,7 +187,7 @@ bool ScriptHelper::validScript(ScriptState *script) { bool ScriptHelper::runScript(ScriptState *script) { _parameter = 0; _continue = true; - + if (!script->ip) return false; @@ -200,18 +200,18 @@ bool ScriptHelper::runScript(ScriptState *script) { } else if (code & 0x4000) { _parameter = (int8)(code); } else if (code & 0x2000) { - _parameter = *script->ip++; + _parameter = *script->ip++; } else { _parameter = 0; } - + if (opcode > 18) { error("Script unknown command: %d", opcode); } else { debugC(5, kDebugLevelScript, "%s([%d/%u])", _commands[opcode].desc, _parameter, (uint)_parameter); (this->*(_commands[opcode].proc))(script); } - + return _continue; } @@ -221,7 +221,7 @@ bool ScriptHelper::runScript(ScriptState *script) { void ScriptFileParser::setFile(const char *filename, Resource *res) { destroy(); - + if (!res->getFileHandle(filename, &_endOffset, _scriptFile)) return; _startOffset = _scriptFile.pos(); @@ -235,7 +235,7 @@ void ScriptFileParser::destroy() { uint32 ScriptFileParser::getFORMBlockSize() { uint32 oldOffset = _scriptFile.pos(); - + uint32 data = _scriptFile.readUint32LE(); if (data != FORM_CHUNK) { @@ -249,13 +249,13 @@ uint32 ScriptFileParser::getFORMBlockSize() { uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) { uint32 size = (uint32)-1; - + _scriptFile.seek(_startOffset + 0x0C); while (_scriptFile.pos() < _endOffset) { uint32 chunk = _scriptFile.readUint32LE(); uint32 size_temp = _scriptFile.readUint32BE(); - + if (chunk != chunkName) { _scriptFile.seek((size_temp + 1) & (~1), SEEK_CUR); assert(_scriptFile.pos() <= _endOffset); @@ -428,10 +428,10 @@ void ScriptHelper::cmd_negate(ScriptState* script) { void ScriptHelper::cmd_eval(ScriptState* script) { int16 ret = 0; bool error = false; - + int16 val1 = script->stack[script->sp++]; int16 val2 = script->stack[script->sp++]; - + switch (_parameter) { case 0: if (!val2 || !val1) @@ -534,7 +534,7 @@ void ScriptHelper::cmd_eval(ScriptState* script) { error = true; break; } - + if (error) { script->ip = 0; _continue = false; diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 7a4f844400..fd0480bb4b 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/system.h" @@ -114,11 +114,11 @@ int KyraEngine_v1::o1_runNPCScript(ScriptState *script) { int KyraEngine_v1::o1_setSpecialExitList(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setSpecialExitList(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9)); - + for (int i = 0; i < 10; ++i) _exitList[i] = stackPos(i); _exitListPtr = _exitList; - + return 0; } @@ -167,7 +167,7 @@ int KyraEngine_v1::o1_dropItemInScene(ScriptState *script) { int item = stackPos(0); int xpos = stackPos(1); int ypos = stackPos(2); - + byte freeItem = findFreeItemInScene(_currentCharacter->sceneId); if (freeItem != 0xFF) { int sceneId = _currentCharacter->sceneId; @@ -175,7 +175,7 @@ int KyraEngine_v1::o1_dropItemInScene(ScriptState *script) { room->itemsXPos[freeItem] = xpos; room->itemsYPos[freeItem] = ypos; room->itemsTable[freeItem] = item; - + _animator->animAddGameItem(freeItem, sceneId); _animator->updateAllObjectShapes(); } else { @@ -276,7 +276,7 @@ int KyraEngine_v1::o1_fadeSpecialPalette(ScriptState *script) { } else { warning("KyraEngine_v1::o1fadeSpecialPalette not implemented"); } - } else { + } else { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fadeSpecialPalette(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); _screen->fadeSpecialPalette(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); } @@ -432,40 +432,40 @@ int KyraEngine_v1::o1_setScaleMode(ScriptState *script) { int KyraEngine_v1::o1_openWSAFile(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1openWSAFile(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3)); - + const char *filename = stackPosString(0); int wsaIndex = stackPos(1); - + _movieObjects[wsaIndex]->open(filename, (stackPos(3) != 0) ? 1 : 0, 0); assert(_movieObjects[wsaIndex]->opened()); - + return 0; } int KyraEngine_v1::o1_closeWSAFile(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1closeWSAFile(%p) (%d)", (const void *)script, stackPos(0)); - + int wsaIndex = stackPos(0); if (_movieObjects[wsaIndex]) _movieObjects[wsaIndex]->close(); - + return 0; } int KyraEngine_v1::o1_runWSAFromBeginningToEnd(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1runWSAFromBeginningToEnd(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); - + _screen->hideMouse(); - + bool running = true; - + int xpos = stackPos(0); int ypos = stackPos(1); int waitTime = stackPos(2); int wsaIndex = stackPos(3); int worldUpdate = stackPos(4); int wsaFrame = 0; - + _movieObjects[wsaIndex]->setX(xpos); _movieObjects[wsaIndex]->setY(ypos); _movieObjects[wsaIndex]->setDrawPage(0); @@ -474,7 +474,7 @@ int KyraEngine_v1::o1_runWSAFromBeginningToEnd(ScriptState *script) { _animator->_updateScreen = true; if (wsaFrame >= _movieObjects[wsaIndex]->frames()) running = false; - + uint32 continueTime = waitTime * _tickLength + _system->getMillis(); while (_system->getMillis() < continueTime) { if (worldUpdate) { @@ -487,9 +487,9 @@ int KyraEngine_v1::o1_runWSAFromBeginningToEnd(ScriptState *script) { delay(10); } } - + _screen->showMouse(); - + return 0; } @@ -577,35 +577,35 @@ int KyraEngine_v1::o1_popBrandonIntoScene(ScriptState *script) { int width = _defaultShapeTable[0].w << 3; int height = _defaultShapeTable[0].h; AnimObject *curAnim = _animator->actors(); - + if (changeScaleMode) { curAnim->x1 = _currentCharacter->x1; curAnim->y1 = _currentCharacter->y1; _animator->_brandonScaleY = _scaleTable[_currentCharacter->y1]; _animator->_brandonScaleX = _animator->_brandonScaleY; - + int animWidth = _animator->fetchAnimWidth(curAnim->sceneAnimPtr, _animator->_brandonScaleX) >> 1; int animHeight = _animator->fetchAnimHeight(curAnim->sceneAnimPtr, _animator->_brandonScaleY); - + animWidth = (xOffset * animWidth) / width; animHeight = (yOffset * animHeight) / height; - + curAnim->x2 = curAnim->x1 += animWidth; curAnim->y2 = curAnim->y1 += animHeight; } else { curAnim->x2 = curAnim->x1 = _currentCharacter->x1 + xOffset; curAnim->y2 = curAnim->y1 = _currentCharacter->y1 + yOffset; } - + int scaleModeBackup = _scaleMode; if (changeScaleMode) _scaleMode = 1; - + _animator->animRefreshNPC(0); _animator->preserveAllBackgrounds(); _animator->prepDrawAllObjects(); _animator->copyChangedObjectsForward(0); - + _scaleMode = scaleModeBackup; return 0; @@ -693,7 +693,7 @@ int KyraEngine_v1::o1_changeCharactersFacing(ScriptState *script) { int character = stackPos(0); int facing = stackPos(1); int newAnimFrame = stackPos(2); - + _animator->restoreAllObjectBackgrounds(); if (newAnimFrame != -1) _characterList[character].currentAnimFrame = newAnimFrame; @@ -702,7 +702,7 @@ int KyraEngine_v1::o1_changeCharactersFacing(ScriptState *script) { _animator->preserveAllBackgrounds(); _animator->prepDrawAllObjects(); _animator->copyChangedObjectsForward(0); - + return 0; } @@ -747,7 +747,7 @@ int KyraEngine_v1::o1_displayWSAFrameOnHidPage(ScriptState *script) { int ypos = stackPos(2); int waitTime = stackPos(3); int wsaIndex = stackPos(4); - + _screen->hideMouse(); uint32 continueTime = waitTime * _tickLength + _system->getMillis(); _movieObjects[wsaIndex]->setX(xpos); @@ -765,7 +765,7 @@ int KyraEngine_v1::o1_displayWSAFrameOnHidPage(ScriptState *script) { delay(10); } _screen->showMouse(); - + return 0; } @@ -841,7 +841,7 @@ int KyraEngine_v1::o1_displayWSASequentialFrames(ScriptState *script) { ++curTime; } _screen->showMouse(); - + return 0; } @@ -906,12 +906,12 @@ int KyraEngine_v1::o1_placeItemInOffScene(ScriptState *script) { int xpos = stackPos(1); int ypos = stackPos(2); int sceneId = stackPos(3); - + byte freeItem = findFreeItemInScene(sceneId); if (freeItem != 0xFF) { assert(sceneId < _roomTableSize); Room *room = &_roomTable[sceneId]; - + room->itemsTable[freeItem] = item; room->itemsXPos[freeItem] = xpos; room->itemsYPos[freeItem] = ypos; @@ -936,7 +936,7 @@ int KyraEngine_v1::o1_placeCharacterInOtherScene(ScriptState *script) { int ypos = (int16)(stackPos(3) & 0xFFFE); int facing = stackPos(4); int animFrame = stackPos(5); - + _characterList[id].sceneId = sceneId; _characterList[id].x1 = _characterList[id].x2 = xpos; _characterList[id].y1 = _characterList[id].y2 = ypos; @@ -965,13 +965,13 @@ int KyraEngine_v1::o1_popMobileNPCIntoScene(ScriptState *script) { int16 xpos = (int16)(stackPos(4) & 0xFFFC); int8 ypos = (int16)(stackPos(5) & 0xFFFE); Character *curChar = &_characterList[character]; - + curChar->sceneId = sceneId; curChar->currentAnimFrame = animFrame; curChar->facing = facing; curChar->x1 = curChar->x2 = xpos; curChar->y1 = curChar->y2 = ypos; - + _animator->animAddNPC(character); _animator->updateAllObjectShapes(); return 0; @@ -1004,7 +1004,7 @@ int KyraEngine_v1::o1_setCharactersLocation(ScriptState *script) { if (_currentCharacter->sceneId != ch->sceneId) animObj->active = 1; } - + ch->sceneId = stackPos(1); return 0; } @@ -1070,10 +1070,10 @@ int KyraEngine_v1::o1_walkCharacterToPoint(ScriptState *script) { forceContinue = true; break; } - + if (forceContinue || !running) continue; - + setCharacterPosition(character, 0); ++curPos; @@ -1298,20 +1298,20 @@ int KyraEngine_v1::o1_makeAmuletAppear(ScriptState *script) { uint32 nextTime = 0; for (int i = 0; _amuleteAnim[i] != 0xFF; ++i) { nextTime = _system->getMillis() + 5 * _tickLength; - + uint8 code = _amuleteAnim[i]; if (code == 3 || code == 7) snd_playSoundEffect(0x71); - + if (code == 5) snd_playSoundEffect(0x72); - + if (code == 14) snd_playSoundEffect(0x73); - + amulet.displayFrame(code); _animator->_updateScreen = true; - + while (_system->getMillis() < nextTime) { _sprites->updateSceneAnims(); _animator->updateAllObjectShapes(); @@ -1367,7 +1367,7 @@ int KyraEngine_v1::o1_waitForConfirmationMouseClick(ScriptState *script) { _animator->updateAllObjectShapes(); delay(10); } - + while (_mousePressFlag) { updateMousePointer(); _sprites->updateSceneAnims(); @@ -1505,7 +1505,7 @@ int KyraEngine_v1::o1_totalItemsInScene(ScriptState *script) { int KyraEngine_v1::o1_restoreBrandonsMovementDelay(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1restoreBrandonsMovementDelay(%p) ()", (const void *)script); - setWalkspeed(_configWalkspeed); + setWalkspeed(_configWalkspeed); return 0; } @@ -1564,7 +1564,7 @@ int KyraEngine_v1::o1_fadeEntirePalette(ScriptState *script) { fadePal = _screen->getPalette(2); uint8 *screenPal = _screen->getPalette(0); uint8 *backUpPal = _screen->getPalette(3); - + memcpy(backUpPal, screenPal, sizeof(uint8)*768); memset(fadePal, 0, sizeof(uint8)*768); } else if (cmd == 1) { @@ -1577,7 +1577,7 @@ int KyraEngine_v1::o1_fadeEntirePalette(ScriptState *script) { fadePal = _screen->getPalette(0); } } - + _screen->fadePalette(fadePal, stackPos(1)); return 0; } diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp index 2136c2830d..180a5839f3 100644 --- a/engines/kyra/seqplayer.cpp +++ b/engines/kyra/seqplayer.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/system.h" #include "engines/engine.h" @@ -85,7 +85,7 @@ uint8 *SeqPlayer::setPanPages(int pageNum, int shape) { data += offs; uint16 sz = READ_LE_UINT16(data + 6); panPage = new uint8[sz]; - assert(panPage); + assert(panPage); memcpy(panPage, data, sz); } } @@ -97,7 +97,7 @@ void SeqPlayer::makeHandShapes() { _screen->loadBitmap("WRITING.CPS", 3, 3, _screen->_currentPalette); if (_vm->gameFlags().platform == Common::kPlatformMacintosh || _vm->gameFlags().platform == Common::kPlatformAmiga) { freeHandShapes(); - + int pageBackUp = _screen->_curPage; _screen->_curPage = 2; _handShapes[0] = _screen->encodeShape(0, 0, 88, 122, 0); @@ -490,7 +490,7 @@ void SeqPlayer::s1_prefetchVocFile() { bool SeqPlayer::playSequence(const uint8 *seqData, bool skipSeq) { debugC(9, kDebugLevelSequence, "SeqPlayer::seq_playSequence(%p, %d)", (const void *)seqData, skipSeq); assert(seqData); - + static SeqEntry floppySeqProcs[] = { // 0x00 SEQOP(3, s1_wsaOpen), diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 562754b9c5..20a90c2c32 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/system.h" #include "kyra/resource.h" #include "kyra/sound.h" @@ -60,7 +60,7 @@ void Sound::voicePlay(const char *file) { _vm->resource()->getFileHandle(filenamebuffer, &fileSize, _compressHandle); if (!_compressHandle.isOpen()) continue; - + Common::MemoryReadStream *tmp = _compressHandle.readStream(fileSize); assert(tmp); _currentVocFile = _supportedCodes[i].streamFunc(tmp, true, 0, 0, 1); @@ -71,7 +71,7 @@ void Sound::voicePlay(const char *file) { if (!found) { strcpy(filenamebuffer, file); strcat(filenamebuffer, ".VOC"); - + fileData = _vm->resource()->fileData(filenamebuffer, &fileSize); if (!fileData) return; @@ -332,7 +332,7 @@ void SoundMidiPC::stopMusic() { _parser = 0; delete [] _parserSource; _parserSource = 0; - + _fadeStartTime = 0; _fadeMusicOut = false; setVolume(255); @@ -366,7 +366,7 @@ void SoundMidiPC::onTimer(void *refCon) { music->_fadeStartTime = 0; music->_fadeMusicOut = false; music->_isPlaying = false; - + music->_eventFromMusic = true; // from sound/midiparser.cpp for (int i = 0; i < 128; ++i) { diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index b6c06b493b..41c11580b3 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -42,7 +42,7 @@ #ifndef KYRA_SOUND_H #define KYRA_SOUND_H -#include "common/stdafx.h" + #include "common/scummsys.h" #include "common/file.h" #include "common/mutex.h" diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 86f9f718ba..a3953aaf48 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -39,7 +39,7 @@ * */ -#include "common/stdafx.h" + #include "common/system.h" #include "common/mutex.h" #include "kyra/resource.h" @@ -184,7 +184,7 @@ private: uint8 opLevel2; uint8 opExtraLevel3; uint8 twoChan; - uint8 unk39; + uint8 unk39; uint8 unk40; uint8 spacing1; uint8 durationRandomness; @@ -250,7 +250,7 @@ private: POpcode function; const char *name; }; - + void setupParserOpcodeTable(); const ParserOpcode *_parserOpcodeTable; int _parserOpcodeTableSize; @@ -797,7 +797,7 @@ void AdlibDriver::executePrograms() { } } -// +// void AdlibDriver::resetAdlibState() { debugC(9, kDebugLevelSound, "resetAdlibState()"); @@ -1180,7 +1180,7 @@ void AdlibDriver::primaryEffect2(Channel &channel) { uint16 unk2 = (channel.regAx | (channel.regBx << 8)) & 0x3FF; unk2 += unk1; - + channel.regAx = unk2 & 0xFF; channel.regBx = (channel.regBx & 0xFC) | (unk2 >> 8); @@ -1893,7 +1893,7 @@ void AdlibDriver::setupOpcodeList() { COMMAND(snd_setFlag), COMMAND(snd_clearFlag) }; - + _opcodeList = opcodeList; _opcodesEntries = ARRAYSIZE(opcodeList); } @@ -2013,7 +2013,7 @@ void AdlibDriver::setupParserOpcodeTable() { COMMAND(updateCallback56), COMMAND(update_stopChannel) }; - + _parserOpcodeTable = parserOpcodeTable; _parserOpcodeTableSize = ARRAYSIZE(parserOpcodeTable); } @@ -2281,7 +2281,7 @@ void SoundAdlibPC::playSoundEffect(uint8 track) { void SoundAdlibPC::play(uint8 track) { uint16 soundId = 0; - + if (_v2) soundId = READ_LE_UINT16(&_trackEntries[track<<1]); else diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp index dea869d4c0..e0a0c2146b 100644 --- a/engines/kyra/sound_towns.cpp +++ b/engines/kyra/sound_towns.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/system.h" #include "kyra/resource.h" #include "kyra/sound.h" diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index 1a2c7f6146..be1fd2df7e 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/stream.h" #include "common/util.h" @@ -87,7 +87,7 @@ void Sprites::setupSceneAnims() { //sceneUnk2[i] = READ_LE_UINT16(data); data += 4; - + _anims[i].x = READ_LE_UINT16(data); data += 4; _anims[i].y = READ_LE_UINT16(data); @@ -216,7 +216,7 @@ void Sprites::updateSceneAnims() { data += 2; debugC(1, kDebugLevelSprites, "func: Set value of unknown animation property to 0"); _anims[i].unk1 = 0; - break; + break; case 0xFF97: data += 2; debugC(6, kDebugLevelSprites, "func: Set default X coordinate of sprite"); @@ -425,7 +425,7 @@ void Sprites::loadDat(const char *filename, SceneExits &exits) { if (_vm->queryGameFlag(0xA0)) memcpy(_screen->getPalette(3), _screen->getPalette(4), 32*3); else - memcpy(_screen->getPalette(3), _screen->getPalette(0), 32*3); + memcpy(_screen->getPalette(3), _screen->getPalette(0), 32*3); } else { if (_vm->queryGameFlag(0xA0)) memcpy(_screen->getPalette(1), _screen->getPalette(3), 768); @@ -446,7 +446,7 @@ void Sprites::loadDat(const char *filename, SceneExits &exits) { while (1) { if (((uint16)(data - _dat) >= fileSize) || (data - start) >= length) - break; + break; if (READ_LE_UINT16(data) == 0xFF83) { //debugC(1, kDebugLevelSprites, "Body section end."); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 2ffa7aee09..f52c041aa4 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/md5.h" #include "kyra/kyra.h" @@ -41,14 +41,14 @@ bool StaticResource::checkKyraDat() { Common::File kyraDat; if (!kyraDat.open("KYRA.DAT")) return false; - + uint32 size = kyraDat.size() - 16; uint8 digest[16]; kyraDat.seek(size, SEEK_SET); if (kyraDat.read(digest, 16) != 16) return false; kyraDat.close(); - + uint8 digestCalc[16]; if (!Common::md5_file("KYRA.DAT", digestCalc, size)) return false; @@ -183,7 +183,7 @@ bool StaticResource::init() { // GUI strings table { kGUIStrings, kLanguageList, "GUISTRINGS." }, { kConfigStrings, kLanguageList, "CONFIGSTRINGS." }, - + // ROOM table/filenames { Kyra::kRoomList, StaticResource::kRoomList, "ROOM-TABLE.ROOM" }, { kRoomFilenames, kStringList, "ROOM-FILENAMES.TXT" }, @@ -210,7 +210,7 @@ bool StaticResource::init() { // PALETTE table { kPaletteList, kPaletteTable, "1 33 PALTABLE" }, - + // FM-TOWNS specific { kKyra1TownsSFXTable, kRawData, "SFXTABLE" }, { kCreditsStrings, kRawData, "CREDITS" }, @@ -233,14 +233,14 @@ bool StaticResource::init() { warning("no matching INDEX file found"); return false; } - + uint32 version = READ_BE_UINT32(temp); uint32 gameID = READ_BE_UINT32((temp+4)); uint32 featuresValue = READ_BE_UINT32((temp+8)); - + delete [] temp; temp = 0; - + if (version != RESFILE_VERSION) error("invalid KYRA.DAT file version (%d, required %d)", version, RESFILE_VERSION); if (gameID != _vm->game()) @@ -381,7 +381,7 @@ const StaticResource::FileType *StaticResource::getFiletype(int type) { const void *StaticResource::getData(int id, int requesttype, int &size) { const void *ptr = 0; - int type = -1; + int type = -1; size = 0; if (checkResList(id, type, ptr, size)) { @@ -413,7 +413,7 @@ bool StaticResource::loadLanguageTable(const char *filename, void *&ptr, int &si for (int i = 0; languages[i].ext; ++i) { if (languages[i].flags != createLanguage(_vm->gameFlags())) continue; - + strcpy(file, filename); strcat(file, languages[i].ext); if (loadStringTable(file, ptr, size)) @@ -444,7 +444,7 @@ bool StaticResource::loadStringTable(const char *filename, void *&ptr, int &size size = count; char **output = new char*[count]; assert(output); - + const char *curPos = (const char*)src; for (uint32 i = 0; i < count; ++i) { int strLen = strlen(curPos); @@ -477,7 +477,7 @@ bool StaticResource::loadShapeTable(const char *filename, void *&ptr, int &size) size = count; Shape *loadTo = new Shape[count]; assert(loadTo); - + for (uint32 i = 0; i < count; ++i) { loadTo[i].imageIndex = *src++; loadTo[i].x = *src++; @@ -504,7 +504,7 @@ bool StaticResource::loadRoomTable(const char *filename, void *&ptr, int &size) size = count; Room *loadTo = new Room[count]; assert(loadTo); - + for (uint32 i = 0; i < count; ++i) { loadTo[i].nameIndex = *src++; loadTo[i].northExit = READ_BE_UINT16(src); src += 2; @@ -656,9 +656,9 @@ void KyraEngine_v1::initStaticResource() { _veryClever = _staticres->loadStrings(kVeryCleverString, _veryClever_Size); _homeString = _staticres->loadStrings(kOutroHomeString, _homeString_Size); _newGameString = _staticres->loadStrings(kNewGameString, _newGameString_Size); - + _healingShapeTable = _staticres->loadShapeTable(kHealing1Shapes, _healingShapeTableSize); - _healingShape2Table = _staticres->loadShapeTable(kHealing2Shapes, _healingShape2TableSize); + _healingShape2Table = _staticres->loadShapeTable(kHealing2Shapes, _healingShape2TableSize); _posionDeathShapeTable = _staticres->loadShapeTable(kPoisonDeathShapes, _posionDeathShapeTableSize); _fluteAnimShapeTable = _staticres->loadShapeTable(kFluteShapes, _fluteAnimShapeTableSize); _winterScrollTable = _staticres->loadShapeTable(kWinter1Shapes, _winterScrollTableSize); @@ -672,14 +672,14 @@ void KyraEngine_v1::initStaticResource() { _characterImageTable = _staticres->loadStrings(kCharacterImageFilenames, _characterImageTableSize); _roomFilenameTable = _staticres->loadStrings(kRoomFilenames, _roomFilenameTableSize); - + _amuleteAnim = _staticres->loadRawData(kAmuleteAnimSeq, temp); - + _specialPalettes = _staticres->loadPaletteTable(kPaletteList, temp); _guiStrings = _staticres->loadStrings(kGUIStrings, _guiStringsSize); _configStrings = _staticres->loadStrings(kConfigStrings, _configStringsSize); - + // copied static res // room list @@ -729,7 +729,7 @@ void KyraEngine_v1::loadCharacterShapes() { int curImage = 0xFF; int videoPage = _screen->_curPage; _screen->_curPage = 2; - for (int i = 0; i < 115; ++i) { + for (int i = 0; i < 115; ++i) { assert(i < _defaultShapeTableSize); Shape *shape = &_defaultShapeTable[i]; if (shape->imageIndex == 0xFF) { @@ -749,17 +749,17 @@ void KyraEngine_v1::loadCharacterShapes() { void KyraEngine_v1::loadSpecialEffectShapes() { _screen->loadBitmap("EFFECTS.CPS", 3, 3, 0); _screen->_curPage = 2; - - int currShape; + + int currShape; for (currShape = 173; currShape < 183; currShape++) _shapes[currShape] = _screen->encodeShape((currShape-173) * 24, 0, 24, 24, 1); - + for (currShape = 183; currShape < 190; currShape++) _shapes[currShape] = _screen->encodeShape((currShape-183) * 24, 24, 24, 24, 1); - + for (currShape = 190; currShape < 201; currShape++) _shapes[currShape] = _screen->encodeShape((currShape-190) * 24, 48, 24, 24, 1); - + for (currShape = 201; currShape < 206; currShape++) _shapes[currShape] = _screen->encodeShape((currShape-201) * 16, 106, 16, 16, 1); } @@ -835,7 +835,7 @@ void KyraEngine_v1::loadMainScreen(int page) { if (_flags.lang == Common::EN_ANY && !_flags.isTalkie && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) _screen->loadBitmap("MAIN15.CPS", page, page, _screen->getPalette(0)); - else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN || (_flags.isTalkie && _flags.lang == Common::IT_ITA)) + else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN || (_flags.isTalkie && _flags.lang == Common::IT_ITA)) _screen->loadBitmap("MAIN_ENG.CPS", page, page, 0); else if (_flags.lang == Common::FR_FRA) _screen->loadBitmap("MAIN_FRE.CPS", page, page, 0); @@ -982,7 +982,7 @@ void KyraEngine_v1::setupButtonData() { &buttonData[14], 0 }; - + _buttonData = buttonData; _buttonDataListPtr = buttonDataListPtr; } @@ -1001,7 +1001,7 @@ Button KyraEngine_v1::_menuButtonData[] = { void KyraEngine_v1::setupMenu() { static Menu menu[] = { - { -1, -1, 208, 136, 248, 249, 250, 0, 251, -1, 8, 0, 5, -1, -1, -1, -1, + { -1, -1, 208, 136, 248, 249, 250, 0, 251, -1, 8, 0, 5, -1, -1, -1, -1, { {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, @@ -1030,16 +1030,16 @@ void KyraEngine_v1::setupMenu() { }, { -1, -1, 288, 160, 248, 249, 250, 0, 251, -1, 8, 0, 6, 132, 22, 132, 124, { - {1, 0, 0, 0, -1, 255, 39, 256, 15, 252, 253, 5, 0, + {1, 0, 0, 0, -1, 255, 39, 256, 15, 252, 253, 5, 0, 248, 249, 250, 0, -1, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, -1, 255, 56, 256, 15, 252, 253, 5, 0, + {1, 0, 0, 0, -1, 255, 56, 256, 15, 252, 253, 5, 0, 248, 249, 250, 0, -1, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, -1, 255, 73, 256, 15, 252, 253, 5, 0, + {1, 0, 0, 0, -1, 255, 73, 256, 15, 252, 253, 5, 0, 248, 249, 250, 0, -1, 0, 0, 0, 0, 0}, - {1, 0, 0, 0, -1, 255, 90, 256, 15, 252, 253, 5, 0, + {1, 0, 0, 0, -1, 255, 90, 256, 15, 252, 253, 5, 0, 248, 249, 250, 0, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, 255, 107, 256, 15, 252, 253, 5, 0, @@ -1058,7 +1058,7 @@ void KyraEngine_v1::setupMenu() { 248, 249, 250, &KyraEngine_v1::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0} } }, - { -1, -1, 208, 76, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1, + { -1, -1, 208, 76, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1, { {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, @@ -1067,7 +1067,7 @@ void KyraEngine_v1::setupMenu() { 248, 249, 250, &KyraEngine_v1::gui_quitPlaying, -1, 0, 0, 0, 0, 0} } }, - { -1, -1, 208, 153, 248, 249, 250, 0, 251, -1, 8, 0, 6, -1, -1, -1, -1, + { -1, -1, 208, 153, 248, 249, 250, 0, 251, -1, 8, 0, 6, -1, -1, -1, -1, { {1, 0, 0, 0, 110, 0, 30, 64, 15, 252, 253, 5, 0, 248, 249, 250, &KyraEngine_v1::gui_controlsChangeMusic, -1, 0, 34, 32, 0, 0}, @@ -1089,7 +1089,7 @@ void KyraEngine_v1::setupMenu() { } } }; - + _menu = menu; } diff --git a/engines/kyra/text.cpp b/engines/kyra/text.cpp index e62410ca19..9428d80725 100644 --- a/engines/kyra/text.cpp +++ b/engines/kyra/text.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "kyra/kyra.h" #include "kyra/screen.h" @@ -76,7 +76,7 @@ int TextDisplayer::getCharLength(const char *str, int len) { if (c >= 0x7F && _vm->gameFlags().lang == Common::JA_JPN) { c = READ_LE_UINT16(str - 1); ++str; - } + } i += _screen->getCharWidth(*str++); ++charsCount; } diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp index 16b40cd06e..685a3e5a31 100644 --- a/engines/kyra/vqa.cpp +++ b/engines/kyra/vqa.cpp @@ -31,7 +31,7 @@ // // The jung2.vqa movie does work, but only thanks to a grotesque hack. -#include "common/stdafx.h" + #include "common/events.h" #include "common/system.h" #include "sound/audiostream.h" @@ -273,7 +273,7 @@ bool VQAMovie::open(const char *filename) { // // This is good, because it means we won't have // to worry about the confusing parts of the - // VQA spec, where 8- and 16-bit data have + // VQA spec, where 8- and 16-bit data have // different signedness and stereo sample // layout varies between different games. diff --git a/engines/kyra/wsamovie.cpp b/engines/kyra/wsamovie.cpp index 7e9ec9b78b..14b82e5d1d 100644 --- a/engines/kyra/wsamovie.cpp +++ b/engines/kyra/wsamovie.cpp @@ -23,7 +23,7 @@ * */ -#include "common/stdafx.h" + #include "common/endian.h" #include "common/system.h" @@ -46,7 +46,7 @@ int WSAMovieV1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { uint8 *p = _vm->resource()->fileData(filename, &fileSize); if (!p) return 0; - + const uint8 *wsaData = p; _numFrames = READ_LE_UINT16(wsaData); wsaData += 2; _width = READ_LE_UINT16(wsaData); wsaData += 2; @@ -55,10 +55,10 @@ int WSAMovieV1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { _offscreenBuffer = NULL; _flags = 0; if (_vm->gameFlags().useAltShapeHeader) { - flags = READ_LE_UINT16(wsaData); + flags = READ_LE_UINT16(wsaData); wsaData += 2; } - + uint32 offsPal = 0; if (flags & 1) { offsPal = 0x300; @@ -66,7 +66,7 @@ int WSAMovieV1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { if (palBuf) memcpy(palBuf, wsaData + (_numFrames + 2) * 4, 0x300); } - + if (offscreenDecode) { _flags |= WF_OFFSCREEN_DECODE; const int offscreenBufferSize = _width * _height; @@ -86,7 +86,7 @@ int WSAMovieV1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { _deltaBuffer = new uint8[_deltaBufferSize]; memset(_deltaBuffer, 0, _deltaBufferSize); - + // read frame offsets _frameOffsTable = new uint32[_numFrames + 2]; _frameOffsTable[0] = 0; @@ -103,22 +103,22 @@ int WSAMovieV1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { _frameOffsTable[i] = READ_LE_UINT32(wsaData) - frameDataOffs; wsaData += 4; } - + // skip palette wsaData += offsPal; - + // read frame data const int frameDataSize = p + fileSize - wsaData; _frameData = new uint8[frameDataSize]; memcpy(_frameData, wsaData, frameDataSize); - + // decode first frame if (firstFrame) Screen::decodeFrame4(_frameData, _deltaBuffer, _deltaBufferSize); - + delete [] p; _opened = true; - + return _numFrames; } @@ -143,7 +143,7 @@ void WSAMovieV1::displayFrame(int frameNum, ...) { dst = _offscreenBuffer; else dst = _vm->screen()->getPageRect(_drawPage, _x, _y, _width, _height); - + if (_currentFrame == _numFrames) { if (!(_flags & WF_NO_FIRST_FRAME)) { if (_flags & WF_OFFSCREEN_DECODE) @@ -171,7 +171,7 @@ void WSAMovieV1::displayFrame(int frameNum, ...) { frameCount = diffCount; } } - + // process if (frameStep > 0) { uint16 cf = _currentFrame; @@ -190,7 +190,7 @@ void WSAMovieV1::displayFrame(int frameNum, ...) { cf += frameStep; } } - + // display _currentFrame = frameNum; if (_flags & WF_OFFSCREEN_DECODE) @@ -223,7 +223,7 @@ int WSAMovieAmiga::open(const char *filename, int offscreenDecode, uint8 *palBuf _buffer = new uint8[_width * _height]; assert(_buffer); - return res; + return res; } void WSAMovieAmiga::close() { @@ -282,7 +282,7 @@ void WSAMovieAmiga::displayFrame(int frameNum, ...) { frameCount = diffCount; } } - + // process if (frameStep > 0) { uint16 cf = _currentFrame; @@ -301,7 +301,7 @@ void WSAMovieAmiga::displayFrame(int frameNum, ...) { cf += frameStep; } } - + // display _currentFrame = frameNum; if (_flags & WF_OFFSCREEN_DECODE) @@ -334,7 +334,7 @@ void WSAMovieAmiga::processFrame(int frameNum, uint8 *dst) { for (int y = 0; y < _height; ++y) { for (int x = 0; x < _width; ++x) - *dst++ ^= *src++; + *dst++ ^= *src++; dst += dstPitch - _width; } } @@ -354,7 +354,7 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { warning("couldn't load wsa file: '%s'", filename); return 0; } - + const uint8 *wsaData = p; _numFrames = READ_LE_UINT16(wsaData); wsaData += 2; _xAdd = (int16)(READ_LE_UINT16(wsaData)); wsaData += 2; @@ -365,7 +365,7 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { _offscreenBuffer = NULL; _flags = 0; flags = READ_LE_UINT16(wsaData); wsaData += 2; - + uint32 offsPal = 0; if (flags & 1) { offsPal = 0x300; @@ -373,10 +373,10 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { if (palBuf) memcpy(palBuf, wsaData + 8 + ((_numFrames << 2) & 0xFFFF), 0x300); } - + if (flags & 2) _flags |= WF_XOR; - + if (!(unk1 & 2)) { _flags |= WF_OFFSCREEN_DECODE; const int offscreenBufferSize = _width * _height; @@ -393,7 +393,7 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { _deltaBuffer = new uint8[_deltaBufferSize]; memset(_deltaBuffer, 0, _deltaBufferSize); - + // read frame offsets _frameOffsTable = new uint32[_numFrames + 2]; _frameOffsTable[0] = 0; @@ -402,21 +402,21 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { _frameOffsTable[i] = READ_LE_UINT32(wsaData) - frameDataOffs; wsaData += 4; } - + // skip palette wsaData += offsPal; - + // read frame data const int frameDataSize = p + fileSize - wsaData; _frameData = new uint8[frameDataSize]; memcpy(_frameData, wsaData, frameDataSize); - + // decode first frame Screen::decodeFrame4(_frameData, _deltaBuffer, _deltaBufferSize); - + delete [] p; _opened = true; - + return _numFrames; } @@ -430,7 +430,7 @@ void WSAMovieV2::displayFrame(int frameNum, ...) { dst = _offscreenBuffer; else dst = _vm->screen()->getPageRect(_drawPage, _x, _y, _width, _height); - + if (_currentFrame == _numFrames) { if (!(_flags & WF_NO_FIRST_FRAME)) { if (_flags & WF_OFFSCREEN_DECODE) @@ -458,7 +458,7 @@ void WSAMovieV2::displayFrame(int frameNum, ...) { frameCount = diffCount; } } - + // process if (frameStep > 0) { uint16 cf = _currentFrame; @@ -477,7 +477,7 @@ void WSAMovieV2::displayFrame(int frameNum, ...) { cf += frameStep; } } - + // display _currentFrame = frameNum; if (_flags & WF_OFFSCREEN_DECODE) { @@ -494,17 +494,17 @@ void WSAMovieV2::displayFrame(int frameNum, ...) { va_list args; va_start(args, frameNum); - + int copyParam = va_arg(args, int); int plotFunc = (copyParam & 0xFF00) >> 12; int unk1 = copyParam & 0xFF; - + const uint8 *unkPtr1 = va_arg(args, const uint8*); const uint8 *unkPtr2 = va_arg(args, const uint8*); va_end(args); screen->copyWsaRect(_x, _y, _width, _height, 0, plotFunc, _offscreenBuffer, unk1, unkPtr1, unkPtr2); - + screen->_curPage = pageBackUp; } } |