diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/animation.cpp | 64 | ||||
-rw-r--r-- | engines/draci/animation.h | 28 | ||||
-rw-r--r-- | engines/draci/barchive.cpp | 58 | ||||
-rw-r--r-- | engines/draci/barchive.h | 10 | ||||
-rw-r--r-- | engines/draci/detection.cpp | 2 | ||||
-rw-r--r-- | engines/draci/draci.cpp | 38 | ||||
-rw-r--r-- | engines/draci/draci.h | 4 | ||||
-rw-r--r-- | engines/draci/font.cpp | 36 | ||||
-rw-r--r-- | engines/draci/font.h | 18 | ||||
-rw-r--r-- | engines/draci/game.cpp | 128 | ||||
-rw-r--r-- | engines/draci/game.h | 22 | ||||
-rw-r--r-- | engines/draci/mouse.cpp | 4 | ||||
-rw-r--r-- | engines/draci/mouse.h | 6 | ||||
-rw-r--r-- | engines/draci/screen.cpp | 10 | ||||
-rw-r--r-- | engines/draci/screen.h | 2 | ||||
-rw-r--r-- | engines/draci/script.cpp | 44 | ||||
-rw-r--r-- | engines/draci/script.h | 16 | ||||
-rw-r--r-- | engines/draci/sprite.cpp | 28 | ||||
-rw-r--r-- | engines/draci/sprite.h | 24 | ||||
-rw-r--r-- | engines/draci/surface.cpp | 4 | ||||
-rw-r--r-- | engines/draci/surface.h | 6 |
21 files changed, 276 insertions, 276 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 5af4110768..3429884397 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -40,7 +40,7 @@ Animation::Animation(DraciEngine *vm, int index) : _vm(vm) { _tick = _vm->_system->getMillis(); _currentFrame = 0; _callback = &Animation::doNothing; -} +} Animation::~Animation() { deleteFrames(); @@ -52,7 +52,7 @@ bool Animation::isLooping() const { void Animation::setRelative(int relx, int rely) { // Delete the previous frame if there is one - if (_frames.size() > 0) + if (_frames.size() > 0) markDirtyRect(_vm->_screen->getSurface()); _displacement.relX = relx; @@ -61,18 +61,18 @@ void Animation::setRelative(int relx, int rely) { void Animation::setLooping(bool looping) { _looping = looping; - debugC(7, kDraciAnimationDebugLevel, "Setting looping to %d on animation %d", + debugC(7, kDraciAnimationDebugLevel, "Setting looping to %d on animation %d", looping, _id); } void Animation::markDirtyRect(Surface *surface) const { // Fetch the current frame's rectangle Drawable *frame = _frames[_currentFrame]; - Common::Rect frameRect = frame->getRect(_displacement); + Common::Rect frameRect = frame->getRect(_displacement); // Mark the rectangle dirty on the surface surface->markDirtyRect(frameRect); -} +} void Animation::nextFrame(bool force) { // If there are no frames or if the animation is not playing, return @@ -81,7 +81,7 @@ void Animation::nextFrame(bool force) { Drawable *frame = _frames[_currentFrame]; Surface *surface = _vm->_screen->getSurface(); - + if (force || (_tick + frame->getDelay() <= _vm->_system->getMillis())) { // If we are at the last frame and not looping, stop the animation // The animation is also restarted to frame zero @@ -100,14 +100,14 @@ void Animation::nextFrame(bool force) { } } - debugC(6, kDraciAnimationDebugLevel, - "anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d x=%d y=%d z=%d", - _id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(), + debugC(6, kDraciAnimationDebugLevel, + "anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d x=%d y=%d z=%d", + _id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(), _currentFrame, _frames.size(), frame->getX() + getRelativeX(), frame->getY() + getRelativeY(), _z); } uint Animation::nextFrameNum() const { - if (_paused) + if (_paused) return _currentFrame; if ((_currentFrame == getFrameCount() - 1) && _looping) @@ -173,12 +173,12 @@ void Animation::setPaused(bool paused) { } void Animation::setScaleFactors(double scaleX, double scaleY) { - debugC(5, kDraciAnimationDebugLevel, - "Setting scaling factors on anim %d (scaleX: %.3f scaleY: %.3f)", + debugC(5, kDraciAnimationDebugLevel, + "Setting scaling factors on anim %d (scaleX: %.3f scaleY: %.3f)", _id, scaleX, scaleY); markDirtyRect(_vm->_screen->getSurface()); - + _displacement.extraScaleX = scaleX; _displacement.extraScaleY = scaleY; } @@ -244,15 +244,15 @@ void Animation::deleteFrames() { for (int i = getFrameCount() - 1; i >= 0; --i) { delete _frames[i]; - _frames.pop_back(); + _frames.pop_back(); } } -void Animation::stopAnimation() { +void Animation::stopAnimation() { _vm->_anims->stop(_id); } -void Animation::exitGameLoop() { +void Animation::exitGameLoop() { _vm->_game->setExitLoop(true); } @@ -261,7 +261,7 @@ Animation *AnimationManager::addAnimation(int id, uint z, bool playing) { ++_lastIndex; Animation *anim = new Animation(_vm, _lastIndex); - + anim->setID(id); anim->setZ(z); anim->setPlaying(playing); @@ -310,7 +310,7 @@ void AnimationManager::play(int id) { void AnimationManager::stop(int id) { Animation *anim = getAnimation(id); - + if (anim) { // Clean up the last frame that was drawn before stopping anim->markDirtyRect(_vm->_screen->getSurface()); @@ -319,7 +319,7 @@ void AnimationManager::stop(int id) { // Reset the animation to the beginning anim->setCurrentFrame(0); - + debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", id); } } @@ -366,7 +366,7 @@ void AnimationManager::insertAnimation(Animation *anim) { Common::List<Animation *>::iterator it; for (it = _animations.begin(); it != _animations.end(); ++it) { - if (anim->getZ() < (*it)->getZ()) + if (anim->getZ() < (*it)->getZ()) break; } @@ -374,11 +374,11 @@ void AnimationManager::insertAnimation(Animation *anim) { } void AnimationManager::addOverlay(Drawable *overlay, uint z) { - // Since this is an overlay, we don't need it to be deleted + // Since this is an overlay, we don't need it to be deleted // when the GPL Release command is invoked so we pass the index // as kIgnoreIndex Animation *anim = new Animation(_vm, kIgnoreIndex); - + anim->setID(kOverlayImage); anim->setZ(z); anim->setPlaying(true); @@ -398,8 +398,8 @@ void AnimationManager::drawScene(Surface *surf) { for (it = _animations.begin(); it != _animations.end(); ++it) { if (! ((*it)->isPlaying()) ) { continue; - } - + } + (*it)->nextFrame(); (*it)->drawFrame(surf); } @@ -413,10 +413,10 @@ void AnimationManager::sortAnimations() { // If the list is empty, we're done if (cur == _animations.end()) - return; + return; + + bool hasChanged; - bool hasChanged; - do { hasChanged = false; cur = _animations.begin(); @@ -447,7 +447,7 @@ void AnimationManager::sortAnimations() { void AnimationManager::deleteAnimation(int id) { Common::List<Animation *>::iterator it; - + int index = -1; // Iterate for the first time to delete the animation @@ -472,7 +472,7 @@ void AnimationManager::deleteAnimation(int id) { } } - // Decrement index of last animation + // Decrement index of last animation _lastIndex -= 1; } @@ -519,7 +519,7 @@ void AnimationManager::deleteAfterIndex(int index) { it = _animations.reverse_erase(it); } } - + _lastIndex = index; } @@ -553,11 +553,11 @@ int AnimationManager::getTopAnimationID(int x, int y) const { retval = anim->getID(); - } else if (frame->getType() == kDrawableSprite && + } else if (frame->getType() == kDrawableSprite && reinterpret_cast<const Sprite *>(frame)->getPixel(x, y, anim->getDisplacement()) != transparent) { retval = anim->getID(); - } + } } // Found an animation diff --git a/engines/draci/animation.h b/engines/draci/animation.h index 9baa829cfb..e8b09823e6 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -22,7 +22,7 @@ * $Id$ * */ - + #ifndef DRACI_ANIMATION_H #define DRACI_ANIMATION_H @@ -35,9 +35,9 @@ namespace Draci { * specified in the data files. */ enum { - kOverlayImage = -1, - kWalkingMapOverlay = -2, - kTitleText = -3, + kOverlayImage = -1, + kWalkingMapOverlay = -2, + kTitleText = -3, kSpeechText = -4, kInventorySprite = -5, kDialogueLinesID = -6, @@ -46,13 +46,13 @@ enum { }; /** - * Default argument to Animation::getFrame() that makes it return + * Default argument to Animation::getFrame() that makes it return * the current frame instead of the user specifying it. */ enum { kCurrentFrame = -1 }; -/** - * Used by overlays as a neutral index that won't get +/** + * Used by overlays as a neutral index that won't get * released with the GPL Release command. */ enum { kIgnoreIndex = -2 }; @@ -66,10 +66,10 @@ typedef void (Animation::* AnimationCallback)(); public: Animation(DraciEngine *v, int index); ~Animation(); - + uint getZ() const; void setZ(uint z); - + void setID(int id); int getID() const; @@ -117,11 +117,11 @@ private: uint nextFrameNum() const; void deleteFrames(); - /** Internal animation ID + /** Internal animation ID * (as specified in the data files and the bytecode) */ - int _id; - + int _id; + /** The recency index of an animation, i.e. the most recently added animation has * the highest index. Some script commands need this. */ @@ -157,7 +157,7 @@ public: Animation *addText(int id, bool playing = false); Animation *addItem(int id, bool playing = false); void addOverlay(Drawable *overlay, uint z); - + void play(int id); void stop(int id); void pauseAnimations(); @@ -187,7 +187,7 @@ private: */ Common::List<Animation *> _animations; - /** The index of the most recently added animation. + /** The index of the most recently added animation. * See Animation::_index for details. */ int _lastIndex; diff --git a/engines/draci/barchive.cpp b/engines/draci/barchive.cpp index ae03cad965..30652a0b5a 100644 --- a/engines/draci/barchive.cpp +++ b/engines/draci/barchive.cpp @@ -50,11 +50,11 @@ const char BArchive::_dfwMagicNumber[] = "BS"; * * header format: [uint16LE] file count * [uint16LE] index table size - * [2 bytes] magic number "BS" + * [2 bytes] magic number "BS" * * index table format: entry0, entry1, ... * - * entry<N> format: [uint16LE] compressed size (not including the 2 bytes for the + * entry<N> format: [uint16LE] compressed size (not including the 2 bytes for the * "uncompressed size" field) * [uint32LE] fileN offset from start of file * @@ -106,7 +106,7 @@ void BArchive::openDFW(const Common::String &path) { // Seek to the current file f.seek(_files[i]._offset); - + _files[i]._length = f.readUint16LE(); // Read in uncompressed length f.readUint16LE(); // Compressed length again (already read from the index table) _files[i]._stopper = f.readByte(); @@ -117,7 +117,7 @@ void BArchive::openDFW(const Common::String &path) { // Indicate that the archive was successfully opened _opened = true; - + // Cleanup delete[] table; f.close(); @@ -129,8 +129,8 @@ void BArchive::openDFW(const Common::String &path) { * * Opens a BAR (Bob's Archiver) archive, which is the game's archiving format. * BAR archives have a .DFW file extension, due to a historical interface. - * - * archive format: header, + * + * archive format: header, * file0, file1, ... * footer * @@ -144,7 +144,7 @@ void BArchive::openDFW(const Common::String &path) { * [1 byte] CRC * [multiple bytes] actual data * - * footer format: [array of uint32LE] offsets of individual files from start of archive + * footer format: [array of uint32LE] offsets of individual files from start of archive * (last entry is footer offset again) */ @@ -156,7 +156,7 @@ void BArchive::openArchive(const Common::String &path) { // Close previously opened archive (if any) closeArchive(); - + debugCN(2, kDraciArchiverDebugLevel, "Loading archive %s: ", path.c_str()); f.open(path); @@ -176,7 +176,7 @@ void BArchive::openArchive(const Common::String &path) { f.read(buf, 4); if (memcmp(buf, _magicNumber, 4) == 0) { debugC(2, kDraciArchiverDebugLevel, "Success"); - + // Indicate this archive is a BAR _isDFW = false; } else { @@ -193,7 +193,7 @@ void BArchive::openArchive(const Common::String &path) { _fileCount = f.readUint16LE(); footerOffset = f.readUint32LE(); footerSize = f.size() - footerOffset; - + debugC(2, kDraciArchiverDebugLevel, "Archive info: %d files, %d data bytes", _fileCount, footerOffset - _archiveHeaderSize); @@ -209,31 +209,31 @@ void BArchive::openArchive(const Common::String &path) { for (uint i = 0; i < _fileCount; i++) { uint32 fileOffset; - + fileOffset = reader.readUint32LE(); f.seek(fileOffset); // Seek to next file in archive - _files[i]._compLength = f.readUint16LE(); // Compressed size + _files[i]._compLength = f.readUint16LE(); // Compressed size // should be the same as uncompressed _files[i]._length = f.readUint16LE(); // Original size - + _files[i]._offset = fileOffset; // Offset of file from start - assert(f.readByte() == 0 && + assert(f.readByte() == 0 && "Compression type flag is non-zero (file is compressed)"); _files[i]._crc = f.readByte(); // CRC checksum of the file _files[i]._data = NULL; // File data will be read in on demand _files[i]._stopper = 0; // Dummy value; not used in BAR files, needed in DFW } - + // Last footer item should be equal to footerOffset assert(reader.readUint32LE() == footerOffset && "Footer offset mismatch"); // Indicate that the archive has been successfully opened - _opened = true; - + _opened = true; + delete[] footer; f.close(); } @@ -251,7 +251,7 @@ void BArchive::closeArchive(void) { for (uint i = 0; i < _fileCount; ++i) { if (_files[i]._data) { - delete[] _files[i]._data; + delete[] _files[i]._data; } } @@ -267,8 +267,8 @@ void BArchive::closeArchive(void) { * @param i Index of file inside an archive * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure) * - * Loads individual BAR files from an archive to memory on demand. - * Should not be called directly. Instead, one should access files + * Loads individual BAR files from an archive to memory on demand. + * Should not be called directly. Instead, one should access files * through the operator[] interface. */ BAFile *BArchive::loadFileBAR(uint i) const { @@ -293,8 +293,8 @@ BAFile *BArchive::loadFileBAR(uint i) const { for (uint j = 0; j < _files[i]._length; j++) { tmp ^= _files[i]._data[j]; } - - debugC(3, kDraciArchiverDebugLevel, "Cached file %d from archive %s", + + debugC(3, kDraciArchiverDebugLevel, "Cached file %d from archive %s", i, _path.c_str()); assert(tmp == _files[i]._crc && "CRC checksum mismatch"); @@ -306,8 +306,8 @@ BAFile *BArchive::loadFileBAR(uint i) const { * @param i Index of file inside an archive * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure) * - * Loads individual DFW files from an archive to memory on demand. - * Should not be called directly. Instead, one should access files + * Loads individual DFW files from an archive to memory on demand. + * Should not be called directly. Instead, one should access files * through the operator[] interface. */ BAFile *BArchive::loadFileDFW(uint i) const { @@ -326,14 +326,14 @@ BAFile *BArchive::loadFileDFW(uint i) const { // Seek to raw data of the file // Five bytes are for the header (uncompressed and compressed length, stopper mark) f.seek(_files[i]._offset + 5); - + // Since we are seeking directly to raw data, we subtract 3 bytes from the length // (to take account the compressed length and stopper mark) uint16 compressedLength = _files[i]._compLength - 3; uint16 uncompressedLength = _files[i]._length; - debugC(2, kDraciArchiverDebugLevel, - "File info (DFW): uncompressed %d bytes, compressed %d bytes", + debugC(2, kDraciArchiverDebugLevel, + "File info (DFW): uncompressed %d bytes, compressed %d bytes", uncompressedLength, compressedLength); // Allocate a buffer for the file data @@ -353,7 +353,7 @@ BAFile *BArchive::loadFileDFW(uint i) const { byte stopper = _files[i]._stopper; uint repeat; uint len = 0; // Sanity check (counts uncompressed bytes) - + current = data.readByte(); // Read initial byte while (!data.eos()) { if (current != stopper) { @@ -396,7 +396,7 @@ const BAFile *BArchive::getFile(uint i) const { return NULL; } - debugCN(2, kDraciArchiverDebugLevel, "Accessing file %d from archive %s... ", + debugCN(2, kDraciArchiverDebugLevel, "Accessing file %d from archive %s... ", i, _path.c_str()); // Check if file has already been opened and return that diff --git a/engines/draci/barchive.h b/engines/draci/barchive.h index d9189e8652..cb3c068289 100644 --- a/engines/draci/barchive.h +++ b/engines/draci/barchive.h @@ -42,7 +42,7 @@ struct BAFile { byte _stopper; //!< Not used in BAR files, needed for DFW /** Releases the file data (for memory considerations) */ - void close(void) { + void close(void) { delete[] _data; _data = NULL; } @@ -53,8 +53,8 @@ public: BArchive() : _files(NULL), _fileCount(0), _opened(false) {} BArchive(const Common::String &path) : - _files(NULL), _fileCount(0), _opened(false) { - openArchive(path); + _files(NULL), _fileCount(0), _opened(false) { + openArchive(path); } ~BArchive() { closeArchive(); } @@ -63,7 +63,7 @@ public: void closeArchive(void); uint size() const { return _fileCount; } - /** + /** * Checks whether there is an archive opened. Should be called before reading * from the archive to check whether openArchive() succeeded. */ @@ -78,7 +78,7 @@ private: static const char _magicNumber[]; static const char _dfwMagicNumber[]; static const uint _archiveHeaderSize = 10; - + // File stream header data static const uint _fileHeaderSize = 6; diff --git a/engines/draci/detection.cpp b/engines/draci/detection.cpp index b57a8f587d..37e1af6a85 100644 --- a/engines/draci/detection.cpp +++ b/engines/draci/detection.cpp @@ -105,7 +105,7 @@ public: virtual const char *getOriginalCopyright() const { return "Copyright (C) 1995 NoSense"; } - + virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; }; diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 57a1b11812..55c42c9097 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -24,7 +24,7 @@ */ #include "common/scummsys.h" - + #include "common/config-manager.h" #include "common/events.h" #include "common/file.h" @@ -33,7 +33,7 @@ #include "graphics/cursorman.h" #include "graphics/font.h" - + #include "draci/draci.h" #include "draci/barchive.h" #include "draci/script.h" @@ -59,14 +59,14 @@ const Common::String itemImagesPath("OBR_IK.DFW"); const Common::String initPath("INIT.DFW"); const Common::String stringsPath("RETEZCE.DFW"); -DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) +DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) { // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you // need to do such things, do them from init(). - + // Do not initialize graphics here - + // However this is the place to specify all default directories //Common::File::addDefaultDirectory(_gameDataPath + "sound/"); @@ -76,7 +76,7 @@ DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) Common::addDebugChannel(kDraciArchiverDebugLevel, "archiver", "BAR archiver debug info"); Common::addDebugChannel(kDraciLogicDebugLevel, "logic", "Game logic debug info"); Common::addDebugChannel(kDraciAnimationDebugLevel, "animation", "Animation debug info"); - + // Don't forget to register your random source g_eventRec.registerRandomSource(_rnd, "draci"); } @@ -112,12 +112,12 @@ int DraciEngine::init() { if (!_objectsArchive->isOpen()) { debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening objects archive failed"); return Common::kUnknownError; - } + } if (!_spritesArchive->isOpen()) { debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening sprites archive failed"); return Common::kUnknownError; - } + } if (!_paletteArchive->isOpen()) { debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening palette archive failed"); @@ -157,14 +157,14 @@ int DraciEngine::init() { BArchive ar(path); const BAFile *f; debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size()); - + if (ar.isOpen()) { f = ar.getFile(0); } else { debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened"); return Common::kUnknownError; - } - + } + debugC(3, kDraciGeneralDebugLevel, "First 10 bytes of file %d: ", 0); for (uint i = 0; i < 10; ++i) { debugC(3, kDraciGeneralDebugLevel, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n'); @@ -175,7 +175,7 @@ int DraciEngine::init() { int DraciEngine::go() { debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()"); - + _game->init(); _game->start(); @@ -202,7 +202,7 @@ bool DraciEngine::handleEvents() { int escRoom = _game->getEscRoom(); // Check if there is an escape room defined for the current room - if (escRoom != kNoEscRoom) { + if (escRoom != kNoEscRoom) { // Schedule room change _game->setRoomNum(_game->getEscRoom()); @@ -220,7 +220,7 @@ bool DraciEngine::handleEvents() { _game->setRoomNum(_game->getMapRoom()); _game->setGateNum(0); } - } else if (event.kbd.keycode == Common::KEYCODE_w) { + } else if (event.kbd.keycode == Common::KEYCODE_w) { // Show walking map toggle _showWalkingMap = !_showWalkingMap; } else if (event.kbd.keycode == Common::KEYCODE_i) { @@ -230,12 +230,12 @@ bool DraciEngine::handleEvents() { } else if (_game->getLoopStatus() == kStatusOrdinary && _game->getLoopSubstatus() == kSubstatusOrdinary) { _game->inventoryInit(); - } + } } - break; + break; default: _mouse->handleEvent(event); - } + } } // Show walking map overlay @@ -251,7 +251,7 @@ bool DraciEngine::handleEvents() { } DraciEngine::~DraciEngine() { // Dispose your resources here - + // TODO: Investigate possibility of using sharedPtr or similar delete _smallFont; @@ -275,7 +275,7 @@ DraciEngine::~DraciEngine() { delete _itemsArchive; delete _itemImagesArchive; delete _stringsArchive; - + // Remove all of our debug levels here Common::clearAllDebugChannels(); } diff --git a/engines/draci/draci.h b/engines/draci/draci.h index 264f4496c4..9ef229c686 100644 --- a/engines/draci/draci.h +++ b/engines/draci/draci.h @@ -25,7 +25,7 @@ #ifndef DRACI_H #define DRACI_H - + #include "common/system.h" #include "engines/engine.h" #include "engines/advancedDetector.h" @@ -50,7 +50,7 @@ public: Common::Error run(); bool hasFeature(Engine::EngineFeature f) const; - + bool handleEvents(); Screen *_screen; diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp index 3d8fa545b6..7c4bd7bbaa 100644 --- a/engines/draci/font.cpp +++ b/engines/draci/font.cpp @@ -31,9 +31,9 @@ namespace Draci { const char * const kFontSmall = "Small.fon"; -const char * const kFontBig = "Big.fon"; +const char * const kFontBig = "Big.fon"; -Font::Font(const Common::String &filename) { +Font::Font(const Common::String &filename) { _fontHeight = 0; _maxCharWidth = 0; _charWidths = NULL; @@ -43,7 +43,7 @@ Font::Font(const Common::String &filename) { } Font::~Font() { - freeFont(); + freeFont(); } /** @@ -53,7 +53,7 @@ Font::~Font() { * * Loads fonts from a file into a Font instance. The original game uses two * fonts (located inside files "Small.fon" and "Big.fon"). The characters in the - * font are indexed from the space character so an appropriate offset must be + * font are indexed from the space character so an appropriate offset must be * added to convert them to equivalent char values, i.e. kDraciIndexOffset. * Characters in the higher range are non-ASCII and vary between different * language versions of the game. @@ -61,7 +61,7 @@ Font::~Font() { * font format: [1 byte] maximum character width * [1 byte] font height * [138 bytes] character widths of all 138 characters in the font - * [138 * fontHeight * maxWidth bytes] character data, stored row-wise + * [138 * fontHeight * maxWidth bytes] character data, stored row-wise */ bool Font::loadFont(const Common::String &filename) { @@ -72,10 +72,10 @@ bool Font::loadFont(const Common::String &filename) { f.open(filename); if (f.isOpen()) { - debugC(6, kDraciGeneralDebugLevel, "Opened font file %s", + debugC(6, kDraciGeneralDebugLevel, "Opened font file %s", filename.c_str()); } else { - debugC(6, kDraciGeneralDebugLevel, "Error opening font file %s", + debugC(6, kDraciGeneralDebugLevel, "Error opening font file %s", filename.c_str()); return false; } @@ -96,7 +96,7 @@ bool Font::loadFont(const Common::String &filename) { _charData = new byte[fontDataSize]; f.read(_charData, fontDataSize); - debugC(5, kDraciGeneralDebugLevel, "Font %s loaded", filename.c_str()); + debugC(5, kDraciGeneralDebugLevel, "Font %s loaded", filename.c_str()); return true; } @@ -185,9 +185,9 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) co * @param len Length of the data * @param x Horizontal offset on the surface * @param y Vertical offset on the surface - * @param spacing Space to leave between individual characters. Defaults to 0. + * @param spacing Space to leave between individual characters. Defaults to 0. */ -void Font::drawString(Surface *dst, const byte *str, uint len, +void Font::drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_colour, int spacing, bool markDirty) const { drawString(dst, Common::String((const char *)str, len), x, y, with_colour, spacing, markDirty); } @@ -199,10 +199,10 @@ void Font::drawString(Surface *dst, const byte *str, uint len, * @param str String to draw * @param x Horizontal offset on the surface * @param y Vertical offset on the surface - * @param spacing Space to leave between individual characters. Defaults to 0. + * @param spacing Space to leave between individual characters. Defaults to 0. */ -void Font::drawString(Surface *dst, const Common::String &str, +void Font::drawString(Surface *dst, const Common::String &str, int x, int y, int with_colour, int spacing, bool markDirty) const { assert(dst != NULL); assert(x >= 0); @@ -212,7 +212,7 @@ void Font::drawString(Surface *dst, const Common::String &str, int curx = x + (widest - getLineWidth(str, 0, spacing)) / 2; int cury = y; - + for (uint i = 0; i < str.size(); ++i) { // If we encounter the '|' char (newline and end of string marker), @@ -242,9 +242,9 @@ void Font::drawString(Surface *dst, const Common::String &str, * @brief Calculate the width of a string when drawn in the current font * * @param str String to draw - * @param spacing Space to leave between individual characters. Defaults to 0. + * @param spacing Space to leave between individual characters. Defaults to 0. * - * @return The calculated width of the string + * @return The calculated width of the string */ uint Font::getStringWidth(const Common::String &str, int spacing) const { uint width = 0; @@ -278,7 +278,7 @@ uint Font::getStringWidth(const Common::String &str, int spacing) const { uint Font::getLineWidth(const Common::String &str, uint startIndex, int spacing) const { uint width = 0; - // If the index is greater or equal to the string size, + // If the index is greater or equal to the string size, // the width of the line is 0 if (startIndex >= str.size()) return 0; @@ -303,9 +303,9 @@ uint Font::getLineWidth(const Common::String &str, uint startIndex, int spacing) * are used as newline characters and end-of-string markers) * * @param str String to draw - * @param spacing Space to leave between individual characters. Defaults to 0. + * @param spacing Space to leave between individual characters. Defaults to 0. * - * @return The calculated height of the string + * @return The calculated height of the string */ uint Font::getStringHeight(const Common::String &str) const { uint len = str.size(); diff --git a/engines/draci/font.h b/engines/draci/font.h index 55a3122bb9..4fb4ae58cb 100644 --- a/engines/draci/font.h +++ b/engines/draci/font.h @@ -33,17 +33,17 @@ namespace Draci { extern const char * const kFontSmall; extern const char * const kFontBig; -/** +/** * Default font colours. They all seem to remain constant except for the * first one which varies depending on the character speaking. * kOverFontColour is set to transparent. * TODO: Find out what kFontColour1 should actually be when the game starts */ -enum { +enum { kFontColour1 = 2, kFontColour2 = 0, kFontColour3 = 3, - kFontColour4 = 4, + kFontColour4 = 4, kOverFontColour = 255, kTitleColour = 255, kLineActiveColour = 254, @@ -54,8 +54,8 @@ enum { * Represents the game's fonts. See docs for setFont() for font format details. */ class Font { - -public: + +public: Font(const Common::String &filename); ~Font(); @@ -65,9 +65,9 @@ public: uint8 getCharWidth(byte chr) const; void drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const; - void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_colour, + void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_colour, int spacing, bool markDirty = true) const; - void drawString(Surface *dst, const Common::String &str, + void drawString(Surface *dst, const Common::String &str, int x, int y, int with_colour, int spacing, bool markDirty = true) const; uint getStringWidth(const Common::String &str, int spacing = 0) const; @@ -83,11 +83,11 @@ private: /** Pointer to a raw byte array representing font pixels stored row-wise */ byte *_charData; - + /** Number of glyphs in the font */ static const uint kCharNum = 138; - /** + /** * Chars are indexed from the space character so this should be subtracted * to get the index of a glyph */ diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 4563030b9e..b148852892 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -63,7 +63,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { Common::MemoryReadStream dialogueData(file->_data, file->_length); uint numDialogues = file->_length / sizeof(uint16); - _dialogueOffsets = new uint[numDialogues]; + _dialogueOffsets = new uint[numDialogues]; uint curOffset; for (i = 0, curOffset = 0; i < numDialogues; ++i) { @@ -101,7 +101,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { _variables = new int[numVariables]; Common::MemoryReadStream variableData(file->_data, file->_length); - + for (i = 0; i < numVariables; ++i) { _variables[i] = variableData.readUint16LE(); } @@ -118,7 +118,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { uint numObjects = file->_length; _objects = new GameObject[numObjects]; - Common::MemoryReadStream objStatus(file->_data, file->_length); + Common::MemoryReadStream objStatus(file->_data, file->_length); for (i = 0; i < numObjects; ++i) { byte tmp = objStatus.readByte(); @@ -150,7 +150,7 @@ void Game::start() { if (_newRoom != _currentRoom._roomNum) { // Set the first two variables to the new room / gate - // Before setting these variables we have to convert the values to + // Before setting these variables we have to convert the values to // 1-based indexing because this is how everything is stored in the data files _variables[0] = _newGate + 1; _variables[1] = _newRoom + 1; @@ -163,10 +163,10 @@ void Game::start() { } setLoopSubstatus(kSubstatusOrdinary); - + // Do the actual change changeRoom(_newRoom); - + // Set the current room / gate to the new value _currentRoom._roomNum = _newRoom; _currentGate = _newGate; @@ -235,7 +235,7 @@ void Game::init() { _dialogueAnims[i]->addFrame(dialogueLine); _dialogueAnims[i]->setZ(254); - _dialogueAnims[i]->setRelative(1, + _dialogueAnims[i]->setRelative(1, kScreenHeight - (i + 1) * _vm->_smallFont->getFontHeight()); Text *text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame()); @@ -271,7 +271,7 @@ void Game::loop() { Surface *surface = _vm->_screen->getSurface(); do { - debugC(4, kDraciLogicDebugLevel, "loopstatus: %d, loopsubstatus: %d", + debugC(4, kDraciLogicDebugLevel, "loopstatus: %d, loopsubstatus: %d", _loopStatus, _loopSubstatus); _vm->handleEvents(); @@ -284,7 +284,7 @@ void Game::loop() { Text *text; for (int i = 0; i < kDialogueLines; ++i) { text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame()); - + if (_animUnderCursor == _dialogueAnims[i]->getID()) { text->setColour(kLineActiveColour); } else { @@ -310,7 +310,7 @@ void Game::loop() { if (_loopStatus == kStatusOrdinary && _loopSubstatus == kSubstatusOrdinary) { if (_vm->_mouse->lButtonPressed()) { _vm->_mouse->lButtonSet(false); - + if (_currentItem != kNoItem) { putItem(_currentItem, 0); _currentItem = kNoItem; @@ -318,7 +318,7 @@ void Game::loop() { } else { if (_objUnderCursor != kObjectNotFound) { GameObject *obj = &_objects[_objUnderCursor]; - + _vm->_mouse->cursorOff(); titleAnim->markDirtyRect(surface); title->setText(""); @@ -388,11 +388,11 @@ void Game::loop() { // If we are in inventory mode, all the animations except game items' // images will necessarily be paused so we can safely assume that any - // animation under the cursor (a value returned by + // animation under the cursor (a value returned by // AnimationManager::getTopAnimationID()) will be an item animation or - // an overlay, for which we check. Item animations have their IDs - // calculated by offseting their itemID from the ID of the last "special" - // animation ID. In this way, we obtain its itemID. + // an overlay, for which we check. Item animations have their IDs + // calculated by offseting their itemID from the ID of the last "special" + // animation ID. In this way, we obtain its itemID. if (_animUnderCursor != kOverlayImage && _animUnderCursor != kInventorySprite) { _itemUnderCursor = kInventoryItemsID - _animUnderCursor; } else { @@ -456,21 +456,21 @@ void Game::loop() { } } - debugC(5, kDraciLogicDebugLevel, "Anim under cursor: %d", _animUnderCursor); + debugC(5, kDraciLogicDebugLevel, "Anim under cursor: %d", _animUnderCursor); // Handle character talking (if there is any) if (_loopSubstatus == kSubstatusTalk) { Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText); Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame()); - uint speechDuration = kBaseSpeechDuration + - speechFrame->getLength() * kSpeechTimeUnit / + uint speechDuration = kBaseSpeechDuration + + speechFrame->getLength() * kSpeechTimeUnit / (128 / 16 + 1); - // If the current speech text has expired or the user clicked a mouse button, + // If the current speech text has expired or the user clicked a mouse button, // advance to the next line of text - if (_vm->_mouse->lButtonPressed() || - _vm->_mouse->rButtonPressed() || + if (_vm->_mouse->lButtonPressed() || + _vm->_mouse->rButtonPressed() || (_vm->_system->getMillis() - _speechTick) >= speechDuration) { _shouldExitLoop = true; @@ -489,7 +489,7 @@ void Game::loop() { _vm->_system->delayMillis(20); // HACK: Won't be needed once the game loop is implemented properly - _shouldExitLoop = _shouldExitLoop || (_newRoom != _currentRoom._roomNum && + _shouldExitLoop = _shouldExitLoop || (_newRoom != _currentRoom._roomNum && (_loopStatus == kStatusOrdinary || _loopStatus == kStatusGate)); } while (!shouldExitLoop()); @@ -606,14 +606,14 @@ void Game::updateTitle() { Text *title = reinterpret_cast<Text *>(titleAnim->getFrame()); // Mark dirty rectangle to delete the previous text - titleAnim->markDirtyRect(surface); - + titleAnim->markDirtyRect(surface); + // If there is no object under the cursor, delete the title. // Otherwise, show the object's title. if (_objUnderCursor == kObjectNotFound) { title->setText(""); } else { - GameObject *obj = &_objects[_objUnderCursor]; + GameObject *obj = &_objects[_objUnderCursor]; title->setText(obj->_title); } @@ -661,7 +661,7 @@ void Game::putItem(int itemID, int position) { uint i = position; - if (position >= 0 && + if (position >= 0 && position < kInventoryLines * kInventoryColumns && _inventory[position] == kNoItem) { _inventory[position] = itemID; @@ -680,16 +680,16 @@ void Game::putItem(int itemID, int position) { Animation *anim = _vm->_anims->getAnimation(kInventoryItemsID - itemID); Drawable *frame = anim->getFrame(); - const int x = kInventoryX + + const int x = kInventoryX + (column * kInventoryItemWidth) - (kInventoryItemWidth / 2) - (frame->getWidth() / 2); - const int y = kInventoryY + - (line * kInventoryItemHeight) - + const int y = kInventoryY + + (line * kInventoryItemHeight) - (kInventoryItemHeight / 2) - (frame->getHeight() / 2); - + debug(2, "itemID: %d position: %d line: %d column: %d x: %d y: %d", itemID, position, line, column, x, y); anim->setRelative(x, y); @@ -711,7 +711,7 @@ void Game::inventoryInit() { // Turn cursor on if it is off _vm->_mouse->cursorOn(); - + // Set the appropriate loop status _loopStatus = kStatusInventory; @@ -758,19 +758,19 @@ void Game::dialogueMenu(int dialogueID) { Common::String ext(tmp); _dialogueArchive = new BArchive(dialoguePath + ext + ".dfw"); - debugC(4, kDraciLogicDebugLevel, "Starting dialogue (ID: %d, Archive: %s)", + debugC(4, kDraciLogicDebugLevel, "Starting dialogue (ID: %d, Archive: %s)", dialogueID, (dialoguePath + ext + ".dfw").c_str()); _currentDialogue = dialogueID; oldLines = 255; dialogueInit(dialogueID); - + do { _dialogueExit = false; hit = dialogueDraw(); - debugC(7, kDraciLogicDebugLevel, - "hit: %d, _lines[hit]: %d, lastblock: %d, dialogueLines: %d, dialogueExit: %d", + debugC(7, kDraciLogicDebugLevel, + "hit: %d, _lines[hit]: %d, lastblock: %d, dialogueLines: %d, dialogueExit: %d", hit, _lines[hit], _lastBlock, _dialogueLinesNum, _dialogueExit); if ((!_dialogueExit) && (hit != -1) && (_lines[hit] != -1)) { @@ -797,7 +797,7 @@ int Game::dialogueDraw() { _dialogueLinesNum = 0; int i = 0; int ret = 0; - + Animation *anim; Text *dialogueLine; @@ -882,7 +882,7 @@ void Game::dialogueInit(int dialogID) { assert(f->_length - 1 == f->_data[0]); _dialogueBlocks[i]._title = Common::String((char *)(f->_data+1), f->_length-1); - + f = _dialogueArchive->getFile(i * 3 + 2); _dialogueBlocks[i]._program._bytecode = f->_data; _dialogueBlocks[i]._program._length = f->_length; @@ -916,7 +916,7 @@ void Game::runDialogueProg(GPL2Program prog, int offset) { // Run the dialogue program _vm->_script->run(prog, offset); - + deleteAnimationsAfterIndex(lastAnimIndex); } @@ -972,10 +972,10 @@ void Game::walkHero(int x, int y) { return; Surface *surface = _vm->_screen->getSurface(); - + _hero = _currentRoom._walkingMap.findNearestWalkable(x, y, surface->getRect()); - GameObject *dragon = getObject(kDragonObject); + GameObject *dragon = getObject(kDragonObject); for (uint i = 0; i < dragon->_anims.size(); ++i) { _vm->_anims->stop(dragon->_anims[i]); @@ -997,7 +997,7 @@ void Game::walkHero(int x, int y) { void Game::loadItem(int itemID) { const BAFile *f = _vm->_itemsArchive->getFile(itemID * 3); Common::MemoryReadStream itemReader(f->_data, f->_length); - + GameItem *item = _items + itemID; item->_init = itemReader.readSint16LE(); @@ -1092,7 +1092,7 @@ void Game::loadRoom(int roomNum) { // Load the room's objects for (uint i = 0; i < _info._numObjects; ++i) { - debugC(7, kDraciLogicDebugLevel, + debugC(7, kDraciLogicDebugLevel, "Checking if object %d (%d) is at the current location (%d)", i, _objects[i]._location, roomNum); @@ -1108,7 +1108,7 @@ void Game::loadRoom(int roomNum) { for (uint i = 0; i < _info._numObjects; ++i) { if (_objects[i]._location == roomNum) { const GameObject *obj = getObject(i); - debugC(6, kDraciLogicDebugLevel, + debugC(6, kDraciLogicDebugLevel, "Running init program for object %d (offset %d)", i, obj->_init); _vm->_script->run(obj->_program, obj->_init); } @@ -1146,7 +1146,7 @@ void Game::loadRoom(int roomNum) { int Game::loadAnimation(uint animNum, uint z) { const BAFile *animFile = _vm->_animationsArchive->getFile(animNum); - Common::MemoryReadStream animationReader(animFile->_data, animFile->_length); + Common::MemoryReadStream animationReader(animFile->_data, animFile->_length); uint numFrames = animationReader.readByte(); @@ -1190,7 +1190,7 @@ int Game::loadAnimation(uint animNum, uint z) { sp->setScaled(scaledWidth, scaledHeight); - if (mirror) + if (mirror) sp->setMirrorOn(); sp->setDelay(delay * 10); @@ -1206,7 +1206,7 @@ void Game::loadObject(uint objNum) { file = _vm->_objectsArchive->getFile(objNum * 3); Common::MemoryReadStream objReader(file->_data, file->_length); - + GameObject *obj = _objects + objNum; obj->_init = objReader.readUint16LE(); @@ -1230,7 +1230,7 @@ void Game::loadObject(uint objNum) { obj->_absNum = objNum; file = _vm->_objectsArchive->getFile(objNum * 3 + 1); - + // The first byte of the file is the length of the string (without the length) assert(file->_length - 1 == file->_data[0]); @@ -1257,22 +1257,22 @@ uint Game::getNumObjects() const { void Game::loadOverlays() { uint x, y, z, num; - + const BAFile *overlayHeader; overlayHeader = _vm->_roomsArchive->getFile(_currentRoom._roomNum * 4 + 2); Common::MemoryReadStream overlayReader(overlayHeader->_data, overlayHeader->_length); - + for (int i = 0; i < _currentRoom._numOverlays; i++) { num = overlayReader.readUint16LE() - 1; x = overlayReader.readUint16LE(); y = overlayReader.readUint16LE(); z = overlayReader.readByte(); - + const BAFile *overlayFile; overlayFile = _vm->_overlaysArchive->getFile(num); Sprite *sp = new Sprite(overlayFile->_data, overlayFile->_length, x, y, true); - + _vm->_anims->addOverlay(sp, z); } @@ -1294,7 +1294,7 @@ void Game::changeRoom(uint roomNum) { _vm->_screen->clearScreen(); _vm->_anims->deleteOverlays(); - + // Delete walking map testing overlay _vm->_anims->deleteAnimation(kWalkingMapOverlay); @@ -1308,7 +1308,7 @@ void Game::changeRoom(uint roomNum) { for (uint i = 0; i < _info._numObjects; ++i) { GameObject *obj = &_objects[i]; - + if (i != 0 && (obj->_location == oldRoomNum)) { for (uint j = 0; j < obj->_anims.size(); ++j) { _vm->_anims->deleteAnimation(obj->_anims[j]); @@ -1333,7 +1333,7 @@ void Game::runGateProgram(int gate) { // Run gate program _vm->_script->run(_currentRoom._program, _currentRoom._gates[gate]); - + deleteAnimationsAfterIndex(lastAnimIndex); setExitLoop(false); @@ -1469,7 +1469,7 @@ int Game::getScheduledPalette() const { } /** - * The GPL command Mark sets the animation index (which specifies the order in which + * The GPL command Mark sets the animation index (which specifies the order in which * animations were loaded in) which is then used by the Release command to delete * all animations that have an index greater than the one marked. */ @@ -1478,7 +1478,7 @@ int Game::getMarkedAnimationIndex() const { } void Game::deleteAnimationsAfterIndex(int lastAnimIndex) { - // Delete all animations loaded after the marked one + // Delete all animations loaded after the marked one // (from objects and from the AnimationManager) for (uint i = 0; i < getNumObjects(); ++i) { GameObject *obj = &_objects[i]; @@ -1526,7 +1526,7 @@ bool WalkingMap::isWalkable(int x, int y) const { return mapByte & (1 << pixelIndex % 8); } -/** +/** * @brief For a given point, find a nearest walkable point on the walking map * * @param startX x coordinate of the point @@ -1574,15 +1574,15 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re prediction = 1 - radius; dx = 3; dy = 2 * radius - 2; - + do { // The following two loops serve the purpose of checking the points on the two // ellipses for walkability. The signs[] array is there to obliterate the need // of writing out all combinations manually. - + for (uint i = 0; i < kSignsNum; ++i) { finalY = startY + y * signs[i]; - + for (uint j = 0; j < kSignsNum; ++j) { finalX = startX + x * signs[j]; @@ -1626,16 +1626,16 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re dx += 2 * _deltaX; x += _deltaX; - // If the current ellipse has been reshaped into a circle, + // If the current ellipse has been reshaped into a circle, // end this loop and enlarge the radius - } while (x <= y); + } while (x <= y); } } static double real_to_double(byte real[6]) { // Extract sign bit int sign = real[0] & (1 << 7); - + // Extract exponent and adjust for bias int exp = real[5] - 129; @@ -1669,4 +1669,4 @@ static double real_to_double(byte real[6]) { return ldexp(mantissa, exp); } -} +} diff --git a/engines/draci/game.h b/engines/draci/game.h index 19bd27e6ff..9e5fabd03d 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -51,7 +51,7 @@ enum { kObjectNotFound = -1 }; -// Used as the value of the _escRoom field of the current room if there is +// Used as the value of the _escRoom field of the current room if there is // no escape room defined enum { kNoEscRoom = -1 @@ -196,15 +196,15 @@ struct Room { }; enum LoopStatus { - kStatusOrdinary, - kStatusGate, - kStatusInventory, + kStatusOrdinary, + kStatusGate, + kStatusInventory, kStatusDialogue }; enum LoopSubstatus { - kSubstatusOrdinary, - kSubstatusTalk, + kSubstatusOrdinary, + kSubstatusTalk, kSubstatusFade, kSubstatusStrange }; @@ -233,7 +233,7 @@ public: void changeRoom(uint roomNum); // HACK: this is only for testing - int nextRoomNum() const { + int nextRoomNum() const { int n = _currentRoom._roomNum; n = n < 37 ? n+1 : n; @@ -245,7 +245,7 @@ public: } // HACK: same as above - int prevRoomNum() const { + int prevRoomNum() const { int n = _currentRoom._roomNum; n = n > 0 ? n-1 : n; @@ -273,7 +273,7 @@ public: int getObjectWithAnimation(int animID) const; int getVariable(int varNum) const; - void setVariable(int varNum, int value); + void setVariable(int varNum, int value); const Person *getPerson(int personID) const; @@ -365,7 +365,7 @@ private: bool _inventoryExit; Room _currentRoom; - int _currentGate; + int _currentGate; int _newRoom; int _newGate; @@ -382,7 +382,7 @@ private: int _blockNum; int _lines[kDialogueLines]; Animation *_dialogueAnims[kDialogueLines]; - + LoopStatus _loopStatus; LoopSubstatus _loopSubstatus; diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp index 4f03ba7f82..3629d40d0d 100644 --- a/engines/draci/mouse.cpp +++ b/engines/draci/mouse.cpp @@ -95,7 +95,7 @@ void Mouse::setCursorType(CursorType cur) { Sprite sp(f->_data, f->_length, 0, 0, true); CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours); - CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(), + CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(), sp.getWidth() / 2, sp.getHeight() / 2); } @@ -105,7 +105,7 @@ void Mouse::loadItemCursor(int itemID, bool highlighted) { Sprite sp(f->_data, f->_length, 0, 0, true); CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours); - CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(), + CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(), sp.getWidth() / 2, sp.getHeight() / 2); } diff --git a/engines/draci/mouse.h b/engines/draci/mouse.h index ad6476ebfa..629a7634d5 100644 --- a/engines/draci/mouse.h +++ b/engines/draci/mouse.h @@ -31,11 +31,11 @@ namespace Draci { -enum CursorType { +enum CursorType { kNormalCursor, - kArrowCursor1, + kArrowCursor1, kArrowCursor2, - kArrowCursor3, + kArrowCursor3, kArrowCursor4, kDialogueCursor, kHighlightedCursor, diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp index 852ab6e8d0..7c67b125c0 100644 --- a/engines/draci/screen.cpp +++ b/engines/draci/screen.cpp @@ -58,7 +58,7 @@ void Screen::setPaletteEmpty(uint numEntries) { * @brief Sets a part of the palette * @param data Pointer to a buffer containing new palette data * start Index of the colour where replacement should start - * num Number of colours to replace + * num Number of colours to replace */ void Screen::setPalette(const byte *data, uint16 start, uint16 num) { Common::MemoryReadStream pal(data, 3 * kNumColours); @@ -92,21 +92,21 @@ void Screen::copyToScreen() { if (_surface->needsFullUpdate()) { byte *ptr = (byte *)_surface->getBasePtr(0, 0); - _vm->_system->copyRectToScreen(ptr, kScreenWidth, + _vm->_system->copyRectToScreen(ptr, kScreenWidth, 0, 0, kScreenWidth, kScreenHeight); } else { // Otherwise, update only the dirty rectangles for (it = dirtyRects->begin(); it != dirtyRects->end(); ++it) { - + // Pointer to the upper left corner of the rectangle byte *ptr = (byte *)_surface->getBasePtr(it->left, it->top); - _vm->_system->copyRectToScreen(ptr, kScreenWidth, + _vm->_system->copyRectToScreen(ptr, kScreenWidth, it->left, it->top, it->width(), it->height()); } } - + // Call the "real" updateScreen and mark the surface clean _vm->_system->updateScreen(); _surface->markClean(); diff --git a/engines/draci/screen.h b/engines/draci/screen.h index 16981eb476..bb3ada693c 100644 --- a/engines/draci/screen.h +++ b/engines/draci/screen.h @@ -52,7 +52,7 @@ public: void copyToScreen(); void clearScreen(); void fillScreen(uint8 colour); - Surface *getSurface(); + Surface *getSurface(); void drawRect(Common::Rect r, uint8 colour); private: diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index e6d1576f17..7cf5ef50a1 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -253,7 +253,7 @@ int Script::funcIsIcoOn(int itemID) const { itemID -= 1; return _vm->_game->getItemStatus(itemID) == 1; -} +} int Script::funcIcoStat(int itemID) const { itemID -= 1; @@ -351,9 +351,9 @@ void Script::play(Common::Queue<int> ¶ms) { } _vm->_game->setLoopSubstatus(kSubstatusStrange); - _vm->_game->setExitLoop(true); + _vm->_game->setExitLoop(true); _vm->_game->loop(); - _vm->_game->setExitLoop(false); + _vm->_game->setExitLoop(false); _vm->_game->setLoopSubstatus(kSubstatusOrdinary); } @@ -364,21 +364,21 @@ void Script::load(Common::Queue<int> ¶ms) { int objID = params.pop() - 1; int animID = params.pop() - 1; - + uint i; GameObject *obj = _vm->_game->getObject(objID); // If the animation is already loaded, return for(i = 0; i < obj->_anims.size(); ++i) { if (obj->_anims[i] == animID) { - return; + return; } } // Load the animation into memory _vm->_game->loadAnimation(animID, obj->_z); - + // We insert the ID of the loaded animation into the object's internal array // of owned animation IDs. // Care must be taken to store them sorted (increasing order) as some things @@ -455,7 +455,7 @@ void Script::startPlay(Common::Queue<int> ¶ms) { } _vm->_game->loop(); - _vm->_game->setExitLoop(false); + _vm->_game->setExitLoop(false); _vm->_anims->stop(animID); _vm->_game->setLoopSubstatus(kSubstatusOrdinary); @@ -576,10 +576,10 @@ void Script::objStat(Common::Queue<int> ¶ms) { obj->_visible = false; obj->_location = -1; } - + for (uint i = 0; i < obj->_anims.size(); ++i) { _vm->_anims->stop(obj->_anims[i]); - } + } } void Script::execInit(Common::Queue<int> ¶ms) { @@ -638,7 +638,7 @@ void Script::walkOnPlay(Common::Queue<int> ¶ms) { // HACK: This should be an onDest action when hero walking is properly implemented _vm->_game->setExitLoop(true); - + _vm->_game->walkHero(x, y); _vm->_game->setLoopSubstatus(kSubstatusStrange); @@ -735,7 +735,7 @@ void Script::loadMap(Common::Queue<int> ¶ms) { void Script::resetDialogue(Common::Queue<int> ¶ms) { const int currentOffset = _vm->_game->getCurrentDialogueOffset(); - + for (int i = 0; i < _vm->_game->getDialogueBlockNum(); ++i) { _vm->_game->setDialogueVar(currentOffset + i, 0); } @@ -893,12 +893,12 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const { } /** - * @brief Evaluates a GPL mathematical expression on a given offset and returns + * @brief Evaluates a GPL mathematical expression on a given offset and returns * the result (which is normally a boolean-like value) - * + * * @param program A GPL2Program instance of the program containing the expression * @param offset Offset of the expression inside the program (in multiples of 2 bytes) - * + * * @return The result of the expression converted to a bool. * * Reference: the function equivalent to this one is called "Can()" in the original engine. @@ -908,14 +908,14 @@ bool Script::testExpression(const GPL2Program &program, uint16 offset) const { Common::MemoryReadStream reader(program._bytecode, program._length); // Offset is given as number of 16-bit integers so we need to convert - // it to a number of bytes + // it to a number of bytes offset -= 1; offset *= 2; // Seek to the expression reader.seek(offset); - debugC(4, kDraciBytecodeDebugLevel, + debugC(4, kDraciBytecodeDebugLevel, "Evaluating (standalone) GPL expression at offset %d:", offset); return (bool)handleMathExpression(&reader); @@ -991,19 +991,19 @@ int Script::run(const GPL2Program &program, uint16 offset) { // Stream reader for the whole program Common::MemoryReadStream reader(program._bytecode, program._length); - + // Parameter queue that is passed to each command Common::Queue<int> params; // Offset is given as number of 16-bit integers so we need to convert - // it to a number of bytes + // it to a number of bytes offset -= 1; offset *= 2; // Seek to the requested part of the program reader.seek(offset); - debugC(3, kDraciBytecodeDebugLevel, + debugC(3, kDraciBytecodeDebugLevel, "Starting GPL program at offset %d (program length: %d)", offset, program._length); const GPL2Command *cmd; @@ -1011,8 +1011,8 @@ int Script::run(const GPL2Program &program, uint16 offset) { // Account for GPL jump that some commands set if (_jump != 0) { - debugC(3, kDraciBytecodeDebugLevel, - "Jumping from offset %d to %d (%d bytes)", + debugC(3, kDraciBytecodeDebugLevel, + "Jumping from offset %d to %d (%d bytes)", reader.pos(), reader.pos() + _jump, _jump); reader.seek(_jump, SEEK_CUR); } @@ -1045,7 +1045,7 @@ int Script::run(const GPL2Program &program, uint16 offset) { for (int i = 0; i < cmd->_numParams; ++i) { if (cmd->_paramTypes[i] == 4) { - debugC(3, kDraciBytecodeDebugLevel, + debugC(3, kDraciBytecodeDebugLevel, "Evaluating (in-script) GPL expression at offset %d: ", offset); params.push(handleMathExpression(&reader)); } else { diff --git a/engines/draci/script.h b/engines/draci/script.h index fc0dc0cd74..aa4b297d28 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -33,7 +33,7 @@ namespace Draci { /** The maximum number of parameters for a GPL command */ -const int kMaxParams = 3; +const int kMaxParams = 3; class DraciEngine; class Script; @@ -49,14 +49,14 @@ typedef int (Script::*GPLFunctionHandler)(int) const; /** * Represents a single command in the GPL scripting language bytecode. - * Each command is represented in the bytecode by a command number and a + * Each command is represented in the bytecode by a command number and a * subnumber. */ -struct GPL2Command { - byte _number; - byte _subNumber; - const char *_name; +struct GPL2Command { + byte _number; + byte _subNumber; + const char *_name; uint16 _numParams; int _paramTypes[kMaxParams]; GPLHandler _handler; @@ -72,7 +72,7 @@ struct GPL2Function { GPLFunctionHandler _handler; }; -/** +/** * A convenience data type that holds both the actual bytecode and the * length of the bytecode. Passed to Script::run(). */ @@ -100,7 +100,7 @@ private: const GPL2Command *_commandList; const GPL2Operator *_operatorList; const GPL2Function *_functionList; - + void c_If(Common::Queue<int> ¶ms); void c_Goto(Common::Queue<int> ¶ms); void c_Let(Common::Queue<int> ¶ms); diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp index dca006ac65..19bb4ea86b 100644 --- a/engines/draci/sprite.cpp +++ b/engines/draci/sprite.cpp @@ -58,7 +58,7 @@ static void transformToRows(byte *img, uint16 width, uint16 height) { /** * Constructor for loading sprites from a raw data buffer, one byte per pixel. */ -Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, +Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, bool columnwise) : _data(NULL) { _width = width; @@ -75,7 +75,7 @@ Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, _mirror = false; byte *data = new byte[width * height]; - + memcpy(data, raw_data, width * height); // If the sprite is stored column-wise, transform it to row-wise @@ -86,10 +86,10 @@ Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, } /** - * Constructor for loading sprites from a sprite-formatted buffer, one byte per + * Constructor for loading sprites from a sprite-formatted buffer, one byte per * pixel. */ -Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise) +Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise) : _data(NULL) { _x = x; @@ -118,7 +118,7 @@ Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool column _data = data; } -Sprite::~Sprite() { +Sprite::~Sprite() { delete[] _data; } @@ -135,7 +135,7 @@ int Sprite::getPixel(int x, int y, const Displacement &displacement) const { int dy = y - rect.top; int dx = x - rect.left; - + // Calculate scaling factors double scaleX = double(rect.width()) / _width; double scaleY = double(rect.height()) / _height; @@ -188,7 +188,7 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement & const byte *row_data = _data + row * _width; for (int j = 0; j < columns; ++j) { - + // Fetch index of current column to be drawn const byte src = row_data[columnIndices[j]]; @@ -217,7 +217,7 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement & * Draws the sprite to a Draci::Surface and marks its rectangle on the surface as dirty. * It is safe to call it for sprites that would overflow the surface. */ -void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const { +void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const { // TODO: refactor like drawReScaled() Common::Rect sourceRect(0, 0, _width, _height); @@ -248,7 +248,7 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const { // Blit the sprite to the surface for (int i = sourceRect.top; i < sourceRect.bottom; ++i) { for (int j = sourceRect.left; j < sourceRect.right; ++j) { - + // Don't blit if the pixel is transparent on the target surface if (src[i * _width + j] != transparent) { @@ -270,7 +270,7 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const { surface->markDirtyRect(destRect); } } - + Common::Rect Sprite::getRect(const Displacement &displacement) const { return Common::Rect(_x + displacement.relX, _y + displacement.relY, @@ -278,7 +278,7 @@ Common::Rect Sprite::getRect(const Displacement &displacement) const { _y + displacement.relY + (int) (_scaledHeight * displacement.extraScaleY)); } -Text::Text(const Common::String &str, const Font *font, byte fontColour, +Text::Text(const Common::String &str, const Font *font, byte fontColour, int x, int y, uint spacing) { _x = x; _y = y; @@ -295,7 +295,7 @@ Text::Text(const Common::String &str, const Font *font, byte fontColour, _spacing = spacing; _colour = fontColour; - + _font = font; _width = _font->getStringWidth(str, _spacing); @@ -303,7 +303,7 @@ Text::Text(const Common::String &str, const Font *font, byte fontColour, _scaledWidth = _width; _scaledHeight = _height; -} +} void Text::setText(const Common::String &str) { _width = _font->getStringWidth(str, _spacing); @@ -348,4 +348,4 @@ void Text::setFont(const Font *font) { } } // End of namespace Draci - + diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h index bc6e44095b..a5859f989c 100644 --- a/engines/draci/sprite.h +++ b/engines/draci/sprite.h @@ -48,14 +48,14 @@ public: virtual void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const = 0; virtual ~Drawable() {}; - + uint getWidth() const { return _width; } uint getHeight() const { return _height; } uint getScaledWidth() const { return _scaledWidth; } uint getScaledHeight() const { return _scaledHeight; } - void setScaled(uint width, uint height) { + void setScaled(uint width, uint height) { _scaledWidth = width; _scaledHeight = height; } @@ -67,12 +67,12 @@ public: void setY(int y) { _y = y; } void setDelay(int delay) { _delay = delay; } - int getDelay() const { return _delay; } + int getDelay() const { return _delay; } virtual Common::Rect getRect(const Displacement &displacement = kNoDisplacement) const = 0; virtual DrawableType getType() const = 0; - + protected: uint _width; //!< Width of the sprite uint _height; //!< Height of the sprite @@ -80,7 +80,7 @@ protected: uint _scaledHeight; //!< Scaled height of the sprite int _x, _y; //!< Sprite coordinates - /** The time a drawable should stay on the screen + /** The time a drawable should stay on the screen * before being replaced by another or deleted */ int _delay; @@ -90,9 +90,9 @@ protected: * Represents a Draci Historie sprite. Supplies two constructors; one for * loading a sprite from a raw data buffer and one for loading a sprite in * the Draci sprite format. Supports loading the sprite from a column-wise - * format (transforming them to row-wise) since that is the way the sprites + * format (transforming them to row-wise) since that is the way the sprites * are stored in the original game files. - * + * * Sprite format: * [uint16LE] sprite width * [uint16LE] sprite height @@ -102,13 +102,13 @@ protected: class Sprite : public Drawable { public: Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, bool columnwise); - Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise); + Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise); ~Sprite(); void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const; void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const; - + void setMirrorOn(); void setMirrorOff(); @@ -125,9 +125,9 @@ private: }; class Text : public Drawable { - + public: - Text(const Common::String &str, const Font *font, byte fontColour, + Text(const Common::String &str, const Font *font, byte fontColour, int x, int y, uint spacing = 0); ~Text() {}; @@ -140,7 +140,7 @@ public: void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const; - // TODO: drawReScaled just calls draw so Text can be accessed through a Drawable pointer. + // TODO: drawReScaled just calls draw so Text can be accessed through a Drawable pointer. // Handle scaling text sometimes (not essential). void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const { draw(surface, markDirty, displacement.relX, displacement.relY); } diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp index d56fcffdb6..069c501cab 100644 --- a/engines/draci/surface.cpp +++ b/engines/draci/surface.cpp @@ -50,7 +50,7 @@ void Surface::markDirtyRect(Common::Rect r) { if (r.isEmpty()) return; - it = _dirtyRects.begin(); + it = _dirtyRects.begin(); while (it != _dirtyRects.end()) { if (it->contains(r)) return; @@ -155,7 +155,7 @@ uint Surface::centerOnX(uint x, uint width) const { */ uint Surface::centerOnY(uint y, uint height) const { int newY = y - height / 2; - + if (newY + height >= (uint)h - 1) newY = (h - 1) - height; diff --git a/engines/draci/surface.h b/engines/draci/surface.h index bb38b864d3..e3371054e6 100644 --- a/engines/draci/surface.h +++ b/engines/draci/surface.h @@ -55,13 +55,13 @@ private: */ uint _transparentColour; - /** Set when the surface is scheduled for a full update. + /** Set when the surface is scheduled for a full update. * See markDirty(), markClean(). Accessed via needsFullUpdate(). */ - bool _fullUpdate; + bool _fullUpdate; Common::List<Common::Rect> _dirtyRects; //!< List of currently dirty rectangles - + }; } // End of namespace Draci |