ASYLUM: Added the ActionArray type. Slowly working on implementing this, but it looks to be what ties the actionlist to the character.
Also started implementing more standardized music handling. git-svn-id: http://asylumengine.googlecode.com/svn/trunk@393 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
63b9cfeb0a
commit
a33b9e677a
11 changed files with 236 additions and 26 deletions
76
engines/asylum/actionarray.cpp
Normal file
76
engines/asylum/actionarray.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "asylum/actionarray.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
ActionArray::ActionArray(AsylumEngine *engine): _vm(engine) {
|
||||
_actionFlag = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
ActionArray::~ActionArray() {
|
||||
|
||||
}
|
||||
|
||||
void ActionArray::reset() {
|
||||
memset(&_items, 0, sizeof(ActionStruct));
|
||||
for (int i = 0; i < 10; i++)
|
||||
_items.entries[i].actionListIndex = -1;
|
||||
}
|
||||
|
||||
void ActionArray::initItem(ActionDefinitions *command, int actionIndex, int actorIndex) {
|
||||
// TODO properly define what actionFlag is actually for.
|
||||
// It appears to remain false 99% of the time, so I'm guessing
|
||||
// it's a "skip processing" flag.
|
||||
if (!_actionFlag) {
|
||||
int i;
|
||||
// iterate through the availble entry slots to determine
|
||||
// the next available slot
|
||||
for (i = 1; i < 10; i++) {
|
||||
if (_items.entries[i].actionListIndex == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
command->counter = 0;
|
||||
|
||||
_items.entries[i].field_10 = 0;
|
||||
_items.entries[i].field_C = 0;
|
||||
|
||||
if (_items.count) {
|
||||
_items.entries[_items.field_CC].field_C = i ;
|
||||
_items.entries[0].field_10 = _items.field_CC;
|
||||
} else {
|
||||
_items.count = i;
|
||||
}
|
||||
_items.field_CC = i;
|
||||
_items.entries[0].actionListIndex = actionIndex;
|
||||
_items.entries[0].actionListItemIndex = 0;
|
||||
_items.entries[0].actorIndex = actorIndex;
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace Asylum
|
83
engines/asylum/actionarray.h
Normal file
83
engines/asylum/actionarray.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ASYLUM_ACTIONARRAY_H_
|
||||
#define ASYLUM_ACTIONARRAY_H_
|
||||
|
||||
#include "asylum/asylum.h"
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
typedef struct ActionItem {
|
||||
int actionListIndex;
|
||||
int actionListItemIndex;
|
||||
int actorIndex;
|
||||
int field_C;
|
||||
int field_10;
|
||||
|
||||
} ActionItem;
|
||||
|
||||
typedef struct ActionStruct {
|
||||
ActionItem entries[10];
|
||||
int count;
|
||||
int field_CC;
|
||||
|
||||
} ActionStruct;
|
||||
|
||||
struct ActionDefinitions;
|
||||
|
||||
class ActionArray {
|
||||
public:
|
||||
ActionArray(AsylumEngine *engine);
|
||||
virtual ~ActionArray();
|
||||
|
||||
/** .text:00401020
|
||||
* Reset the _actionArray entries to their
|
||||
* default values
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/** .text:00401050
|
||||
* Initialize the script element at actionIndex to
|
||||
* the actor at actorIndex
|
||||
*
|
||||
* FIXME passing in a reference to the command at actionIndex
|
||||
* to do a quick update.
|
||||
*/
|
||||
void initItem(ActionDefinitions *command, int actionIndex, int actorIndex);
|
||||
|
||||
void setActionFlag(bool value) { _actionFlag = value; }
|
||||
|
||||
private:
|
||||
bool _actionFlag;
|
||||
ActionStruct _items;
|
||||
AsylumEngine *_vm;
|
||||
|
||||
}; // end of class ActionArray
|
||||
|
||||
} // end of namespace Asylum
|
||||
|
||||
#endif /* ASYLUM_ACTIONARRAY_H_ */
|
|
@ -104,8 +104,8 @@ static const AsylumFunction function_map[] = {
|
|||
/*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
|
||||
/*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
|
||||
/*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
|
||||
/*0x2F*/ MAPFUNC("kSetActionFlag01", kSetActionFlag01),
|
||||
/*0x30*/ MAPFUNC("kClearActionFlag01", kClearActionFlag01),
|
||||
/*0x2F*/ MAPFUNC("kSetActionFlag", kSetActionFlag),
|
||||
/*0x30*/ MAPFUNC("kClearActionFlag", kClearActionFlag),
|
||||
/*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
|
||||
/*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
|
||||
/*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
|
||||
|
@ -808,11 +808,13 @@ int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int kSetActionFlag01(ActionCommand *cmd, Scene *scn) {
|
||||
return -2;
|
||||
int kSetActionFlag(ActionCommand *cmd, Scene *scn) {
|
||||
scn->vm()->actionarray()->setActionFlag(true);
|
||||
return 0;
|
||||
}
|
||||
int kClearActionFlag01(ActionCommand *cmd, Scene *scn) {
|
||||
return -2;
|
||||
int kClearActionFlag(ActionCommand *cmd, Scene *scn) {
|
||||
scn->vm()->actionarray()->setActionFlag(false);
|
||||
return 0;
|
||||
}
|
||||
int kResetSceneRect(ActionCommand *cmd, Scene *scn) {
|
||||
return -2;
|
||||
|
|
|
@ -57,7 +57,6 @@ typedef struct ActionDefinitions {
|
|||
uint32 field_1BAC;
|
||||
uint32 field_1BB0;
|
||||
uint32 counter;
|
||||
|
||||
} ActionDefinitions;
|
||||
|
||||
class ActionList {
|
||||
|
@ -88,6 +87,10 @@ public:
|
|||
ActionDefinitions* getScript() {
|
||||
return _currentScript;
|
||||
}
|
||||
|
||||
/** .text:00402120
|
||||
* Process the current script
|
||||
*/
|
||||
int process();
|
||||
|
||||
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
|
||||
|
@ -149,8 +152,8 @@ int kChangeScene(ActionCommand *cmd, Scene *scn);
|
|||
int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn);
|
||||
int kPlayMovie(ActionCommand *cmd, Scene *scn);
|
||||
int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn);
|
||||
int kSetActionFlag01(ActionCommand *cmd, Scene *scn);
|
||||
int kClearActionFlag01(ActionCommand *cmd, Scene *scn);
|
||||
int kSetActionFlag(ActionCommand *cmd, Scene *scn);
|
||||
int kClearActionFlag(ActionCommand *cmd, Scene *scn);
|
||||
int kResetSceneRect(ActionCommand *cmd, Scene *scn);
|
||||
int kChangeMusicById(ActionCommand *cmd, Scene *scn);
|
||||
int kStopMusic(ActionCommand *cmd, Scene *scn);
|
||||
|
|
|
@ -55,8 +55,6 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
|
|||
Common::enableDebugChannel("Scripts");
|
||||
|
||||
g_eventRec.registerRandomSource(_rnd, "asylum");
|
||||
|
||||
memset(_gameFlags, 0, 1512);
|
||||
}
|
||||
|
||||
AsylumEngine::~AsylumEngine() {
|
||||
|
@ -70,6 +68,7 @@ AsylumEngine::~AsylumEngine() {
|
|||
delete _screen;
|
||||
delete _encounter;
|
||||
delete _text;
|
||||
delete _actionArray;
|
||||
}
|
||||
|
||||
Common::Error AsylumEngine::run() {
|
||||
|
@ -95,6 +94,9 @@ Common::Error AsylumEngine::init() {
|
|||
|
||||
_introPlaying = false;
|
||||
|
||||
memset(_gameFlags, 0, 1512);
|
||||
_actionArray = new ActionArray(this);
|
||||
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "asylum/video.h"
|
||||
#include "asylum/blowuppuzzle.h"
|
||||
#include "asylum/encounters.h"
|
||||
#include "asylum/actionarray.h"
|
||||
|
||||
namespace Asylum {
|
||||
|
||||
|
@ -66,6 +67,7 @@ class Screen;
|
|||
class Sound;
|
||||
class Video;
|
||||
class Encounter;
|
||||
class ActionArray;
|
||||
|
||||
enum kDebugLevels {
|
||||
kDebugLevelMain = 1 << 0,
|
||||
|
@ -85,7 +87,9 @@ public:
|
|||
AsylumEngine(OSystem *system, Common::Language language);
|
||||
virtual ~AsylumEngine();
|
||||
|
||||
// Engine APIs
|
||||
/** .text:0040F430
|
||||
* Initalize the game environment
|
||||
*/
|
||||
Common::Error init();
|
||||
Common::Error go();
|
||||
virtual Common::Error run();
|
||||
|
@ -114,6 +118,7 @@ public:
|
|||
Screen* screen() { return _screen; }
|
||||
Scene* scene() { return _scene;}
|
||||
Text* text() { return _text; }
|
||||
ActionArray *actionarray() { return _actionArray; }
|
||||
|
||||
private:
|
||||
void checkForEvent(bool doUpdate);
|
||||
|
@ -136,6 +141,8 @@ private:
|
|||
Text *_text;
|
||||
Encounter *_encounter;
|
||||
|
||||
ActionArray *_actionArray;
|
||||
|
||||
int _gameFlags[1512];
|
||||
|
||||
friend class Console;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
MODULE := engines/asylum
|
||||
|
||||
MODULE_OBJS := \
|
||||
actionarray.o \
|
||||
actionlist.o \
|
||||
actor.o \
|
||||
asylum.o \
|
||||
|
|
|
@ -168,6 +168,10 @@ void Scene::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
uint32 actionIdx = _ws->actionListIdx;
|
||||
if (actionIdx)
|
||||
_vm->actionarray()->initItem(&_actions->entries[actionIdx], actionIdx, 0);
|
||||
|
||||
// TODO initActionListArrayItem(idx, 0) .text:00401050
|
||||
// XXX not sure why we need to do this again
|
||||
_vm->screen()->clearScreen();
|
||||
|
@ -177,23 +181,33 @@ void Scene::initialize() {
|
|||
// TODO preloadGraphics() .text:00410F10
|
||||
// TODO sound_sub(sceneNumber) .text:0040E750
|
||||
_ws->actorType = actorType[_ws->numChapter];
|
||||
// TODO musicCacheOk check as part of if
|
||||
int musicId = 0;
|
||||
if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
|
||||
musicId = _ws->musicResId - 0x7FFE0000;
|
||||
// TODO playMusic(musicId, cfgMusicVolume);
|
||||
|
||||
startMusic();
|
||||
|
||||
_vm->tempTick07 = 1;
|
||||
|
||||
// TODO sceneRectChangedFlag = 1;
|
||||
|
||||
actor->tickValue1= _vm->getTick();
|
||||
// XXX This initialization was already done earlier,
|
||||
// so I'm not sure why we need to do it again. Investigate.
|
||||
updateActorDirectionDefault(_playerActorIdx);
|
||||
|
||||
if (_ws->numChapter == 9) {
|
||||
// TODO changeActorIndex(1); .text:00405140
|
||||
_ws->field_E860C = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::startMusic() {
|
||||
// TODO musicCacheOk check as part of if
|
||||
int musicId = 0;
|
||||
if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
|
||||
musicId = _ws->musicResId - 0x7FFE0000;
|
||||
_vm->sound()->playMusic(_musPack, musicId);
|
||||
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
delete _ws;
|
||||
delete _polygons;
|
||||
|
@ -399,8 +413,8 @@ void Scene::enterScene() {
|
|||
_cursor->set(0);
|
||||
_cursor->show();
|
||||
|
||||
// Music testing: play the first music track
|
||||
_vm->sound()->playMusic(_musPack, 0);
|
||||
startMusic();
|
||||
|
||||
_walking = false;
|
||||
#ifdef SHOW_SCENE_LOADING
|
||||
}
|
||||
|
@ -1409,7 +1423,7 @@ void Scene::drawActorsAndBarriers() {
|
|||
if (bar->flags & 4) {
|
||||
if (intersects) {
|
||||
if(act->flags & 2)
|
||||
warning ("Assigning mask to masked character [%s]", bar->name);
|
||||
warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
|
||||
else {
|
||||
// TODO there's a call to sub_40ac10 that does
|
||||
// a point calculation, but the result doesn't appear to
|
||||
|
@ -1459,7 +1473,6 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
|
|||
}
|
||||
|
||||
int Scene::queueActorUpdates() {
|
||||
|
||||
if (_ws->numActors > 0) {
|
||||
Common::Point pt;
|
||||
for (uint32 a = 0; a < _ws->numActors; a++) {
|
||||
|
|
|
@ -164,16 +164,29 @@ private:
|
|||
void initialize();
|
||||
|
||||
void update();
|
||||
void startMusic();
|
||||
|
||||
/** .text:0040B5B0
|
||||
* Loop through the various update blocks (actors,
|
||||
* barriers, mouse, music, sfx, screenPosition), then
|
||||
* process the current action script
|
||||
*/
|
||||
int updateScene();
|
||||
/** .text:0040D190 */
|
||||
void updateMouse();
|
||||
/** .text:0040B740 */
|
||||
void updateActor(uint32 actorIdx);
|
||||
/**
|
||||
* TODO give more meaningful name
|
||||
*/
|
||||
void updateActorSub01(Actor *act);
|
||||
/** .text:0040CBD0 */
|
||||
void updateBarriers();
|
||||
/** .text:00409BA0 */
|
||||
void updateAmbientSounds();
|
||||
/** .text:00409EF0 */
|
||||
void updateMusic();
|
||||
/** .text:0040DAE0 */
|
||||
void updateAdjustScreen();
|
||||
int drawScene();
|
||||
void drawActorsAndBarriers();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "asylum/sound.h"
|
||||
#include "asylum/asylum.h"
|
||||
#include "asylum/config.h"
|
||||
|
||||
#include "common/stream.h"
|
||||
#include "sound/audiostream.h"
|
||||
|
@ -36,6 +37,7 @@ namespace Asylum {
|
|||
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
|
||||
_speechPack = new ResourcePack(3);
|
||||
_soundPack = new ResourcePack(18);
|
||||
_currentMusicResIndex = -666;
|
||||
}
|
||||
|
||||
Sound::~Sound() {
|
||||
|
@ -226,7 +228,7 @@ void Sound::playMusic(ResourcePack *pack, uint resId) {
|
|||
stopMusic();
|
||||
|
||||
ResourceEntry *resource = pack->getResource(resId);
|
||||
playSoundData(&_musicHandle, resource->data, resource->size, true, 0, 0);
|
||||
playSoundData(&_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
|
||||
}
|
||||
|
||||
void Sound::stopMusic() {
|
||||
|
|
|
@ -128,6 +128,14 @@ private:
|
|||
|
||||
Common::Array<SoundBufferItem> _soundBuffer;
|
||||
|
||||
/**
|
||||
* The resource pointer for the currently playing music file.
|
||||
* This was originally a scene variable, but it makes more sense
|
||||
* to track it uniquely, as this doesn't involve initializing the
|
||||
* scene just to set a single variable
|
||||
*/
|
||||
int _currentMusicResIndex;
|
||||
|
||||
/**
|
||||
* Find the index within the _soundBuffer array of the
|
||||
* sound sample with provided id.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue