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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Mar 4 10:20:05 CET 2007


Revision: 25964
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25964&view=rev
Author:   peres001
Date:     2007-03-04 01:20:03 -0800 (Sun, 04 Mar 2007)

Log Message:
-----------
moved platform-dependant resource loading routines into disk.cpp

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

Modified: scummvm/trunk/engines/parallaction/disk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk.cpp	2007-03-04 09:00:41 UTC (rev 25963)
+++ scummvm/trunk/engines/parallaction/disk.cpp	2007-03-04 09:20:03 UTC (rev 25964)
@@ -27,12 +27,153 @@
 
 namespace Parallaction {
 
+//
+// decompress a graphics block
+//
+uint16 decompressChunk(byte *src, byte *dst, uint16 size) {
+
+	uint16 written = 0;
+	uint16 read = 0;
+	uint16 len = 0;
+
+	for (; written != size; written += len) {
+
+		len = src[read];
+		read++;
+
+		if (len <= 127) {
+			// copy run
+
+			len++;
+			memcpy(dst+written, src+read, len);
+			read += len;
+
+		} else {
+			// expand run
+
+			len = 257 - len;
+			memset(dst+written, src[read], len);
+			read++;
+
+		}
+
+	}
+
+	return read;
+}
+
+
+//
+// loads a cnv from an external file
+//
+void loadExternalCnv(const char *filename, Cnv *cnv) {
+//	printf("Graphics::loadExternalCnv(%s)...", filename);
+
+	char path[PATH_LEN];
+
+	sprintf(path, "%s.cnv", filename);
+
+	Common::File stream;
+
+	if (!stream.open(path))
+		errorFileNotFound(path);
+
+	cnv->_count = stream.readByte();
+	cnv->_width = stream.readByte();
+	cnv->_height = stream.readByte();
+
+	cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*));
+
+	uint16 size = cnv->_width*cnv->_height;
+	for (uint16 i = 0; i < cnv->_count; i++) {
+		cnv->_array[i] = (byte*)malloc(size);
+		stream.read(cnv->_array[i], size);
+	}
+
+	stream.close();
+
+//	printf("done\n");
+
+
+	return;
+}
+
+void loadExternalStaticCnv(const char *filename, StaticCnv *cnv) {
+
+	char path[PATH_LEN];
+
+	sprintf(path, "%s.cnv", filename);
+
+	Common::File stream;
+
+	if (!stream.open(path))
+		errorFileNotFound(path);
+
+	cnv->_width = cnv->_height = 0;
+
+	stream.skip(1);
+	cnv->_width = stream.readByte();
+	cnv->_height = stream.readByte();
+
+	uint16 size = cnv->_width*cnv->_height;
+
+	cnv->_data0 = (byte*)malloc(size);
+	stream.read(cnv->_data0, size);
+
+	stream.close();
+
+	return;
+}
+
+void loadCnv(const char *filename, Cnv *cnv) {
+//	printf("Graphics::loadCnv(%s)\n", filename);
+
+	char path[PATH_LEN];
+
+	strcpy(path, filename);
+	if (!_vm->_archive.openArchivedFile(path)) {
+		sprintf(path, "%s.pp", filename);
+		if (!_vm->_archive.openArchivedFile(path))
+			errorFileNotFound(path);
+	}
+
+	cnv->_count = _vm->_archive.readByte();
+	cnv->_width = _vm->_archive.readByte();
+	cnv->_height = _vm->_archive.readByte();
+
+	uint16 framesize = cnv->_width*cnv->_height;
+
+	cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*));
+
+	uint32 size = _vm->_archive.size() - 3;
+
+	byte *buf = (byte*)malloc(size);
+	_vm->_archive.read(buf, size);
+
+	byte *s = buf;
+
+	for (uint16 i = 0; i < cnv->_count; i++) {
+		cnv->_array[i] = (byte*)malloc(framesize);
+		uint16 read = decompressChunk(s, cnv->_array[i], framesize);
+
+//		printf("frame %i decompressed: %i --> %i\n", i, read, framesize);
+
+		s += read;
+	}
+
+	_vm->_archive.closeArchivedFile();
+
+	free(buf);
+
+	return;
+}
+
 void loadTalk(const char *name, Cnv *cnv) {
 
 	char* ext = strstr(name, ".talk");
 	if (ext != NULL) {
 		// npc talk
-		_vm->_graphics->loadCnv(name, cnv);
+		loadCnv(name, cnv);
 
 	} else {
 		// character talk
@@ -49,7 +190,7 @@
 			sprintf(v20, "%stal", v24);
 		}
 
-		_vm->_graphics->loadExternalCnv(v20, cnv);
+		loadExternalCnv(v20, cnv);
 
 	}
 
