From ed09766accb9cf677bf88802d7d268b06698a6bd Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 2 Feb 2008 13:57:29 +0000 Subject: BRA now loads and displays location backgrounds (at least in the intro). svn-id: r30740 --- engines/parallaction/disk_br.cpp | 3 +++ engines/parallaction/exec_ns.cpp | 23 +++++++++++++--------- engines/parallaction/parallaction.h | 3 +++ engines/parallaction/parser_br.cpp | 39 +++++++++++++++++-------------------- 4 files changed, 38 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index aca01e0880..0a5fe90525 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -318,6 +318,7 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char info.bg.create(info.width, info.height, 1); stream.read(info.bg.pixels, info.width * info.height); + stream.close(); } if (mask) { @@ -329,6 +330,7 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char // have already been loaded info.mask.create(info.width, info.height); stream.read(info.mask.data, info.width * info.height); + stream.close(); } if (path) { @@ -340,6 +342,7 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char // have already been loaded info.path.create(info.width, info.height); stream.read(info.path.data, info.width * info.height); + stream.close(); } return; diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 9a15bbfdf5..0c04f566fc 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -335,13 +335,14 @@ void Parallaction_ns::drawAnimations() { else layer = _gfx->_backgroundInfo.getLayer(v18->_top + v18->height()); - - _gfx->showGfxObj(obj, true); - obj->frame = frame; - obj->x = v18->_left; - obj->y = v18->_top; - obj->z = v18->_z; - obj->layer = layer; + if (obj) { + _gfx->showGfxObj(obj, true); + obj->frame = frame; + obj->x = v18->_left; + obj->y = v18->_top; + obj->z = v18->_z; + obj->layer = layer; + } } if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove)) { @@ -352,7 +353,9 @@ void Parallaction_ns::drawAnimations() { if ((v18->_flags & kFlagsActive) && (v18->_flags & kFlagsRemove)) { v18->_flags &= ~kFlagsActive; v18->_flags |= kFlagsRemove; - _gfx->showGfxObj(obj, false); + if (obj) { + _gfx->showGfxObj(obj, false); + } } } @@ -407,7 +410,9 @@ label1: } _char._ani._z = _char._ani.height() + _char._ani._top; - _char._ani.gfxobj->z = _char._ani._z; + if (_char._ani.gfxobj) { + _char._ani.gfxobj->z = _char._ani._z; + } modCounter++; return; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 447eaffb35..6f0d085185 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -680,6 +680,9 @@ protected: // BRA specific int numZones; + char *bgName; + char *maskName; + char *pathName; } _locParseCtxt; void warning_unexpected(); diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 023edc1460..c0d218b010 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -115,6 +115,7 @@ DECLARE_LOCATION_PARSER(location) { debugC(7, kDebugParser, "LOCATION_PARSER(location) "); strcpy(_location._name, _tokens[1]); + _locParseCtxt.bgName = strdup(_tokens[1]); bool flip = false; int nextToken; @@ -125,17 +126,8 @@ DECLARE_LOCATION_PARSER(location) { } else { nextToken = 2; } -#if 0 - _disk->loadScenery(*_backgroundInfo, _location._name, NULL, NULL); -// if (flip) { -// flip(); -// } - - _gfx->setBackground(&_backgroundInfo.bg); - _gfx->_palette.clone(_backgroundInfo.palette); - _gfx->setPalette(_backgroundInfo.palette); -#endif + // TODO: handle background horizontal flip (via a context parameter) if (_tokens[nextToken][0] != '\0') { _char._ani._left = atoi(_tokens[nextToken]); @@ -271,23 +263,18 @@ DECLARE_LOCATION_PARSER(null) { DECLARE_LOCATION_PARSER(mask) { debugC(7, kDebugParser, "LOCATION_PARSER(mask) "); -#if 0 - _disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL); - _gfx->setMask(&_backgroundInfo.mask); - _gfx->_bgLayers[0] = atoi(_tokens[2]); - _gfx->_bgLayers[1] = atoi(_tokens[3]); - _gfx->_bgLayers[2] = atoi(_tokens[4]); -#endif + _locParseCtxt.maskName = strdup(_tokens[1]); + _gfx->_backgroundInfo.layers[0] = atoi(_tokens[2]); + _gfx->_backgroundInfo.layers[1] = atoi(_tokens[3]); + _gfx->_backgroundInfo.layers[2] = atoi(_tokens[4]); } DECLARE_LOCATION_PARSER(path) { debugC(7, kDebugParser, "LOCATION_PARSER(path) "); -#if 0 - _disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]); - _pathBuffer = &_backgroundInfo.path; -#endif + + _locParseCtxt.pathName = strdup(_tokens[1]); } @@ -947,9 +934,19 @@ void Parallaction_br::initParsers() { void Parallaction_br::parseLocation(const char* filename) { _locParseCtxt.numZones = 0; + _locParseCtxt.bgName = 0; + _locParseCtxt.maskName = 0; + _locParseCtxt.pathName = 0; Super::parseLocation(filename); + _gfx->setBackground(kBackgroundLocation, _locParseCtxt.bgName, _locParseCtxt.maskName, _locParseCtxt.pathName); + _pathBuffer = &_gfx->_backgroundInfo.path; + + free(_locParseCtxt.bgName); + free(_locParseCtxt.maskName); + free(_locParseCtxt.pathName); + // drawZones(); return; -- cgit v1.2.3