From ee8c63183d82aa4deebf87ca6c7a63671684d25f Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Fri, 18 Mar 2016 23:19:54 +0100 Subject: ADL: Implement hires2 random cond opcode --- engines/adl/adl_v2.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'engines/adl/adl_v2.cpp') 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 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); -- cgit v1.2.3