@@ -118,20 +259,20 @@
 	snprintf(path, 8, "%shead", name);
 	path[8] = '\0';
 
-	_vm->_graphics->loadExternalStaticCnv(path, cnv);
+	loadExternalStaticCnv(path, cnv);
 
 }
 
 
 void loadPointer(StaticCnv* cnv) {
-	_vm->_graphics->loadExternalStaticCnv("pointer", cnv);
+	loadExternalStaticCnv("pointer", cnv);
 }
 
 void loadFont(const char* name, Cnv* cnv) {
 	char path[PATH_LEN];
 
 	sprintf(path, "%scnv", name);
-	_vm->_graphics->loadExternalCnv(path, cnv);
+	loadExternalCnv(path, cnv);
 }
 
 // loads character's icons set
@@ -145,21 +286,45 @@
 	char path[PATH_LEN];
 	sprintf(path, "%sobj", name);
 
-	_vm->_graphics->loadExternalCnv(path, cnv);
+	loadExternalCnv(path, cnv);
 
 	return;
 }
 
+
 void loadStatic(const char* name, StaticCnv* cnv) {
 
-	_vm->_graphics->loadStaticCnv(name, cnv);
+	char path[PATH_LEN];
 
+	strcpy(path, name);
+	if (!_vm->_archive.openArchivedFile(path)) {
+		sprintf(path, "%s.pp", name);
+		if (!_vm->_archive.openArchivedFile(path))
+			errorFileNotFound(path);
+	}
+
+	_vm->_archive.skip(1);
+	cnv->_width = _vm->_archive.readByte();
+	cnv->_height = _vm->_archive.readByte();
+
+	uint16 compressedsize = _vm->_archive.size() - 3;
+	byte *compressed = (byte*)malloc(compressedsize);
+
+	uint16 size = cnv->_width*cnv->_height;
+	cnv->_data0 = (byte*)malloc(size);
+
+	_vm->_archive.read(compressed, compressedsize);
+	_vm->_archive.closeArchivedFile();
+
+	decompressChunk(compressed, cnv->_data0, size);
+	free(compressed);
+
 	return;
 }
 
 void loadFrames(const char* name, Cnv* cnv) {
 
-	_vm->_graphics->loadCnv(name, cnv);
+	loadCnv(name, cnv);
 
 	return;
 }

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-03-04 09:00:41 UTC (rev 25963)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-03-04 09:20:03 UTC (rev 25964)
@@ -952,158 +952,6 @@
 }
 
 
