[Scummvm-cvs-logs] SF.net SVN: scummvm:[39425] scummvm/trunk/engines/kyra

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Sun Mar 15 19:21:56 CET 2009


Revision: 39425
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39425&view=rev
Author:   athrxx
Date:     2009-03-15 18:21:33 +0000 (Sun, 15 Mar 2009)

Log Message:
-----------
LOL: - implemented original style random number generator for moving around the monsters

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_lol.cpp
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/scene_lol.cpp
    scummvm/trunk/engines/kyra/sprites_lol.cpp

Modified: scummvm/trunk/engines/kyra/gui_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_lol.cpp	2009-03-15 18:07:24 UTC (rev 39424)
+++ scummvm/trunk/engines/kyra/gui_lol.cpp	2009-03-15 18:21:33 UTC (rev 39425)
@@ -1394,7 +1394,7 @@
 }
 
 int LoLEngine::clickedSceneThrowItem(Button *button) {
-	//if (_updateFlags & 1)
+	if (_updateFlags & 1)
 		return 0;
 
 	uint16 block = calcNewBlockPosition(_currentBlock, _currentDirection);

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-03-15 18:07:24 UTC (rev 39424)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-03-15 18:21:33 UTC (rev 39425)
@@ -199,6 +199,8 @@
 	
 	_unkBt1 = _unkBt2 = 0;
 	_dialogueField = false;
+
+	_rndSpecial = 0x12349876;
 	
 	_buttonData = 0;
 	_activeButtons = 0;
@@ -413,8 +415,8 @@
 	_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 @@
 	}
 }
 
+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);
 }

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-03-15 18:07:24 UTC (rev 39424)
+++ scummvm/trunk/engines/kyra/lol.h	2009-03-15 18:21:33 UTC (rev 39425)
@@ -207,6 +207,22 @@
 	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 @@
 	uint8 _unkGameFlag;
 
 	uint8 *_tempBuffer5120;
-	uint8 *_throwItemState;
-
+	
 	const char *const * _levelDatList;
 	int _levelDatListSize;
 	const char *const * _levelShpList;
@@ -965,6 +980,8 @@
 	int _hideControls;
 	int _lastCharInventory;
 
+	ThrownItem *_throwItemState;
+
 	EMCData _itemScript;
 
 	const uint8 *_charInvIndex;
@@ -1045,6 +1062,7 @@
 
 	// misc
 	void delay(uint32 millis, bool cUpdate = false, bool isMainLoop = false);
+	uint8 getRandomNumberSpecial();
 
 	uint8 _unkBt1;
 	uint8 _unkBt2;
@@ -1052,6 +1070,7 @@
 
 	uint8 *_pageBuffer1;
 	uint8 *_pageBuffer2;
+	uint32 _rndSpecial;
 
 	// spells
 	bool notEnoughMagic(int charNum, int spellNum, int spellLevel);

Modified: scummvm/trunk/engines/kyra/scene_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_lol.cpp	2009-03-15 18:07:24 UTC (rev 39424)
+++ scummvm/trunk/engines/kyra/scene_lol.cpp	2009-03-15 18:21:33 UTC (rev 39425)
@@ -473,7 +473,7 @@
 	}
 
 	if (flag)
-		memset(_throwItemState, 0, 136);
+		memset(_throwItemState, 0, 8 * sizeof(ThrownItem));
 }
 
 void LoLEngine::resetLvlBuffer() {

Modified: scummvm/trunk/engines/kyra/sprites_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-03-15 18:07:24 UTC (rev 39424)
+++ scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-03-15 18:21:33 UTC (rev 39425)
@@ -948,7 +948,7 @@
 		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);
 		}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list