aboutsummaryrefslogtreecommitdiff
path: root/backends/gp32
diff options
context:
space:
mode:
authorMarcus Comstedt2002-12-17 01:15:13 +0000
committerMarcus Comstedt2002-12-17 01:15:13 +0000
commit83da387eef75aa1140c81bd9e3e002ae3ea83864 (patch)
treea66d39aca4ef689a33df4d7ca374e4ad7ebdc817 /backends/gp32
parentfadf55aad038286803cb2c1d0b5e75aca0ba3a02 (diff)
downloadscummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.tar.gz
scummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.tar.bz2
scummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.zip
New savefile backend system (bye bye NONSTANDARD_SAVE...)
svn-id: r6007
Diffstat (limited to 'backends/gp32')
-rw-r--r--backends/gp32/gp32.cpp41
-rw-r--r--backends/gp32/gp32.h4
2 files changed, 35 insertions, 10 deletions
diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp
index 773b4e95ec..19a1aaec57 100644
--- a/backends/gp32/gp32.cpp
+++ b/backends/gp32/gp32.cpp
@@ -1221,26 +1221,47 @@ extern "C" int write(int fd, void *p, size_t n);
int write(int fd, void *p, size_t n) { return 0; } //ph0x hack!
// fixme - unnecessary?
-int SerializerStream::fwrite(void *buf, int size, int cnt) {
+class GP32SaveFile : public SaveFile {
+private:
+ FILE *fh;
+public:
+ GP32SaveFile(FILE *f) : fh(f) { }
+
+ ~GP32SaveFile();
+
+ int fread(void *buf, int size, int cnt);
+ int fwrite(void *buf, int size, int cnt);
+}
+
+class GP32SaveFileManager : public SaveFileManager {
+ SaveFile *open_savefile(const char *filename, bool saveOrLoad);
+}
+
+int GP32SaveFile::fwrite(void *buf, int size, int cnt) {
// implement me
- return ::fwrite(buf, size, cnt, (FILE*)context);
+ return ::fwrite(buf, size, cnt, fh);
}
-bool SerializerStream::fopen(const char *filename, const char *mode) {
+SaveFile GP32SaveFileManager::open_savefile(const char *filename,
+ bool saveOrLoad) {
// implement me
- (FILE*)context = ::fopen(filename, mode);
- //if (tolower(mode[0])=='w') error("Autosaving..");
- return context != NULL;
+ FILE *fh = ::fopen(filename, (saveOrLoad? "wb":"rb"));
+ //if (saveOrLoad) error("Autosaving..");
+ return fh? new GP32SaveFile(fh) : NULL;
}
-void SerializerStream::fclose() {
+void GP32SaveFile::~GP32SaveFile() {
// implement me
- ::fclose((FILE*)context);
+ ::fclose(fh);
}
-int SerializerStream::fread(void *buf, int size, int cnt) {
+int GP32SaveFile::fread(void *buf, int size, int cnt) {
// implement me
- return ::fread(buf, size, cnt, (FILE*)context);
+ return ::fread(buf, size, cnt, fh);
+
+}
+SaveFileManager *OSystem_GP32::get_savefile_manager() {
+ return new GP32SaveFileManager();
}
// Converts 8bit rgb values to a GP32 palette value
diff --git a/backends/gp32/gp32.h b/backends/gp32/gp32.h
index 7546a25b7b..f56de538f7 100644
--- a/backends/gp32/gp32.h
+++ b/backends/gp32/gp32.h
@@ -115,6 +115,10 @@ public:
void grab_overlay(int16 *buf, int pitch);
void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
+ // Savefiles
+ SaveFileManager *get_savefile_manager();
+
+
static OSystem *create(int gfx_mode, bool full_screen);
private:
typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,