-//
-// loads a cnv from an external file
-//
-void Graphics::loadExternalCnv(const char *filename, Cnv *cnv) {
-//	printf("Graphics::loadExternalCnv(%s)...", filename);
-
-	char path[PATH_LEN];
-
-	sprintf(path, "%s.cnv", filename);
-
-	Common::File stream;
-
-	if (!stream.open(path))
-		errorFileNotFound(path);
-
-	cnv->_count = stream.readByte();
-	cnv->_width = stream.readByte();
-	cnv->_height = stream.readByte();
-
-	cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*));
-
-	uint16 size = cnv->_width*cnv->_height;
-	for (uint16 i = 0; i < cnv->_count; i++) {
-		cnv->_array[i] = (byte*)malloc(size);
-		stream.read(cnv->_array[i], size);
-	}
-
-	stream.close();
-
-//	printf("done\n");
-
-
-	return;
-}
-
-
-
-
-void Graphics::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) {
-
-	char path[PATH_LEN];
-
-	sprintf(path, "%s.cnv", filename);
-
-	Common::File stream;
-
-	if (!stream.open(path))
-		errorFileNotFound(path);
-
-	cnv->_width = cnv->_height = 0;
-
-	stream.skip(1);
-	cnv->_width = stream.readByte();
-	cnv->_height = stream.readByte();
-
-	uint16 size = cnv->_width*cnv->_height;
-
-	cnv->_data0 = (byte*)malloc(size);
-	stream.read(cnv->_data0, size);
-
-	stream.close();
-
-	return;
-}
-
-
-
-
-
-void Graphics::loadStaticCnv(const char *filename, StaticCnv *cnv) {
-//	printf("Graphics::loadStaticCnv(%s)\n", filename);
-
-	char path[PATH_LEN];
-
-	strcpy(path, filename);
-	if (!_vm->_archive.openArchivedFile(path)) {
-		sprintf(path, "%s.pp", filename);
-		if (!_vm->_archive.openArchivedFile(path))
-			errorFileNotFound(path);
-	}
-
-	_vm->_archive.skip(1);
-	cnv->_width = _vm->_archive.readByte();
-	cnv->_height = _vm->_archive.readByte();
-
-	uint16 compressedsize = _vm->_archive.size() - 3;
-	byte *compressed = (byte*)malloc(compressedsize);
-
-	uint16 size = cnv->_width*cnv->_height;
-	cnv->_data0 = (byte*)malloc(size);
-
-	_vm->_archive.read(compressed, compressedsize);
-	_vm->_archive.closeArchivedFile();
-
-	decompressChunk(compressed, cnv->_data0, size);
-	free(compressed);
-
-	return;
-}
-
-
-
-
-void Graphics::loadCnv(const char *filename, Cnv *cnv) {
-//	printf("Graphics::loadCnv(%s)\n", filename);
-
-	char path[PATH_LEN];
-
-	strcpy(path, filename);
-	if (!_vm->_archive.openArchivedFile(path)) {
-		sprintf(path, "%s.pp", filename);
-		if (!_vm->_archive.openArchivedFile(path))
-			errorFileNotFound(path);
-	}
-
-	cnv->_count = _vm->_archive.readByte();
-	cnv->_width = _vm->_archive.readByte();
-	cnv->_height = _vm->_archive.readByte();
-
-	uint16 framesize = cnv->_width*cnv->_height;
-
-	cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*));
-
-	uint32 size = _vm->_archive.size() - 3;
-
-	byte *buf = (byte*)malloc(size);
-	_vm->_archive.read(buf, size);
-
-	byte *s = buf;
-
-	for (uint16 i = 0; i < cnv->_count; i++) {
-		cnv->_array[i] = (byte*)malloc(framesize);
-		uint16 read = decompressChunk(s, cnv->_array[i], framesize);
-
-//		printf("frame %i decompressed: %i --> %i\n", i, read, framesize);
-
-		s += read;
-	}
-
-	_vm->_archive.closeArchivedFile();
-
-	free(buf);
-
-	return;
-}
-
-
-
-
-
-
-
 void Graphics::freeCnv(Cnv *cnv) {
 //	printf("Graphics::freeCnv()\n");
 
@@ -1181,7 +1029,6 @@
 
 }
 
-
 void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) {
 //	printf("Graphics::loadBackground(%s)\n", filename);
 
@@ -1189,29 +1036,7 @@
 		errorFileNotFound(filename);
 
 	parseBackground(_vm->_archive);
-/*
-	_vm->_archive.read(_palette, PALETTE_SIZE);
 
-	uint16 _si;
-	for (_si = 0; _si < 4; _si++)
-		_bgLayers[_si] = _vm->_archive.readByte();
-
-	for (_si = 0; _si < 6; _si++) {
-		_palettefx[_si]._timer = _vm->_archive.readUint16BE();
-		_palettefx[_si]._step = _vm->_archive.readUint16BE();
-		_palettefx[_si]._flags = _vm->_archive.readUint16BE();
-		_palettefx[_si]._first = _vm->_archive.readByte();
-		_palettefx[_si]._last = _vm->_archive.readByte();
-	}
-
-#if 0
-	uint16 v147;
-	for (v147 = 0; v147 < PALETTE_SIZE; v147++) {
-		byte _al = _palette[v147];
-		_palette[PALETTE_SIZE+v147] = _al / 2;
-	}
-#endif
-*/
 	memset(_buffers[kPath0], 0, SCREENPATH_WIDTH*SCREEN_HEIGHT);
 	memset(_buffers[kMask0], 0, SCREENMASK_WIDTH*SCREEN_HEIGHT);
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-03-04 09:00:41 UTC (rev 25963)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-03-04 09:20:03 UTC (rev 25964)
@@ -88,10 +88,6 @@
 
 	// cnv management
 	void makeCnvFromString(StaticCnv *cnv, char *text);
-	void loadExternalCnv(const char *filename, Cnv *cnv);
-	void loadExternalStaticCnv(const char *filename, StaticCnv *cnv);
-	void loadCnv(const char *filename, Cnv *cnv);
-	void loadStaticCnv(const char *filename, StaticCnv *cnv);
 	void freeCnv(Cnv *cnv);
 	void freeStaticCnv(StaticCnv *cnv);
 	void backupCnvBackground(StaticCnv *cnv, int16 x, int16 y);


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