[Scummvm-cvs-logs] SF.net SVN: scummvm: [29765] scummvm/trunk/backends/platform/dc

marcus_c at users.sourceforge.net marcus_c at users.sourceforge.net
Sat Dec 8 16:11:21 CET 2007


Revision: 29765
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29765&view=rev
Author:   marcus_c
Date:     2007-12-08 07:11:20 -0800 (Sat, 08 Dec 2007)

Log Message:
-----------
Use "new" framework for compressed saves...

Modified Paths:
--------------
    scummvm/trunk/backends/platform/dc/Makefile
    scummvm/trunk/backends/platform/dc/vmsave.cpp

Modified: scummvm/trunk/backends/platform/dc/Makefile
===================================================================
--- scummvm/trunk/backends/platform/dc/Makefile	2007-12-08 14:58:06 UTC (rev 29764)
+++ scummvm/trunk/backends/platform/dc/Makefile	2007-12-08 15:11:20 UTC (rev 29765)
@@ -11,7 +11,7 @@
 CC      = sh-elf-gcc -ml -m4-single-only
 CXX     = sh-elf-g++ -ml -m4-single-only
 CXXFLAGS= -O3 -Wno-multichar -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks -fno-exceptions
-DEFINES = -D__DC__ -DNONSTANDARD_PORT -DUSE_MAD
+DEFINES = -D__DC__ -DNONSTANDARD_PORT -DUSE_MAD -DUSE_ZLIB
 LDFLAGS = -Wl,-Ttext,0x8c010000 -nostartfiles $(ronindir)/lib/crt0.o
 INCLUDES= -I./ -I$(srcdir) -I$(srcdir)/common -I$(ronindir)/include/ -I$(srcdir)/engines
 LIBS	= -L$(ronindir)/lib -lmad -lronin -lz -lm

Modified: scummvm/trunk/backends/platform/dc/vmsave.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/vmsave.cpp	2007-12-08 14:58:06 UTC (rev 29764)
+++ scummvm/trunk/backends/platform/dc/vmsave.cpp	2007-12-08 15:11:20 UTC (rev 29765)
@@ -30,11 +30,10 @@
 #include <common/savefile.h>
 #include <gui/newgui.h>
 #include <gui/message.h>
+#include <backends/saves/compressed/compressed-saves.h>
 
-#include <zlib.h>
 
-
-// Savegame can not be bigger than this, even before compression
+// Savegame can not be bigger than this
 #define MAX_SAVE_SIZE (128*1024)
 
 
@@ -137,7 +136,6 @@
   struct timestamp tstamp;
   struct tm tm;
   time_t t;
-  unsigned char iconbuffer[512+32];
 
   if (!vmsfs_check_unit(vm, 0, &info))
     return false;
@@ -298,20 +296,6 @@
 
   bool readSaveGame(const char *filename)
   { return ::readSaveGame(buffer, _size, filename); }
-
-  void tryUncompress()
-  {
-    if (_size > 0 && buffer[0] != 'S') {
-      // Data does not start with "SCVM".  Maybe compressed?
-      char *expbuf = new char[MAX_SAVE_SIZE];
-      unsigned long destlen = MAX_SAVE_SIZE;
-      if (!uncompress((Bytef*)expbuf, &destlen, (Bytef*)buffer, _size)) {
-	delete[] buffer;
-	buffer = expbuf;
-	_size = destlen;
-      } else delete[] expbuf;
-    }
-  }
 };
 
 class OutVMSave : public Common::OutSaveFile {
@@ -342,14 +326,13 @@
 public:
 
   virtual Common::OutSaveFile *openForSaving(const char *filename) {
-	return new OutVMSave(filename);
+	return wrapOutSaveFile(new OutVMSave(filename));
   }
 
   virtual Common::InSaveFile *openForLoading(const char *filename) {
 	InVMSave *s = new InVMSave();
 	if (s->readSaveGame(filename)) {
-	  s->tryUncompress();
-	  return s;
+	  return wrapInSaveFile(s);
 	} else {
 	  delete s;
 	  return NULL;
@@ -371,22 +354,11 @@
   if (committed >= pos)
     return;
 
-  char *data = buffer, *compbuf = NULL;
+  char *data = buffer;
   int len = pos;
 
-  if (pos) {
-    // Try compression
-    compbuf = new char[pos];
-    unsigned long destlen = pos;
-    if (!compress((Bytef*)compbuf, &destlen, (Bytef*)buffer, pos)) {
-      data = compbuf;
-      len = destlen;
-    }
-  }
   vmsaveResult r = writeSaveGame(gGameName, data, len, filename, icon);
   committed = pos;
-  if (compbuf != NULL)
-    delete[] compbuf;
   if (r != VMSAVE_OK)
     iofailed = true;
   displaySaveResult(r);


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