[Scummvm-cvs-logs] SF.net SVN: scummvm:[47126] scummvm/trunk/backends/platform/n64
Hkz at users.sourceforge.net
Hkz at users.sourceforge.net
Thu Jan 7 17:07:23 CET 2010
Revision: 47126
http://scummvm.svn.sourceforge.net/scummvm/?rev=47126&view=rev
Author: Hkz
Date: 2010-01-07 16:07:22 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Nintendo64: Add FlashRAM support for saving if a compatible cart is available.
Modified Paths:
--------------
scummvm/trunk/backends/platform/n64/Makefile
scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp
scummvm/trunk/backends/platform/n64/pakfs_save_manager.h
Added Paths:
-----------
scummvm/trunk/backends/platform/n64/framfs_save_manager.cpp
scummvm/trunk/backends/platform/n64/framfs_save_manager.h
Modified: scummvm/trunk/backends/platform/n64/Makefile
===================================================================
--- scummvm/trunk/backends/platform/n64/Makefile 2010-01-07 15:50:58 UTC (rev 47125)
+++ scummvm/trunk/backends/platform/n64/Makefile 2010-01-07 16:07:22 UTC (rev 47126)
@@ -15,7 +15,7 @@
RANLIB = $(GCCN64PREFIX)ranlib
DEFINES += -D__N64__ -DLIMIT_FPS -DNONSTANDARD_PORT -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_FANCY_THEMES -DDISABLE_DOSBOX_OPL -DENABLE_VKEYBD -DUSE_ZLIB
-LIBS += -lpakfs -ln64 -ln64utils -lromfs
+LIBS += -lpakfs -lframfs -ln64 -ln64utils -lromfs
DEFINES += -D_ENABLE_DEBUG_
@@ -64,7 +64,7 @@
#ENABLE_MADE = $(ENABLED)
#ENABLE_SAGA = $(ENABLED)
-OBJS := nintendo64.o osys_n64_base.o osys_n64_events.o osys_n64_utilities.o pakfs_save_manager.o
+OBJS := nintendo64.o osys_n64_base.o osys_n64_events.o osys_n64_utilities.o pakfs_save_manager.o framfs_save_manager.o
include $(srcdir)/Makefile.common
Added: scummvm/trunk/backends/platform/n64/framfs_save_manager.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/framfs_save_manager.cpp (rev 0)
+++ scummvm/trunk/backends/platform/n64/framfs_save_manager.cpp 2010-01-07 16:07:22 UTC (rev 47126)
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <n64utils.h>
+
+#include "framfs_save_manager.h"
+
+bool fram_deleteSaveGame(const char *filename) {
+ int res = framfs_removeFile(filename);
+
+ return (res == 0);
+}
+
+uint32 InFRAMSave::read(void *buf, uint32 cnt) {
+ return framfs_read(buf, 1, cnt, fd);
+}
+
+bool InFRAMSave::seek(int32 offs, int whence) {
+ framfs_seek(fd, offs, whence);
+
+ return true;
+}
+
+bool InFRAMSave::skip(uint32 offset) {
+ framfs_seek(fd, offset, SEEK_CUR);
+
+ return true;
+}
+
+uint32 OutFRAMSave::write(const void *buf, uint32 cnt) {
+ return framfs_write(buf, 1, cnt, fd);
+}
+
+Common::StringList FRAMSaveManager::listSavefiles(const Common::String &pattern) {
+ FRAMDIR *dirp = framfs_opendir();
+ framfs_dirent *dp;
+ Common::StringList list;
+ Common::String *fname;
+
+ while ((dp = framfs_readdir(dirp)) != NULL) {
+ fname = new Common::String(dp->entryname);
+ if (fname->matchString(pattern, false, false))
+ list.push_back(dp->entryname);
+
+ delete fname;
+ free(dp);
+ }
+
+ framfs_closedir(dirp);
+
+ return list;
+}
+
Property changes on: scummvm/trunk/backends/platform/n64/framfs_save_manager.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/backends/platform/n64/framfs_save_manager.h
===================================================================
--- scummvm/trunk/backends/platform/n64/framfs_save_manager.h (rev 0)
+++ scummvm/trunk/backends/platform/n64/framfs_save_manager.h 2010-01-07 16:07:22 UTC (rev 47126)
@@ -0,0 +1,132 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __FRAMFS_SAVE_MANAGER__
+#define __FRAMFS_SAVE_MANAGER__
+
+#include <common/savefile.h>
+#include <common/zlib.h>
+
+#include <framfs.h> // N64 FramFS library
+
+bool fram_deleteSaveGame(const char *filename);
+
+class InFRAMSave : public Common::InSaveFile {
+private:
+ FRAMFILE *fd;
+
+ uint32 read(void *buf, uint32 cnt);
+ bool skip(uint32 offset);
+ bool seek(int32 offs, int whence);
+
+public:
+ InFRAMSave() : fd(NULL) { }
+
+ ~InFRAMSave() {
+ if (fd != NULL)
+ framfs_close(fd);
+ }
+
+ bool eos() const {
+ return framfs_eof(fd);
+ }
+ void clearErr() {
+ framfs_clearerr(fd);
+ }
+ int32 pos() const {
+ return framfs_tell(fd);
+ }
+ int32 size() const {
+ return fd->size;
+ }
+
+ bool readSaveGame(const char *filename) {
+ fd = framfs_open(filename, "r");
+ return (fd != NULL);
+ }
+};
+
+class OutFRAMSave : public Common::OutSaveFile {
+private:
+ FRAMFILE *fd;
+
+public:
+ uint32 write(const void *buf, uint32 cnt);
+
+ OutFRAMSave(const char *_filename) : fd(NULL) {
+ fd = framfs_open(_filename, "w");
+ }
+
+ ~OutFRAMSave() {
+ if (fd != NULL) {
+ finalize();
+ framfs_close(fd);
+ }
+ }
+
+ bool err() const {
+ if (fd)
+ return (framfs_error(fd) == 1);
+ else
+ return true;
+ }
+ void clearErr() {
+ framfs_clearerr(fd);
+ }
+ void finalize() {
+ framfs_flush(fd);
+ }
+};
+
+class FRAMSaveManager : public Common::SaveFileManager {
+public:
+
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename) {
+ OutFRAMSave *s = new OutFRAMSave(filename.c_str());
+ if (!s->err()) {
+ return Common::wrapCompressedWriteStream(s);
+ } else {
+ delete s;
+ return 0;
+ }
+ }
+
+ virtual Common::InSaveFile *openForLoading(const Common::String &filename) {
+ InFRAMSave *s = new InFRAMSave();
+ if (s->readSaveGame(filename.c_str())) {
+ return Common::wrapCompressedReadStream(s);
+ } else {
+ delete s;
+ return 0;
+ }
+ }
+
+ virtual bool removeSavefile(const Common::String &filename) {
+ return ::fram_deleteSaveGame(filename.c_str());
+ }
+
+ virtual Common::StringList listSavefiles(const Common::String &pattern);
+};
+
+
+#endif
+
Property changes on: scummvm/trunk/backends/platform/n64/framfs_save_manager.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64_base.cpp 2010-01-07 15:50:58 UTC (rev 47125)
+++ scummvm/trunk/backends/platform/n64/osys_n64_base.cpp 2010-01-07 16:07:22 UTC (rev 47126)
@@ -26,6 +26,7 @@
#include "osys_n64.h"
#include "pakfs_save_manager.h"
+#include "framfs_save_manager.h"
#include "backends/fs/n64/n64-fs-factory.h"
extern uint8 _romfs; // Defined by linker (used to calculate position of romfs image)
@@ -55,19 +56,6 @@
// Init PI interface
PI_Init();
- // Init Controller Pak
- initPakFs();
-
- // Use the first controller pak found
- uint8 ctrl_num;
- for (ctrl_num = 0; ctrl_num < 4; ctrl_num++) {
- int8 pak_type = identifyPak(ctrl_num);
- if (pak_type == 1) {
- loadPakData(ctrl_num);
- break;
- }
- }
-
// Screen size
_screenWidth = 320;
_screenHeight = 240;
@@ -164,8 +152,28 @@
ConfMan.setBool("FM_medium_quality", true);
ConfMan.set("gui_theme", "modern"); // In case of modern theme being present, use it.
- _savefile = new PAKSaveManager();
+ FRAM_Init();
+ if (FRAM_Detect()) { // Use FlashRAM
+ initFramFS();
+ _savefile = new FRAMSaveManager();
+ } else { // Use PakFS
+ // Init Controller Pak
+ initPakFs();
+
+ // Use the first controller pak found
+ uint8 ctrl_num;
+ for (ctrl_num = 0; ctrl_num < 4; ctrl_num++) {
+ int8 pak_type = identifyPak(ctrl_num);
+ if (pak_type == 1) {
+ loadPakData(ctrl_num);
+ break;
+ }
+ }
+
+ _savefile = new PAKSaveManager();
+ }
+
_mixer = new Audio::MixerImpl(this);
_mixer->setReady(false);
Modified: scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp 2010-01-07 15:50:58 UTC (rev 47125)
+++ scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp 2010-01-07 16:07:22 UTC (rev 47126)
@@ -24,7 +24,7 @@
#include "pakfs_save_manager.h"
-bool deleteSaveGame(const char *filename) {
+bool pakfs_deleteSaveGame(const char *filename) {
int res = removeFileOnPak(filename);
flushCurrentPakData();
Modified: scummvm/trunk/backends/platform/n64/pakfs_save_manager.h
===================================================================
--- scummvm/trunk/backends/platform/n64/pakfs_save_manager.h 2010-01-07 15:50:58 UTC (rev 47125)
+++ scummvm/trunk/backends/platform/n64/pakfs_save_manager.h 2010-01-07 16:07:22 UTC (rev 47126)
@@ -28,7 +28,7 @@
#include <pakfs.h> // N64 PakFS library
-bool deleteSaveGame(const char *filename);
+bool pakfs_deleteSaveGame(const char *filename);
class InPAKSave : public Common::InSaveFile {
private:
@@ -39,7 +39,7 @@
bool seek(int32 offs, int whence);
public:
- InPAKSave() : fd(0) { }
+ InPAKSave() : fd(NULL) { }
~InPAKSave() {
if (fd != NULL)
@@ -72,7 +72,7 @@
public:
uint32 write(const void *buf, uint32 cnt);
- OutPAKSave(const char *_filename) {
+ OutPAKSave(const char *_filename) : fd(NULL) {
fd = pakfs_open(_filename, "w");
}
@@ -85,7 +85,10 @@
}
bool err() const {
- return pakfs_error(fd);
+ if (fd)
+ return (pakfs_error(fd) == 1);
+ else
+ return true;
}
void clearErr() {
pakfs_clearerr(fd);
@@ -99,7 +102,13 @@
public:
virtual Common::OutSaveFile *openForSaving(const Common::String &filename) {
- return Common::wrapCompressedWriteStream(new OutPAKSave(filename.c_str()));
+ OutPAKSave *s = new OutPAKSave(filename.c_str());
+ if (!s->err()) {
+ return Common::wrapCompressedWriteStream(s);
+ } else {
+ delete s;
+ return NULL;
+ }
}
virtual Common::InSaveFile *openForLoading(const Common::String &filename) {
@@ -113,7 +122,7 @@
}
virtual bool removeSavefile(const Common::String &filename) {
- return ::deleteSaveGame(filename.c_str());
+ return ::pakfs_deleteSaveGame(filename.c_str());
}
virtual Common::StringList listSavefiles(const Common::String &pattern);
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