aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/dc
diff options
context:
space:
mode:
authorMarcus Comstedt2007-12-08 15:11:20 +0000
committerMarcus Comstedt2007-12-08 15:11:20 +0000
commit9f43e2cf8a7c42db3521bfa408ddbf40cb03d845 (patch)
tree555d714ec6d49eab35728c89a36a8969b034346b /backends/platform/dc
parent7f019cfdee4a425ee892cab3266d41726fa0ac52 (diff)
downloadscummvm-rg350-9f43e2cf8a7c42db3521bfa408ddbf40cb03d845.tar.gz
scummvm-rg350-9f43e2cf8a7c42db3521bfa408ddbf40cb03d845.tar.bz2
scummvm-rg350-9f43e2cf8a7c42db3521bfa408ddbf40cb03d845.zip
Use "new" framework for compressed saves...
svn-id: r29765
Diffstat (limited to 'backends/platform/dc')
-rw-r--r--backends/platform/dc/Makefile2
-rw-r--r--backends/platform/dc/vmsave.cpp38
2 files changed, 6 insertions, 34 deletions
diff --git a/backends/platform/dc/Makefile b/backends/platform/dc/Makefile
index 3ad96a6caf..4cbb244a95 100644
--- a/backends/platform/dc/Makefile
+++ b/backends/platform/dc/Makefile
@@ -11,7 +11,7 @@ VPATH = $(srcdir)
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
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp
index cd8d5d4770..6830696e4e 100644
--- a/backends/platform/dc/vmsave.cpp
+++ b/backends/platform/dc/vmsave.cpp
@@ -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 @@ static bool tryLoad(char *&buffer, int &size, const char *filename, int vm)
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 @@ public:
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 @@ class VMSaveManager : public Common::SaveFileManager {
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 @@ void OutVMSave::finalize()
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);