[Scummvm-cvs-logs] SF.net SVN: scummvm: [26578] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Apr 23 19:07:48 CEST 2007


Revision: 26578
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26578&view=rev
Author:   peres001
Date:     2007-04-23 10:07:47 -0700 (Mon, 23 Apr 2007)

Log Message:
-----------
Simplified loading of background resources for Amiga.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/disk.cpp
    scummvm/trunk/engines/parallaction/disk.h

Modified: scummvm/trunk/engines/parallaction/disk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk.cpp	2007-04-23 17:07:09 UTC (rev 26577)
+++ scummvm/trunk/engines/parallaction/disk.cpp	2007-04-23 17:07:47 UTC (rev 26578)
@@ -978,26 +978,7 @@
 
 void AmigaDisk::loadSlide(const char *name) {
 	debugC(1, kDebugDisk, "AmigaDisk::loadSlide '%s'", name);
-
-	Common::SeekableReadStream *s = openArchivedFile(name, true);
-
-	Graphics::Surface surf;
-	byte *pal;
-
-	// CRNG headers may be safely ignored for slides
-	Graphics::ILBMDecoder decoder(*s);
-	decoder.decode(surf, pal);
-
-	for (uint32 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
-		_vm->_gfx->_palette[i] = pal[i] >> 2;
-	free(pal);
-	_vm->_gfx->setPalette(_vm->_gfx->_palette);
-
-	_vm->_gfx->setBackground(static_cast<byte*>(surf.pixels));
-	surf.free();
-
-	delete s;
-
+	loadBackground(name);
 	return;
 }
 
@@ -1048,18 +1029,17 @@
 	}
 };
 
-void AmigaDisk::loadScenery(const char* background, const char* mask) {
-	debugC(1, kDebugDisk, "AmigaDisk::loadScenery '%s', '%s'", background, mask);
 
+void AmigaDisk::loadBackground(const char *name) {
+
+	Common::SeekableReadStream *s = openArchivedFile(name, true);
+	BackgroundDecoder decoder(*s, _vm->_gfx->_palettefx);
+
 	Graphics::Surface surf;
 	byte *pal;
-	char path[PATH_LEN];
 
-	sprintf(path, "%s.bkgnd", background);
-	Common::SeekableReadStream *s = openArchivedFile(path, true);
-	BackgroundDecoder decoder(*s, _vm->_gfx->_palettefx);
 	decoder.decode(surf, pal);
-	for (uint32 i = 0; i < PALETTE_SIZE; i++)
+	for (uint32 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
 		_vm->_gfx->_palette[i] = pal[i] >> 2;
 	free(pal);
 	_vm->_gfx->setPalette(_vm->_gfx->_palette);
@@ -1067,35 +1047,64 @@
 	surf.free();
 	delete s;
 
-	sprintf(path, "%s.mask", background);
-	s = openArchivedFile(path, true);
+	return;
+
+}
+
+void AmigaDisk::loadMask(const char *name) {
+
+	char path[PATH_LEN];
+	sprintf(path, "%s.mask", name);
+
+	Common::SeekableReadStream *s = openArchivedFile(path, true);
 	s->seek(0x126, SEEK_SET);	// HACK: skipping IFF/ILBM header should be done by analysis, not magic
-	RLEStream *stream2 = new RLEStream(s);
+	RLEStream stream(s);
+
 	byte *buf = (byte*)malloc(SCREENMASK_WIDTH*SCREEN_HEIGHT);
-	stream2->read(buf, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+	stream.read(buf, SCREENMASK_WIDTH*SCREEN_HEIGHT);
 	buildMask(buf);
 	_vm->_gfx->setMask(buf);
 	free(buf);
 	delete s;
-	delete stream2;
 
-	sprintf(path, "%s.path", background);
-	s = openArchivedFile(path, false);
+	return;
+}
+
+void AmigaDisk::loadPath(const char *name) {
+
+	char path[PATH_LEN];
+	sprintf(path, "%s.path", name);
+
+	Common::SeekableReadStream *s = openArchivedFile(path, false);
 	if (s == NULL)
 		return;	// no errors if missing path files: not every location has one
 
+
 	s->seek(0x120, SEEK_SET);	// HACK: skipping IFF/ILBM header should be done by analysis, not magic
-	stream2 = new RLEStream(s);
-	buf = (byte*)malloc(SCREENPATH_WIDTH*SCREEN_HEIGHT);
-	stream2->read(buf, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+
+	RLEStream stream(s);
+	byte *buf = (byte*)malloc(SCREENPATH_WIDTH*SCREEN_HEIGHT);
+	stream.read(buf, SCREENPATH_WIDTH*SCREEN_HEIGHT);
 	setPath(buf);
 	free(buf);
 	delete s;
-	delete stream2;
 
 	return;
 }
 
+void AmigaDisk::loadScenery(const char* background, const char* mask) {
+	debugC(1, kDebugDisk, "AmigaDisk::loadScenery '%s', '%s'", background, mask);
+
+	char path[PATH_LEN];
+	sprintf(path, "%s.bkgnd", background);
+
+	loadBackground(path);
+	loadMask(background);
+	loadPath(background);
+
+	return;
+}
+
 Table* AmigaDisk::loadTable(const char* name) {
 	debugC(1, kDebugDisk, "AmigaDisk::loadTable '%s'", name);
 

Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h	2007-04-23 17:07:09 UTC (rev 26577)
+++ scummvm/trunk/engines/parallaction/disk.h	2007-04-23 17:07:47 UTC (rev 26578)
@@ -156,6 +156,9 @@
 	void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 planeSize);
 	Common::SeekableReadStream *openArchivedFile(const char* name, bool errorOnFileNotFound = false);
 	Font *createFont(const char *name, Common::SeekableReadStream &stream);
+	void loadMask(const char *name);
+	void loadPath(const char *name);
+	void loadBackground(const char *name);
 
 public:
 	AmigaDisk(Parallaction *vm);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list