From 73832f2edd82ca25bf25c15b43b1678e4ac4c32d Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Wed, 4 Jun 2008 09:07:55 +0000 Subject: * Implemented character change opcodes in BRA * Fixed loading of dialogue characters in BRA svn-id: r32529 --- engines/parallaction/disk.h | 2 +- engines/parallaction/disk_br.cpp | 27 +++++++++++++++++---------- engines/parallaction/exec_br.cpp | 3 ++- engines/parallaction/parallaction.h | 2 +- engines/parallaction/parallaction_br.cpp | 8 +++++++- engines/parallaction/parser.h | 1 + engines/parallaction/parser_br.cpp | 8 +++++++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index 21ff4aba76..b76c66aead 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -209,7 +209,7 @@ protected: protected: void errorFileNotFound(const char *s); Font *createFont(const char *name, Common::ReadStream &stream); - Sprites* createSprites(const char *name); + Sprites* createSprites(Common::ReadStream &stream); void loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette); public: diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index e4c4ce7492..5e88327879 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -139,12 +139,19 @@ DosDisk_br::~DosDisk_br() { } Frames* DosDisk_br::loadTalk(const char *name) { - debugC(5, kDebugDisk, "DosDisk_br::loadTalk"); + debugC(5, kDebugDisk, "DosDisk_br::loadTalk(%s)", name); + + Common::File stream; char path[PATH_LEN]; - sprintf(path, "%s/tal/%s.tal", _partPath, name); + sprintf(path, "%s/tal/%s", _partPath, name); + if (!stream.open(path)) { + sprintf(path, "%s/tal/%s.tal", _partPath, name); + if (!stream.open(path)) + errorFileNotFound(path); + } - return createSprites(path); + return createSprites(stream); } Script* DosDisk_br::loadLocation(const char *name) { @@ -252,12 +259,7 @@ Frames* DosDisk_br::loadStatic(const char* name) { return new SurfaceToFrames(surf); } -Sprites* DosDisk_br::createSprites(const char *path) { - - Common::File stream; - if (!stream.open(path)) { - errorFileNotFound(path); - } +Sprites* DosDisk_br::createSprites(Common::ReadStream &stream) { uint16 num = stream.readUint16LE(); @@ -284,7 +286,12 @@ Frames* DosDisk_br::loadFrames(const char* name) { char path[PATH_LEN]; sprintf(path, "%s/ani/%s", _partPath, name); - return createSprites(path); + Common::File stream; + if (!stream.open(path)) + errorFileNotFound(path); + + + return createSprites(stream); } // Slides in Nippon Safes are basically screen-sized pictures with valid diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 2aeec6358d..3b67b4c370 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -176,7 +176,8 @@ DECLARE_COMMAND_OPCODE(stop) { DECLARE_COMMAND_OPCODE(character) { - warning("Parallaction_br::cmdOp_character not yet implemented"); + debugC(9, kDebugExec, "Parallaction_br::cmdOp_character(%s)", _cmdRunCtxt.cmd->u._string); + changeCharacter(_cmdRunCtxt.cmd->u._string); } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 63042a8882..6e5957d3cd 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -654,6 +654,7 @@ public: public: typedef void (Parallaction_br::*Callable)(void*); virtual void callFunction(uint index, void* parm); + void changeCharacter(const char *name); public: Table *_countersNames; @@ -688,7 +689,6 @@ private: void setInventoryCursor(int pos); void changeLocation(char *location); - void changeCharacter(const char *name); void runPendingZones(); void initPart(); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 62cc702222..057664e03d 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -202,7 +202,7 @@ void Parallaction_br::runPendingZones() { if (_activeZone) { z = _activeZone; // speak Zone or sound _activeZone = nullZonePtr; -// runZone(z); // FIXME: BRA doesn't handle sound yet + runZone(z); // FIXME: BRA doesn't handle sound yet } if (_activeZone2) { @@ -281,7 +281,13 @@ void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) { void Parallaction_br::changeCharacter(const char *name) { + const char *charName = _char.getName(); + if (!stricmp(charName, name)) { + return; + } + _char.setName(name); + _char._talk = _disk->loadTalk(name); } diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index 22d3119d87..d488cf9b58 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -131,6 +131,7 @@ protected: char *bgName; char *maskName; char *pathName; + char *characterName; } ctxt; void warning_unexpected(); diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index cebda4b5ed..51da7eb396 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -442,7 +442,7 @@ DECLARE_LOCATION_PARSER(redundant) { DECLARE_LOCATION_PARSER(character) { debugC(7, kDebugParser, "LOCATION_PARSER(character) "); -// changeCharacter(character); + ctxt.characterName = strdup(_tokens[0]); } @@ -1113,15 +1113,21 @@ void LocationParser_br::parse(Script *script) { ctxt.bgName = 0; ctxt.maskName = 0; ctxt.pathName = 0; + ctxt.characterName = 0; LocationParser_ns::parse(script); _vm->_gfx->setBackground(kBackgroundLocation, ctxt.bgName, ctxt.maskName, ctxt.pathName); _vm->_pathBuffer = &_vm->_gfx->_backgroundInfo.path; + if (ctxt.characterName) { + _vm->changeCharacter(ctxt.characterName); + } + free(ctxt.bgName); free(ctxt.maskName); free(ctxt.pathName); + free(ctxt.characterName); } -- cgit v1.2.3