[Scummvm-cvs-logs] SF.net SVN: scummvm:[53087] scummvm/trunk
sev at users.sourceforge.net
sev at users.sourceforge.net
Sat Oct 9 00:30:40 CEST 2010
Revision: 53087
http://scummvm.svn.sourceforge.net/scummvm/?rev=53087&view=rev
Author: sev
Date: 2010-10-08 22:30:39 +0000 (Fri, 08 Oct 2010)
Log Message:
-----------
TOON: Merged Toon engine to ScummVM trunk
Modified Paths:
--------------
scummvm/trunk/base/plugins.cpp
scummvm/trunk/configure
scummvm/trunk/engines/engines.mk
Added Paths:
-----------
scummvm/trunk/dists/engine-data/toon.dat
scummvm/trunk/engines/toon/
scummvm/trunk/engines/toon/anim.cpp
scummvm/trunk/engines/toon/anim.h
scummvm/trunk/engines/toon/audio.cpp
scummvm/trunk/engines/toon/audio.h
scummvm/trunk/engines/toon/character.cpp
scummvm/trunk/engines/toon/character.h
scummvm/trunk/engines/toon/conversation.cpp
scummvm/trunk/engines/toon/conversation.h
scummvm/trunk/engines/toon/detection.cpp
scummvm/trunk/engines/toon/drew.cpp
scummvm/trunk/engines/toon/drew.h
scummvm/trunk/engines/toon/flux.cpp
scummvm/trunk/engines/toon/flux.h
scummvm/trunk/engines/toon/font.cpp
scummvm/trunk/engines/toon/font.h
scummvm/trunk/engines/toon/hotspot.cpp
scummvm/trunk/engines/toon/hotspot.h
scummvm/trunk/engines/toon/module.mk
scummvm/trunk/engines/toon/movie.cpp
scummvm/trunk/engines/toon/movie.h
scummvm/trunk/engines/toon/path.cpp
scummvm/trunk/engines/toon/path.h
scummvm/trunk/engines/toon/picture.cpp
scummvm/trunk/engines/toon/picture.h
scummvm/trunk/engines/toon/resource.cpp
scummvm/trunk/engines/toon/resource.h
scummvm/trunk/engines/toon/script.cpp
scummvm/trunk/engines/toon/script.h
scummvm/trunk/engines/toon/script_func.cpp
scummvm/trunk/engines/toon/script_func.h
scummvm/trunk/engines/toon/state.cpp
scummvm/trunk/engines/toon/state.h
scummvm/trunk/engines/toon/text.cpp
scummvm/trunk/engines/toon/text.h
scummvm/trunk/engines/toon/tools.cpp
scummvm/trunk/engines/toon/tools.h
scummvm/trunk/engines/toon/toon.cpp
scummvm/trunk/engines/toon/toon.h
scummvm/trunk/tools/create_toon/
scummvm/trunk/tools/create_toon/create_toon.cpp
scummvm/trunk/tools/create_toon/create_toon.h
scummvm/trunk/tools/create_toon/dists/
scummvm/trunk/tools/create_toon/dists/msvc9/
scummvm/trunk/tools/create_toon/dists/msvc9/create_toon.sln
scummvm/trunk/tools/create_toon/dists/msvc9/create_toon.vcproj
scummvm/trunk/tools/create_toon/module.mk
scummvm/trunk/tools/create_toon/staticdata.h
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2010-10-08 22:17:03 UTC (rev 53086)
+++ scummvm/trunk/base/plugins.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -163,6 +163,9 @@
#if PLUGIN_ENABLED_STATIC(TINSEL)
LINK_PLUGIN(TINSEL)
#endif
+ #if PLUGIN_ENABLED_STATIC(TOON)
+ LINK_PLUGIN(TOON)
+ #endif
#if PLUGIN_ENABLED_STATIC(TOUCHE)
LINK_PLUGIN(TOUCHE)
#endif
Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure 2010-10-08 22:17:03 UTC (rev 53086)
+++ scummvm/trunk/configure 2010-10-08 22:30:39 UTC (rev 53087)
@@ -108,6 +108,7 @@
add_engine teenagent "Teen Agent" yes
add_engine testbed "TestBed: the Testing framework" no
add_engine tinsel "Tinsel" yes
+add_engine toon "Toonstruck" no
add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes
add_engine tucker "Bud Tucker in Double Trouble" yes
Added: scummvm/trunk/dists/engine-data/toon.dat
===================================================================
(Binary files differ)
Property changes on: scummvm/trunk/dists/engine-data/toon.dat
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: scummvm/trunk/engines/engines.mk
===================================================================
--- scummvm/trunk/engines/engines.mk 2010-10-08 22:17:03 UTC (rev 53086)
+++ scummvm/trunk/engines/engines.mk 2010-10-08 22:30:39 UTC (rev 53087)
@@ -156,6 +156,11 @@
MODULES += engines/tinsel
endif
+ifdef ENABLE_TOON
+DEFINES += -DENABLE_TOON=$(ENABLE_TOON)
+MODULES += engines/toon
+endif
+
ifdef ENABLE_TOUCHE
DEFINES += -DENABLE_TOUCHE=$(ENABLE_TOUCHE)
MODULES += engines/touche
Added: scummvm/trunk/engines/toon/anim.cpp
===================================================================
--- scummvm/trunk/engines/toon/anim.cpp (rev 0)
+++ scummvm/trunk/engines/toon/anim.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,703 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "anim.h"
+#include "toon.h"
+#include "tools.h"
+
+namespace Toon {
+
+bool Animation::loadAnimation(Common::String file) {
+ debugC(1, kDebugAnim, "loadAnimation(%s)", file.c_str());
+
+ uint32 fileSize = 0;
+ uint8 *fileData = _vm->resources()->getFileData(file, &fileSize);
+ if (!fileData)
+ return false;
+
+ strcpy(_name, "not_loaded");
+ if (strncmp((char *)fileData, "KevinAguilar", 12))
+ return false;
+
+ strcpy(_name, file.c_str());
+
+ uint32 headerSize = READ_LE_UINT32(fileData + 16);
+ uint32 uncompressedBytes = READ_LE_UINT32(fileData + 20);
+ uint32 compressedBytes = READ_LE_UINT32(fileData + 24);
+ _numFrames = READ_LE_UINT32(fileData + 28);
+ _x1 = READ_LE_UINT32(fileData + 32);
+ _y1 = READ_LE_UINT32(fileData + 36);
+ _x2 = READ_LE_UINT32(fileData + 40);
+ _y2 = READ_LE_UINT32(fileData + 44);
+ _paletteEntries = READ_LE_UINT32(fileData + 56);
+ _fps = READ_LE_UINT32(fileData + 60);
+ uint32 paletteSize = READ_LE_UINT32(fileData + 64);
+
+ uint8 *currentData = fileData + 68;
+ if (_paletteEntries) {
+ if (paletteSize) {
+ _palette = new uint8[paletteSize];
+ memcpy(_palette, currentData, paletteSize);
+ currentData += paletteSize;
+ } else {
+ _palette = 0;
+ }
+ }
+
+ byte *finalBuffer = new byte[uncompressedBytes];
+ if (uncompressedBytes > compressedBytes)
+ decompressLZSS(currentData, finalBuffer, uncompressedBytes);
+ else
+ memcpy(finalBuffer, currentData, uncompressedBytes);
+
+ if (READ_LE_UINT32(finalBuffer) == 0x12345678) {
+ uint8 *data = finalBuffer;
+ _frames = new AnimationFrame[_numFrames];
+ for (int32 e = 0; e < _numFrames; e++) {
+ if (READ_LE_UINT32(data) != 0x12345678)
+ return false;
+
+ int32 oldRef = READ_LE_UINT32(data + 4);
+ uint32 compressedSize = READ_LE_UINT32(data + 8);
+ uint32 decompressedSize = READ_LE_UINT32(data + 12);
+
+ _frames[e]._x1 = READ_LE_UINT32(data + 16);
+ _frames[e]._y1 = READ_LE_UINT32(data + 20);
+ _frames[e]._x2 = READ_LE_UINT32(data + 24);
+ _frames[e]._y2 = READ_LE_UINT32(data + 28);
+
+ uint8 *imageData = data + headerSize;
+ if (oldRef != -1 || decompressedSize == 0) {
+ _frames[e]._ref = oldRef;
+ _frames[e]._data = 0;
+ } else {
+ _frames[e]._ref = -1;
+ _frames[e]._data = new uint8[decompressedSize];
+ decompressLZSS(imageData, _frames[e]._data, decompressedSize);
+ }
+
+ data += headerSize + compressedSize;
+ }
+ }
+
+ delete[] finalBuffer;
+ return true;
+}
+
+Animation::Animation(ToonEngine *vm) : _vm(vm) {
+ _palette = 0;
+ _frames = 0;
+}
+
+Animation::~Animation() {
+ delete[] _palette;
+ for (int32 i = 0; i < _numFrames; i++) {
+ delete[] _frames[i]._data;
+ }
+ delete[] _frames;
+}
+
+Common::Rect Animation::getRect() {
+ debugC(5, kDebugAnim, "getRect");
+ return Common::Rect(_x1, _y1, _x2, _y2);
+}
+
+void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy) {
+ debugC(3, kDebugAnim, "drawFrame(surface, %d, %d, %d)", frame, xx, yy);
+ if (frame < 0)
+ frame = 0;
+
+ if (frame >= _numFrames)
+ frame = _numFrames - 1;
+
+ if (_numFrames == 0)
+ return;
+
+ 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;
+
+ if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0))
+ return;
+
+ if (rectX + xx + _x1 + _frames[frame]._x1 >= surface.w)
+ rectX = surface.w - xx - _x1 - _frames[frame]._x1;
+
+ if (rectX < 0)
+ return;
+
+ if (rectY + yy + _y1 + _frames[frame]._y1 >= surface.h)
+ rectY = surface.h - yy - _y1 - _frames[frame]._y1;
+
+ if (rectY < 0)
+ return;
+
+ int32 destPitch = surface.pitch;
+ uint8 *srcRow = _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++) {
+ uint8 *cur = curRow;
+ uint8 *c = srcRow + y * (_frames[frame]._x2 - _frames[frame]._x1);
+ for (int32 x = 0; x < rectX; x++) {
+ if (*c)
+ *cur = *c;
+ c++;
+ cur++;
+ }
+ curRow += destPitch;
+ }
+}
+
+void Animation::drawFrameWithMask(Graphics::Surface &surface, int32 frame, int32 xx, int32 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) {
+ 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;
+
+ int32 finalWidth = rectX * scale / 1024;
+ int32 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;
+// Strangerke - Commented (not used)
+// int32 h = _frames[frame]._y2 - _frames[frame]._y1;
+
+ int32 destPitch = surface.pitch;
+ int32 destPitchMask = mask->getWidth();
+ uint8 *c = _frames[frame]._data;
+ uint8 *curRow = (uint8 *)surface.pixels;
+ uint8 *curRowMask = mask->getDataPtr();
+
+ if (strstr(_name, "shadow")) {
+ for (int y = yy1; y < yy2; y++) {
+ for (int x = xx1; x < xx2; x++) {
+ if (x < 0 || x >= 1280 || y < 0 || y >= 400)
+ continue;
+
+ uint8 *cur = curRow + x + y * destPitch;
+ uint8 *curMask = curRowMask + x + y * destPitchMask;
+
+ // find the good c
+ int32 xs = (x - xx1) * 1024 / scale;
+ int32 ys = (y - yy1) * 1024 / scale;
+ uint8 *cc = &c[ys * w + xs];
+ if (*cc && ((*curMask) >= zz))
+ *cur = _vm->getShadowLUT()[*cur];
+ }
+ }
+ } else {
+ for (int y = yy1; y < yy2; y++) {
+ for (int x = xx1; x < xx2; x++) {
+ if (x < 0 || x >= 1280 || y < 0 || y >= 400)
+ continue;
+
+ uint8 *cur = curRow + x + y * destPitch;
+ uint8 *curMask = curRowMask + x + y * destPitchMask;
+
+ // find the good c
+ int32 xs = (x - xx1) * 1024 / scale;
+ int32 ys = (y - yy1) * 1024 / scale;
+ uint8 *cc = &c[ys * w + xs];
+ if (*cc && ((*curMask) >= zz))
+ *cur = *cc;
+ }
+ }
+ }
+}
+
+void Animation::applyPalette(int32 offset, int32 srcOffset, int32 numEntries) {
+ debugC(1, kDebugAnim, "applyPalette(%d, %d, %d)", offset, srcOffset, numEntries);
+ _vm->setPaletteEntries(_palette + srcOffset, offset, numEntries);
+}
+
+int32 Animation::getFrameWidth(int32 frame) {
+ debugC(4, kDebugAnim, "getFrameWidth(%d)", frame);
+ if ((frame < 0) || (frame >= _numFrames))
+ return 0;
+
+ if (_frames[frame]._ref != -1)
+ frame = _frames[frame]._ref;
+
+ return _frames[frame]._x2 - _frames[frame]._x1;
+}
+
+int32 Animation::getFrameHeight(int32 frame) {
+ debugC(4, kDebugAnim, "getFrameHeight(%d)", frame);
+ if (frame < 0 || frame >= _numFrames)
+ return 0;
+
+ if (_frames[frame]._ref != -1)
+ frame = _frames[frame]._ref;
+
+ return _frames[frame]._y2 - _frames[frame]._y1;
+}
+
+int32 Animation::getWidth() const {
+ return _x2 - _x1;
+}
+
+int32 Animation::getHeight() const {
+ return _y2 - _y1;
+}
+
+void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, byte *colorMap) {
+ debugC(4, kDebugAnim, "drawFontFrame(surface, %d, %d, %d, colorMap)", frame, xx, yy);
+ if (frame < 0)
+ frame = 0;
+
+ if (frame >= _numFrames)
+ frame = _numFrames - 1;
+
+ if (_numFrames == 0)
+ return;
+
+ 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;
+
+ if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0))
+ return;
+
+ if (rectX + xx + _x1 + _frames[frame]._x1 >= surface.w)
+ rectX = surface.w - xx - _x1 - _frames[frame]._x1;
+
+ if (rectX < 0)
+ return;
+
+ if (rectY + yy + _y1 + _frames[frame]._y1 >= surface.h)
+ rectY = surface.h - yy - _y1 - _frames[frame]._y1;
+
+ if (rectY < 0)
+ return;
+
+ 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++) {
+ unsigned char *cur = curRow;
+ for (int32 x = 0; x < rectX; x++) {
+ if (*c && *c < 4)
+ *cur = colorMap[*c];
+ c++;
+ cur++;
+ }
+ curRow += destPitch;
+ }
+}
+
+void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) {
+ debugC(1, kDebugAnim, "drawFrameOnPicture(%d, %d, %d)", frame, xx, yy);
+ if (frame < 0)
+ frame = 0;
+
+ if (frame >= _numFrames)
+ frame = _numFrames - 1;
+
+ if (_numFrames == 0)
+ return;
+
+ 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;
+
+ Picture *pic = _vm->getPicture();
+
+ if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0))
+ return;
+
+ if (rectX + xx + _x1 + _frames[frame]._x1 >= pic->getWidth())
+ rectX = pic->getWidth() - xx - _x1 - _frames[frame]._x1 ;
+
+ if (rectX < 0)
+ return;
+
+ if (rectY + yy + _y1 + _frames[frame]._y1 >= pic->getHeight())
+ rectY = pic->getHeight() - yy - _y1 - _frames[frame]._y1 ;
+
+ if (rectY < 0)
+ return;
+
+ 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++) {
+ unsigned char *cur = curRow;
+ for (int32 x = 0; x < rectX; x++) {
+ if (*c)
+ *cur = *c;
+ c++;
+ cur++;
+ }
+ curRow += destPitch;
+ }
+}
+
+void AnimationInstance::update(int32 timeIncrement) {
+ debugC(5, kDebugAnim, "update(%d)", timeIncrement);
+ if (_currentFrame == -1)
+ return;
+
+ if (_rangeStart == _rangeEnd) {
+ _currentFrame = _rangeStart;
+ return;
+ }
+
+ if (_playing) {
+ _currentTime += timeIncrement;
+ _currentFrame = _currentTime / (1000 / _fps);
+ }
+
+ if (_looping) {
+ _currentFrame = (_currentFrame % (_rangeEnd - _rangeStart + 1)) + _rangeStart;
+ } else {
+ if (_currentFrame >= _rangeEnd - _rangeStart) {
+ _playing = false;
+ _currentFrame = _rangeEnd;
+ } else {
+ _currentFrame = _rangeStart + _currentFrame;
+ }
+ }
+}
+
+AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type) : _vm(vm) {
+ _id = 0;
+ _type = type;
+ _animation = 0;
+ _currentFrame = 0;
+ _currentTime = 0;
+ _fps = 15;
+ _looping = true;
+ _playing = false;
+ _rangeEnd = 0;
+ _useMask = false;
+ _rangeStart = 0;
+ _scale = 1024;
+ _x = 0;
+ _y = 0;
+ _z = 0;
+ _layerZ = 0;
+}
+
+void AnimationInstance::render() {
+ debugC(5, kDebugAnim, "render()");
+ if (_visible && _animation) {
+ int32 frame = _currentFrame;
+ if (frame < 0)
+ frame = 0;
+
+ if (frame >= _animation->_numFrames)
+ frame = _animation->_numFrames - 1;
+
+ if (_useMask) {
+ //if (_scale == 100) { // 100% scale
+ // _animation->drawFrameWithMask(_vm->getMainSurface(), _currentFrame, _x, _y, _z, _vm->getMask());
+ //} else {
+ _animation->drawFrameWithMaskAndScale(_vm->getMainSurface(), frame, _x, _y, _z, _vm->getMask(), _scale);
+ //}
+ } else {
+ _animation->drawFrame(_vm->getMainSurface(), frame, _x, _y);
+ }
+ }
+}
+
+void AnimationInstance::renderOnPicture() {
+ debugC(5, kDebugAnim, "renderOnPicture()");
+ if (_visible && _animation)
+ _animation->drawFrameOnPicture(_currentFrame, _x, _y);
+}
+
+void AnimationInstance::playAnimation() {
+ debugC(6, kDebugAnim, "playAnimation()");
+ _playing = true;
+}
+
+void AnimationInstance::setAnimation(Animation *animation, bool setRange) {
+ debugC(5, kDebugAnim, "setAnimation(animation)");
+ _animation = animation;
+ if (animation && setRange) {
+ _rangeStart = 0;
+ _rangeEnd = animation->_numFrames - 1;
+ }
+}
+
+void AnimationInstance::setAnimationRange(int32 rangeStart, int rangeEnd) {
+ debugC(5, kDebugAnim, "setAnimationRange(%d, %d)", rangeStart, rangeEnd);
+ _rangeStart = rangeStart;
+ _rangeEnd = rangeEnd;
+
+ if (_currentFrame < _rangeStart)
+ _currentFrame = _rangeStart;
+
+ if (_currentFrame > _rangeEnd)
+ _currentFrame = _rangeEnd;
+}
+
+void AnimationInstance::setPosition(int32 x, int32 y, int32 z, bool relative) {
+ debugC(5, kDebugAnim, "setPosition(%d, %d, %d, %d)", x, y, z, (relative) ? 1 : 0);
+ if (relative || !_animation) {
+ _x = x;
+ _y = y;
+ _z = z;
+ } else {
+ _x = x - _animation->_x1 ;
+ _y = y - _animation->_y1;
+ _z = z;
+ }
+}
+
+void AnimationInstance::moveRelative(int32 dx, int32 dy, int32 dz) {
+ debugC(1, kDebugAnim, "moveRelative(%d, %d, %d)", dx, dy, dz);
+ _x += dx;
+ _y += dy;
+ _z += dz;
+}
+
+void AnimationInstance::forceFrame(int32 position) {
+ debugC(5, kDebugAnim, "forceFrame(%d)", position);
+ _currentFrame = position;
+ _rangeStart = position;
+ _rangeEnd = position;
+}
+
+void AnimationInstance::setFrame(int32 position) {
+ debugC(5, kDebugAnim, "setFrame(%d)", position);
+ _currentFrame = position;
+}
+
+void AnimationInstance::setFps(int32 fps) {
+ debugC(4, kDebugAnim, "setFps(%d)", fps);
+ _fps = fps;
+}
+
+void AnimationInstance::stopAnimation() {
+ debugC(5, kDebugAnim, "stopAnimation()");
+ _playing = false;
+}
+
+void AnimationInstance::setVisible(bool visible) {
+ debugC(1, kDebugAnim, "setVisible(%d)", (visible) ? 1 : 0);
+ _visible = visible;
+}
+
+void AnimationInstance::setScale(int32 scale) {
+ debugC(4, kDebugAnim, "setScale(%d)", scale);
+ _scale = scale;
+}
+
+void AnimationInstance::setUseMask(bool useMask) {
+ debugC(1, kDebugAnim, "setUseMask(%d)", (useMask) ? 1 : 0);
+ _useMask = useMask;
+}
+
+void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *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;
+
+ int32 finalWidth = rectX * _scale / 1024;
+ int32 finalHeight = rectY * _scale / 1024;
+
+ // compute final x1,y1,x2,y2
+ *x1 = _x + _animation->_x1 + _animation->_frames[_currentFrame]._x1 * _scale / 1024;
+ *y1 = _y + _animation->_y1 + _animation->_frames[_currentFrame]._y1 * _scale / 1024;
+ *x2 = *x1 + finalWidth;
+ *y2 = *y1 + finalHeight;
+}
+
+void AnimationInstance::setX(int32 x, bool relative) {
+ debugC(1, kDebugAnim, "setX(%d, %d)", x, (relative) ? 1 : 0);
+ if (relative || !_animation)
+ _x = x;
+ else
+ _x = x - _animation->_x1 ;
+}
+
+void AnimationInstance::setY(int32 y, bool relative) {
+ debugC(1, kDebugAnim, "setY(%d, %d)", y, (relative) ? 1 : 0);
+ if (relative || !_animation)
+ _y = y;
+ else
+ _y = y - _animation->_y1 ;
+}
+
+void AnimationInstance::setZ(int32 z, bool relative) {
+ debugC(1, kDebugAnim, "setZ(%d, %d)", z, (relative) ? 1 : 0);
+ _z = z;
+}
+
+void AnimationInstance::setLayerZ(int32 z) {
+ _layerZ = z;
+}
+
+int32 AnimationInstance::getLayerZ() const {
+ return _layerZ;
+}
+
+int32 AnimationInstance::getX2() const {
+ return _x + _animation->_x1 ;
+}
+
+int32 AnimationInstance::getY2() const {
+ return _y + _animation->_y1 ;
+}
+
+int32 AnimationInstance::getZ2() const {
+ return _z ;
+}
+
+void AnimationInstance::save(Common::WriteStream *stream) {
+ // we don't load the animation here
+ // it must be loaded externally to avoid leaks.
+ stream->writeSint32LE(_currentFrame);
+ stream->writeSint32LE(_currentTime);
+ stream->writeSint32LE(_layerZ);
+ stream->writeSint32LE(_x);
+ stream->writeSint32LE(_y);
+ stream->writeSint32LE(_z);
+ stream->writeSint32LE(_scale);
+ stream->writeSint32LE(_playing);
+ stream->writeSint32LE(_looping);
+ stream->writeSint32LE(_rangeStart);
+ stream->writeSint32LE(_rangeEnd);
+ stream->writeSint32LE(_rangeStart);
+ stream->writeSint32LE(_fps);
+ stream->writeSint32LE(_id);
+ stream->writeSint32LE(_type);
+ stream->writeSint32LE(_visible);
+ stream->writeSint32LE(_useMask);
+}
+void AnimationInstance::load(Common::ReadStream *stream) {
+ _currentFrame = stream->readSint32LE();
+ _currentTime = stream->readSint32LE();
+ _layerZ = stream->readSint32LE();
+ _x = stream->readSint32LE();
+ _y = stream->readSint32LE();
+ _z = stream->readSint32LE();
+ _scale = stream->readSint32LE();
+ _playing = stream->readSint32LE();
+ _looping = stream->readSint32LE();
+ _rangeStart = stream->readSint32LE();
+ _rangeEnd = stream->readSint32LE();
+ _rangeStart = stream->readSint32LE();
+ _fps = stream->readSint32LE();
+ _id = stream->readSint32LE();
+ _type = (AnimationInstanceType)stream->readSint32LE();
+ _visible = stream->readSint32LE();
+ _useMask = stream->readSint32LE();
+}
+
+
+
+void AnimationInstance::setLooping(bool enable) {
+ debugC(6, kDebugAnim, "setLooping(%d)", (enable) ? 1 : 0);
+ _looping = enable;
+}
+
+void AnimationInstance::reset() {
+ _currentFrame = 0;
+ _currentTime = 0;
+}
+
+AnimationManager::AnimationManager(ToonEngine *vm) : _vm(vm) {
+}
+
+void AnimationManager::addInstance(AnimationInstance *instance) {
+ _instances.push_back(instance);
+}
+
+void AnimationManager::removeInstance(AnimationInstance *instance) {
+ debugC(1, kDebugAnim, "removeInstance(instance)");
+ int32 found = -1;
+ for (uint32 i = 0; i < _instances.size(); i++) {
+ if (_instances[i] == instance) {
+ found = i;
+ break;
+ }
+ }
+
+ if (found > -1)
+ _instances.remove_at(found);
+}
+
+void AnimationManager::removeAllInstances(AnimationInstanceType type) {
+ debugC(1, kDebugAnim, "removeInstance(type)");
+ for (int32 i = (int32)_instances.size(); i >= 0 ; i--) {
+ if (_instances[i]->getType() & type)
+ _instances.remove_at(i);
+ }
+}
+
+void AnimationManager::update(int32 timeIncrement) {
+ debugC(5, kDebugAnim, "update(%d)", timeIncrement);
+ for (uint32 i = 0; i < _instances.size(); i++)
+ _instances[i]->update(timeIncrement);
+}
+
+void AnimationManager::render() {
+ debugC(5, kDebugAnim, "render()");
+ // sort the instance by layer z
+ // bubble sort (replace by faster afterwards)
+ bool changed = true;
+ while (changed) {
+ changed = false;
+ for (uint32 i = 0; i < _instances.size() - 1; i++) {
+ if ((_instances[i]->getLayerZ() > _instances[i + 1]->getLayerZ()) ||
+ ((_instances[i]->getLayerZ() == _instances[i + 1]->getLayerZ()) &&
+ (_instances[i]->getId() < _instances[i+1]->getId()))) {
+ AnimationInstance *instance = _instances[i];
+ _instances[i] = _instances[i + 1];
+ _instances[i + 1] = instance;
+ changed = true;
+ }
+ }
+ }
+
+ for (uint32 i = 0; i < _instances.size(); i++) {
+ if (_instances[i]->getVisible())
+ _instances[i]->render();
+ }
+}
+
+AnimationInstance *AnimationManager::createNewInstance(AnimationInstanceType type) {
+ return new AnimationInstance(_vm, type);
+}
+
+} // End of namespace Toon
Property changes on: scummvm/trunk/engines/toon/anim.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/anim.h
===================================================================
--- scummvm/trunk/engines/toon/anim.h (rev 0)
+++ scummvm/trunk/engines/toon/anim.h 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,194 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef TOON_ANIM_H
+#define TOON_ANIM_H
+
+#include "common/stream.h"
+#include "common/array.h"
+#include "common/func.h"
+#include "graphics/surface.h"
+
+#include "script.h"
+
+namespace Toon {
+
+class Picture;
+class ToonEngine;
+
+struct AnimationFrame {
+ int32 _x1;
+ int32 _y1;
+ int32 _x2;
+ int32 _y2;
+ int32 _ref;
+ uint8 *_data;
+};
+
+class Animation {
+public:
+ Animation(ToonEngine *vm);
+ ~Animation();
+
+ int32 _x1;
+ int32 _y1;
+ int32 _x2;
+ int32 _y2;
+ int32 _numFrames;
+ int32 _fps;
+ AnimationFrame *_frames;
+ uint8 *_palette;
+ int32 _paletteEntries;
+ char _name[32];
+
+ bool loadAnimation(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 drawStrip(int32 offset = 0);
+ void applyPalette(int32 offset, int32 srcOffset, int32 numEntries);
+ int32 getFrameWidth(int32 frame);
+ int32 getFrameHeight(int32 frame);
+ int32 getWidth() const;
+ int32 getHeight() const;
+ Common::Rect getRect();
+protected:
+ ToonEngine *_vm;
+};
+
+enum AnimationInstanceType {
+ kAnimationCharacter = 1,
+ kAnimationScene = 2,
+ kAnimationCursor = 4
+};
+
+class AnimationInstance {
+public:
+ AnimationInstance(ToonEngine *vm, AnimationInstanceType type);
+ void update(int32 timeIncrement);
+ void render();
+ void renderOnPicture();
+ void setAnimation(Animation *animation, bool setRange = true);
+ void playAnimation();
+ void setAnimationRange(int32 rangeStart, int 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);
+ Animation *getAnimation() const { return _animation; }
+ void setScale(int32 scale);
+ 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; };
+ int32 getZ() const { return _z; };
+ int32 getX2() const;
+ int32 getY2() const;
+ int32 getZ2() const;
+ int32 getFrame() const { return _currentFrame; };
+ void reset();
+ void save(Common::WriteStream *stream);
+ void load(Common::ReadStream *stream);
+
+ 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 setZ(int32 z, bool relative = false);
+ void setLayerZ(int32 layer);
+ int32 getLayerZ() const;
+
+ AnimationInstanceType getType() const { return _type; }
+
+protected:
+ int32 _currentFrame;
+ int32 _currentTime;
+ int32 _fps;
+ Animation *_animation;
+ int32 _x;
+ int32 _y;
+ int32 _z;
+ int32 _layerZ;
+ int32 _rangeStart;
+ int32 _rangeEnd;
+ int32 _scale;
+ int32 _id;
+
+ AnimationInstanceType _type;
+
+ bool _useMask;
+ bool _playing;
+ bool _looping;
+ bool _visible;
+
+ ToonEngine *_vm;
+};
+
+class AnimationManager {
+public:
+ AnimationManager(ToonEngine *vm);
+ AnimationInstance *createNewInstance(AnimationInstanceType type);
+ void addInstance(AnimationInstance *instance);
+ void removeInstance(AnimationInstance *instance);
+ void removeAllInstances(AnimationInstanceType type);
+ void render();
+ void update(int32 timeIncrement);
+
+protected:
+ ToonEngine *_vm;
+ Common::Array<AnimationInstance *> _instances;
+};
+
+class SceneAnimation {
+public:
+ AnimationInstance *_animInstance;
+ Animation *_animation;
+ int32 _id;
+ bool _active;
+
+ void load(ToonEngine* vm,Common::ReadStream *stream);
+ void save(ToonEngine* vm,Common::WriteStream *stream);
+};
+
+class SceneAnimationScript {
+public:
+ EMCData *_data;
+ EMCState _state;
+ uint32 _lastTimer;
+ bool _frozen;
+ bool _active;
+};
+
+} // End of namespace Toon
+
+#endif
Property changes on: scummvm/trunk/engines/toon/anim.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/audio.cpp
===================================================================
--- scummvm/trunk/engines/toon/audio.cpp (rev 0)
+++ scummvm/trunk/engines/toon/audio.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,443 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "audio.h"
+
+namespace Toon {
+
+static int ADPCM_index[8] = {
+ -1, -1, -1, -1, 2 , 4 , 6 , 8
+};
+static int ADPCM_table[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+};
+
+AudioManager::AudioManager(ToonEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
+ for (int32 i = 0; i < 16; i++)
+ _channels[i] = 0;
+}
+
+AudioManager::~AudioManager(void) {
+}
+
+void AudioManager::removeInstance(AudioStreamInstance *inst) {
+ debugC(1, kDebugAudio, "removeInstance(inst)");
+
+ for (int32 i = 0; i < 16; i++) {
+ if (inst == _channels[i])
+ _channels[i] = 0;
+ }
+}
+
+void AudioManager::playMusic(Common::String dir, Common::String music) {
+ debugC(1, kDebugAudio, "playMusic(%s, %s)", dir.c_str(), music.c_str());
+
+ // two musics can be played at same time
+ Common::String path = Common::String::printf("act%d/%s/%s.mus", _vm->state()->_currentChapter, dir.c_str(), music.c_str());;
+
+ if (_currentMusicName == music)
+ return;
+
+ _currentMusicName = music;
+
+ // see what channel to take
+ if (_channels[0] && _channels[0]->isPlaying() && _channels[1] && _channels[1]->isPlaying()) {
+ // take the one that is fading
+ if (_channels[0]->isFading()) {
+ _channels[0]->stop(false);
+ _channels[1]->stop(true);
+ _currentMusicChannel = 0;
+ } else {
+ _channels[1]->stop(false);
+ _channels[0]->stop(true);
+ _currentMusicChannel = 1;
+ }
+ } else if (_channels[0] && _channels[0]->isPlaying()) {
+ _channels[0]->stop(true);
+ _currentMusicChannel = 1;
+ } else {
+ if (_channels[1] && _channels[1]->isPlaying())
+ _channels[1]->stop(true);
+ _currentMusicChannel = 0;
+ }
+
+ Common::SeekableReadStream *srs = _vm->resources()->openFile(path);
+ //if (!_channels[_currentMusicChannel])
+ // delete _channels[_currentMusicChannel];
+ _channels[_currentMusicChannel] = new AudioStreamInstance(this, _mixer, srs, true);
+ _channels[_currentMusicChannel]->play(true, Audio::Mixer::kMusicSoundType);
+}
+
+bool AudioManager::voiceStillPlaying() {
+ if (!_channels[2])
+ return false;
+
+ return _channels[2]->isPlaying();
+}
+
+void AudioManager::playVoice(int32 id, bool genericVoice) {
+ debugC(1, kDebugAudio, "playVoice(%d, %d)", id, (genericVoice) ? 1 : 0);
+
+ if (voiceStillPlaying()) {
+ // stop current voice
+ _channels[2]->stop(false);
+ }
+
+ Common::SeekableReadStream *stream ;
+ if (genericVoice)
+ stream = _audioPacks[0]->getStream(id);
+ else
+ stream = _audioPacks[1]->getStream(id);
+
+ _channels[2] = new AudioStreamInstance(this, _mixer, stream);
+ _channels[2]->play(false, Audio::Mixer::kSpeechSoundType);
+
+}
+
+void AudioManager::playSFX(int32 id, int32 volume , bool genericSFX) {
+ debugC(4, kDebugAudio, "playSFX(%d, %d)", id, (genericSFX) ? 1 : 0);
+
+ // find a free SFX channel
+ Common::SeekableReadStream *stream ;
+
+ if (genericSFX)
+ stream = _audioPacks[2]->getStream(id, true);
+ else
+ stream = _audioPacks[3]->getStream(id, true);
+
+ if (stream->size() == 0)
+ return;
+
+ for (int32 i = 3; i < 16; i++) {
+ if (!_channels[i]) {
+ _channels[i] = new AudioStreamInstance(this, _mixer, stream);
+ _channels[i]->play(false, Audio::Mixer::kSFXSoundType);
+ _channels[i]->setVolume(volume);
+ break;
+ }
+ }
+}
+
+void AudioManager::stopCurrentVoice() {
+ debugC(1, kDebugAudio, "stopCurrentVoice()");
+
+ if (_channels[2] && _channels[2]->isPlaying())
+ _channels[2]->stop(false);
+}
+
+bool AudioManager::loadAudioPack(int32 id, Common::String indexFile, Common::String packFile) {
+ debugC(4, kDebugAudio, "loadAudioPack(%d, %s, %s)", id, indexFile.c_str(), packFile.c_str());
+
+ _audioPacks[id] = new AudioStreamPackage(_vm);
+ return _audioPacks[id]->loadAudioPackage(indexFile, packFile);
+}
+
+void AudioManager::setMusicVolume(int32 volume) {
+ debugC(1, kDebugAudio, "setMusicVolume(%d)", volume);
+ if (_channels[0])
+ _channels[0]->setVolume(volume);
+
+ if (_channels[1])
+ _channels[1]->setVolume(volume);
+}
+
+void AudioManager::stopMusic() {
+ debugC(1, kDebugAudio, "stopMusic()");
+
+ if (_channels[0])
+ _channels[0]->stop(true);
+ if (_channels[1])
+ _channels[1]->stop(true);
+}
+AudioStreamInstance::~AudioStreamInstance() {
+ if (_man)
+ _man->removeInstance(this);
+}
+
+AudioStreamInstance::AudioStreamInstance(AudioManager *man, Audio::Mixer *mixer, Common::SeekableReadStream *stream , bool looping) {
+ _compBufferSize = 0;
+ _buffer = 0;
+ _bufferMaxSize = 0;
+ _mixer = mixer;
+ _compBuffer = 0;
+ _bufferOffset = 0;
+ _lastADPCMval1 = 0;
+ _lastADPCMval2 = 0;
+ _file = stream;
+ _fadingIn = false;
+ _fadingOut = false;
+ _fadeTime = 0;
+ _stopped = false;
+ _volume = 255;
+ _totalSize = stream->size();
+ _currentReadSize = 8;
+ _man = man;
+ _looping = looping;
+ // preload one packet
+ if (_totalSize > 0) {
+ _file->skip(8);
+ readPacket();
+ } else {
+ stopNow();
+ }
+}
+
+int32 AudioStreamInstance::readBuffer(int16 *buffer, const int numSamples) {
+ debugC(5, kDebugAudio, "readBuffer(buffer, %d)", numSamples);
+
+ handleFade(numSamples);
+ int32 leftSamples = numSamples;
+ int32 destOffset = 0;
+ if ((_bufferOffset + leftSamples) * 2 >= _bufferSize) {
+ if (_bufferSize - _bufferOffset * 2 > 0) {
+ memcpy(buffer, &_buffer[_bufferOffset], _bufferSize - _bufferOffset * 2);
+ leftSamples -= (_bufferSize - _bufferOffset * 2) / 2;
+ destOffset += (_bufferSize - _bufferOffset * 2) / 2;
+ }
+ if (!readPacket())
+ return 0;
+
+ _bufferOffset = 0;
+ }
+
+ if (leftSamples >= 0) {
+ memcpy(buffer + destOffset, &_buffer[_bufferOffset], MIN(leftSamples * 2, _bufferSize));
+ _bufferOffset += leftSamples;
+ }
+
+ return numSamples;
+}
+
+bool AudioStreamInstance::readPacket() {
+ debugC(5, kDebugAudio, "readPacket()");
+
+ if (_file->eos() || (_currentReadSize >= _totalSize)) {
+ if (_looping) {
+ _file->seek(8);
+ _currentReadSize = 8;
+ } else {
+ _bufferSize = 0;
+ stopNow();
+ return false;
+ }
+ }
+ int16 numCompressedBytes = _file->readSint16LE();
+ int16 numDecompressedBytes = _file->readSint16LE();
+ _file->readSint32LE();
+
+ if (numCompressedBytes > _compBufferSize) {
+ if (_compBuffer)
+ delete[] _compBuffer;
+ _compBufferSize = numCompressedBytes;
+ _compBuffer = new uint8[_compBufferSize];
+ }
+
+ if (numDecompressedBytes > _bufferMaxSize) {
+ if (_buffer)
+ delete [] _buffer;
+ _bufferMaxSize = numDecompressedBytes;
+ _buffer = new int16[numDecompressedBytes];
+ }
+
+ _bufferSize = numDecompressedBytes;
+ _file->read(_compBuffer, numCompressedBytes);
+ _currentReadSize += 8 + numCompressedBytes;
+
+ decodeADPCM(_compBuffer, _buffer, numCompressedBytes);
+ return true;
+}
+
+void AudioStreamInstance::decodeADPCM(uint8 *comp, int16 *dest, int32 packetSize) {
+ debugC(5, kDebugAudio, "decodeADPCM(comp, dest, %d)", packetSize);
+
+ int32 numSamples = 2 * packetSize ;
+ int32 v18 = _lastADPCMval1;
+ int32 v19 = _lastADPCMval2;
+ for (int32 i = 0; i < numSamples; i++) {
+ uint8 comm = *comp;
+
+ int32 v29 = i & 1;
+ int32 v30;
+ if (v29 == 0)
+ v30 = comm & 0xf;
+ else
+ v30 = (comm & 0xf0) >> 4;
+
+ int32 v31 = v30 & 0x8;
+ int32 v32 = v30 & 0x7;
+ int32 v33 = ADPCM_table[v19];
+ int32 v34 = v33 >> 3;
+ if (v32 & 4)
+ v34 += v33;
+
+ if (v32 & 2)
+ v34 += v33 >> 1;
+
+ if (v32 & 1)
+ v34 += v33 >> 2;
+
+ v19 += ADPCM_index[v32];
+ if (v19 < 0)
+ v19 = 0;
+
+ if (v19 > 88)
+ v19 = 88;
+
+ if (v31)
+ v18 -= v34;
+ else
+ v18 += v34;
+
+ if (v18 > 32767)
+ v18 = 32767;
+ else if (v18 < -32768)
+ v18 = -32768;
+
+ *dest = v18;
+ comp += v29;
+ dest ++;
+ }
+
+ _lastADPCMval1 = v18;
+ _lastADPCMval2 = v19;
+}
+
+void AudioStreamInstance::play(bool fade, Audio::Mixer::SoundType soundType ) {
+ debugC(1, kDebugAudio, "play(%d)", (fade) ? 1 : 0);
+
+ Audio::SoundHandle soundHandle;
+ _stopped = false;
+ _fadingIn = fade;
+ _fadeTime = 0;
+ _mixer->playStream(soundType, &_handle, this);
+ handleFade(0);
+}
+
+void AudioStreamInstance::handleFade(int numSamples) {
+ debugC(5, kDebugAudio, "handleFade(%d)", numSamples);
+
+ if (_fadingOut) {
+ _fadeTime += numSamples;
+
+ if (_fadeTime > 40960) {
+ _fadeTime = 40960;
+ stopNow();
+ _fadingOut = false;
+ }
+
+ _mixer->setChannelVolume(_handle, _volume - _fadeTime * _volume / 40960);
+ } else {
+ if (_fadingIn) {
+ _fadeTime += numSamples;
+ if (_fadeTime > 40960) {
+ _fadeTime = 40960;
+ _fadingIn = false;
+ }
+
+ _mixer->setChannelVolume(_handle, _volume * _fadeTime / 40960);
+ }
+ }
+}
+
+void AudioStreamInstance::stop(bool fade /*= false*/) {
+ debugC(1, kDebugAudio, "stop(%d)", (fade) ? 1 : 0);
+
+ if (fade) {
+ _fadingIn = false;
+ _fadingOut = true;
+ _fadeTime = 0;
+ } else {
+ stopNow();
+ }
+}
+
+void AudioStreamInstance::stopNow() {
+ debugC(1, kDebugAudio, "stopNow()");
+
+ _stopped = true;
+}
+
+void AudioStreamInstance::setVolume(int32 volume) {
+ debugC(1, kDebugAudio, "setVolume(%d)", volume);
+
+ _volume = volume;
+ _mixer->setChannelVolume(_handle, volume);
+}
+
+AudioStreamPackage::AudioStreamPackage(ToonEngine *vm) : _vm(vm) {
+ _indexBuffer = 0;
+}
+
+bool AudioStreamPackage::loadAudioPackage(Common::String indexFile, Common::String streamFile) {
+ debugC(4, kDebugAudio, "loadAudioPackage(%s, %s)", indexFile.c_str(), streamFile.c_str());
+
+ uint32 size = 0;
+ uint8 *fileData = _vm->resources()->getFileData(indexFile, &size);
+ if (!fileData)
+ return false;
+
+ _indexBuffer = new uint32[size / 4];
+ memcpy(_indexBuffer, fileData, size);
+
+ _file = _vm->resources()->openFile(streamFile);
+ if (!_file)
+ return false;
+
+ return true;
+}
+
+void AudioStreamPackage::getInfo(int32 id, int32 *offset, int32 *size) {
+ debugC(1, kDebugAudio, "getInfo(%d, offset, size)", id);
+
+ *offset = READ_LE_UINT32(_indexBuffer + id);
+ *size = READ_LE_UINT32(_indexBuffer + id + 1) - READ_LE_UINT32(_indexBuffer + id);
+}
+
+Common::SeekableReadStream *AudioStreamPackage::getStream(int32 id, bool ownMemory) {
+ debugC(1, kDebugAudio, "getStream(%d, %d)", id, (ownMemory) ? 1 : 0);
+
+ int32 offset = 0;
+ int32 size = 0;
+ getInfo(id, &offset, &size);
+ if (ownMemory) {
+ byte *memory = new byte[size];
+ _file->seek(offset);
+ _file->read(memory, size);
+ return new Common::MemoryReadStream(memory, size, DisposeAfterUse::YES);
+ } else {
+ return new Common::SeekableSubReadStream(_file, offset, size + offset);
+ }
+}
+
+} // End of namespace Toon
+
Property changes on: scummvm/trunk/engines/toon/audio.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/audio.h
===================================================================
--- scummvm/trunk/engines/toon/audio.h (rev 0)
+++ scummvm/trunk/engines/toon/audio.h 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,143 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef TOON_AUDIO_H
+#define TOON_AUDIO_H
+
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
+#include "toon.h"
+
+namespace Toon {
+
+// used for music/voice/everything
+class AudioManager;
+class AudioStreamInstance : public Audio::AudioStream {
+
+public:
+ AudioStreamInstance(AudioManager *man, Audio::Mixer *mixer, Common::SeekableReadStream *stream, bool looping = false);
+ ~AudioStreamInstance();
+ void play(bool fade = false, Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
+ void stop(bool fade = false);
+
+ bool isPlaying() {
+ return !_stopped;
+ }
+ bool isLooping() {
+ return _looping;
+ }
+ bool isFading() {
+ return _fadingIn || _fadingOut;
+ }
+
+ void setVolume(int32 volume);
+protected:
+ int32 readBuffer(int16 *buffer, const int numSamples);
+ bool isStereo() const {
+ return false;
+ };
+ int getRate() const {
+ return 22100;
+ };
+ bool endOfData() const {
+ return _stopped;
+ };
+ void handleFade(int32 numSamples);
+ void stopNow();
+
+ bool readPacket();
+ void decodeADPCM(uint8 *comp, int16 *dest, int32 packetSize);
+
+ Common::SeekableReadStream *_file;
+ bool _fadingIn;
+ bool _fadingOut;
+ int32 _fadeTime;
+ uint8 *_compBuffer;
+ int16 *_buffer;
+ int32 _bufferSize;
+ int32 _bufferMaxSize;
+ int32 _bufferOffset;
+ int32 _compBufferSize;
+ Audio::SoundHandle _handle;
+ Audio::Mixer *_mixer;
+ int32 _lastADPCMval1;
+ int32 _lastADPCMval2;
+ bool _stopped;
+ AudioManager *_man;
+ int32 _totalSize;
+ int32 _currentReadSize;
+ bool _looping;
+ int32 _volume;
+};
+
+class AudioStreamPackage {
+
+public:
+ AudioStreamPackage(ToonEngine *vm);
+ bool loadAudioPackage(Common::String indexFile, Common::String streamFile);
+ void getInfo(int32 id, int32 *offset, int32 *size);
+ Common::SeekableReadStream *getStream(int32 id, bool ownMemory = false);
+protected:
+ Common::SeekableReadStream *_file;
+ uint32 *_indexBuffer;
+ ToonEngine *_vm;
+};
+
+class AudioManager {
+public:
+ void removeInstance(AudioStreamInstance *inst); // called by destructor
+
+ AudioManager(ToonEngine *vm, Audio::Mixer *mixer);
+ ~AudioManager(void);
+
+ bool voiceStillPlaying();
+
+ void playMusic(Common::String dir, Common::String music);
+ void playVoice(int32 id, bool genericVoice);
+ void playSFX(int32 id, int volume, bool genericSFX);
+ void stopCurrentVoice();
+ void setMusicVolume(int32 volume);
+ void stopMusic();
+
+
+ bool loadAudioPack(int32 id, Common::String indexFile, Common::String packFile);
+
+ AudioStreamInstance *_channels[16]; // 0-1 : music
+ // 2 : voice
+ // 3-16 : SFX
+
+ AudioStreamPackage *_audioPacks[4]; // 0 : generic streams
+ // 1 : local streams
+ // 2 : generic SFX
+ // 3 : local SFX
+ uint32 _currentMusicChannel;
+ Common::String _currentMusicName;
+ ToonEngine *_vm;
+ Audio::Mixer *_mixer;
+};
+
+} // End of namespace Toon
+
+#endif
Property changes on: scummvm/trunk/engines/toon/audio.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/character.cpp
===================================================================
--- scummvm/trunk/engines/toon/character.cpp (rev 0)
+++ scummvm/trunk/engines/toon/character.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,1024 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* $URL$
+* $Id$
+*
+*/
+
+#include "character.h"
+#include "drew.h"
+#include "path.h"
+
+namespace Toon {
+
+Character::Character(ToonEngine *vm) : _vm(vm) {
+ _animationInstance = 0;
+ _shadowAnimationInstance = 0;
+ _shadowAnim = 0;
+ _x = 0;
+ _y = 0;
+ _z = 0;
+ _finalX = 0;
+ _finalY = 0;
+ _specialAnim = 0;
+ _sceneAnimationId = -1;
+ _idleAnim = 0;
+ _walkAnim = 0;
+ _talkAnim = 0;
+ _facing = 0;
+ _flags = 0;
+ _animFlags = 0;
+ _id = 0;
+ _scale = 1024;
+ _blockingWalk = false;
+ _animScriptId = -1;
+ _animSpecialId = -1;
+ _animSpecialDefaultId = 0;
+ _currentPathNodeCount = 0;
+ _currentPathNode = 0;
+ _visible = true;
+ _speed = 150; // 150 = nominal drew speed
+ _lastWalkTime = 0;
+ _numPixelToWalk = 0;
+ _nextIdleTime = _vm->getSystem()->getMillis() + (_vm->randRange(0, 600) + 300) * _vm->getTickLength();
+}
+
+Character::~Character(void) {
+}
+
+void Character::init() {
+
+}
+
+void Character::setFacing(int32 facing) {
+ debugC(4, kDebugCharacter, "setFacing(%d)", facing);
+ _facing = facing;
+}
+
+void Character::setPosition(int32 x, int32 y) {
+ debugC(5, kDebugCharacter, "setPosition(%d, %d)", x, y);
+
+ _x = x;
+ _y = y;
+ if (_animationInstance)
+ _animationInstance->setPosition(_x, _y, _z);
+ return;
+}
+
+bool Character::walkTo(int32 newPosX, int32 newPosY) {
+ debugC(1, kDebugCharacter, "walkTo(%d, %d)", newPosX, newPosY);
+
+ if (!_visible)
+ return true;
+
+ if (_x == newPosX && _y == newPosY)
+ return true;
+
+ _vm->getPathFinding()->resetBlockingRects();
+
+ if (_id == 1) {
+ int32 sizeX = MAX(5,40 * _vm->getDrew()->getScale() / 1024);
+ int32 sizeY = MAX(2,20 * _vm->getDrew()->getScale() / 1024);
+ _vm->getPathFinding()->addBlockingEllipse(_vm->getDrew()->getFinalX(),_vm->getDrew()->getFinalY(),sizeX,sizeY );
+ }
+
+ _vm->getPathFinding()->findClosestWalkingPoint(newPosX, newPosY, &_finalX, &_finalY, _x, _y);
+ if (_x == _finalX && _y == _finalY)
+ return true;
+
+
+ if (_vm->getPathFinding()->findPath(_x, _y, _finalX, _finalY)) {
+
+ int32 localFinalX = _finalX;
+ int32 localFinalY = _finalY;
+
+ for (int32 a = 0; a < _vm->getPathFinding()->getPathNodeCount(); a++) {
+ _currentPathX[a] = _vm->getPathFinding()->getPathNodeX(a);
+ _currentPathY[a] = _vm->getPathFinding()->getPathNodeY(a);
+ }
+ _currentPathNodeCount = _vm->getPathFinding()->getPathNodeCount();
+ _currentPathNode = 0;
+ stopSpecialAnim();
+ _flags |= 0x1;
+ _lastWalkTime = _vm->getSystem()->getMillis();
+
+ _numPixelToWalk = 0;
+
+ if (_blockingWalk) {
+ while ((_x != newPosX || _y != newPosY) && _currentPathNode < _currentPathNodeCount && !_vm->shouldQuit()) {
+ if (_currentPathNode < _currentPathNodeCount - 10) {
+ int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode);
+ int32 dx = _currentPathX[_currentPathNode+delta] - _x;
+ int32 dy = _currentPathY[_currentPathNode+delta] - _y;
+ setFacing(getFacingFromDirection(dx, dy));
+ playWalkAnim(0, 0);
+ }
+
+ // in 1/1000 pixels
+ _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024;
+ _lastWalkTime = _vm->getSystem()->getMillis();
+
+ while(_numPixelToWalk >= 1000 && _currentPathNode < _currentPathNodeCount) {
+ _x = _currentPathX[_currentPathNode];
+ _y = _currentPathY[_currentPathNode];
+ _currentPathNode += 1;
+ _numPixelToWalk -= 1000;
+ }
+ setPosition(_x, _y);
+
+ _vm->doFrame();
+ }
+ playStandingAnim();
+ _flags &= ~0x1;
+ _currentPathNode = 0;
+ _currentPathNodeCount = 0;
+
+ if (_x != localFinalX || _y != localFinalY) {
+ return false;
+ }
+ }
+ }
+
+ //_vm->getPathFinding()->findClosestWalkingPoint(newPosX, newPosY, &_x, &_y, _x, _y);
+ //setPosition(_x,_y);
+ return true;
+}
+
+void Character::setFlag(int flag) {
+ _flags = flag;
+}
+
+int32 Character::getFlag() {
+ return _flags;
+}
+
+int32 Character::getX() {
+ return _x;
+}
+int32 Character::getY() {
+ return _y;
+}
+
+bool Character::getVisible() {
+ return _visible;
+}
+
+void Character::setVisible(bool visible) {
+ debugC(1, kDebugCharacter, "setVisible(%d)", (visible) ? 1 : 0);
+
+ _visible = visible;
+ if (_animationInstance)
+ _animationInstance->setVisible(visible);
+
+ if (_shadowAnimationInstance)
+ _shadowAnimationInstance->setVisible(visible);
+
+ return;
+}
+
+int32 Character::getFacing() {
+ return _facing;
+}
+
+bool Character::loadWalkAnimation(Common::String animName) {
+ debugC(1, kDebugCharacter, "loadWalkAnimation(%s)", animName.c_str());
+ if (_walkAnim)
+ delete _walkAnim;
+
+ _walkAnim = new Animation(_vm);
+ return _walkAnim->loadAnimation(animName);
+}
+
+bool Character::loadIdleAnimation(Common::String animName) {
+ debugC(1, kDebugCharacter, "loadIdleAnimation(%s)", animName.c_str());
+ if (_idleAnim)
+ delete _idleAnim;
+
+ _idleAnim = new Animation(_vm);
+ return _idleAnim->loadAnimation(animName);
+}
+
+bool Character::loadTalkAnimation(Common::String animName) {
+ debugC(1, kDebugCharacter, "loadTalkAnimation(%s)", animName.c_str());
+ if (_talkAnim)
+ delete _talkAnim;
+
+ _talkAnim = new Animation(_vm);
+ return _talkAnim->loadAnimation(animName);
+}
+
+bool Character::setupPalette() {
+ return false; // only for Drew
+}
+
+void Character::playStandingAnim() {
+
+}
+
+void Character::stopSpecialAnim() {
+ debugC(4, kDebugCharacter, "stopSpecialAnim()");
+// Strangerke - Commented (not used)
+#if 0
+ if (_animSpecialId != _animSpecialDefaultId)
+ delete anim
+#endif
+ if (_animScriptId != -1)
+ _vm->getSceneAnimationScript(_animScriptId)->_frozen = false;
+
+ if (_sceneAnimationId != -1)
+ _animationInstance->setAnimation(_vm->getSceneAnimation(_sceneAnimationId)->_animation);
+
+ _animSpecialId = -1;
+ _time = 0;
+ _animFlags = 0;
+ _flags &= ~1;
+ _flags &= ~4;
+
+ // end of idle animation
+ if (_animFlags & 0x40) {
+ playStandingAnim();
+ }
+
+#if 0
+ _animationInstance->setFrame(0);
+ playStandingAnim();
+#endif
+}
+
+void Character::update(int32 timeIncrement) {
+ debugC(5, kDebugCharacter, "update(%d)", timeIncrement);
+ if ((_flags & 0x1) && _currentPathNodeCount > 0) {
+ if (_currentPathNode < _currentPathNodeCount) {
+ if (_currentPathNode < _currentPathNodeCount - 10) {
+ int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode);
+ int32 dx = _currentPathX[_currentPathNode+delta] - _x;
+ int32 dy = _currentPathY[_currentPathNode+delta] - _y;
+ setFacing(getFacingFromDirection(dx, dy));
+ playWalkAnim(0, 0);
+ }
+
+ // in 1/1000 pixels
+ _numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024;
+ _lastWalkTime = _vm->getSystem()->getMillis();
+
+ while(_numPixelToWalk > 1000 && _currentPathNode < _currentPathNodeCount) {
+ _x = _currentPathX[_currentPathNode];
+ _y = _currentPathY[_currentPathNode];
+ _currentPathNode += 1;
+ _numPixelToWalk -= 1000;
+ }
+ setPosition(_x, _y);
+ } else {
+ playStandingAnim();
+ _flags &= ~0x1;
+ _currentPathNodeCount = 0;
+ }
+ }
+
+ updateIdle();
+
+#if 0
+ // handle special anims
+ if ((_flags & 4) == 0)
+ return;
+
+
+ if (_animScriptId != -1) {
+ _animationInstance = _vm->getSceneAnimation(this->)
+#endif
+
+ int32 animId = _animSpecialId;
+ if (animId >= 1000)
+ animId = 0;
+
+ if (_animSpecialId < 0)
+ return;
+
+ int32 currentFrame = _animationInstance->getFrame();
+
+ SpecialCharacterAnimation *anim = getSpecialAnimation(_id, animId);
+
+ if ((_animFlags & 0x10) == 0) {
+ if (_animScriptId != -1 && currentFrame > 0 && !_vm->getSceneAnimationScript(_animScriptId)->_frozen) {
+ if (_vm->getCurrentLineToSay() != _lineToSayId && (_animFlags & 8))
+ stopSpecialAnim();
+ return;
+ }
+
+ if (_id == 1 && (_animFlags & 4)) {
+ if (_animFlags & 0x10)
+ return;
+ } else {
+ if (_id == 1 && (_animFlags & 0x10) && _vm->getCurrentLineToSay() != -1) {
+ return;
+ }
+ if ((_animFlags & 0x40) == 0 && _vm->getCurrentLineToSay() == -1) {
+ stopSpecialAnim();
+ return;
+ }
+
+// Strangerke - Commented (not used)
+#if 0
+ if (_animFlags & 8) {
+ if (anim->_flags7 == 0xff && anim->_flags9 == 0xff) {
+ // start voice
+ }
+ }
+#endif
+
+ if (_animScriptId != -1)
+ _vm->getSceneAnimationScript(_animScriptId)->_frozen = true;
+
+ // TODO setup backup //
+
+ _animFlags |= 0x10;
+ _animationInstance->setFrame(0);
+ _time = _vm->getOldMilli() + 8 * _vm->getTickLength();
+ }
+
+ }
+
+ if ((_animFlags & 3) == 2) {
+ if (_vm->getCurrentLineToSay() != _lineToSayId || !_vm->getAudioManager()->voiceStillPlaying() ) // || (_flags & 8)) && _vm->getAudioManager()->voiceStillPlaying() )
+ _animFlags |= 1;
+
+// Strangerke - Commented (not used)
+// } else {
+ }
+
+ // label29 :
+ if (_time > _vm->getOldMilli())
+ return;
+
+ int32 animFlag = anim->_unused;
+ int32 nextFrame = currentFrame + 1;
+ int32 nextTime = _time;
+ int32 animDir = 1;
+ if (!animFlag) {
+ if (_animFlags & 1) {
+ if (anim->_flags7 == 0xff) {
+ if (currentFrame > anim->_flag1 / 2)
+ animDir = 1;
+ else
+ animDir = -1;
+ } else {
+ if (currentFrame >= anim->_flags6) {
+ if (currentFrame < anim->_flags7)
+ currentFrame = anim->_flags7;
+ }
+ if (currentFrame > anim->_flags6)
+ animDir = 1;
+ else
+ animDir = -1;
+ }
+
+ nextFrame = currentFrame + animDir;
+ nextTime = _vm->getOldMilli() + 6 * _vm->getTickLength();
+ } else {
+ if (_animFlags & 0x20) {
+ nextFrame = currentFrame - 1;
+ if (nextFrame == anim->_flags6 - 1) {
+ if (anim->_flags8 != 1 && (_vm->randRange(0, 1) == 1 || anim->_flags8 == 2)) {
+ _animFlags &= ~0x20;
+ nextFrame += 2;
+ if (nextFrame > anim->_flags7)
+ nextFrame = anim->_flags7;
+ } else {
+ nextFrame = anim->_flags7;
+ }
+ }
+ } else {
+ nextFrame = currentFrame + 1;
+// Strangerke - Commented (not used)
+#if 0
+ if (!_vm->getAudioManager()->voiceStillPlaying()) {
+ if (_animFlags & 8) {
+ if ((anim->_flags9 == 0xff && nextFrame == anim->_flags6) ||
+ (anim->_flags9 != 0xff && nextFrame >= anim->_flags9)) {
+ // start really talking
+ }
+ }
+ }
+#endif
+ if (nextFrame == anim->_flags7 + 1 && (_animFlags & 0x40) == 0) {
+ if (anim->_flags8 != 1 && (_vm->randRange(0, 1) || anim->_flags8 == 2)) {
+ _animFlags |= 0x20;
+ nextFrame -= 2;
+ if (nextFrame < anim->_flags6)
+ nextFrame = anim->_flags6;
+ } else {
+ nextFrame = anim->_flags6;
+ }
+ }
+ }
+
+ nextTime = _vm->getOldMilli() + 8 * _vm->getTickLength();
+ }
+ // goto label78
+ }
+ // skipped all this part.
+
+ //label78
+#if 0
+ if (_id == 0)
+ debugC(0, 0xfff, " drew animation flag %d / frame %d", _animFlags, nextFrame);
+
+ if (_id == 1)
+ debugC(0, 0xfff, " flux animation flag %d / frame %d", _animFlags, nextFrame);
+
+ if (_id == 7)
+ debugC(0, 0xfff, " footman animation flag %d / frame %d", _animFlags, nextFrame);
+#endif
+
+ _time = nextTime;
+ if (nextFrame < 0 || nextFrame >= anim->_flag1) {
+ if ((_animFlags & 2) == 0 || _vm->getCurrentLineToSay() != _lineToSayId) {
+ stopSpecialAnim();
+ return;
+ }
+
+ // lots skipped here
+
+ _animFlags &= ~0x10;
+ _animationInstance->forceFrame(0);
+ return;
+
+ }
+
+ //if ((_flags & 8) == 0 || !_vm->getAudioManager()->voiceStillPlaying( ) || )
+ _animationInstance->forceFrame(nextFrame);
+}
+
+// adapted from Kyra
+int32 Character::getFacingFromDirection(int32 dx, int32 dy) {
+ debugC(4, kDebugCharacter, "getFacingFromDirection(%d, %d)", dx, dy);
+
+ static const int facingTable[] = {
+ //1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6
+ 5, 6, 5, 4, 3, 2, 3, 4, 7, 6, 7, 0, 1, 2, 1, 0
+ };
+ dx = -dx;
+
+ int32 facingEntry = 0;
+ int32 ydiff = dy;
+ if (ydiff < 0) {
+ ++facingEntry;
+ ydiff = -ydiff;
+ }
+ facingEntry <<= 1;
+
+ int32 xdiff = dx;
+ if (xdiff < 0) {
+ ++facingEntry;
+ xdiff = -xdiff;
+ }
+
+ facingEntry <<= 1;
+
+ if (xdiff >= ydiff) {
+ int32 temp = ydiff;
+ ydiff = xdiff;
+ xdiff = temp;
+ } else {
+ facingEntry += 1;
+ }
+
+ facingEntry <<= 1;
+
+ int32 temp = (ydiff + 1) >> 1;
+
+ if (xdiff < temp)
+ facingEntry += 1;
+
+ return facingTable[facingEntry];
+}
+
+AnimationInstance *Character::getAnimationInstance() {
+ return _animationInstance;
+}
+
+void Character::setAnimationInstance(AnimationInstance *instance) {
+ _animationInstance = instance;
+}
+
+int32 Character::getScale() {
+ return _scale;
+}
+
+void Character::playWalkAnim(int32 startFrame, int32 endFrame) {
+
+}
+
+void Character::setId(int32 id) {
+ _id = id;
+}
+
+int32 Character::getId() {
+ return _id;
+}
+
+void Character::save(Common::WriteStream *stream) {
+ debugC(1, kDebugCharacter, "save(stream)");
+
+ stream->writeSint32LE(_flags);
+ stream->writeSint32LE(_x);
+ stream->writeSint32LE(_y);
+ stream->writeSint32LE(_z);
+ stream->writeSint32LE(_finalX);
+ stream->writeSint32LE(_finalY);
+ stream->writeSint32LE(_scale);
+ stream->writeSint32LE(_id);
+
+ stream->writeSint32LE(_animScriptId);
+ stream->writeSint32LE(_animFlags);
+ stream->writeSint32LE(_animSpecialDefaultId);
+ stream->writeSint32LE(_sceneAnimationId);
+}
+
+void Character::load(Common::ReadStream *stream) {
+ debugC(1, kDebugCharacter, "read(stream)");
+
+ _flags = stream->readSint32LE();
+ _x = stream->readSint32LE();
+ _y = stream->readSint32LE();
+ _z = stream->readSint32LE();
+ _finalX = stream->readSint32LE();
+ _finalY = stream->readSint32LE();
+ _scale = stream->readSint32LE();
+ _id = stream->readSint32LE();
+
+ _animScriptId = stream->readSint32LE();
+ _animFlags = stream->readSint32LE();
+ _animSpecialDefaultId = stream->readSint32LE();
+ _sceneAnimationId = stream->readSint32LE();
+
+ if (_sceneAnimationId > -1) {
+ setAnimationInstance(_vm->getSceneAnimation(_sceneAnimationId)->_animInstance);
+ }
+}
+
+void Character::setAnimScript(int32 animScriptId) {
+ _animScriptId = animScriptId;
+}
+
+void Character::setSceneAnimationId(int32 sceneAnimationId) {
+ _sceneAnimationId = sceneAnimationId;
+}
+
+int32 Character::getAnimScript() {
+ return _animScriptId;
+}
+
+void Character::playTalkAnim() {
+
+}
+
+void Character::stopWalk() {
+ debugC(1, kDebugCharacter, "stopWalk()");
+
+ _finalX = _x;
+ _finalY = _y;
+ _flags &= ~0x1;
+ _currentPathNode = 0;
+ _currentPathNodeCount = 0;
+}
+
+SpecialCharacterAnimation *Character::getSpecialAnimation(int32 characterId, int32 animationId) {
+ debugC(6, kDebugCharacter, "getSpecialAnimation(%d, %d)", characterId, animationId);
+
+ // very nice animation list hardcoded in the executable...
+ static SpecialCharacterAnimation anims[] = {
+ { "TLK547_?", 9, 0, 0, 0, 0, 0, 1, 5, 8, 1, 8, 0, 255 },
+ { "TLK555_?", 16, 0, 0, 0, 0, 6, 8, 10, 255, 6, 11, 2, 255 },
+ { "LST657_?", 14, 0, 0, 0, 0, 255, 255, 255, 255, 5, 11, 0, 255 },
+ { "TLK587_?", 18, 0, 0, 0, 0, 5, 7, 9, 11, 4, 13, 1, 255 },
+ { "LST659_?", 14, 0, 0, 0, 0, 255, 255, 255, 255, 6, 8, 0, 255 },
+ { "TLK595_?", 11, 0, 0, 0, 0, 3, 6, 255, 255, 1, 7, 0, 255 },
+ { "IDL165_?", 13, 0, 0, 0, 0, 255, 255, 255, 255, 6, 8, 0, 255 },
+ { "LST699_?", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 9, 1, 255 },
+ { "LST713_?", 10, 0, 0, 0, 0, 255, 255, 255, 255, 4, 6, 0, 255 },
+ { "IDL169_?", 16, 0, 0, 0, 0, 255, 255, 255, 255, 5, 9, 2, 255 },
+ { "IDL173_?", 19, 0, 0, 0, 0, 255, 255, 255, 255, 4, 17, 1, 255 },
+ { "IDL187_?", 14, 0, 0, 0, 0, 255, 255, 255, 255, 4, 8, 0, 255 },
+ { "IDL185_?", 15, 0, 0, 0, 0, 255, 255, 255, 255, 6, 9, 1, 255 },
+ { "TLK635_?", 16, 0, 0, 0, 0, 5, 8, 10, 12, 4, 12, 0, 255 },
+ { "TLK637_?", 18, 0, 0, 0, 0, 5, 7, 9, 12, 4, 13, 0, 255 },
+ { "TLK551_?", 20, 0, 0, 0, 0, 5, 9, 11, 15, 4, 16, 0, 255 },
+ { "TLK553_?", 20, 0, 0, 0, 0, 7, 9, 11, 13, 6, 15, 0, 255 },
+ { "TLK619_?", 18, 0, 0, 0, 0, 5, 8, 11, 13, 5, 15, 0, 255 },
+ { "TLK601_?", 12, 0, 0, 0, 0, 2, 5, 6, 10, 2, 10, 1, 255 },
+ { "TLK559_?", 18, 0, 0, 0, 0, 4, 6, 10, 12, 4, 13, 0, 255 },
+ { "TLK557_?", 16, 0, 0, 0, 0, 6, 8, 10, 255, 6, 11, 0, 255 },
+ { "TLK561_?", 17, 0, 0, 0, 0, 6, 8, 10, 12, 5, 12, 0, 255 },
+ { "TLK623_?", 19, 0, 0, 0, 0, 6, 8, 10, 13, 6, 14, 0, 255 },
+ { "TLK591_?", 20, 0, 0, 0, 0, 10, 14, 255, 255, 7, 15, 0, 255 },
+ { "TLK567_?", 19, 0, 0, 0, 0, 6, 9, 11, 14, 5, 15, 0, 255 },
+ { "TLK629_?", 18, 0, 0, 0, 0, 6, 8, 10, 11, 6, 12, 0, 255 },
+ { "TLK627_?", 19, 0, 0, 0, 0, 7, 10, 12, 14, 4, 14, 0, 255 },
+ { "TLK631_?", 19, 0, 0, 0, 0, 8, 10, 255, 255, 8, 12, 0, 255 },
+ { "TLK565_?", 17, 0, 0, 0, 0, 4, 7, 9, 11, 3, 12, 0, 255 },
+ { "TLK603_?", 16, 0, 0, 0, 0, 5, 255, 255, 255, 3, 9, 0, 255 },
+ { "TLK573_?", 20, 0, 0, 0, 0, 6, 7, 10, 255, 6, 16, 2, 255 },
+ { "TLK615_?", 17, 0, 0, 0, 0, 6, 8, 10, 12, 5, 12, 0, 255 },
+ { "TLK609_?", 18, 0, 0, 0, 0, 6, 8, 10, 12, 5, 13, 0, 255 },
+ { "TLK611_?", 18, 0, 0, 0, 0, 8, 10, 12, 255, 7, 13, 0, 255 },
+ { "TLK607_?", 16, 0, 0, 0, 0, 4, 7, 9, 11, 4, 12, 0, 255 },
+ { "TLK581_?", 15, 0, 0, 0, 0, 7, 9, 11, 255, 6, 11, 0, 255 },
+ { "SHD107_?", 46, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "IHL106_?", 23, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 7 },
+ { "GLV106_?", 23, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 7 },
+ { "FXTKA_?", 11, 0, 0, 0, 0, 7, 255, 255, 255, 2, 9, 0, 255 },
+ { "FXTKF_?", 12, 0, 0, 0, 0, 6, 8, 255, 255, 5, 9, 0, 255 },
+ { "FXTKG_?", 9, 0, 0, 0, 0, 5, 255, 255, 255, 4, 7, 0, 255 },
+ { "FXTKI_?", 12, 0, 0, 0, 0, 6, 255, 255, 255, 5, 9, 0, 255 },
+ { "FXTKL_?", 14, 0, 0, 0, 0, 4, 6, 255, 255, 3, 10, 0, 255 },
+ { "FXTKO_?", 10, 0, 0, 0, 0, 4, 255, 255, 255, 4, 7, 0, 255 },
+ { "FXTKP_?", 9, 0, 0, 0, 0, 4, 6, 255, 255, 3, 7, 0, 255 },
+ { "FXTKQ_?", 10, 0, 0, 0, 0, 4, 6, 255, 255, 3, 7, 0, 255 },
+ { "FXLSA_?", 11, 0, 0, 0, 0, 255, 255, 255, 255, 4, 6, 0, 255 },
+ { "FXLSB_?", 9, 0, 0, 0, 0, 255, 255, 255, 255, 4, 5, 0, 255 },
+ { "FXLSK_?", 8, 0, 0, 0, 0, 255, 255, 255, 255, 5, 6, 0, 255 },
+ { "FXLSM_?", 7, 0, 0, 0, 0, 255, 255, 255, 255, 4, 4, 0, 255 },
+ { "FXLSP_?", 7, 0, 0, 0, 0, 255, 255, 255, 255, 3, 3, 0, 255 },
+ { "FXLSQ_?", 6, 0, 0, 0, 0, 255, 255, 255, 255, 3, 3, 0, 255 },
+ { "FXIDE_?", 10, 0, 0, 0, 0, 255, 255, 255, 255, 5, 7, 0, 255 },
+ { "FXIDI_?", 7, 0, 0, 0, 0, 255, 255, 255, 255, 1, 6, 1, 255 },
+ { "FXRCT1_?", 12, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FXTKB_?", 11, 0, 0, 0, 0, 7, 255, 255, 255, 5, 9, 0, 255 },
+ { "FXTKC_?", 14, 0, 0, 0, 0, 2, 5, 8, 10, 1, 12, 2, 255 },
+ { "FXTKD_?", 14, 0, 0, 0, 0, 5, 7, 9, 255, 4, 11, 0, 255 },
+ { "FXTKE_?", 14, 0, 0, 0, 0, 2, 255, 255, 255, 1, 12, 1, 255 },
+ { "FXTKH_?", 11, 0, 0, 0, 0, 6, 8, 255, 255, 4, 9, 0, 255 },
+ { "FXTKJ_?", 8, 0, 0, 0, 0, 7, 255, 255, 255, 4, 7, 0, 255 },
+ { "FXTKK_?", 13, 0, 0, 0, 0, 6, 8, 255, 255, 5, 9, 0, 255 },
+ { "FXTKM_?", 11, 0, 0, 0, 0, 6, 255, 255, 255, 4, 7, 0, 255 },
+ { "FXTKN_?", 9, 0, 0, 0, 0, 5, 7, 255, 255, 4, 7, 0, 255 },
+ { "FXLSC_?", 9, 0, 0, 0, 0, 255, 255, 255, 255, 3, 6, 1, 255 },
+ { "FXLSD_?", 7, 0, 0, 0, 0, 255, 255, 255, 255, 4, 5, 0, 255 },
+ { "FXLSE_?", 9, 0, 0, 0, 0, 255, 255, 255, 255, 8, 8, 0, 255 },
+ { "FXLSG_?", 11, 0, 0, 0, 0, 255, 255, 255, 255, 6, 8, 2, 255 },
+ { "FXLSI_?", 8, 0, 0, 0, 0, 255, 255, 255, 255, 5, 6, 0, 255 },
+ { "FXLSJ_?", 5, 0, 0, 0, 0, 255, 255, 255, 255, 3, 4, 0, 255 },
+ { "FXLSO_?", 8, 0, 0, 0, 0, 255, 255, 255, 255, 4, 5, 0, 255 },
+ { "FXIDA_?", 15, 0, 0, 0, 0, 255, 255, 255, 255, 1, 12, 1, 255 },
+ { "FXIDB_?", 12, 0, 0, 0, 0, 255, 255, 255, 255, 4, 11, 1, 255 },
+ { "FXIDC_?", 11, 0, 0, 0, 0, 255, 255, 255, 255, 7, 7, 0, 255 },
+ { "FXIDD_?", 15, 0, 0, 0, 0, 255, 255, 255, 255, 6, 6, 0, 255 },
+ { "FXIDG_?", 6, 0, 0, 0, 0, 255, 255, 255, 255, 3, 4, 0, 255 },
+ { "FXVRA_?", 7, 0, 0, 0, 0, 255, 255, 255, 255, 2, 6, 2, 255 },
+ { "FXIDF_?", 15, 0, 0, 0, 0, 255, 255, 255, 255, 9, 11, 0, 255 },
+ { "FXEXA_?", 9, 0, 0, 0, 0, 255, 255, 255, 255, 5, 5, 0, 255 },
+ { "FXEXA_?", 9, 0, 0, 0, 0, 255, 255, 255, 255, 5, 5, 0, 255 },
+ { "FFNTK1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 1, 7, 0, 255 },
+ { "FFTLK1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 9, 0, 1 },
+ { "FFBLS1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 3, 8, 0, 2 },
+ { "FFLOV2", 6, 0, 0, 0, 0, 255, 255, 255, 255, 3, 5, 0, 2 },
+ { "FFWOE1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 3, 9, 0, 2 },
+ { "FFSNF1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 4, 6, 0, 4 },
+ { "FFLAF1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 2, 8, 0, 1 },
+ { "FFSKE1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 3, 10, 0, 2 },
+ { "RGTLK2", 10, 0, 0, 0, 0, 4, 6, 255, 255, 2, 6, 0, 1 },
+ { "RGTLK1", 10, 0, 0, 0, 0, 4, 6, 255, 255, 2, 6, 0, 1 },
+ { "BRTLK1", 26, 0, 0, 0, 0, 255, 255, 255, 255, 2, 23, 0, 255 },
+ { "BREXT1", 14, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRLRT1", 19, 0, 0, 0, 0, 255, 255, 255, 255, 1, 15, 0, 255 },
+ { "BRBWV1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 3, 8, 0, 255 },
+ { "BRPAT1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRBSP1", 7, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRBEX1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRBLK1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRBET1", 17, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRWEX1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BBTLK2", 26, 0, 0, 0, 0, 255, 255, 255, 255, 2, 23, 1, 255 },
+ { "BBEXT2", 14, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 1, 255 },
+ { "BRLST1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 2, 7, 0, 255 },
+ { "BRLSN1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 1, 13, 2, 255 },
+ { "BRBNO1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BRBND1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BBLSN2", 13, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "CCTALK", 6, 0, 0, 0, 0, 2, 5, 255, 255, 1, 5, 0, 255 },
+ { "CCBIT1", 13, 0, 0, 0, 0, 3, 5, 9, 11, 2, 11, 2, 255 },
+ { "CCCMP1", 13, 0, 0, 0, 0, 6, 9, 255, 255, 5, 10, 1, 2 },
+ { "CCCOY1", 14, 0, 0, 0, 0, 6, 8, 255, 255, 4, 8, 0, 3 },
+ { "CCFNG1", 5, 0, 0, 0, 0, 255, 255, 255, 255, 4, 4, 0, 255 },
+ { "CCGRB1", 13, 0, 0, 0, 0, 6, 255, 255, 255, 6, 9, 0, 3 },
+ { "CCGST1", 9, 0, 0, 0, 0, 4, 255, 255, 255, 4, 7, 0, 2 },
+ { "CCHCN1", 10, 0, 0, 0, 0, 6, 9, 255, 255, 4, 9, 0, 0 },
+ { "CCHND1", 7, 0, 0, 0, 0, 6, 255, 255, 255, 2, 6, 0, 1 },
+ { "FTTLK2", 11, 0, 0, 0, 0, 1, 4, 6, 9, 1, 10, 0, 2 },
+ { "FTGNO2", 11, 0, 0, 0, 0, 4, 6, 8, 255, 4, 8, 1, 2 },
+ { "FTGST2", 6, 0, 0, 0, 0, 1, 2, 4, 5, 2, 5, 0, 1 },
+ { "FTHND2", 7, 0, 0, 0, 0, 2, 5, 255, 255, 1, 6, 1, 255 },
+ { "FTRNT2", 11, 0, 0, 0, 0, 3, 5, 7, 9, 2, 9, 1, 1 },
+ { "FTSRG2", 10, 0, 0, 0, 0, 4, 6, 8, 255, 3, 8, 1, 1 },
+ { "FTQOT2", 8, 0, 0, 0, 0, 1, 4, 8, 255, 1, 6, 1, 255 },
+ { "FMSTK1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 1, 7, 0, 255 },
+ { "FMCRH1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 3, 10, 0, 255 },
+ { "FMFGR1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 1, 10, 0, 255 },
+ { "FMPRS1", 17, 0, 0, 0, 0, 255, 255, 255, 255, 1, 14, 0, 255 },
+ { "FMAGR1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 2, 9, 0, 255 },
+ { "FMWOE1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 1, 9, 0, 255 },
+ { "FMTOE1", 17, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FM1TK1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FM2TK1", 6, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FM3TK1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FMTNB1", 4, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FMLOK1", 6, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "FMCST1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 3, 8, 0, 255 },
+ { "FMLUP3", 8, 0, 0, 0, 0, 255, 255, 255, 255, 2, 5, 0, 255 },
+ { "BDTLK1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 1, 7, 0, 255 },
+ { "BDGLE1", 15, 0, 0, 0, 0, 255, 255, 255, 255, 6, 10, 0, 255 },
+ { "BDSHK1", 16, 0, 0, 0, 0, 255, 255, 255, 255, 5, 11, 0, 1 },
+ { "BDWOE1", 22, 0, 0, 0, 0, 255, 255, 255, 255, 9, 16, 0, 2 },
+ { "BDHIP1", 22, 0, 0, 0, 0, 255, 255, 255, 255, 8, 16, 0, 1 },
+ { "BDFLG1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "BDKLT1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 5, 10, 0, 255 },
+ { "BDSWY1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "WPSNK1", 5, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "WPLAF1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 5, 9, 1, 1 },
+ { "DOTLK1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 8, 0, 255 },
+ { "DOGST1", 15, 0, 0, 0, 0, 255, 255, 255, 255, 4, 11, 1, 255 },
+ { "DO2DF1", 14, 0, 0, 0, 0, 255, 255, 255, 255, 3, 11, 1, 255 },
+ { "DOSNG1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 8, 9, 1, 255 },
+ { "DOWOE1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 5, 10, 1, 255 },
+ { "DO2ME1", 18, 0, 0, 0, 0, 255, 255, 255, 255, 5, 13, 1, 255 },
+ { "DOGLP1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 1, 255 },
+ { "DOCRY1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 3, 6, 1, 255 },
+ { "METLK1", 5, 0, 0, 0, 0, 255, 255, 255, 255, 1, 4, 0, 255 },
+ { "MECHT1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 2, 9, 1, 255 },
+ { "ME2DF1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 2, 9, 0, 255 },
+ { "MESNG1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 5, 10, 2, 255 },
+ { "MEWOE1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 3, 10, 1, 255 },
+ { "ME2DO1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 2, 9, 1, 255 },
+ { "MEGLP1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 1, 255 },
+ { "MECRY1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 6, 9, 1, 255 },
+ { "CSTLK1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 1, 7, 0, 0 },
+ { "CSNUD1", 14, 0, 0, 0, 0, 255, 255, 255, 255, 5, 11, 0, 2 },
+ { "CSSPR1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 4, 8, 0, 2 },
+ { "CSWVE1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 4, 9, 0, 1 },
+ { "CSYEL1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 2, 6, 0, 1 },
+ { "JMTLK1", 7, 0, 0, 0, 0, 1, 4, 255, 255, 1, 6, 0, 0 },
+ { "JMEGO1", 11, 0, 0, 0, 0, 6, 255, 255, 255, 3, 8, 0, 1 },
+ { "JMARS1", 7, 0, 0, 0, 0, 4, 6, 255, 255, 3, 6, 0, 2 },
+ { "JMHIP1", 8, 0, 0, 0, 0, 3, 5, 7, 255, 2, 7, 0, 1 },
+ { "JMBNK1", 2, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "MRTLK1", 9, 0, 0, 0, 0, 4, 7, 255, 255, 2, 7, 0, 1 },
+ { "MRHOF1", 8, 0, 0, 0, 0, 3, 5, 255, 255, 2, 5, 0, 255 },
+ { "MRMRN1", 11, 0, 0, 0, 0, 3, 7, 255, 255, 1, 8, 0, 0 },
+ { "MRDPR1", 11, 0, 0, 0, 0, 1, 5, 9, 255, 1, 8, 0, 255 },
+ { "MRGLE1", 13, 0, 0, 0, 0, 5, 9, 255, 255, 3, 10, 0, 2 },
+ { "MRTDF1", 11, 0, 0, 0, 0, 3, 7, 9, 255, 3, 9, 0, 1 },
+ { "MREDF1", 11, 0, 0, 0, 0, 4, 255, 255, 255, 1, 10, 1, 255 },
+ { "MREPL1", 12, 0, 0, 0, 0, 5, 6, 7, 9, 2, 9, 1, 1 },
+ { "MRAPL1", 12, 0, 0, 0, 0, 4, 8, 9, 255, 2, 9, 0, 1 },
+ { "MREVL1", 8, 0, 0, 0, 0, 5, 255, 255, 255, 1, 5, 1, 255 },
+ { "BWDMR1", 16, 0, 0, 0, 0, 4, 7, 9, 11, 3, 14, 0, 1 },
+ { "BWBUF1", 12, 0, 0, 0, 0, 5, 8, 255, 255, 3, 11, 0, 1 },
+ { "BWHIP1", 12, 0, 0, 0, 0, 3, 6, 255, 255, 1, 9, 2, 0 },
+ { "BWHWL1", 14, 0, 0, 0, 0, 255, 255, 255, 255, 1, 4, 2, 255 },
+ { "BWLEN1", 10, 0, 0, 0, 0, 3, 6, 255, 255, 2, 7, 0, 1 },
+ { "BWSRL1", 6, 0, 0, 0, 0, 255, 255, 255, 255, 2, 5, 0, 1 },
+ { "BWWAG1", 6, 0, 0, 0, 0, 4, 10, 14, 18, 1, 4, 0, 0 },
+ { "BWYEL1", 8, 0, 0, 0, 0, 4, 255, 255, 255, 2, 7, 0, 1 },
+ { "BWTLK1", 15, 0, 0, 0, 0, 5, 8, 255, 255, 5, 9, 0, 1 },
+ { "SLTLK1", 19, 0, 0, 0, 0, 255, 255, 255, 255, 1, 18, 0, 255 },
+ { "SLPND1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SLPNT1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SLPTR1", 14, 0, 0, 0, 0, 255, 255, 255, 255, 6, 13, 1, 255 },
+ { "SDTLK1", 7, 0, 0, 0, 0, 255, 255, 255, 255, 1, 5, 0, 255 },
+ { "SDPDF1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 3, 6, 0, 255 },
+ { "SDPNT1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 2, 7, 0, 255 },
+ { "SDSLF1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 2, 7, 0, 255 },
+ { "SDSTG1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SDWVE1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 8, 0, 255 },
+ { "SDSTK1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SDSMK1", 22, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SDGLN1", 5, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SDLAF1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "RMHIP1", 12, 0, 0, 0, 0, 7, 255, 255, 255, 1, 10, 2, 255 },
+ { "RMGES1", 19, 0, 0, 0, 0, 11, 255, 255, 255, 8, 13, 2, 2 },
+ { "RMPCH1", 18, 0, 0, 0, 0, 12, 255, 255, 255, 6, 13, 0, 2 },
+ { "RMSTH1", 12, 0, 0, 0, 0, 5, 255, 255, 255, 3, 6, 0, 2 },
+ { "RMHND1", 7, 0, 0, 0, 0, 5, 255, 255, 255, 5, 5, 1, 255 },
+ { "RMSTH1", 12, 0, 0, 0, 0, 5, 255, 255, 255, 5, 6, 1, 2 },
+ { "SGHND1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 9, 0, 0 },
+ { "SGSTF1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 1, 12, 0, 255 },
+ { "SGSLP1", 16, 0, 0, 0, 0, 255, 255, 255, 255, 1, 15, 0, 255 },
+ { "SGPHC1", 12, 0, 0, 0, 0, 255, 255, 255, 255, 4, 9, 0, 255 },
+ { "SGHALT", 22, 0, 0, 0, 0, 255, 255, 255, 255, 7, 15, 0, 255 },
+ { "STTLK1", 13, 0, 0, 0, 0, 5, 9, 255, 255, 3, 10, 0, 2 },
+ { "STTNM1", 13, 0, 0, 0, 0, 5, 9, 255, 255, 3, 10, 0, 2 },
+ { "STFST1", 11, 0, 0, 0, 0, 3, 8, 255, 255, 1, 9, 0, 255 },
+ { "STLAF1", 20, 0, 0, 0, 0, 255, 255, 255, 255, 11, 15, 1, 2 },
+ { "STGES1", 13, 0, 0, 0, 0, 5, 7, 255, 255, 3, 7, 0, 2 },
+ { "STFNT1", 10, 0, 0, 0, 0, 4, 6, 255, 255, 255, 255, 0, 2 },
+ { "STSRK1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 3, 2, 0 },
+ { "STRED1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 2, 10, 0, 255 },
+ { "STLKU1", 6, 0, 0, 0, 0, 3, 255, 255, 255, 2, 5, 0, 0 },
+ { "STKEY1", 15, 0, 0, 0, 0, 9, 11, 255, 255, 9, 14, 0, 255 },
+ { "STMKTD1", 7, 0, 0, 0, 0, 3, 6, 255, 255, 1, 6, 0, 255 },
+ { "STTKM1", 21, 0, 0, 0, 0, 12, 13, 15, 16, 12, 17, 0, 1 },
+ { "STMSZ1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 3, 2, 255 },
+ { "STPNV1", 14, 0, 0, 0, 0, 6, 11, 255, 255, 4, 11, 0, 1 },
+ { "STSOM1", 10, 0, 0, 0, 0, 255, 255, 255, 255, 1, 3, 2, 255 },
+ { "MYTLK1", 9, 0, 0, 0, 0, 2, 4, 255, 255, 1, 4, 0, 0 },
+ { "MYSQUAWK", 5, 0, 0, 0, 0, 255, 255, 255, 255, 3, 3, 1, 255 },
+ { "SPTLK", 12, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPARM", 16, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPHOP", 18, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPLNT", 16, 0, 0, 0, 0, 255, 255, 255, 255, 3, 13, 0, 255 },
+ { "SPLAF", 11, 0, 0, 0, 0, 255, 255, 255, 255, 5, 10, 2, 255 },
+ { "SPTFN", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPPIN", 14, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPINH1", 21, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "SPSFTCOM", 10, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255 },
+ { "MFTMZ1", 9, 0, 0, 0, 0, 255, 255, 255, 255, 1, 8, 1, 255 },
+ { "MFTLK1", 13, 0, 0, 0, 0, 2, 7, 255, 255, 1, 12, 1, 255 },
+ { "VGCIR1", 15, 0, 0, 0, 0, 5, 9, 255, 255, 2, 13, 1, 255 },
+ { "VGBIT1", 12, 0, 0, 0, 0, 6, 9, 255, 255, 2, 9, 1, 255 },
+ { "VGANG1", 10, 0, 0, 0, 0, 9, 255, 255, 255, 1, 9, 0, 255 },
+ { "VGCOM1", 13, 0, 0, 0, 0, 5, 11, 255, 255, 2, 11, 0, 255 },
+ { "VGCUR1", 8, 0, 0, 0, 0, 4, 8, 255, 255, 2, 7, 0, 255 },
+ { "VGTLK1", 11, 0, 0, 0, 0, 3, 6, 255, 255, 3, 10, 0, 255 },
+ { "VGEXP1", 10, 0, 0, 0, 0, 5, 9, 255, 255, 3, 9, 0, 255 },
+ { "WFTLK1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 1, 7, 0, 1 },
+ { "WFPNT1", 20, 0, 0, 0, 0, 255, 255, 255, 255, 6, 16, 0, 1 },
+ { "WFFST1", 13, 0, 0, 0, 0, 255, 255, 255, 255, 2, 8, 0, 2 },
+ { "WFTNO1", 8, 0, 0, 0, 0, 255, 255, 255, 255, 2, 5, 0, 2 },
+ { "WFSRG1", 11, 0, 0, 0, 0, 255, 255, 255, 255, 3, 8, 0, 1 },
+ { "WFGTK1", 16, 0, 0, 0, 0, 255, 255, 255, 255, 1, 15, 0, 255 },
+ { "WFPAW1", 24, 0, 0, 0, 0, 255, 255, 255, 255, 4, 22, 0, 1 },
+ { "LGTLK", 20, 0, 0, 0, 0, 4, 8, 11, 15, 1, 17, 0, 255 },
+ { "LGSHOUT", 16, 0, 0, 0, 0, 12, 255, 255, 255, 6, 12, 0, 255 },
+ { "POMRN1", 12, 0, 0, 0, 0, 3, 5, 7, 255, 3, 9, 0, 2 },
+ { "POGLE1", 14, 0, 0, 0, 0, 7, 10, 255, 255, 5, 10, 0, 2 },
+ { "PLMRG1", 16, 0, 0, 0, 0, 9, 255, 255, 255, 8, 12, 0, 1 },
+ { "PLCMR1", 16, 0, 0, 0, 0, 8, 10, 255, 255, 8, 12, 0, 3 },
+ { "PLEVL1", 17, 0, 0, 0, 0, 9, 255, 255, 255, 7, 9, 0, 1 },
+ { "PLEDF1", 9, 0, 0, 0, 0, 4, 6, 255, 255, 5, 7, 0, 2 },
+ { "PLTLK1", 11, 0, 0, 0, 0, 5, 8, 255, 255, 5, 8, 0, 1 },
+ { "ELTLK1", 8, 0, 0, 0, 0, 3, 5, 7, 255, 2, 7, 0, 255 },
+ { "ELSNR1", 7, 0, 0, 0, 0, 3, 255, 255, 255, 1, 5, 0, 255 },
+ { "RG2TK1", 10, 0, 0, 0, 0, 4, 6, 255, 255, 2, 6, 0, 1 },
+ { "RG2TK1", 10, 0, 0, 0, 0, 4, 6, 255, 255, 2, 6, 0, 1 },
+ { "C2TALK", 6, 0, 0, 0, 0, 2, 5, 255, 255, 1, 5, 0, 255 },
+ { "C2BIT1", 13, 0, 0, 0, 0, 3, 5, 9, 11, 2, 11, 2, 255 },
+ { "C2CMP1", 13, 0, 0, 0, 0, 6, 9, 255, 255, 5, 10, 1, 2 },
+ { "C2COY1", 14, 0, 0, 0, 0, 6, 8, 255, 255, 4, 8, 0, 3 },
+ { "C2FNG1", 5, 0, 0, 0, 0, 255, 255, 255, 255, 4, 4, 0, 255 },
+ { "C2GRB1", 13, 0, 0, 0, 0, 6, 255, 255, 255, 6, 9, 0, 3 },
+ { "C2GST1", 9, 0, 0, 0, 0, 4, 255, 255, 255, 4, 7, 0, 2 },
+ { "C2HCN1", 10, 0, 0, 0, 0, 6, 9, 255, 255, 4, 9, 0, 0 },
+ { "C2HND1", 7, 0, 0, 0, 0, 6, 255, 255, 255, 2, 6, 0, 1 },
+ { "666TKBB3", 21, 0, 0, 0, 0, 9, 14, 255, 255, 6, 16, 0, 255 },
+ { "665TFLX3", 27, 0, 0, 0, 0, 10, 14, 17, 255, 10, 18, 0, 255 },
+ { "664FXTK3", 18, 0, 0, 0, 0, 5, 7, 11, 13, 3, 15, 0, 255 },
+ { "FDTALK", 15, 0, 0, 0, 0, 9, 255, 255, 255, 7, 9, 0, 255 },
+ { "FDYELL", 16, 0, 0, 0, 0, 10, 255, 255, 255, 8, 10, 0, 255 },
+ { "GLTLK", 20, 0, 0, 0, 0, 6, 12, 18, 255, 1, 19, 0, 255 },
+ { "GLTRN", 4, 0, 0, 0, 0, 3, 255, 255, 255, 1, 2, 0, 255 },
+ { "RAYTALK1", 10, 0, 0, 0, 0, 3, 5, 8, 255, 1, 9, 0, 255 },
+ { "BRTKB1", 17, 0, 0, 0, 0, 255, 255, 255, 255, 2, 14, 0, 255 }
+ };
+
+ static int32 characterAnims[] = {
+ 0, 39, 81, 89, 91, 108, 117, 124, 138, 146,
+ 148, 156, 164, 169, 174, 179, 184, 193, 197, 207,
+ 213, 218, 233, 235, 244, 245, 246, 246, 246, 246,
+ 253, 253, 253, 253, 260, 262, 264, 269, 271, 273,
+ 282, 284, 285, 287, 289, 290, 291, 291, 291, 291,
+ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289
+ };
+
+ return &anims[characterAnims[characterId] + animationId];
+}
+
+bool Character::loadShadowAnimation(Common::String animName) {
+ debugC(1, kDebugCharacter, "loadShadowAnimation(%s)", animName.c_str());
+
+ _shadowAnim = new Animation(_vm);
+ if (!_shadowAnim->loadAnimation(animName))
+ return false;
+
+ _shadowAnimationInstance = _vm->getAnimationManager()->createNewInstance(kAnimationCharacter);
+ _vm->getAnimationManager()->addInstance(_shadowAnimationInstance);
+ _shadowAnimationInstance->setAnimation(_shadowAnim);
+ _shadowAnimationInstance->setVisible(true);
+ _shadowAnimationInstance->setUseMask(true);
+
+ return true;
+}
+
+void Character::playAnim(int32 animId, int32 unused, int32 flags) {
+ debugC(3, kDebugCharacter, "playAnim(%d, unused, %d)", animId, flags);
+
+ if (animId == 0)
+ animId = _animSpecialDefaultId;
+
+ // get the anim to load
+ SpecialCharacterAnimation *anim = getSpecialAnimation(_id, animId);
+
+ char animName[20];
+ strcpy(animName, anim->_filename);
+ if (strchr(animName, '?'))
+ *strchr(animName, '?') = '0' + _facing;
+ strcat(animName, ".CAF");
+
+
+ if (_animScriptId != -1)
+ _vm->getSceneAnimationScript(_animScriptId)->_frozen = true;
+
+ if (_sceneAnimationId > -1)
+ setAnimationInstance(_vm->getSceneAnimation(_sceneAnimationId)->_animInstance);
+
+ stopSpecialAnim();
+
+ if (flags & 8) {
+ // talker
+ _lineToSayId = _vm->getCurrentLineToSay();
+
+ // make the talker busy
+ _flags |= 1;
+ }
+ _animFlags |= flags;
+
+ if (_specialAnim)
+ delete _specialAnim;
+ _specialAnim = new Animation(_vm);
+ _specialAnim->loadAnimation(animName);
+
+ _animSpecialId = animId;
+
+ _animationInstance->setAnimation(_specialAnim);
+ _animationInstance->setAnimationRange(0, _specialAnim->_numFrames - 1);
+ _animationInstance->reset();
+ _animationInstance->stopAnimation();
+ _animationInstance->setLooping(false);
+}
+
+int32 Character::getAnimFlag() {
+ return _animFlags;
+}
+
+void Character::setAnimFlag(int32 flag) {
+ _animFlags = flag;
+}
+
+int32 Character::getSceneAnimationId() {
+ return _sceneAnimationId;
+}
+
+void Character::setDefaultSpecialAnimationId( int32 defaultAnimationId ) {
+ _animSpecialDefaultId = defaultAnimationId;
+}
+
+int32 Character::getFinalX() {
+ return _finalX;
+}
+
+int32 Character::getFinalY() {
+ return _finalY;
+}
+
+void Character::updateIdle() {
+ debugC(5, kDebugCharacter, "updateIdle()");
+
+ // only flux and drew
+ if (_id > 1)
+ return;
+
+ if (_vm->state()->_mouseHidden)
+ _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0,600)) * _vm->getTickLength();
+
+ if (_vm->getOldMilli() > _nextIdleTime) {
+ if ( ((_flags & 1) == 0) || ((_flags & 2) != 0) ) {
+ if (!_vm->state()->_inCloseUp && !_vm->state()->_inCutaway && _animSpecialId == -1) {
+ if (!_vm->state()->_mouseHidden) {
+ _nextIdleTime = _vm->getOldMilli() + (300 + _vm->randRange(0,600)) * _vm->getTickLength();
+ playAnim(getRandomIdleAnim(), 0, 0x40);
+ _flags |= 0x4;
+ }
+ }
+ }
+ }
+}
+} // End of namespace Toon
+
Property changes on: scummvm/trunk/engines/toon/character.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/character.h
===================================================================
--- scummvm/trunk/engines/toon/character.h (rev 0)
+++ scummvm/trunk/engines/toon/character.h 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,144 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* $URL$
+* $Id$
+*
+*/
+
+#ifndef TOON_CHARACTER_H
+#define TOON_CHARACTER_H
+
+#include "toon.h"
+
+namespace Toon {
+
+class ToonEngine;
+
+struct SpecialCharacterAnimation {
+ char _filename[9]; // 0
+ byte _flag1; // 9
+ short _offsetX; // 10
+ short _offsetY; // 12
+ short _unused; // 14
+ short _unused2; // 16
+ byte _flags2; // 18
+ byte _flags3; // 19
+ byte _flags4; // 20
+ byte _flags5; // 21
+ byte _flags6; // 22
+ byte _flags7; // 23
+ byte _flags8; // 24
+ byte _flags9; // 25
+};
+
+
+class Character {
+public:
+ Character(ToonEngine *vm);
+ virtual ~Character(void);
+ virtual void init();
+ virtual int32 getId();
+ virtual void setId(int32 id);
+ virtual void setFacing(int32 facing);
+ virtual int32 getFacing();
+ virtual void setAnimScript(int32 animScriptId);
+ virtual void setSceneAnimationId(int32 sceneAnimationId);
+ virtual void setDefaultSpecialAnimationId(int32 defaultAnimationId);
+ virtual int32 getAnimScript();
+ virtual int32 getSceneAnimationId();
+ virtual void setFlag(int flag);
+ virtual int32 getFlag();
+ virtual int32 getAnimFlag();
+ virtual void setAnimFlag(int32 flag);
+ virtual void setPosition(int32 x, int32 y);
+ virtual int32 getX();
+ virtual int32 getY();
+ virtual int32 getFinalX();
+ virtual int32 getFinalY();
+ virtual bool walkTo(int32 newPosX, int32 newPosY);
+ virtual bool getVisible();
+ virtual void setVisible(bool visible);
+ virtual bool loadWalkAnimation(Common::String animName);
+ virtual bool loadIdleAnimation(Common::String animName);
+ virtual bool loadTalkAnimation(Common::String animName);
+ virtual bool loadShadowAnimation(Common::String animName);
+ virtual bool setupPalette();
+ virtual void playStandingAnim();
+ virtual void playWalkAnim(int32 start, int32 end);
+ virtual void playTalkAnim();
+ virtual void playAnim(int32 animId, int32 unused, int32 flags);
+ virtual void update(int32 timeIncrement);
+ virtual int32 getScale();
+ virtual AnimationInstance *getAnimationInstance();
+ virtual void setAnimationInstance(AnimationInstance *instance);
+ virtual void save(Common::WriteStream *stream);
+ virtual void load(Common::ReadStream *stream);
+ virtual void stopWalk();
+ virtual void stopSpecialAnim();
+ virtual void updateIdle();
+ virtual int32 getRandomIdleAnim() { return 0; };
+
+ int32 getFacingFromDirection(int32 dx, int32 dy);
+ static SpecialCharacterAnimation *getSpecialAnimation(int32 characterId, int32 animationId);
+
+
+protected:
+ ToonEngine *_vm;
+
+ int32 _id;
+ int32 _animScriptId;
+ int32 _animSpecialId;
+ int32 _animSpecialDefaultId;
+ int32 _sceneAnimationId;
+ int32 _lineToSayId;
+ int32 _time;
+ int32 _x;
+ int32 _y;
+ int32 _z;
+ int32 _finalX;
+ int32 _finalY;
+ int32 _facing;
+ int32 _flags;
+ int32 _animFlags;
+ int32 _scale;
+ int32 _nextIdleTime;
+ bool _visible;
+ bool _blockingWalk;
+ int32 _speed;
+ int32 _lastWalkTime;
+ int32 _numPixelToWalk;
+
+ AnimationInstance *_animationInstance;
+ AnimationInstance *_shadowAnimationInstance;
+ Animation *_walkAnim;
+ Animation *_idleAnim;
+ Animation *_talkAnim;
+ Animation *_shadowAnim;
+ Animation *_specialAnim;
+
+ int32 _currentPathX[4096];
+ int32 _currentPathY[4096];
+ int32 _currentPathNodeCount;
+ int32 _currentPathNode;
+};
+
+} // End of namespace Toon
+#endif
Property changes on: scummvm/trunk/engines/toon/character.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/conversation.cpp
===================================================================
--- scummvm/trunk/engines/toon/conversation.cpp (rev 0)
+++ scummvm/trunk/engines/toon/conversation.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* $URL$
+* $Id$
+*
+*/
+
+#include "conversation.h"
+
+namespace Toon {
+
+void Conversation::save(Common::WriteStream *stream, int16* conversationDataBase) {
+ stream->writeSint32BE(_enable);
+ for (int32 i = 0; i < 10; i++) {
+ stream->writeSint32BE(state[i]._data2);
+ stream->writeSint16BE(state[i]._data3);
+ stream->writeSint32BE((int16*)state[i]._data4 - conversationDataBase);
+ }
+}
+
+void Conversation::load(Common::ReadStream *stream, int16* conversationDataBase) {
+ _enable = stream->readSint32BE();
+ for (int32 i = 0; i < 10; i++) {
+ state[i]._data2 = stream->readSint32BE();
+ state[i]._data3 = stream->readSint16BE();
+ state[i]._data4 = conversationDataBase + stream->readSint32BE();
+ }
+}
+
+
+}
\ No newline at end of file
Property changes on: scummvm/trunk/engines/toon/conversation.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/conversation.h
===================================================================
--- scummvm/trunk/engines/toon/conversation.h (rev 0)
+++ scummvm/trunk/engines/toon/conversation.h 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* $URL$
+* $Id$
+*
+*/
+
+#ifndef TOON_CONVERSATION_H
+#define TOON_CONVERSATION_H
+
+#include "engines/engine.h"
+#include "common/stream.h"
+namespace Toon {
+
+class Conversation {
+public:
+ int32 _enable; // 00
+
+ struct ConvState {
+ int32 _data2; // 04
+ int16 _data3; // 08
+ void *_data4; // 10
+ } state[10];
+
+ void save(Common::WriteStream *stream, int16* conversationDataBase);
+ void load(Common::ReadStream *stream, int16* conversationDataBase);
+};
+
+} // End of namespace Toon
+
+#endif
Property changes on: scummvm/trunk/engines/toon/conversation.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/detection.cpp
===================================================================
--- scummvm/trunk/engines/toon/detection.cpp (rev 0)
+++ scummvm/trunk/engines/toon/detection.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,254 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/config-manager.h"
+#include "engines/advancedDetector.h"
+#include "common/savefile.h"
+#include "common/system.h"
+#include "base/plugins.h"
+#include "graphics/thumbnail.h"
+#include "toon.h"
+
+static const PlainGameDescriptor ToonGames[] = {
+ { "toon", "Toonstruck" },
+ { "toondemo", "Toonstruck Demo" },
+ { 0, 0 }
+};
+
+namespace Toon {
+
+using Common::GUIO_NONE;
+
+static const ADGameDescription gameDescriptions[] = {
+ { "toon", "", {
+ {"local.pak", 0, "3290209ef9bc92692108dd2f45df0736", 3237611},
+ {"arcaddbl.svl", 0, "c418478cd2833c7c983799f948af41ac", 7844688},
+ {"study.svl", 0, "281efa3f33f6712c0f641a605f4d40fd", 2511090},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ },
+ { "toon", "", {
+ {"local.pak", 0, "517132c3575b38806d1e7b6f59848072", 3224044},
+ {"arcaddbl.svl", 0, "ff74008827b62fbef1f46f104c438e44", 9699256},
+ {"study.svl", 0, "df056b94ea83f1ed92a539cf636053ab", 2542668},
+ AD_LISTEND},
+ Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ },
+ { "toon", "", {
+ {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841},
+ {"arcaddbl.svl", 0, "7a0d74f4d66d1c722b946abbeb0834ef", 9122249},
+ {"study.svl", 0, "72fe96a9e10967d3138e918295babc42", 2910283},
+ AD_LISTEND},
+ Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ },
+ { "toon", "", {
+ {"local.pak", 0, "e8645168a247e2abdbfc2f9fa9d1c0fa", 3232222},
+ {"arcaddbl.svl", 0, "7893ac4cc78d51356baa058bbee7aa28", 8275016},
+ {"study.svl", 0, "b6b1ee2d9d94d53d305856039ab7bde7", 2634620},
+ AD_LISTEND},
+ Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ },
+ { "toondemo", "", {
+ {"local.pak", 0, "bf5da4c03f78ffbd643f12122319366e", 3250841},
+ {"wacexdbl.emc", 0, "cfbc2156a31b294b038204888407ebc8", 6974},
+ {"generic.svl", 0, "5eb99850ada22f0b8cf6392262d4dd07", 9404599},
+ AD_LISTEND},
+ Common::DE_DEU, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE
+ },
+
+ AD_TABLE_END_MARKER
+};
+
+static const ADFileBasedFallback fileBasedFallback[] = {
+ { &gameDescriptions[0], { "local.pak", "arcaddbl.svl", "study.svl", 0 } }, // default to english version
+ { 0, { 0 } }
+};
+
+} // End of namespace Toon
+
+static const char *directoryGlobs[] = {
+ "misc",
+ "act1",
+ "arcaddbl",
+ "act2",
+ "study",
+ 0
+};
+
+static const ADParams detectionParams = {
+ (const byte *)Toon::gameDescriptions,
+ sizeof(ADGameDescription),
+ 5000, // number of md5 bytes
+ ToonGames,
+ 0, // no obsolete targets data
+ "toon",
+ Toon::fileBasedFallback,
+ 0,
+ // Additional GUI options (for every game}
+ Common::GUIO_NONE,
+ // Maximum directory depth
+ 3,
+ // List of directory globs
+ directoryGlobs
+};
+
+class ToonMetaEngine : public AdvancedMetaEngine {
+public:
+ ToonMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+
+ virtual const char *getName() const {
+ return "Toon Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Toonstruck (C) 1996 Virgin Interactive";
+ }
+
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual SaveStateList listSaves(const char *target) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+// virtual void removeSaveState(const char *target, int slot) const;
+};
+
+bool ToonMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves) ||
+// (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate);
+}
+
+int ToonMetaEngine::getMaximumSaveSlot() const { return 99; }
+
+SaveStateList ToonMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String pattern = target;
+ pattern += ".???";
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ int slotNum = 0;
+ for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ slotNum = atoi(filename->c_str() + filename->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 99) {
+ Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ if (file) {
+ int32 version = file->readSint32BE();
+ if (version != TOON_SAVEGAME_VERSION) {
+ delete file;
+ continue;
+ }
+
+ // read name
+ uint16 nameSize = file->readUint16BE();
+ if (nameSize >= 255) {
+ delete file;
+ continue;
+ }
+ char name[256];
+ file->read(name, nameSize);
+ name[nameSize] = 0;
+
+ saveList.push_back(SaveStateDescriptor(slotNum, name));
+ delete file;
+ }
+ }
+ }
+
+ return saveList;
+}
+
+SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Common::String fileName = Common::String::printf("%s.%03d", target, slot);
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
+
+ if (file) {
+
+ int32 version = file->readSint32BE();
+ if (version != TOON_SAVEGAME_VERSION) {
+ delete file;
+ return SaveStateDescriptor();
+ }
+
+ uint32 saveNameLength = file->readUint16BE();
+ char saveName[256];
+ file->read(saveName, saveNameLength);
+ saveName[saveNameLength] = 0;
+
+ SaveStateDescriptor desc(slot, saveName);
+
+ Graphics::Surface *thumbnail = new Graphics::Surface();
+ assert(thumbnail);
+ if (!Graphics::loadThumbnail(*file, *thumbnail)) {
+ delete thumbnail;
+ thumbnail = 0;
+ }
+ desc.setThumbnail(thumbnail);
+
+ desc.setDeletableFlag(true);
+ desc.setWriteProtectedFlag(false);
+
+ uint32 saveDate = file->readUint32BE();
+ uint16 saveTime = file->readUint16BE();
+
+ int day = (saveDate >> 24) & 0xFF;
+ int month = (saveDate >> 16) & 0xFF;
+ int year = saveDate & 0xFFFF;
+
+ desc.setSaveDate(year, month, day);
+
+ int hour = (saveTime >> 8) & 0xFF;
+ int minutes = saveTime & 0xFF;
+
+ desc.setSaveTime(hour, minutes);
+
+ delete file;
+ return desc;
+ }
+
+ return SaveStateDescriptor();
+}
+
+bool ToonMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ if (desc) {
+ *engine = new Toon::ToonEngine(syst, desc);
+ }
+ return desc != 0;
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(TOON)
+ REGISTER_PLUGIN_DYNAMIC(TOON, PLUGIN_TYPE_ENGINE, ToonMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(TOON, PLUGIN_TYPE_ENGINE, ToonMetaEngine);
+#endif
Property changes on: scummvm/trunk/engines/toon/detection.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/toon/drew.cpp
===================================================================
--- scummvm/trunk/engines/toon/drew.cpp (rev 0)
+++ scummvm/trunk/engines/toon/drew.cpp 2010-10-08 22:30:39 UTC (rev 53087)
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+ #include "drew.h"
+
+namespace Toon {
+
+CharacterDrew::CharacterDrew(ToonEngine *vm) : Character(vm) {
+ _id = 0;
+ _blockingWalk = true;
+ _animationInstance = vm->getAnimationManager()->createNewInstance(kAnimationCharacter);
+ _animationInstance->setUseMask(true);
+ vm->getAnimationManager()->addInstance(_animationInstance);
+}
+
+CharacterDrew::~CharacterDrew(void) {
+}
+
+bool CharacterDrew::setupPalette() {
+ debugC(1, kDebugCharacter, "setupPalette()");
+
+ if (_walkAnim) {
+ _walkAnim->applyPalette(129, 129 * 3, 63);
+ return true;
+ }
+ return false;
+}
+
+void CharacterDrew::setFacing(int32 facing) {
+ debugC(4, kDebugCharacter, "setFacing(%d)", facing);
+ _facing = facing;
+}
+
+void CharacterDrew::setPosition(int32 x, int32 y) {
+ debugC(5, kDebugCharacter, "setPosition(%d, %d)", x, y);
+
+ _z = _vm->getLayerAtPoint(x, y);
+ _scale = _vm->getScaleAtPoint(x, y);
+
+ // work out position and scale of the character sprite
+ int32 width = _walkAnim->getWidth() * _scale / 1024;
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list