From 92ba3d1a29fbbb4506cbaffd023e76a560f0e43d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 12 Jun 2015 00:34:43 +0300 Subject: SHERLOCK: Implement the rest of the NPC path opcodes for Rose Tattoo This includes cmdNPCLabelGoto, cmdNPCLabelIfFlagGoto, cmdNPCLabelSet, cmdSetNPCPathDest, cmdSetNPCPathPause, cmdSetNPCPathPauseTakingNotes, cmdSetNPCPathPauseLookingHolmes and cmdSetNPCTalkFile --- engines/sherlock/people.cpp | 3 +- engines/sherlock/people.h | 2 + engines/sherlock/tattoo/tattoo_talk.cpp | 163 ++++++++++++++++++++++++++++++-- 3 files changed, 159 insertions(+), 9 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp index 18621badb2..e4892b787a 100644 --- a/engines/sherlock/people.cpp +++ b/engines/sherlock/people.cpp @@ -72,9 +72,10 @@ const char *const WALK_LIB_NAMES[NUM_IN_WALK_LIB] = { Person::Person() : Sprite(), _walkLoaded(false), _npcIndex(0), _npcStack(0), _npcPause(false) { Common::fill(&_npcPath[0], &_npcPath[MAX_NPC_PATH], 0); _tempX = _tempScaleVal = 0; - _updateNPCPath = false; _npcIndex = 0; _npcStack = 0; + _npcMoved = false; + _resetNPCPath = true; _savedNpcSequence = 0; _savedNpcFrame = 0; _updateNPCPath = false; diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h index c15248cc02..cd790ead5c 100644 --- a/engines/sherlock/people.h +++ b/engines/sherlock/people.h @@ -69,6 +69,8 @@ public: bool _npcPause; byte _npcPath[MAX_NPC_PATH]; Common::String _npcName; + bool _npcMoved; + bool _resetNPCPath; int _savedNpcSequence; int _savedNpcFrame; int _tempX; diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp index 148a10ae0a..4516dcd488 100644 --- a/engines/sherlock/tattoo/tattoo_talk.cpp +++ b/engines/sherlock/tattoo/tattoo_talk.cpp @@ -287,9 +287,62 @@ OpcodeReturn TattooTalk::cmdNextSong(const byte *&str) { return RET_SUCCESS; } -OpcodeReturn TattooTalk::cmdNPCLabelGoto(const byte *&str) { error("TODO: script opcode"); } -OpcodeReturn TattooTalk::cmdNPCLabelIfFlagGoto(const byte *&str) { error("TODO: script opcode"); } -OpcodeReturn TattooTalk::cmdNPCLabelSet(const byte *&str) { error("TODO: script opcode"); } +OpcodeReturn TattooTalk::cmdNPCLabelGoto(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 8; + person._npcPath[person._npcIndex + 1] = str[1]; + person._npcIndex += 2; + str++; + + return RET_SUCCESS; +} + +OpcodeReturn TattooTalk::cmdNPCLabelIfFlagGoto(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 9; + for (int i = 1; i <= 3; i++) + person._npcPath[person._npcIndex + i] = str[i]; + + person._npcIndex += 4; + str += 3; + + return RET_SUCCESS; +} + +OpcodeReturn TattooTalk::cmdNPCLabelSet(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 7; + person._npcPath[person._npcIndex + 1] = str[1]; + person._npcIndex += 2; + str++; + + return RET_SUCCESS; +} + OpcodeReturn TattooTalk::cmdPassword(const byte *&str) { error("TODO: script opcode"); } OpcodeReturn TattooTalk::cmdPlaySong(const byte *&str) { error("TODO: script opcode"); } OpcodeReturn TattooTalk::cmdRestorePeopleSequence(const byte *&str) { error("TODO: script opcode"); } @@ -345,10 +398,86 @@ OpcodeReturn TattooTalk::cmdSetNPCOn(const byte *&str) { return RET_SUCCESS; } -OpcodeReturn TattooTalk::cmdSetNPCPathDest(const byte *&str) { error("TODO: script opcode"); } -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::cmdSetNPCPathDest(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 1; + for (int i = 1; i <= 4; i++) + person._npcPath[person._npcIndex + i] = str[i]; + person._npcPath[person._npcIndex + 5] = DIRECTION_CONVERSION[str[5] - 1] + 1; + + person._npcIndex += 6; + str += 5; + + return RET_SUCCESS; +} + +OpcodeReturn TattooTalk::cmdSetNPCPathPause(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 2; + for (int i = 1; i <= 2; i++) + person._npcPath[person._npcIndex + i] = str[i]; + + person._npcIndex += 3; + str += 2; + + return RET_SUCCESS; +} + +OpcodeReturn TattooTalk::cmdSetNPCPathPauseTakingNotes(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 5; + for (int i = 1; i <= 2; i++) + person._npcPath[person._npcIndex + i] = str[i]; + + person._npcIndex += 3; + str += 2; + + return RET_SUCCESS; +} + +OpcodeReturn TattooTalk::cmdSetNPCPathPauseLookingHolmes(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 6; + for (int i = 1; i <= 2; i++) + person._npcPath[person._npcIndex + i] = str[i]; + + person._npcIndex += 3; + str += 2; + + return RET_SUCCESS; +} OpcodeReturn TattooTalk::cmdSetNPCPosition(const byte *&str) { int npcNum = *++str - 1; @@ -392,7 +521,25 @@ OpcodeReturn TattooTalk::cmdSetNPCPosition(const byte *&str) { return RET_SUCCESS; } -OpcodeReturn TattooTalk::cmdSetNPCTalkFile(const byte *&str) { error("TODO: script opcode"); } +OpcodeReturn TattooTalk::cmdSetNPCTalkFile(const byte *&str) { + int npcNum = *++str; + People &people = *_vm->_people; + Person &person = people[npcNum]; + + if (person._resetNPCPath) { + person._npcIndex = person._resetNPCPath = person._npcPause = 0; + memset(person._npcPath, 0, 100); + } + + person._npcPath[person._npcIndex] = 3; + for (int i = 1; i <= 8; i++) + person._npcPath[person._npcIndex + i] = str[i]; + + person._npcIndex += 9; + str += 8; + + return RET_SUCCESS; +} OpcodeReturn TattooTalk::cmdSetNPCVerb(const byte *&str) { int npcNum = *++str; -- cgit v1.2.3