diff options
author | Walter van Niftrik | 2016-04-10 14:27:51 +0200 |
---|---|---|
committer | Walter van Niftrik | 2016-06-06 20:35:49 +0200 |
commit | 6044022c8ed3349242d86206adb57cb9f4f3031e (patch) | |
tree | 88d0a9acaba5a3eeda15192c915e380a54636655 | |
parent | ca47d3bb2273f5fde754bb51ef500e0eca3a25ed (diff) | |
download | scummvm-rg350-6044022c8ed3349242d86206adb57cb9f4f3031e.tar.gz scummvm-rg350-6044022c8ed3349242d86206adb57cb9f4f3031e.tar.bz2 scummvm-rg350-6044022c8ed3349242d86206adb57cb9f4f3031e.zip |
ADL: Add '%' string code processing for hires6
-rw-r--r-- | engines/adl/adl_v2.h | 4 | ||||
-rw-r--r-- | engines/adl/hires6.cpp | 33 | ||||
-rw-r--r-- | engines/adl/hires6.h | 1 |
3 files changed, 36 insertions, 2 deletions
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index 947b0d8faf..60af4de484 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -45,8 +45,8 @@ protected: virtual void setupOpcodeTables(); byte roomArg(byte room) const; void advanceClock(); - void printString(const Common::String &str); - Common::String loadMessage(uint idx) const; + virtual void printString(const Common::String &str); + virtual Common::String loadMessage(uint idx) const; void drawItems(); void drawItem(Item &item, const Common::Point &pos); void loadRoom(byte roomNr); diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index e15cf43e5b..7ac953c19a 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -246,6 +246,39 @@ void HiRes6Engine::applyDataBlockOffset(byte &track, byte §or) const { ++track; } +void HiRes6Engine::printString(const Common::String &str) { + Common::String s; + uint found = 0; + + // This does not emulate the corner cases of the original, hence this check + if (getVar(27) > 1) + error("Invalid value %i encountered for variable 27", getVar(27)); + + for (uint i = 0; i < str.size(); ++i) { + if (str[i] == '%') { + ++found; + if (found == 3) + found = 0; + continue; + } + + switch (found) { + case 0: + s += str[i]; + break; + case 1: + if (getVar(27) == 0) + s += str[i]; + break; + case 2: + if (getVar(27) == 1) + s += str[i]; + } + } + + AdlEngine_v2::printString(s); +} + Engine *HiRes6Engine_create(OSystem *syst, const AdlGameDescription *gd) { return new HiRes6Engine(syst, gd); } diff --git a/engines/adl/hires6.h b/engines/adl/hires6.h index 395e85232f..a8450705c4 100644 --- a/engines/adl/hires6.h +++ b/engines/adl/hires6.h @@ -59,6 +59,7 @@ private: void initState(); // AdlEngine_v2 + void printString(const Common::String &str); void applyDataBlockOffset(byte &track, byte §or) const; }; |