[Scummvm-cvs-logs] SF.net SVN: scummvm:[46777] scummvm/trunk

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Wed Dec 30 23:56:22 CET 2009


Revision: 46777
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46777&view=rev
Author:   Hkz
Date:     2009-12-30 22:56:19 +0000 (Wed, 30 Dec 2009)

Log Message:
-----------
remove bad hackery caused by n64 port and avoid polluting StdioStream using a custom Stream subclass

Modified Paths:
--------------
    scummvm/trunk/backends/fs/n64/n64-fs.cpp
    scummvm/trunk/backends/fs/stdiostream.cpp
    scummvm/trunk/backends/module.mk
    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/portdefs.h
    scummvm/trunk/common/debug.cpp
    scummvm/trunk/common/util.cpp
    scummvm/trunk/graphics/colormasks.h

Added Paths:
-----------
    scummvm/trunk/backends/fs/n64/romfsstream.cpp
    scummvm/trunk/backends/fs/n64/romfsstream.h

Modified: scummvm/trunk/backends/fs/n64/n64-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/n64/n64-fs.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/fs/n64/n64-fs.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -23,12 +23,10 @@
 #ifdef __N64__
 
 #include "backends/fs/abstract-fs.h"
-#include "backends/fs/stdiostream.h"
+#include "backends/fs/n64/romfsstream.h"
 
 #include <sys/param.h>
-
 #include <unistd.h>
-
 #include <n64utils.h>
 
 #define	ROOT_PATH	"/"
@@ -202,11 +200,11 @@
 }
 
 Common::SeekableReadStream *N64FilesystemNode::createReadStream() {
-	return StdioStream::makeFromPath(getPath(), false);
+	return RomfsStream::makeFromPath(getPath(), false);
 }
 
 Common::WriteStream *N64FilesystemNode::createWriteStream() {
-	return StdioStream::makeFromPath(getPath(), true);
+	return RomfsStream::makeFromPath(getPath(), true);
 }
 
 #endif //#ifdef __N64__

Added: scummvm/trunk/backends/fs/n64/romfsstream.cpp
===================================================================
--- scummvm/trunk/backends/fs/n64/romfsstream.cpp	                        (rev 0)
+++ scummvm/trunk/backends/fs/n64/romfsstream.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -0,0 +1,86 @@
+/* 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.
+ *
+ */
+
+#ifdef __N64__
+
+#include <romfs.h>
+#include "backends/fs/n64/romfsstream.h"
+
+RomfsStream::RomfsStream(void *handle) : _handle(handle) {
+	assert(handle);
+}
+
+RomfsStream::~RomfsStream() {
+	romfs_close((ROMFILE *)_handle);
+}
+
+bool RomfsStream::err() const {
+	return romfs_error((ROMFILE *)_handle) != 0;
+}
+
+void RomfsStream::clearErr() {
+	romfs_clearerr((ROMFILE *)_handle);
+}
+
+bool RomfsStream::eos() const {
+	return romfs_eof((ROMFILE *)_handle) != 0;
+}
+
+int32 RomfsStream::pos() const {
+	return romfs_tell((ROMFILE *)_handle);
+}
+
+int32 RomfsStream::size() const {
+	int32 oldPos = romfs_tell((ROMFILE *)_handle);
+	romfs_seek((ROMFILE *)_handle, 0, SEEK_END);
+	int32 length = romfs_tell((ROMFILE *)_handle);
+	romfs_seek((ROMFILE *)_handle, oldPos, SEEK_SET);
+
+	return length;
+}
+
+bool RomfsStream::seek(int32 offs, int whence) {
+	return romfs_seek((ROMFILE *)_handle, offs, whence) == 0;
+}
+
+uint32 RomfsStream::read(void *ptr, uint32 len) {
+	return romfs_read((byte *)ptr, 1, len, (ROMFILE *)_handle);
+}
+
+uint32 RomfsStream::write(const void *ptr, uint32 len) {
+	return romfs_write(ptr, 1, len, (ROMFILE *)_handle);
+}
+
+bool RomfsStream::flush() {
+	return romfs_flush((ROMFILE *)_handle) == 0;
+}
+
+RomfsStream *RomfsStream::makeFromPath(const Common::String &path, bool writeMode) {
+	ROMFILE *handle = romfs_open(path.c_str(), writeMode ? "wb" : "rb");
+
+	if (handle)
+		return new RomfsStream(handle);
+	return 0;
+}
+
+#endif /* __N64__ */
+


