From 9f43e2cf8a7c42db3521bfa408ddbf40cb03d845 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sat, 8 Dec 2007 15:11:20 +0000 Subject: Use "new" framework for compressed saves... svn-id: r29765 --- backends/platform/dc/Makefile | 2 +- backends/platform/dc/vmsave.cpp | 38 +++++--------------------------------- 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 #include #include +#include -#include - -// 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); -- cgit v1.2.3