diff options
Diffstat (limited to 'engines/toon')
-rw-r--r-- | engines/toon/anim.cpp | 112 | ||||
-rw-r--r-- | engines/toon/anim.h | 58 | ||||
-rw-r--r-- | engines/toon/audio.cpp | 2 | ||||
-rw-r--r-- | engines/toon/character.cpp | 38 | ||||
-rw-r--r-- | engines/toon/detection.cpp | 5 | ||||
-rw-r--r-- | engines/toon/font.cpp | 46 | ||||
-rw-r--r-- | engines/toon/font.h | 6 | ||||
-rw-r--r-- | engines/toon/hotspot.cpp | 4 | ||||
-rw-r--r-- | engines/toon/hotspot.h | 4 | ||||
-rw-r--r-- | engines/toon/movie.cpp | 58 | ||||
-rw-r--r-- | engines/toon/movie.h | 14 | ||||
-rw-r--r-- | engines/toon/picture.cpp | 60 | ||||
-rw-r--r-- | engines/toon/picture.h | 24 | ||||
-rw-r--r-- | engines/toon/script_func.cpp | 4 | ||||
-rw-r--r-- | engines/toon/toon.cpp | 24 | ||||
-rw-r--r-- | engines/toon/toon.h | 5 |
16 files changed, 225 insertions, 239 deletions
diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp index 84f6fa375c..1c85a8d798 100644 --- a/engines/toon/anim.cpp +++ b/engines/toon/anim.cpp @@ -132,7 +132,7 @@ Common::Rect Animation::getRect() { return Common::Rect(_x1, _y1, _x2, _y2); } -void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy) { +void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy) { debugC(3, kDebugAnim, "drawFrame(surface, %d, %d, %d)", frame, xx, yy); if (frame < 0) frame = 0; @@ -146,10 +146,13 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int if (_frames[frame]._ref != -1) frame = _frames[frame]._ref; - int32 rectX = _frames[frame]._x2 - _frames[frame]._x1; - int32 rectY = _frames[frame]._y2 - _frames[frame]._y1; - int32 offsX = 0; - int32 offsY = 0; + if (!_frames[frame]._data) + return; + + int16 rectX = _frames[frame]._x2 - _frames[frame]._x1; + int16 rectY = _frames[frame]._y2 - _frames[frame]._y1; + int16 offsX = 0; + int16 offsY = 0; _vm->addDirtyRect(xx + _x1 + _frames[frame]._x1, yy + _y1 + _frames[frame]._y1, xx + rectX + _x1 + _frames[frame]._x1 , yy + rectY + _y1 + _frames[frame]._y1); @@ -186,10 +189,10 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int int32 destPitch = surface.pitch; uint8 *srcRow = _frames[frame]._data + offsX + (_frames[frame]._x2 - _frames[frame]._x1) * offsY; uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1 + offsY) * destPitch + (xx + _x1 + _frames[frame]._x1 + offsX); - for (int32 y = 0; y < rectY; y++) { + for (int16 y = 0; y < rectY; y++) { uint8 *cur = curRow; uint8 *c = srcRow + y * (_frames[frame]._x2 - _frames[frame]._x1); - for (int32 x = 0; x < rectX; x++) { + for (int16 x = 0; x < rectX; x++) { if (*c) *cur = *c; c++; @@ -199,27 +202,27 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int } } -void Animation::drawFrameWithMask(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask) { +void Animation::drawFrameWithMask(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask) { debugC(1, kDebugAnim, "drawFrameWithMask(surface, %d, %d, %d, %d, mask)", frame, xx, yy, zz); warning("STUB: drawFrameWithMask()"); } -void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask, int32 scale) { +void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale) { debugC(5, kDebugAnim, "drawFrameWithMaskAndScale(surface, %d, %d, %d, %d, mask, %d)", frame, xx, yy, zz, scale); if (_frames[frame]._ref != -1) frame = _frames[frame]._ref; - int32 rectX = _frames[frame]._x2 - _frames[frame]._x1; - int32 rectY = _frames[frame]._y2 - _frames[frame]._y1; + int16 rectX = _frames[frame]._x2 - _frames[frame]._x1; + int16 rectY = _frames[frame]._y2 - _frames[frame]._y1; - int32 finalWidth = rectX * scale / 1024; - int32 finalHeight = rectY * scale / 1024; + int16 finalWidth = rectX * scale / 1024; + int16 finalHeight = rectY * scale / 1024; // compute final x1, y1, x2, y2 - int32 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024; - int32 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024; - int32 xx2 = xx1 + finalWidth; - int32 yy2 = yy1 + finalHeight; - int32 w = _frames[frame]._x2 - _frames[frame]._x1; + int16 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024; + int16 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024; + int16 xx2 = xx1 + finalWidth; + int16 yy2 = yy1 + finalHeight; + int16 w = _frames[frame]._x2 - _frames[frame]._x1; _vm->addDirtyRect(xx1, yy1, xx2, yy2); @@ -233,8 +236,8 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram if (strstr(_name, "SHADOW")) shadowFlag = true; - for (int32 y = yy1; y < yy2; y++) { - for (int32 x = xx1; x < xx2; x++) { + for (int16 y = yy1; y < yy2; y++) { + for (int16 x = xx1; x < xx2; x++) { if (x < 0 || x >= 1280 || y < 0 || y >= 400) continue; @@ -242,8 +245,8 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram uint8 *curMask = curRowMask + x + y * destPitchMask; // find the good c - int32 xs = (x - xx1) * 1024 / scale; - int32 ys = (y - yy1) * 1024 / scale; + int16 xs = (x - xx1) * 1024 / scale; + int16 ys = (y - yy1) * 1024 / scale; uint8 *cc = &c[ys * w + xs]; if (*cc && ((*curMask) >= zz)) { if (shadowFlag) @@ -272,7 +275,7 @@ Common::Rect Animation::getFrameRect(int32 frame) { return Common::Rect(_frames[frame]._x1, _frames[frame]._y1, _frames[frame]._x2, _frames[frame]._y2); } -int32 Animation::getFrameWidth(int32 frame) { +int16 Animation::getFrameWidth(int32 frame) { debugC(4, kDebugAnim, "getFrameWidth(%d)", frame); if ((frame < 0) || (frame >= _numFrames)) return 0; @@ -283,7 +286,7 @@ int32 Animation::getFrameWidth(int32 frame) { return _frames[frame]._x2 - _frames[frame]._x1; } -int32 Animation::getFrameHeight(int32 frame) { +int16 Animation::getFrameHeight(int32 frame) { debugC(4, kDebugAnim, "getFrameHeight(%d)", frame); if (frame < 0 || frame >= _numFrames) return 0; @@ -294,15 +297,15 @@ int32 Animation::getFrameHeight(int32 frame) { return _frames[frame]._y2 - _frames[frame]._y1; } -int32 Animation::getWidth() const { +int16 Animation::getWidth() const { return _x2 - _x1; } -int32 Animation::getHeight() const { +int16 Animation::getHeight() const { return _y2 - _y1; } -void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, byte *colorMap) { +void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, byte *colorMap) { debugC(4, kDebugAnim, "drawFontFrame(surface, %d, %d, %d, colorMap)", frame, xx, yy); if (frame < 0) frame = 0; @@ -316,8 +319,8 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, if (_frames[frame]._ref != -1) frame = _frames[frame]._ref; - int32 rectX = _frames[frame]._x2 - _frames[frame]._x1; - int32 rectY = _frames[frame]._y2 - _frames[frame]._y1; + int16 rectX = _frames[frame]._x2 - _frames[frame]._x1; + int16 rectY = _frames[frame]._y2 - _frames[frame]._y1; if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0)) return; @@ -337,9 +340,9 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 destPitch = surface.pitch; uint8 *c = _frames[frame]._data; uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1) * destPitch + (xx + _x1 + _frames[frame]._x1); - for (int32 y = 0; y < rectY; y++) { + for (int16 y = 0; y < rectY; y++) { unsigned char *cur = curRow; - for (int32 x = 0; x < rectX; x++) { + for (int16 x = 0; x < rectX; x++) { if (*c && *c < 4) *cur = colorMap[*c]; c++; @@ -349,7 +352,7 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, } } -void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) { +void Animation::drawFrameOnPicture(int32 frame, int16 xx, int16 yy) { debugC(1, kDebugAnim, "drawFrameOnPicture(%d, %d, %d)", frame, xx, yy); if (frame < 0) frame = 0; @@ -363,8 +366,8 @@ void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) { if (_frames[frame]._ref != -1) frame = _frames[frame]._ref; - int32 rectX = _frames[frame]._x2 - _frames[frame]._x1; - int32 rectY = _frames[frame]._y2 - _frames[frame]._y1; + int16 rectX = _frames[frame]._x2 - _frames[frame]._x1; + int16 rectY = _frames[frame]._y2 - _frames[frame]._y1; Picture *pic = _vm->getPicture(); @@ -386,9 +389,9 @@ void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) { int32 destPitch = pic->getWidth(); uint8 *c = _frames[frame]._data; uint8 *curRow = (uint8 *)pic->getDataPtr() + (yy + _frames[frame]._y1 + _y1) * destPitch + (xx + _x1 + _frames[frame]._x1); - for (int32 y = 0; y < rectY; y++) { + for (int16 y = 0; y < rectY; y++) { unsigned char *cur = curRow; - for (int32 x = 0; x < rectX; x++) { + for (int16 x = 0; x < rectX; x++) { if (*c) *cur = *c; c++; @@ -455,8 +458,8 @@ void AnimationInstance::render() { if (frame >= _animation->_numFrames) frame = _animation->_numFrames - 1; - int32 x = _x; - int32 y = _y; + int16 x = _x; + int16 y = _y; if (_alignBottom) { int32 offsetX = (_animation->_x2 - _animation->_x1) / 2 * (_scale - 1024); @@ -498,7 +501,7 @@ void AnimationInstance::setAnimation(Animation *animation, bool setRange) { } } -void AnimationInstance::setAnimationRange(int32 rangeStart, int rangeEnd) { +void AnimationInstance::setAnimationRange(int32 rangeStart, int32 rangeEnd) { debugC(5, kDebugAnim, "setAnimationRange(%d, %d)", rangeStart, rangeEnd); _rangeStart = rangeStart; _rangeEnd = rangeEnd; @@ -510,7 +513,7 @@ void AnimationInstance::setAnimationRange(int32 rangeStart, int rangeEnd) { _currentFrame = _rangeEnd; } -void AnimationInstance::setPosition(int32 x, int32 y, int32 z, bool relative) { +void AnimationInstance::setPosition(int16 x, int16 y, int32 z, bool relative) { debugC(5, kDebugAnim, "setPosition(%d, %d, %d, %d)", x, y, z, (relative) ? 1 : 0); if (relative || !_animation) { _x = x; @@ -523,7 +526,7 @@ void AnimationInstance::setPosition(int32 x, int32 y, int32 z, bool relative) { } } -void AnimationInstance::moveRelative(int32 dx, int32 dy, int32 dz) { +void AnimationInstance::moveRelative(int16 dx, int16 dy, int32 dz) { debugC(1, kDebugAnim, "moveRelative(%d, %d, %d)", dx, dy, dz); _x += dx; _y += dy; @@ -568,13 +571,13 @@ void AnimationInstance::setUseMask(bool useMask) { _useMask = useMask; } -void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) const { +void AnimationInstance::getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) const { debugC(5, kDebugAnim, "getRect(%d, %d, %d, %d)", *x1, *y1, *x2, *y2); - int32 rectX = _animation->_frames[_currentFrame]._x2 - _animation->_frames[_currentFrame]._x1; - int32 rectY = _animation->_frames[_currentFrame]._y2 - _animation->_frames[_currentFrame]._y1; + int16 rectX = _animation->_frames[_currentFrame]._x2 - _animation->_frames[_currentFrame]._x1; + int16 rectY = _animation->_frames[_currentFrame]._y2 - _animation->_frames[_currentFrame]._y1; - int32 finalWidth = rectX * _scale / 1024; - int32 finalHeight = rectY * _scale / 1024; + int16 finalWidth = rectX * _scale / 1024; + int16 finalHeight = rectY * _scale / 1024; // compute final x1, y1, x2, y2 *x1 = _x + _animation->_x1 + _animation->_frames[_currentFrame]._x1 * _scale / 1024; @@ -583,7 +586,7 @@ void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) cons *y2 = *y1 + finalHeight; } -void AnimationInstance::setX(int32 x, bool relative) { +void AnimationInstance::setX(int16 x, bool relative) { debugC(1, kDebugAnim, "setX(%d, %d)", x, (relative) ? 1 : 0); if (relative || !_animation) _x = x; @@ -591,7 +594,7 @@ void AnimationInstance::setX(int32 x, bool relative) { _x = x - _animation->_x1; } -void AnimationInstance::setY(int32 y, bool relative) { +void AnimationInstance::setY(int16 y, bool relative) { debugC(1, kDebugAnim, "setY(%d, %d)", y, (relative) ? 1 : 0); if (relative || !_animation) _y = y; @@ -614,11 +617,11 @@ int32 AnimationInstance::getLayerZ() const { return _layerZ; } -int32 AnimationInstance::getX2() const { +int16 AnimationInstance::getX2() const { return _x + _animation->_x1; } -int32 AnimationInstance::getY2() const { +int16 AnimationInstance::getY2() const { return _y + _animation->_y1; } @@ -647,6 +650,7 @@ void AnimationInstance::save(Common::WriteStream *stream) { stream->writeSint32LE(_visible); stream->writeSint32LE(_useMask); } + void AnimationInstance::load(Common::ReadStream *stream) { _currentFrame = stream->readSint32LE(); _currentTime = stream->readSint32LE(); @@ -695,14 +699,13 @@ void AnimationManager::updateInstance(AnimationInstance* instance) { } void AnimationManager::addInstance(AnimationInstance *instance) { - // if the instance already exists, we skip the add for (uint32 i = 0; i < _instances.size(); i++) { if (_instances[i] == instance) return; } - int found = -1; + int32 found = -1; // here we now do an ordered insert (closer to the original game) for (uint32 i = 0; i < _instances.size(); i++) { @@ -712,11 +715,10 @@ void AnimationManager::addInstance(AnimationInstance *instance) { } } - if ( found == -1 ) { + if (found == -1) _instances.push_back(instance); - } else { + else _instances.insert_at(found, instance); - } } void AnimationManager::removeInstance(AnimationInstance *instance) { diff --git a/engines/toon/anim.h b/engines/toon/anim.h index eb8dcbd600..cd550b2621 100644 --- a/engines/toon/anim.h +++ b/engines/toon/anim.h @@ -36,10 +36,10 @@ class Picture; class ToonEngine; struct AnimationFrame { - int32 _x1; - int32 _y1; - int32 _x2; - int32 _y2; + int16 _x1; + int16 _y1; + int16 _x2; + int16 _y2; int32 _ref; uint8 *_data; }; @@ -49,10 +49,10 @@ public: Animation(ToonEngine *vm); ~Animation(); - int32 _x1; - int32 _y1; - int32 _x2; - int32 _y2; + int16 _x1; + int16 _y1; + int16 _x2; + int16 _y2; int32 _numFrames; int32 _fps; AnimationFrame *_frames; @@ -61,18 +61,18 @@ public: char _name[32]; bool loadAnimation(const Common::String &file); - void drawFrame(Graphics::Surface &surface, int32 frame, int32 x, int32 y); - void drawFontFrame(Graphics::Surface &surface, int32 frame, int32 x, int32 y, byte *colorMap); - void drawFrameOnPicture(int32 frame, int32 x, int32 y); - void drawFrameWithMask(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask); - void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask, int32 scale); + void drawFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y); + void drawFontFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y, byte *colorMap); + void drawFrameOnPicture(int32 frame, int16 x, int16 y); + void drawFrameWithMask(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask); + void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale); void drawStrip(int32 offset = 0); void applyPalette(int32 offset, int32 srcOffset, int32 numEntries); Common::Rect getFrameRect(int32 frame); - int32 getFrameWidth(int32 frame); - int32 getFrameHeight(int32 frame); - int32 getWidth() const; - int32 getHeight() const; + int16 getFrameWidth(int32 frame); + int16 getFrameHeight(int32 frame); + int16 getWidth() const; + int16 getHeight() const; Common::Rect getRect(); protected: ToonEngine *_vm; @@ -92,25 +92,25 @@ public: void renderOnPicture(); void setAnimation(Animation *animation, bool setRange = true); void playAnimation(); - void setAnimationRange(int32 rangeStart, int rangeEnd); + void setAnimationRange(int32 rangeStart, int32 rangeEnd); void setFps(int32 fps); void setLooping(bool enable); void stopAnimation(); void setFrame(int32 position); void forceFrame(int32 position); - void setPosition(int32 x, int32 y, int32 z, bool relative = false); + void setPosition(int16 x, int16 y, int32 z, bool relative = false); Animation *getAnimation() const { return _animation; } void setScale(int32 scale, bool align = false); void setVisible(bool visible); bool getVisible() const { return _visible; } void setUseMask(bool useMask); - void moveRelative(int32 dx, int32 dy, int32 dz); - void getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) const; - int32 getX() const { return _x; } - int32 getY() const { return _y; } + void moveRelative(int16 dx, int16 dy, int32 dz); + void getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) const; + int16 getX() const { return _x; } + int16 getY() const { return _y; } int32 getZ() const { return _z; } - int32 getX2() const; - int32 getY2() const; + int16 getX2() const; + int16 getY2() const; int32 getZ2() const; int32 getFrame() const { return _currentFrame; } void reset(); @@ -120,8 +120,8 @@ public: void setId(int32 id) { _id = id; } int32 getId() const { return _id; } - void setX(int32 x, bool relative = false); - void setY(int32 y, bool relative = false); + void setX(int16 x, bool relative = false); + void setY(int16 y, bool relative = false); void setZ(int32 z, bool relative = false); void setLayerZ(int32 layer); int32 getLayerZ() const; @@ -133,8 +133,8 @@ protected: int32 _currentTime; int32 _fps; Animation *_animation; - int32 _x; - int32 _y; + int16 _x; + int16 _y; int32 _z; int32 _layerZ; int32 _rangeStart; diff --git a/engines/toon/audio.cpp b/engines/toon/audio.cpp index 77822ab078..bc0e051057 100644 --- a/engines/toon/audio.cpp +++ b/engines/toon/audio.cpp @@ -326,7 +326,7 @@ bool AudioStreamInstance::readPacket() { } if (numDecompressedBytes > _bufferMaxSize) { - delete [] _buffer; + delete[] _buffer; _bufferMaxSize = numDecompressedBytes; _buffer = new int16[numDecompressedBytes]; } diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 09730626f2..479f4965f3 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -62,7 +62,7 @@ Character::Character(ToonEngine *vm) : _vm(vm) { _speed = 150; // 150 = nominal drew speed _lastWalkTime = 0; _numPixelToWalk = 0; - _nextIdleTime = _vm->getSystem()->getMillis() + (_vm->randRange(0, 600) + 300) * _vm->getTickLength(); + _nextIdleTime = _vm->_system->getMillis() + (_vm->randRange(0, 600) + 300) * _vm->getTickLength(); _lineToSayId = 0; } @@ -101,7 +101,7 @@ void Character::setFacing(int32 facing) { int32 dir = 0; - _lastWalkTime = _vm->getSystem()->getMillis(); + _lastWalkTime = _vm->_system->getMillis(); if ((_facing - facing + 8) % 8 > (facing - _facing + 8) % 8) dir = 1; else @@ -188,7 +188,7 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) { _currentPathNode = 0; stopSpecialAnim(); - _lastWalkTime = _vm->getSystem()->getMillis(); + _lastWalkTime = _vm->_system->getMillis(); _numPixelToWalk = 0; @@ -220,8 +220,8 @@ bool Character::walkTo(int16 newPosX, int16 newPosY) { } // in 1/1000 pixels - _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024; - _lastWalkTime = _vm->getSystem()->getMillis(); + _numPixelToWalk += _speed * (_vm->_system->getMillis() - _lastWalkTime) * _scale / 1024; + _lastWalkTime = _vm->_system->getMillis(); while (_numPixelToWalk >= 1000 && _currentPathNode < _currentPath.size()) { _x = _currentPath[_currentPathNode].x; @@ -356,8 +356,8 @@ void Character::update(int32 timeIncrement) { } // in 1/1000 pixels - _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024; - _lastWalkTime = _vm->getSystem()->getMillis(); + _numPixelToWalk += _speed * (_vm->_system->getMillis() - _lastWalkTime) * _scale / 1024; + _lastWalkTime = _vm->_system->getMillis(); while (_numPixelToWalk > 1000 && _currentPathNode < _currentPath.size()) { _x = _currentPath[_currentPathNode].x; @@ -534,35 +534,33 @@ int32 Character::getFacingFromDirection(int16 dx, int16 dy) { dx = -dx; int32 facingEntry = 0; - int32 ydiff = dy; + int16 ydiff = dy; if (ydiff < 0) { ++facingEntry; ydiff = -ydiff; } - facingEntry <<= 1; + facingEntry *= 2; - int32 xdiff = dx; + int16 xdiff = dx; if (xdiff < 0) { ++facingEntry; xdiff = -xdiff; } - facingEntry <<= 1; + facingEntry *= 2; if (xdiff >= ydiff) { - int32 temp = ydiff; + // Swap xdiff and ydiff + int16 temp = ydiff; ydiff = xdiff; xdiff = temp; - } else { - facingEntry += 1; - } - - facingEntry <<= 1; + } else + facingEntry++; - int32 temp = (ydiff + 1) >> 1; + facingEntry *= 2; - if (xdiff < temp) - facingEntry += 1; + if (xdiff < ((ydiff + 1) / 2)) + facingEntry++; return facingTable[facingEntry]; } diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp index 8234934972..3877fa2a6c 100644 --- a/engines/toon/detection.cpp +++ b/engines/toon/detection.cpp @@ -133,7 +133,7 @@ public: } virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { - return detectGameFilebased(allFiles, Toon::fileBasedFallback); + return detectGameFilebased(allFiles, fslist, Toon::fileBasedFallback); } virtual const char *getName() const { @@ -234,9 +234,6 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); desc.setThumbnail(thumbnail); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - uint32 saveDate = file->readUint32BE(); uint16 saveTime = file->readUint16BE(); diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp index d58663a00c..1e851ff4ae 100644 --- a/engines/toon/font.cpp +++ b/engines/toon/font.cpp @@ -65,10 +65,10 @@ byte FontRenderer::textToFont(byte c) { return map_textToFont[c - 0x80]; } -void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText, int32 mode) { +void FontRenderer::renderText(int16 x, int16 y, const Common::String &origText, int32 mode) { debugC(5, kDebugFont, "renderText(%d, %d, %s, %d)", x, y, origText.c_str(), mode); - int32 xx, yy; + int16 xx, yy; computeSize(origText, &xx, &yy); if (mode & 2) { @@ -83,8 +83,8 @@ void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText, _vm->addDirtyRect(x, y, x + xx, y + yy); - int32 curX = x; - int32 curY = y; + int16 curX = x; + int16 curY = y; int32 height = 0; const byte *text = (const byte *)origText.c_str(); @@ -98,20 +98,20 @@ void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText, curChar = textToFont(curChar); _currentFont->drawFontFrame(_vm->getMainSurface(), curChar, curX, curY, _currentFontColor); curX = curX + _currentFont->getFrameWidth(curChar) - 1; - height = MAX(height, _currentFont->getFrameHeight(curChar)); + height = MAX<int32>(height, _currentFont->getFrameHeight(curChar)); } text++; } } -void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int32 *retY) { +void FontRenderer::computeSize(const Common::String &origText, int16 *retX, int16 *retY) { debugC(4, kDebugFont, "computeSize(%s, retX, retY)", origText.c_str()); - int32 lineWidth = 0; - int32 lineHeight = 0; - int32 totalHeight = 0; - int32 totalWidth = 0; - int32 lastLineHeight = 0; + int16 lineWidth = 0; + int16 lineHeight = 0; + int16 totalHeight = 0; + int16 totalWidth = 0; + int16 lastLineHeight = 0; const byte *text = (const byte *)origText.c_str(); while (*text) { @@ -127,8 +127,8 @@ void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int3 lastLineHeight = 0; } else { curChar = textToFont(curChar); - int32 charWidth = _currentFont->getFrameWidth(curChar) - 1; - int32 charHeight = _currentFont->getFrameHeight(curChar); + int16 charWidth = _currentFont->getFrameWidth(curChar) - 1; + int16 charHeight = _currentFont->getFrameHeight(curChar); lineWidth += charWidth; lineHeight = MAX(lineHeight, charHeight); @@ -137,7 +137,7 @@ void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int3 // assume we only need to take the lower bound into // consideration. Common::Rect charRect = _currentFont->getFrameRect(curChar); - lastLineHeight = MAX<int32>(lastLineHeight, charRect.bottom); + lastLineHeight = MAX(lastLineHeight, charRect.bottom); } text++; } @@ -189,7 +189,7 @@ void FontRenderer::setFontColor(int32 fontColor1, int32 fontColor2, int32 fontCo _currentFontColor[3] = fontColor3; } -void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &origText, int32 mode) { +void FontRenderer::renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode) { debugC(5, kDebugFont, "renderMultiLineText(%d, %d, %s, %d)", x, y, origText.c_str(), mode); // divide the text in several lines @@ -204,10 +204,10 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o byte *it = text; - int32 maxWidth = 0; - int32 curWidth = 0; + int16 maxWidth = 0; + int16 curWidth = 0; - while (1) { + while (true) { byte *lastLine = it; byte *lastSpace = it; int32 lastSpaceX = 0; @@ -223,7 +223,7 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o curChar = textToFont(curChar); int width = _currentFont->getFrameWidth(curChar); - curWidth += MAX<int32>(width - 2, 0); + curWidth += MAX(width - 2, 0); it++; curLetterNr++; } @@ -260,8 +260,8 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o //numLines++; // get font height (assumed to be constant) - int32 height = _currentFont->getHeight(); - int textSize = (height - 2) * numLines; + int16 height = _currentFont->getHeight(); + int32 textSize = (height - 2) * numLines; y = y - textSize; if (y < 30) y = 30; @@ -278,8 +278,8 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o x = TOON_SCREEN_WIDTH - (maxWidth / 2) - 30; // we have good coordinates now, we can render the multi line - int32 curX = x; - int32 curY = y; + int16 curX = x; + int16 curY = y; for (int32 i = 0; i < numLines; i++) { const byte *line = lines[i]; diff --git a/engines/toon/font.h b/engines/toon/font.h index 349d9d1ee7..2a46ad3559 100644 --- a/engines/toon/font.h +++ b/engines/toon/font.h @@ -33,9 +33,9 @@ public: ~FontRenderer(); void setFont(Animation *font); - void computeSize(const Common::String &origText, int32 *retX, int32 *retY); - void renderText(int32 x, int32 y, const Common::String &origText, int32 mode); - void renderMultiLineText(int32 x, int32 y, const Common::String &origText, int32 mode); + void computeSize(const Common::String &origText, int16 *retX, int16 *retY); + void renderText(int16 x, int16 y, const Common::String &origText, int32 mode); + void renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode); void setFontColorByCharacter(int32 characterId); void setFontColor(int32 fontColor1, int32 fontColor2, int32 fontColor3); protected: diff --git a/engines/toon/hotspot.cpp b/engines/toon/hotspot.cpp index ce2cdf1bb9..8b8f0ab577 100644 --- a/engines/toon/hotspot.cpp +++ b/engines/toon/hotspot.cpp @@ -57,7 +57,7 @@ void Hotspots::save(Common::WriteStream *Stream) { } } -int32 Hotspots::FindBasedOnCorner(int32 x, int32 y) { +int32 Hotspots::FindBasedOnCorner(int16 x, int16 y) { debugC(1, kDebugHotspot, "FindBasedOnCorner(%d, %d)", x, y); for (int32 i = 0; i < _numItems; i++) { @@ -73,7 +73,7 @@ int32 Hotspots::FindBasedOnCorner(int32 x, int32 y) { return -1; } -int32 Hotspots::Find(int32 x, int32 y) { +int32 Hotspots::Find(int16 x, int16 y) { debugC(6, kDebugHotspot, "Find(%d, %d)", x, y); int32 priority = -1; diff --git a/engines/toon/hotspot.h b/engines/toon/hotspot.h index 70e80046e1..3852e2e42e 100644 --- a/engines/toon/hotspot.h +++ b/engines/toon/hotspot.h @@ -51,8 +51,8 @@ public: ~Hotspots(); bool LoadRif(const Common::String &rifName, const Common::String &additionalRifName); - int32 Find(int32 x, int32 y); - int32 FindBasedOnCorner(int32 x, int32 y); + int32 Find(int16 x, int16 y); + int32 FindBasedOnCorner(int16 x, int16 y); HotspotData *Get(int32 id); int32 getCount() const { return _numItems; } diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 8cdf92363f..8c85e20f7c 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -25,6 +25,7 @@ #include "common/keyboard.h" #include "common/stream.h" #include "common/system.h" +#include "graphics/palette.h" #include "graphics/surface.h" #include "toon/audio.h" @@ -33,6 +34,10 @@ namespace Toon { +ToonstruckSmackerDecoder::ToonstruckSmackerDecoder() : Video::SmackerDecoder() { + _lowRes = false; +} + void ToonstruckSmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize) { debugC(6, kDebugMovie, "handleAudioTrack(%d, %d, %d)", track, chunkSize, unpackedSize); @@ -40,33 +45,21 @@ void ToonstruckSmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, ui /* uint16 width = */ _fileStream->readUint16LE(); uint16 height = _fileStream->readUint16LE(); _lowRes = (height == getHeight() / 2); - } else + } else { Video::SmackerDecoder::handleAudioTrack(track, chunkSize, unpackedSize); + } } -bool ToonstruckSmackerDecoder::loadFile(const Common::String &filename) { - debugC(1, kDebugMovie, "loadFile(%s)", filename.c_str()); +bool ToonstruckSmackerDecoder::loadStream(Common::SeekableReadStream *stream) { + if (!Video::SmackerDecoder::loadStream(stream)) + return false; _lowRes = false; - - if (Video::SmackerDecoder::loadFile(filename)) { - if (_surface->h == 200) { - if (_surface) { - _surface->free(); - delete _surface; - } - _surface = new Graphics::Surface(); - _surface->create(640, 400, Graphics::PixelFormat::createFormatCLUT8()); - _header.flags = 4; - } - - return true; - } - return false; + return true; } -ToonstruckSmackerDecoder::ToonstruckSmackerDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) : Video::SmackerDecoder(mixer, soundType) { - _lowRes = false; +Video::SmackerDecoder::SmackerVideoTrack *ToonstruckSmackerDecoder::createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const { + return Video::SmackerDecoder::createVideoTrack(width, height, frameCount, frameRate, (height == 200) ? 4 : flags, signature); } // decoder is deallocated with Movie destruction i.e. new ToonstruckSmackerDecoder is needed @@ -103,46 +96,49 @@ void Movie::play(const Common::String &video, int32 flags) { bool Movie::playVideo(bool isFirstIntroVideo) { debugC(1, kDebugMovie, "playVideo(isFirstIntroVideo: %d)", isFirstIntroVideo); + + _decoder->start(); + while (!_vm->shouldQuit() && !_decoder->endOfVideo()) { if (_decoder->needsUpdate()) { const Graphics::Surface *frame = _decoder->decodeNextFrame(); if (frame) { if (_decoder->isLowRes()) { // handle manually 2x scaling here - Graphics::Surface* surf = _vm->getSystem()->lockScreen(); + Graphics::Surface* surf = _vm->_system->lockScreen(); for (int y = 0; y < frame->h / 2; y++) { memcpy(surf->getBasePtr(0, y * 2 + 0), frame->getBasePtr(0, y), frame->pitch); memcpy(surf->getBasePtr(0, y * 2 + 1), frame->getBasePtr(0, y), frame->pitch); } - _vm->getSystem()->unlockScreen(); + _vm->_system->unlockScreen(); } else { - _vm->getSystem()->copyRectToScreen(frame->pixels, frame->pitch, 0, 0, frame->w, frame->h); + _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, 0, 0, frame->w, frame->h); // WORKAROUND: There is an encoding glitch in the first intro video. This hides this using the adjacent pixels. if (isFirstIntroVideo) { int32 currentFrame = _decoder->getCurFrame(); if (currentFrame >= 956 && currentFrame <= 1038) { debugC(1, kDebugMovie, "Triggered workaround for glitch in first intro video..."); - _vm->getSystem()->copyRectToScreen(frame->getBasePtr(frame->w-188, 123), frame->pitch, frame->w-188, 124, 188, 1); - _vm->getSystem()->copyRectToScreen(frame->getBasePtr(frame->w-188, 126), frame->pitch, frame->w-188, 125, 188, 1); - _vm->getSystem()->copyRectToScreen(frame->getBasePtr(0, 125), frame->pitch, 0, 126, 64, 1); - _vm->getSystem()->copyRectToScreen(frame->getBasePtr(0, 128), frame->pitch, 0, 127, 64, 1); + _vm->_system->copyRectToScreen(frame->getBasePtr(frame->w-188, 123), frame->pitch, frame->w-188, 124, 188, 1); + _vm->_system->copyRectToScreen(frame->getBasePtr(frame->w-188, 126), frame->pitch, frame->w-188, 125, 188, 1); + _vm->_system->copyRectToScreen(frame->getBasePtr(0, 125), frame->pitch, 0, 126, 64, 1); + _vm->_system->copyRectToScreen(frame->getBasePtr(0, 128), frame->pitch, 0, 127, 64, 1); } } } } - _decoder->setSystemPalette(); - _vm->getSystem()->updateScreen(); + _vm->_system->getPaletteManager()->setPalette(_decoder->getPalette(), 0, 256); + _vm->_system->updateScreen(); } Common::Event event; - while (_vm->getSystem()->getEventManager()->pollEvent(event)) + while (_vm->_system->getEventManager()->pollEvent(event)) if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE)) { _vm->dirtyAllScreen(); return false; } - _vm->getSystem()->delayMillis(10); + _vm->_system->delayMillis(10); } _vm->dirtyAllScreen(); return !_vm->shouldQuit(); diff --git a/engines/toon/movie.h b/engines/toon/movie.h index 2cd33302f2..e795182cba 100644 --- a/engines/toon/movie.h +++ b/engines/toon/movie.h @@ -30,13 +30,17 @@ namespace Toon { class ToonstruckSmackerDecoder : public Video::SmackerDecoder { public: - ToonstruckSmackerDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType); - virtual ~ToonstruckSmackerDecoder() {} - void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize); - bool loadFile(const Common::String &filename); + ToonstruckSmackerDecoder(); + + bool loadStream(Common::SeekableReadStream *stream); bool isLowRes() { return _lowRes; } + protected: - bool _lowRes; + void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize); + SmackerVideoTrack *createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const; + +private: + bool _lowRes; }; class Movie { diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp index ff136e5acb..204b0fe576 100644 --- a/engines/toon/picture.cpp +++ b/engines/toon/picture.cpp @@ -150,7 +150,7 @@ void Picture::setupPalette() { _vm->setPaletteEntries(_palette, 1, 128); } -void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy) { +void Picture::drawMask(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy) { debugC(1, kDebugPicture, "drawMask(surface, %d, %d, %d, %d)", x, y, dx, dy); for (int32 i = 0; i < 128; i++) { @@ -161,8 +161,8 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i _vm->setPaletteEntries(color, i, 1); } - int32 rx = MIN(_width, surface.w - x); - int32 ry = MIN(_height, surface.h - y); + int16 rx = MIN<int16>(_width, surface.w - x); + int16 ry = MIN<int16>(_height, surface.h - y); if (rx < 0 || ry < 0) return; @@ -172,10 +172,10 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i uint8 *c = _data + _width * dy + dx; uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x; - for (int32 yy = 0; yy < ry; yy++) { + for (int16 yy = 0; yy < ry; yy++) { uint8 *curSrc = c; uint8 *cur = curRow; - for (int32 xx = 0; xx < rx; xx++) { + for (int16 xx = 0; xx < rx; xx++) { //*cur = (*curSrc >> 5) * 8; // & 0x1f; *cur = (*curSrc & 0x1f) ? 127 : 0; @@ -187,10 +187,9 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i } } -void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray) { - - int32 rx = MIN(_width, surface.w - x); - int32 ry = MIN(_height, surface.h - y); +void Picture::drawWithRectList(Graphics::Surface& surface, int16 x, int16 y, int16 dx, int16 dy, Common::Array<Common::Rect>& rectArray) { + int16 rx = MIN<int16>(_width, surface.w - x); + int16 ry = MIN<int16>(_height, surface.h - y); if (rx < 0 || ry < 0) return; @@ -202,16 +201,16 @@ void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int Common::Rect rect = rectArray[i]; - int32 fillRx = MIN<int32>(rx, rect.right - rect.left); - int32 fillRy = MIN<int32>(ry, rect.bottom - rect.top); + int16 fillRx = MIN<int32>(rx, rect.right - rect.left); + int16 fillRy = MIN<int32>(ry, rect.bottom - rect.top); uint8 *c = _data + _width * (dy + rect.top) + (dx + rect.left); uint8 *curRow = (uint8 *)surface.pixels + (y + rect.top) * destPitch + (x + rect.left); - for (int32 yy = 0; yy < fillRy; yy++) { + for (int16 yy = 0; yy < fillRy; yy++) { uint8 *curSrc = c; uint8 *cur = curRow; - for (int32 xx = 0; xx < fillRx; xx++) { + for (int16 xx = 0; xx < fillRx; xx++) { *cur = *curSrc; curSrc++; cur++; @@ -222,11 +221,11 @@ void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int } } -void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy) { +void Picture::draw(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy) { debugC(6, kDebugPicture, "draw(surface, %d, %d, %d, %d)", x, y, dx, dy); - int32 rx = MIN(_width, surface.w - x); - int32 ry = MIN(_height, surface.h - y); + int16 rx = MIN<int16>(_width, surface.w - x); + int16 ry = MIN<int16>(_height, surface.h - y); if (rx < 0 || ry < 0) return; @@ -236,10 +235,10 @@ void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 uint8 *c = _data + _width * dy + dx; uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x; - for (int32 yy = 0; yy < ry; yy++) { + for (int16 yy = 0; yy < ry; yy++) { uint8 *curSrc = c; uint8 *cur = curRow; - for (int32 xx = 0; xx < rx; xx++) { + for (int16 xx = 0; xx < rx; xx++) { *cur = *curSrc; curSrc++; cur++; @@ -249,7 +248,7 @@ void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 } } -uint8 Picture::getData(int32 x, int32 y) { +uint8 Picture::getData(int16 x, int16 y) { debugC(6, kDebugPicture, "getData(%d, %d)", x, y); if (!_data) @@ -259,7 +258,7 @@ uint8 Picture::getData(int32 x, int32 y) { } // use original work from johndoe -void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) { +void Picture::floodFillNotWalkableOnMask(int16 x, int16 y) { debugC(1, kDebugPicture, "floodFillNotWalkableOnMask(%d, %d)", x, y); // Stack-based floodFill algorithm based on // http://student.kuleuven.be/~m0216922/CG/files/floodfill.cpp @@ -292,10 +291,10 @@ void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) { } } -void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable) { +void Picture::drawLineOnMask(int16 x, int16 y, int16 x2, int16 y2, bool walkable) { debugC(1, kDebugPicture, "drawLineOnMask(%d, %d, %d, %d, %d)", x, y, x2, y2, (walkable) ? 1 : 0); - static int32 lastX = 0; - static int32 lastY = 0; + static int16 lastX = 0; + static int16 lastY = 0; if (x == -1) { x = lastX; @@ -303,12 +302,12 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable } uint32 bx = x << 16; - int32 dx = x2 - x; + int16 dx = x2 - x; uint32 by = y << 16; - int32 dy = y2 - y; - uint32 adx = abs(dx); - uint32 ady = abs(dy); - int32 t = 0; + int16 dy = y2 - y; + uint16 adx = abs(dx); + uint16 ady = abs(dy); + int16 t = 0; if (adx <= ady) t = ady; else @@ -317,9 +316,7 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable int32 cdx = (dx << 16) / t; int32 cdy = (dy << 16) / t; - int32 i = t; - while (i) { - + for (int16 i = t; i > 0; i--) { int32 rx = bx >> 16; int32 ry = by >> 16; @@ -337,7 +334,6 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable bx += cdx; by += cdy; - i--; } } } // End of namespace Toon diff --git a/engines/toon/picture.h b/engines/toon/picture.h index 460c5b58a2..5e79612a39 100644 --- a/engines/toon/picture.h +++ b/engines/toon/picture.h @@ -33,25 +33,27 @@ namespace Toon { class ToonEngine; -class Picture { +class Picture { public: Picture(ToonEngine *vm); ~Picture(); + bool loadPicture(const Common::String &file); void setupPalette(); - void draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy); - void drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray); - void drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy); - void drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable); - void floodFillNotWalkableOnMask(int32 x, int32 y); - uint8 getData(int32 x, int32 y); + void draw(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy); + void drawWithRectList(Graphics::Surface& surface, int16 x, int16 y, int16 dx, int16 dy, Common::Array<Common::Rect>& rectArray); + void drawMask(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy); + void drawLineOnMask(int16 x, int16 y, int16 x2, int16 y2, bool walkable); + void floodFillNotWalkableOnMask(int16 x, int16 y); + uint8 getData(int16 x, int16 y); uint8 *getDataPtr() { return _data; } - int32 getWidth() const { return _width; } - int32 getHeight() const { return _height; } + int16 getWidth() const { return _width; } + int16 getHeight() const { return _height; } + protected: - int32 _width; - int32 _height; + int16 _width; + int16 _height; uint8 *_data; uint8 *_palette; // need to be copied at 3-387 int32 _paletteEntries; diff --git a/engines/toon/script_func.cpp b/engines/toon/script_func.cpp index e9b7534198..1fa4058114 100644 --- a/engines/toon/script_func.cpp +++ b/engines/toon/script_func.cpp @@ -564,9 +564,9 @@ int32 ScriptFunc::sys_Cmd_Exit_Conversation(EMCState *state) { int32 ScriptFunc::sys_Cmd_Set_Mouse_Pos(EMCState *state) { if (_vm->state()->_inCloseUp) { - _vm->getSystem()->warpMouse(stackPos(0), stackPos(1)); + _vm->_system->warpMouse(stackPos(0), stackPos(1)); } else { - _vm->getSystem()->warpMouse(stackPos(0) - _vm->state()->_currentScrollValue, stackPos(1)); + _vm->_system->warpMouse(stackPos(0) - _vm->state()->_currentScrollValue, stackPos(1)); } return 0; } diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 416daa1fe8..9fd8415676 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -51,7 +51,7 @@ void ToonEngine::init() { _currentScriptRegion = 0; _resources = new Resources(this); _animationManager = new AnimationManager(this); - _moviePlayer = new Movie(this, new ToonstruckSmackerDecoder(_mixer)); + _moviePlayer = new Movie(this, new ToonstruckSmackerDecoder()); _hotspots = new Hotspots(this); _mainSurface = new Graphics::Surface(); @@ -820,7 +820,6 @@ Common::Error ToonEngine::run() { ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription), _language(gameDescription->language), _rnd("toon") { - _system = syst; _tickLength = 16; _currentPicture = NULL; _inventoryPicture = NULL; @@ -1224,7 +1223,7 @@ void ToonEngine::loadScene(int32 SceneId, bool forGameLoad) { _script->init(&_sceneAnimationScripts[i]._state, _sceneAnimationScripts[i]._data); if (!forGameLoad) { _script->start(&_sceneAnimationScripts[i]._state, 9 + i); - _sceneAnimationScripts[i]._lastTimer = getSystem()->getMillis(); + _sceneAnimationScripts[i]._lastTimer = _system->getMillis(); _sceneAnimationScripts[i]._frozen = false; _sceneAnimationScripts[i]._frozenForConversation = false; } @@ -1588,12 +1587,12 @@ void ToonEngine::clickEvent() { } void ToonEngine::selectHotspot() { - int32 x1 = 0; - int32 x2 = 0; - int32 y1 = 0; - int32 y2 = 0; + int16 x1 = 0; + int16 x2 = 0; + int16 y1 = 0; + int16 y2 = 0; - int32 mouseX = _mouseX; + int16 mouseX = _mouseX; if (_gameState->_inCutaway) mouseX += TOON_BACKBUFFER_WIDTH; @@ -1693,7 +1692,6 @@ void ToonEngine::selectHotspot() { } void ToonEngine::exitScene() { - fadeOut(5); // disable all scene animation @@ -2831,7 +2829,6 @@ void ToonEngine::playSoundWrong() { } void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) { - if (characterId < 0) characterId = 0; @@ -2852,8 +2849,8 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) { } } else if (characterId == 1) { // flux - int32 x = _flux->getX(); - int32 y = _flux->getY(); + int16 x = _flux->getX(); + int16 y = _flux->getY(); if (x >= _gameState->_currentScrollValue && x <= _gameState->_currentScrollValue + TOON_SCREEN_WIDTH) { if (!_gameState->_inCutaway) { *retX = x; @@ -2885,7 +2882,7 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) { if (character && !_gameState->_inCutaway) { if (character->getAnimationInstance()) { if (character->getX() >= _gameState->_currentScrollValue && character->getX() <= _gameState->_currentScrollValue + TOON_SCREEN_WIDTH) { - int32 x1, y1, x2, y2; + int16 x1, y1, x2, y2; character->getAnimationInstance()->getRect(&x1, &y1, &x2, &y2); *retX = (x1 + x2) / 2; *retY = y1; @@ -2896,7 +2893,6 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) { } Character *ToonEngine::getCharacterById(int32 charId) { - for (int32 i = 0; i < 8; i++) { if (_characters[i] && _characters[i]->getId() == charId) return _characters[i]; diff --git a/engines/toon/toon.h b/engines/toon/toon.h index 540f3e403b..d40c489011 100644 --- a/engines/toon/toon.h +++ b/engines/toon/toon.h @@ -289,10 +289,6 @@ public: return _oldTimer2; } - OSystem *getSystem() { - return _system; - } - AudioManager *getAudioManager() { return _audioManager; } @@ -340,7 +336,6 @@ public: void clearDirtyRects(); protected: - OSystem *_system; int32 _tickLength; Resources *_resources; TextResource *_genericTexts; |