[Scummvm-cvs-logs] CVS: scummvm/backends/gp32 gp32.cpp,1.3,1.4 gp32.h,1.3,1.4

Marcus Comstedt marcus_c at users.sourceforge.net
Mon Dec 16 17:16:06 CET 2002


Update of /cvsroot/scummvm/scummvm/backends/gp32
In directory sc8-pr-cvs1:/tmp/cvs-serv32726/backends/gp32

Modified Files:
	gp32.cpp gp32.h 
Log Message:
New savefile backend system (bye bye NONSTANDARD_SAVE...)

Index: gp32.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gp32.cpp	2 Dec 2002 16:55:17 -0000	1.3
+++ gp32.cpp	17 Dec 2002 01:15:13 -0000	1.4
@@ -1221,26 +1221,47 @@
 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 

Index: gp32.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/gp32/gp32.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gp32.h	2 Dec 2002 16:55:17 -0000	1.3
+++ gp32.h	17 Dec 2002 01:15:13 -0000	1.4
@@ -115,6 +115,10 @@
 	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,





More information about the Scummvm-git-logs mailing list