aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Kagerer2008-03-15 00:16:11 +0000
committerFlorian Kagerer2008-03-15 00:16:11 +0000
commit9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75 (patch)
treeb0aa0d53b99c01ee761ce6139b535027a25bb3d0
parent6547ef6e129fb42c75c20f24e1f24dff1458f727 (diff)
downloadscummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.tar.gz
scummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.tar.bz2
scummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.zip
animations for inventory items and mouse pointers
svn-id: r31122
-rw-r--r--engines/kyra/animator_v2.cpp62
-rw-r--r--engines/kyra/kyra_v2.cpp10
-rw-r--r--engines/kyra/kyra_v2.h14
-rw-r--r--engines/kyra/resource.h1
-rw-r--r--engines/kyra/staticres.cpp13
5 files changed, 96 insertions, 4 deletions
diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp
index 9bd9b76dfc..ceb9a80215 100644
--- a/engines/kyra/animator_v2.cpp
+++ b/engines/kyra/animator_v2.cpp
@@ -26,6 +26,8 @@
#include "kyra/kyra_v2.h"
#include "kyra/wsamovie.h"
+#include "common/endian.h"
+
namespace Kyra {
void KyraEngine_v2::clearAnimObjects() {
@@ -191,6 +193,66 @@ void KyraEngine_v2::refreshAnimObjectsIfNeed() {
}
}
+void KyraEngine_v2::updateItemAnimations() {
+ bool nextFrame = false;
+
+ if (_itemAnimData[0].itemIndex == -1 || _holdItemAnims)
+ return;
+
+ ItemAnimData *s = &_itemAnimData[_nextAnimItem++];
+
+ if (s->itemIndex == -1) {
+ _nextAnimItem = 0;
+ return;
+ }
+
+ uint32 ctime = _system->getMillis();
+ if (ctime < s->nextFrame)
+ return;
+
+ uint16 shpIdx = READ_LE_UINT16(s->frames + (s->curFrame << 2)) + 64;
+ if ((s->itemIndex == _handItemSet || s->itemIndex == _itemInHand) && (!_mouseState && _screen->isMouseVisible())) {
+ nextFrame = true;
+ _screen->setMouseCursor(8, 15, getShapePtr(shpIdx));
+ }
+
+ for (int i = 0; i < 10; i++) {
+ if (s->itemIndex == _mainCharacter.inventory[i]) {
+ nextFrame = true;
+ _screen->drawShape(2, _defaultShapeTable[240 + i], 304, 184, 0, 0);
+ _screen->drawShape(2, getShapePtr(shpIdx), 304, 184, 0, 0);
+ _screen->copyRegion(304, 184, _inventoryX[i], _inventoryY[i], 16, 16, 2, 0);
+ }
+ }
+
+ _screen->updateScreen();
+
+ for (int i = 11; i < 40; i++) {
+ AnimObj *animObject = &_animObjects[i];
+ if (animObject->shapeIndex2 == s->itemIndex + 64) {
+ if (s->itemIndex == 121) {
+ int f = findItem(_mainCharacter.sceneId, 121);
+ int nx = _itemList[f].x - 4;
+ if (nx > 12) {
+ if (lineIsPassable(nx, _itemList[f].y)) {
+ animObject->xPos2 -= 4;
+ _itemList[f].x -= 4;
+ }
+ }
+ }
+ animObject->shapePtr = _defaultShapeTable[shpIdx];
+ animObject->shapeIndex1 = shpIdx;
+ animObject->needRefresh = 1;
+ nextFrame = true;
+ }
+ }
+
+ if (nextFrame) {
+ s->nextFrame = _system->getMillis() + READ_LE_UINT16(s->frames + (s->curFrame << 2) + 2) * _tickLength;
+ s->curFrame = ++s->curFrame % s->numFrames;
+ }
+}
+
void KyraEngine_v2::flagAnimObjsForRefresh() {
for (AnimObj *curEntry = _animList; curEntry; curEntry = curEntry->nextObject)
curEntry->needRefresh = 1;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index f33b69b7c9..69375a36f4 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -95,6 +95,9 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_currentTalkSections.ENDTim = NULL;
_invWsa.wsa = 0;
+ _itemAnimTable = 0;
+ _nextAnimItem = 0;
+ _holdItemAnims = false;
_colorCodeFlag1 = 0;
_colorCodeFlag2 = -1;
@@ -578,7 +581,7 @@ void KyraEngine_v2::update() {
updateMouse();
updateSpecialSceneScripts();
_timer->update();
- //sub_274C0();
+ updateItemAnimations();
updateInvWsa();
//sub_1574C();
_screen->updateScreen();
@@ -591,7 +594,7 @@ void KyraEngine_v2::updateWithText() {
//sub_157C();
updateSpecialSceneScripts();
_timer->update();
- //sub_274C0();
+ updateItemAnimations();
updateInvWsa();
restorePage3();
drawAnimObjects();
@@ -697,7 +700,7 @@ void KyraEngine_v2::updateMouse() {
}
if (type != 0 && _handItemSet != type) {
- _handItemSet = type;
+ _mouseState = _handItemSet = type;
_screen->hideMouse();
_screen->setMouseCursor(xOffset, yOffset, getShapePtr(shapeIndex));
_screen->showMouse();
@@ -705,6 +708,7 @@ void KyraEngine_v2::updateMouse() {
if (type == 0 && _handItemSet != _itemInHand) {
if ((mouse.y > 145) || (mouse.x > 6 && mouse.x < 312 && mouse.y > 6 && mouse.y < 135)) {
+ _mouseState = 0;
_handItemSet = _itemInHand;
_screen->hideMouse();
if (_itemInHand == -1)
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 6db213c1b5..243f0bd830 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -319,6 +319,7 @@ protected:
void updateInput();
int _mouseX, _mouseY;
+ int _mouseState;
Common::List<Common::Event> _eventList;
// gfx/animation specific
@@ -446,6 +447,7 @@ protected:
void refreshAnimObjects(int force);
void refreshAnimObjectsIfNeed();
+ void updateItemAnimations();
void flagAnimObjsForRefresh();
@@ -571,6 +573,17 @@ protected:
void redrawInventory(int page);
void scrollInventoryWheel();
+ struct ItemAnimData {
+ int16 itemIndex;
+ uint8 numFrames;
+ uint8 curFrame;
+ uint32 nextFrame;
+ const uint8 *frames;
+ } _itemAnimData[15];
+
+ int _nextAnimItem;
+ bool _holdItemAnims;
+
// gui
void loadButtonShapes();
uint8 *_buttonShapes[19];
@@ -1076,6 +1089,7 @@ protected:
int _ingameTalkObjIndexSize;
const char *const *_ingameTimJpStr;
int _ingameTimJpStrSize;
+ const uint8 *_itemAnimTable;
uint8 *_demoShapeDefs;
int _sequenceStringsDuration[33];
diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h
index c0aa05f77d..ace8c413f4 100644
--- a/engines/kyra/resource.h
+++ b/engines/kyra/resource.h
@@ -222,6 +222,7 @@ enum kKyraResources {
k2IngameCDA,
k2IngameTalkObjIndex,
k2IngameTimJpStrings,
+ k2IngameItemAnimTable,
kMaxResIDs
};
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 6ac5322e0d..34ac268024 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -35,7 +35,7 @@
namespace Kyra {
-#define RESFILE_VERSION 21
+#define RESFILE_VERSION 22
bool StaticResource::checkKyraDat() {
Common::File kyraDat;
@@ -247,6 +247,7 @@ bool StaticResource::init() {
{ k2IngameCDA, kRawData, "I_TRACKS.CDA" },
{ k2IngameTalkObjIndex, kRawData, "I_TALKOBJECTS.MAP" },
{ k2IngameTimJpStrings, kStringList, "I_TIMJPSTR.TXT" },
+ { k2IngameItemAnimTable, kRawData, "I_INVANIM.SHP" },
{ 0, 0, 0 }
};
@@ -929,6 +930,16 @@ void KyraEngine_v2::initStaticResource() {
_cdaTrackTableFinale = _staticres->loadRawData(k2SeqplayFinaleCDA, _cdaTrackTableFinaleSize);
_ingameTalkObjIndex = (const uint16*) _staticres->loadRawData(k2IngameTalkObjIndex, _ingameTalkObjIndexSize);
_ingameTimJpStr = _staticres->loadStrings(k2IngameTimJpStrings, _ingameTimJpStrSize);
+ _itemAnimTable = _staticres->loadRawData(k2IngameItemAnimTable, tmpSize);
+
+ for (int i = 0; i < 15; i++) {
+ const uint8 *tmp = _itemAnimTable + 56 * i;
+ _itemAnimData[i].itemIndex = (int16) READ_LE_UINT16(tmp);
+ _itemAnimData[i].numFrames = tmp[2];
+ _itemAnimData[i].curFrame = tmp[3];
+ _itemAnimData[i].nextFrame = READ_LE_UINT32(&tmp[4]);
+ _itemAnimData[i].frames = &tmp[8];
+ }
// replace sequence talkie files with localized versions and cut off .voc
// suffix from voc files so as to allow compression specific file extensions