aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorFlorian Kagerer2009-03-15 18:21:33 +0000
committerFlorian Kagerer2009-03-15 18:21:33 +0000
commitc826106e44c529fff84eee3dd052ae4895916c47 (patch)
treea22f6a8b9339ba511855fa915086ceb37af26663 /engines/kyra
parentadde70537a29d891247c8c9ce19d6e1dcd0d4e67 (diff)
downloadscummvm-rg350-c826106e44c529fff84eee3dd052ae4895916c47.tar.gz
scummvm-rg350-c826106e44c529fff84eee3dd052ae4895916c47.tar.bz2
scummvm-rg350-c826106e44c529fff84eee3dd052ae4895916c47.zip
LOL: - implemented original style random number generator for moving around the monsters
svn-id: r39425
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/gui_lol.cpp2
-rw-r--r--engines/kyra/lol.cpp32
-rw-r--r--engines/kyra/lol.h23
-rw-r--r--engines/kyra/scene_lol.cpp2
-rw-r--r--engines/kyra/sprites_lol.cpp2
5 files changed, 54 insertions, 7 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 453e4280ea..9f36e060df 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -1394,7 +1394,7 @@ int LoLEngine::clickedUnk24(Button *button) {
}
int LoLEngine::clickedSceneThrowItem(Button *button) {
- //if (_updateFlags & 1)
+ if (_updateFlags & 1)
return 0;
uint16 block = calcNewBlockPosition(_currentBlock, _currentDirection);
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index 2f5ae741c5..62b3bcaa1d 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -199,6 +199,8 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy
_unkBt1 = _unkBt2 = 0;
_dialogueField = false;
+
+ _rndSpecial = 0x12349876;
_buttonData = 0;
_activeButtons = 0;
@@ -413,8 +415,8 @@ Common::Error LoLEngine::init() {
_tempBuffer5120 = new uint8[5120];
memset(_tempBuffer5120, 0, 5120);
- _throwItemState = new uint8[136];
- memset(_throwItemState, 0, 136);
+ _throwItemState = new ThrownItem[8];
+ memset(_throwItemState, 0, 8 * sizeof(ThrownItem));
memset(_gameFlags, 0, sizeof(_gameFlags));
memset(_globalScriptVars, 0, sizeof(_globalScriptVars));
@@ -1678,6 +1680,32 @@ void LoLEngine::delay(uint32 millis, bool cUpdate, bool isMainLoop) {
}
}
+uint8 LoLEngine::getRandomNumberSpecial() {
+ uint8 a = _rndSpecial & 0xff;
+ uint8 b = (_rndSpecial >> 8) & 0xff;
+ uint8 c = (_rndSpecial >> 16) & 0xff;
+
+ a >>= 1;
+
+ uint as = a & 1;
+ uint bs = (b >> 7) ? 0 : 1;
+ uint cs = c >> 7;
+
+ a >>= 1;
+ c = (c << 1) | as;
+ b = (b << 1) | cs;
+
+ a -= ((_rndSpecial & 0xff) - bs);
+ as = a & 1;
+ a >>= 1;
+
+ a = ((_rndSpecial & 0xff) >> 1) | (as << 7);
+
+ _rndSpecial = (_rndSpecial & 0xff000000) | (c << 16) | (b << 8) | a;
+
+ return a ^ b;
+}
+
void LoLEngine::updateEnvironmentalSfx(int soundId) {
snd_processEnvironmentalSoundEffect(soundId, _currentBlock);
}
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index b76d562550..2673afad19 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -207,6 +207,22 @@ struct ButtonDef {
uint16 screenDim;
};
+struct ThrownItem {
+ uint8 enable;
+ uint8 a;
+ uint16 c;
+ uint16 item;
+ uint16 x;
+ uint16 y;
+ uint8 b;
+ uint8 direction;
+ int8 field_C;
+ int8 field_D;
+ uint8 charNum;
+ uint8 flags;
+ uint8 field_10;
+};
+
class LoLEngine : public KyraEngine_v1 {
friend class GUI_LoL;
friend class TextDisplayer_LoL;
@@ -883,8 +899,7 @@ private:
uint8 _unkGameFlag;
uint8 *_tempBuffer5120;
- uint8 *_throwItemState;
-
+
const char *const * _levelDatList;
int _levelDatListSize;
const char *const * _levelShpList;
@@ -965,6 +980,8 @@ private:
int _hideControls;
int _lastCharInventory;
+ ThrownItem *_throwItemState;
+
EMCData _itemScript;
const uint8 *_charInvIndex;
@@ -1045,6 +1062,7 @@ private:
// misc
void delay(uint32 millis, bool cUpdate = false, bool isMainLoop = false);
+ uint8 getRandomNumberSpecial();
uint8 _unkBt1;
uint8 _unkBt2;
@@ -1052,6 +1070,7 @@ private:
uint8 *_pageBuffer1;
uint8 *_pageBuffer2;
+ uint32 _rndSpecial;
// spells
bool notEnoughMagic(int charNum, int spellNum, int spellLevel);
diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp
index 0bb5d31dbe..615b40a4c2 100644
--- a/engines/kyra/scene_lol.cpp
+++ b/engines/kyra/scene_lol.cpp
@@ -473,7 +473,7 @@ void LoLEngine::resetItems(int flag) {
}
if (flag)
- memset(_throwItemState, 0, 136);
+ memset(_throwItemState, 0, 8 * sizeof(ThrownItem));
}
void LoLEngine::resetLvlBuffer() {
diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp
index 9a2f2b43f5..0609c7d00d 100644
--- a/engines/kyra/sprites_lol.cpp
+++ b/engines/kyra/sprites_lol.cpp
@@ -948,7 +948,7 @@ void LoLEngine::updateMonster(MonsterInPlay *monster) {
setMonsterMode(monster, 7);
if ((monster->mode != 11) && (monster->mode != 14)) {
- if (!(_rnd.getRandomNumberRng(1, 100) & 3)) {
+ if (!(getRandomNumberSpecial() & 3)) {
monster->shiftStep = (++monster->shiftStep) & 0x0f;
checkSceneUpdateNeed(monster->blockPropertyIndex);
}