aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/actor.cpp24
-rw-r--r--scumm/actor.h13
-rw-r--r--scumm/akos.cpp12
-rw-r--r--scumm/base-costume.cpp21
-rw-r--r--scumm/base-costume.h14
-rw-r--r--scumm/costume.cpp22
-rw-r--r--scumm/debugger.cpp6
-rw-r--r--scumm/script_v2.cpp5
-rw-r--r--scumm/script_v5.cpp5
-rw-r--r--scumm/script_v6.cpp8
-rw-r--r--scumm/script_v8.cpp6
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/string.cpp4
13 files changed, 70 insertions, 72 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 275282aa86..dd6793508e 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -305,7 +305,7 @@ int Actor::updateActorDirection(bool is_walking) {
if (ignoreTurns)
return facing;
- dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(this) : false;
+ dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(costume) : false;
from = toSimpleDir(dirType, facing);
dir = remapDirection(targetFacing, is_walking);
@@ -876,7 +876,7 @@ void ScummEngine::processActors() {
for (int i = 1; i < _numActors; i++) {
if (_version == 8 && _actors[i].layer < 0)
continue;
- if (_actors[i].isInCurrentRoom())
+ if (_actors[i].isInCurrentRoom() && _actors[i].costume)
actors[numactors++] = &_actors[i];
}
if (!numactors) {
@@ -893,12 +893,10 @@ void ScummEngine::processActors() {
// Finally draw the now sorted actors
for (Actor** ac = actors; ac != end; ++ac) {
Actor* a = *ac;
- if (a->costume) {
- CHECK_HEAP
- a->drawActorCostume();
- CHECK_HEAP
- a->animateCostume();
- }
+ CHECK_HEAP
+ a->drawActorCostume();
+ CHECK_HEAP
+ a->animateCostume();
}
delete [] actors;
@@ -929,7 +927,7 @@ void Actor::drawActorCostume() {
BaseCostumeRenderer* bcr = _vm->_costumeRenderer;
- bcr->updateNbStrips();
+ bcr->_actorID = number;
bcr->_actorX = _pos.x - _vm->virtscr[0].xstart;
bcr->_actorY = _pos.y - elevation;
@@ -960,8 +958,6 @@ void Actor::drawActorCostume() {
bcr->setPalette(palette);
bcr->setFacing(this);
- bcr->_dirty_id = number;
-
if (!(_vm->_features & GF_NEW_COSTUMES)) {
if (forceClip)
@@ -989,13 +985,9 @@ void Actor::drawActorCostume() {
bcr->_draw_bottom = bottom = 0;
- bcr->_outptr = _vm->virtscr[0].screenPtr + _vm->virtscr[0].xstart;
- bcr->_outwidth = _vm->virtscr[0].width;
- bcr->_outheight = _vm->virtscr[0].height;
-
// If the actor is partially hidden, redraw it next frame.
// Only done for pre-AKOS, though.
- if (bcr->drawCostume(cost) & 1) {
+ if (bcr->drawCostume(_vm->virtscr[0], cost) & 1) {
needRedraw = !(_vm->_features & GF_NEW_COSTUMES);
}
diff --git a/scumm/actor.h b/scumm/actor.h
index b911a1727d..815690e368 100644
--- a/scumm/actor.h
+++ b/scumm/actor.h
@@ -85,7 +85,6 @@ public:
public:
Common::Point _pos;
int top, bottom;
- int elevation;
uint width;
byte number;
uint16 costume;
@@ -112,6 +111,7 @@ public:
CostumeData cost;
byte palette[256];
protected:
+ int elevation;
uint16 facing;
uint16 targetFacing;
uint speedx, speedy;
@@ -194,6 +194,17 @@ public:
animSpeed = newAnimSpeed;
animProgress = 0;
}
+
+ int getElevation() const {
+ return elevation;
+ }
+
+ void setElevation(int newElevation) {
+ if (elevation != newElevation) {
+ elevation = newElevation;
+ needRedraw = true;
+ }
+ }
void classChanged(int cls, bool value);
diff --git a/scumm/akos.cpp b/scumm/akos.cpp
index a0f583f36a..bcf6066ecf 100644
--- a/scumm/akos.cpp
+++ b/scumm/akos.cpp
@@ -113,11 +113,11 @@ static bool akos_compare(int a, int b, byte cmd) {
}
}
-bool ScummEngine::akos_hasManyDirections(Actor *a) {
+bool ScummEngine::akos_hasManyDirections(int costume) {
byte *akos;
const AkosHeader *akhd;
- akos = getResourceAddress(rtCostume, a->costume);
+ akos = getResourceAddress(rtCostume, costume);
assert(akos);
akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos);
@@ -125,7 +125,7 @@ bool ScummEngine::akos_hasManyDirections(Actor *a) {
}
int ScummEngine::akos_frameToAnim(Actor *a, int frame) {
- if (akos_hasManyDirections(a))
+ if (akos_hasManyDirections(a->costume))
return toSimpleDir(1, a->getFacing()) + frame * 8;
else
return newDirToOldDir(a->getFacing()) + frame * 4;
@@ -673,7 +673,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) {
if (_actorHitX < x_left || _actorHitX >= x_right || _actorHitY < y_top || _actorHitY >= y_bottom)
return 0;
} else
- _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right, y_top, y_bottom, _dirty_id);
+ _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right, y_top, y_bottom, _actorID);
if (y_top >= (int)_outheight || y_bottom <= 0)
return 0;
@@ -763,7 +763,7 @@ byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) {
maxw = _outwidth - 1;
maxh = _outheight - 1;
- _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
+ _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID);
if (clip_top < 0) {
clip_top = 0;
@@ -980,7 +980,7 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) {
cur_x = _width - 1;
cur_y = _height - 1;
- _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
+ _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID);
if (clip_left < 0) {
skip_x = -clip_left;
diff --git a/scumm/base-costume.cpp b/scumm/base-costume.cpp
index 67fb8eaf3d..691ea27d2b 100644
--- a/scumm/base-costume.cpp
+++ b/scumm/base-costume.cpp
@@ -25,10 +25,15 @@
namespace Scumm {
-byte BaseCostumeRenderer::drawCostume(const CostumeData &cost) {
+byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, const CostumeData &cost) {
int i;
byte result = 0;
+ _outptr = vs.screenPtr + vs.xstart;
+ _outwidth = vs.width;
+ _outheight = vs.height;
+ _numStrips = vs.width / 8;
+
if (_vm->_version == 1) {
_xmove = 0;
_ymove = 0;
@@ -61,4 +66,18 @@ void BaseCostumeRenderer::codec1_ignorePakCols(int num) {
} while (1);
}
+bool ScummEngine::isCostumeInUse(int cost) const {
+ int i;
+ Actor *a;
+
+ if (_roomResource != 0)
+ for (i = 1; i < _numActors; i++) {
+ a = derefActor(i);
+ if (a->isInCurrentRoom() && a->costume == cost)
+ return true;
+ }
+
+ return false;
+}
+
} // End of namespace Scumm
diff --git a/scumm/base-costume.h b/scumm/base-costume.h
index 45b522b616..5c5cf25bdd 100644
--- a/scumm/base-costume.h
+++ b/scumm/base-costume.h
@@ -44,13 +44,14 @@ struct CostumeInfo {
class Actor;
class ScummEngine;
+struct VirtScreen;
/**
* Base class for both CostumeRenderer and AkosRenderer.
*/
class BaseCostumeRenderer {
public:
- byte _dirty_id;
+ byte _actorID;
byte _shadow_mode;
byte *_shadow_table;
@@ -61,12 +62,12 @@ public:
int _draw_top, _draw_bottom;
+protected:
+ ScummEngine *_vm;
+
// Destination
byte *_outptr;
uint _outwidth, _outheight;
-
-protected:
- ScummEngine *_vm;
int32 _numStrips;
// Source pointer
@@ -98,7 +99,7 @@ protected:
public:
BaseCostumeRenderer(ScummEngine *scumm) {
- _dirty_id = 0;
+ _actorID = 0;
_shadow_mode = 0;
_shadow_table = 0;
_actorX = _actorY = 0;
@@ -120,10 +121,9 @@ public:
virtual void setPalette(byte *palette) = 0;
virtual void setFacing(Actor *a) = 0;
virtual void setCostume(int costume) = 0;
- void updateNbStrips (void) { _numStrips = _vm->gdi._numStrips; }
- byte drawCostume(const CostumeData &cost);
+ byte drawCostume(const VirtScreen &vs, const CostumeData &cost);
protected:
diff --git a/scumm/costume.cpp b/scumm/costume.cpp
index 9e1a0f4cdd..5ce63356cf 100644
--- a/scumm/costume.cpp
+++ b/scumm/costume.cpp
@@ -202,9 +202,9 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) {
if (_vm->_version == 1)
//HACK: it fix gfx glitches leaved by actor costume in V1 games, when actor moving to left
- _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 8, y_top, y_bottom, _dirty_id);
+ _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 8, y_top, y_bottom, _actorID);
else
- _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 1, y_top, y_bottom, _dirty_id);
+ _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 1, y_top, y_bottom, _actorID);
if (y_top >= (int)_outheight || y_bottom <= 0)
return 0;
@@ -280,8 +280,8 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) {
if (_loaded._format == 0x57) {
// The v1 costume renderer needs the actor number, which is
- // the same thing as the costume renderer's _dirty_id.
- procC64(_dirty_id);
+ // the same thing as the costume renderer's _actorID.
+ procC64(_actorID);
} else if (newAmiCost)
proc3_ami();
else
@@ -848,20 +848,6 @@ byte LoadedCostume::increaseAnim(Actor *a, int slot) {
} while (1);
}
-bool ScummEngine::isCostumeInUse(int cost) const {
- int i;
- Actor *a;
-
- if (_roomResource != 0)
- for (i = 1; i < _numActors; i++) {
- a = derefActor(i);
- if (a->isInCurrentRoom() && a->costume == cost)
- return true;
- }
-
- return false;
-}
-
} // End of namespace Scumm
#ifdef __PALM_OS__
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index 01d2e1ad81..6b65a9a36d 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -377,8 +377,8 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) {
DebugPrintf("Actor[%d].y = %d\n", actnum, a->_pos.y);
_vm->_fullRedraw = 1;
} else if (!strcmp(argv[2], "elevation")) {
- a->elevation = value;
- DebugPrintf("Actor[%d].elevation = %d\n", actnum, a->elevation);
+ a->setElevation(value);
+ DebugPrintf("Actor[%d].elevation = %d\n", actnum, a->getElevation());
_vm->_fullRedraw = 1;
} else if (!strcmp(argv[2], "costume")) {
if (value >= _vm->res.num[rtCostume])
@@ -408,7 +408,7 @@ bool ScummDebugger::Cmd_PrintActor(int argc, const char **argv) {
a = &_vm->_actors[i];
if (a->visible)
DebugPrintf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|$%02x|\n",
- a->number, a->room, a->_pos.x, a->_pos.y, a->elevation, a->costume,
+ a->number, a->room, a->_pos.x, a->_pos.y, a->getElevation(), a->costume,
a->width, a->walkbox, a->moving, a->forceClip, a->frame,
a->scalex, a->getFacing(), int(_vm->_classData[a->number]&0xFF));
}
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index d21c844943..6fc9047594 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -1153,7 +1153,7 @@ void ScummEngine_v2::o2_getActorElevation() {
getResultPos();
int act = getVarOrDirectByte(PARAM_1);
Actor *a = derefActor(act, "o2_getActorElevation");
- setResult(a->elevation / 2);
+ setResult(a->getElevation() / 2);
}
void ScummEngine_v2::o2_setActorElevation() {
@@ -1161,8 +1161,7 @@ void ScummEngine_v2::o2_setActorElevation() {
int elevation = (int8)getVarOrDirectByte(PARAM_2);
Actor *a = derefActor(act, "o2_setActorElevation");
- a->elevation = elevation * 2;
- a->needRedraw = true;
+ a->setElevation(elevation * 2);
}
void ScummEngine_v2::o2_animateActor() {
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 38e9fe7f58..f151d19571 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -446,8 +446,7 @@ void ScummEngine_v5::o5_actorOps() {
a->initActor(0);
break;
case 9: // SO_ELEVATION
- a->elevation = getVarOrDirectWord(PARAM_1);
- a->needRedraw = true;
+ a->setElevation(getVarOrDirectWord(PARAM_1));
break;
case 10: // SO_ANIMATION_DEFAULT
a->initFrame = 1;
@@ -1032,7 +1031,7 @@ void ScummEngine_v5::o5_getActorElevation() {
getResultPos();
int act = getVarOrDirectByte(PARAM_1);
Actor *a = derefActor(act, "o5_getActorElevation");
- setResult(a->elevation);
+ setResult(a->getElevation());
}
void ScummEngine_v5::o5_getActorFacing() {
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index f2e8637984..725c68615b 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -1254,7 +1254,7 @@ void ScummEngine_v6::o6_getActorCostume() {
void ScummEngine_v6::o6_getActorElevation() {
Actor *a = derefActor(pop(), "o6_getActorElevation");
- push(a->elevation);
+ push(a->getElevation());
}
void ScummEngine_v6::o6_getActorWidth() {
@@ -1692,11 +1692,7 @@ void ScummEngine_v6::o6_actorOps() {
a->initActor(0);
break;
case 84: // SO_ELEVATION
- i = pop();
- if (i != a->elevation) {
- a->elevation = i;
- a->needRedraw = true;
- }
+ a->setElevation(pop());
break;
case 85: // SO_ANIMATION_DEFAULT
a->initFrame = 1;
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index a88e65cf0c..75c240fd10 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -967,11 +967,7 @@ void ScummEngine_v8::o8_actorOps() {
a->initActor(0);
break;
case 0x6E: // SO_ACTOR_ELEVATION
- i = pop();
- if (i != a->elevation) {
- a->elevation = i;
- a->needRedraw = true;
- }
+ a->setElevation(pop());
break;
case 0x6F: // SO_ACTOR_PALETTE Set actor palette
j = pop();
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 08fd340b2e..1418a4f5a6 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -748,7 +748,7 @@ public:
void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2);
void akos_decodeData(Actor *a, int frame, uint usemask);
int akos_frameToAnim(Actor *a, int frame);
- bool akos_hasManyDirections(Actor *a);
+ bool akos_hasManyDirections(int costume);
protected:
/* Should be in Graphics class? */
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 80016dc286..64a696d5dc 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -118,14 +118,14 @@ void ScummEngine::CHARSET_1() {
if (VAR(VAR_V5_TALK_STRING_Y) < 0) {
s = (a->scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF;
- _string[0].ypos = (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s - a->elevation + a->_pos.y);
+ _string[0].ypos = (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s - a->getElevation() + a->_pos.y);
} else {
_string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y);
}
} else {
s = a->scaley * a->talkPosY / 0xFF;
- _string[0].ypos = ((a->talkPosY - s) / 2) + s - a->elevation + a->_pos.y;
+ _string[0].ypos = ((a->talkPosY - s) / 2) + s - a->getElevation() + a->_pos.y;
if (_string[0].ypos < _screenTop)
_string[0].ypos = _screenTop;