aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
authorGregory Montoir2003-10-20 08:34:48 +0000
committerGregory Montoir2003-10-20 08:34:48 +0000
commit769f033b003d848ed9722dab239670386ce2317a (patch)
treead962f8198b0f75b51cd1956a29f10184f88f84c /queen
parente25bda32ecb82a45acefaca5a31e1e6eba5e6dc5 (diff)
downloadscummvm-rg350-769f033b003d848ed9722dab239670386ce2317a.tar.gz
scummvm-rg350-769f033b003d848ed9722dab239670386ce2317a.tar.bz2
scummvm-rg350-769f033b003d848ed9722dab239670386ce2317a.zip
Logic::anim / BobSlot cleanup
svn-id: r10909
Diffstat (limited to 'queen')
-rw-r--r--queen/graphics.cpp67
-rw-r--r--queen/graphics.h4
-rw-r--r--queen/logic.cpp28
-rw-r--r--queen/logic.h4
4 files changed, 75 insertions, 28 deletions
diff --git a/queen/graphics.cpp b/queen/graphics.cpp
index 40e1c2cdef..b3624fe38f 100644
--- a/queen/graphics.cpp
+++ b/queen/graphics.cpp
@@ -143,32 +143,34 @@ void Graphics::bobSetupControl() {
void Graphics::bobAnimString(uint32 bobnum, const AnimFrame *animBuf) {
- BobSlot *pbs = &_bobs[bobnum];
- pbs->active = true;
- pbs->animating = true;
- pbs->anim.string.buffer = animBuf;
- pbs->anim.string.curPos = animBuf;
- pbs->frameNum = animBuf->frame;
- pbs->anim.speed = animBuf->speed / 4;
+ debug(9, "Graphics::bobAnimString(%d)", bobnum);
+ _bobs[bobnum].animString(animBuf);
}
void Graphics::bobAnimNormal(uint32 bobnum, uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip) {
debug(9, "Graphics::bobAnimNormal(%d, %d, %d, %d)", bobnum, firstFrame, lastFrame, speed);
+ _bobs[bobnum].animNormal(firstFrame, lastFrame, speed, rebound, xflip);
+}
+
+
+void Graphics::bobAnimReset(uint32 bobnum) {
BobSlot *pbs = &_bobs[bobnum];
- pbs->active = true;
- pbs->animating = true;
- pbs->frameNum = firstFrame;
- pbs->anim.speed = speed;
- pbs->anim.speedBak = speed;
- pbs->anim.string.buffer = NULL;
- pbs->anim.normal.firstFrame = firstFrame;
- pbs->anim.normal.lastFrame = lastFrame;
- pbs->anim.normal.rebound = rebound;
- pbs->frameDir = 1;
- pbs->xflip = xflip;
+ if(pbs->active && pbs->animating) {
+ const AnimFrame *anim = pbs->anim.string.buffer;
+ if (anim != NULL) {
+ pbs->anim.string.curPos = anim;
+ pbs->frameNum = anim->frame;
+ pbs->anim.speed = anim->speed / 4;
+ }
+ else {
+ pbs->anim.speed = pbs->anim.speedBak;
+ pbs->frameNum = pbs->anim.normal.firstFrame;
+ pbs->frameDir = 1;
+ }
+ }
}
@@ -296,7 +298,34 @@ void BobSlot::animOneStep() {
}
}
}
-
+
+
+void BobSlot::animString(const AnimFrame *animBuf) {
+
+ active = true;
+ animating = true;
+ anim.string.buffer = animBuf;
+ anim.string.curPos = animBuf;
+ frameNum = animBuf->frame;
+ anim.speed = animBuf->speed / 4;
+}
+
+
+void BobSlot::animNormal(uint16 firstFrame, uint16 lastFrame, uint16 spd, bool rebound, bool flip) {
+
+ active = true;
+ animating = true;
+ frameNum = firstFrame;
+ anim.speed = spd;
+ anim.speedBak = spd;
+ anim.string.buffer = NULL;
+ anim.normal.firstFrame = firstFrame;
+ anim.normal.lastFrame = lastFrame;
+ anim.normal.rebound = rebound;
+ frameDir = 1;
+ xflip = flip;
+}
+
void Graphics::bobDraw(uint32 bobnum, int16 x, int16 y, uint16 scale, bool xflip, const Box& box) {
diff --git a/queen/graphics.h b/queen/graphics.h
index 55205aa4cc..41054fe9ca 100644
--- a/queen/graphics.h
+++ b/queen/graphics.h
@@ -90,6 +90,9 @@ struct BobSlot {
void moveOneStep();
void animOneStep();
+
+ void animString(const AnimFrame *animBuf);
+ void animNormal(uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip);
};
@@ -117,6 +120,7 @@ public:
void bobSetupControl();
void bobAnimString(uint32 bobnum, const AnimFrame *buf); // stringanim()
void bobAnimNormal(uint32 bobnum, uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip); // makeanim()
+ void bobAnimReset(uint32 bobnum);
void bobMove(uint32 bobnum, int16 endx, int16 endy, int16 speed); // movebob()
void bobDraw(uint32 bobnum, int16 x, int16 y, uint16 scale, bool xflip, const Box& box); // bob()
void bobDrawInventoryItem(uint32 bobnum, uint16 x, uint16 y); // invbob()
diff --git a/queen/logic.cpp b/queen/logic.cpp
index b4889a4bcc..29cc6ecbe7 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -900,7 +900,9 @@ void Logic::roomSetupObjects() {
if (pgd->firstFrame < 0) {
// FIXME: if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
curBob = 5 + _numFurnitureAnimated;
- AnimFrame *paf = NULL;
+ animSetup(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
+ curImage += pgd->lastFrame;
+/* AnimFrame *paf = NULL;
if (pod->name > 0) {
paf = _newAnim[curBob + numObjectAnimated];
}
@@ -918,7 +920,7 @@ void Logic::roomSetupObjects() {
}
else {
pbs->animating = false;
- }
+ }*/
++numObjectAnimated;
}
else if (lastFrame != 0) {
@@ -1062,7 +1064,9 @@ uint16 Logic::roomRefreshObject(uint16 obj) {
rebound = true;
}
if (pgd->firstFrame < 0) {
- AnimFrame *paf = NULL;
+ animSetup(pgd, curImage, curBob, pod->name != 0);
+ curImage += pgd->lastFrame - 1;
+/* AnimFrame *paf = NULL;
if (pod->name != 0) {
paf = _newAnim[curBob];
}
@@ -1079,7 +1083,7 @@ uint16 Logic::roomRefreshObject(uint16 obj) {
}
else {
pbs->animating = false;
- }
+ }*/
}
else if (lastFrame != 0) {
// turn on an animated bob
@@ -1331,6 +1335,7 @@ uint16 Logic::personAllocate(uint16 noun, uint16 curImage) {
++curImage;
}
}
+ // FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
_personFrames[bobNum] = curImage + 1;
}
}
@@ -1399,6 +1404,7 @@ uint16 Logic::animCreate(uint16 curImage, const Person *person) {
void Logic::animErase(uint16 bobNum) {
+
_newAnim[bobNum][0].frame = 0;
BobSlot *pbs = _graphics->bob(bobNum);
pbs->animating = false;
@@ -1406,7 +1412,7 @@ void Logic::animErase(uint16 bobNum) {
}
-int16 Logic::animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *paf) {
+void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible) {
int16 tempFrames[20];
memset(tempFrames, 0, sizeof(tempFrames));
@@ -1450,7 +1456,15 @@ int16 Logic::animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *pa
for (i = 0; i < gd->lastFrame; ++i) {
_graphics->bankUnpack(ABS(tempFrames[i]), firstImage + i, 15);
}
- if (paf != NULL) {
+ BobSlot *pbs = _graphics->bob(bobNum);
+ pbs->animating = false;
+ if (visible) {
+ pbs->x = gd->x;
+ pbs->y = gd->y;
+ if (tempFrames[0] < 0) {
+ pbs->xflip = true;
+ }
+ AnimFrame *paf = _newAnim[bobNum];
for (i = 1; i <= _numGraphicAnim; ++i) {
const GraphicAnim *pga = &_graphicAnim[i];
if (pga->keyFrame == gd->firstFrame) {
@@ -1472,8 +1486,8 @@ int16 Logic::animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *pa
}
paf->frame = 0;
paf->speed = 0;
+ pbs->animString(_newAnim[bobNum]);
}
- return tempFrames[0];
}
diff --git a/queen/logic.h b/queen/logic.h
index 3c684f77de..71cdf65cac 100644
--- a/queen/logic.h
+++ b/queen/logic.h
@@ -131,7 +131,7 @@ public:
uint16 animCreate(uint16 curImage, const Person *person); // CREATE_ANIM
void animErase(uint16 bobNum);
- int16 animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *paf); // FIND_GRAPHIC_ANIMS
+ void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible); // FIND_GRAPHIC_ANIMS
StateDirection findStateDirection(uint16 state); // == FIND_STATE(state, "DIR");
StateTalk findStateTalk (uint16 state); // == FIND_STATE(state, "TALK");
@@ -240,7 +240,7 @@ protected:
//! Last frame number used for person animation
uint16 _personFrames[4];
- //! Describe an string based animation (30 frames maximum, bob number must be < 17)
+ //! Describe a string based animation (30 frames maximum, bob number must be < 17)
AnimFrame _newAnim[17][30];
Resource *_resource;