aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorJohannes Schickel2009-09-30 10:45:14 +0000
committerJohannes Schickel2009-09-30 10:45:14 +0000
commitc9ca057ae2d8d3994aba86bb1ded05e0db008188 (patch)
tree55ec41d9c13bd108b41e28f9642ef24d78e6897b /engines/draci
parent4477f419034b7c606aef7eb7038337b7229cec33 (diff)
downloadscummvm-rg350-c9ca057ae2d8d3994aba86bb1ded05e0db008188.tar.gz
scummvm-rg350-c9ca057ae2d8d3994aba86bb1ded05e0db008188.tar.bz2
scummvm-rg350-c9ca057ae2d8d3994aba86bb1ded05e0db008188.zip
- Adapt parts of the Draci code to match our code formatting guidelines
- Remove use of tabs for formatting, now in nearly all cases tabs are only used for indentation - Use "uint" instead of "unsigned int" in the whole engine for consistency's sake - Strip some trailing tabs and leading whitespaces svn-id: r44478
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/animation.cpp38
-rw-r--r--engines/draci/animation.h29
-rw-r--r--engines/draci/barchive.cpp78
-rw-r--r--engines/draci/barchive.h27
-rw-r--r--engines/draci/detection.cpp5
-rw-r--r--engines/draci/draci.cpp47
-rw-r--r--engines/draci/draci.h10
-rw-r--r--engines/draci/font.cpp96
-rw-r--r--engines/draci/font.h40
-rw-r--r--engines/draci/game.cpp213
-rw-r--r--engines/draci/game.h19
-rw-r--r--engines/draci/mouse.cpp8
-rw-r--r--engines/draci/mouse.h12
-rw-r--r--engines/draci/screen.cpp25
-rw-r--r--engines/draci/screen.h2
-rw-r--r--engines/draci/script.cpp124
-rw-r--r--engines/draci/script.h20
-rw-r--r--engines/draci/sprite.cpp60
-rw-r--r--engines/draci/sprite.h33
-rw-r--r--engines/draci/surface.cpp8
-rw-r--r--engines/draci/surface.h8
21 files changed, 398 insertions, 504 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index 90dc7fdf9d..5af4110768 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -51,7 +51,6 @@ bool Animation::isLooping() const {
}
void Animation::setRelative(int relx, int rely) {
-
// Delete the previous frame if there is one
if (_frames.size() > 0)
markDirtyRect(_vm->_screen->getSurface());
@@ -76,7 +75,6 @@ void Animation::markDirtyRect(Surface *surface) const {
}
void Animation::nextFrame(bool force) {
-
// If there are no frames or if the animation is not playing, return
if (getFrameCount() == 0 || !_playing)
return;
@@ -109,7 +107,6 @@ void Animation::nextFrame(bool force) {
}
uint Animation::nextFrameNum() const {
-
if (_paused)
return _currentFrame;
@@ -120,14 +117,13 @@ uint Animation::nextFrameNum() const {
}
void Animation::drawFrame(Surface *surface) {
-
// If there are no frames or the animation is not playing, return
if (_frames.size() == 0 || !_playing)
return;
const Drawable *frame = _frames[_currentFrame];
- if (_id == kOverlayImage) {
+ if (_id == kOverlayImage) {
frame->draw(surface, false);
} else {
// Draw frame
@@ -177,12 +173,11 @@ 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)",
_id, scaleX, scaleY);
- markDirtyRect(_vm->_screen->getSurface());
+ markDirtyRect(_vm->_screen->getSurface());
_displacement.extraScaleX = scaleX;
_displacement.extraScaleY = scaleY;
@@ -197,7 +192,7 @@ double Animation::getScaleY() const {
}
void Animation::addFrame(Drawable *frame) {
- _frames.push_back(frame);
+ _frames.push_back(frame);
}
int Animation::getIndex() const {
@@ -209,7 +204,6 @@ void Animation::setIndex(int index) {
}
Drawable *Animation::getFrame(int frameNum) {
-
// If there are no frames stored, return NULL
if (_frames.size() == 0) {
return NULL;
@@ -232,7 +226,6 @@ uint Animation::currentFrameNum() const {
}
void Animation::setCurrentFrame(uint frame) {
-
// Check whether the value is sane
if (frame >= _frames.size()) {
return;
@@ -242,7 +235,6 @@ void Animation::setCurrentFrame(uint frame) {
}
void Animation::deleteFrames() {
-
// If there are no frames to delete, return
if (_frames.size() == 0) {
return;
@@ -250,7 +242,7 @@ void Animation::deleteFrames() {
markDirtyRect(_vm->_screen->getSurface());
- for (int i = getFrameCount() - 1; i >= 0; --i) {
+ for (int i = getFrameCount() - 1; i >= 0; --i) {
delete _frames[i];
_frames.pop_back();
}
@@ -265,7 +257,6 @@ void Animation::exitGameLoop() {
}
Animation *AnimationManager::addAnimation(int id, uint z, bool playing) {
-
// Increment animation index
++_lastIndex;
@@ -281,7 +272,6 @@ Animation *AnimationManager::addAnimation(int id, uint z, bool playing) {
}
Animation *AnimationManager::addItem(int id, bool playing) {
-
Animation *anim = new Animation(_vm, kIgnoreIndex);
anim->setID(id);
@@ -294,7 +284,6 @@ Animation *AnimationManager::addItem(int id, bool playing) {
}
Animation *AnimationManager::addText(int id, bool playing) {
-
Animation *anim = new Animation(_vm, kIgnoreIndex);
anim->setID(id);
@@ -336,7 +325,6 @@ void AnimationManager::stop(int id) {
}
void AnimationManager::pauseAnimations() {
-
Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
@@ -350,7 +338,6 @@ void AnimationManager::pauseAnimations() {
}
void AnimationManager::unpauseAnimations() {
-
Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
@@ -364,7 +351,6 @@ void AnimationManager::unpauseAnimations() {
}
Animation *AnimationManager::getAnimation(int id) {
-
Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
@@ -377,8 +363,7 @@ Animation *AnimationManager::getAnimation(int id) {
}
void AnimationManager::insertAnimation(Animation *anim) {
-
- Common::List<Animation *>::iterator it;
+ Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
if (anim->getZ() < (*it)->getZ())
@@ -403,8 +388,7 @@ void AnimationManager::addOverlay(Drawable *overlay, uint z) {
}
void AnimationManager::drawScene(Surface *surf) {
-
- // Fill the screen with colour zero since some rooms may rely on the screen being black
+ // Fill the screen with colour zero since some rooms may rely on the screen being black
_vm->_screen->getSurface()->fill(0);
sortAnimations();
@@ -462,7 +446,6 @@ void AnimationManager::sortAnimations() {
}
void AnimationManager::deleteAnimation(int id) {
-
Common::List<Animation *>::iterator it;
int index = -1;
@@ -494,7 +477,6 @@ void AnimationManager::deleteAnimation(int id) {
}
void AnimationManager::deleteOverlays() {
-
debugC(3, kDraciAnimationDebugLevel, "Deleting overlays...");
Common::List<Animation *>::iterator it;
@@ -503,12 +485,11 @@ void AnimationManager::deleteOverlays() {
if ((*it)->getID() == kOverlayImage) {
delete *it;
it = _animations.reverse_erase(it);
- }
+ }
}
}
void AnimationManager::deleteAll() {
-
debugC(3, kDraciAnimationDebugLevel, "Deleting all animations...");
Common::List<Animation *>::iterator it;
@@ -527,7 +508,6 @@ int AnimationManager::getLastIndex() const {
}
void AnimationManager::deleteAfterIndex(int index) {
-
Common::List<Animation *>::iterator it;
for (it = _animations.begin(); it != _animations.end(); ++it) {
@@ -544,7 +524,6 @@ void AnimationManager::deleteAfterIndex(int index) {
}
int AnimationManager::getTopAnimationID(int x, int y) const {
-
Common::List<Animation *>::const_iterator it;
// The default return value if no animations were found on these coordinates (not even overlays)
@@ -570,7 +549,6 @@ int AnimationManager::getTopAnimationID(int x, int y) const {
}
if (frame->getRect(anim->getDisplacement()).contains(x, y)) {
-
if (frame->getType() == kDrawableText) {
retval = anim->getID();
@@ -589,5 +567,5 @@ int AnimationManager::getTopAnimationID(int x, int y) const {
return retval;
}
-
+
}
diff --git a/engines/draci/animation.h b/engines/draci/animation.h
index 24ee5368c1..9baa829cfb 100644
--- a/engines/draci/animation.h
+++ b/engines/draci/animation.h
@@ -34,14 +34,16 @@ namespace Draci {
* Animation IDs for those animations that don't have their IDs
* specified in the data files.
*/
-enum { kOverlayImage = -1,
- kWalkingMapOverlay = -2,
- kTitleText = -3,
- kSpeechText = -4,
- kInventorySprite = -5,
- kDialogueLinesID = -6,
- kUnused = -10,
- kInventoryItemsID = -11};
+enum {
+ kOverlayImage = -1,
+ kWalkingMapOverlay = -2,
+ kTitleText = -3,
+ kSpeechText = -4,
+ kInventorySprite = -5,
+ kDialogueLinesID = -6,
+ kUnused = -10,
+ kInventoryItemsID = -11
+};
/**
* Default argument to Animation::getFrame() that makes it return
@@ -63,7 +65,7 @@ typedef void (Animation::* AnimationCallback)();
public:
Animation(DraciEngine *v, int index);
- ~Animation();
+ ~Animation();
uint getZ() const;
void setZ(uint z);
@@ -112,12 +114,11 @@ public:
void exitGameLoop();
private:
-
uint nextFrameNum() const;
void deleteFrames();
/** Internal animation ID
- * (as specified in the data files and the bytecode)
+ * (as specified in the data files and the bytecode)
*/
int _id;
@@ -138,7 +139,7 @@ private:
/** Array of frames of the animation. The animation object owns these pointers.
*/
- Common::Array<Drawable*> _frames;
+ Common::Array<Drawable *> _frames;
AnimationCallback _callback;
@@ -176,7 +177,7 @@ public:
int getTopAnimationID(int x, int y) const;
private:
- void sortAnimations();
+ void sortAnimations();
void insertAnimation(Animation *anim);
DraciEngine *_vm;
@@ -187,7 +188,7 @@ private:
Common::List<Animation *> _animations;
/** The index of the most recently added animation.
- * See Animation::_index for details.
+ * See Animation::_index for details.
*/
int _lastIndex;
};
diff --git a/engines/draci/barchive.cpp b/engines/draci/barchive.cpp
index 12d0987262..ae03cad965 100644
--- a/engines/draci/barchive.cpp
+++ b/engines/draci/barchive.cpp
@@ -45,23 +45,23 @@ const char BArchive::_dfwMagicNumber[] = "BS";
* and this file is compressed using a simple run-length scheme.
*
* archive format: header
- * index table
- * file0, file1, ...
+ * index table
+ * file0, file1, ...
*
* header format: [uint16LE] file count
- * [uint16LE] index table size
- * [2 bytes] magic number "BS"
+ * [uint16LE] index table size
+ * [2 bytes] magic number "BS"
*
* index table format: entry0, entry1, ...
*
* entry<N> format: [uint16LE] compressed size (not including the 2 bytes for the
- * "uncompressed size" field)
- * [uint32LE] fileN offset from start of file
+ * "uncompressed size" field)
+ * [uint32LE] fileN offset from start of file
*
* file<N> format: [uint16LE] uncompressed size
- * [uint16LE] compressed size (the same as in the index table entry)
- * [byte] stopper mark (for run-length compression)
- * [multiple bytes] compressed data
+ * [uint16LE] compressed size (the same as in the index table entry)
+ * [byte] stopper mark (for run-length compression)
+ * [multiple bytes] compressed data
*/
void BArchive::openDFW(const Common::String &path) {
@@ -76,7 +76,7 @@ void BArchive::openDFW(const Common::String &path) {
debugC(2, kDraciArchiverDebugLevel, "Error opening file");
return;
}
-
+
_fileCount = f.readUint16LE();
tableSize = f.readUint16LE();
@@ -94,16 +94,16 @@ void BArchive::openDFW(const Common::String &path) {
// Read in index table
table = new byte[tableSize];
- f.read(table, tableSize);
-
+ f.read(table, tableSize);
+
// Read in file headers, but do not read the actual data yet
// The data will be read on demand to save memory
_files = new BAFile[_fileCount];
Common::MemoryReadStream tableReader(table, tableSize);
- for (unsigned int i = 0; i < _fileCount; ++i) {
+ for (uint i = 0; i < _fileCount; ++i) {
_files[i]._compLength = tableReader.readUint16LE();
_files[i]._offset = tableReader.readUint32LE();
-
+
// Seek to the current file
f.seek(_files[i]._offset);
@@ -117,11 +117,11 @@ void BArchive::openDFW(const Common::String &path) {
// Indicate that the archive was successfully opened
_opened = true;
-
+
// Cleanup
delete[] table;
f.close();
-}
+}
/**
* @brief BArchive open method
@@ -142,7 +142,7 @@ void BArchive::openDFW(const Common::String &path) {
* [2 bytes] original length
* [1 byte] compression type
* [1 byte] CRC
- * [multiple bytes] actual data
+ * [multiple bytes] actual data
*
* footer format: [array of uint32LE] offsets of individual files from start of archive
* (last entry is footer offset again)
@@ -177,7 +177,7 @@ void BArchive::openArchive(const Common::String &path) {
if (memcmp(buf, _magicNumber, 4) == 0) {
debugC(2, kDraciArchiverDebugLevel, "Success");
- // Indicate this archive is a BAR
+ // Indicate this archive is a BAR
_isDFW = false;
} else {
debugC(2, kDraciArchiverDebugLevel, "Not a BAR archive");
@@ -197,8 +197,8 @@ void BArchive::openArchive(const Common::String &path) {
debugC(2, kDraciArchiverDebugLevel, "Archive info: %d files, %d data bytes",
_fileCount, footerOffset - _archiveHeaderSize);
- // Read in footer
- footer = new byte[footerSize];
+ // Read in footer
+ footer = new byte[footerSize];
f.seek(footerOffset);
f.read(footer, footerSize);
Common::MemoryReadStream reader(footer, footerSize);
@@ -207,8 +207,8 @@ void BArchive::openArchive(const Common::String &path) {
// The data will be read on demand to save memory
_files = new BAFile[_fileCount];
- for (unsigned int i = 0; i < _fileCount; i++) {
- uint32 fileOffset;
+ for (uint i = 0; i < _fileCount; i++) {
+ uint32 fileOffset;
fileOffset = reader.readUint32LE();
f.seek(fileOffset); // Seek to next file in archive
@@ -226,7 +226,7 @@ void BArchive::openArchive(const Common::String &path) {
_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");
@@ -249,7 +249,7 @@ void BArchive::closeArchive(void) {
return;
}
- for (unsigned int i = 0; i < _fileCount; ++i) {
+ for (uint i = 0; i < _fileCount; ++i) {
if (_files[i]._data) {
delete[] _files[i]._data;
}
@@ -271,7 +271,7 @@ void BArchive::closeArchive(void) {
* Should not be called directly. Instead, one should access files
* through the operator[] interface.
*/
-BAFile *BArchive::loadFileBAR(unsigned int i) const {
+BAFile *BArchive::loadFileBAR(uint i) const {
Common::File f;
// Else open archive and read in requested file
@@ -290,7 +290,7 @@ BAFile *BArchive::loadFileBAR(unsigned int i) const {
// Calculate CRC
byte tmp = 0;
- for (unsigned int j = 0; j < _files[i]._length; j++) {
+ for (uint j = 0; j < _files[i]._length; j++) {
tmp ^= _files[i]._data[j];
}
@@ -310,7 +310,7 @@ BAFile *BArchive::loadFileBAR(unsigned int i) const {
* Should not be called directly. Instead, one should access files
* through the operator[] interface.
*/
-BAFile *BArchive::loadFileDFW(unsigned int i) const {
+BAFile *BArchive::loadFileDFW(uint i) const {
Common::File f;
byte *buf;
@@ -343,7 +343,7 @@ BAFile *BArchive::loadFileDFW(unsigned int i) const {
f.read(buf, compressedLength);
// Allocate the space for the uncompressed file
- byte *dst;
+ byte *dst;
dst = _files[i]._data = new byte[uncompressedLength];
Common::MemoryReadStream data(buf, compressedLength);
@@ -351,21 +351,20 @@ BAFile *BArchive::loadFileDFW(unsigned int i) const {
// Uncompress file
byte current, what;
byte stopper = _files[i]._stopper;
- unsigned int repeat;
- unsigned int len = 0; // Sanity check (counts uncompressed bytes)
+ uint repeat;
+ uint len = 0; // Sanity check (counts uncompressed bytes)
current = data.readByte(); // Read initial byte
while (!data.eos()) {
-
if (current != stopper) {
*dst++ = current;
++len;
} else {
- // Inflate block
+ // Inflate block
repeat = data.readByte();
what = data.readByte();
len += repeat;
- for (unsigned int j = 0; j < repeat; ++j) {
+ for (uint j = 0; j < repeat; ++j) {
*dst++ = what;
}
}
@@ -385,16 +384,13 @@ BAFile *BArchive::loadFileDFW(unsigned int i) const {
* If the files are subsequently accessed, they are read from the disk.
*/
void BArchive::clearCache() {
-
// Delete all cached data
- for (unsigned int i = 0; i < _fileCount; ++i) {
+ for (uint i = 0; i < _fileCount; ++i) {
_files[i].close();
}
}
-
-
-const BAFile *BArchive::getFile(unsigned int i) const {
+const BAFile *BArchive::getFile(uint i) const {
// Check whether requested file exists
if (i >= _fileCount) {
return NULL;
@@ -405,12 +401,12 @@ const BAFile *BArchive::getFile(unsigned int i) const {
// Check if file has already been opened and return that
if (_files[i]._data) {
- debugC(2, kDraciArchiverDebugLevel, "Success");
+ debugC(2, kDraciArchiverDebugLevel, "Success");
return _files + i;
}
-
+
BAFile *file;
-
+
// file will be NULL if something goes wrong
if (_isDFW) {
file = loadFileDFW(i);
diff --git a/engines/draci/barchive.h b/engines/draci/barchive.h
index 2ac1a6aa7f..d9189e8652 100644
--- a/engines/draci/barchive.h
+++ b/engines/draci/barchive.h
@@ -33,14 +33,13 @@ namespace Draci {
/**
* Represents individual files inside the archive.
*/
-
struct BAFile {
- uint _compLength; //!< Compressed length (the same as _length if the file is uncompressed)
- uint _length; //!< Uncompressed length
- uint32 _offset; //!< Offset of file inside archive
+ uint _compLength; //!< Compressed length (the same as _length if the file is uncompressed)
+ uint _length; //!< Uncompressed length
+ uint32 _offset; //!< Offset of file inside archive
byte *_data;
byte _crc;
- byte _stopper; //!< Not used in BAR files, needed for DFW
+ byte _stopper; //!< Not used in BAR files, needed for DFW
/** Releases the file data (for memory considerations) */
void close(void) {
@@ -67,31 +66,31 @@ public:
/**
* Checks whether there is an archive opened. Should be called before reading
* from the archive to check whether openArchive() succeeded.
- */
+ */
bool isOpen() const { return _opened; }
void clearCache();
- const BAFile *getFile(unsigned int i) const;
+ const BAFile *getFile(uint i) const;
private:
// Archive header data
static const char _magicNumber[];
static const char _dfwMagicNumber[];
- static const unsigned int _archiveHeaderSize = 10;
+ static const uint _archiveHeaderSize = 10;
// File stream header data
- static const unsigned int _fileHeaderSize = 6;
+ static const uint _fileHeaderSize = 6;
Common::String _path; //!< Path to file
BAFile *_files; //!< Internal array of files
- uint _fileCount; //!< Number of files in archive
- bool _isDFW; //!< True if the archive is in DFW format, false otherwise
- bool _opened; //!< True if the archive is opened, false otherwise
+ uint _fileCount; //!< Number of files in archive
+ bool _isDFW; //!< True if the archive is in DFW format, false otherwise
+ bool _opened; //!< True if the archive is opened, false otherwise
void openDFW(const Common::String &path);
- BAFile *loadFileDFW(unsigned int i) const;
- BAFile *loadFileBAR(unsigned int i) const;
+ BAFile *loadFileDFW(uint i) const;
+ BAFile *loadFileBAR(uint i) const;
};
} // End of namespace Draci
diff --git a/engines/draci/detection.cpp b/engines/draci/detection.cpp
index b8aeb11200..b57a8f587d 100644
--- a/engines/draci/detection.cpp
+++ b/engines/draci/detection.cpp
@@ -38,7 +38,6 @@ namespace Draci {
using Common::GUIO_NONE;
const ADGameDescription gameDescriptions[] = {
-
{
"draci",
0,
@@ -48,7 +47,7 @@ const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO_NONE
},
-
+
{
"draci",
0,
@@ -98,7 +97,7 @@ const ADParams detectionParams = {
class DraciMetaEngine : public AdvancedMetaEngine {
public:
DraciMetaEngine() : AdvancedMetaEngine(detectionParams) {}
-
+
virtual const char *getName() const {
return "Draci Historie Engine";
}
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index abe3393c31..57a1b11812 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -109,42 +109,42 @@ int DraciEngine::init() {
_script = new Script(this);
_game = new Game(this);
- if(!_objectsArchive->isOpen()) {
+ if (!_objectsArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening objects archive failed");
return Common::kUnknownError;
}
- if(!_spritesArchive->isOpen()) {
+ if (!_spritesArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening sprites archive failed");
return Common::kUnknownError;
}
- if(!_paletteArchive->isOpen()) {
+ if (!_paletteArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening palette archive failed");
return Common::kUnknownError;
}
- if(!_roomsArchive->isOpen()) {
+ if (!_roomsArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening rooms archive failed");
return Common::kUnknownError;
}
- if(!_overlaysArchive->isOpen()) {
+ if (!_overlaysArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening overlays archive failed");
return Common::kUnknownError;
}
- if(!_animationsArchive->isOpen()) {
+ if (!_animationsArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening animations archive failed");
return Common::kUnknownError;
}
- if(!_iconsArchive->isOpen()) {
+ if (!_iconsArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening icons archive failed");
return Common::kUnknownError;
}
- if(!_walkingMapsArchive->isOpen()) {
+ if (!_walkingMapsArchive->isOpen()) {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening walking maps archive failed");
return Common::kUnknownError;
}
@@ -152,21 +152,21 @@ int DraciEngine::init() {
_showWalkingMap = false;
// Basic archive test
- debugC(2, kDraciGeneralDebugLevel, "Running archive tests...");
- Common::String path("INIT.DFW");
+ debugC(2, kDraciGeneralDebugLevel, "Running archive tests...");
+ Common::String path("INIT.DFW");
BArchive ar(path);
const BAFile *f;
- debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size());
+ debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size());
- if(ar.isOpen()) {
- f = ar.getFile(0);
+ 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 (unsigned int i = 0; i < 10; ++i) {
+ for (uint i = 0; i < 10; ++i) {
debugC(3, kDraciGeneralDebugLevel, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n');
}
@@ -195,12 +195,10 @@ bool DraciEngine::handleEvents() {
if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
_game->setRoomNum(_game->nextRoomNum());
_game->setGateNum(0);
- }
- else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
+ } else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
_game->setRoomNum(_game->prevRoomNum());
_game->setGateNum(0);
- }
- else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
int escRoom = _game->getEscRoom();
// Check if there is an escape room defined for the current room
@@ -214,8 +212,7 @@ bool DraciEngine::handleEvents() {
// End any currently running GPL programs
_script->endCurrentProgram();
}
- }
- else if (event.kbd.keycode == Common::KEYCODE_m) {
+ } else if (event.kbd.keycode == Common::KEYCODE_m) {
if (_game->getLoopStatus() == kStatusOrdinary) {
// TODO: record the current room number
// so that we can quickly exit there
@@ -223,13 +220,11 @@ bool DraciEngine::handleEvents() {
_game->setRoomNum(_game->getMapRoom());
_game->setGateNum(0);
}
- }
- // Show walking map toggle
- 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) {
- if(_game->getLoopStatus() == kStatusInventory &&
+ } else if (event.kbd.keycode == Common::KEYCODE_i) {
+ if (_game->getLoopStatus() == kStatusInventory &&
_game->getLoopSubstatus() == kSubstatusOrdinary) {
_game->inventoryDone();
} else if (_game->getLoopStatus() == kStatusOrdinary &&
diff --git a/engines/draci/draci.h b/engines/draci/draci.h
index 168d48733f..264f4496c4 100644
--- a/engines/draci/draci.h
+++ b/engines/draci/draci.h
@@ -81,11 +81,11 @@ public:
};
enum {
- kDraciGeneralDebugLevel = 1 << 0,
- kDraciBytecodeDebugLevel = 1 << 1,
- kDraciArchiverDebugLevel = 1 << 2,
- kDraciLogicDebugLevel = 1 << 3,
- kDraciAnimationDebugLevel = 1 << 4
+ kDraciGeneralDebugLevel = 1 << 0,
+ kDraciBytecodeDebugLevel = 1 << 1,
+ kDraciArchiverDebugLevel = 1 << 2,
+ kDraciLogicDebugLevel = 1 << 3,
+ kDraciAnimationDebugLevel = 1 << 4
};
// Macro to simulate lround() for non-C99 compilers
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp
index 7b58149ac1..3d8fa545b6 100644
--- a/engines/draci/font.cpp
+++ b/engines/draci/font.cpp
@@ -30,11 +30,10 @@
namespace Draci {
-const char *kFontSmall = "Small.fon";
-const char *kFontBig = "Big.fon";
+const char * const kFontSmall = "Small.fon";
+const char * const kFontBig = "Big.fon";
Font::Font(const Common::String &filename) {
-
_fontHeight = 0;
_maxCharWidth = 0;
_charWidths = NULL;
@@ -60,13 +59,12 @@ Font::~Font() {
* language versions of the game.
*
* 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
+ * [1 byte] font height
+ * [138 bytes] character widths of all 138 characters in the font
+ * [138 * fontHeight * maxWidth bytes] character data, stored row-wise
*/
bool Font::loadFont(const Common::String &filename) {
-
// Free previously loaded font (if any)
freeFont();
@@ -85,14 +83,14 @@ bool Font::loadFont(const Common::String &filename) {
_maxCharWidth = f.readByte();
_fontHeight = f.readByte();
- // Read in the widths of the glyphs
+ // Read in the widths of the glyphs
_charWidths = new uint8[kCharNum];
- for (unsigned int i = 0; i < kCharNum; ++i) {
+ for (uint i = 0; i < kCharNum; ++i) {
_charWidths[i] = f.readByte();
}
// Calculate size of font data
- unsigned int fontDataSize = kCharNum * _maxCharWidth * _fontHeight;
+ uint fontDataSize = kCharNum * _maxCharWidth * _fontHeight;
// Read in all glyphs
_charData = new byte[fontDataSize];
@@ -115,10 +113,10 @@ uint8 Font::getCharWidth(uint8 chr) const {
/**
* @brief Draw a char to a Draci::Surface
*
- * @param dst Pointer to the destination surface
- * @param chr Character to draw
- * @param tx Horizontal offset on the surface
- * @param ty Vertical offset on the surface
+ * @param dst Pointer to the destination surface
+ * @param chr Character to draw
+ * @param tx Horizontal offset on the surface
+ * @param ty Vertical offset on the surface
*/
void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const {
@@ -132,11 +130,11 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) co
uint8 currentWidth = _charWidths[charIndex];
// Determine how many pixels to draw horizontally (to prevent overflow)
- int xSpaceLeft = dst->w - tx - 1;
+ int xSpaceLeft = dst->w - tx - 1;
int xPixelsToDraw = (currentWidth < xSpaceLeft) ? currentWidth : xSpaceLeft;
// Determine how many pixels to draw vertically
- int ySpaceLeft = dst->h - ty - 1;
+ int ySpaceLeft = dst->h - ty - 1;
int yPixelsToDraw = (_fontHeight < ySpaceLeft) ? _fontHeight : ySpaceLeft;
int _transparent = dst->getTransparentColour();
@@ -148,12 +146,11 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) co
int colour = _charData[charOffset + curr];
// If pixel is transparent, skip it
- if (colour == _transparent)
+ if (colour == _transparent)
continue;
// Replace colour with font colours
switch (colour) {
-
case 254:
colour = with_colour;
break;
@@ -176,38 +173,37 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) co
}
// Advance to next row
- ptr += dst->pitch;
+ ptr += dst->pitch;
}
}
/**
* @brief Draw a string to a Draci::Surface
*
- * @param dst Pointer to the destination surface
- * @param str Buffer containing string data
- * @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 dst Pointer to the destination surface
+ * @param str Buffer containing string data
+ * @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.
*/
-
void Font::drawString(Surface *dst, const byte *str, uint len,
- int x, int y, int with_colour, int spacing, bool markDirty) const {
+ 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);
}
/**
* @brief Draw a string to a Draci::Surface
*
- * @param dst Pointer to the destination surface
- * @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 dst Pointer to the destination surface
+ * @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.
*/
void Font::drawString(Surface *dst, const Common::String &str,
- int x, int y, int with_colour, int spacing, bool markDirty) const {
+ int x, int y, int with_colour, int spacing, bool markDirty) const {
assert(dst != NULL);
assert(x >= 0);
assert(y >= 0);
@@ -226,12 +222,12 @@ void Font::drawString(Surface *dst, const Common::String &str,
curx = x + (widest - getLineWidth(str, i+1, spacing) - 1) / 2;
continue;
}
-
- // Break early if there's no more space on the screen
+
+ // Break early if there's no more space on the screen
if (curx >= dst->w - 1 || cury >= dst->h - 1) {
break;
- }
-
+ }
+
drawChar(dst, str[i], curx, cury, with_colour);
curx += getCharWidth(str[i]) + spacing;
}
@@ -245,19 +241,18 @@ 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 str String to draw
+ * @param spacing Space to leave between individual characters. Defaults to 0.
*
* @return The calculated width of the string
*/
-
uint Font::getStringWidth(const Common::String &str, int spacing) const {
- unsigned int width = 0;
+ uint width = 0;
// Real length, including '|' separators
uint len = str.size();
- for (unsigned int i = 0, tmp = 0; i < len; ++i) {
+ for (uint i = 0, tmp = 0; i < len; ++i) {
if (str[i] != '|') {
uint8 charIndex = str[i] - kCharIndexOffset;
@@ -281,7 +276,6 @@ 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,
@@ -291,7 +285,7 @@ uint Font::getLineWidth(const Common::String &str, uint startIndex, int spacing)
for (uint i = startIndex; i < str.size(); ++i) {
- // EOL encountered
+ // EOL encountered
if (str[i] == '|')
break;
@@ -306,28 +300,26 @@ uint Font::getLineWidth(const Common::String &str, uint startIndex, int spacing)
/**
* @brief Calculate the height of a string by counting the number of '|' chars (which
- * are used as newline characters and end-of-string markers)
+ * 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 str String to draw
+ * @param spacing Space to leave between individual characters. Defaults to 0.
*
* @return The calculated height of the string
*/
-
-
uint Font::getStringHeight(const Common::String &str) const {
uint len = str.size();
int separators = 0;
- for (unsigned int i = 0; i < len; ++i) {
+ for (uint i = 0; i < len; ++i) {
// All strings in the data files should end with '|' but not all do.
// This is why we check whether we are at the last char too.
if (str[i] == '|' || i == len - 1) {
++separators;
}
}
-
+
return separators * getFontHeight();
-}
+}
} // End of namespace Draci
diff --git a/engines/draci/font.h b/engines/draci/font.h
index 931801ccd2..55a3122bb9 100644
--- a/engines/draci/font.h
+++ b/engines/draci/font.h
@@ -30,30 +30,32 @@
namespace Draci {
-extern const char *kFontSmall;
-extern const char *kFontBig;
+extern const char * const kFontSmall;
+extern const char * const kFontBig;
/**
- * Default font colours. They all seem to remain constant except for the
+ * 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 {
- kFontColour1 = 2, kFontColour2 = 0,
- kFontColour3 = 3, kFontColour4 = 4,
- kOverFontColour = 255, kTitleColour = 255,
- kLineActiveColour = 254, kLineInactiveColour = 255
+ kFontColour1 = 2,
+ kFontColour2 = 0,
+ kFontColour3 = 3,
+ kFontColour4 = 4,
+ kOverFontColour = 255,
+ kTitleColour = 255,
+ kLineActiveColour = 254,
+ kLineInactiveColour = 255
};
/**
* Represents the game's fonts. See docs for setFont() for font format details.
*/
-
class Font {
public:
-
Font(const Common::String &filename);
~Font();
@@ -62,12 +64,12 @@ public:
uint8 getMaxCharWidth() const { return _maxCharWidth; };
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,
- int spacing, bool markDirty = true) const;
+ int spacing, bool markDirty = true) const;
void drawString(Surface *dst, const Common::String &str,
- int x, int y, int with_colour, int spacing, bool markDirty = true) const;
-
+ int x, int y, int with_colour, int spacing, bool markDirty = true) const;
+
uint getStringWidth(const Common::String &str, int spacing = 0) const;
uint getStringHeight(const Common::String &str) const;
uint getLineWidth(const Common::String &str, uint startIndex, int spacing = 0) const;
@@ -75,21 +77,21 @@ public:
private:
uint8 _fontHeight;
uint8 _maxCharWidth;
-
- /** Pointer to an array of individual char widths */
+
+ /** Pointer to an array of individual char widths */
uint8 *_charWidths;
-
+
/** Pointer to a raw byte array representing font pixels stored row-wise */
byte *_charData;
/** Number of glyphs in the font */
- static const unsigned int kCharNum = 138;
+ static const uint kCharNum = 138;
/**
- * Chars are indexed from the space character so this should be subtracted
+ * Chars are indexed from the space character so this should be subtracted
* to get the index of a glyph
*/
- static const unsigned int kCharIndexOffset = 32;
+ static const uint kCharIndexOffset = 32;
/** Internal function for freeing fonts when destructing/loading another */
void freeFont();
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 61cb4c7988..4563030b9e 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -35,23 +35,23 @@
namespace Draci {
-const Common::String dialoguePath("ROZH");
+static const Common::String dialoguePath("ROZH");
static double real_to_double(byte real[6]);
Game::Game(DraciEngine *vm) : _vm(vm) {
- unsigned int i;
-
+ uint i;
+
BArchive *initArchive = _vm->_initArchive;
const BAFile *file;
-
+
// Read in persons
file = initArchive->getFile(5);
Common::MemoryReadStream personData(file->_data, file->_length);
-
- unsigned int numPersons = file->_length / personSize;
+
+ uint numPersons = file->_length / personSize;
_persons = new Person[numPersons];
-
+
for (i = 0; i < numPersons; ++i) {
_persons[i]._x = personData.readUint16LE();
_persons[i]._y = personData.readUint16LE();
@@ -61,23 +61,23 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
// Read in dialogue offsets
file = initArchive->getFile(4);
Common::MemoryReadStream dialogueData(file->_data, file->_length);
-
- unsigned int numDialogues = file->_length / sizeof(uint16);
+
+ uint numDialogues = file->_length / sizeof(uint16);
_dialogueOffsets = new uint[numDialogues];
-
- unsigned int curOffset;
+
+ uint curOffset;
for (i = 0, curOffset = 0; i < numDialogues; ++i) {
_dialogueOffsets[i] = curOffset;
curOffset += dialogueData.readUint16LE();
}
-
+
_dialogueVars = new int[curOffset];
memset(_dialogueVars, 0, sizeof (int) * curOffset);
-
+
// Read in game info
file = initArchive->getFile(3);
Common::MemoryReadStream gameData(file->_data, file->_length);
-
+
_info._startRoom = gameData.readByte() - 1;
_info._mapRoom = gameData.readByte() - 1;
_info._numObjects = gameData.readUint16LE();
@@ -97,7 +97,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
// Read in variables
file = initArchive->getFile(2);
- unsigned int numVariables = file->_length / sizeof (int16);
+ uint numVariables = file->_length / sizeof (int16);
_variables = new int[numVariables];
Common::MemoryReadStream variableData(file->_data, file->_length);
@@ -112,14 +112,14 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
_itemStatus = new byte[numItems];
memcpy(_itemStatus, file->_data, numItems);
_items = new GameItem[numItems];
-
+
// Read in object status
file = initArchive->getFile(0);
- unsigned int numObjects = file->_length;
-
+ uint numObjects = file->_length;
+
_objects = new GameObject[numObjects];
Common::MemoryReadStream objStatus(file->_data, file->_length);
-
+
for (i = 0; i < numObjects; ++i) {
byte tmp = objStatus.readByte();
@@ -128,13 +128,13 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
// Set object location
_objects[i]._location = (~(1 << 7) & tmp) - 1;
- }
-
+ }
+
assert(numDialogues == _info._numDialogues);
assert(numPersons == _info._numPersons);
assert(numVariables == _info._numVariables);
assert(numObjects == _info._numObjects);
- assert(numItems == _info._numItems);
+ assert(numItems == _info._numItems);
// Deallocate all cached files, because we have copied them into our own data structures.
initArchive->clearCache();
@@ -142,7 +142,6 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
void Game::start() {
while (!shouldQuit()) {
-
// Whenever the top-level loop is entered, it should not finish unless
// the exit is triggered by a script
_shouldExitLoop = false;
@@ -184,7 +183,7 @@ void Game::start() {
debugC(6, kDraciLogicDebugLevel, "Mouse: OFF");
_vm->_mouse->cursorOff();
}
- }
+ }
// Mimic the original engine by setting the loop status to Ordinary before
// entering the main loop
@@ -210,7 +209,7 @@ void Game::init() {
_objUnderCursor = kOverlayImage;
// Set the inventory to empty initially
- memset(_inventory, kNoItem, kInventorySlots * sizeof (int));
+ memset(_inventory, kNoItem, kInventorySlots * sizeof(int));
// Initialize animation for object / room titles
Animation *titleAnim = _vm->_anims->addText(kTitleText, true);
@@ -228,7 +227,7 @@ void Game::init() {
Sprite *inventorySprite = new Sprite(f->_data, f->_length, 0, 0, true);
inventoryAnim->addFrame(inventorySprite);
inventoryAnim->setRelative((kScreenWidth - inventorySprite->getWidth()) / 2,
- (kScreenHeight - inventorySprite->getHeight()) / 2);
+ (kScreenHeight - inventorySprite->getHeight()) / 2);
for (uint i = 0; i < kDialogueLines; ++i) {
_dialogueAnims[i] = _vm->_anims->addText(kDialogueLinesID - i, true);
@@ -237,7 +236,7 @@ void Game::init() {
_dialogueAnims[i]->setZ(254);
_dialogueAnims[i]->setRelative(1,
- kScreenHeight - (i + 1) * _vm->_smallFont->getFontHeight());
+ kScreenHeight - (i + 1) * _vm->_smallFont->getFontHeight());
Text *text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame());
text->setText("");
@@ -248,7 +247,7 @@ void Game::init() {
}
loadObject(kDragonObject);
-
+
const GameObject *dragon = getObject(kDragonObject);
debugC(4, kDraciLogicDebugLevel, "Running init program for the dragon object...");
_vm->_script->run(dragon->_program, dragon->_init);
@@ -269,22 +268,19 @@ void Game::init() {
}
void Game::loop() {
-
Surface *surface = _vm->_screen->getSurface();
do {
-
debugC(4, kDraciLogicDebugLevel, "loopstatus: %d, loopsubstatus: %d",
_loopStatus, _loopSubstatus);
_vm->handleEvents();
- // Fetch mouse coordinates
+ // Fetch mouse coordinates
int x = _vm->_mouse->getPosX();
int y = _vm->_mouse->getPosY();
if (_loopStatus == kStatusDialogue && _loopSubstatus == kSubstatusOrdinary) {
-
Text *text;
for (int i = 0; i < kDialogueLines; ++i) {
text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame());
@@ -295,7 +291,7 @@ void Game::loop() {
text->setColour(kLineInactiveColour);
}
}
-
+
if (_vm->_mouse->lButtonPressed() || _vm->_mouse->rButtonPressed()) {
_shouldExitLoop = true;
_vm->_mouse->lButtonSet(false);
@@ -304,7 +300,6 @@ void Game::loop() {
}
if(_vm->_mouse->isCursorOn()) {
-
// Fetch the dedicated objects' title animation / current frame
Animation *titleAnim = _vm->_anims->getAnimation(kTitleText);
Text *title = reinterpret_cast<Text *>(titleAnim->getFrame());
@@ -313,9 +308,8 @@ void Game::loop() {
updateTitle();
if (_loopStatus == kStatusOrdinary && _loopSubstatus == kSubstatusOrdinary) {
-
if (_vm->_mouse->lButtonPressed()) {
- _vm->_mouse->lButtonSet(false);
+ _vm->_mouse->lButtonSet(false);
if (_currentItem != kNoItem) {
putItem(_currentItem, 0);
@@ -389,7 +383,7 @@ void Game::loop() {
if (_loopStatus == kStatusInventory && _loopSubstatus == kSubstatusOrdinary) {
if (_inventoryExit) {
- inventoryDone();
+ inventoryDone();
}
// If we are in inventory mode, all the animations except game items'
@@ -402,7 +396,7 @@ void Game::loop() {
if (_animUnderCursor != kOverlayImage && _animUnderCursor != kInventorySprite) {
_itemUnderCursor = kInventoryItemsID - _animUnderCursor;
} else {
- _itemUnderCursor = kNoItem;
+ _itemUnderCursor = kNoItem;
}
// If the user pressed the left mouse button
@@ -431,11 +425,10 @@ void Game::loop() {
// If we right-clicked outside the inventory, close it
if (_animUnderCursor != kInventorySprite && _itemUnderCursor == kNoItem) {
- inventoryDone();
+ inventoryDone();
// If there is an inventory item under our cursor
} else if (_itemUnderCursor != kNoItem) {
-
// Again, we have two possibilities:
// The first is that there is no item in our hands.
@@ -460,22 +453,22 @@ void Game::loop() {
updateCursor();
}
}
- }
- }
-
+ }
+ }
+
debugC(5, kDraciLogicDebugLevel, "Anim under cursor: %d", _animUnderCursor);
// Handle character talking (if there is any)
if (_loopSubstatus == kSubstatusTalk) {
- Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText);
+ Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText);
Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame());
uint speechDuration = kBaseSpeechDuration +
- speechFrame->getLength() * kSpeechTimeUnit /
- (128 / 16 + 1);
+ speechFrame->getLength() * kSpeechTimeUnit /
+ (128 / 16 + 1);
// If the current speech text has expired or the user clicked a mouse button,
- // advance to the next line of text
+ // advance to the next line of text
if (_vm->_mouse->lButtonPressed() ||
_vm->_mouse->rButtonPressed() ||
(_vm->_system->getMillis() - _speechTick) >= speechDuration) {
@@ -497,14 +490,13 @@ void Game::loop() {
// HACK: Won't be needed once the game loop is implemented properly
_shouldExitLoop = _shouldExitLoop || (_newRoom != _currentRoom._roomNum &&
- (_loopStatus == kStatusOrdinary || _loopStatus == kStatusGate));
+ (_loopStatus == kStatusOrdinary || _loopStatus == kStatusGate));
} while (!shouldExitLoop());
}
void Game::updateCursor() {
-
- // Fetch mouse coordinates
+ // Fetch mouse coordinates
int x = _vm->_mouse->getPosX();
int y = _vm->_mouse->getPosY();
@@ -534,9 +526,9 @@ void Game::updateCursor() {
if (_vm->_script->testExpression(program, canUseOffset)) {
if (_currentItem == kNoItem) {
- _vm->_mouse->setCursorType(kHighlightedCursor);
+ _vm->_mouse->setCursorType(kHighlightedCursor);
} else {
- _vm->_mouse->loadItemCursor(_currentItem, true);
+ _vm->_mouse->loadItemCursor(_currentItem, true);
}
}
}
@@ -565,8 +557,7 @@ void Game::updateCursor() {
// TODO: Handle main menu
// If there is no game object under the cursor, try using the room itself
- if (_objUnderCursor == kObjectNotFound) {
-
+ if (_objUnderCursor == kObjectNotFound) {
if (_vm->_script->testExpression(_currentRoom._program, _currentRoom._canUse)) {
if (_currentItem == kNoItem) {
_vm->_mouse->setCursorType(kHighlightedCursor);
@@ -577,7 +568,7 @@ void Game::updateCursor() {
// If there *is* a game object under the cursor, update the cursor image
} else {
GameObject *obj = &_objects[_objUnderCursor];
-
+
// If there is no walking direction set on the object (i.e. the object
// is not a gate / exit), test whether it can be used and, if so,
// update the cursor image (highlight it).
@@ -598,7 +589,6 @@ void Game::updateCursor() {
}
void Game::updateTitle() {
-
// If we are inside a dialogue, don't update titles
if (_loopStatus == kStatusDialogue)
return;
@@ -607,7 +597,7 @@ void Game::updateTitle() {
Surface *surface = _vm->_screen->getSurface();
const int smallFontHeight = _vm->_smallFont->getFontHeight();
- // Fetch mouse coordinates
+ // Fetch mouse coordinates
int x = _vm->_mouse->getPosX();
int y = _vm->_mouse->getPosY();
@@ -639,12 +629,12 @@ void Game::updateTitle() {
} else {
_vm->_anims->play(titleAnim->getID());
}
-}
+}
int Game::getObjectWithAnimation(int animID) const {
for (uint i = 0; i < _info._numObjects; ++i) {
GameObject *obj = &_objects[i];
-
+
for (uint j = 0; j < obj->_anims.size(); ++j) {
if (obj->_anims[j] == animID) {
return i;
@@ -656,18 +646,16 @@ int Game::getObjectWithAnimation(int animID) const {
}
void Game::removeItem(int itemID) {
-
for (uint i = 0; i < kInventorySlots; ++i) {
if (_inventory[i] == itemID) {
_inventory[i] = kNoItem;
_vm->_anims->stop(kInventoryItemsID - itemID);
- break;
+ break;
}
}
}
void Game::putItem(int itemID, int position) {
-
if (itemID == kNoItem)
return;
@@ -681,7 +669,7 @@ void Game::putItem(int itemID, int position) {
for (i = 0; i < kInventorySlots; ++i) {
if (_inventory[i] == kNoItem) {
_inventory[i] = itemID;
- break;
+ break;
}
}
}
@@ -693,14 +681,14 @@ void Game::putItem(int itemID, int position) {
Drawable *frame = anim->getFrame();
const int x = kInventoryX +
- (column * kInventoryItemWidth) -
- (kInventoryItemWidth / 2) -
- (frame->getWidth() / 2);
+ (column * kInventoryItemWidth) -
+ (kInventoryItemWidth / 2) -
+ (frame->getWidth() / 2);
const int y = kInventoryY +
- (line * kInventoryItemHeight) -
- (kInventoryItemHeight / 2) -
- (frame->getHeight() / 2);
+ (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);
@@ -715,13 +703,12 @@ void Game::putItem(int itemID, int position) {
}
void Game::inventoryInit() {
-
// Pause all "background" animations
_vm->_anims->pauseAnimations();
// Draw the inventory and the current items
inventoryDraw();
-
+
// Turn cursor on if it is off
_vm->_mouse->cursorOn();
@@ -754,7 +741,6 @@ void Game::inventoryDone() {
}
void Game::inventoryDraw() {
-
_vm->_anims->play(kInventorySprite);
for (uint i = 0; i < kInventorySlots; ++i) {
@@ -765,7 +751,6 @@ void Game::inventoryDraw() {
}
void Game::dialogueMenu(int dialogueID) {
-
int oldLines, hit;
char tmp[5];
@@ -774,7 +759,7 @@ void Game::dialogueMenu(int dialogueID) {
_dialogueArchive = new BArchive(dialoguePath + ext + ".dfw");
debugC(4, kDraciLogicDebugLevel, "Starting dialogue (ID: %d, Archive: %s)",
- dialogueID, (dialoguePath + ext + ".dfw").c_str());
+ dialogueID, (dialoguePath + ext + ".dfw").c_str());
_currentDialogue = dialogueID;
oldLines = 255;
@@ -783,7 +768,7 @@ void Game::dialogueMenu(int dialogueID) {
do {
_dialogueExit = false;
hit = dialogueDraw();
-
+
debugC(7, kDraciLogicDebugLevel,
"hit: %d, _lines[hit]: %d, lastblock: %d, dialogueLines: %d, dialogueExit: %d",
hit, _lines[hit], _lastBlock, _dialogueLinesNum, _dialogueExit);
@@ -817,7 +802,6 @@ int Game::dialogueDraw() {
Text *dialogueLine;
while ((_dialogueLinesNum < 4) && (i < _blockNum)) {
-
GPL2Program blockTest;
blockTest._bytecode = _dialogueBlocks[i]._canBlock;
blockTest._length = _dialogueBlocks[i]._canLen;
@@ -848,15 +832,15 @@ int Game::dialogueDraw() {
_shouldExitLoop = false;
loop();
_vm->_mouse->cursorOff();
-
+
bool notDialogueAnim = true;
for (uint j = 0; j < kDialogueLines; ++j) {
if (_dialogueAnims[j]->getID() == _animUnderCursor) {
notDialogueAnim = false;
break;
}
- }
-
+ }
+
if (notDialogueAnim) {
ret = -1;
} else {
@@ -927,7 +911,6 @@ void Game::dialogueDone() {
}
void Game::runDialogueProg(GPL2Program prog, int offset) {
-
// Mark last animation
int lastAnimIndex = _vm->_anims->getLastIndex();
@@ -970,11 +953,11 @@ int Game::getDialogueLastBlock() const {
}
int Game::getDialogueLinesNum() const {
- return _dialogueLinesNum;
+ return _dialogueLinesNum;
}
int Game::getDialogueCurrentBlock() const {
- return _currentBlock;
+ return _currentBlock;
}
int Game::getCurrentDialogueOffset() const {
@@ -1012,7 +995,6 @@ 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);
@@ -1039,7 +1021,6 @@ void Game::loadItem(int itemID) {
}
void Game::loadRoom(int roomNum) {
-
const BAFile *f;
f = _vm->_roomsArchive->getFile(roomNum * 4);
Common::MemoryReadStream roomReader(f->_data, f->_length);
@@ -1120,15 +1101,15 @@ void Game::loadRoom(int roomNum) {
loadObject(i);
}
}
-
- // Run the init scripts for room objects
+
+ // Run the init scripts for room objects
// We can't do this in the above loop because some objects' scripts reference
// other objects that may not yet be loaded
for (uint i = 0; i < _info._numObjects; ++i) {
if (_objects[i]._location == roomNum) {
const GameObject *obj = getObject(i);
debugC(6, kDraciLogicDebugLevel,
- "Running init program for object %d (offset %d)", i, obj->_init);
+ "Running init program for object %d (offset %d)", i, obj->_init);
_vm->_script->run(obj->_program, obj->_init);
}
}
@@ -1164,7 +1145,6 @@ 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);
@@ -1173,7 +1153,7 @@ int Game::loadAnimation(uint animNum, uint z) {
// FIXME: handle these properly
animationReader.readByte(); // Memory logic field, not used
animationReader.readByte(); // Disable erasing field, not used
-
+
bool cyclic = animationReader.readByte();
animationReader.readByte(); // Relative field, not used
@@ -1223,7 +1203,7 @@ int Game::loadAnimation(uint animNum, uint z) {
void Game::loadObject(uint objNum) {
const BAFile *file;
-
+
file = _vm->_objectsArchive->getFile(objNum * 3);
Common::MemoryReadStream objReader(file->_data, file->_length);
@@ -1246,9 +1226,9 @@ void Game::loadObject(uint objNum) {
obj->_useY = objReader.readUint16LE();
obj->_lookDir = objReader.readByte() - 1;
obj->_useDir = objReader.readByte() - 1;
-
+
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)
@@ -1262,7 +1242,6 @@ void Game::loadObject(uint objNum) {
}
void Game::loadWalkingMap(int mapID) {
-
const BAFile *f;
f = _vm->_walkingMapsArchive->getFile(mapID);
_currentRoom._walkingMap.load(f->_data, f->_length);
@@ -1277,34 +1256,32 @@ uint Game::getNumObjects() const {
}
void Game::loadOverlays() {
- uint x, y, z, num;
+ 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++) {
-
+ for (int i = 0; i < _currentRoom._numOverlays; i++) {
num = overlayReader.readUint16LE() - 1;
- x = overlayReader.readUint16LE();
- y = overlayReader.readUint16LE();
- z = overlayReader.readByte();
+ 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);
+ Sprite *sp = new Sprite(overlayFile->_data, overlayFile->_length, x, y, true);
- _vm->_anims->addOverlay(sp, z);
+ _vm->_anims->addOverlay(sp, z);
}
_vm->_overlaysArchive->clearCache();
- _vm->_screen->getSurface()->markDirty();
+ _vm->_screen->getSurface()->markDirty();
}
void Game::changeRoom(uint roomNum) {
-
debugC(1, kDraciLogicDebugLevel, "Changing to room %d", roomNum);
// Clear archives
@@ -1346,7 +1323,6 @@ void Game::changeRoom(uint roomNum) {
}
void Game::runGateProgram(int gate) {
-
debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", gate);
// Set the appropriate loop statu before executing the gate program
@@ -1364,7 +1340,6 @@ void Game::runGateProgram(int gate) {
}
void Game::positionAnimAsHero(Animation *anim) {
-
// Calculate scaling factors
const double scale = getPers0() + getPersStep() * _hero.y;
@@ -1387,7 +1362,7 @@ void Game::positionAnimAsHero(Animation *anim) {
// Since _persons[] is used for placing talking text, we use the non-adjusted x value
// so the text remains centered over the dragon.
- _persons[kDragonObject]._x = _hero.x;
+ _persons[kDragonObject]._x = _hero.x;
_persons[kDragonObject]._y = p.y;
// Set the per-animation scaling factor
@@ -1458,7 +1433,7 @@ int Game::getItemStatus(int itemID) const {
}
void Game::setItemStatus(int itemID, int status) {
- _itemStatus[itemID] = status;
+ _itemStatus[itemID] = status;
}
int Game::getCurrentItem() const {
@@ -1498,7 +1473,6 @@ int Game::getScheduledPalette() const {
* 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.
*/
-
int Game::getMarkedAnimationIndex() const {
return _markedAnimationIndex;
}
@@ -1541,7 +1515,6 @@ Game::~Game() {
bool WalkingMap::isWalkable(int x, int y) const {
-
// Convert to map pixels
x = x / _deltaX;
y = y / _deltaY;
@@ -1556,22 +1529,20 @@ bool WalkingMap::isWalkable(int x, int y) const {
/**
* @brief For a given point, find a nearest walkable point on the walking map
*
- * @param startX x coordinate of the point
- * @param startY y coordinate of the point
+ * @param startX x coordinate of the point
+ * @param startY y coordinate of the point
*
* @return A Common::Point representing the nearest walkable point
*
- * The algorithm was copied from the original engine for exactness.
- * TODO: Study this algorithm in more detail so it can be documented properly and
- * possibly improved / simplified.
+ * The algorithm was copied from the original engine for exactness.
+ * TODO: Study this algorithm in more detail so it can be documented properly and
+ * possibly improved / simplified.
*/
Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Rect searchRect) const {
-
// If the starting point is walkable, just return that
if (searchRect.contains(startX, startY) && isWalkable(startX, startY)) {
return Common::Point(startX, startY);
}
-
int signs[] = { 1, -1 };
const uint kSignsNum = 2;
@@ -1582,7 +1553,7 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re
int prediction;
// The place where, eventually, the result coordinates will be stored
- int finalX, finalY;
+ int finalX, finalY;
// The algorithm appears to start off with an ellipse with the minor radius equal to
// zero and the major radius equal to the walking map delta (the number of pixels
@@ -1592,7 +1563,6 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re
// It also does the same check for the ellipse perpendicular to it (rotated by 90 degrees).
while(1) {
-
// The default major radius
radius += _deltaX;
@@ -1606,7 +1576,6 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re
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.
@@ -1664,7 +1633,6 @@ Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Re
}
static double real_to_double(byte real[6]) {
-
// Extract sign bit
int sign = real[0] & (1 << 7);
@@ -1677,9 +1645,8 @@ static double real_to_double(byte real[6]) {
if (real[5] == 0) {
mantissa = 0.0;
} else {
-
// Process the first four least significant bytes
- for (int i = 4; i >= 1; --i) {
+ for (int i = 4; i >= 1; --i) {
tmp += real[i];
tmp /= 1 << 8;
}
@@ -1699,7 +1666,7 @@ static double real_to_double(byte real[6]) {
}
// Calculate final value
- return ldexp(mantissa, exp);
+ return ldexp(mantissa, exp);
}
}
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 861ba6292d..19bd27e6ff 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -70,7 +70,8 @@ enum {
};
enum {
- kNoDialogue = -1, kDialogueLines = 4
+ kNoDialogue = -1,
+ kDialogueLines = 4
};
enum {
@@ -94,8 +95,7 @@ enum InventoryConstants {
};
class WalkingMap {
-
-public:
+public:
WalkingMap() {
_realWidth = 0;
_realHeight = 0;
@@ -103,7 +103,7 @@ public:
_mapHeight = 0;
_byteWidth = 0;
_data = NULL;
- }
+ }
void load(const byte *data, uint length) {
Common::MemoryReadStream mapReader(data, length);
@@ -132,7 +132,6 @@ private:
};
struct GameObject {
-
uint _init, _look, _use, _canUse;
bool _imInit, _imLook, _imUse;
int _walkDir;
@@ -181,7 +180,7 @@ struct Dialogue {
};
struct Room {
- int _roomNum;
+ int _roomNum;
byte _music;
WalkingMap _walkingMap;
byte _palette;
@@ -213,9 +212,9 @@ enum LoopSubstatus {
/**
* Enumerates the animations for the dragon's movement.
*/
-
enum Movement {
- kMoveUndefined, kMoveDown, kMoveUp, kMoveRight, kMoveLeft,
+ kMoveUndefined,
+ kMoveDown, kMoveUp, kMoveRight, kMoveLeft,
kMoveRightDown, kMoveRightUp, kMoveLeftDown, kMoveLeftUp,
kMoveDownRight, kMoveUpRight, kMoveDownLeft, kMoveUpLeft,
kMoveLeftRight, kMoveRightLeft, kMoveUpStopLeft, kMoveUpStopRight,
@@ -223,9 +222,7 @@ enum Movement {
};
class Game {
-
public:
-
Game(DraciEngine *vm);
~Game();
@@ -395,7 +392,7 @@ private:
uint _speechTick;
int _objUnderCursor;
- int _oldObjUnderCursor;
+ int _oldObjUnderCursor;
int _animUnderCursor;
int _markedAnimationIndex; //!< Used by the Mark GPL command
diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp
index 054591931f..4f03ba7f82 100644
--- a/engines/draci/mouse.cpp
+++ b/engines/draci/mouse.cpp
@@ -39,7 +39,6 @@ Mouse::Mouse(DraciEngine *vm) {
}
void Mouse::handleEvent(Common::Event event) {
-
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
debugC(6, kDraciGeneralDebugLevel, "Left button down (x: %u y: %u)", _x, _y);
@@ -65,7 +64,7 @@ void Mouse::handleEvent(Common::Event event) {
debugC(6, kDraciGeneralDebugLevel, "Mouse move (x: %u y: %u)", _x, _y);
_x = (uint16) event.mouse.x;
_y = (uint16) event.mouse.y;
- break;
+ break;
default:
break;
@@ -97,18 +96,17 @@ 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(),
- sp.getWidth() / 2, sp.getHeight() / 2);
+ sp.getWidth() / 2, sp.getHeight() / 2);
}
void Mouse::loadItemCursor(int itemID, bool highlighted) {
-
const BAFile *f;
f = _vm->_itemImagesArchive->getFile(2 * itemID + 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(),
- sp.getWidth() / 2, sp.getHeight() / 2);
+ sp.getWidth() / 2, sp.getHeight() / 2);
}
}
diff --git a/engines/draci/mouse.h b/engines/draci/mouse.h
index 8a6496fda9..ad6476ebfa 100644
--- a/engines/draci/mouse.h
+++ b/engines/draci/mouse.h
@@ -32,10 +32,14 @@
namespace Draci {
enum CursorType {
- kNormalCursor, kArrowCursor1,
- kArrowCursor2, kArrowCursor3,
- kArrowCursor4, kDialogueCursor,
- kHighlightedCursor, kMainMenuCursor
+ kNormalCursor,
+ kArrowCursor1,
+ kArrowCursor2,
+ kArrowCursor3,
+ kArrowCursor4,
+ kDialogueCursor,
+ kHighlightedCursor,
+ kMainMenuCursor
};
class DraciEngine;
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index ad91157218..852ab6e8d0 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -46,26 +46,25 @@ Screen::~Screen() {
* @brief Sets the first numEntries of palette to zero
* @param numEntries The number of entries to set to zero (from start)
*/
-void Screen::setPaletteEmpty(unsigned int numEntries) {
- for (unsigned int i = 0; i < 4 * numEntries; ++i) {
+void Screen::setPaletteEmpty(uint numEntries) {
+ for (uint i = 0; i < 4 * numEntries; ++i) {
_palette[i] = 0;
}
_vm->_system->setPalette(_palette, 0, 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
+ * start Index of the colour where replacement should start
+ * num Number of colours to replace
*/
void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
-
Common::MemoryReadStream pal(data, 3 * kNumColours);
pal.seek(start * 4);
- // Copy the palette
+ // Copy the palette
for (uint16 i = start; i < start + num; ++i) {
_palette[i * 4] = pal.readByte();
_palette[i * 4 + 1] = pal.readByte();
@@ -75,7 +74,7 @@ void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
// TODO: Investigate why this is needed
// Shift the palette two bits to the left to make it brighter
- for (unsigned int i = 0; i < 4 * kNumColours; ++i) {
+ for (uint i = 0; i < 4 * kNumColours; ++i) {
_palette[i] <<= 2;
}
@@ -88,17 +87,16 @@ void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
void Screen::copyToScreen() {
const Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects();
Common::List<Common::Rect>::const_iterator it;
-
- // If a full update is needed, update the whole screen
+
+ // If a full update is needed, update the whole screen
if (_surface->needsFullUpdate()) {
byte *ptr = (byte *)_surface->getBasePtr(0, 0);
_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
@@ -141,10 +139,9 @@ void Screen::fillScreen(uint8 colour) {
/**
* @brief Draws a rectangle on the screen
* @param r Which rectangle to draw
- * colour The colour of the rectangle
+ * colour The colour of the rectangle
*/
void Screen::drawRect(Common::Rect r, uint8 colour) {
-
// Clip the rectangle to screen size
r.clip(_surface->w, _surface->h);
diff --git a/engines/draci/screen.h b/engines/draci/screen.h
index 2efa6625df..16981eb476 100644
--- a/engines/draci/screen.h
+++ b/engines/draci/screen.h
@@ -46,7 +46,7 @@ public:
Screen(DraciEngine *vm);
~Screen();
- void setPaletteEmpty(unsigned int numEntries = kNumColours);
+ void setPaletteEmpty(uint numEntries = kNumColours);
void setPalette(const byte *data, uint16 start, uint16 num);
const byte *getPalette() const;
void copyToScreen();
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 80bb25425e..e6d1576f17 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -210,7 +210,6 @@ int Script::operMod(int op1, int op2) const {
/* GPL functions */
int Script::funcRandom(int n) const {
-
// The function needs to return numbers in the [0..n-1] range so we need to deduce 1
// (RandomSource::getRandomNumber returns a number in the range [0..n])
@@ -220,7 +219,7 @@ int Script::funcRandom(int n) const {
int Script::funcAtBegin(int yesno) const {
return _vm->_game->isDialogueBegin() == (bool)yesno;
-}
+}
int Script::funcLastBlock(int blockID) const {
blockID -= 1;
@@ -230,7 +229,7 @@ int Script::funcLastBlock(int blockID) const {
int Script::funcBlockVar(int blockID) const {
blockID -= 1;
-
+
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID);
}
@@ -270,7 +269,6 @@ int Script::funcIsIcoAct(int itemID) const {
}
int Script::funcActIco(int itemID) const {
-
// The parameter seems to be an omission in the original player since it's not
// used in the implementation of the function. It's possible that the functions were
// implemented in such a way that they had to have a single parameter so this is only
@@ -304,12 +302,12 @@ int Script::funcObjStat(int objID) const {
if (obj->_location == _vm->_game->getRoomNum()) {
if (obj->_visible) {
- return 1; // object is ON (in the room and visible)
+ return 1; // object is ON (in the room and visible)
} else {
- return 2; // object is OFF (in the room, not visible)
+ return 2; // object is OFF (in the room, not visible)
}
} else {
- return 3; // object is AWAY (not in the room)
+ return 3; // object is AWAY (not in the room)
}
}
@@ -323,8 +321,7 @@ int Script::funcIsObjAway(int objID) const {
}
int Script::funcActPhase(int objID) const {
-
- objID -= 1;
+ objID -= 1;
// Default return value
int ret = 0;
@@ -388,7 +385,7 @@ void Script::load(Common::Queue<int> &params) {
// depend on this.
for(i = 0; i < obj->_anims.size(); ++i) {
- if (obj->_anims[i] > animID) {
+ if (obj->_anims[i] > animID) {
break;
}
}
@@ -402,7 +399,7 @@ void Script::start(Common::Queue<int> &params) {
}
int objID = params.pop() - 1;
- int animID = params.pop() - 1;
+ int animID = params.pop() - 1;
const GameObject *obj = _vm->_game->getObject(objID);
@@ -417,7 +414,7 @@ void Script::start(Common::Queue<int> &params) {
if (objID == kDragonObject)
_vm->_game->positionAnimAsHero(anim);
- anim->registerCallback(&Animation::stopAnimation);
+ anim->registerCallback(&Animation::stopAnimation);
bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
@@ -447,7 +444,7 @@ void Script::startPlay(Common::Queue<int> &params) {
if (objID == kDragonObject)
_vm->_game->positionAnimAsHero(anim);
- anim->registerCallback(&Animation::exitGameLoop);
+ anim->registerCallback(&Animation::exitGameLoop);
_vm->_game->setLoopSubstatus(kSubstatusStrange);
@@ -455,7 +452,7 @@ void Script::startPlay(Common::Queue<int> &params) {
if (objID == kDragonObject || visible) {
_vm->_anims->play(animID);
- }
+ }
_vm->_game->loop();
_vm->_game->setExitLoop(false);
@@ -515,19 +512,18 @@ void Script::icoStat(Common::Queue<int> &params) {
int itemID = params.pop() - 1;
_vm->_game->setItemStatus(itemID, status == 1);
-
- if (_vm->_game->getItemStatus(itemID) == 0) {
+ if (_vm->_game->getItemStatus(itemID) == 0) {
if (itemID != kNoItem) {
_vm->_anims->deleteAnimation(kInventoryItemsID - itemID);
}
- _vm->_game->removeItem(itemID);
+ _vm->_game->removeItem(itemID);
if (_vm->_game->getCurrentItem() == itemID) {
_vm->_game->setCurrentItem(kNoItem);
}
-
+
if (_vm->_mouse->getCursorType() == kNormalCursor) {
if (_vm->_game->getLoopStatus() == kStatusInventory) {
_vm->_mouse->cursorOff();
@@ -536,7 +532,6 @@ void Script::icoStat(Common::Queue<int> &params) {
}
if (_vm->_game->getItemStatus(itemID) == 1) {
-
if (itemID != kNoItem) {
Animation *itemAnim = _vm->_anims->addItem(kInventoryItemsID - itemID);
const BAFile *f = _vm->_itemImagesArchive->getFile(2 * itemID);
@@ -654,7 +649,6 @@ void Script::walkOnPlay(Common::Queue<int> &params) {
}
void Script::newRoom(Common::Queue<int> &params) {
-
if (_vm->_game->getLoopStatus() == kStatusInventory) {
return;
}
@@ -667,7 +661,6 @@ void Script::newRoom(Common::Queue<int> &params) {
}
void Script::talk(Common::Queue<int> &params) {
-
int personID = params.pop() - 1;
int sentenceID = params.pop() - 1;
@@ -693,7 +686,7 @@ void Script::talk(Common::Queue<int> &params) {
if (speechFrame->getWidth() >= kScreenWidth) {
speechFrame->setFont(_vm->_smallFont);
} else {
- speechFrame->setFont(_vm->_bigFont);
+ speechFrame->setFont(_vm->_bigFont);
}
// Set the loop substatus to an appropriate value
@@ -741,7 +734,6 @@ void Script::loadMap(Common::Queue<int> &params) {
}
void Script::resetDialogue(Common::Queue<int> &params) {
-
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
for (int i = 0; i < _vm->_game->getDialogueBlockNum(); ++i) {
@@ -750,7 +742,6 @@ void Script::resetDialogue(Common::Queue<int> &params) {
}
void Script::resetDialogueFrom(Common::Queue<int> &params) {
-
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
for (int i = _vm->_game->getDialogueCurrentBlock(); i < _vm->_game->getDialogueBlockNum(); ++i) {
@@ -771,13 +762,12 @@ void Script::exitDialogue(Common::Queue<int> &params) {
}
void Script::roomMap(Common::Queue<int> &params) {
-
// Load the default walking map for the room
_vm->_game->loadWalkingMap();
}
void Script::loadPalette(Common::Queue<int> &params) {
- int palette = params.pop() - 1;
+ int palette = params.pop() - 1;
_vm->_game->schedulePalette(palette);
}
@@ -788,11 +778,10 @@ void Script::blackPalette(Common::Queue<int> &params) {
}
void Script::setPalette(Common::Queue<int> &params) {
-
if (_vm->_game->getScheduledPalette() == -1) {
_vm->_screen->setPaletteEmpty();
} else {
- const BAFile *f;
+ const BAFile *f;
f = _vm->_paletteArchive->getFile(_vm->_game->getScheduledPalette());
_vm->_screen->setPalette(f->_data, 0, kNumColours);
}
@@ -806,7 +795,6 @@ void Script::endCurrentProgram() {
* @brief Evaluates mathematical expressions
* @param reader Stream reader set to the beginning of the expression
*/
-
int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
Common::Stack<int> stk;
mathExpressionObject obj;
@@ -826,7 +814,7 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
// Check whether the expression was evaluated correctly
// The stack should contain only one value after the evaluation
// i.e. the result of the expression
- assert(stk.size() == 1 && "Mathematical expression error");
+ assert(stk.size() == 1 && "Mathematical expression error");
break;
}
@@ -850,7 +838,7 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
// Calculate result
res = (this->*(oper._handler))(arg1, arg2);
-
+
// Push result
stk.push(res);
@@ -872,8 +860,8 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
// Fetch function
func = _functionList[value-1];
-
- // If not yet implemented
+
+ // If not yet implemented
if (func._handler == NULL) {
stk.pop();
@@ -881,7 +869,7 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
stk.push(0);
debugC(4, kDraciBytecodeDebugLevel, "\t\tcall: %s (not implemented)",
- func._name);
+ func._name);
} else {
arg1 = stk.pop();
@@ -890,9 +878,9 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
// Push the result on the evaluation stack
stk.push(res);
-
+
debugC(4, kDraciBytecodeDebugLevel, "\t\tcall: %s(%d) (res: %d)",
- func._name, arg1, res);
+ func._name, arg1, res);
}
break;
@@ -908,15 +896,14 @@ int Script::handleMathExpression(Common::MemoryReadStream *reader) const {
* @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)
+ * @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.
*/
bool Script::testExpression(const GPL2Program &program, uint16 offset) const {
-
// Initialize program reader
Common::MemoryReadStream reader(program._bytecode, program._length);
@@ -929,7 +916,7 @@ bool Script::testExpression(const GPL2Program &program, uint16 offset) const {
reader.seek(offset);
debugC(4, kDraciBytecodeDebugLevel,
- "Evaluating (standalone) GPL expression at offset %d:", offset);
+ "Evaluating (standalone) GPL expression at offset %d:", offset);
return (bool)handleMathExpression(&reader);
}
@@ -937,14 +924,14 @@ bool Script::testExpression(const GPL2Program &program, uint16 offset) const {
/**
* @brief Find the current command in the internal table
*
- * @param num Command number
- * @param subnum Command subnumer
+ * @param num Command number
+ * @param subnum Command subnumer
*
* @return NULL if command is not found. Otherwise, a pointer to a GPL2Command
* struct representing the command.
*/
const GPL2Command *Script::findCommand(byte num, byte subnum) const {
- unsigned int i = 0;
+ uint i = 0;
while (1) {
// Command not found
@@ -976,27 +963,26 @@ const GPL2Command *Script::findCommand(byte num, byte subnum) const {
* and their parameters. The syntax is as follows:
*
* Syntax of a command:
- * <name of the command> <number> <sub-number> <list of parameters...>
+ * <name of the command> <number> <sub-number> <list of parameters...>
*
- * Syntax of a parameter:
- * - 1: integer number literally passed to the program
- * - 2-1: string stored in the reservouir of game strings (i.e. something to be
- * displayed) and stored as an index in this list
- * - 2-2: string resolved by the compiler (i.e., a path to another file) and
- * replaced by an integer index of this entity in the appropriate namespace
- * (e.g., the index of the palette, location, ...)
- * - 3-0: relative jump to a label defined in this code. Each label must be
- * first declared in the beginning of the program.
- * - 3-1 .. 3-9: index of an entity in several namespaces, defined in file ident
- * - 4: mathematical expression compiled into a postfix format
+ * Syntax of a parameter:
+ * - 1: integer number literally passed to the program
+ * - 2-1: string stored in the reservouir of game strings (i.e. something to be
+ * displayed) and stored as an index in this list
+ * - 2-2: string resolved by the compiler (i.e., a path to another file) and
+ * replaced by an integer index of this entity in the appropriate namespace
+ * (e.g., the index of the palette, location, ...)
+ * - 3-0: relative jump to a label defined in this code. Each label must be
+ * first declared in the beginning of the program.
+ * - 3-1 .. 3-9: index of an entity in several namespaces, defined in file ident
+ * - 4: mathematical expression compiled into a postfix format
*
- * In the compiled program, parameters of type 1..3 are represented by a single
- * 16-bit integer. The called command knows by its definition what namespace the
- * value comes from.
+ * In the compiled program, parameters of type 1..3 are represented by a single
+ * 16-bit integer. The called command knows by its definition what namespace the
+ * value comes from.
*/
int Script::run(const GPL2Program &program, uint16 offset) {
-
int oldJump = _jump;
// Mark the last animation index before we do anything so a Release command
@@ -1016,7 +1002,7 @@ int Script::run(const GPL2Program &program, uint16 offset) {
// Seek to the requested part of the program
reader.seek(offset);
-
+
debugC(3, kDraciBytecodeDebugLevel,
"Starting GPL program at offset %d (program length: %d)", offset, program._length);
@@ -1024,10 +1010,10 @@ int Script::run(const GPL2Program &program, uint16 offset) {
do {
// Account for GPL jump that some commands set
- if (_jump != 0) {
+ if (_jump != 0) {
debugC(3, kDraciBytecodeDebugLevel,
"Jumping from offset %d to %d (%d bytes)",
- reader.pos(), reader.pos() + _jump, _jump);
+ reader.pos(), reader.pos() + _jump, _jump);
reader.seek(_jump, SEEK_CUR);
}
@@ -1060,19 +1046,17 @@ int Script::run(const GPL2Program &program, uint16 offset) {
for (int i = 0; i < cmd->_numParams; ++i) {
if (cmd->_paramTypes[i] == 4) {
debugC(3, kDraciBytecodeDebugLevel,
- "Evaluating (in-script) GPL expression at offset %d: ", offset);
+ "Evaluating (in-script) GPL expression at offset %d: ", offset);
params.push(handleMathExpression(&reader));
- }
- else {
+ } else {
tmp = reader.readSint16LE();
params.push(tmp);
debugC(2, kDraciBytecodeDebugLevel, "\t%d", tmp);
}
}
- }
- else {
+ } else {
debugC(1, kDraciBytecodeDebugLevel, "Unknown opcode %d, %d",
- num, subnum);
+ num, subnum);
abort();
}
@@ -1083,7 +1067,7 @@ int Script::run(const GPL2Program &program, uint16 offset) {
(this->*(cmd->_handler))(params);
}
- } while (cmd->_number != 0 && !_endProgram); // 0 = gplend and exit
+ } while (cmd->_number != 0 && !_endProgram); // 0 = gplend and exit
_endProgram = false;
_jump = oldJump;
@@ -1091,5 +1075,5 @@ int Script::run(const GPL2Program &program, uint16 offset) {
return 0;
}
-}
+} // end of namespace Draci
diff --git a/engines/draci/script.h b/engines/draci/script.h
index c594c6241c..fc0dc0cd74 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -43,14 +43,14 @@ enum {
};
// TODO(spalek): shouldn't modify params passed by reference. Either make it const or copy the parameter.
-typedef void (Script::* GPLHandler)(Common::Queue<int> &);
-typedef int (Script::* GPLOperatorHandler)(int, int) const;
-typedef int (Script::* GPLFunctionHandler)(int) const;
+typedef void (Script::*GPLHandler)(Common::Queue<int> &);
+typedef int (Script::*GPLOperatorHandler)(int, int) const;
+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
- * subnumber.
+ * Each command is represented in the bytecode by a command number and a
+ * subnumber.
*/
struct GPL2Command {
@@ -76,10 +76,9 @@ struct GPL2Function {
* A convenience data type that holds both the actual bytecode and the
* length of the bytecode. Passed to Script::run().
*/
-
struct GPL2Program {
GPL2Program() : _bytecode(NULL), _length(0) {}
-
+
byte *_bytecode;
uint16 _length;
};
@@ -87,14 +86,13 @@ struct GPL2Program {
class Script {
public:
- Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
+ Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
int run(const GPL2Program &program, uint16 offset);
bool testExpression(const GPL2Program &program, uint16 offset) const;
void endCurrentProgram();
private:
-
int _jump;
bool _endProgram;
@@ -110,7 +108,7 @@ private:
void start(Common::Queue<int> &params);
void mark(Common::Queue<int> &params);
void release(Common::Queue<int> &params);
- void icoStat(Common::Queue<int> &params);
+ void icoStat(Common::Queue<int> &params);
void objStat(Common::Queue<int> &params);
void objStatOn(Common::Queue<int> &params);
void execInit(Common::Queue<int> &params);
@@ -172,6 +170,6 @@ private:
DraciEngine *_vm;
};
-}
+} // end of namespace Draci
#endif // DRACI_SCRIPT_H
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index a41cc17a02..dca006ac65 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -37,21 +37,21 @@ const Displacement kNoDisplacement = { 0, 0, 1.0, 1.0 };
/**
* @brief Transforms an image from column-wise to row-wise
- * @param img pointer to the buffer containing the image data
- * width width of the image in the buffer
- * height height of the image in the buffer
+ * @param img pointer to the buffer containing the image data
+ * width width of the image in the buffer
+ * height height of the image in the buffer
*/
static void transformToRows(byte *img, uint16 width, uint16 height) {
byte *buf = new byte[width * height];
byte *tmp = buf;
memcpy(buf, img, width * height);
-
+
for (uint16 i = 0; i < width; ++i) {
for (uint16 j = 0; j < height; ++j) {
img[j * width + i] = *tmp++;
}
}
-
+
delete[] buf;
}
@@ -59,7 +59,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,
- bool columnwise) : _data(NULL) {
+ bool columnwise) : _data(NULL) {
_width = width;
_height = height;
@@ -81,23 +81,23 @@ Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y,
// If the sprite is stored column-wise, transform it to row-wise
if (columnwise) {
transformToRows(data, width, height);
- }
+ }
_data = data;
}
/**
* Constructor for loading sprites from a sprite-formatted buffer, one byte per
- * pixel.
+ * pixel.
*/
Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise)
- : _data(NULL) {
+ : _data(NULL) {
_x = x;
_y = y;
_delay = 0;
- _mirror = false;
+ _mirror = false;
Common::MemoryReadStream reader(sprite_data, length);
@@ -114,7 +114,7 @@ Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool column
// If the sprite is stored column-wise, transform it to row-wise
if (columnwise) {
transformToRows(data, _width, _height);
- }
+ }
_data = data;
}
@@ -130,9 +130,7 @@ void Sprite::setMirrorOff() {
_mirror = false;
}
-
int Sprite::getPixel(int x, int y, const Displacement &displacement) const {
-
Common::Rect rect = getRect(displacement);
int dy = y - rect.top;
@@ -153,7 +151,6 @@ int Sprite::getPixel(int x, int y, const Displacement &displacement) const {
void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement) const {
-
const Common::Rect destRect(getRect(displacement));
const Common::Rect surfaceRect(0, 0, surface->w, surface->h);
Common::Rect clippedDestRect(destRect);
@@ -178,7 +175,7 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement &
columnIndices[j] = (j + croppedBy.x) * _width / destRect.width();
}
} else {
- // Draw the sprite mirrored if the _mirror flag is set
+ // Draw the sprite mirrored if the _mirror flag is set
for (int j = 0; j < columns; ++j) {
columnIndices[j] = _width - 1 - (j + croppedBy.x) * _width / destRect.width();
}
@@ -186,11 +183,10 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement &
// Blit the sprite to the surface
for (int i = 0; i < rows; ++i) {
-
// Compute the index of current row to be drawn
const int row = (i + croppedBy.y) * _height / destRect.height();
const byte *row_data = _data + row * _width;
-
+
for (int j = 0; j < columns; ++j) {
// Fetch index of current column to be drawn
@@ -207,13 +203,12 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement &
}
// Mark the sprite's rectangle dirty
- if (markDirty) {
+ if (markDirty) {
surface->markDirtyRect(destRect);
}
delete[] columnIndices;
}
-
/**
* @brief Draws the sprite to a Draci::Surface
@@ -223,7 +218,6 @@ void Sprite::drawReScaled(Surface *surface, bool markDirty, const Displacement &
* 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 {
-
// TODO: refactor like drawReScaled()
Common::Rect sourceRect(0, 0, _width, _height);
@@ -237,7 +231,7 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const {
const int adjustLeft = clippedDestRect.left - destRect.left;
const int adjustRight = clippedDestRect.right - destRect.right;
const int adjustTop = clippedDestRect.top - destRect.top;
- const int adjustBottom = clippedDestRect.bottom - destRect.bottom;
+ const int adjustBottom = clippedDestRect.bottom - destRect.bottom;
// Resize source rectangle
sourceRect.left += adjustLeft;
@@ -258,13 +252,13 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const {
// Don't blit if the pixel is transparent on the target surface
if (src[i * _width + j] != transparent) {
- // Draw the sprite mirrored if the _mirror flag is set
+ // Draw the sprite mirrored if the _mirror flag is set
if (_mirror) {
dst[sourceRect.right - j - 1] = src[i * _width + j];
- } else {
+ } else {
dst[j] = src[i * _width + j];
}
- }
+ }
}
// Advance to next row
@@ -272,7 +266,7 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const {
}
// Mark the sprite's rectangle dirty
- if (markDirty) {
+ if (markDirty) {
surface->markDirtyRect(destRect);
}
}
@@ -280,16 +274,16 @@ void Sprite::draw(Surface *surface, bool markDirty, int relX, int relY) const {
Common::Rect Sprite::getRect(const Displacement &displacement) const {
return Common::Rect(_x + displacement.relX, _y + displacement.relY,
- _x + displacement.relX + (int) (_scaledWidth * displacement.extraScaleX),
- _y + displacement.relY + (int) (_scaledHeight * displacement.extraScaleY));
+ _x + displacement.relX + (int) (_scaledWidth * displacement.extraScaleX),
+ _y + displacement.relY + (int) (_scaledHeight * displacement.extraScaleY));
}
Text::Text(const Common::String &str, const Font *font, byte fontColour,
- int x, int y, uint spacing) {
+ int x, int y, uint spacing) {
_x = x;
_y = y;
_delay = 0;
-
+
_text = str;
_length = 0;
@@ -298,7 +292,7 @@ Text::Text(const Common::String &str, const Font *font, byte fontColour,
++_length;
}
}
-
+
_spacing = spacing;
_colour = fontColour;
@@ -312,7 +306,6 @@ Text::Text(const Common::String &str, const Font *font, byte fontColour,
}
void Text::setText(const Common::String &str) {
-
_width = _font->getStringWidth(str, _spacing);
_height = _font->getStringHeight(str);
@@ -353,7 +346,6 @@ void Text::setFont(const Font *font) {
_width = _font->getStringWidth(_text, _spacing);
_height = _font->getStringHeight(_text);
}
-
-} // End of namespace Draci
-
+
+} // End of namespace Draci
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index ce2d516437..bc6e44095b 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -31,7 +31,10 @@
namespace Draci {
-enum DrawableType { kDrawableText, kDrawableSprite };
+enum DrawableType {
+ kDrawableText,
+ kDrawableSprite
+};
struct Displacement {
int relX, relY;
@@ -40,7 +43,6 @@ struct Displacement {
extern const Displacement kNoDisplacement;
class Drawable {
-
public:
virtual void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const = 0;
virtual void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const = 0;
@@ -72,11 +74,11 @@ public:
virtual DrawableType getType() const = 0;
protected:
- uint _width; //!< Width of the sprite
- uint _height; //!< Height of the sprite
- uint _scaledWidth; //!< Scaled width of the sprite
+ uint _width; //!< Width of the sprite
+ uint _height; //!< Height of the sprite
+ uint _scaledWidth; //!< Scaled width of the sprite
uint _scaledHeight; //!< Scaled height of the sprite
- int _x, _y; //!< Sprite coordinates
+ int _x, _y; //!< Sprite coordinates
/** The time a drawable should stay on the screen
* before being replaced by another or deleted
@@ -91,17 +93,15 @@ protected:
* 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
- * [height * width bytes] image pixels stored column-wise, one byte per pixel
+ * Sprite format:
+ * [uint16LE] sprite width
+ * [uint16LE] sprite height
+ * [height * width bytes] image pixels stored column-wise, one byte per pixel
*/
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();
@@ -120,7 +120,7 @@ public:
DrawableType getType() const { return kDrawableSprite; }
private:
- const byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
+ const byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
bool _mirror;
};
@@ -128,9 +128,9 @@ class Text : public Drawable {
public:
Text(const Common::String &str, const Font *font, byte fontColour,
- int x, int y, uint spacing = 0);
+ int x, int y, uint spacing = 0);
~Text() {};
-
+
void setText(const Common::String &str);
void setColour(byte fontColour);
void setSpacing(uint spacing);
@@ -147,7 +147,6 @@ public:
Common::Rect getRect(const Displacement &displacement = kNoDisplacement) const;
DrawableType getType() const { return kDrawableText; }
-
private:
Common::String _text;
uint _length;
@@ -155,7 +154,7 @@ private:
uint _spacing;
const Font *_font;
};
-
+
} // End of namespace Draci
#endif // DRACI_SPRITE_H
diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp
index 872b228797..d56fcffdb6 100644
--- a/engines/draci/surface.cpp
+++ b/engines/draci/surface.cpp
@@ -52,7 +52,6 @@ void Surface::markDirtyRect(Common::Rect r) {
it = _dirtyRects.begin();
while (it != _dirtyRects.end()) {
-
if (it->contains(r))
return;
@@ -129,13 +128,12 @@ void Surface::fill(uint colour) {
/**
* @brief Calculates horizontal center of an object
*
- * @param x The x coordinate of the center
+ * @param x The x coordinate of the center
* @param width The width of the object to be centered (in pixels)
*
* @return The centered x coordinate
*/
uint Surface::centerOnX(uint x, uint width) const {
-
int newX = x - width / 2;
if (newX + width >= (uint)w - 1)
@@ -150,13 +148,12 @@ uint Surface::centerOnX(uint x, uint width) const {
/**
* @brief Calculates vertical center of an object
*
- * @param y The y coordinate of the center
+ * @param y The y coordinate of the center
* @param height The height of the object to be centered (in pixels)
*
* @return The centered y coordinate
*/
uint Surface::centerOnY(uint y, uint height) const {
-
int newY = y - height / 2;
if (newY + height >= (uint)h - 1)
@@ -171,7 +168,6 @@ uint Surface::centerOnY(uint y, uint height) const {
/**
* @brief Returns a Common::Rect corresponding to the surface.
*/
-
Common::Rect Surface::getRect() const {
return Common::Rect(w, h);
}
diff --git a/engines/draci/surface.h b/engines/draci/surface.h
index 5ce92bbd76..bb38b864d3 100644
--- a/engines/draci/surface.h
+++ b/engines/draci/surface.h
@@ -51,13 +51,13 @@ public:
private:
/** The current transparent colour of the surface. See getTransparentColour() and
- * setTransparentColour().
+ * setTransparentColour().
*/
uint _transparentColour;
-
+
/** Set when the surface is scheduled for a full update.
- * See markDirty(), markClean(). Accessed via needsFullUpdate().
- */
+ * See markDirty(), markClean(). Accessed via needsFullUpdate().
+ */
bool _fullUpdate;
Common::List<Common::Rect> _dirtyRects; //!< List of currently dirty rectangles