aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-18 23:19:54 +0100
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commitee8c63183d82aa4deebf87ca6c7a63671684d25f (patch)
treee6562358600f477b8efa3a9b9dd731a0a3c0435e
parent8d1901c39bbfd22ff3540e2db68897f2aae652d9 (diff)
downloadscummvm-rg350-ee8c63183d82aa4deebf87ca6c7a63671684d25f.tar.gz
scummvm-rg350-ee8c63183d82aa4deebf87ca6c7a63671684d25f.tar.bz2
scummvm-rg350-ee8c63183d82aa4deebf87ca6c7a63671684d25f.zip
ADL: Implement hires2 random cond opcode
-rw-r--r--engines/adl/adl_v2.cpp20
-rw-r--r--engines/adl/adl_v2.h10
2 files changed, 27 insertions, 3 deletions
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index 7560504c3c..3a938b3ae5 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -20,12 +20,19 @@
*
*/
+#include "common/random.h"
+
#include "adl/adl_v2.h"
namespace Adl {
+AdlEngine_v2::~AdlEngine_v2() {
+ delete _random;
+}
+
AdlEngine_v2::AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd) :
AdlEngine(syst, gd) {
+ _random = new Common::RandomSource("adl");
}
typedef Common::Functor1Mem<ScriptEnv &, int, AdlEngine_v2> OpcodeV2;
@@ -39,8 +46,8 @@ void AdlEngine_v2::setupOpcodeTables() {
SetOpcodeTable(_condOpcodes);
// 0x00
OpcodeUnImpl();
- OpcodeUnImpl();
- OpcodeUnImpl();
+ Opcode(o2_isFirstTime);
+ Opcode(o2_isRandomGT);
Opcode(o2_isItemInRoom);
// 0x04
Opcode(o2_isNounNotInRoom);
@@ -104,6 +111,15 @@ int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) {
return 0;
}
+int AdlEngine_v2::o2_isRandomGT(ScriptEnv &e) {
+ byte rnd = _random->getRandomNumber(255);
+
+ if (e.arg(1) >= rnd)
+ return -1;
+
+ return 1;
+}
+
int AdlEngine_v2::o2_isItemInRoom(ScriptEnv &e) {
byte room = e.arg(2);
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index 61c811b02f..5513da38a8 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -28,11 +28,15 @@
#define IDI_CUR_ROOM 0xfc
#define IDI_VOID_ROOM 0xfd
+namespace Common{
+class RandomSource;
+}
+
namespace Adl {
class AdlEngine_v2 : public AdlEngine {
public:
- virtual ~AdlEngine_v2() { }
+ virtual ~AdlEngine_v2();
protected:
AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd);
@@ -40,10 +44,14 @@ protected:
virtual void setupOpcodeTables();
int o2_isFirstTime(ScriptEnv &e);
+ int o2_isRandomGT(ScriptEnv &e);
int o2_isItemInRoom(ScriptEnv &e);
int o2_isNounNotInRoom(ScriptEnv &e);
int o2_moveItem(ScriptEnv &e);
+
+private:
+ Common::RandomSource *_random;
};
} // End of namespace Adl