aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
authorPaul Gilbert2010-07-06 11:32:10 +0000
committerPaul Gilbert2010-07-06 11:32:10 +0000
commit3f7dc9e0e2e4d043b2234b7b66981e16eb8a84b1 (patch)
treeb88d9beb2c38f8f21f521e6d8c2c3b72bb3b7a5a /engines/m4
parent2d5dabee30b842a6670f4d6e956c45e37389e344 (diff)
downloadscummvm-rg350-3f7dc9e0e2e4d043b2234b7b66981e16eb8a84b1.tar.gz
scummvm-rg350-3f7dc9e0e2e4d043b2234b7b66981e16eb8a84b1.tar.bz2
scummvm-rg350-3f7dc9e0e2e4d043b2234b7b66981e16eb8a84b1.zip
Added extra initialisation code for the game's global variables list
svn-id: r50722
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/globals.cpp1
-rw-r--r--engines/m4/globals.h10
-rw-r--r--engines/m4/mads_logic.cpp113
-rw-r--r--engines/m4/mads_logic.h5
4 files changed, 125 insertions, 4 deletions
diff --git a/engines/m4/globals.cpp b/engines/m4/globals.cpp
index fb95adf29f..a96229a0b3 100644
--- a/engines/m4/globals.cpp
+++ b/engines/m4/globals.cpp
@@ -284,6 +284,7 @@ MadsGlobals::MadsGlobals(MadsEngine *vm): Globals(vm) {
sceneNumber = -1;
for (int i = 0; i < 3; ++i)
actionNouns[i] = 0;
+ _difficultyLevel = 0;
}
MadsGlobals::~MadsGlobals() {
diff --git a/engines/m4/globals.h b/engines/m4/globals.h
index 5ab1ccd9a6..3fc31b4ec2 100644
--- a/engines/m4/globals.h
+++ b/engines/m4/globals.h
@@ -150,7 +150,7 @@ public:
void pauseGame(bool value);
};
-#define TOTAL_NUM_VARIABLES 256
+#define TOTAL_NUM_VARIABLES 210
#define PLAYER_INVENTORY 2
@@ -224,6 +224,11 @@ struct MadsConfigData {
int screenFades;
};
+#define GET_GLOBAL(x) (_madsVm->globals()->_globals[x])
+#define GET_GLOBAL32(x) (((uint32)_madsVm->globals()->_globals[x + 1] << 16) | _madsVm->globals()->_globals[x])
+#define SET_GLOBAL(x,y) _madsVm->globals()->_globals[x] = y
+#define SET_GLOBAL32(x,y) { _madsVm->globals()->_globals[x] = (y) & 0xffff; _madsVm->globals()->_globals[(x) + 1] = (y) >> 16; }
+
typedef Common::HashMap<uint16, uint16> IntStorage;
class MadsGlobals : public Globals {
@@ -246,7 +251,7 @@ public:
~MadsGlobals();
// MADS variables
- int _globals[TOTAL_NUM_VARIABLES];
+ uint16 _globals[TOTAL_NUM_VARIABLES];
MadsConfigData _config;
bool playerSpriteChanged;
MadsDialogType dialogType;
@@ -255,6 +260,7 @@ public:
int16 _nextSceneId;
uint16 actionNouns[3];
IntStorage _dataMap;
+ int _difficultyLevel;
void loadMadsVocab();
uint32 getVocabSize() { return _madsVocab.size(); }
diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp
index c90fb11c11..8561963208 100644
--- a/engines/m4/mads_logic.cpp
+++ b/engines/m4/mads_logic.cpp
@@ -29,6 +29,114 @@
namespace M4 {
+void MadsGameLogic::initialiseGlobals() {
+ // Clear the entire globals list
+ Common::set_to(&_madsVm->globals()->_globals[0], &_madsVm->globals()->_globals[TOTAL_NUM_VARIABLES], 0);
+
+ SET_GLOBAL(4, 8);
+ SET_GLOBAL(33, 1);
+ SET_GLOBAL(10, 0xFFFF);
+ SET_GLOBAL(13, 0xFFFF);
+ SET_GLOBAL(15, 0xFFFF);
+ SET_GLOBAL(19, 0xFFFF);
+ SET_GLOBAL(20, 0xFFFF);
+ SET_GLOBAL(21, 0xFFFF);
+ SET_GLOBAL(95, 0xFFFF);
+
+ // TODO: unknown sub call
+
+ // Put the values 0 through 3 in a random ordering in global slots 83 - 86
+ for (int idx = 0; idx < 4; ) {
+ int randVal = _madsVm->_random->getRandomNumber(4);
+ SET_GLOBAL(83 + idx, randVal);
+
+ // Check whether the given value has already been used
+ bool flag = false;
+ for (int idx2 = 0; idx2 < idx; ++idx2) {
+ if (randVal == GET_GLOBAL(83 + idx2))
+ flag = true;
+ }
+
+ if (!flag)
+ ++idx;
+ }
+
+ // Put the values 0 through 3 in a random ordering in global slots 87 - 90
+ for (int idx = 0; idx < 4; ) {
+ int randVal = _madsVm->_random->getRandomNumber(3);
+ SET_GLOBAL(87 + idx, randVal);
+
+ // Check whether the given value has already been used
+ bool flag = false;
+ for (int idx2 = 0; idx2 < idx; ++idx2) {
+ if (randVal == GET_GLOBAL(87 + idx2))
+ flag = true;
+ }
+
+ if (!flag)
+ ++idx;
+ }
+
+ // Miscellaneous global settings
+ SET_GLOBAL(120, 501);
+ SET_GLOBAL(121, 0xFFFF);
+ SET_GLOBAL(110, 0xFFFF);
+ SET_GLOBAL(119, 1);
+ SET_GLOBAL(134, 4);
+ SET_GLOBAL(190, 201);
+ SET_GLOBAL(191, 301);
+ SET_GLOBAL(192, 413);
+ SET_GLOBAL(193, 706);
+ SET_GLOBAL(194, 801);
+ SET_GLOBAL(195, 551);
+ SET_GLOBAL(196, 752);
+
+ // Fill out the globals 200 - 209 with unique random number values less than 10000
+ for (int idx = 0; idx < 10; ) {
+ int randVal = _madsVm->_random->getRandomNumber(9999);
+ SET_GLOBAL(200 + idx, randVal);
+
+ // Check whether the given value has already been used
+ bool flag = false;
+ for (int idx2 = 0; idx2 < idx; ++idx2) {
+ if (randVal == GET_GLOBAL(87 + idx2))
+ flag = true;
+ }
+
+ if (!flag)
+ ++idx;
+ }
+
+ switch (_madsVm->globals()->_difficultyLevel) {
+ case 1:
+ // Very hard
+ SET_GLOBAL(35, 0);
+ // TODO: object set room
+ SET_GLOBAL(137, 5);
+ SET_GLOBAL(136, 0);
+ break;
+
+ case 2:
+ // Hard
+ SET_GLOBAL(35, 0);
+ // TODO: object set room
+ SET_GLOBAL(136, 0xFFFF);
+ SET_GLOBAL(137, 6);
+ break;
+
+ case 3:
+ // Easy
+ SET_GLOBAL(35, 2);
+ // TODO: object set room
+ break;
+ }
+
+ _madsVm->_player._direction = 8;
+ _madsVm->_player._direction2 = 8;
+
+ // TODO: unknown processing routine getting called for 'RXM' and 'ROX'
+}
+
/*--------------------------------------------------------------------------*/
const char *MadsSceneLogic::formAnimName(char sepChar, int16 suffixNum) {
@@ -299,6 +407,7 @@ void MadsSceneLogic::enterScene() {
_madsVm->_player._playerPos = Common::Point(68, 140);
_madsVm->_player._direction = 4;
_madsVm->_player._visible = false;
+ _madsVm->_player._stepEnabled = false;
dataMap()[0x56FC] = 0;
dataMap()[0x5482] = 0;
@@ -323,9 +432,9 @@ void MadsSceneLogic::sceneStep() {
case 71:
_madsVm->globals()->_globals[10] = 0;
_madsVm->_player._visible = true;
- dataMap()[0x56FC] = 0;
+ _madsVm->_player._stepEnabled = true;
- _madsVm->scene()->_newTimeout = _madsVm->_currentTimer - _madsVm->scene()->_ticksAmount;
+ _madsVm->_player._priorTimer = _madsVm->_currentTimer - _madsVm->_player._ticksAmount;
break;
case 72:
case 73:
diff --git a/engines/m4/mads_logic.h b/engines/m4/mads_logic.h
index 3c6cb8edf1..98d6df6163 100644
--- a/engines/m4/mads_logic.h
+++ b/engines/m4/mads_logic.h
@@ -63,6 +63,11 @@ public:
void sceneStep();
};
+class MadsGameLogic {
+public:
+ static void initialiseGlobals();
+};
+
}
#endif