mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
ASYLUM: Cleanup some actor-related opcodes
- Add enum for Actor visibility flags - Get rid of GET_ACTOR macro (a call to Scene::getActor() is enough) - Misc cleanups git-svn-id: http://asylumengine.googlecode.com/svn/trunk@466 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
@@ -127,11 +127,11 @@ public:
|
||||
uint32 tempTick07;
|
||||
|
||||
// Game
|
||||
Video* video() { return _video; }
|
||||
Sound* sound() { return _sound; }
|
||||
Screen* screen() { return _screen; }
|
||||
Scene* scene() { return _scene;}
|
||||
Text* text() { return _text; }
|
||||
Video* video() { return _video; }
|
||||
Sound* sound() { return _sound; }
|
||||
Screen* screen() { return _screen; }
|
||||
Scene* scene() { return _scene; }
|
||||
Text* text() { return _text; }
|
||||
|
||||
// Flags
|
||||
void setGameFlag(GameFlag flag);
|
||||
|
||||
@@ -186,34 +186,24 @@ bool ActionList::process() {
|
||||
|
||||
_scene->vm()->setGameFlag(kGameFlagScriptProcessing);
|
||||
|
||||
if (_currentScript)
|
||||
if (_currentScript) {
|
||||
while (!_done && !_waitCycle) {
|
||||
_lineIncrement = 0; //Reset line increment value
|
||||
|
||||
ScriptEntry *currentCommand = &_currentScript->commands[_currentLine];
|
||||
ScriptEntry *cmd = &_currentScript->commands[_currentLine];
|
||||
|
||||
int32 opcode = currentCommand->opcode;
|
||||
int32 opcode = cmd->opcode;
|
||||
|
||||
debugC(kDebugLevelScripts,
|
||||
"[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
||||
opcode,
|
||||
_actions[opcode]->name,
|
||||
currentCommand->param1,
|
||||
currentCommand->param2,
|
||||
currentCommand->param3,
|
||||
currentCommand->param4,
|
||||
currentCommand->param5,
|
||||
currentCommand->param6,
|
||||
currentCommand->param7,
|
||||
currentCommand->param8,
|
||||
currentCommand->param9);
|
||||
debugC(kDebugLevelScripts, "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
||||
opcode, _actions[opcode]->name,
|
||||
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
|
||||
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
|
||||
|
||||
// Execute opcode
|
||||
(*_actions[opcode]->func)(currentCommand);
|
||||
(*_actions[opcode]->func)(cmd);
|
||||
|
||||
if (!_lineIncrement)
|
||||
_currentLine ++;
|
||||
|
||||
}
|
||||
|
||||
if (_done) {
|
||||
@@ -224,6 +214,7 @@ bool ActionList::process() {
|
||||
_currentScript = &_entries[_currentQueueEntry.actionListIndex];
|
||||
} else {
|
||||
_currentScript = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,8 +324,7 @@ IMPLEMENT_OPCODE(ShowCursor) {
|
||||
_scene->getCursor()->show();
|
||||
_allowInput = true;
|
||||
|
||||
// TODO clear_flag_01()
|
||||
error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
|
||||
_scene->vm()->clearFlag(kFlagType1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -456,18 +446,18 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x09
|
||||
IMPLEMENT_OPCODE(HideActor) {
|
||||
Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
|
||||
Actor *actor = _scene->getActor(cmd->param1);
|
||||
|
||||
actor->visible(false);
|
||||
actor->setVisible(false);
|
||||
actor->updateDirection();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x0A
|
||||
IMPLEMENT_OPCODE(ShowActor) {
|
||||
GET_ACTOR();
|
||||
Actor *actor = _scene->getActor(cmd->param1);
|
||||
|
||||
actor->visible(true);
|
||||
actor->setVisible(true);
|
||||
actor->updateDirection();
|
||||
actor->tickValue1 = _scene->vm()->getTick();
|
||||
}
|
||||
@@ -489,7 +479,7 @@ IMPLEMENT_OPCODE(SetSceneMotionStatus) {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x0D
|
||||
IMPLEMENT_OPCODE(DisableActor) {
|
||||
GET_ACTOR();
|
||||
Actor *actor = _scene->getActor(cmd->param1);
|
||||
|
||||
actor->updateStatus(kActorStatusDisabled);
|
||||
}
|
||||
@@ -497,7 +487,7 @@ IMPLEMENT_OPCODE(DisableActor) {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x0E
|
||||
IMPLEMENT_OPCODE(EnableActor) {
|
||||
GET_ACTOR();
|
||||
Actor *actor = _scene->getActor(cmd->param1);
|
||||
|
||||
if (actor->status == kActorStatusDisabled)
|
||||
actor->updateStatus(kActorStatusEnabled);
|
||||
@@ -546,12 +536,12 @@ IMPLEMENT_OPCODE(EnableBarriers) {
|
||||
// Opcode 0x11
|
||||
IMPLEMENT_OPCODE(DestroyBarrier) {
|
||||
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
|
||||
|
||||
if (!barrier)
|
||||
error("ActionList::kDestroyBarrier: Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
|
||||
error("[ActionList::kDestroyBarrier] Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
|
||||
|
||||
barrier->flags &= 0xFFFFFFFE;
|
||||
barrier->destroy();
|
||||
barrier->flags |= 0x20000;
|
||||
|
||||
_scene->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
|
||||
}
|
||||
|
||||
@@ -735,10 +725,9 @@ IMPLEMENT_OPCODE(JumpIfActorField638) {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x2B
|
||||
IMPLEMENT_OPCODE(ChangeScene) {
|
||||
debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", _delayedSceneIndex);
|
||||
|
||||
_delayedSceneIndex = cmd->param1 + 4;
|
||||
debug(kDebugLevelScripts,
|
||||
"Queueing Scene Change to scene %d...",
|
||||
_delayedSceneIndex);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1181,7 +1170,7 @@ IMPLEMENT_OPCODE(_unk59) {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Opcode 0x5A
|
||||
IMPLEMENT_OPCODE(_unk5A) {
|
||||
error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
|
||||
_scene->getActor(cmd->param1)->actionIdx2 = cmd->param2;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1206,6 +1195,7 @@ IMPLEMENT_OPCODE(_unk5D) {
|
||||
// Opcode 0x5E
|
||||
IMPLEMENT_OPCODE(ClearActorField970) {
|
||||
Actor *act = _scene->getActor(cmd->param1);
|
||||
|
||||
act->field_970 = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,6 @@ namespace Asylum {
|
||||
_actions.push_back(func); \
|
||||
}
|
||||
|
||||
#define GET_ACTOR() \
|
||||
Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
|
||||
|
||||
class Scene;
|
||||
|
||||
class ActionList {
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
Actor::Actor() {
|
||||
_graphic = 0;
|
||||
Actor::Actor() : _currentWalkArea(NULL), _graphic(NULL), _resPack(NULL) {
|
||||
currentAction = 0;
|
||||
_currentWalkArea = 0;
|
||||
|
||||
// TODO initialize other class variables
|
||||
}
|
||||
|
||||
Actor::~Actor() {
|
||||
@@ -47,11 +47,11 @@ Actor::~Actor() {
|
||||
// free _resources?
|
||||
}
|
||||
|
||||
void Actor::visible(bool value) {
|
||||
if (value) // TODO - enums for flags (0x01 is visible)
|
||||
flags |= 0x01;
|
||||
void Actor::setVisible(bool value) {
|
||||
if (value)
|
||||
flags |= kVisible;
|
||||
else
|
||||
flags &= 0xFFFFFFFE;
|
||||
flags &= kHidden;
|
||||
|
||||
stopSound();
|
||||
}
|
||||
@@ -480,7 +480,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
|
||||
|
||||
case kActorStatusDisabled:
|
||||
updateGraphicData(15);
|
||||
grResId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
|
||||
graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
|
||||
|
||||
// TODO set word_446EE4 to -1. This global seems to be used with screen blitting
|
||||
break;
|
||||
@@ -495,8 +495,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
|
||||
_scene->setActorIndex(0);
|
||||
|
||||
// Hide this actor and the show the other one
|
||||
visible(false);
|
||||
actor->visible(true);
|
||||
setVisible(false);
|
||||
actor->setVisible(true);
|
||||
|
||||
_scene->vm()->clearGameFlag(kGameFlag279);
|
||||
|
||||
@@ -528,25 +528,25 @@ void Actor::updateStatus(ActorStatus actorStatus) {
|
||||
|
||||
case kActorStatus18:
|
||||
if (_scene->worldstats()->numChapter == 2) {
|
||||
GraphicResource *gra = new GraphicResource();
|
||||
GraphicResource *resource = new GraphicResource();
|
||||
frameNum = 0;
|
||||
|
||||
if (_index > 12)
|
||||
grResId = grResTable[direction + 30];
|
||||
graphicResourceId = grResTable[direction + 30];
|
||||
|
||||
if (_scene->getActorIndex() == _index) {
|
||||
gra->load(_resPack, grResId);
|
||||
frameNum = gra->getFrameCount() - 1;
|
||||
resource->load(_resPack, graphicResourceId);
|
||||
frameNum = resource->getFrameCount() - 1;
|
||||
}
|
||||
|
||||
if (_index == 11)
|
||||
grResId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
|
||||
graphicResourceId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
|
||||
|
||||
// Reload the graphic resource if the resource ID has changed
|
||||
if (gra->getEntryNum() != grResId)
|
||||
gra->load(_resPack, grResId);
|
||||
if (resource->getEntryNum() != graphicResourceId)
|
||||
resource->load(_resPack, graphicResourceId);
|
||||
|
||||
frameCount = gra->getFrameCount();
|
||||
frameCount = resource->getFrameCount();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -555,11 +555,11 @@ void Actor::updateStatus(ActorStatus actorStatus) {
|
||||
}
|
||||
|
||||
void Actor::updateGraphicData(uint32 offset) {
|
||||
grResId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
|
||||
graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
|
||||
|
||||
GraphicResource *gra = new GraphicResource(_resPack, grResId);
|
||||
frameCount = gra->getFrameCount();
|
||||
delete gra;
|
||||
GraphicResource *resource = new GraphicResource(_resPack, graphicResourceId);
|
||||
frameCount = resource->getFrameCount();
|
||||
delete resource;
|
||||
|
||||
frameNum = 0;
|
||||
}
|
||||
@@ -610,7 +610,7 @@ void Actor::setDirection(int actorDirection) {
|
||||
}
|
||||
|
||||
void Actor::update() {
|
||||
if (visible()) {
|
||||
if (isVisible()) {
|
||||
// printf("Actor updateType = 0x%02X\n", actor->updateType);
|
||||
|
||||
switch (status) {
|
||||
@@ -722,7 +722,7 @@ void Actor::updateActorSub01() {
|
||||
if (_scene->vm()->tempTick07) {
|
||||
if (_scene->vm()->getTick() - _scene->vm()->tempTick07 > 500) {
|
||||
if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)) { // processing action list
|
||||
if (visible()) {
|
||||
if (isVisible()) {
|
||||
// if some_encounter_flag
|
||||
// if !soundResId04
|
||||
if (_scene->vm()->getRandom(100) < 50) {
|
||||
|
||||
@@ -72,6 +72,11 @@ enum ActorType {
|
||||
kAztec = 3
|
||||
};
|
||||
|
||||
enum ActorFlags {
|
||||
kVisible = 0x01,
|
||||
kHidden = 0xFFFFFFFE
|
||||
};
|
||||
|
||||
// TODO investigate other actor resources (from other
|
||||
// scenes) to see if the unused blocks in the actor
|
||||
// definition are in fact used elsewhere
|
||||
@@ -177,11 +182,9 @@ public:
|
||||
*/
|
||||
void setRawResources(uint8* data);
|
||||
|
||||
bool visible() {
|
||||
return flags & 0x01;
|
||||
}
|
||||
|
||||
void visible(bool value);
|
||||
// Visibility
|
||||
bool isVisible() { return flags & kVisible; }
|
||||
void setVisible(bool value);
|
||||
|
||||
/** .text:0040A260
|
||||
* Initialize the x1/y1 values of the actor, update the active animation frame
|
||||
@@ -228,7 +231,7 @@ public:
|
||||
|
||||
int32 x;
|
||||
int32 y;
|
||||
uint32 grResId;
|
||||
uint32 graphicResourceId;
|
||||
int32 field_C; // BarrierIndex? Mask index?
|
||||
uint32 frameNum;
|
||||
uint32 frameCount;
|
||||
@@ -301,9 +304,9 @@ private:
|
||||
Scene *_scene;
|
||||
int32 _resources[61];
|
||||
|
||||
ResourcePack *_resPack;
|
||||
GraphicResource *_graphic;
|
||||
ActionArea *_currentWalkArea;
|
||||
GraphicResource *_graphic;
|
||||
ResourcePack *_resPack;
|
||||
|
||||
// Our current index
|
||||
ActorIndex _index;
|
||||
|
||||
@@ -36,6 +36,10 @@ Barrier::~Barrier() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void Barrier::destroy() {
|
||||
flags &= 0xFFFFFFFE;
|
||||
}
|
||||
|
||||
int32 Barrier::getRandomId() {
|
||||
int32 numRes = 0;
|
||||
int32 rndResId[5];
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
Barrier();
|
||||
virtual ~Barrier();
|
||||
|
||||
void destroy();
|
||||
|
||||
bool visible();
|
||||
int32 getRandomId(); // TODO Give this a better name?
|
||||
bool onscreen();
|
||||
|
||||
@@ -302,7 +302,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
|
||||
|
||||
actor.x = stream->readSint32LE();
|
||||
actor.y = stream->readSint32LE();
|
||||
actor.grResId = stream->readSint32LE();
|
||||
actor.graphicResourceId = stream->readSint32LE();
|
||||
actor.field_C = stream->readSint32LE();
|
||||
actor.frameNum = stream->readSint32LE();
|
||||
actor.frameCount = stream->readSint32LE();
|
||||
|
||||
@@ -736,7 +736,7 @@ bool Scene::hitTestActor(const Common::Point pt) {
|
||||
else
|
||||
hitFrame = act->frameNum;
|
||||
|
||||
return hitTestPixel(act->grResId,
|
||||
return hitTestPixel(act->graphicResourceId,
|
||||
hitFrame,
|
||||
pt.x - act->x - actPos.x,
|
||||
pt.y - act->y - actPos.y,
|
||||
@@ -1297,7 +1297,7 @@ int Scene::queueActorUpdates() {
|
||||
|
||||
} else {
|
||||
// TODO: get flag value from character_DeadSarah_sub_40A140
|
||||
_vm->screen()->addGraphicToQueue(actor->grResId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
|
||||
_vm->screen()->addGraphicToQueue(actor->graphicResourceId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user