aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Boutonné2010-11-01 00:27:11 +0000
committerArnaud Boutonné2010-11-01 00:27:11 +0000
commite48cdb378c89e17c5f213eb921c0841aca062bd6 (patch)
treed9684775f9ac8aeea2d235b06e527c9cc3db1dfe
parente3dfadc6c1444a2b84ffcb3d40b9afe00df863bf (diff)
downloadscummvm-rg350-e48cdb378c89e17c5f213eb921c0841aca062bd6.tar.gz
scummvm-rg350-e48cdb378c89e17c5f213eb921c0841aca062bd6.tar.bz2
scummvm-rg350-e48cdb378c89e17c5f213eb921c0841aca062bd6.zip
HUGO: Move _actListArr to scheduler
svn-id: r53995
-rw-r--r--engines/hugo/hugo.cpp633
-rw-r--r--engines/hugo/hugo.h4
-rw-r--r--engines/hugo/object.cpp1
-rw-r--r--engines/hugo/object_v1d.cpp2
-rw-r--r--engines/hugo/object_v1w.cpp3
-rw-r--r--engines/hugo/object_v2d.cpp2
-rw-r--r--engines/hugo/object_v3d.cpp3
-rw-r--r--engines/hugo/schedule.cpp640
-rw-r--r--engines/hugo/schedule.h23
9 files changed, 671 insertions, 640 deletions
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 1f06eec74b..b00b50cb6e 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -62,11 +62,11 @@ char _textBoxBuffer[MAX_BOX]; // Buffer for text box
command_t _line; // Line of user text input
HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), _mouseX(0), _mouseY(0),
- _textData(0), _stringtData(0), _screenNames(0), _textEngine(0), _textIntro(0), _textMouse(0), _textParser(0), _textSchedule(0), _textUtil(0),
- _arrayNouns(0), _arrayVerbs(0), _arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0), _backgroundObjects(0),
- _points(0), _cmdList(0), _screenActs(0), _actListArr(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0), _introY(0),
- _maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _numObj(0),
- _score(0), _maxscore(0), _backgroundObjectsSize(0), _screenActsSize(0), _actListArrSize(0), _usesSize(0)
+ _textData(0), _stringtData(0), _screenNames(0), _textEngine(0), _textIntro(0), _textMouse(0), _textParser(0), _textSchedule(0),
+ _textUtil(0), _arrayNouns(0), _arrayVerbs(0), _arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0),
+ _backgroundObjects(0), _points(0), _cmdList(0), _screenActs(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0),
+ _introY(0), _maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0),
+ _numObj(0), _score(0), _maxscore(0), _backgroundObjectsSize(0), _screenActsSize(0), _usesSize(0)
{
DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
@@ -130,10 +130,7 @@ HugoEngine::~HugoEngine() {
free(_screenActs);
_object->freeObjectArr();
-
- for (int i = 0; i < _actListArrSize; i++)
- free(_actListArr[i]);
- free(_actListArr);
+ _scheduler->freeActListArr();
free(_defltTunes);
free(_screenStates);
@@ -485,7 +482,7 @@ bool HugoEngine::loadHugoDat() {
}
}
- int numElem, numSubElem, numSubAct;
+ int numElem, numSubElem;
//Read _invent
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
@@ -672,571 +669,10 @@ bool HugoEngine::loadHugoDat() {
_screen_p = &(_object->_objects[HERO].screenIndex); // Current screen is hero's
_heroImage = HERO; // Current in use hero image
+ _scheduler->loadActListArr(in);
+
//read _actListArr
for (int varnt = 0; varnt < _numVariant; varnt++) {
- numElem = in.readUint16BE();
- if (varnt == _gameVariant) {
- _actListArrSize = numElem;
- _actListArr = (act **)malloc(sizeof(act *) * _actListArrSize);
- for (int i = 0; i < _actListArrSize; i++) {
- numSubElem = in.readUint16BE();
- _actListArr[i] = (act *) malloc(sizeof(act) * (numSubElem + 1));
- for (int j = 0; j < numSubElem; j++) {
- _actListArr[i][j].a0.actType = (action_t) in.readByte();
- switch (_actListArr[i][j].a0.actType) {
- case ANULL: // -1
- break;
- case ASCHEDULE: // 0
- _actListArr[i][j].a0.timer = in.readSint16BE();
- _actListArr[i][j].a0.actIndex = in.readUint16BE();
- break;
- case START_OBJ: // 1
- _actListArr[i][j].a1.timer = in.readSint16BE();
- _actListArr[i][j].a1.objNumb = in.readSint16BE();
- _actListArr[i][j].a1.cycleNumb = in.readSint16BE();
- _actListArr[i][j].a1.cycle = (cycle_t) in.readByte();
- break;
- case INIT_OBJXY: // 2
- _actListArr[i][j].a2.timer = in.readSint16BE();
- _actListArr[i][j].a2.objNumb = in.readSint16BE();
- _actListArr[i][j].a2.x = in.readSint16BE();
- _actListArr[i][j].a2.y = in.readSint16BE();
- break;
- case PROMPT: // 3
- _actListArr[i][j].a3.timer = in.readSint16BE();
- _actListArr[i][j].a3.promptIndex = in.readSint16BE();
- numSubAct = in.readUint16BE();
- _actListArr[i][j].a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct);
- for (int k = 0; k < numSubAct; k++)
- _actListArr[i][j].a3.responsePtr[k] = in.readSint16BE();
- _actListArr[i][j].a3.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a3.actFailIndex = in.readUint16BE();
- _actListArr[i][j].a3.encodedFl = (in.readByte() == 1) ? true : false;
- break;
- case BKGD_COLOR: // 4
- _actListArr[i][j].a4.timer = in.readSint16BE();
- _actListArr[i][j].a4.newBackgroundColor = in.readUint32BE();
- break;
- case INIT_OBJVXY: // 5
- _actListArr[i][j].a5.timer = in.readSint16BE();
- _actListArr[i][j].a5.objNumb = in.readSint16BE();
- _actListArr[i][j].a5.vx = in.readSint16BE();
- _actListArr[i][j].a5.vy = in.readSint16BE();
- break;
- case INIT_CARRY: // 6
- _actListArr[i][j].a6.timer = in.readSint16BE();
- _actListArr[i][j].a6.objNumb = in.readSint16BE();
- _actListArr[i][j].a6.carriedFl = (in.readByte() == 1) ? true : false;
- break;
- case INIT_HF_COORD: // 7
- _actListArr[i][j].a7.timer = in.readSint16BE();
- _actListArr[i][j].a7.objNumb = in.readSint16BE();
- break;
- case NEW_SCREEN: // 8
- _actListArr[i][j].a8.timer = in.readSint16BE();
- _actListArr[i][j].a8.screenIndex = in.readSint16BE();
- break;
- case INIT_OBJSTATE: // 9
- _actListArr[i][j].a9.timer = in.readSint16BE();
- _actListArr[i][j].a9.objNumb = in.readSint16BE();
- _actListArr[i][j].a9.newState = in.readByte();
- break;
- case INIT_PATH: // 10
- _actListArr[i][j].a10.timer = in.readSint16BE();
- _actListArr[i][j].a10.objNumb = in.readSint16BE();
- _actListArr[i][j].a10.newPathType = in.readSint16BE();
- _actListArr[i][j].a10.vxPath = in.readByte();
- _actListArr[i][j].a10.vyPath = in.readByte();
- break;
- case COND_R: // 11
- _actListArr[i][j].a11.timer = in.readSint16BE();
- _actListArr[i][j].a11.objNumb = in.readSint16BE();
- _actListArr[i][j].a11.stateReq = in.readByte();
- _actListArr[i][j].a11.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a11.actFailIndex = in.readUint16BE();
- break;
- case TEXT: // 12
- _actListArr[i][j].a12.timer = in.readSint16BE();
- _actListArr[i][j].a12.stringIndex = in.readSint16BE();
- break;
- case SWAP_IMAGES: // 13
- _actListArr[i][j].a13.timer = in.readSint16BE();
- _actListArr[i][j].a13.obj1 = in.readSint16BE();
- _actListArr[i][j].a13.obj2 = in.readSint16BE();
- break;
- case COND_SCR: // 14
- _actListArr[i][j].a14.timer = in.readSint16BE();
- _actListArr[i][j].a14.objNumb = in.readSint16BE();
- _actListArr[i][j].a14.screenReq = in.readSint16BE();
- _actListArr[i][j].a14.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a14.actFailIndex = in.readUint16BE();
- break;
- case AUTOPILOT: // 15
- _actListArr[i][j].a15.timer = in.readSint16BE();
- _actListArr[i][j].a15.obj1 = in.readSint16BE();
- _actListArr[i][j].a15.obj2 = in.readSint16BE();
- _actListArr[i][j].a15.dx = in.readByte();
- _actListArr[i][j].a15.dy = in.readByte();
- break;
- case INIT_OBJ_SEQ: // 16
- _actListArr[i][j].a16.timer = in.readSint16BE();
- _actListArr[i][j].a16.objNumb = in.readSint16BE();
- _actListArr[i][j].a16.seqIndex = in.readSint16BE();
- break;
- case SET_STATE_BITS: // 17
- _actListArr[i][j].a17.timer = in.readSint16BE();
- _actListArr[i][j].a17.objNumb = in.readSint16BE();
- _actListArr[i][j].a17.stateMask = in.readSint16BE();
- break;
- case CLEAR_STATE_BITS: // 18
- _actListArr[i][j].a18.timer = in.readSint16BE();
- _actListArr[i][j].a18.objNumb = in.readSint16BE();
- _actListArr[i][j].a18.stateMask = in.readSint16BE();
- break;
- case TEST_STATE_BITS: // 19
- _actListArr[i][j].a19.timer = in.readSint16BE();
- _actListArr[i][j].a19.objNumb = in.readSint16BE();
- _actListArr[i][j].a19.stateMask = in.readSint16BE();
- _actListArr[i][j].a19.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a19.actFailIndex = in.readUint16BE();
- break;
- case DEL_EVENTS: // 20
- _actListArr[i][j].a20.timer = in.readSint16BE();
- _actListArr[i][j].a20.actTypeDel = (action_t) in.readByte();
- break;
- case GAMEOVER: // 21
- _actListArr[i][j].a21.timer = in.readSint16BE();
- break;
- case INIT_HH_COORD: // 22
- _actListArr[i][j].a22.timer = in.readSint16BE();
- _actListArr[i][j].a22.objNumb = in.readSint16BE();
- break;
- case EXIT: // 23
- _actListArr[i][j].a23.timer = in.readSint16BE();
- break;
- case BONUS: // 24
- _actListArr[i][j].a24.timer = in.readSint16BE();
- _actListArr[i][j].a24.pointIndex = in.readSint16BE();
- break;
- case COND_BOX: // 25
- _actListArr[i][j].a25.timer = in.readSint16BE();
- _actListArr[i][j].a25.objNumb = in.readSint16BE();
- _actListArr[i][j].a25.x1 = in.readSint16BE();
- _actListArr[i][j].a25.y1 = in.readSint16BE();
- _actListArr[i][j].a25.x2 = in.readSint16BE();
- _actListArr[i][j].a25.y2 = in.readSint16BE();
- _actListArr[i][j].a25.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a25.actFailIndex = in.readUint16BE();
- break;
- case SOUND: // 26
- _actListArr[i][j].a26.timer = in.readSint16BE();
- _actListArr[i][j].a26.soundIndex = in.readSint16BE();
- break;
- case ADD_SCORE: // 27
- _actListArr[i][j].a27.timer = in.readSint16BE();
- _actListArr[i][j].a27.objNumb = in.readSint16BE();
- break;
- case SUB_SCORE: // 28
- _actListArr[i][j].a28.timer = in.readSint16BE();
- _actListArr[i][j].a28.objNumb = in.readSint16BE();
- break;
- case COND_CARRY: // 29
- _actListArr[i][j].a29.timer = in.readSint16BE();
- _actListArr[i][j].a29.objNumb = in.readSint16BE();
- _actListArr[i][j].a29.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a29.actFailIndex = in.readUint16BE();
- break;
- case INIT_MAZE: // 30
- _actListArr[i][j].a30.timer = in.readSint16BE();
- _actListArr[i][j].a30.mazeSize = in.readByte();
- _actListArr[i][j].a30.x1 = in.readSint16BE();
- _actListArr[i][j].a30.y1 = in.readSint16BE();
- _actListArr[i][j].a30.x2 = in.readSint16BE();
- _actListArr[i][j].a30.y2 = in.readSint16BE();
- _actListArr[i][j].a30.x3 = in.readSint16BE();
- _actListArr[i][j].a30.x4 = in.readSint16BE();
- _actListArr[i][j].a30.firstScreenIndex = in.readByte();
- break;
- case EXIT_MAZE: // 31
- _actListArr[i][j].a31.timer = in.readSint16BE();
- break;
- case INIT_PRIORITY: // 32
- _actListArr[i][j].a32.timer = in.readSint16BE();
- _actListArr[i][j].a32.objNumb = in.readSint16BE();
- _actListArr[i][j].a32.priority = in.readByte();
- break;
- case INIT_SCREEN: // 33
- _actListArr[i][j].a33.timer = in.readSint16BE();
- _actListArr[i][j].a33.objNumb = in.readSint16BE();
- _actListArr[i][j].a33.screenIndex = in.readSint16BE();
- break;
- case AGSCHEDULE: // 34
- _actListArr[i][j].a34.timer = in.readSint16BE();
- _actListArr[i][j].a34.actIndex = in.readUint16BE();
- break;
- case REMAPPAL: // 35
- _actListArr[i][j].a35.timer = in.readSint16BE();
- _actListArr[i][j].a35.oldColorIndex = in.readSint16BE();
- _actListArr[i][j].a35.newColorIndex = in.readSint16BE();
- break;
- case COND_NOUN: // 36
- _actListArr[i][j].a36.timer = in.readSint16BE();
- _actListArr[i][j].a36.nounIndex = in.readUint16BE();
- _actListArr[i][j].a36.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a36.actFailIndex = in.readUint16BE();
- break;
- case SCREEN_STATE: // 37
- _actListArr[i][j].a37.timer = in.readSint16BE();
- _actListArr[i][j].a37.screenIndex = in.readSint16BE();
- _actListArr[i][j].a37.newState = in.readByte();
- break;
- case INIT_LIPS: // 38
- _actListArr[i][j].a38.timer = in.readSint16BE();
- _actListArr[i][j].a38.lipsObjNumb = in.readSint16BE();
- _actListArr[i][j].a38.objNumb = in.readSint16BE();
- _actListArr[i][j].a38.dxLips = in.readByte();
- _actListArr[i][j].a38.dyLips = in.readByte();
- break;
- case INIT_STORY_MODE: // 39
- _actListArr[i][j].a39.timer = in.readSint16BE();
- _actListArr[i][j].a39.storyModeFl = (in.readByte() == 1);
- break;
- case WARN: // 40
- _actListArr[i][j].a40.timer = in.readSint16BE();
- _actListArr[i][j].a40.stringIndex = in.readSint16BE();
- break;
- case COND_BONUS: // 41
- _actListArr[i][j].a41.timer = in.readSint16BE();
- _actListArr[i][j].a41.BonusIndex = in.readSint16BE();
- _actListArr[i][j].a41.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a41.actFailIndex = in.readUint16BE();
- break;
- case TEXT_TAKE: // 42
- _actListArr[i][j].a42.timer = in.readSint16BE();
- _actListArr[i][j].a42.objNumb = in.readSint16BE();
- break;
- case YESNO: // 43
- _actListArr[i][j].a43.timer = in.readSint16BE();
- _actListArr[i][j].a43.promptIndex = in.readSint16BE();
- _actListArr[i][j].a43.actYesIndex = in.readUint16BE();
- _actListArr[i][j].a43.actNoIndex = in.readUint16BE();
- break;
- case STOP_ROUTE: // 44
- _actListArr[i][j].a44.timer = in.readSint16BE();
- break;
- case COND_ROUTE: // 45
- _actListArr[i][j].a45.timer = in.readSint16BE();
- _actListArr[i][j].a45.routeIndex = in.readSint16BE();
- _actListArr[i][j].a45.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a45.actFailIndex = in.readUint16BE();
- break;
- case INIT_JUMPEXIT: // 46
- _actListArr[i][j].a46.timer = in.readSint16BE();
- _actListArr[i][j].a46.jumpExitFl = (in.readByte() == 1);
- break;
- case INIT_VIEW: // 47
- _actListArr[i][j].a47.timer = in.readSint16BE();
- _actListArr[i][j].a47.objNumb = in.readSint16BE();
- _actListArr[i][j].a47.viewx = in.readSint16BE();
- _actListArr[i][j].a47.viewy = in.readSint16BE();
- _actListArr[i][j].a47.direction = in.readSint16BE();
- break;
- case INIT_OBJ_FRAME: // 48
- _actListArr[i][j].a48.timer = in.readSint16BE();
- _actListArr[i][j].a48.objNumb = in.readSint16BE();
- _actListArr[i][j].a48.seqIndex = in.readSint16BE();
- _actListArr[i][j].a48.frameIndex = in.readSint16BE();
- break;
- case OLD_SONG: //49
- _actListArr[i][j].a49.timer = in.readSint16BE();
- _actListArr[i][j].a49.soundIndex = in.readUint16BE();
- break;
- default:
- error("Engine - Unknown action type encountered: %d", _actListArr[i][j].a0.actType);
- }
- }
- _actListArr[i][numSubElem].a0.actType = ANULL;
- }
- } else {
- for (int i = 0; i < numElem; i++) {
- numSubElem = in.readUint16BE();
- for (int j = 0; j < numSubElem; j++) {
- numSubAct = in.readByte();
- switch (numSubAct) {
- case ANULL: // -1
- break;
- case ASCHEDULE: // 0
- in.readSint16BE();
- in.readUint16BE();
- break;
- case START_OBJ: // 1
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_OBJXY: // 2
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case PROMPT: // 3
- in.readSint16BE();
- in.readSint16BE();
- numSubAct = in.readUint16BE();
- for (int k = 0; k < numSubAct; k++)
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- in.readByte();
- break;
- case BKGD_COLOR: // 4
- in.readSint16BE();
- in.readUint32BE();
- break;
- case INIT_OBJVXY: // 5
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_CARRY: // 6
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_HF_COORD: // 7
- in.readSint16BE();
- in.readSint16BE();
- break;
- case NEW_SCREEN: // 8
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_OBJSTATE: // 9
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_PATH: // 10
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case COND_R: // 11
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case TEXT: // 12
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SWAP_IMAGES: // 13
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_SCR: // 14
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case AUTOPILOT: // 15
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case INIT_OBJ_SEQ: // 16
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SET_STATE_BITS: // 17
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case CLEAR_STATE_BITS: // 18
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case TEST_STATE_BITS: // 19
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case DEL_EVENTS: // 20
- in.readSint16BE();
- in.readByte();
- break;
- case GAMEOVER: // 21
- in.readSint16BE();
- break;
- case INIT_HH_COORD: // 22
- in.readSint16BE();
- in.readSint16BE();
- break;
- case EXIT: // 23
- in.readSint16BE();
- break;
- case BONUS: // 24
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_BOX: // 25
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case SOUND: // 26
- in.readSint16BE();
- in.readSint16BE();
- break;
- case ADD_SCORE: // 27
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SUB_SCORE: // 28
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_CARRY: // 29
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case INIT_MAZE: // 30
- in.readSint16BE();
- in.readByte();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case EXIT_MAZE: // 31
- in.readSint16BE();
- break;
- case INIT_PRIORITY: // 32
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_SCREEN: // 33
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case AGSCHEDULE: // 34
- in.readSint16BE();
- in.readUint16BE();
- break;
- case REMAPPAL: // 35
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_NOUN: // 36
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case SCREEN_STATE: // 37
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_LIPS: // 38
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case INIT_STORY_MODE: // 39
- in.readSint16BE();
- in.readByte();
- break;
- case WARN: // 40
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_BONUS: // 41
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case TEXT_TAKE: // 42
- in.readSint16BE();
- in.readSint16BE();
- break;
- case YESNO: // 43
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case STOP_ROUTE: // 44
- in.readSint16BE();
- break;
- case COND_ROUTE: // 45
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case INIT_JUMPEXIT: // 46
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_VIEW: // 47
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_OBJ_FRAME: // 48
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case OLD_SONG: //49
- in.readSint16BE();
- in.readUint16BE();
- break;
- default:
- error("Engine - Unknown action type encountered %d - variante %d pos %d.%d", numSubAct, varnt, i, j);
- }
- }
- }
- }
- }
- for (int varnt = 0; varnt < _numVariant; varnt++) {
if (varnt == _gameVariant) {
_tunesNbr = in.readSByte();
_soundSilence = in.readSByte();
@@ -1292,12 +728,7 @@ bool HugoEngine::loadHugoDat() {
_numObj = numElem;
}
- //Read kALnewscr used by maze (Hugo 2)
- for (int varnt = 0; varnt < _numVariant; varnt++) {
- numElem = in.readUint16BE();
- if (varnt == _gameVariant)
- _alNewscrIndex = numElem;
- }
+ _scheduler->loadAlNewscrIndex(in);
if (_gameVariant > 2) {
_arrayFontSize[0] = in.readUint16BE();
@@ -1714,50 +1145,6 @@ void HugoEngine::clearBoundary(int x1, int x2, int y) {
}
}
-// Maze mode is enabled. Check to see whether hero has crossed the maze
-// bounding box, if so, go to the next room */
-void HugoEngine::processMaze() {
- debugC(1, kDebugEngine, "processMaze");
-
- seq_t *currImage = _hero->currImagePtr; // Get ptr to current image
-
- // hero coordinates
- int x1 = _hero->x + currImage->x1; // Left edge of object
- int x2 = _hero->x + currImage->x2; // Right edge
- int y1 = _hero->y + currImage->y1; // Top edge
- int y2 = _hero->y + currImage->y2; // Bottom edge
-
- if (x1 < _maze.x1) {
- // Exit west
- _actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p - 1;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - SHIFT - (x2 - x1);
- _actListArr[_alNewscrIndex][0].a2.y = _hero->y;
- _status.routeIndex = -1;
- _scheduler->insertActionList(_alNewscrIndex);
- } else if (x2 > _maze.x2) {
- // Exit east
- _actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p + 1;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + SHIFT;
- _actListArr[_alNewscrIndex][0].a2.y = _hero->y;
- _status.routeIndex = -1;
- _scheduler->insertActionList(_alNewscrIndex);
- } else if (y1 < _maze.y1 - SHIFT) {
- // Exit north
- _actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p - _maze.size;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x3;
- _actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - SHIFT - (y2 - y1);
- _status.routeIndex = -1;
- _scheduler->insertActionList(_alNewscrIndex);
- } else if (y2 > _maze.y2 - SHIFT / 2) {
- // Exit south
- _actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p + _maze.size;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x4;
- _actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + SHIFT;
- _status.routeIndex = -1;
- _scheduler->insertActionList(_alNewscrIndex);
- }
-}
-
// Search background command list for this screen for supplied object.
// Return first associated verb (not "look") or 0 if none found.
char *HugoEngine::useBG(char *name) {
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index 766d1d9dfe..3e80ced2d5 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -153,14 +153,11 @@ public:
uint16 _cmdListSize;
uint16 **_screenActs;
uint16 _screenActsSize;
- act **_actListArr;
- uint16 _actListArrSize;
int16 *_defltTunes;
uint16 _look;
uint16 _take;
uint16 _drop;
uint16 _numObj;
- uint16 _alNewscrIndex;
Common::RandomSource *_rnd;
@@ -200,7 +197,6 @@ public:
void clearBoundary(int x1, int x2, int y);
void endGame();
void initStatus();
- void processMaze();
void readObjectImages();
void readScreenFiles(int screen);
void screenActions(int screen);
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 77a25ca343..5ecfb354fe 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -42,6 +42,7 @@
#include "hugo/route.h"
#include "hugo/util.h"
#include "hugo/parser.h"
+#include "hugo/schedule.h"
namespace Hugo {
diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp
index b2801d14c1..e7e9115a62 100644
--- a/engines/hugo/object_v1d.cpp
+++ b/engines/hugo/object_v1d.cpp
@@ -335,7 +335,7 @@ void ObjectHandler_v1d::moveObjects() {
// If maze mode is enabled, do special maze processing
if (_maze.enabledFl)
- _vm->processMaze();
+ _vm->_scheduler->processMaze();
}
void ObjectHandler_v1d::swapImages(int objNumb1, int objNumb2) {
diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp
index 05fa4bd35c..449c3e79ae 100644
--- a/engines/hugo/object_v1w.cpp
+++ b/engines/hugo/object_v1w.cpp
@@ -42,6 +42,7 @@
#include "hugo/route.h"
#include "hugo/util.h"
#include "hugo/parser.h"
+#include "hugo/schedule.h"
namespace Hugo {
@@ -342,7 +343,7 @@ void ObjectHandler_v1w::moveObjects() {
// If maze mode is enabled, do special maze processing
if (_maze.enabledFl)
- _vm->processMaze();
+ _vm->_scheduler->processMaze();
}
void ObjectHandler_v1w::swapImages(int objNumb1, int objNumb2) {
diff --git a/engines/hugo/object_v2d.cpp b/engines/hugo/object_v2d.cpp
index 3a0e367261..eb840c290b 100644
--- a/engines/hugo/object_v2d.cpp
+++ b/engines/hugo/object_v2d.cpp
@@ -346,7 +346,7 @@ void ObjectHandler_v2d::moveObjects() {
// If maze mode is enabled, do special maze processing
if (_maze.enabledFl)
- _vm->processMaze();
+ _vm->_scheduler->processMaze();
}
} // End of namespace Hugo
diff --git a/engines/hugo/object_v3d.cpp b/engines/hugo/object_v3d.cpp
index 42476ce379..adad3218ec 100644
--- a/engines/hugo/object_v3d.cpp
+++ b/engines/hugo/object_v3d.cpp
@@ -42,6 +42,7 @@
#include "hugo/route.h"
#include "hugo/util.h"
#include "hugo/parser.h"
+#include "hugo/schedule.h"
namespace Hugo {
@@ -228,7 +229,7 @@ void ObjectHandler_v3d::moveObjects() {
// If maze mode is enabled, do special maze processing
if (_maze.enabledFl)
- _vm->processMaze();
+ _vm->_scheduler->processMaze();
}
void ObjectHandler_v3d::swapImages(int objNumb1, int objNumb2) {
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index a72b337ffe..02597b5656 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -82,9 +82,9 @@ event_t *Scheduler::getQueue() {
void Scheduler::insertActionList(uint16 actIndex) {
debugC(1, kDebugSchedule, "insertActionList(%d)", actIndex);
- if (_vm->_actListArr[actIndex]) {
- for (int i = 0; _vm->_actListArr[actIndex][i].a0.actType != ANULL; i++)
- insertAction(&_vm->_actListArr[actIndex][i]);
+ if (_actListArr[actIndex]) {
+ for (int i = 0; _actListArr[actIndex][i].a0.actType != ANULL; i++)
+ insertAction(&_actListArr[actIndex][i]);
}
}
@@ -220,4 +220,638 @@ void Scheduler::waitForRefresh(void) {
timeout = ++t;
}
+ //Read kALnewscr used by maze (Hugo 2)
+void Scheduler::loadAlNewscrIndex(Common::File &in) {
+ debugC(6, kDebugSchedule, "loadAlNewscrIndex(&in)");
+
+ int numElem;
+ for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
+ numElem = in.readUint16BE();
+ if (varnt == _vm->_gameVariant)
+ _alNewscrIndex = numElem;
+ }
+}
+
+void Scheduler::loadActListArr(Common::File &in) {
+ debugC(6, kDebugSchedule, "loadActListArr(&in)");
+
+ int numElem, numSubElem, numSubAct;
+ for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
+ numElem = in.readUint16BE();
+ if (varnt == _vm->_gameVariant) {
+ _actListArrSize = numElem;
+ _actListArr = (act **)malloc(sizeof(act *) * _actListArrSize);
+ for (int i = 0; i < _actListArrSize; i++) {
+ numSubElem = in.readUint16BE();
+ _actListArr[i] = (act *) malloc(sizeof(act) * (numSubElem + 1));
+ for (int j = 0; j < numSubElem; j++) {
+ _actListArr[i][j].a0.actType = (action_t) in.readByte();
+ switch (_actListArr[i][j].a0.actType) {
+ case ANULL: // -1
+ break;
+ case ASCHEDULE: // 0
+ _actListArr[i][j].a0.timer = in.readSint16BE();
+ _actListArr[i][j].a0.actIndex = in.readUint16BE();
+ break;
+ case START_OBJ: // 1
+ _actListArr[i][j].a1.timer = in.readSint16BE();
+ _actListArr[i][j].a1.objNumb = in.readSint16BE();
+ _actListArr[i][j].a1.cycleNumb = in.readSint16BE();
+ _actListArr[i][j].a1.cycle = (cycle_t) in.readByte();
+ break;
+ case INIT_OBJXY: // 2
+ _actListArr[i][j].a2.timer = in.readSint16BE();
+ _actListArr[i][j].a2.objNumb = in.readSint16BE();
+ _actListArr[i][j].a2.x = in.readSint16BE();
+ _actListArr[i][j].a2.y = in.readSint16BE();
+ break;
+ case PROMPT: // 3
+ _actListArr[i][j].a3.timer = in.readSint16BE();
+ _actListArr[i][j].a3.promptIndex = in.readSint16BE();
+ numSubAct = in.readUint16BE();
+ _actListArr[i][j].a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct);
+ for (int k = 0; k < numSubAct; k++)
+ _actListArr[i][j].a3.responsePtr[k] = in.readSint16BE();
+ _actListArr[i][j].a3.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a3.actFailIndex = in.readUint16BE();
+ _actListArr[i][j].a3.encodedFl = (in.readByte() == 1) ? true : false;
+ break;
+ case BKGD_COLOR: // 4
+ _actListArr[i][j].a4.timer = in.readSint16BE();
+ _actListArr[i][j].a4.newBackgroundColor = in.readUint32BE();
+ break;
+ case INIT_OBJVXY: // 5
+ _actListArr[i][j].a5.timer = in.readSint16BE();
+ _actListArr[i][j].a5.objNumb = in.readSint16BE();
+ _actListArr[i][j].a5.vx = in.readSint16BE();
+ _actListArr[i][j].a5.vy = in.readSint16BE();
+ break;
+ case INIT_CARRY: // 6
+ _actListArr[i][j].a6.timer = in.readSint16BE();
+ _actListArr[i][j].a6.objNumb = in.readSint16BE();
+ _actListArr[i][j].a6.carriedFl = (in.readByte() == 1) ? true : false;
+ break;
+ case INIT_HF_COORD: // 7
+ _actListArr[i][j].a7.timer = in.readSint16BE();
+ _actListArr[i][j].a7.objNumb = in.readSint16BE();
+ break;
+ case NEW_SCREEN: // 8
+ _actListArr[i][j].a8.timer = in.readSint16BE();
+ _actListArr[i][j].a8.screenIndex = in.readSint16BE();
+ break;
+ case INIT_OBJSTATE: // 9
+ _actListArr[i][j].a9.timer = in.readSint16BE();
+ _actListArr[i][j].a9.objNumb = in.readSint16BE();
+ _actListArr[i][j].a9.newState = in.readByte();
+ break;
+ case INIT_PATH: // 10
+ _actListArr[i][j].a10.timer = in.readSint16BE();
+ _actListArr[i][j].a10.objNumb = in.readSint16BE();
+ _actListArr[i][j].a10.newPathType = in.readSint16BE();
+ _actListArr[i][j].a10.vxPath = in.readByte();
+ _actListArr[i][j].a10.vyPath = in.readByte();
+ break;
+ case COND_R: // 11
+ _actListArr[i][j].a11.timer = in.readSint16BE();
+ _actListArr[i][j].a11.objNumb = in.readSint16BE();
+ _actListArr[i][j].a11.stateReq = in.readByte();
+ _actListArr[i][j].a11.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a11.actFailIndex = in.readUint16BE();
+ break;
+ case TEXT: // 12
+ _actListArr[i][j].a12.timer = in.readSint16BE();
+ _actListArr[i][j].a12.stringIndex = in.readSint16BE();
+ break;
+ case SWAP_IMAGES: // 13
+ _actListArr[i][j].a13.timer = in.readSint16BE();
+ _actListArr[i][j].a13.obj1 = in.readSint16BE();
+ _actListArr[i][j].a13.obj2 = in.readSint16BE();
+ break;
+ case COND_SCR: // 14
+ _actListArr[i][j].a14.timer = in.readSint16BE();
+ _actListArr[i][j].a14.objNumb = in.readSint16BE();
+ _actListArr[i][j].a14.screenReq = in.readSint16BE();
+ _actListArr[i][j].a14.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a14.actFailIndex = in.readUint16BE();
+ break;
+ case AUTOPILOT: // 15
+ _actListArr[i][j].a15.timer = in.readSint16BE();
+ _actListArr[i][j].a15.obj1 = in.readSint16BE();
+ _actListArr[i][j].a15.obj2 = in.readSint16BE();
+ _actListArr[i][j].a15.dx = in.readByte();
+ _actListArr[i][j].a15.dy = in.readByte();
+ break;
+ case INIT_OBJ_SEQ: // 16
+ _actListArr[i][j].a16.timer = in.readSint16BE();
+ _actListArr[i][j].a16.objNumb = in.readSint16BE();
+ _actListArr[i][j].a16.seqIndex = in.readSint16BE();
+ break;
+ case SET_STATE_BITS: // 17
+ _actListArr[i][j].a17.timer = in.readSint16BE();
+ _actListArr[i][j].a17.objNumb = in.readSint16BE();
+ _actListArr[i][j].a17.stateMask = in.readSint16BE();
+ break;
+ case CLEAR_STATE_BITS: // 18
+ _actListArr[i][j].a18.timer = in.readSint16BE();
+ _actListArr[i][j].a18.objNumb = in.readSint16BE();
+ _actListArr[i][j].a18.stateMask = in.readSint16BE();
+ break;
+ case TEST_STATE_BITS: // 19
+ _actListArr[i][j].a19.timer = in.readSint16BE();
+ _actListArr[i][j].a19.objNumb = in.readSint16BE();
+ _actListArr[i][j].a19.stateMask = in.readSint16BE();
+ _actListArr[i][j].a19.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a19.actFailIndex = in.readUint16BE();
+ break;
+ case DEL_EVENTS: // 20
+ _actListArr[i][j].a20.timer = in.readSint16BE();
+ _actListArr[i][j].a20.actTypeDel = (action_t) in.readByte();
+ break;
+ case GAMEOVER: // 21
+ _actListArr[i][j].a21.timer = in.readSint16BE();
+ break;
+ case INIT_HH_COORD: // 22
+ _actListArr[i][j].a22.timer = in.readSint16BE();
+ _actListArr[i][j].a22.objNumb = in.readSint16BE();
+ break;
+ case EXIT: // 23
+ _actListArr[i][j].a23.timer = in.readSint16BE();
+ break;
+ case BONUS: // 24
+ _actListArr[i][j].a24.timer = in.readSint16BE();
+ _actListArr[i][j].a24.pointIndex = in.readSint16BE();
+ break;
+ case COND_BOX: // 25
+ _actListArr[i][j].a25.timer = in.readSint16BE();
+ _actListArr[i][j].a25.objNumb = in.readSint16BE();
+ _actListArr[i][j].a25.x1 = in.readSint16BE();
+ _actListArr[i][j].a25.y1 = in.readSint16BE();
+ _actListArr[i][j].a25.x2 = in.readSint16BE();
+ _actListArr[i][j].a25.y2 = in.readSint16BE();
+ _actListArr[i][j].a25.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a25.actFailIndex = in.readUint16BE();
+ break;
+ case SOUND: // 26
+ _actListArr[i][j].a26.timer = in.readSint16BE();
+ _actListArr[i][j].a26.soundIndex = in.readSint16BE();
+ break;
+ case ADD_SCORE: // 27
+ _actListArr[i][j].a27.timer = in.readSint16BE();
+ _actListArr[i][j].a27.objNumb = in.readSint16BE();
+ break;
+ case SUB_SCORE: // 28
+ _actListArr[i][j].a28.timer = in.readSint16BE();
+ _actListArr[i][j].a28.objNumb = in.readSint16BE();
+ break;
+ case COND_CARRY: // 29
+ _actListArr[i][j].a29.timer = in.readSint16BE();
+ _actListArr[i][j].a29.objNumb = in.readSint16BE();
+ _actListArr[i][j].a29.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a29.actFailIndex = in.readUint16BE();
+ break;
+ case INIT_MAZE: // 30
+ _actListArr[i][j].a30.timer = in.readSint16BE();
+ _actListArr[i][j].a30.mazeSize = in.readByte();
+ _actListArr[i][j].a30.x1 = in.readSint16BE();
+ _actListArr[i][j].a30.y1 = in.readSint16BE();
+ _actListArr[i][j].a30.x2 = in.readSint16BE();
+ _actListArr[i][j].a30.y2 = in.readSint16BE();
+ _actListArr[i][j].a30.x3 = in.readSint16BE();
+ _actListArr[i][j].a30.x4 = in.readSint16BE();
+ _actListArr[i][j].a30.firstScreenIndex = in.readByte();
+ break;
+ case EXIT_MAZE: // 31
+ _actListArr[i][j].a31.timer = in.readSint16BE();
+ break;
+ case INIT_PRIORITY: // 32
+ _actListArr[i][j].a32.timer = in.readSint16BE();
+ _actListArr[i][j].a32.objNumb = in.readSint16BE();
+ _actListArr[i][j].a32.priority = in.readByte();
+ break;
+ case INIT_SCREEN: // 33
+ _actListArr[i][j].a33.timer = in.readSint16BE();
+ _actListArr[i][j].a33.objNumb = in.readSint16BE();
+ _actListArr[i][j].a33.screenIndex = in.readSint16BE();
+ break;
+ case AGSCHEDULE: // 34
+ _actListArr[i][j].a34.timer = in.readSint16BE();
+ _actListArr[i][j].a34.actIndex = in.readUint16BE();
+ break;
+ case REMAPPAL: // 35
+ _actListArr[i][j].a35.timer = in.readSint16BE();
+ _actListArr[i][j].a35.oldColorIndex = in.readSint16BE();
+ _actListArr[i][j].a35.newColorIndex = in.readSint16BE();
+ break;
+ case COND_NOUN: // 36
+ _actListArr[i][j].a36.timer = in.readSint16BE();
+ _actListArr[i][j].a36.nounIndex = in.readUint16BE();
+ _actListArr[i][j].a36.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a36.actFailIndex = in.readUint16BE();
+ break;
+ case SCREEN_STATE: // 37
+ _actListArr[i][j].a37.timer = in.readSint16BE();
+ _actListArr[i][j].a37.screenIndex = in.readSint16BE();
+ _actListArr[i][j].a37.newState = in.readByte();
+ break;
+ case INIT_LIPS: // 38
+ _actListArr[i][j].a38.timer = in.readSint16BE();
+ _actListArr[i][j].a38.lipsObjNumb = in.readSint16BE();
+ _actListArr[i][j].a38.objNumb = in.readSint16BE();
+ _actListArr[i][j].a38.dxLips = in.readByte();
+ _actListArr[i][j].a38.dyLips = in.readByte();
+ break;
+ case INIT_STORY_MODE: // 39
+ _actListArr[i][j].a39.timer = in.readSint16BE();
+ _actListArr[i][j].a39.storyModeFl = (in.readByte() == 1);
+ break;
+ case WARN: // 40
+ _actListArr[i][j].a40.timer = in.readSint16BE();
+ _actListArr[i][j].a40.stringIndex = in.readSint16BE();
+ break;
+ case COND_BONUS: // 41
+ _actListArr[i][j].a41.timer = in.readSint16BE();
+ _actListArr[i][j].a41.BonusIndex = in.readSint16BE();
+ _actListArr[i][j].a41.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a41.actFailIndex = in.readUint16BE();
+ break;
+ case TEXT_TAKE: // 42
+ _actListArr[i][j].a42.timer = in.readSint16BE();
+ _actListArr[i][j].a42.objNumb = in.readSint16BE();
+ break;
+ case YESNO: // 43
+ _actListArr[i][j].a43.timer = in.readSint16BE();
+ _actListArr[i][j].a43.promptIndex = in.readSint16BE();
+ _actListArr[i][j].a43.actYesIndex = in.readUint16BE();
+ _actListArr[i][j].a43.actNoIndex = in.readUint16BE();
+ break;
+ case STOP_ROUTE: // 44
+ _actListArr[i][j].a44.timer = in.readSint16BE();
+ break;
+ case COND_ROUTE: // 45
+ _actListArr[i][j].a45.timer = in.readSint16BE();
+ _actListArr[i][j].a45.routeIndex = in.readSint16BE();
+ _actListArr[i][j].a45.actPassIndex = in.readUint16BE();
+ _actListArr[i][j].a45.actFailIndex = in.readUint16BE();
+ break;
+ case INIT_JUMPEXIT: // 46
+ _actListArr[i][j].a46.timer = in.readSint16BE();
+ _actListArr[i][j].a46.jumpExitFl = (in.readByte() == 1);
+ break;
+ case INIT_VIEW: // 47
+ _actListArr[i][j].a47.timer = in.readSint16BE();
+ _actListArr[i][j].a47.objNumb = in.readSint16BE();
+ _actListArr[i][j].a47.viewx = in.readSint16BE();
+ _actListArr[i][j].a47.viewy = in.readSint16BE();
+ _actListArr[i][j].a47.direction = in.readSint16BE();
+ break;
+ case INIT_OBJ_FRAME: // 48
+ _actListArr[i][j].a48.timer = in.readSint16BE();
+ _actListArr[i][j].a48.objNumb = in.readSint16BE();
+ _actListArr[i][j].a48.seqIndex = in.readSint16BE();
+ _actListArr[i][j].a48.frameIndex = in.readSint16BE();
+ break;
+ case OLD_SONG: //49
+ _actListArr[i][j].a49.timer = in.readSint16BE();
+ _actListArr[i][j].a49.soundIndex = in.readUint16BE();
+ break;
+ default:
+ error("Engine - Unknown action type encountered: %d", _actListArr[i][j].a0.actType);
+ }
+ }
+ _actListArr[i][numSubElem].a0.actType = ANULL;
+ }
+ } else {
+ for (int i = 0; i < numElem; i++) {
+ numSubElem = in.readUint16BE();
+ for (int j = 0; j < numSubElem; j++) {
+ numSubAct = in.readByte();
+ switch (numSubAct) {
+ case ANULL: // -1
+ break;
+ case ASCHEDULE: // 0
+ in.readSint16BE();
+ in.readUint16BE();
+ break;
+ case START_OBJ: // 1
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_OBJXY: // 2
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case PROMPT: // 3
+ in.readSint16BE();
+ in.readSint16BE();
+ numSubAct = in.readUint16BE();
+ for (int k = 0; k < numSubAct; k++)
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ in.readByte();
+ break;
+ case BKGD_COLOR: // 4
+ in.readSint16BE();
+ in.readUint32BE();
+ break;
+ case INIT_OBJVXY: // 5
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case INIT_CARRY: // 6
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_HF_COORD: // 7
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case NEW_SCREEN: // 8
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case INIT_OBJSTATE: // 9
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_PATH: // 10
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ in.readByte();
+ break;
+ case COND_R: // 11
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case TEXT: // 12
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case SWAP_IMAGES: // 13
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case COND_SCR: // 14
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case AUTOPILOT: // 15
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ in.readByte();
+ break;
+ case INIT_OBJ_SEQ: // 16
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case SET_STATE_BITS: // 17
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case CLEAR_STATE_BITS: // 18
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case TEST_STATE_BITS: // 19
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case DEL_EVENTS: // 20
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case GAMEOVER: // 21
+ in.readSint16BE();
+ break;
+ case INIT_HH_COORD: // 22
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case EXIT: // 23
+ in.readSint16BE();
+ break;
+ case BONUS: // 24
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case COND_BOX: // 25
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case SOUND: // 26
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case ADD_SCORE: // 27
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case SUB_SCORE: // 28
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case COND_CARRY: // 29
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case INIT_MAZE: // 30
+ in.readSint16BE();
+ in.readByte();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case EXIT_MAZE: // 31
+ in.readSint16BE();
+ break;
+ case INIT_PRIORITY: // 32
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_SCREEN: // 33
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case AGSCHEDULE: // 34
+ in.readSint16BE();
+ in.readUint16BE();
+ break;
+ case REMAPPAL: // 35
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case COND_NOUN: // 36
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case SCREEN_STATE: // 37
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_LIPS: // 38
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readByte();
+ in.readByte();
+ break;
+ case INIT_STORY_MODE: // 39
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case WARN: // 40
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case COND_BONUS: // 41
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case TEXT_TAKE: // 42
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case YESNO: // 43
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case STOP_ROUTE: // 44
+ in.readSint16BE();
+ break;
+ case COND_ROUTE: // 45
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readUint16BE();
+ in.readUint16BE();
+ break;
+ case INIT_JUMPEXIT: // 46
+ in.readSint16BE();
+ in.readByte();
+ break;
+ case INIT_VIEW: // 47
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case INIT_OBJ_FRAME: // 48
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ in.readSint16BE();
+ break;
+ case OLD_SONG: //49
+ in.readSint16BE();
+ in.readUint16BE();
+ break;
+ default:
+ error("Engine - Unknown action type encountered %d - variante %d pos %d.%d", numSubAct, varnt, i, j);
+ }
+ }
+ }
+ }
+ }
+}
+
+void Scheduler::freeActListArr() {
+ debugC(6, kDebugSchedule, "freeActListArr()");
+
+ for (int i = 0; i < _actListArrSize; i++)
+ free(_actListArr[i]);
+ free(_actListArr);
+}
+
+// Maze mode is enabled. Check to see whether hero has crossed the maze
+// bounding box, if so, go to the next room */
+void Scheduler::processMaze() {
+ debugC(1, kDebugSchedule, "processMaze");
+
+ status_t &gameStatus = _vm->getGameStatus();
+ seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image
+
+ // hero coordinates
+ int x1 = _vm->_hero->x + currImage->x1; // Left edge of object
+ int x2 = _vm->_hero->x + currImage->x2; // Right edge
+ int y1 = _vm->_hero->y + currImage->y1; // Top edge
+ int y2 = _vm->_hero->y + currImage->y2; // Bottom edge
+
+ if (x1 < _maze.x1) {
+ // Exit west
+ _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1;
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - SHIFT - (x2 - x1);
+ _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y;
+ gameStatus.routeIndex = -1;
+ insertActionList(_alNewscrIndex);
+ } else if (x2 > _maze.x2) {
+ // Exit east
+ _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1;
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + SHIFT;
+ _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y;
+ gameStatus.routeIndex = -1;
+ insertActionList(_alNewscrIndex);
+ } else if (y1 < _maze.y1 - SHIFT) {
+ // Exit north
+ _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _maze.size;
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x3;
+ _actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - SHIFT - (y2 - y1);
+ gameStatus.routeIndex = -1;
+ insertActionList(_alNewscrIndex);
+ } else if (y2 > _maze.y2 - SHIFT / 2) {
+ // Exit south
+ _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _maze.size;
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x4;
+ _actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + SHIFT;
+ gameStatus.routeIndex = -1;
+ insertActionList(_alNewscrIndex);
+ }
+}
+
} // End of namespace Hugo
diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h
index e6eb5d7947..af2a45da2f 100644
--- a/engines/hugo/schedule.h
+++ b/engines/hugo/schedule.h
@@ -33,6 +33,8 @@
#ifndef HUGO_SCHEDULE_H
#define HUGO_SCHEDULE_H
+#include "common/file.h"
+
namespace Hugo {
#define SIGN(X) ((X < 0) ? -1 : 1)
@@ -56,15 +58,24 @@ public:
virtual void runScheduler() = 0;
virtual void saveEvents(Common::WriteStream *f) = 0;
+ void decodeString(char *line);
+ void freeActListArr();
void initEventQueue();
void insertActionList(uint16 actIndex);
- void decodeString(char *line);
- uint32 getWinTicks();
- uint32 getDosTicks(bool updateFl);
- void waitForRefresh(void);
- void processBonus(int bonusIndex);
+ void loadActListArr(Common::File &in);
+ void loadAlNewscrIndex(Common::File &in);
void newScreen(int screenIndex);
+ void processBonus(int bonusIndex);
+ void processMaze();
void restoreScreen(int screenIndex);
+ void waitForRefresh(void);
+
+ uint32 getWinTicks();
+ uint32 getDosTicks(bool updateFl);
+
+ act **_actListArr;
+ uint16 _actListArrSize;
+ uint16 _alNewscrIndex;
protected:
HugoEngine *_vm;
@@ -77,7 +88,7 @@ protected:
event_t *_freeEvent; // Free list of event structures
event_t *_headEvent; // Head of list (earliest time)
event_t *_tailEvent; // Tail of list (latest time)
- event_t _events[kMaxEvents]; // Statically declare event structures
+ event_t _events[kMaxEvents]; // Statically declare event structures
virtual const char *getCypher() = 0;
virtual void delQueue(event_t *curEvent) = 0;