aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorMax Horn2008-09-25 08:06:18 +0000
committerMax Horn2008-09-25 08:06:18 +0000
commit8d16a42c932c3dc147ce1b1ec801ac8293fb360e (patch)
treec77cbae538c3e7f1927d8e7fc91ff73333de2378 /engines/scumm
parent84379f1124bd68a228e83219bc57b0f56fffd5f5 (diff)
downloadscummvm-rg350-8d16a42c932c3dc147ce1b1ec801ac8293fb360e.tar.gz
scummvm-rg350-8d16a42c932c3dc147ce1b1ec801ac8293fb360e.tar.bz2
scummvm-rg350-8d16a42c932c3dc147ce1b1ec801ac8293fb360e.zip
SCUMM: Added a new ActorHE class, as well as a virtual Actor::prepareDrawActorCostume() method
svn-id: r34646
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/actor.cpp128
-rw-r--r--engines/scumm/actor.h21
-rw-r--r--engines/scumm/akos.cpp8
-rw-r--r--engines/scumm/scumm.cpp2
-rw-r--r--engines/scumm/scumm.h2
5 files changed, 99 insertions, 62 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index df6660523a..8172c1f41f 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -50,9 +50,11 @@ Actor::Actor(ScummEngine *scumm, int id) :
assert(_vm != 0);
}
-void Actor::initActor(int mode) {
- // begin HE specific
+void ActorHE::initActor(int mode) {
+ Actor::initActor(mode);
+
if (mode == -1) {
+ _heOffsX = _heOffsY = 0;
_heSkipLimbs = false;
memset(_heTalkQueue, 0, sizeof(_heTalkQueue));
}
@@ -70,11 +72,18 @@ void Actor::initActor(int mode) {
_hePaletteNum = 0;
_heFlags = 0;
_heTalking = false;
- // end HE specific
+ if (_vm->_game.heversion >= 61)
+ _flip = 0;
+
+ _clipOverride = _vm->_actorClipOverride;
+
+ _auxBlock.reset();
+}
+
+void Actor::initActor(int mode) {
if (mode == -1) {
- _offsX = _offsY = 0;
_top = _bottom = 0;
_needRedraw = false;
_needBgReset = false;
@@ -132,9 +141,6 @@ void Actor::initActor(int mode) {
_forceClip = (_vm->_game.version >= 7) ? 100 : 0;
_ignoreTurns = false;
- if (_vm->_game.heversion >= 61)
- _flip = 0;
-
_talkFrequency = 256;
_talkPan = 64;
_talkVolume = 127;
@@ -148,10 +154,6 @@ void Actor::initActor(int mode) {
_walkScript = 0;
_talkScript = 0;
- _clipOverride = _vm->_actorClipOverride;
-
- _auxBlock.reset();
-
_vm->_classData[_number] = (_vm->_game.version >= 7) ? _vm->_classData[0] : 0;
}
@@ -1434,39 +1436,28 @@ void Actor::drawActorCostume(bool hitTestMode) {
}
setupActorScale();
+
+ BaseCostumeRenderer *bcr = _vm->_costumeRenderer;
+ prepareDrawActorCostume(bcr);
- BaseCostumeRenderer* bcr = _vm->_costumeRenderer;
-
- bcr->_actorID = _number;
-
- bcr->_actorX = _pos.x + _offsX;
- bcr->_actorY = _pos.y + _offsY - _elevation;
-
- if (_vm->_game.version <= 2) {
- bcr->_actorX *= V12_X_MULTIPLIER;
- bcr->_actorY *= V12_Y_MULTIPLIER;
+ // If the actor is partially hidden, redraw it next frame.
+ if (bcr->drawCostume(_vm->_virtscr[kMainVirtScreen], _vm->_gdi->_numStrips, this, _drawToBackBuf) & 1) {
+ _needRedraw = (_vm->_game.version <= 6);
}
- bcr->_actorX -= _vm->_virtscr[kMainVirtScreen].xstart;
- if (_vm->_game.platform == Common::kPlatformNES) {
- // In the NES version, when the actor is facing right,
- // we need to shift it 8 pixels to the left
- if (_facing == 90)
- bcr->_actorX -= 8;
- } else if (_vm->_game.version <= 2) {
- // HACK: We have to adjust the x position by one strip (8 pixels) in
- // V2 games. However, it is not quite clear to me why. And to fully
- // match the original, it seems we have to offset by 2 strips if the
- // actor is facing left (270 degree).
- // V1 games are once again slightly different, here we only have
- // to adjust the 270 degree case...
- if (_facing == 270)
- bcr->_actorX += 16;
- else if (_vm->_game.version == 2)
- bcr->_actorX += 8;
+ if (!hitTestMode) {
+ // Record the vertical extent of the drawn actor
+ _top = bcr->_draw_top;
+ _bottom = bcr->_draw_bottom;
}
+}
- bcr->_clipOverride = _clipOverride;
+
+void Actor::prepareDrawActorCostume(BaseCostumeRenderer *bcr) {
+
+ bcr->_actorID = _number;
+ bcr->_actorX = _pos.x - _vm->_virtscr[kMainVirtScreen].xstart;
+ bcr->_actorY = _pos.y - _elevation;
if (_vm->_game.version == 4 && (_boxscale & 0x8000)) {
bcr->_scaleX = bcr->_scaleY = _vm->getScaleFromSlot((_boxscale & 0x7fff) + 1, _pos.x, _pos.y);
@@ -1478,8 +1469,6 @@ void Actor::drawActorCostume(bool hitTestMode) {
bcr->_shadow_mode = _shadowMode;
if (_vm->_game.version >= 5 && _vm->_game.heversion == 0) {
bcr->_shadow_table = _vm->_shadowPalette;
- } else if (_vm->_game.heversion == 70) {
- bcr->_shadow_table = _vm->_HEV7ActorPalette;
}
bcr->setCostume(_costume, _heXmapNum);
@@ -1510,6 +1499,19 @@ void Actor::drawActorCostume(bool hitTestMode) {
bcr->_draw_top = 0x7fffffff;
bcr->_draw_bottom = 0;
+}
+
+void ActorHE::prepareDrawActorCostume(BaseCostumeRenderer *bcr) {
+ Actor::prepareDrawActorCostume(bcr);
+
+ bcr->_actorX += _heOffsX;
+ bcr->_actorY += _heOffsY;
+
+ bcr->_clipOverride = _clipOverride;
+
+ if (_vm->_game.heversion == 70) {
+ bcr->_shadow_table = _vm->_HEV7ActorPalette;
+ }
bcr->_skipLimbs = (_heSkipLimbs != 0);
bcr->_paletteNum = _hePaletteNum;
@@ -1530,16 +1532,36 @@ void Actor::drawActorCostume(bool hitTestMode) {
}
}
_heNoTalkAnimation = 0;
+}
- // If the actor is partially hidden, redraw it next frame.
- if (bcr->drawCostume(_vm->_virtscr[kMainVirtScreen], _vm->_gdi->_numStrips, this, _drawToBackBuf) & 1) {
- _needRedraw = (_vm->_game.version <= 6);
+void Actor_v2::prepareDrawActorCostume(BaseCostumeRenderer *bcr) {
+ Actor::prepareDrawActorCostume(bcr);
+
+ bcr->_actorX = _pos.x;
+ bcr->_actorY = _pos.y - _elevation;
+
+ if (_vm->_game.version <= 2) {
+ bcr->_actorX *= V12_X_MULTIPLIER;
+ bcr->_actorY *= V12_Y_MULTIPLIER;
}
+ bcr->_actorX -= _vm->_virtscr[kMainVirtScreen].xstart;
- if (!hitTestMode) {
- // Record the vertical extent of the drawn actor
- _top = bcr->_draw_top;
- _bottom = bcr->_draw_bottom;
+ if (_vm->_game.platform == Common::kPlatformNES) {
+ // In the NES version, when the actor is facing right,
+ // we need to shift it 8 pixels to the left
+ if (_facing == 90)
+ bcr->_actorX -= 8;
+ } else if (_vm->_game.version <= 2) {
+ // HACK: We have to adjust the x position by one strip (8 pixels) in
+ // V2 games. However, it is not quite clear to me why. And to fully
+ // match the original, it seems we have to offset by 2 strips if the
+ // actor is facing left (270 degree).
+ // V1 games are once again slightly different, here we only have
+ // to adjust the 270 degree case...
+ if (_facing == 270)
+ bcr->_actorX += 16;
+ else if (_vm->_game.version == 2)
+ bcr->_actorX += 8;
}
}
@@ -2311,10 +2333,10 @@ void ScummEngine_v71he::postProcessAuxQueue() {
for (int i = 0; i < _auxEntriesNum; ++i) {
AuxEntry *ae = &_auxEntries[i];
if (ae->actorNum != -1) {
- Actor *a = derefActor(ae->actorNum, "postProcessAuxQueue");
+ ActorHE *a = (ActorHE *)derefActor(ae->actorNum, "postProcessAuxQueue");
const uint8 *cost = getResourceAddress(rtCostume, a->_costume);
- int dy = a->_offsY + a->getPos().y;
- int dx = a->_offsX + a->getPos().x;
+ int dy = a->_heOffsY + a->getPos().y;
+ int dx = a->_heOffsX + a->getPos().x;
if (_game.heversion >= 72)
dy -= a->getElevation();
@@ -2401,8 +2423,8 @@ void Actor::saveLoadWithSerializer(Serializer *ser) {
static const SaveLoadEntry actorEntries[] = {
MKLINE(Actor, _pos.x, sleInt16, VER(8)),
MKLINE(Actor, _pos.y, sleInt16, VER(8)),
- MKLINE(Actor, _offsX, sleInt16, VER(32)),
- MKLINE(Actor, _offsY, sleInt16, VER(32)),
+ MKLINE(Actor, _heOffsX, sleInt16, VER(32)),
+ MKLINE(Actor, _heOffsY, sleInt16, VER(32)),
MKLINE(Actor, _top, sleInt16, VER(8)),
MKLINE(Actor, _bottom, sleInt16, VER(8)),
MKLINE(Actor, _elevation, sleInt16, VER(8)),
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 30dc7789d6..f49da7a9bc 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -95,10 +95,6 @@ protected:
Common::Point _pos;
public:
- /** HE specific: This rect is used to clip actor drawing. */
- Common::Rect _clipOverride;
-
- int _offsX, _offsY;
int _top, _bottom;
uint _width;
byte _number;
@@ -137,6 +133,11 @@ public:
CostumeData _cost;
/* HE specific */
+
+ /** This rect is used to clip actor drawing. */
+ Common::Rect _clipOverride;
+
+ int _heOffsX, _heOffsY;
bool _heNoTalkAnimation;
bool _heSkipLimbs;
bool _heTalking;
@@ -225,6 +226,7 @@ public:
virtual void walkActor();
void drawActorToBackBuf(int x, int y);
void drawActorCostume(bool hitTestMode = false);
+ virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
void animateCostume();
void setActorCostume(int c);
@@ -336,6 +338,16 @@ protected:
bool findPathTowards(byte box, byte box2, byte box3, Common::Point &foundPath);
};
+class ActorHE : public Actor {
+public:
+ ActorHE(ScummEngine *scumm, int id) : Actor(scumm, id) {}
+
+ virtual void initActor(int mode);
+
+protected:
+ virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
+};
+
class Actor_v3 : public Actor {
public:
Actor_v3(ScummEngine *scumm, int id) : Actor(scumm, id) {}
@@ -357,6 +369,7 @@ public:
protected:
virtual bool isPlayer();
+ virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
};
class ActorC64 : public Actor_v2 {
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index 8e8fff938d..cca45b06fd 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -1763,8 +1763,8 @@ void ScummEngine_v6::akos_processQueue() {
a->_forceClip = param_1;
break;
case 6:
- a->_offsX = param_1;
- a->_offsY = param_2;
+ a->_heOffsX = param_1;
+ a->_heOffsY = param_2;
break;
case 7:
#ifdef ENABLE_HE
@@ -1825,8 +1825,8 @@ void ScummEngine_v7::akos_processQueue() {
a->_forceClip = param_1;
break;
case 6:
- a->_offsX = param_1;
- a->_offsY = param_2;
+ a->_heOffsX = param_1;
+ a->_heOffsY = param_2;
break;
case 7:
if (param_1 != 0) {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index f87adfd9ac..a10af41145 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1307,6 +1307,8 @@ void ScummEngine::resetScumm() {
_actors[i] = new Actor_v2(this, i);
else if (_game.version == 3)
_actors[i] = new Actor_v3(this, i);
+ else if (_game.heversion != 0)
+ _actors[i] = new ActorHE(this, i);
else
_actors[i] = new Actor(this, i);
_actors[i]->initActor(-1);
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 27c8943fee..ec733d32f4 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -918,7 +918,7 @@ public:
// Generic costume code
bool isCostumeInUse(int i) const;
- Common::Rect _actorClipOverride;
+ Common::Rect _actorClipOverride; // HE specific
protected:
/* Should be in Graphics class? */