Property changes on: scummvm/trunk/backends/fs/n64/romfsstream.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/backends/fs/n64/romfsstream.h
===================================================================
--- scummvm/trunk/backends/fs/n64/romfsstream.h	                        (rev 0)
+++ scummvm/trunk/backends/fs/n64/romfsstream.h	2009-12-30 22:56:19 UTC (rev 46777)
@@ -0,0 +1,59 @@
+/* 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 BACKENDS_FS_ROMFSSTREAM_H
+#define BACKENDS_FS_ROMFSSTREAM_H
+
+#include "common/scummsys.h"
+#include "common/noncopyable.h"
+#include "common/stream.h"
+#include "common/str.h"
+
+class RomfsStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable {
+protected:
+	/** File handle to the actual file. */
+	void *_handle;
+
+public:
+	/**
+	 * Given a path, invokes fopen on that path and wrap the result in a
+	 * RomfsStream instance.
+	 */
+	static RomfsStream *makeFromPath(const Common::String &path, bool writeMode);
+
+	RomfsStream(void *handle);
+	virtual ~RomfsStream();
+
+	virtual bool err() const;
+	virtual void clearErr();
+	virtual bool eos() const;
+
+	virtual uint32 write(const void *dataPtr, uint32 dataSize);
+	virtual bool flush();
+
+	virtual int32 pos() const;
+	virtual int32 size() const;
+	virtual bool seek(int32 offs, int whence = SEEK_SET);
+	virtual uint32 read(void *dataPtr, uint32 dataSize);
+};
+
+#endif


Property changes on: scummvm/trunk/backends/fs/n64/romfsstream.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/backends/fs/stdiostream.cpp
===================================================================
--- scummvm/trunk/backends/fs/stdiostream.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/fs/stdiostream.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -25,28 +25,6 @@
 
 #include "backends/fs/stdiostream.h"
 
-#ifdef __N64__
-	#include <romfs.h> 
-
-	#undef feof
-	#undef clearerr
-	#undef ferror
-
-	#undef FILE
-	#define FILE ROMFILE
-
-	#define fopen(name, mode)					romfs_open(name, mode)
-	#define fclose(handle)						romfs_close(handle)
-	#define fread(ptr, size, items, file)		romfs_read(ptr, size, items, file)
-	#define fwrite(ptr, size, items, file)		romfs_write(ptr, size, items, file)
-	#define feof(handle)						romfs_eof(handle)
-	#define ftell(handle)						romfs_tell(handle)
-	#define fseek(handle, offset, whence)		romfs_seek(handle, offset, whence)
-	#define clearerr(handle)					romfs_clearerr(handle)
-	#define fflush(file)						romfs_flush(file)
-	#define ferror(handle)						romfs_error(handle)
-#endif
-
 StdioStream::StdioStream(void *handle) : _handle(handle) {
 	assert(handle);
 }

Modified: scummvm/trunk/backends/module.mk
===================================================================
--- scummvm/trunk/backends/module.mk	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/module.mk	2009-12-30 22:56:19 UTC (rev 46777)
@@ -16,6 +16,7 @@
 	fs/windows/windows-fs-factory.o \
 	fs/wii/wii-fs-factory.o \
 	fs/n64/n64-fs-factory.o \
+	fs/n64/romfsstream.o \
 	keymapper/action.o \
 	keymapper/keymap.o \
 	keymapper/keymapper.o \

Modified: scummvm/trunk/backends/platform/n64/Makefile
===================================================================
--- scummvm/trunk/backends/platform/n64/Makefile	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/platform/n64/Makefile	2009-12-30 22:56:19 UTC (rev 46777)
@@ -52,7 +52,7 @@
 
 ENABLED=STATIC_PLUGIN
 
-#ENABLE_SCUMM=$(ENABLED)
+ENABLE_SCUMM=$(ENABLED)
 #ENABLE_SKY=$(ENABLED)
 #ENABLE_SCI=$(ENABLED)
 #ENABLE_GOB=$(ENABLED)
@@ -62,7 +62,7 @@
 #ENABLE_AGI = $(ENABLED)
 #ENABLE_QUEEN = $(ENABLED)
 #ENABLE_MADE = $(ENABLED)
-ENABLE_SAGA = $(ENABLED)
+#ENABLE_SAGA = $(ENABLED)
 
 OBJS :=	nintendo64.o osys_n64_base.o osys_n64_events.o osys_n64_utilities.o pakfs_save_manager.o
 

Modified: scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64_base.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/platform/n64/osys_n64_base.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -22,6 +22,8 @@
 
 #include <romfs.h>
 
+#include <malloc.h> // Required for memalign
+
 #include "osys_n64.h"
 #include "pakfs_save_manager.h"
 #include "backends/fs/n64/n64-fs-factory.h"

Modified: scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/platform/n64/pakfs_save_manager.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -21,10 +21,9 @@
  */
 
 #include <n64utils.h>
+
 #include "pakfs_save_manager.h"
 
-static bool matches(const char *glob, const char *name);
-
 bool deleteSaveGame(const char *filename) {
 	int res = removeFileOnPak(filename);
 	flushCurrentPakData();
@@ -56,11 +55,14 @@
 	PAKDIR *dirp = pakfs_opendir();
 	pakfs_dirent *dp;
 	Common::StringList list;
+	Common::String *fname;
 
 	while ((dp = pakfs_readdir(dirp)) != NULL) {
-		if (matches(pattern.c_str(), dp->entryname))
+		fname = new Common::String(dp->entryname);
+		if (fname->matchString(pattern, false, false))
 			list.push_back(dp->entryname);
 
+		delete fname;
 		free(dp);
 	}
 
@@ -69,24 +71,3 @@
 	return list;
 }
 
-static bool matches(const char *glob, const char *name) {
-	while (*glob)
-		if (*glob == '*') {
-			while (*glob == '*')
-				glob++;
-			do {
-				if ((*name == *glob || *glob == '?') &&
-				        matches(glob, name))
-					return true;
-			} while (*name++);
-			return false;
-		} else if (!*name)
-			return false;
-		else if (*glob == '?' || *glob == *name) {
-			glob++;
-			name++;
-		} else
-			return false;
-	return !*name;
-}
-

Modified: scummvm/trunk/backends/platform/n64/portdefs.h
===================================================================
--- scummvm/trunk/backends/platform/n64/portdefs.h	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/backends/platform/n64/portdefs.h	2009-12-30 22:56:19 UTC (rev 46777)
@@ -29,15 +29,11 @@
 #include <n64utils.h>
 
 #include <sys/types.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
 #include <stdarg.h>
-#include <assert.h>
+#include <string.h>
+#include <stdio.h>
 #include <ctype.h>
 #include <math.h>
-#include <malloc.h>
 
 #undef assert
 #define assert(x)  ((x) ? 0 : (print_error("["#x"] (%s:%d)", __FILE__, __LINE__)))

Modified: scummvm/trunk/common/debug.cpp
===================================================================
--- scummvm/trunk/common/debug.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/common/debug.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -45,15 +45,6 @@
 	#define fflush(file)		DS::std_fflush(file)
 #endif
 
-#ifdef __N64__
-	#include <n64utils.h>
-
-	#define fputs(str, file)	asm("nop");
-	#define fflush(a)			asm("nop");
-	#define OutputDebugString	addLineTextLayer
-#endif
-
-
 // TODO: Move gDebugLevel into namespace Common.
 int gDebugLevel = -1;
 

Modified: scummvm/trunk/common/util.cpp
===================================================================
--- scummvm/trunk/common/util.cpp	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/common/util.cpp	2009-12-30 22:56:19 UTC (rev 46777)
@@ -46,10 +46,6 @@
 	#define fputs(str, file)	DS::std_fwrite(str, strlen(str), 1, file)
 #endif
 
-#ifdef __N64__
-	#define fputs(str, file)	asm("nop");
-#endif
-
 namespace Common {
 
 StringTokenizer::StringTokenizer(const String &str, const String &delimiters) : _str(str), _delimiters(delimiters) {

Modified: scummvm/trunk/graphics/colormasks.h
===================================================================
--- scummvm/trunk/graphics/colormasks.h	2009-12-30 21:54:45 UTC (rev 46776)
+++ scummvm/trunk/graphics/colormasks.h	2009-12-30 22:56:19 UTC (rev 46777)
@@ -118,11 +118,12 @@
 		kBlueBits   = 5,
 
 #ifdef __N64__
+		/* Nintendo 64 uses a BGR555 color format for 16bit display */
 		kAlphaShift = 0,
 		kRedShift   = kBlueBits+kGreenBits+1,
 		kGreenShift = kBlueBits + 1,
 		kBlueShift  = 1,
-#else
+#else   /* RGB555 */
 		kAlphaShift = 0,
 		kRedShift   = kGreenBits+kBlueBits,
 		kGreenShift = kBlueBits,


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