aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorFilippos Karapetis2015-06-07 00:04:06 +0300
committerFilippos Karapetis2015-06-07 00:04:30 +0300
commitb2492419206fba27c008acb79abe140aebf544ac (patch)
tree5afd439829ab223c713482eddd1ab4591cdd9bb7 /engines/sherlock
parent97813f89ecd2a06c74f776708a3d1852c96811a7 (diff)
downloadscummvm-rg350-b2492419206fba27c008acb79abe140aebf544ac.tar.gz
scummvm-rg350-b2492419206fba27c008acb79abe140aebf544ac.tar.bz2
scummvm-rg350-b2492419206fba27c008acb79abe140aebf544ac.zip
SHERLOCK: Implement cmdSetNPCPosition opcode
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/objects.h12
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.cpp51
2 files changed, 56 insertions, 7 deletions
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 88e9db116e..c35b777be1 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -167,12 +167,6 @@ private:
static SherlockEngine *_vm;
/**
- * Checks a sprite associated with an NPC to see if the frame sequence specified
- * in the sequence number uses alternate graphics, and if so if they need to be loaded
- */
- void checkWalkGraphics();
-
- /**
* Free the alternate graphics used by NPCs
*/
void freeAltGraphics();
@@ -277,6 +271,12 @@ public:
* Returns the old bounsd for the sprite from the previous frame
*/
const Common::Rect getOldBounds() const;
+
+ /**
+ * Checks a sprite associated with an NPC to see if the frame sequence specified
+ * in the sequence number uses alternate graphics, and if so if they need to be loaded
+ */
+ void checkWalkGraphics();
};
enum { OBJ_BEHIND = 1, OBJ_FLIPPED = 2, OBJ_FORWARD = 4, TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 };
diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp
index 0ac02d5865..bd587e3896 100644
--- a/engines/sherlock/tattoo/tattoo_talk.cpp
+++ b/engines/sherlock/tattoo/tattoo_talk.cpp
@@ -28,6 +28,12 @@ namespace Sherlock {
namespace Tattoo {
+static const uint8 DIRECTION_CONVERSION[] = {
+ WALK_RIGHT, WALK_DOWN, WALK_LEFT, WALK_UP,
+ STOP_RIGHT, STOP_DOWN, STOP_LEFT, STOP_UP,
+ WALK_UPRIGHT, WALK_DOWNRIGHT, WALK_UPLEFT, WALK_DOWNLEFT,
+ STOP_UPRIGHT, STOP_UPLEFT, STOP_DOWNRIGHT, STOP_DOWNLEFT
+};
const byte TATTOO_OPCODES[] = {
170, // OP_SWITCH_SPEAKER
@@ -232,7 +238,50 @@ OpcodeReturn TattooTalk::cmdSetNPCPathDest(const byte *&str) { error("TODO: scri
OpcodeReturn TattooTalk::cmdSetNPCPathPause(const byte *&str) { error("TODO: script opcode"); }
OpcodeReturn TattooTalk::cmdSetNPCPathPauseTakingNotes(const byte *&str) { error("TODO: script opcode"); }
OpcodeReturn TattooTalk::cmdSetNPCPathPauseLookingHolmes(const byte *&str) { error("TODO: script opcode"); }
-OpcodeReturn TattooTalk::cmdSetNPCPosition(const byte *&str) { error("TODO: script opcode"); }
+
+OpcodeReturn TattooTalk::cmdSetNPCPosition(const byte *&str) {
+ ++str;
+ int npc = *str - 1;
+ ++str;
+ People &people = *_vm->_people;
+ Person &person = people[npc];
+ int32 posX = (str[0] - 1) * 256 + str[1] - 1;
+ if (posX > 16384)
+ posX = -1 * (posX - 16384);
+ int32 posY = (str[2] - 1) * 256 + str[3] - 1;
+
+ people[npc]._position = Point32(posX * 1000, posY * 1000);
+ if (person._seqTo && person._walkLoaded) {
+ person._walkSequences[person._sequenceNumber]._sequences[person._frameNumber] = person._seqTo;
+ person._seqTo = 0;
+ }
+
+ assert(str[4] - 1 < 16);
+ person._sequenceNumber = DIRECTION_CONVERSION[str[4] - 1];
+ person._frameNumber = 0;
+
+ if (person._walkLoaded)
+ person.checkWalkGraphics();
+
+ if (person._walkLoaded && person._type == CHARACTER &&
+ person._sequenceNumber >= STOP_UP && person._sequenceNumber <= STOP_UPLEFT) {
+ bool done = false;
+ do {
+ person.checkSprite();
+ for (int x = 0; x < person._frameNumber; x++) {
+ if (person._walkSequences[person._sequenceNumber]._sequences[x] == 0) {
+ done = true;
+ break;
+ }
+ }
+ } while(!done);
+ }
+
+ str += 4;
+
+ return RET_SUCCESS;
+}
+
OpcodeReturn TattooTalk::cmdSetNPCTalkFile(const byte *&str) { error("TODO: script opcode"); }
OpcodeReturn TattooTalk::cmdSetNPCVerb(const byte *&str) { error("TODO: script opcode"); }
OpcodeReturn TattooTalk::cmdSetNPCVerbCAnimation(const byte *&str) { error("TODO: script opcode"); }