From 1537e162f607610947f1ab0ccdeae31a00caaf36 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 25 Sep 2008 10:11:06 +0000 Subject: SCUMM: Moved more stuf from class Actor to ActorHE svn-id: r34648 --- engines/scumm/actor.cpp | 78 +++++++++++++++++++++++---------------- engines/scumm/actor.h | 60 ++++++++++++++++-------------- engines/scumm/akos.cpp | 20 +++++----- engines/scumm/he/intern_he.h | 3 +- engines/scumm/he/script_v71he.cpp | 8 ++-- engines/scumm/he/script_v90he.cpp | 10 ++--- 6 files changed, 101 insertions(+), 78 deletions(-) (limited to 'engines') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index d794d5db01..b2bb8be9c9 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -881,9 +881,9 @@ void Actor::putActor(int dstX, int dstY, int newRoom) { _vm->stopTalk(); } - // WORKAROUND: The green transparency of the tank in the Hall of Oddities is - // is positioned one pixel too far to the left. This appears to be a - // bug in the original game as well. + // WORKAROUND: The green transparency of the tank in the Hall of Oddities + // is positioned one pixel too far to the left. This appears to be a bug + // in the original game as well. if (_vm->_game.id == GID_SAMNMAX && newRoom == 16 && _number == 5 && dstX == 235 && dstY == 236) dstX++; @@ -906,7 +906,7 @@ void Actor::putActor(int dstX, int dstY, int newRoom) { } else { #ifdef ENABLE_HE if (_vm->_game.heversion >= 71) - ((ScummEngine_v71he *)_vm)->queueAuxBlock(this); + ((ScummEngine_v71he *)_vm)->queueAuxBlock((ActorHE *)this); #endif hideActor(); } @@ -1210,6 +1210,10 @@ void Actor::hideActor() { _cost.soundCounter = 0; _needRedraw = false; _needBgReset = true; +} + +void ActorHE::hideActor() { + Actor::hideActor(); _auxBlock.reset(); } @@ -1633,13 +1637,15 @@ void Actor::startAnimActor(int f) { if (isInCurrentRoom() && _costume != 0) { _animProgress = 0; - _cost.animCounter = 0; _needRedraw = true; + _cost.animCounter = 0; // V1 - V2 games don't seem to need a _cost.reset() at this point. // Causes Zak to lose his body in several scenes, see bug #771508 if (_vm->_game.version >= 3 && f == _initFrame) { _cost.reset(); - _auxBlock.reset(); + if (_vm->_game.heversion != 0) { + ((ActorHE *)this)->_auxBlock.reset(); + } } _vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1); _frame = f; @@ -1780,7 +1786,7 @@ void ScummEngine::resetActorBgs() { clearGfxUsageBit(strip, USAGE_BIT_DIRTY); clearGfxUsageBit(strip, USAGE_BIT_RESTORED); for (j = 1; j < _numActors; j++) { - if (_actors[j]->_heFlags & 1) + if (_game.heversion != 0 && ((ActorHE *)_actors[j])->_heFlags & 1) continue; if (testGfxUsageBit(strip, j) && @@ -1958,7 +1964,8 @@ void ScummEngine::actorTalk(const byte *msg) { stopTalk(); } setTalkingActor(a->_number); - a->_heTalking = true; + if (_game.heversion != 0) + ((ActorHE *)a)->_heTalking = true; if (!_string[0].no_talk_anim) { a->runActorTalkScript(a->_talkStartFrame); _useTalkAnims = true; @@ -2031,7 +2038,8 @@ void ScummEngine::stopTalk() { } if (_game.version <= 7 && _game.heversion == 0) setTalkingActor(0xFF); - a->_heTalking = false; + if (_game.heversion != 0) + ((ActorHE *)a)->_heTalking = false; } if (_game.id == GID_DIG || _game.id == GID_CMI) { @@ -2057,9 +2065,7 @@ void ScummEngine::stopTalk() { #pragma mark - -void Actor::setActorCostume(int c) { - int i; - +void ActorHE::setActorCostume(int c) { if (_vm->_game.heversion >= 61 && (c == -1 || c == -2)) { _heSkipLimbs = (c == -1); _needRedraw = true; @@ -2071,27 +2077,43 @@ void Actor::setActorCostume(int c) { if (_vm->_game.heversion == 61) c &= 0xff; - _costumeNeedsInit = true; - if (_vm->_game.features & GF_NEW_COSTUMES) { - memset(_animVariable, 0, sizeof(_animVariable)); - #ifdef ENABLE_HE if (_vm->_game.heversion >= 71) ((ScummEngine_v71he *)_vm)->queueAuxBlock(this); #endif + _auxBlock.reset(); + if (_visible) { + if (_vm->_game.heversion >= 60) + _needRedraw = true; + } + } + + Actor::setActorCostume(c); + + if (_vm->_game.heversion >= 71 && _vm->getTalkingActor() == _number) { + if (_vm->_game.heversion <= 95 || (_vm->_game.heversion >= 98 && _vm->VAR(_vm->VAR_SKIP_RESET_TALK_ACTOR) == 0)) { + _vm->setTalkingActor(0); + } + } +} + +void Actor::setActorCostume(int c) { + int i; + + _costumeNeedsInit = true; + + if (_vm->_game.features & GF_NEW_COSTUMES) { + memset(_animVariable, 0, sizeof(_animVariable)); _costume = c; _cost.reset(); - _auxBlock.reset(); if (_visible) { if (_costume) { _vm->ensureResourceLoaded(rtCostume, _costume); } startAnimActor(_initFrame); - if (_vm->_game.heversion >= 60) - _needRedraw = true; } } else { if (_visible) { @@ -2126,12 +2148,6 @@ void Actor::setActorCostume(int c) { for (i = 0; i < 32; i++) _palette[i] = 0xFF; } - - if (_vm->_game.heversion >= 71 && _vm->getTalkingActor() == _number) { - if (_vm->_game.heversion <= 95 || (_vm->_game.heversion >= 98 && _vm->VAR(_vm->VAR_SKIP_RESET_TALK_ACTOR) == 0)) { - _vm->setTalkingActor(0); - } - } } static const char* v0ActorNames[7] = { @@ -2267,7 +2283,7 @@ bool Actor_v2::isPlayer() { return _vm->VAR(42) <= _number && _number <= _vm->VAR(43); } -void Actor::setHEFlag(int bit, int set) { +void ActorHE::setHEFlag(int bit, int set) { // Note that condition is inverted if (!set) { _heFlags |= bit; @@ -2276,7 +2292,7 @@ void Actor::setHEFlag(int bit, int set) { } } -void Actor::setUserCondition(int slot, int set) { +void ActorHE::setUserCondition(int slot, int set) { const int condMaskCode = (_vm->_game.heversion >= 85) ? 0x1FFF : 0x3FF; assertRange(1, slot, 32, "setUserCondition: Condition"); if (set == 0) { @@ -2291,12 +2307,12 @@ void Actor::setUserCondition(int slot, int set) { } } -bool Actor::isUserConditionSet(int slot) const { +bool ActorHE::isUserConditionSet(int slot) const { assertRange(1, slot, 32, "isUserConditionSet: Condition"); return (_heCondMask & (1 << (slot + 0xF))) != 0; } -void Actor::setTalkCondition(int slot) { +void ActorHE::setTalkCondition(int slot) { const int condMaskCode = (_vm->_game.heversion >= 85) ? 0x1FFF : 0x3FF; assertRange(1, slot, 32, "setTalkCondition: Condition"); _heCondMask = (_heCondMask & ~condMaskCode) | 1; @@ -2310,7 +2326,7 @@ void Actor::setTalkCondition(int slot) { } } -bool Actor::isTalkConditionSet(int slot) const { +bool ActorHE::isTalkConditionSet(int slot) const { assertRange(1, slot, 32, "isTalkConditionSet: Condition"); return (_heCondMask & (1 << (slot - 1))) != 0; } @@ -2400,7 +2416,7 @@ void ScummEngine_v71he::postProcessAuxQueue() { _auxEntriesNum = 0; } -void ScummEngine_v71he::queueAuxBlock(Actor *a) { +void ScummEngine_v71he::queueAuxBlock(ActorHE *a) { if (!a->_auxBlock.visible) return; diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index fe5865d12b..3e8fe6626b 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -61,6 +61,7 @@ struct CostumeData { uint16 end[16]; uint16 frame[16]; + /* HE specific */ uint16 heJumpOffsetTable[16]; uint16 heJumpCountTable[16]; uint32 heCondMaskTable[16]; @@ -133,27 +134,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; uint32 _heCondMask; uint32 _hePaletteNum; uint32 _heXmapNum; - byte _heFlags; - - AuxBlock _auxBlock; - - struct { - int16 posX; - int16 posY; - int16 color; - byte sentence[128]; - } _heTalkQueue[16]; protected: struct ActorWalkData { @@ -188,7 +173,7 @@ public: virtual ~Actor() {} //protected: - void hideActor(); + virtual void hideActor(); void showActor(); virtual void initActor(int mode); @@ -227,7 +212,7 @@ public: void drawActorCostume(bool hitTestMode = false); virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr); void animateCostume(); - void setActorCostume(int c); + virtual void setActorCostume(int c); void animateLimb(int limb, int f); @@ -318,14 +303,6 @@ public: void classChanged(int cls, bool value); - void setHEFlag(int bit, int set); - - void setUserCondition(int slot, int set); - bool isUserConditionSet(int slot) const; - - void setTalkCondition(int slot); - bool isTalkConditionSet(int slot) const; - // Used by the save/load system: void saveLoadWithSerializer(Serializer *ser); @@ -342,10 +319,39 @@ public: ActorHE(ScummEngine *scumm, int id) : Actor(scumm, id) {} virtual void initActor(int mode); + + virtual void hideActor(); + void drawActorToBackBuf(int x, int y); -protected: + void setHEFlag(int bit, int set); + + void setUserCondition(int slot, int set); + bool isUserConditionSet(int slot) const; + + void setTalkCondition(int slot); + bool isTalkConditionSet(int slot) const; + +public: + /** This rect is used to clip actor drawing. */ + Common::Rect _clipOverride; + + bool _heNoTalkAnimation; + bool _heTalking; + byte _heFlags; + + AuxBlock _auxBlock; + + struct { + int16 posX; + int16 posY; + int16 color; + byte sentence[128]; + } _heTalkQueue[16]; + + virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr); + virtual void setActorCostume(int c); }; class Actor_v3 : public Actor { diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index cca45b06fd..19c7c3320b 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -1664,28 +1664,28 @@ bool ScummEngine_v6::akos_increaseAnim(Actor *a, int chan, const byte *aksq, con akos_queCommand(9, a, a->_sound[a->getAnimVar(GB(2))], 0); continue; case AKC_C045: - a->setUserCondition(GB(3), a->getAnimVar(GB(4))); + ((ActorHE *)a)->setUserCondition(GB(3), a->getAnimVar(GB(4))); continue; case AKC_C046: - a->setAnimVar(GB(4), a->isUserConditionSet(GB(3))); + a->setAnimVar(GB(4), ((ActorHE *)a)->isUserConditionSet(GB(3))); continue; case AKC_C047: - a->setTalkCondition(GB(3)); + ((ActorHE *)a)->setTalkCondition(GB(3)); continue; case AKC_C048: - a->setAnimVar(GB(4), a->isTalkConditionSet(GB(3))); + a->setAnimVar(GB(4), ((ActorHE *)a)->isTalkConditionSet(GB(3))); continue; case AKC_C0A0: akos_queCommand(8, a, GB(2), 0); continue; case AKC_C0A1: - if (a->_heTalking != 0) { + if (((ActorHE *)a)->_heTalking != 0) { curpos = GUW(2); break; } continue; case AKC_C0A2: - if (a->_heTalking == 0) { + if (((ActorHE *)a)->_heTalking == 0) { curpos = GUW(2); break; } @@ -1775,13 +1775,13 @@ void ScummEngine_v6::akos_processQueue() { case 8: _actorToPrintStrFor = a->_number; - a->_talkPosX = a->_heTalkQueue[param_1].posX; - a->_talkPosY = a->_heTalkQueue[param_1].posY; - a->_talkColor = a->_heTalkQueue[param_1].color; + a->_talkPosX = ((ActorHE *)a)->_heTalkQueue[param_1].posX; + a->_talkPosY = ((ActorHE *)a)->_heTalkQueue[param_1].posY; + a->_talkColor = ((ActorHE *)a)->_heTalkQueue[param_1].color; _string[0].loadDefault(); _string[0].color = a->_talkColor; - actorTalk(a->_heTalkQueue[param_1].sentence); + actorTalk(((ActorHE *)a)->_heTalkQueue[param_1].sentence); break; case 9: diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index 72ba7edb85..8fd9122503 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -39,6 +39,7 @@ class WriteStream; namespace Scumm { +class ActorHE; class ResExtractor; #ifdef ENABLE_HE class LogicHE; @@ -243,7 +244,7 @@ public: AuxEntry _auxEntries[16]; uint16 _auxEntriesNum; - void queueAuxBlock(Actor *a); + void queueAuxBlock(ActorHE *a); void queueAuxEntry(int actorNum, int subIndex); void remapHEPalette(const uint8 *src, uint8 *dst); diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp index 557fd2d285..f11825dbee 100644 --- a/engines/scumm/he/script_v71he.cpp +++ b/engines/scumm/he/script_v71he.cpp @@ -498,7 +498,7 @@ void ScummEngine_v71he::adjustRect(Common::Rect &rect) { void ScummEngine_v71he::o71_kernelSetFunctions() { int args[29]; int num; - Actor *a; + ActorHE *a; num = getStackList(args, ARRAYSIZE(args)); @@ -509,7 +509,7 @@ void ScummEngine_v71he::o71_kernelSetFunctions() { virtScreenLoad(args[1], args[2], args[3], args[4], args[5]); break; case 20: // HE72+ - a = derefActor(args[1], "o71_kernelSetFunctions: 20"); + a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 20"); ((ScummEngine_v71he *)this)->queueAuxBlock(a); break; case 21: @@ -531,14 +531,14 @@ void ScummEngine_v71he::o71_kernelSetFunctions() { redrawAllActors(); break; case 26: - a = derefActor(args[1], "o71_kernelSetFunctions: 26"); + a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 26"); a->_auxBlock.r.left = 0; a->_auxBlock.r.right = -1; a->_auxBlock.r.top = 0; a->_auxBlock.r.bottom = -2; break; case 30: - a = derefActor(args[1], "o71_kernelSetFunctions: 30"); + a = (ActorHE *)derefActor(args[1], "o71_kernelSetFunctions: 30"); a->_clipOverride.bottom = args[2]; break; case 42: diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index 607628ea4b..9829d0ecb5 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -1615,13 +1615,13 @@ void ScummEngine_v90he::o90_getWizData() { } void ScummEngine_v90he::o90_getActorData() { - Actor *a; + ActorHE *a; int subOp = pop(); int val = pop(); int act = pop(); - a = derefActor(act, "o90_getActorData"); + a = (ActorHE *)derefActor(act, "o90_getActorData"); switch (subOp) { case 1: @@ -2568,13 +2568,13 @@ void ScummEngine_v90he::o90_kernelGetFunctions() { void ScummEngine_v90he::o90_kernelSetFunctions() { int args[29]; int num, tmp; - Actor *a; + ActorHE *a; num = getStackList(args, ARRAYSIZE(args)); switch (args[0]) { case 20: - a = derefActor(args[1], "o90_kernelSetFunctions: 20"); + a = (ActorHE *)derefActor(args[1], "o90_kernelSetFunctions: 20"); queueAuxBlock(a); break; case 21: @@ -2616,7 +2616,7 @@ void ScummEngine_v90he::o90_kernelSetFunctions() { // Remote start script function break; case 1969: - a = derefActor(args[1], "o90_kernelSetFunctions: 1969"); + a = (ActorHE *)derefActor(args[1], "o90_kernelSetFunctions: 1969"); tmp = a->_heCondMask; tmp ^= args[2]; tmp &= 0x7FFF0000; -- cgit v1.2.3