diff options
author | Max Horn | 2005-03-27 01:07:22 +0000 |
---|---|---|
committer | Max Horn | 2005-03-27 01:07:22 +0000 |
commit | abcf7bf2de88c3926843fa3fd613e50f5ea63cd5 (patch) | |
tree | ac27f9a9639270ceff80adb478f19fba339ea9bc /scumm | |
parent | 5bd26a52df502391714b539df30eb76e50c72cf7 (diff) | |
download | scummvm-rg350-abcf7bf2de88c3926843fa3fd613e50f5ea63cd5.tar.gz scummvm-rg350-abcf7bf2de88c3926843fa3fd613e50f5ea63cd5.tar.bz2 scummvm-rg350-abcf7bf2de88c3926843fa3fd613e50f5ea63cd5.zip |
Tie the AKOS code into the new costume infrastructure, too
svn-id: r17259
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 33 | ||||
-rw-r--r-- | scumm/akos.cpp | 42 | ||||
-rw-r--r-- | scumm/akos.h | 14 | ||||
-rw-r--r-- | scumm/base-costume.cpp | 14 | ||||
-rw-r--r-- | scumm/scumm.cpp | 12 | ||||
-rw-r--r-- | scumm/scumm.h | 7 |
6 files changed, 56 insertions, 66 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 4178d629b8..cf1691279c 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -320,14 +320,16 @@ int Actor::remapDirection(int dir, bool is_walking) { int Actor::updateActorDirection(bool is_walking) { int from; - int dirType; + bool dirType = false; int dir; bool shouldInterpolate; if ((_vm->_version == 6) && _ignoreTurns) return _facing; - dirType = (_vm->_version >= 7) ? _vm->akos_hasManyDirections(_costume) : false; + if (_vm->_version >= 7) { + dirType = ((AkosCostumeLoader *)_vm->_costumeLoader)->hasManyDirections(_costume); + } from = toSimpleDir(dirType, _facing); dir = remapDirection(_targetFacing, is_walking); @@ -467,7 +469,7 @@ void Actor::startAnimActor(int f) { _needRedraw = true; if (f == _initFrame) _cost.reset(); - _vm->costumeDecodeData(this, f, (uint) - 1); + _vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1); _frame = f; } } else { @@ -501,7 +503,7 @@ void Actor::startAnimActor(int f) { _cost.reset(); _auxBlock.visible = false; } - _vm->costumeDecodeData(this, f, (uint) - 1); + _vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1); _frame = f; } } @@ -570,7 +572,7 @@ void Actor::setDirection(int direction) { vald = _cost.frame[i]; if (vald == 0xFFFF) continue; - _vm->costumeDecodeData(this, vald, (_vm->_version <= 2) ? 0xFFFF : aMask); + _vm->_costumeLoader->costumeDecodeData(this, vald, (_vm->_version <= 2) ? 0xFFFF : aMask); } _needRedraw = true; @@ -1128,25 +1130,10 @@ void Actor::animateCostume() { if (_animProgress >= _animSpeed) { _animProgress = 0; - BaseCostumeLoader *cost = 0; - - if (_vm->_features & GF_NEW_COSTUMES) { - byte *akos = _vm->getResourceAddress(rtCostume, _costume); - assert(akos); - if (_vm->akos_increaseAnims(akos, this)) { - _needRedraw = true; - } - } else { - if (_vm->_features & GF_NES) - cost = new NESCostumeLoader(_vm); - else - cost = new ClassicCostumeLoader(_vm); - cost->loadCostume(_costume); - if (cost->increaseAnims(this)) { - _needRedraw = true; - } + _vm->_costumeLoader->loadCostume(_costume); + if (_vm->_costumeLoader->increaseAnims(this)) { + _needRedraw = true; } - delete cost; } } diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 28ef532c93..920141d4af 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -137,20 +137,21 @@ static bool akos_compare(int a, int b, byte cmd) { } } -bool ScummEngine::akos_hasManyDirections(int costume) { - byte *akos; - const AkosHeader *akhd; +void AkosCostumeLoader::loadCostume(int id) { + _akos = _vm->getResourceAddress(rtCostume, id); + assert(_akos); +} - akos = getResourceAddress(rtCostume, costume); - assert(akos); +bool AkosCostumeLoader::hasManyDirections() { + const AkosHeader *akhd; - akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos); + akhd = (const AkosHeader *)_vm->findResourceData(MKID('AKHD'), _akos); return (akhd->flags & 2) != 0; } -void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { +void AkosCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) { uint anim; - const byte *akos, *r; + const byte *r; const AkosHeader *akhd; uint offs; int i; @@ -161,20 +162,19 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { if (a->_costume == 0) return; - if (_version >= 7 && akos_hasManyDirections(a->_costume)) + loadCostume(a->_costume); + + if (_vm->_version >= 7 && hasManyDirections()) anim = toSimpleDir(1, a->getFacing()) + frame * 8; else anim = newDirToOldDir(a->getFacing()) + frame * 4; - akos = getResourceAddress(rtCostume, a->_costume); - assert(akos); - - akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos); + akhd = (const AkosHeader *)_vm->findResourceData(MKID('AKHD'), _akos); if (anim >= READ_LE_UINT16(&akhd->num_anims)) return; - r = findResourceData(MKID('AKCH'), akos); + r = _vm->findResourceData(MKID('AKCH'), _akos); assert(r); offs = READ_LE_UINT16(r + anim * sizeof(uint16)); @@ -182,8 +182,8 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { return; r += offs; - const uint8 *akst = findResourceData(MKID('AKST'), akos); - const uint8 *aksf = findResourceData(MKID('AKSF'), akos); + const uint8 *akst = _vm->findResourceData(MKID('AKST'), _akos); + const uint8 *aksf = _vm->findResourceData(MKID('AKSF'), _akos); i = 0; mask = READ_LE_UINT16(r); r += 2; @@ -201,7 +201,7 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { a->_cost.seq3[i] = 0; if (akst) { - int size = getResourceDataSize(akst) / 8; + int size = _vm->getResourceDataSize(akst) / 8; if (size > 0) { bool found = false; while (size--) { @@ -231,7 +231,7 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { a->_cost.seq1[i] = 0; a->_cost.seq2[i] = 0; if (aksf) { - int size = getResourceDataSize(aksf) / 6; + int size = _vm->getResourceDataSize(aksf) / 6; if (size > 0) { bool found = false; while (size--) { @@ -256,7 +256,7 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { a->_cost.curpos[i] = start; a->_cost.seq3[i] = 0; if (akst) { - int size = getResourceDataSize(akst) / 8; + int size = _vm->getResourceDataSize(akst) / 8; if (size > 0) { bool found = false; while (size--) { @@ -1239,6 +1239,10 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { return 0; } +byte AkosCostumeLoader::increaseAnims(Actor *a) { + return _vm->akos_increaseAnims(_akos, a); +} + bool ScummEngine::akos_increaseAnims(const byte *akos, Actor *a) { const byte *aksq, *akfo; int i; diff --git a/scumm/akos.h b/scumm/akos.h index 1055f9ab88..bbd1f41f60 100644 --- a/scumm/akos.h +++ b/scumm/akos.h @@ -37,18 +37,26 @@ struct CostumeData; struct AkosHeader; struct AkosOffset; -/* TODO: class AkosCostumeLoader : public BaseCostumeLoader { +protected: + const byte *_akos; + public: - AkosCostumeLoader(ScummEngine *vm); + AkosCostumeLoader(ScummEngine *vm) : BaseCostumeLoader(vm) {} void loadCostume(int id); byte increaseAnims(Actor *a); void costumeDecodeData(Actor *a, int frame, uint usemask); //void animateLimb(int limb, int f); + bool hasManyDirections(int id) { + loadCostume(id); + return hasManyDirections(); + } + +protected: + bool hasManyDirections(); }; -*/ class AkosRenderer : public BaseCostumeRenderer { protected: diff --git a/scumm/base-costume.cpp b/scumm/base-costume.cpp index c1402f922e..89df0607a3 100644 --- a/scumm/base-costume.cpp +++ b/scumm/base-costume.cpp @@ -88,18 +88,4 @@ bool ScummEngine::isCostumeInUse(int cost) const { return false; } -void ScummEngine::costumeDecodeData(Actor *a, int frame, uint usemask) { - // TODO: This should eventually become a method of the appropriate - // BaseCostumeLoader subclasses. - if (_features & GF_NEW_COSTUMES) - akos_decodeData(a, frame, usemask); - else if (_features & GF_NES) { - NESCostumeLoader lc(this); - lc.costumeDecodeData(a, frame, usemask); - } else { - ClassicCostumeLoader lc(this); - lc.costumeDecodeData(a, frame, usemask); - } -} - } // End of namespace Scumm diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 8fe5f0080e..a96bd09de2 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -857,6 +857,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _existLanguageFile = false; _languageBuffer = NULL; _languageIndex = NULL; + _costumeLoader = NULL; _costumeRenderer = NULL; _2byteFontPtr = 0; _V1TalkingActor = 0; @@ -1154,6 +1155,7 @@ ScummEngine::~ScummEngine() { free(_languageBuffer); free(_audioNames); + delete _costumeLoader; delete _costumeRenderer; free(_shadowPalette); @@ -1270,12 +1272,16 @@ int ScummEngine::init(GameDetector &detector) { _charset = new CharsetRendererClassic(this); // Create the costume renderer - if (_features & GF_NEW_COSTUMES) + if (_features & GF_NEW_COSTUMES) { _costumeRenderer = new AkosRenderer(this); - else if (_features & GF_NES) + _costumeLoader = new AkosCostumeLoader(this); + } else if (_features & GF_NES) { _costumeRenderer = new NESCostumeRenderer(this); - else + _costumeLoader = new NESCostumeLoader(this); + } else { _costumeRenderer = new ClassicCostumeRenderer(this); + _costumeLoader = new ClassicCostumeLoader(this); + } // Create FT INSANE object if (_gameId == GID_FT) diff --git a/scumm/scumm.h b/scumm/scumm.h index 31006b61a8..eed39e4b91 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -43,6 +43,7 @@ class GameDetector; namespace Scumm { class Actor; +class BaseCostumeLoader; class BaseCostumeRenderer; class CharsetRenderer; class IMuse; @@ -470,7 +471,8 @@ public: int _numCostumes; // FIXME - should be protected, used by Actor::remapActorPalette int _numCharsets; // FIXME - should be protected, used by CharsetRenderer - BaseCostumeRenderer* _costumeRenderer; + BaseCostumeLoader *_costumeLoader; + BaseCostumeRenderer *_costumeRenderer; int _NESCostumeSet; void NES_loadCostumeSet(int n); @@ -845,7 +847,6 @@ public: void setTalkingActor(int variable); // Generic costume code - void costumeDecodeData(Actor *a, int frame, uint usemask); bool isCostumeInUse(int i) const; // Akos Class @@ -863,8 +864,6 @@ public: bool akos_increaseAnim(Actor *a, int i, const byte *aksq, const uint16 *akfo, int numakfo); void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2); void akos_processQueue(); - void akos_decodeData(Actor *a, int frame, uint usemask); - bool akos_hasManyDirections(int costume); protected: /* Should be in Graphics class? */ |