[Scummvm-cvs-logs] SF.net SVN: scummvm: [28893] scummvm/trunk/engines/agi

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Sep 11 22:09:40 CEST 2007


Revision: 28893
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28893&view=rev
Author:   mthreepwood
Date:     2007-09-11 13:09:39 -0700 (Tue, 11 Sep 2007)

Log Message:
-----------
PreAGI does not need an AGI resource loader, as it only needs to load pictures and doesn't use directories. So, this allows Winnie to decode pictures without using the loader

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.h
    scummvm/trunk/engines/agi/loader_preagi.cpp
    scummvm/trunk/engines/agi/picture.cpp
    scummvm/trunk/engines/agi/picture.h
    scummvm/trunk/engines/agi/preagi.cpp
    scummvm/trunk/engines/agi/preagi_winnie.cpp

Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/agi.h	2007-09-11 20:09:39 UTC (rev 28893)
@@ -548,8 +548,6 @@
 	virtual int deinit() = 0;
 	virtual int detectGame() = 0;
 	virtual int loadResource(int, int) = 0;
-	virtual int loadResource(int, const char*) = 0;
-	virtual int loadResource(int, byte*) = 0;
 	virtual int unloadResource(int, int) = 0;
 	virtual int loadObjects(const char *) = 0;
 	virtual int loadWords(const char *) = 0;
@@ -577,8 +575,6 @@
 	virtual int deinit();
 	virtual int detectGame();
 	virtual int loadResource(int, int);
-	virtual int loadResource(int, const char*);
-	virtual int loadResource(int, byte*);
 	virtual int unloadResource(int, int);
 	virtual int loadObjects(const char *);
 	virtual int loadWords(const char *);
@@ -606,8 +602,6 @@
 	virtual int deinit();
 	virtual int detectGame();
 	virtual int loadResource(int, int);
-	virtual int loadResource(int, const char*) { return 0; }
-	virtual int loadResource(int, byte*) { return 0; }
 	virtual int unloadResource(int, int);
 	virtual int loadObjects(const char *);
 	virtual int loadWords(const char *);
@@ -635,8 +629,6 @@
 	virtual int deinit();
 	virtual int detectGame();
 	virtual int loadResource(int, int);
-	virtual int loadResource(int, const char*) { return 0; }
-	virtual int loadResource(int, byte*) { return 0; }
 	virtual int unloadResource(int, int);
 	virtual int loadObjects(const char *);
 	virtual int loadWords(const char *);
@@ -983,8 +975,6 @@
 	int agiIsKeypressLow() { return 0; }
 
 	int preAgiLoadResource(int r, int n);
-	int preAgiLoadResource(int r, const char* n);
-	int preAgiLoadResource(int r, byte* n);
 	int preAgiUnloadResource(int r, int n);
 
 	PreAgiEngine(OSystem *syst);

Modified: scummvm/trunk/engines/agi/loader_preagi.cpp
===================================================================
--- scummvm/trunk/engines/agi/loader_preagi.cpp	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/loader_preagi.cpp	2007-09-11 20:09:39 UTC (rev 28893)
@@ -211,86 +211,6 @@
 	return ec;
 }
 
