Tie the AKOS code into the new costume infrastructure, too
svn-id: r17259
This commit is contained in:
parent
5bd26a52df
commit
abcf7bf2de
6 changed files with 56 additions and 66 deletions
|
@ -320,14 +320,16 @@ int Actor::remapDirection(int dir, bool is_walking) {
|
||||||
|
|
||||||
int Actor::updateActorDirection(bool is_walking) {
|
int Actor::updateActorDirection(bool is_walking) {
|
||||||
int from;
|
int from;
|
||||||
int dirType;
|
bool dirType = false;
|
||||||
int dir;
|
int dir;
|
||||||
bool shouldInterpolate;
|
bool shouldInterpolate;
|
||||||
|
|
||||||
if ((_vm->_version == 6) && _ignoreTurns)
|
if ((_vm->_version == 6) && _ignoreTurns)
|
||||||
return _facing;
|
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);
|
from = toSimpleDir(dirType, _facing);
|
||||||
dir = remapDirection(_targetFacing, is_walking);
|
dir = remapDirection(_targetFacing, is_walking);
|
||||||
|
@ -467,7 +469,7 @@ void Actor::startAnimActor(int f) {
|
||||||
_needRedraw = true;
|
_needRedraw = true;
|
||||||
if (f == _initFrame)
|
if (f == _initFrame)
|
||||||
_cost.reset();
|
_cost.reset();
|
||||||
_vm->costumeDecodeData(this, f, (uint) - 1);
|
_vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1);
|
||||||
_frame = f;
|
_frame = f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -501,7 +503,7 @@ void Actor::startAnimActor(int f) {
|
||||||
_cost.reset();
|
_cost.reset();
|
||||||
_auxBlock.visible = false;
|
_auxBlock.visible = false;
|
||||||
}
|
}
|
||||||
_vm->costumeDecodeData(this, f, (uint) - 1);
|
_vm->_costumeLoader->costumeDecodeData(this, f, (uint) - 1);
|
||||||
_frame = f;
|
_frame = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +572,7 @@ void Actor::setDirection(int direction) {
|
||||||
vald = _cost.frame[i];
|
vald = _cost.frame[i];
|
||||||
if (vald == 0xFFFF)
|
if (vald == 0xFFFF)
|
||||||
continue;
|
continue;
|
||||||
_vm->costumeDecodeData(this, vald, (_vm->_version <= 2) ? 0xFFFF : aMask);
|
_vm->_costumeLoader->costumeDecodeData(this, vald, (_vm->_version <= 2) ? 0xFFFF : aMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
_needRedraw = true;
|
_needRedraw = true;
|
||||||
|
@ -1128,25 +1130,10 @@ void Actor::animateCostume() {
|
||||||
if (_animProgress >= _animSpeed) {
|
if (_animProgress >= _animSpeed) {
|
||||||
_animProgress = 0;
|
_animProgress = 0;
|
||||||
|
|
||||||
BaseCostumeLoader *cost = 0;
|
_vm->_costumeLoader->loadCostume(_costume);
|
||||||
|
if (_vm->_costumeLoader->increaseAnims(this)) {
|
||||||
if (_vm->_features & GF_NEW_COSTUMES) {
|
_needRedraw = true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
delete cost;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,20 +137,21 @@ static bool akos_compare(int a, int b, byte cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScummEngine::akos_hasManyDirections(int costume) {
|
void AkosCostumeLoader::loadCostume(int id) {
|
||||||
byte *akos;
|
_akos = _vm->getResourceAddress(rtCostume, id);
|
||||||
|
assert(_akos);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AkosCostumeLoader::hasManyDirections() {
|
||||||
const AkosHeader *akhd;
|
const AkosHeader *akhd;
|
||||||
|
|
||||||
akos = getResourceAddress(rtCostume, costume);
|
akhd = (const AkosHeader *)_vm->findResourceData(MKID('AKHD'), _akos);
|
||||||
assert(akos);
|
|
||||||
|
|
||||||
akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos);
|
|
||||||
return (akhd->flags & 2) != 0;
|
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;
|
uint anim;
|
||||||
const byte *akos, *r;
|
const byte *r;
|
||||||
const AkosHeader *akhd;
|
const AkosHeader *akhd;
|
||||||
uint offs;
|
uint offs;
|
||||||
int i;
|
int i;
|
||||||
|
@ -161,20 +162,19 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
if (a->_costume == 0)
|
if (a->_costume == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_version >= 7 && akos_hasManyDirections(a->_costume))
|
loadCostume(a->_costume);
|
||||||
|
|
||||||
|
if (_vm->_version >= 7 && hasManyDirections())
|
||||||
anim = toSimpleDir(1, a->getFacing()) + frame * 8;
|
anim = toSimpleDir(1, a->getFacing()) + frame * 8;
|
||||||
else
|
else
|
||||||
anim = newDirToOldDir(a->getFacing()) + frame * 4;
|
anim = newDirToOldDir(a->getFacing()) + frame * 4;
|
||||||
|
|
||||||
akos = getResourceAddress(rtCostume, a->_costume);
|
akhd = (const AkosHeader *)_vm->findResourceData(MKID('AKHD'), _akos);
|
||||||
assert(akos);
|
|
||||||
|
|
||||||
akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos);
|
|
||||||
|
|
||||||
if (anim >= READ_LE_UINT16(&akhd->num_anims))
|
if (anim >= READ_LE_UINT16(&akhd->num_anims))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r = findResourceData(MKID('AKCH'), akos);
|
r = _vm->findResourceData(MKID('AKCH'), _akos);
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
offs = READ_LE_UINT16(r + anim * sizeof(uint16));
|
offs = READ_LE_UINT16(r + anim * sizeof(uint16));
|
||||||
|
@ -182,8 +182,8 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
return;
|
return;
|
||||||
r += offs;
|
r += offs;
|
||||||
|
|
||||||
const uint8 *akst = findResourceData(MKID('AKST'), akos);
|
const uint8 *akst = _vm->findResourceData(MKID('AKST'), _akos);
|
||||||
const uint8 *aksf = findResourceData(MKID('AKSF'), akos);
|
const uint8 *aksf = _vm->findResourceData(MKID('AKSF'), _akos);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
mask = READ_LE_UINT16(r); r += 2;
|
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;
|
a->_cost.seq3[i] = 0;
|
||||||
|
|
||||||
if (akst) {
|
if (akst) {
|
||||||
int size = getResourceDataSize(akst) / 8;
|
int size = _vm->getResourceDataSize(akst) / 8;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
|
@ -231,7 +231,7 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
a->_cost.seq1[i] = 0;
|
a->_cost.seq1[i] = 0;
|
||||||
a->_cost.seq2[i] = 0;
|
a->_cost.seq2[i] = 0;
|
||||||
if (aksf) {
|
if (aksf) {
|
||||||
int size = getResourceDataSize(aksf) / 6;
|
int size = _vm->getResourceDataSize(aksf) / 6;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
|
@ -256,7 +256,7 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
a->_cost.curpos[i] = start;
|
a->_cost.curpos[i] = start;
|
||||||
a->_cost.seq3[i] = 0;
|
a->_cost.seq3[i] = 0;
|
||||||
if (akst) {
|
if (akst) {
|
||||||
int size = getResourceDataSize(akst) / 8;
|
int size = _vm->getResourceDataSize(akst) / 8;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
|
@ -1239,6 +1239,10 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte AkosCostumeLoader::increaseAnims(Actor *a) {
|
||||||
|
return _vm->akos_increaseAnims(_akos, a);
|
||||||
|
}
|
||||||
|
|
||||||
bool ScummEngine::akos_increaseAnims(const byte *akos, Actor *a) {
|
bool ScummEngine::akos_increaseAnims(const byte *akos, Actor *a) {
|
||||||
const byte *aksq, *akfo;
|
const byte *aksq, *akfo;
|
||||||
int i;
|
int i;
|
||||||
|
|
14
scumm/akos.h
14
scumm/akos.h
|
@ -37,18 +37,26 @@ struct CostumeData;
|
||||||
struct AkosHeader;
|
struct AkosHeader;
|
||||||
struct AkosOffset;
|
struct AkosOffset;
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
class AkosCostumeLoader : public BaseCostumeLoader {
|
class AkosCostumeLoader : public BaseCostumeLoader {
|
||||||
|
protected:
|
||||||
|
const byte *_akos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AkosCostumeLoader(ScummEngine *vm);
|
AkosCostumeLoader(ScummEngine *vm) : BaseCostumeLoader(vm) {}
|
||||||
|
|
||||||
void loadCostume(int id);
|
void loadCostume(int id);
|
||||||
byte increaseAnims(Actor *a);
|
byte increaseAnims(Actor *a);
|
||||||
void costumeDecodeData(Actor *a, int frame, uint usemask);
|
void costumeDecodeData(Actor *a, int frame, uint usemask);
|
||||||
|
|
||||||
//void animateLimb(int limb, int f);
|
//void animateLimb(int limb, int f);
|
||||||
|
bool hasManyDirections(int id) {
|
||||||
|
loadCostume(id);
|
||||||
|
return hasManyDirections();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool hasManyDirections();
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
class AkosRenderer : public BaseCostumeRenderer {
|
class AkosRenderer : public BaseCostumeRenderer {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -88,18 +88,4 @@ bool ScummEngine::isCostumeInUse(int cost) const {
|
||||||
return false;
|
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
|
} // End of namespace Scumm
|
||||||
|
|
|
@ -857,6 +857,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
|
||||||
_existLanguageFile = false;
|
_existLanguageFile = false;
|
||||||
_languageBuffer = NULL;
|
_languageBuffer = NULL;
|
||||||
_languageIndex = NULL;
|
_languageIndex = NULL;
|
||||||
|
_costumeLoader = NULL;
|
||||||
_costumeRenderer = NULL;
|
_costumeRenderer = NULL;
|
||||||
_2byteFontPtr = 0;
|
_2byteFontPtr = 0;
|
||||||
_V1TalkingActor = 0;
|
_V1TalkingActor = 0;
|
||||||
|
@ -1154,6 +1155,7 @@ ScummEngine::~ScummEngine() {
|
||||||
free(_languageBuffer);
|
free(_languageBuffer);
|
||||||
free(_audioNames);
|
free(_audioNames);
|
||||||
|
|
||||||
|
delete _costumeLoader;
|
||||||
delete _costumeRenderer;
|
delete _costumeRenderer;
|
||||||
|
|
||||||
free(_shadowPalette);
|
free(_shadowPalette);
|
||||||
|
@ -1270,12 +1272,16 @@ int ScummEngine::init(GameDetector &detector) {
|
||||||
_charset = new CharsetRendererClassic(this);
|
_charset = new CharsetRendererClassic(this);
|
||||||
|
|
||||||
// Create the costume renderer
|
// Create the costume renderer
|
||||||
if (_features & GF_NEW_COSTUMES)
|
if (_features & GF_NEW_COSTUMES) {
|
||||||
_costumeRenderer = new AkosRenderer(this);
|
_costumeRenderer = new AkosRenderer(this);
|
||||||
else if (_features & GF_NES)
|
_costumeLoader = new AkosCostumeLoader(this);
|
||||||
|
} else if (_features & GF_NES) {
|
||||||
_costumeRenderer = new NESCostumeRenderer(this);
|
_costumeRenderer = new NESCostumeRenderer(this);
|
||||||
else
|
_costumeLoader = new NESCostumeLoader(this);
|
||||||
|
} else {
|
||||||
_costumeRenderer = new ClassicCostumeRenderer(this);
|
_costumeRenderer = new ClassicCostumeRenderer(this);
|
||||||
|
_costumeLoader = new ClassicCostumeLoader(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Create FT INSANE object
|
// Create FT INSANE object
|
||||||
if (_gameId == GID_FT)
|
if (_gameId == GID_FT)
|
||||||
|
|
|
@ -43,6 +43,7 @@ class GameDetector;
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
class Actor;
|
class Actor;
|
||||||
|
class BaseCostumeLoader;
|
||||||
class BaseCostumeRenderer;
|
class BaseCostumeRenderer;
|
||||||
class CharsetRenderer;
|
class CharsetRenderer;
|
||||||
class IMuse;
|
class IMuse;
|
||||||
|
@ -470,7 +471,8 @@ public:
|
||||||
int _numCostumes; // FIXME - should be protected, used by Actor::remapActorPalette
|
int _numCostumes; // FIXME - should be protected, used by Actor::remapActorPalette
|
||||||
int _numCharsets; // FIXME - should be protected, used by CharsetRenderer
|
int _numCharsets; // FIXME - should be protected, used by CharsetRenderer
|
||||||
|
|
||||||
BaseCostumeRenderer* _costumeRenderer;
|
BaseCostumeLoader *_costumeLoader;
|
||||||
|
BaseCostumeRenderer *_costumeRenderer;
|
||||||
|
|
||||||
int _NESCostumeSet;
|
int _NESCostumeSet;
|
||||||
void NES_loadCostumeSet(int n);
|
void NES_loadCostumeSet(int n);
|
||||||
|
@ -845,7 +847,6 @@ public:
|
||||||
void setTalkingActor(int variable);
|
void setTalkingActor(int variable);
|
||||||
|
|
||||||
// Generic costume code
|
// Generic costume code
|
||||||
void costumeDecodeData(Actor *a, int frame, uint usemask);
|
|
||||||
bool isCostumeInUse(int i) const;
|
bool isCostumeInUse(int i) const;
|
||||||
|
|
||||||
// Akos Class
|
// Akos Class
|
||||||
|
@ -863,8 +864,6 @@ public:
|
||||||
bool akos_increaseAnim(Actor *a, int i, const byte *aksq, const uint16 *akfo, int numakfo);
|
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_queCommand(byte cmd, Actor *a, int param_1, int param_2);
|
||||||
void akos_processQueue();
|
void akos_processQueue();
|
||||||
void akos_decodeData(Actor *a, int frame, uint usemask);
|
|
||||||
bool akos_hasManyDirections(int costume);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* Should be in Graphics class? */
|
/* Should be in Graphics class? */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue