diff options
-rw-r--r-- | engines/parallaction/disk.h | 28 | ||||
-rw-r--r-- | engines/parallaction/disk_br.cpp | 20 | ||||
-rw-r--r-- | engines/parallaction/disk_ns.cpp | 99 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 18 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/parallaction_br.cpp | 27 |
6 files changed, 94 insertions, 100 deletions
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index c54ad4eedc..d58d85e15c 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -59,8 +59,8 @@ public: virtual Font* loadFont(const char* name) = 0; virtual Graphics::Surface* loadStatic(const char* name) = 0; virtual Cnv* loadFrames(const char* name) = 0; - virtual BackgroundInfo* loadSlide(const char *filename) = 0; - virtual BackgroundInfo* loadScenery(const char* background, const char* mask, const char* path) = 0; + virtual void loadSlide(BackgroundInfo& info, const char *filename) = 0; + virtual void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) = 0; virtual Table* loadTable(const char* name) = 0; virtual Common::SeekableReadStream* loadMusic(const char* name) = 0; virtual Common::ReadStream* loadSound(const char* name) = 0; @@ -129,10 +129,10 @@ private: Cnv* loadExternalCnv(const char *filename); Cnv* loadCnv(const char *filename); Graphics::Surface *loadExternalStaticCnv(const char *filename); - BackgroundInfo* loadBackground(const char *filename); - void loadMaskAndPath(const char *name, BackgroundInfo *info); + void loadBackground(BackgroundInfo& info, const char *filename); + void loadMaskAndPath(BackgroundInfo& info, const char *name); void parseDepths(Common::SeekableReadStream &stream); - void parseBackground(Common::SeekableReadStream &stream, BackgroundInfo *info); + void parseBackground(BackgroundInfo& info, Common::SeekableReadStream &stream); Font *createFont(const char *name, Cnv* cnv); protected: @@ -151,8 +151,8 @@ public: Font* loadFont(const char* name); Graphics::Surface* loadStatic(const char* name); Cnv* loadFrames(const char* name); - BackgroundInfo* loadSlide(const char *filename); - BackgroundInfo* loadScenery(const char* background, const char* mask, const char* path); + void loadSlide(BackgroundInfo& info, const char *filename); + void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path); Table* loadTable(const char* name); Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); @@ -168,9 +168,9 @@ protected: void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height); Common::SeekableReadStream *openArchivedFile(const char* name, bool errorOnFileNotFound = false); Font *createFont(const char *name, Common::SeekableReadStream &stream); - void loadMask(const char *name, BackgroundInfo* info); - void loadPath(const char *name, BackgroundInfo* info); - BackgroundInfo* loadBackground(const char *name); + void loadMask(BackgroundInfo& info, const char *name); + void loadPath(BackgroundInfo& info, const char *name); + void loadBackground(BackgroundInfo& info, const char *name); public: AmigaDisk_ns(Parallaction *vm); @@ -185,8 +185,8 @@ public: Font* loadFont(const char* name); Graphics::Surface* loadStatic(const char* name); Cnv* loadFrames(const char* name); - BackgroundInfo* loadSlide(const char *filename); - BackgroundInfo* loadScenery(const char* background, const char* mask, const char* path); + void loadSlide(BackgroundInfo& info, const char *filename); + void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path); Table* loadTable(const char* name); Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); @@ -222,8 +222,8 @@ public: Font* loadFont(const char* name); Graphics::Surface* loadStatic(const char* name); Cnv* loadFrames(const char* name); - BackgroundInfo* loadSlide(const char *filename); - BackgroundInfo* loadScenery(const char* background, const char* mask, const char* path); + void loadSlide(BackgroundInfo& info, const char *filename); + void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path); Table* loadTable(const char* name); Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index cb33bdb485..65332a2a4a 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -175,7 +175,7 @@ Cnv* DosDisk_br::loadFrames(const char* name) { // doesn't need slides in that sense, but it still has some special // graphics resources with palette data, so those will be named slides. // -BackgroundInfo* DosDisk_br::loadSlide(const char *name) { +void DosDisk_br::loadSlide(BackgroundInfo& info, const char *name) { debugC(5, kDebugDisk, "DosDisk_br::loadSlide"); char path[PATH_LEN]; @@ -185,29 +185,27 @@ BackgroundInfo* DosDisk_br::loadSlide(const char *name) { if (!stream.open(path)) errorFileNotFound(path); - BackgroundInfo* info = new BackgroundInfo; - stream.skip(4); - info->width = stream.readUint32BE(); - info->height = stream.readUint32BE(); + info.width = stream.readUint32BE(); + info.height = stream.readUint32BE(); stream.skip(20); byte rgb[768]; stream.read(rgb, 768); for (uint i = 0; i < 256; i++) { - info->palette.setEntry(i, rgb[i] >> 2, rgb[i+256] >> 2, rgb[i+512] >> 2); + info.palette.setEntry(i, rgb[i] >> 2, rgb[i+256] >> 2, rgb[i+512] >> 2); } - info->bg.create(info->width, info->height, 1); - stream.read(info->bg.pixels, info->width * info->height); + info.bg.create(info.width, info.height, 1); + stream.read(info.bg.pixels, info.width * info.height); - return info; + return; } -BackgroundInfo* DosDisk_br::loadScenery(const char *name, const char *mask, const char* path) { +void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char *mask, const char* path) { debugC(5, kDebugDisk, "DosDisk_br::loadScenery"); - return 0; + return; } Table* DosDisk_br::loadTable(const char* name) { diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index e8301d2dd8..8e71e4a6b7 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -562,7 +562,7 @@ void DosDisk_ns::parseDepths(Common::SeekableReadStream &stream) { } -void DosDisk_ns::parseBackground(Common::SeekableReadStream &stream, BackgroundInfo *info) { +void DosDisk_ns::parseBackground(BackgroundInfo& info, Common::SeekableReadStream &stream) { byte tmp[3]; @@ -570,7 +570,7 @@ void DosDisk_ns::parseBackground(Common::SeekableReadStream &stream, BackgroundI tmp[0] = stream.readByte(); tmp[1] = stream.readByte(); tmp[2] = stream.readByte(); - info->palette.setEntry(i, tmp[0], tmp[1], tmp[2]); + info.palette.setEntry(i, tmp[0], tmp[1], tmp[2]); } parseDepths(stream); @@ -585,25 +585,24 @@ void DosDisk_ns::parseBackground(Common::SeekableReadStream &stream, BackgroundI } -BackgroundInfo* DosDisk_ns::loadBackground(const char *filename) { +void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) { if (!_resArchive.openArchivedFile(filename)) errorFileNotFound(filename); - BackgroundInfo *info = new BackgroundInfo; - info->width = _vm->_screenWidth; // 320 - info->height = _vm->_screenHeight; // 200 + info.width = _vm->_screenWidth; // 320 + info.height = _vm->_screenHeight; // 200 - parseBackground(_resArchive, info); + parseBackground(info, _resArchive); - info->bg.create(info->width, info->height, 1); - info->mask.create(info->width, info->height); - info->path.create(info->width, info->height); + info.bg.create(info.width, info.height, 1); + info.mask.create(info.width, info.height); + info.path.create(info.width, info.height); Graphics::PackBitsReadStream stream(_resArchive); - unpackBackground(&stream, (byte*)info->bg.pixels, info->mask.data, info->path.data); + unpackBackground(&stream, (byte*)info.bg.pixels, info.mask.data, info.path.data); - return info; + return; } // @@ -612,7 +611,7 @@ BackgroundInfo* DosDisk_ns::loadBackground(const char *filename) { // mask and path are normally combined (via OR) into the background picture itself // read the comment on the top of this file for more // -void DosDisk_ns::loadMaskAndPath(const char *name, BackgroundInfo *info) { +void DosDisk_ns::loadMaskAndPath(BackgroundInfo& info, const char *name) { char path[PATH_LEN]; sprintf(path, "%s.msk", name); @@ -621,32 +620,35 @@ void DosDisk_ns::loadMaskAndPath(const char *name, BackgroundInfo *info) { parseDepths(_resArchive); - info->path.create(info->width, info->height); - _resArchive.read(info->path.data, info->path.size); + info.path.create(info.width, info.height); + _resArchive.read(info.path.data, info.path.size); - info->mask.create(info->width, info->height); - _resArchive.read(info->mask.data, info->mask.size); + info.mask.create(info.width, info.height); + _resArchive.read(info.mask.data, info.mask.size); return; } -BackgroundInfo* DosDisk_ns::loadSlide(const char *filename) { +void DosDisk_ns::loadSlide(BackgroundInfo& info, const char *filename) { char path[PATH_LEN]; sprintf(path, "%s.slide", filename); - return loadBackground(path); + loadBackground(info, path); + + return; } -BackgroundInfo* DosDisk_ns::loadScenery(const char *name, const char *mask, const char* path) { +void DosDisk_ns::loadScenery(BackgroundInfo& info, const char *name, const char *mask, const char* path) { char filename[PATH_LEN]; sprintf(filename, "%s.dyn", name); - BackgroundInfo *info = loadBackground(filename); + + loadBackground(info, filename); if (mask != NULL) { // load external masks and paths only for certain locations - loadMaskAndPath(mask, info); + loadMaskAndPath(info, mask); } - return info; + return; } Table* DosDisk_ns::loadTable(const char* name) { @@ -1176,19 +1178,17 @@ public: }; -BackgroundInfo* AmigaDisk_ns::loadBackground(const char *name) { +void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) { Common::SeekableReadStream *s = openArchivedFile(name, true); byte *pal; - BackgroundInfo* info = new BackgroundInfo; - - BackgroundDecoder decoder(*s, info->bg, pal, _vm->_gfx->_palettefx); + BackgroundDecoder decoder(*s, info.bg, pal, _vm->_gfx->_palettefx); decoder.decode(); - info->width = info->bg.w; - info->height = info->bg.h; + info.width = info.bg.w; + info.height = info.bg.h; byte *p = pal; for (uint i = 0; i < 32; i++) { @@ -1198,18 +1198,18 @@ BackgroundInfo* AmigaDisk_ns::loadBackground(const char *name) { p++; byte b = *p >> 2; p++; - info->palette.setEntry(i, r, g, b); + info.palette.setEntry(i, r, g, b); } free(pal); delete s; - return info; + return; } -void AmigaDisk_ns::loadMask(const char *name, BackgroundInfo* info) { +void AmigaDisk_ns::loadMask(BackgroundInfo& info, const char *name) { debugC(5, kDebugDisk, "AmigaDisk_ns::loadMask(%s)", name); char path[PATH_LEN]; @@ -1238,16 +1238,16 @@ void AmigaDisk_ns::loadMask(const char *name, BackgroundInfo* info) { s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic Graphics::PackBitsReadStream stream(*s); - info->mask.create(info->width, info->height); - stream.read(info->mask.data, info->mask.size); - buildMask(info->mask.data); + info.mask.create(info.width, info.height); + stream.read(info.mask.data, info.mask.size); + buildMask(info.mask.data); delete s; return; } -void AmigaDisk_ns::loadPath(const char *name, BackgroundInfo* info) { +void AmigaDisk_ns::loadPath(BackgroundInfo& info, const char *name) { char path[PATH_LEN]; sprintf(path, "%s.path", name); @@ -1261,49 +1261,48 @@ void AmigaDisk_ns::loadPath(const char *name, BackgroundInfo* info) { Graphics::PackBitsReadStream stream(*s); - info->path.create(info->width, info->height); - stream.read(info->path.data, info->path.size); + info.path.create(info.width, info.height); + stream.read(info.path.data, info.path.size); delete s; return; } -BackgroundInfo* AmigaDisk_ns::loadScenery(const char* background, const char* mask, const char* path) { +void AmigaDisk_ns::loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) { debugC(1, kDebugDisk, "AmigaDisk_ns::loadScenery '%s', '%s'", background, mask); char filename[PATH_LEN]; sprintf(filename, "%s.bkgnd", background); - BackgroundInfo* info = loadBackground(filename); + loadBackground(info, filename); if (mask == NULL) { - loadMask(background, info); - loadPath(background, info); + loadMask(info, background); + loadPath(info, background); } else { - loadMask(mask, info); - loadPath(mask, info); + loadMask(info, mask); + loadPath(info, mask); } - return info; + return; } -BackgroundInfo* AmigaDisk_ns::loadSlide(const char *name) { +void AmigaDisk_ns::loadSlide(BackgroundInfo& info, const char *name) { debugC(1, kDebugDisk, "AmigaDisk_ns::loadSlide '%s'", name); char path[PATH_LEN]; sprintf(path, "slides/%s", name); Common::SeekableReadStream *s = openArchivedFile(path, false); - BackgroundInfo *info; if (s) - info = loadBackground(path); + loadBackground(info, path); else - info = loadBackground(name); + loadBackground(info, name); delete s; - return info; + return; } Cnv* AmigaDisk_ns::loadFrames(const char* name) { diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index a1545b9eb7..6798e72afa 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -240,9 +240,7 @@ void Parallaction::freeBackground() { _backgroundInfo->bg.free(); _backgroundInfo->mask.free(); _backgroundInfo->path.free(); - delete _backgroundInfo; - _backgroundInfo = 0; _pathBuffer = 0; } @@ -251,7 +249,7 @@ void Parallaction::setBackground(const char *background, const char *mask, const freeBackground(); - _backgroundInfo = _disk->loadScenery(background, mask, path); + _disk->loadScenery(*_backgroundInfo, background, mask, path); _gfx->setPalette(_backgroundInfo->palette); _gfx->_palette.clone(_backgroundInfo->palette); @@ -316,21 +314,21 @@ extern Job *_jEraseLabel; void Parallaction::showSlide(const char *name) { - BackgroundInfo *info; + BackgroundInfo info; - info = _disk->loadSlide(name); + _disk->loadSlide(info, name); // TODO: avoid using screen buffers for displaying slides. Using a generic buffer // allows for positioning of graphics as needed by Big Red Adventure. // The main problem lies with menu, which relies on multiple buffers, mainly because // it is crappy code. - _gfx->setBackground(&info->bg); - _gfx->setPalette(info->palette); + _gfx->setBackground(&info.bg); + _gfx->setPalette(info.palette); _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - info->bg.free(); - info->mask.free(); - info->path.free(); + info.bg.free(); + info.mask.free(); + info.path.free(); return; } diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index cf6fde1d39..c09ffba97d 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -123,6 +123,7 @@ Parallaction::~Parallaction() { delete _debugger; freeBackground(); + delete _backgroundInfo; delete _globalTable; @@ -169,6 +170,7 @@ int Parallaction::init() { _screenSize = _screenWidth * _screenHeight; + _backgroundInfo = new BackgroundInfo; strcpy(_characterName1, "null"); strcpy(_characterName, "dough"); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 45dfbc134f..f6dd1aee45 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -151,26 +151,24 @@ int Parallaction_br::go() { void Parallaction_br::splash(const char *name) { - BackgroundInfo *info; + BackgroundInfo info; _gfx->clearScreen(Gfx::kBitFront); - info = _disk->loadSlide(name); - _gfx->setPalette(info->palette); - _gfx->flatBlitCnv(&info->bg, (640 - info->width) >> 1, (400 - info->height) >> 1, Gfx::kBitFront); + _disk->loadSlide(info, name); + _gfx->setPalette(info.palette); + _gfx->flatBlitCnv(&info.bg, (640 - info.width) >> 1, (400 - info.height) >> 1, Gfx::kBitFront); _gfx->updateScreen(); _system->delayMillis(600); Palette pal; for (uint i = 0; i < 64; i++) { - info->palette.fadeTo(pal, 1); - _gfx->setPalette(info->palette); + info.palette.fadeTo(pal, 1); + _gfx->setPalette(info.palette); _gfx->updateScreen(); _system->delayMillis(20); } - info->bg.free(); - - delete info; + info.bg.free(); return; } @@ -197,7 +195,7 @@ int Parallaction_br::showMenu() { _gfx->clearScreen(Gfx::kBitFront); - BackgroundInfo *info; + BackgroundInfo info; Graphics::Surface _menuItems[7]; @@ -221,9 +219,9 @@ int Parallaction_br::showMenu() { kMenuPart4 }; - info = _disk->loadSlide("tbra"); - _gfx->setPalette(info->palette); - _gfx->flatBlitCnv(&info->bg, 20, 50, Gfx::kBitFront); + _disk->loadSlide(info, "tbra"); + _gfx->setPalette(info.palette); + _gfx->flatBlitCnv(&info.bg, 20, 50, Gfx::kBitFront); int availItems = 4 + _progress; @@ -274,8 +272,7 @@ int Parallaction_br::showMenu() { _system->showMouse(false); - info->bg.free(); - delete info; + info.bg.free(); for (int i = 0; i < availItems; i++) _menuItems[i].free(); |