-/*
- * Loads a resource into memory, a raw resource is loaded in
- * with above routine, then further decoded here.
- */
-int AgiLoader_preagi::loadResource(int t, const char* n) {
-	int ec = errOK;
-	uint8 *data = NULL;
-	Common::File infile;
-
-	switch (t) {
-	case rPICTURE:
-		/* if picture is currently NOT loaded *OR* cacheing is off,
-		 * unload the resource (caching==off) and reload it
-		 */
-		if (~_vm->_game.dirPic[0].flags & RES_LOADED)
-			unloadResource(rPICTURE, 0);
-
-		data = new uint8[4096];
-
-		if (!infile.open(n))
-			return errBadResource;
-		infile.read(data, infile.size());
-
-		if (data != NULL) {
-			_vm->_game.pictures[0].rdata = data;
-			_vm->_game.dirPic[0].len = infile.size();
-			_vm->_game.dirPic[0].flags |= RES_LOADED;
-		} else {
-			ec = errBadResource;
-		}
-
-		infile.close();
-		break;
-	case rSOUND:
-		break;
-	case rVIEW:
-		break;
-	default:
-		ec = errBadResource;
-		break;
-	}
-
-	return ec;
-}
-
-/*
- * Loads a resource into memory, a raw resource is loaded in
- * with above routine, then further decoded here.
- */
-int AgiLoader_preagi::loadResource(int t, byte* n) {
-	int ec = errOK;
-
-	switch (t) {
-	case rPICTURE:
-		/* if picture is currently NOT loaded *OR* cacheing is off,
-		 * unload the resource (caching==off) and reload it
-		 */
-		if (~_vm->_game.dirPic[0].flags & RES_LOADED)
-			unloadResource(rPICTURE, 0);
-
-		if (n != NULL) {
-			_vm->_game.pictures[0].rdata = n;
-			_vm->_game.dirPic[0].len = 4096;		//FIXME: set up real resource length
-			_vm->_game.dirPic[0].flags |= RES_LOADED;
-		} else {
-			ec = errBadResource;
-		}
-		break;
-	case rSOUND:
-		break;
-	case rVIEW:
-		break;
-	default:
-		ec = errBadResource;
-		break;
-	}
-
-	return ec;
-}
-
 int AgiLoader_preagi::loadObjects(const char *fname) {
 	return 0;
 	//return _vm->loadObjects(fname);

Modified: scummvm/trunk/engines/agi/picture.cpp
===================================================================
--- scummvm/trunk/engines/agi/picture.cpp	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/picture.cpp	2007-09-11 20:09:39 UTC (rev 28893)
@@ -802,6 +802,37 @@
 }
 
 /**
+ * Decode an AGI picture resource.
+ * This function decodes an AGI picture resource into the correct slot
+ * and draws it on the AGI screen, optionally clearing the screen before
+ * drawing.
+ * @param data   the AGI Picture data
+ * @param length the size of the picture data buffer
+ * @param clear  clear AGI screen before drawing
+ */
+int PictureMgr::decodePicture(byte* data, uint32 length, int clear, int pic_width, int pic_height) {
+	_patCode = 0;
+	_patNum = 0;
+	_priOn = _scrOn = false;
+	_scrColor = 0xF;
+	_priColor = 0x4;
+
+	_data = data;
+	_flen = length;
+	_foffs = 0;
+
+	_width = pic_width;
+	_height = pic_height;
+
+	if (clear) // 256 color pictures should always fill the whole screen, so no clearing for them.
+		memset(_vm->_game.sbuf16c, 0x4f, _width * _height); // Clear 16 color AGI screen (Priority 4, color white).
+
+	drawPicture(); // Draw 16 color picture.
+
+	return errOK;
+}
+
+/**
  * Unload an AGI picture resource.
  * This function unloads an AGI picture resource and deallocates
  * resource data.

Modified: scummvm/trunk/engines/agi/picture.h
===================================================================
--- scummvm/trunk/engines/agi/picture.h	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/picture.h	2007-09-11 20:09:39 UTC (rev 28893)
@@ -83,6 +83,7 @@
 	PictureMgr(AgiBase *agi, GfxMgr *gfx);
 
 	int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
+	int decodePicture(byte* data, uint32 length, int clear, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
 	int unloadPicture(int);
 	void drawPicture();
 	void showPic(int x = 0, int y = 0, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);

Modified: scummvm/trunk/engines/agi/preagi.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi.cpp	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/preagi.cpp	2007-09-11 20:09:39 UTC (rev 28893)
@@ -256,14 +256,6 @@
 	return _loader->loadResource(r, n);
 }
 
-int PreAgiEngine::preAgiLoadResource (int r, const char* n) {
-	return _loader->loadResource(r, n);
-}
-
-int PreAgiEngine::preAgiLoadResource (int r, byte* n) {
-	return _loader->loadResource(r, n);
-}
-
 int PreAgiEngine::preAgiUnloadResource(int r, int n) {
 	return _loader->unloadResource(r, n);
 }

Modified: scummvm/trunk/engines/agi/preagi_winnie.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_winnie.cpp	2007-09-11 15:49:19 UTC (rev 28892)
+++ scummvm/trunk/engines/agi/preagi_winnie.cpp	2007-09-11 20:09:39 UTC (rev 28893)
@@ -968,13 +968,17 @@
 
 	// construct filename
 	sprintf(szFile, IDS_WTP_PATH, szName);
+	Common::File file;
+	if (!file.open(szName))
+		return;
+	uint32 size = file.size();
+	file.read(buffer, size);
+	file.close();
 
-	_vm->preAgiLoadResource(rPICTURE, szName);
-	_vm->_picture->decodePicture(0, true, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_vm->_picture->decodePicture(buffer, size, 1, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_gfx->doUpdate();
 	_vm->_system->updateScreen();	// TODO: this should go in the game's main loop
-	_vm->preAgiUnloadResource(rPICTURE, 0);
 
 	delete [] buffer;
 }
@@ -989,9 +993,8 @@
 	readObj(iObj, buffer, 2048);
 	memcpy(&objhdr, buffer, sizeof(WTP_OBJ_HDR));
 
-	_vm->preAgiLoadResource(rPICTURE, buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ);
 	_vm->_picture->setOffset(x0, y0);
-	_vm->_picture->decodePicture(0, false, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_vm->_picture->decodePicture(buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ, 4096, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_picture->setOffset(0, 0);
 	_vm->_picture->showPic(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_gfx->doUpdate();
@@ -1015,8 +1018,7 @@
 	memcpy(&roomhdr, buffer, sizeof(WTP_ROOM_HDR));
 
 	// draw room picture
-	_vm->preAgiLoadResource(rPICTURE, buffer + roomhdr.ofsPic - IDI_WTP_OFS_ROOM);
-	_vm->_picture->decodePicture(0, true, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_vm->_picture->decodePicture(buffer + roomhdr.ofsPic - IDI_WTP_OFS_ROOM, 4096, 1, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 	_vm->_gfx->doUpdate();
 	_vm->_system->updateScreen();	// TODO: this should go in the game's main loop


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