diff -ur release-0-13-0/backends/events/default/default-events.h release-0-13-0-ps2/backends/events/default/default-events.h
--- release-0-13-0/backends/events/default/default-events.h	2009-03-01 11:27:21.000000000 -0500
+++ release-0-13-0-ps2/backends/events/default/default-events.h	2009-03-01 11:45:03.000000000 -0500
@@ -145,6 +145,7 @@
 	virtual int shouldQuit() const { return _shouldQuit; }
 	virtual int shouldRTL() const { return _shouldRTL; }
 	virtual void resetRTL() { _shouldRTL = false; }
+	virtual void resetQuit() { _shouldQuit = false; }
 	
 #ifdef ENABLE_KEYMAPPER
 	virtual Common::Keymapper *getKeymapper() { return _keymapper; }
diff -ur release-0-13-0/backends/fs/ps2/ps2-fs.cpp release-0-13-0-ps2/backends/fs/ps2/ps2-fs.cpp
--- release-0-13-0/backends/fs/ps2/ps2-fs.cpp	2009-03-01 11:27:25.000000000 -0500
+++ release-0-13-0-ps2/backends/fs/ps2/ps2-fs.cpp	2009-03-01 12:14:32.000000000 -0500
@@ -33,6 +33,10 @@
 #include "backends/platform/ps2/systemps2.h"
 #include "backends/platform/ps2/ps2debug.h"
 
+#include <fileXio_rpc.h>
+
+#include "ps2temp.h"
+
 #define DEFAULT_MODE (FIO_S_IRUSR | FIO_S_IWUSR | FIO_S_IRGRP | FIO_S_IWGRP | FIO_S_IROTH | FIO_S_IWOTH)
 
 extern AsyncFio fio;
@@ -52,10 +56,12 @@
 	Common::String _path;
 	bool _isDirectory;
 	bool _isRoot;
+	bool _isHere;
+	bool _verified;
 
 private:
-	char *getDeviceDescription(const char *path) const;
-	bool getDirectoryFlag(const char *path);
+	char *getDeviceDescription() const;
+	void doverify();
 
 public:
 	/**
@@ -76,23 +82,28 @@
 	 */
 	Ps2FilesystemNode(const Ps2FilesystemNode *node);
 
-	virtual bool exists(void) const;
-
 	virtual Common::String getDisplayName() const { return _displayName; }
 	virtual Common::String getName() const { return _displayName; }
 	virtual Common::String getPath() const { return _path; }
 
+	virtual bool exists() const {
+		// printf("%s : is %d\n", _path.c_str(), _isHere);
+		return _isHere;
+	}
+
 	virtual bool isDirectory() const {
+		// printf("%s : dir %d\n", _path.c_str(), _isDirectory);
 		return _isDirectory;
 	}
 
 	virtual bool isReadable() const {
-		return exists();
+		return _isHere;
 	}
 
 	virtual bool isWritable() const {
-		// The only writable device on the ps2 is the memory card
-		return false;
+		if (strncmp(_path.c_str(), "cdfs", 4)==0)
+			return false;
+		return true; // exists(); // creating ?
 	}
 
 	virtual AbstractFSNode *clone() const { return new Ps2FilesystemNode(this); }
@@ -102,58 +113,108 @@
 
 	virtual Common::SeekableReadStream *openForReading();
 	virtual Common::WriteStream *openForWriting();
+
+	int getDev() { return 0; };
 };
 
+const char *_lastPathComponent(const Common::String &str) {
+	if (str.empty())
+		return "";
+
+	const char *start = str.c_str();
+	const char *cur = start + str.size() - 2;
+
+	while (cur >= start && *cur != '/' && *cur != ':') {
+		--cur;
+	}
+
+	cur++;
+
+	// printf("lastPathComponent path=%s token=%s\n", start, cur);
+
+	return cur;
+}
+
 Ps2FilesystemNode::Ps2FilesystemNode() {
+	printf("NEW FSNODE()\n");
+
+	_isHere = true;
 	_isDirectory = true;
 	_isRoot = true;
-	_displayName = "PlayStation 2";
+	_verified = false;
+	_displayName = Common::String("PlayStation 2");
 	_path = "";
 }
 
 Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) {
+	printf("NEW FSNODE(%s)\n", path.c_str());
+
 	_path = path;
-	_isDirectory = true;
-	if (strcmp(path.c_str(), "") == 0) {
+
+	if (path.empty()) {
+		_isHere = true;
+		_isDirectory = true; /* root is always a dir */
 		_isRoot = true;
 		_displayName = Common::String("PlayStation 2");
+		_verified = true;
+	} else if (path.lastChar() == ':') {
+		_isHere = true;
+		_isDirectory = true; /* devs are always a dir */
+		_isRoot = false;
+		_displayName = getDeviceDescription();
+		_verified = true;
 	} else {
+		_verified = false;
+		doverify();
+		if (!_isHere)
+			return;
+
+		_displayName = _lastPathComponent(_path);
+
+		if (_isDirectory && _path.lastChar() != '/')
+			_path+= '/';
+
 		_isRoot = false;
-		const char *dsplName = NULL, *pos = path.c_str();
-		while (*pos)
-			if (*pos++ == '/')
-				dsplName = pos;
-		if (dsplName)
-			_displayName = Common::String(dsplName);
-		else
-			_displayName = getDeviceDescription(path.c_str());
 	}
 }
 
 Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path, bool verify) {
+	printf("NEW FSNODE(%s, %d)\n", path.c_str(), verify);
+
 	_path = path;
 
-	if (strcmp(path.c_str(), "") == 0) {
-		_isRoot = true; /* root is always a dir*/
+	if (path.empty()) {
+		_isHere = true;
+		_isDirectory = true; /* root is always a dir */
+		_isRoot = true;
 		_displayName = Common::String("PlayStation 2");
-		_isDirectory = true;
-	} else {
+		_verified = true;
+	} else if (path.lastChar() == ':') {
+		_isHere = true;
+		_isDirectory = true; /* devs are always a dir */
 		_isRoot = false;
-		const char *dsplName = NULL, *pos = path.c_str();
-		while (*pos)
-			if (*pos++ == '/')
-				dsplName = pos;
-
-		if (dsplName) {
-			_displayName = Common::String(dsplName);
-			if (verify)
-				_isDirectory = getDirectoryFlag(path.c_str());
-			else
-				_isDirectory = false;
+		_displayName = getDeviceDescription();
+		_verified = true;
+	} else {
+		_verified = false;
+		if (verify) {
+			doverify();
+
+			if (!_isHere)
+				return;
+
 		} else {
-			_displayName = getDeviceDescription(path.c_str());
-			_isDirectory = true; /* devices are always dir */
+			_verified = false;
+			_isDirectory = false;
+			_isHere = false; // true
 		}
+
+		_displayName = _lastPathComponent(_path);
+
+		if (_isDirectory && _path.lastChar() != '/')
+			_path+= '/';
+
+		_isRoot = false;
 	}
 }
 
@@ -162,61 +223,149 @@
 	_isDirectory = node->_isDirectory;
 	_path = node->_path;
 	_isRoot = node->_isRoot;
+	_isHere = node->_isHere;
+	_verified = node->_verified;
 }
 
-bool Ps2FilesystemNode::exists(void) const {
+void Ps2FilesystemNode::doverify(void) {
+	PS2Device medium;
+	int fd;
 
-	dbg_printf("Ps2FilesystemNode::exists: path \"%s\": ", _path.c_str());
+	if (_verified)
+		return;
 
-	if (_path[4] != ':') { // don't bother for relative path... they always fail on PS2!
-		dbg_printf("NO, relative path\n");
-		return false;
+	_verified = true;
+
+	printf(" verify: %s -> ", _path.c_str());
+
+#if 0
+	if (_path.empty()) {
+		printf("PlayStation 2 Root !\n");
+		_verified = true;
+		return;
 	}
 
-	if (_path[0] == 'h') { // bypass host
-		dbg_printf("NO, host device ignored\n");
-		return false;
+	if (_path.lastChar() == ':') {
+		printf("Dev: %s\n", _path.c_str());
+		_verified = true;
+		return;
 	}
+#endif
 
-	int fd = fio.open(_path.c_str(), O_RDONLY);
-	if (fd == -EISDIR) {
-		dbg_printf("YES, directory\n");
-		return true;
-	} else if (fd >= 0) {
-		dbg_printf("YES, file\n");
-		fio.close(fd);
-		return true;
+	if (_path[3] != ':' && _path[4] != ':') {
+		printf("relative path !\n");
+		_isHere = false;
+		_isDirectory = false;
+		return;
 	}
 
-	printf("NO, not found\n");
-	return false;
-}
+	medium = _getDev(_path);
+	if (medium == ERR_DEV) {
+		_isHere = false;
+		_isDirectory = false;
+		return;
+	} 
 
-bool Ps2FilesystemNode::getDirectoryFlag(const char *path) {
-	if (strncmp(path, "host:", 5) == 0)
-		return true;	// Can't get listings from host: right now
+	switch (medium) {
+#if 0
+	case HD_DEV: /*stat*/
+	case USB_DEV:
+		iox_stat_t stat;
 
-	int fd = fio.open(_path.c_str(), O_RDONLY);
+		fileXioGetStat(_path.c_str(), &stat);
+		fileXioWaitAsync(FXIO_WAIT, &fd);
 
-	if (fd == -EISDIR) {
-		dbg_printf(" romeo : new node [ %s ] is a dir\n", path);
-		return true;
-	} else if (fd >=0) {
-		dbg_printf(" romeo : new node [ %s ] is -not- a dir (%d)\n", path, fd);
+		if (!fd) {
+			printf("  yes [stat]\n");
+			return true;
+		}
+	break;
+#endif
+
+	case CD_DEV: /*no stat*/
+	case HD_DEV:
+	case USB_DEV:
+	case HOST_DEV:
+	case MC_DEV:
+#if 1
+	fd = fio.open(_path.c_str(), O_RDONLY);
+
+	printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);
+
+	if (fd >=0) {
 		fio.close(fd);
-	} else
-		dbg_printf(" romeo : new node [ %s ] is -not- (%d)\n", path, fd);
+		printf("  yes [open]\n");
+		_isHere = true;
+		if (medium==MC_DEV && _path.lastChar()=='/')
+			_isDirectory = true;
+		else
+			_isDirectory = false;
+		return;
+	}
 
-	return false;
+	fd = fio.dopen(_path.c_str());
+	if (fd >=0) {
+		fio.dclose(fd);
+		printf("  yes [dopen]\n");
+		_isHere = true;
+		_isDirectory = true;
+		return;
+	}
+
+#else
+	fileXioOpen(_path.c_str(), O_RDONLY, DEFAULT_MODE);
+	fileXioWaitAsync(FXIO_WAIT, &fd);
+	if (fd>=0) {
+		fileXioClose(fd);
+		fileXioWaitAsync(FXIO_WAIT, &fd);
+		return true;
+	}
+
+	fileXioDopen(_path.c_str());
+	fileXioWaitAsync(FXIO_WAIT, &fd);
+	if (fd>=0) {
+		fileXioDclose(fd);
+		fileXioWaitAsync(FXIO_WAIT, &fd);
+		return true;
+	}
+#endif
+	break;
+	case ERR_DEV:
+		_isHere = false;
+		_isDirectory = false;
+	break;
+	}
+
+	_isHere = false;
+	_isDirectory = false;
+
+	printf("  no\n");
+	return;
 }
 
 AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const {
+
+	printf("getChild : %s\n", n.c_str());
+
 	if (!_isDirectory)
 		return NULL;
 
-	char listDir[256];
-	sprintf(listDir, "%s/", _path.c_str());
-	int fd = fio.dopen(listDir);
+	if (_isRoot) {
+		if (n.lastChar() == ':')
+			return new Ps2FilesystemNode(n);
+		else
+			return NULL;
+	}
+
+	return new Ps2FilesystemNode(_path+n, 1);
+
+/*
+	int fd;
+ 
+	if (_path == "pfs0:")
+		fd = fio.dopen("pfs0:/");
+	else
+		fd = fio.dopen(_path.c_str());
 
 	if (fd >= 0) {
 		iox_dirent_t dirent;
@@ -225,15 +374,18 @@
 			if (strcmp(n.c_str(), dirent.name) == 0) {
 				Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
 
+				dirEntry->_isHere = true;
 				dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
 				dirEntry->_isRoot = false;
 
 				dirEntry->_path = _path;
-				dirEntry->_path += "/";
 				dirEntry->_path += dirent.name;
-
+				if (dirEntry->_isDirectory && dirEntry->_path.lastChar() != '/')
+					dirEntry->_path += '/';
 				dirEntry->_displayName = dirent.name;
 
+				dirEntry->_verified = true;
+
 				fio.dclose(fd);
 				return dirEntry;
 			}
@@ -242,107 +394,118 @@
 	}
 
 	return NULL;
+*/
 }
 
 bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
 	//TODO: honor the hidden flag
 
+	// printf("getChildren\n");
+
 	if (!_isDirectory)
 		return false;
 
 	if (_isRoot) {
-		Ps2FilesystemNode dirEntry;
-		dirEntry._isDirectory = true;
-		dirEntry._isRoot = false;
-		dirEntry._path = "cdfs:";
-		dirEntry._displayName = getDeviceDescription(dirEntry._path.c_str());
-		list.push_back(new Ps2FilesystemNode(&dirEntry));
-
-		if (g_systemPs2->hddPresent()) {
-			dirEntry._path = "pfs0:";
-			dirEntry._displayName = getDeviceDescription(dirEntry._path.c_str());
-			list.push_back(new Ps2FilesystemNode(&dirEntry));
-		}
+		list.push_back(new Ps2FilesystemNode("cdfs:"));
+
+		if (g_systemPs2->hddPresent())
+			list.push_back(new Ps2FilesystemNode("pfs0:"));
+
+		if (g_systemPs2->usbMassPresent())
+			list.push_back(new Ps2FilesystemNode("mass:"));
+
+		if (g_systemPs2->getBootDevice()==HOST_DEV || g_systemPs2->netPresent())
+			list.push_back(new Ps2FilesystemNode("host:"));
+
+		if (g_systemPs2->mcPresent())
+			list.push_back(new Ps2FilesystemNode("mc0:"));
 
-		if (g_systemPs2->usbMassPresent()) {
-			dirEntry._path = "mass:";
-			dirEntry._displayName = getDeviceDescription(dirEntry._path.c_str());
-			list.push_back(new Ps2FilesystemNode(&dirEntry));
-		}
 		return true;
 	} else {
-		char listDir[256];
 		int fd;
 
-		if (_path.lastChar() == '/' /* || _path.lastChar() == ':'*/)
+		if (_path == "pfs0:")
+			fd = fio.dopen("pfs0:/");
+		else
 			fd = fio.dopen(_path.c_str());
-		else {
-			sprintf(listDir, "%s/", _path.c_str());
-			fd = fio.dopen(listDir);
-		}
+
+		// printf("dopen = %d\n", fd);
 
 		if (fd >= 0) {
 			iox_dirent_t dirent;
 			Ps2FilesystemNode dirEntry;
 			int dreadRes;
 			while ((dreadRes = fio.dread(fd, &dirent)) > 0) {
+
 				if (dirent.name[0] == '.')
 					continue; // ignore '.' and '..'
-				if (((mode == Common::FSNode::kListDirectoriesOnly) && (dirent.stat.mode & FIO_S_IFDIR)) ||
-					((mode == Common::FSNode::kListFilesOnly) && !(dirent.stat.mode & FIO_S_IFDIR)) ||
-					(mode == Common::FSNode::kListAll)) {
 
+				if ( (mode == Common::FSNode::kListAll) ||
+
+					((mode == Common::FSNode::kListDirectoriesOnly) && 
+					 (dirent.stat.mode & FIO_S_IFDIR)) ||
+
+				    ((mode == Common::FSNode::kListFilesOnly) &&
+					 !(dirent.stat.mode & FIO_S_IFDIR)) ) {
+
+					dirEntry._isHere = true;
 					dirEntry._isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
 					dirEntry._isRoot = false;
 
 					dirEntry._path = _path;
-					if (_path.lastChar() != '/')
-						dirEntry._path += "/";
 					dirEntry._path += dirent.name;
-
+					if (dirEntry._isDirectory && dirEntry._path.lastChar() != '/')
+						dirEntry._path += '/';
 					dirEntry._displayName = dirent.name;
 
+					dirEntry._verified = true;
+
 					list.push_back(new Ps2FilesystemNode(&dirEntry));
 				}
 			}
 			fio.dclose(fd);
 			return true;
-		} else
-			return false;
+		}
 	}
+	return false;
 }
 
 AbstractFSNode *Ps2FilesystemNode::getParent() const {
+	// printf("Ps2FilesystemNode::getParent : path = %s\n", _path.c_str());
+
 	if (_isRoot)
-		return new Ps2FilesystemNode(this);
+		return new Ps2FilesystemNode(this); // FIXME : 0 ???
 
-	const char *slash = NULL;
-	const char *cnt = _path.c_str();
+	if (_path.lastChar() == ':') // devs
+		return new Ps2FilesystemNode(); // N: default is root
 
-	while (*cnt) {
-		if (*cnt == '/')
-			slash = cnt;
-		cnt++;
-	}
+	const char *start = _path.c_str();
+	const char *end = _lastPathComponent(_path);
 
-	if (slash)
-		return new Ps2FilesystemNode(Common::String(_path.c_str(), slash - _path.c_str()));
-	else
-		return new Ps2FilesystemNode();
-}
+	Common::String str(start, end - start);
+	// printf("  parent = %s\n", str.c_str());
 
+	return new Ps2FilesystemNode(str, true);
+}
 
-char *Ps2FilesystemNode::getDeviceDescription(const char *path) const {
-	if (strncmp(path, "cdfs", 4) == 0)
+char *Ps2FilesystemNode::getDeviceDescription() const {
+	if (strncmp(_path.c_str(), "cdfs", 4) == 0)
 		return "DVD Drive";
-	else if (strncmp(path, "mass", 4) == 0)
-		return "USB Mass Storage";
-	else
+	else if (strncmp(_path.c_str(), "pfs0", 4) == 0)
 		return "Harddisk";
+	else if (strncmp(_path.c_str(), "mass", 4) == 0)
+		return "USB Mass Storage";
+	else if (strncmp(_path.c_str(), "host", 4) == 0)
+		return "Host";
+	else if (strncmp(_path.c_str(), "mc0", 3) == 0)
+		return "Memory Card";
+	else 
+		return "WTF ???";
 }
 
 Common::SeekableReadStream *Ps2FilesystemNode::openForReading() {
-	return StdioStream::makeFromPath(getPath().c_str(), false);
+	Common::SeekableReadStream *ss = StdioStream::makeFromPath(getPath().c_str(), false);
+	return ss;
 }
 
 Common::WriteStream *Ps2FilesystemNode::openForWriting() {
diff -ur release-0-13-0/backends/fs/ps2/ps2-fs-factory.cpp release-0-13-0-ps2/backends/fs/ps2/ps2-fs-factory.cpp
--- release-0-13-0/backends/fs/ps2/ps2-fs-factory.cpp	2009-03-01 11:27:25.000000000 -0500
+++ release-0-13-0-ps2/backends/fs/ps2/ps2-fs-factory.cpp	2009-03-01 11:56:46.000000000 -0500
@@ -37,18 +37,6 @@
 }
 
 AbstractFSNode *Ps2FilesystemFactory::makeFileNodePath(const Common::String &path) const {
-	// return new Ps2FilesystemNode(path);
-
-	Ps2FilesystemNode *nf = new Ps2FilesystemNode(path, true);
-/*
-	int fd = fio.dopen(path.c_str());
-	if (fd < 0) {
-		nf->_isDirectory = false;
-	}
-	else {
-		fio.dclose(fd);
-	}
-*/
-	return nf; // new Ps2FilesystemNode(path, true);
+	return new Ps2FilesystemNode(path, true);
 }
 #endif
diff -ur release-0-13-0/backends/fs/stdiostream.cpp release-0-13-0-ps2/backends/fs/stdiostream.cpp
--- release-0-13-0/backends/fs/stdiostream.cpp	2009-03-01 11:27:25.000000000 -0500
+++ release-0-13-0-ps2/backends/fs/stdiostream.cpp	2009-03-01 15:16:02.000000000 -0500
@@ -40,14 +40,16 @@
 
 	#define fopen(a, b)			ps2_fopen(a, b)
 	#define fclose(a)			ps2_fclose(a)
-	#define fseek(a, b, c)			ps2_fseek(a, b, c)
+	#define fseek(a, b, c)		ps2_fseek(a, b, c)
 	#define ftell(a)			ps2_ftell(a)
 	#define feof(a)				ps2_feof(a)
-	#define fread(a, b, c, d)		ps2_fread(a, b, c, d)
-	#define fwrite(a, b, c, d)		ps2_fwrite(a, b, c, d)
+	#define fread(a, b, c, d)	ps2_fread(a, b, c, d)
+	#define fwrite(a, b, c, d)	ps2_fwrite(a, b, c, d)
 
-	//#define fprintf				ps2_fprintf	// used in common/util.cpp
-	//#define fflush(a)			ps2_fflush(a)	// used in common/util.cpp
+	#define fprintf				ps2_fprintf // used in common/util.cpp
+	#define fflush(a)			ps2_fflush(a)   // used in common/util.cpp
+	#define ferror(a)			ps2_ferror(a)
+	#define clearerr(a)			ps2_clearerr(a)
 
 	//#define fgetc(a)			ps2_fgetc(a)	// not used
 	//#define fgets(a, b, c)			ps2_fgets(a, b, c)	// not used
diff -ur release-0-13-0/backends/platform/ps2/asyncfio.cpp release-0-13-0-ps2/backends/platform/ps2/asyncfio.cpp
--- release-0-13-0/backends/platform/ps2/asyncfio.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/asyncfio.cpp	2009-03-01 12:04:53.000000000 -0500
@@ -58,6 +58,17 @@
 	return res;
 }
 
+int AsyncFio::open(const char *name, int ioMode, int mode) {
+	WaitSema(_ioSema);
+	checkSync();
+	int res;
+	fileXioOpen(name, ioMode, mode);
+	fileXioWaitAsync(FXIO_WAIT, &res);
+	SignalSema(_ioSema);
+	// dbg_printf("FIO: open ext(%s, %d, %d) => %d", name, ioMode, mode, res);
+    return res;
+}
+
 void AsyncFio::close(int handle) {
 	WaitSema(_ioSema);
 	checkSync();
@@ -95,6 +106,15 @@
 	SignalSema(_ioSema);
 }
 
+void AsyncFio::remove(const char *path) {
+	int res;
+	WaitSema(_ioSema);
+	checkSync();
+	fileXioRemove(path);
+	fileXioWaitAsync(FXIO_WAIT, &res);
+	SignalSema(_ioSema);
+}
+
 int AsyncFio::seek(int fd, int offset, int whence) {
 	int res;
 	WaitSema(_ioSema);
@@ -149,6 +169,16 @@
 	SignalSema(_ioSema);
 }
 
+int AsyncFio::chdir(const char *name) {
+	int res;
+	WaitSema(_ioSema);
+	checkSync();
+	fileXioChdir(name);
+	fileXioWaitAsync(FXIO_WAIT, &res);
+	SignalSema(_ioSema);
+	return res;
+}
+
 int AsyncFio::mount(const char *mountpoint, const char *mountstring, int flag) {
 	int res;
 	WaitSema(_ioSema);
diff -ur release-0-13-0/backends/platform/ps2/asyncfio.h release-0-13-0-ps2/backends/platform/ps2/asyncfio.h
--- release-0-13-0/backends/platform/ps2/asyncfio.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/asyncfio.h	2009-03-01 12:15:07.000000000 -0500
@@ -31,14 +31,17 @@
 	AsyncFio(void);
 	~AsyncFio(void);
 	int open(const char *name, int ioMode);
+	int open(const char *name, int ioMode, int mode);
 	void close(int handle);
 	void read(int fd, void *dest, unsigned int len);
 	void write(int fd, const void *src, unsigned int len);
+	void remove(const char *name);
 	int seek(int fd, int offset, int whence);
 	int mkdir(const char *name);
 	int dopen(const char *name);
 	int dread(int fd, iox_dirent_t *dest);
 	void dclose(int fd);
+	int chdir(const char *name);
 	int mount(const char *mountpoint, const char *mountstring, int flag);
 	int umount(const char *mountpoint);
 	int sync(int fd);
diff -ur release-0-13-0/backends/platform/ps2/DmaPipe.cpp release-0-13-0-ps2/backends/platform/ps2/DmaPipe.cpp
--- release-0-13-0/backends/platform/ps2/DmaPipe.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/DmaPipe.cpp	2009-03-01 12:16:48.000000000 -0500
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-0-13-0/backends/platform/ps2/DmaPipe.cpp $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-0.13.0/backends/platform/ps2/DmaPipe.cpp $
  * $Id: DmaPipe.cpp 27024 2007-05-30 21:56:52Z fingolfin $
  *
  */
diff -ur release-0-13-0/backends/platform/ps2/fileio.cpp release-0-13-0-ps2/backends/platform/ps2/fileio.cpp
--- release-0-13-0/backends/platform/ps2/fileio.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/fileio.cpp	2009-03-01 19:20:55.000000000 -0500
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-0-13-0/backends/platform/ps2/fileio.cpp $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-0.13-0/backends/platform/ps2/fileio.cpp $
  * $Id: fileio.cpp 35648 2009-01-01 15:06:43Z sev $
  *
  */
@@ -36,54 +36,31 @@
 #include "eecodyvdfs.h"
 #include "common/config-manager.h"
 #include "backends/platform/ps2/ps2debug.h"
-#include "backends/platform/ps2/savefile.h"
 #include "backends/platform/ps2/systemps2.h"
 
-#define CACHE_SIZE (2048 * 32)
-#define MAX_READ_STEP (2048 * 16)
-#define MAX_CACHED_FILES 6
-#define CACHE_READ_THRESHOLD (16 * 2048)
-#define CACHE_FILL_MIN (2048 * 24)
-#define READ_ALIGN 64	// align all reads to the size of an EE cache line
-#define READ_ALIGN_MASK (READ_ALIGN - 1)
+#define __PS2_FILE_SEMA__ 1
+// #define __PS2_FILE_DEBUG 1
+// #define __PS2_CACHE_DEBUG__ 1
+
+#define PS2_CACHE_MAX (128 * 1024)
+#define PS2_CACHE_CHK (16 * 1024)
 
 extern OSystem_PS2 *g_systemPs2;
 
-AsyncFio fio;
+uint32 _rseek;
 
-Ps2File::Ps2File(int64 cacheId) {
-	_cacheId = cacheId;
-}
+AsyncFio fio;
 
-Ps2File::~Ps2File(void) {
-}
+Ps2File::Ps2File(void) {
+	_fd = -1;
+	_fileSize = 0;
+	_filePos = 0;
+	_cacheSize = 0;
+	_cachePos = 0;
+	_eof = false;
 
-class Ps2ReadFile : public Ps2File {
-public:
-	Ps2ReadFile(int64 cacheId, bool stream);
-	virtual ~Ps2ReadFile(void);
-	virtual bool open(const char *name);
-	virtual uint32 read(void *dest, uint32 len);
-	virtual uint32 write(const void *src, uint32 len);
-	virtual uint32 tell(void);
-	virtual uint32 size(void);
-	virtual int seek(int32 offset, int origin);
-	virtual bool eof(void);
-private:
-	void cacheReadAhead(void);
-	void cacheReadSync(void);
-	int _fd, _sema;
-	uint8 *_cacheBuf;
-	bool _cacheOpRunning;
-	uint32 _filePos, _physFilePos, _cachePos;
-	uint32 _fileSize, _bytesInCache, _cacheOfs;
-
-	uint32 _readBytesBlock;
-	bool _stream;
-};
+	// _cache = (uint8 *)malloc(PS2_CACHE_MAX);
 
-Ps2ReadFile::Ps2ReadFile(int64 cacheId, bool stream) : Ps2File(cacheId) {
-	_fd = -1;
 	_cacheBuf = (uint8*)memalign(64, CACHE_SIZE);
 
 	_cacheOpRunning = 0;
@@ -91,58 +68,102 @@
 	_fileSize = _bytesInCache = _cacheOfs = 0;
 	_cacheOpRunning = false;
 	_readBytesBlock = 0;
-	_stream = stream;
+	_stream = true;
 
+#ifdef __PS2_FILE_SEMA__
 	ee_sema_t newSema;
 	newSema.init_count = 1;
 	newSema.max_count = 1;
 	_sema = CreateSema(&newSema);
 	assert(_sema >= 0);
+#endif
 }
 
-Ps2ReadFile::~Ps2ReadFile(void) {
-	if (_cacheOpRunning)
-		cacheReadSync();
-	free(_cacheBuf);
-	if (_fd >= 0)
+Ps2File::~Ps2File(void) {
+	if (_fd >= 0) {
 		fio.close(_fd);
+		uint32 r = fio.sync(_fd);
+		printf("close [%d] - sync'd = %d\n", _fd, r);
+	}
+
+	// free(_cache);
+	free(_cacheBuf);
+
+#ifdef __PS2_FILE_SEMA__
 	DeleteSema(_sema);
+#endif
 }
 
-bool Ps2ReadFile::open(const char *name) {
+bool Ps2File::open(const char *name, int mode) {
 	assert(_fd < 0);
-	_fd = fio.open(name, O_RDONLY);
+
+	_fd = fio.open(name, mode);
+
+	printf("open %s [%d]\n", name, _fd);
+
 	if (_fd >= 0) {
 		_fileSize = fio.seek(_fd, 0, SEEK_END);
-		fio.seek(_fd, 0, SEEK_SET);
+		if (mode == O_RDONLY)
+		// if (!(mode & O_APPEND))
+			fio.seek(_fd, 0, SEEK_SET);
+
+		printf("  _fileSize = %d\n", _fileSize);
+		printf("  _filePos = %d\n", _filePos);
+
 		return true;
 	} else
 		return false;
 }
 
-uint32 Ps2ReadFile::tell(void) {
+int32 Ps2File::tell(void) {
+#ifdef __PS2_FILE_SEMA__
 	WaitSema(_sema);
-	uint32 res = _filePos;
+#endif
+	int32 res = _filePos;
+#ifdef __PS2_FILE_SEMA__
 	SignalSema(_sema);
+#endif
 	return res;
 }
 
-uint32 Ps2ReadFile::size(void) {
+int32 Ps2File::size(void) {
+#ifdef __PS2_FILE_SEMA__
 	WaitSema(_sema);
-	uint32 res = _fileSize;
+#endif
+	int32 res = _fileSize;
+#ifdef __PS2_FILE_SEMA__
 	SignalSema(_sema);
+#endif
 	return res;
 }
 
-bool Ps2ReadFile::eof(void) {
+bool Ps2File::eof(void) {
+#ifdef __PS2_FILE_SEMA__
 	WaitSema(_sema);
-	bool res = (_filePos == _fileSize);
+#endif
+	bool res = _eof; // (_filePos == _fileSize);
+	// bool res = (_filePos >= _fileSize);
+#ifdef __PS2_FILE_SEMA__
 	SignalSema(_sema);
+
+	// printf(" EOF [%d] : %d of %d  -> %d\n", _fd, _filePos, _fileSize, res);
+#endif
 	return res;
 }
 
-int Ps2ReadFile::seek(int32 offset, int origin) {
+bool Ps2File::getErr(void) {
+	return _eof;
+}
+
+void Ps2File::setErr(bool err) {
+	_eof = err;
+}
+
+int Ps2File::seek(int32 offset, int origin) {
+#ifdef __PS2_FILE_SEMA__
 	WaitSema(_sema);
+#endif
+	_rseek = 0;
 	int seekDest;
 	int res = -1;
 	switch (origin) {
@@ -160,14 +181,27 @@
 			break;
 	}
 	if ((seekDest >= 0) && (seekDest <= (int)_fileSize)) {
+		// _rseek = fio.sync(_fd);
 		_filePos = seekDest;
+		// fio.seek(_fd, _filePos, SEEK_SET);
+		// fio.sync(_fd);
+		// _cacheSize = 0;
+		_eof = false;
 		res = 0;
 	}
+	else _eof = true;
+
+	// printf("seek [%d]  %d  %d\n", _fd, offset, origin);
+	// printf("  res = %d\n", res);
+
+#ifdef __PS2_FILE_SEMA__
 	SignalSema(_sema);
+#endif
+
 	return res;
 }
 
-void Ps2ReadFile::cacheReadAhead(void) {
+void Ps2File::cacheReadAhead(void) {
 	if (_cacheOpRunning) {
 		// there's already some cache read running
 		if (fio.poll(_fd)) // did it finish?
@@ -191,7 +225,7 @@
 			_cachePos = cachePosEnd = _filePos & ~READ_ALIGN_MASK;
 			assert(_filePos == _physFilePos);
 		} else {
-            uint32 cacheDiff = _filePos - _cachePos;
+            		uint32 cacheDiff = _filePos - _cachePos;
 			assert(_bytesInCache >= cacheDiff);
 			cacheDiff &= ~READ_ALIGN_MASK;
 			_bytesInCache -= cacheDiff;
@@ -201,7 +235,7 @@
 
 		if (_physFilePos != cachePosEnd) {
 			sioprintf("unexpected _physFilePos %d cache %d %d\n", _physFilePos, _cacheOfs, _bytesInCache);
-			assert(!(cachePosEnd & READ_ALIGN_MASK));
+			// assert(!(cachePosEnd & READ_ALIGN_MASK)); // romeo
 			_physFilePos = fio.seek(_fd, cachePosEnd, SEEK_SET);
 			if (_physFilePos != cachePosEnd) {
 				sioprintf("cache seek error: seek to %d instead of %d, fs = %d\n", _physFilePos, cachePosEnd, _fileSize);
@@ -223,7 +257,7 @@
 	}
 }
 
-void Ps2ReadFile::cacheReadSync(void) {
+void Ps2File::cacheReadSync(void) {
 	if (_cacheOpRunning) {
 		int res = fio.sync(_fd);
 		assert(res >= 0);
@@ -233,8 +267,30 @@
 	}
 }
 
-uint32 Ps2ReadFile::read(void *dest, uint32 len) {
+uint32 Ps2File::read(void *dest, uint32 len) {	
+	// uint32 r=0, d=0, ds=0, sz=0;
+#ifdef __PS2_FILE_SEMA__
 	WaitSema(_sema);
+#endif
+
+#ifdef __PS2_FILE_DEBUG__
+	printf("read (1) : _filePos = %d\n", _filePos);
+	printf("read (1) : _cachePos = %d\n", _cachePos);
+#endif
+
+	if (_filePos >= _fileSize) {
+		_eof = true;
+#ifdef __PS2_FILE_SEMA__
+    SignalSema(_sema);
+#endif
+		return 0;
+	}
+
+	if ((_filePos+len) > _fileSize) {
+		len = _fileSize-_filePos;
+		_eof = true;
+	}
+
 	uint8 *destBuf = (uint8*)dest;
 	if ((_filePos < _cachePos) || (_filePos + len > _cachePos + _bytesInCache))
 		cacheReadSync(); // we have to read from CD, sync cache.
@@ -287,195 +343,60 @@
 	return destBuf - (uint8*)dest;
 }
 
-uint32 Ps2ReadFile::write(const void *src, uint32 len) {
-	sioprintf("write request on Ps2ReadFile!\n");
-	SleepThread();
-	return 0;
-}
+uint32 Ps2File::write(const void *src, uint32 len) {
+	uint32 w;
+#ifdef __PS2_FILE_SEMA__
+	WaitSema(_sema);
+#endif
+	_cacheSize = 0;
 
-struct TocNode {
-	char name[64];
-	TocNode *next, *sub;
-	bool isDir;
-	uint8 nameLen;
-};
-
-class TocManager {
-public:
-	TocManager(void);
-	~TocManager(void);
-	void readEntries(const char *root);
-    int64 fileExists(const char *name);
-	bool haveEntries(void);
-private:
-	void readDir(const char *path, TocNode **node, int level);
-	TocNode *_rootNode;
-	char _root[256];
-	uint8 _rootLen;
-};
-
-static TocManager tocManager;
-
-struct FioHandleCache {
-	Ps2File *file;
-	FioHandleCache *next, *prev;
-};
-
-static FioHandleCache *cacheListStart = NULL;
-static FioHandleCache *cacheListEnd = NULL;
-static int cacheListLen = 0;
-static int openFileCount = 0;
-static int cacheListSema = -1;
+	w = fio.sync(_fd);
+	assert(w==0);
 
-static bool checkedPath = false;
+	fio.seek(_fd, _filePos, SEEK_SET);
+	fio.write(_fd, src, len);
 
-Ps2File *findInCache(int64 id);
+	w = fio.sync(_fd);
 
-FILE *ps2_fopen(const char *fname, const char *mode) {
-	if (cacheListSema == -1) {
-		ee_sema_t newSema;
-		newSema.init_count = 1;
-		newSema.max_count = 1;
-		cacheListSema = CreateSema(&newSema);
-		assert(cacheListSema >= 0);
-	}
+#ifdef __PS2_FILE_SEMA__
+	SignalSema(_sema);
+#endif
 
-	if (((mode[0] != 'r') && (mode[0] != 'w')) || ((mode[1] != '\0') && (mode[1] != 'b'))) {
-		printf("unsupported mode \"%s\" for file \"%s\"\n", mode, fname);
-		return NULL;
+	if (w) {
+		_filePos += w;
+		if (w < len)
+			_eof = true;
+		return w;
 	}
-	bool rdOnly = (mode[0] == 'r');
-
-	if (strnicmp(fname, "mc0:", 4) == 0) {
-		// File access to the memory card (for scummvm.ini) has to go through the savefilemanager
-		Ps2File *file;
-		if (rdOnly)
-			file = new Ps2McReadFile((Ps2SaveFileManager *)g_systemPs2->getSavefileManager());
-		else
-			file = new Ps2McWriteFile((Ps2SaveFileManager *)g_systemPs2->getSavefileManager());
-		if (file->open(fname + 4)) // + 4 to skip "mc0:"
-			return (FILE *)file;
-
-		delete file;
-		return NULL;
-	} else {
-		// Regular access to one of the devices
 
-		printf("ps2_fopen = %s\n", fname); // romeo : temp
-
-		if (!rdOnly)
-			return NULL; // we only provide readaccess for cd,dvd,hdd,usb
+	return 0;
+}
 
-		if (!checkedPath && g_engine) {
-			// are we playing from cd/dvd?
-			const char *gameDataPath = ConfMan.get("path").c_str();
-			printf("Read TOC dir: %s\n", gameDataPath);
-			if (strncmp(gameDataPath, "cdfs:", 5) != 0)
-				driveStop(); // no, we aren't. stop the drive. it's noisy.
-			// now cache the dir tree
-			tocManager.readEntries(gameDataPath);
-			checkedPath = true;
-		}
+FILE *ps2_fopen(const char *fname, const char *mode) {
+	Ps2File *file = new Ps2File();
+	int _mode = O_RDONLY;
 
-		int64 cacheId = -1;
-		if (tocManager.haveEntries())
-			cacheId = tocManager.fileExists(fname);
-
-		if (cacheId != 0) {
-			Ps2File *file = findInCache(cacheId);
-			if (file) {
-				printf("  findInCache(%x)\n", cacheId); // romeo : temp
-				return (FILE*)file;
-			}
+	printf("fopen(%s, %s)\n", fname, mode);
 
-			bool isAudioFile = strstr(fname, ".bun") || strstr(fname, ".BUN") || strstr(fname, ".Bun");
-			file = new Ps2ReadFile(cacheId, isAudioFile);
+	if (mode[0] == 'r' && mode [1] == 'w')
+		_mode = O_RDWR;
+	else if (mode[0] == 'w')
+		_mode = O_WRONLY | O_CREAT;
+	else if (mode[0] == 'a')
+		_mode = O_RDWR | O_CREAT | O_APPEND;
 
-			if (file->open(fname)) {
-				openFileCount++;
-				printf("  new cacheID = %x\n", cacheId); // romeo : temp
-				return (FILE*)file;
-			} else
-				delete file;
-		}
+	if (file->open(fname, _mode))
+		return (FILE *)file;
+	else
 		return NULL;
-	}
-}
-
-void checkCacheListLen(void) {
-	while ((cacheListLen > MAX_CACHED_FILES) || ((openFileCount > 13) && cacheListLen)) {
-		assert(cacheListEnd && cacheListStart);
-		delete cacheListEnd->file;
-		if (cacheListEnd->prev) {
-			cacheListEnd->prev->next = NULL;
-			FioHandleCache *temp = cacheListEnd;
-			cacheListEnd = cacheListEnd->prev;
-			delete temp;
-		} else {
-			assert(cacheListEnd == cacheListStart);
-			assert(cacheListLen == 1);
-			delete cacheListEnd;
-			cacheListEnd = cacheListStart = NULL;
-		}
-		cacheListLen--;
-		openFileCount--;
-	}
 }
 
 int ps2_fclose(FILE *stream) {
 	Ps2File *file = (Ps2File*)stream;
-	if (file->_cacheId > 0) { // this is a file on the CD, could be smart to cache it
-		FioHandleCache *newHandle = new FioHandleCache;
-		newHandle->file = file;
-		file->seek(0, SEEK_SET);
-
-		WaitSema(cacheListSema);
-		if (!cacheListEnd) {
-			assert(!cacheListStart);
-			newHandle->prev = newHandle->next = NULL;
-			cacheListEnd = cacheListStart = newHandle;
-		} else {
-			assert(cacheListStart);
-			newHandle->prev = NULL;
-			newHandle->next = cacheListStart;
-			cacheListStart->prev = newHandle;
-			cacheListStart = newHandle;
-		}
-		cacheListLen++;
-		checkCacheListLen();
-		SignalSema(cacheListSema);
-	} else {
-		openFileCount--;
-		delete file;
-	}
-    return 0;
-}
 
-Ps2File *findInCache(int64 id) {
-	if (id <= 0)
-		return NULL;
-	WaitSema(cacheListSema);
-	FioHandleCache *node = cacheListStart;
-	while (node) {
-		if (node->file->_cacheId == id) {
-			if (node == cacheListStart)
-				cacheListStart = node->next;
-			if (node == cacheListEnd)
-				cacheListEnd = node->prev;
-			if (node->prev)
-				node->prev->next = node->next;
-			if (node->next)
-				node->next->prev = node->prev;
-			Ps2File *ret = node->file;
-			delete node;
-			cacheListLen--;
-			SignalSema(cacheListSema);
-			return ret;
-		} else
-			node = node->next;
-	}
-	SignalSema(cacheListSema);
-	return NULL;
+	delete file;
+
+	return 0;
 }
 
 int ps2_fseek(FILE *stream, long offset, int origin) {
@@ -503,40 +424,6 @@
 		return EOF;
 }
 
-char *ps2_fgets(char *buf, int n, FILE *stream) {
-	char *retVal = buf;
-	while (n--) {
-		if (n == 0)
-			*buf = '\0';
-		else {
-			char c = ps2_fgetc(stream);
-			if (c == EOF)
-				return NULL;
-			if ((c == '\r') || (c == '\n')) {
-				*buf++ = '\0';
-                return retVal;
-			}
-			*buf++ = c;
-		}
-	}
-	return retVal;
-}
-
-int ps2_fprintf(FILE *pOut, const char *zFormat, ...) {
-	va_list ap;
-	char resStr[2048];
-
-	va_start(ap,zFormat);
-	int res = vsnprintf(resStr, 2048, zFormat, ap);
-	va_end(ap);
-	if ((pOut == stderr) || (pOut == stdout)) {
-		printf("%s", resStr);
-		sioprintf("%s", resStr);
-	} else
-		res = ps2_fwrite(resStr, 1, res, pOut);
-	return res;
-}
-
 size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream) {
 	assert(r != 0);
 	return ((Ps2File*)stream)->write(buf, r * n) / r;
@@ -557,137 +444,36 @@
 		return EOF;
 }
 
-int ps2_fflush(FILE *stream) {
-	printf("fflush not implemented\n");
-	return 0;
-}
+int ps2_fprintf(FILE *pOut, const char *zFormat, ...) {
+	va_list ap;
+	char resStr[2048];
 
-TocManager::TocManager(void) {
-	_rootNode = NULL;
-}
+	va_start(ap,zFormat);
+	int res = vsnprintf(resStr, 2048, zFormat, ap);
+	va_end(ap);
+	if ((pOut == stderr) || (pOut == stdout)) {
+		printf("%s", resStr);
+		sioprintf("%s", resStr);
+	} else
+		res = ps2_fwrite(resStr, 1, res, pOut);
 
-TocManager::~TocManager(void) {
+	return res;
 }
 
-bool TocManager::haveEntries(void) {
-	return _rootNode != NULL;
+int ps2_fflush(FILE *stream) {
+	// printf("fflush not implemented\n");
+	return 0;
 }
 
-void TocManager::readEntries(const char *root) {
-    _rootLen = strlen(root);
-	strcpy(_root, root);
-	while (_root[_rootLen - 1] == '/') {
-		_rootLen--;
-		_root[_rootLen] = '\0';
-	}
-	char readPath[256];
-	sprintf(readPath, "%s/", _root);
-	printf("readDir: %s    (root: %s )\n", readPath, root);
-	readDir(readPath, &_rootNode, 0);
-}
-
-void TocManager::readDir(const char *path, TocNode **node, int level) {
-	if (level <= 2) { // we don't scan deeper than that
-		iox_dirent_t dirent;
-		int fd = fio.dopen(path);
-		TocNode *eNode = NULL; // = *node; // entry node
-		bool first = true;
-
-		printf("path=%s - level=%d fd=%d\n", path, level, fd); // romeo : temp
-		if (fd >= 0) {
-			while (fio.dread(fd, &dirent) > 0) {
-				if (dirent.name[0] != '.') { // skip '.' & '..' - romeo : check
-				                             // --- do we have them on PS2?
-					*node = new TocNode;
-					if (first) {
-						eNode = *node;
-						first = false;
-					}
-					(*node)->sub = (*node)->next = NULL;
-					(*node)->nameLen = strlen(dirent.name);
-					memcpy((*node)->name, dirent.name, (*node)->nameLen + 1);
-
-					if (dirent.stat.mode & FIO_S_IFDIR) {
-						(*node)->isDir = true;
-						printf("dirent.name = %s [DIR]\n", dirent.name);
-					}
-					else {
-						(*node)->isDir = false;
-						printf("dirent.name = %s\n", dirent.name);
-					}
-
-					node = &((*node)->next);
-				}
-			}
-
-			fio.dclose(fd);
-		}
-
-		TocNode *iNode = eNode;
-		char nextPath[256];
+int ps2_ferror(FILE *stream) {
+	int err = ((Ps2File*)stream)->getErr();
 
-		while (iNode) {
-			if (iNode->isDir == true) {
-				sprintf(nextPath, "%s%s/", path, iNode->name);
-				readDir(nextPath, &(iNode->sub), level + 1);
-			}
-			iNode = iNode->next;
-		}
+	if (err)
+		printf("ferror -> %d\n", err);
 
-	}
-
-	/*
-		** Wizard of Oz' trick (to get all games running from USB on PS2):
-
-		1. Make a list of files / dirs in level #0 (dclose before continuing)
-
-		2. Go through the dirs : dopen / dread them / mark dirs / dclose
-
-		   It's a safe recursion, cause it recurses on 'isDir' nodes
-		   after dclosing the higher hierarchy
-	*/
+	return err;
 }
 
-int64 TocManager::fileExists(const char *name) {
-	if (((name[_rootLen] != '/') && (name[_rootLen] != '\0')) || (strnicmp(name, _root, _rootLen) != 0)) {
-		for (int i = 0; i < 8; i++)
-			if (name[i] == ':')	// we don't know the content of other drives,
-				return -1;		// assume file exists
-			else if ((name[i] == '/') || (name[i] == '\\'))
-				return 0;		// does not exists (this is probably ScummVM trying the 'current directory'.)
-		return 0;
-	}
-
-	uint8 nameLen = strlen(name);
-
-	name += _rootLen + 1;
-	nameLen -= _rootLen + 1;
-
-	TocNode *node = _rootNode;
-	int64 retId = 1;
-	while (node) {
-		if (((name[node->nameLen] == '/') || (name[node->nameLen] == '\0')) && (strnicmp(name, node->name, node->nameLen) == 0)) {
-			name += node->nameLen;
-			nameLen -= node->nameLen;
-			if (node->isDir) {
-				if (nameLen) {
-					name++;	// skip '/'
-					nameLen--;
-					node = node->sub;
-					retId <<= 10;
-				} else
-					return 0; // can't open a directory with fopen()
-			} else {
-				if (nameLen == 0)
-					return retId; // ok, found
-				else
-					return 0; // here's a file, but there's something left in the path
-			}
-		} else {
-			node = node->next;
-			retId++;
-		}
-	}
-	return 0; // does not exist
+void ps2_clearerr(FILE *stream) {
+	((Ps2File*)stream)->setErr(false);
 }
-
diff -ur release-0-13-0/backends/platform/ps2/fileio.h release-0-13-0-ps2/backends/platform/ps2/fileio.h
--- release-0-13-0/backends/platform/ps2/fileio.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/fileio.h	2009-03-01 12:20:05.000000000 -0500
@@ -32,21 +32,56 @@
 #include <stdio.h>
 #include "common/scummsys.h"
 
+
+#define CACHE_SIZE (2048 * 32)
+#define MAX_READ_STEP (2048 * 16)
+#define MAX_CACHED_FILES 6
+#define CACHE_READ_THRESHOLD (16 * 2048)
+#define CACHE_FILL_MIN (2048 * 24)
+#define READ_ALIGN 64   // align all reads to the size of an EE cache line
+#define READ_ALIGN_MASK (READ_ALIGN - 1)
+
+
 class Ps2File {
 public:
-	Ps2File(int64 cacheId);
+	Ps2File(void);
 	virtual ~Ps2File(void);
-	virtual bool open(const char *name) = 0;
-	virtual uint32 read(void *dest, uint32 len) = 0;
-	virtual uint32 write(const void *src, uint32 len) = 0;
-	virtual uint32 tell(void) = 0;
-	virtual uint32 size(void) = 0;
-	virtual int seek(int32 offset, int origin) = 0;
-	virtual bool eof(void) = 0;
-	int64 _cacheId;
+	virtual bool open(const char *name, int mode);
+	virtual uint32 read(void *dest, uint32 len);
+	virtual uint32 write(const void *src, uint32 len);
+	virtual int32 tell(void);
+	virtual int32 size(void);
+	virtual int seek(int32 offset, int origin);
+	virtual bool eof(void);
+	virtual bool getErr(void);
+	virtual void setErr(bool);
+
+	
 private:
-};
+	void cacheReadAhead(void);
+	void cacheReadSync(void);
+
+	int _fd;
+	uint32 _fileSize;
+	uint32 _filePos;
+	uint32 _cacheSize;
+	uint32 _cachePos;
 
+	// uint8 cache[2048];
+	uint8 *_cache;
+
+	int _eof;
+	int _sema;
+
+
+	uint8 *_cacheBuf;
+	bool _cacheOpRunning;
+	uint32 _physFilePos;
+	uint32 _bytesInCache, _cacheOfs;
+
+	uint32 _readBytesBlock;
+	bool _stream;
+};
 
 FILE *ps2_fopen(const char *fname, const char *mode);
 int ps2_fclose(FILE *stream);
@@ -64,5 +99,8 @@
 int ps2_fputs(const char *s, FILE *stream);
 int ps2_fprintf(FILE *pOut, const char *zFormat, ...);
 
+int ps2_ferror(FILE *stream);
+void ps2_clearerr(FILE *stream);
+
 #endif // __PS2FILE_IO__
 
diff -ur release-0-13-0/backends/platform/ps2/Gs2dScreen.cpp release-0-13-0-ps2/backends/platform/ps2/Gs2dScreen.cpp
--- release-0-13-0/backends/platform/ps2/Gs2dScreen.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/Gs2dScreen.cpp	2009-03-01 19:37:43.000000000 -0500
@@ -47,7 +47,7 @@
 #define ANIM_STACK_SIZE (1024 * 32)
 
 #define DEFAULT_PAL_X		175
-#define DEFAULT_PAL_Y		60
+#define DEFAULT_PAL_Y		72 // 60
 #define DEFAULT_NTSC_X		165
 #define DEFAULT_NTSC_Y		45
 #define ORG_X 256
@@ -141,18 +141,31 @@
 	clearOverlay();
 
 	if (tvMode == TV_DONT_CARE) {
+#if 1
+	char romver[8];
+	int fd = fioOpen("rom0:ROMVER", O_RDONLY);
+	fioRead(fd, &romver, 8);
+	fioClose(fd);
+
+	if (romver[4] == 'E')
+		_videoMode = TV_PAL;
+	else
+		_videoMode = TV_NTSC;
+#else
 		if (PAL_NTSC_FLAG == 'E')
 			_videoMode = TV_PAL;
 		else
 			_videoMode = TV_NTSC;
+#endif
 	} else
 		_videoMode = tvMode;
 
+	// _videoMode = TV_NTSC;
 	printf("Setting up %s mode\n", (_videoMode == TV_PAL) ? "PAL" : "NTSC");
-
-    // set screen size, 640x544 for pal, 640x448 for ntsc
+	
+    // set screen size, 640x512 for pal, 640x448 for ntsc
 	_tvWidth = 640;
-	_tvHeight = ((_videoMode == TV_PAL) ? 544 : 448);
+	_tvHeight = ((_videoMode == TV_PAL) ? 512 /*544*/ : 448);
 	kFullScreen[0].z = kFullScreen[1].z = 0;
 	kFullScreen[0].x = ORIGIN_X;
 	kFullScreen[0].y = ORIGIN_Y;
@@ -175,7 +188,7 @@
 	_clutPtrs[TEXT]   = _clutPtrs[SCREEN] + 0x2000;
 	_texPtrs[SCREEN]  = _clutPtrs[SCREEN] + 0x3000;
 	_texPtrs[TEXT]    = 0;						  // these buffers are stored in the alpha gaps of the frame buffers
-	_texPtrs[MOUSE]	  = 128 * 256 * 4;
+	_texPtrs[MOUSE]	  = 128 * 256 * 4;			  
 	_texPtrs[PRINTF]  = _texPtrs[MOUSE] + M_SIZE * M_SIZE * 4;
 
 	_showOverlay = false;
@@ -224,7 +237,7 @@
 	updateScreen();
 
 	createAnimTextures();
-
+	
 	// create anim thread
 	ee_thread_t animThread, thisThread;
 	ReferThreadStatus(GetThreadId(), &thisThread);
@@ -535,6 +548,16 @@
 
 void Gs2dScreen::copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h) {
 	WaitSema(g_DmacSema);
+
+	// warning("_overlayBuf [dst] = %x", _overlayBuf);
+	// warning("buf [src] = %x", buf);
+
+	// warning("pitch=%d _width=%d - x=%d y=%d w=%d h=%d",
+	//	pitch, _width, x, y, w, h);
+
+	if (x >= 65535) x=0;
+	if (y >= 65535) y=0;
+
 	_overlayChanged = true;
 	uint16 *dest = _overlayBuf + y * _width + x;
 	for (uint32 cnt = 0; cnt < h; cnt++) {
@@ -636,7 +659,7 @@
 		do {
 			WaitSema(g_AnimSema);
 		} while ((!_systemQuit) && (!g_RunAnim));
-
+		
 		if (_systemQuit)
 			break;
 
@@ -761,7 +784,7 @@
 	GS_RGBA(   0,    0,    0, 0x20), // scrPrintf: semitransparent
 	GS_RGBA(0xC0, 0xC0, 0xC0,    0), // scrPrintf: red
 	GS_RGBA(0x16, 0x16, 0xF0,    0), // scrPrintf: blue
-
+	
 	GS_RGBA(0xFF, 0xFF, 0xFF, 0x80), GS_RGBA(0xFF, 0xFF, 0xFF, 0x80), // unused
 	GS_RGBA(0xFF, 0xFF, 0xFF, 0x80), GS_RGBA(0xFF, 0xFF, 0xFF, 0x80),
 	GS_RGBA(0xFF, 0xFF, 0xFF, 0x80), GS_RGBA(0xFF, 0xFF, 0xFF, 0x80),
diff -ur release-0-13-0/backends/platform/ps2/icon.cpp release-0-13-0-ps2/backends/platform/ps2/icon.cpp
--- release-0-13-0/backends/platform/ps2/icon.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/icon.cpp	2009-03-01 12:22:16.000000000 -0500
@@ -23,36 +23,40 @@
  *
  */
 
-#include "backends/platform/ps2/savefilemgr.h"
-#include "backends/platform/ps2/Gs2dScreen.h"
-#include "backends/platform/ps2/GsDefs.h"
+#include "Gs2dScreen.h"
+#include "GsDefs.h"
 
-const iconIVECTOR Ps2SaveFileManager::_bgcolor[4] = {
+#include <libmc.h>
+#include "icon.h"
+
+const char _info[] = "ScummVM\nFolder";
+
+const iconIVECTOR _bgcolor[4] = {
 	{  68,  23, 116,  0 }, // top left
 	{ 255, 255, 255,  0 }, // top right
 	{ 255, 255, 255,  0 }, // bottom left
 	{  68,  23, 116,  0 }, // bottom right
 };
 
-const iconFVECTOR Ps2SaveFileManager::_lightdir[3] = {
+const iconFVECTOR _lightdir[3] = {
 	{ 0.5, 0.5, 0.5, 0.0 },
 	{ 0.0,-0.4,-0.1, 0.0 },
 	{-0.5,-0.5, 0.5, 0.0 },
 };
 
-const iconFVECTOR Ps2SaveFileManager::_lightcol[3] = {
+const iconFVECTOR _lightcol[3] = {
 	{ 0.3, 0.3, 0.3, 0.00 },
 	{ 0.4, 0.4, 0.4, 0.00 },
 	{ 0.5, 0.5, 0.5, 0.00 },
 };
 
-const iconFVECTOR Ps2SaveFileManager::_ambient = { 0.50, 0.50, 0.50, 0.00 };
+const iconFVECTOR _ambient = { 0.50, 0.50, 0.50, 0.00 };
 
-//  Source File: stdico2.rle
+// Source File: stdico2.rle
 // Orig. Offset: 0 / 0x00000000
-//       Length: 14018 / 0x000036C2 (bytes)
+// Length: 14018 / 0x000036C2 (bytes)
 
-const uint8 Ps2SaveFileManager::_rleIcoData[14018] = {
+const uint8 _rleIcoData[14018] = {
     0xCC, 0x41, 0x00, 0x00, 0xCC, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x24, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0xF7, 0x00, 0xFE,
     0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0E, 0x7F, 0x7F,
@@ -932,4 +936,40 @@
     0x00, 0x00
 };
 
+uint16 PS2Icon::decompressData(uint16 **data) {
+	uint16 inPos = 1;
+	uint16 *rleData = (uint16*)_rleIcoData;
+	uint16 resSize = rleData[0];
+	uint16 *resData = (uint16*)malloc(resSize * sizeof(uint16));
+	uint16 outPos = 0;
+
+	while (outPos < resSize) {
+	uint16 len = rleData[inPos++];
+	while (len--)
+		resData[outPos++] = 0x7FFF;
+	len = rleData[inPos++];
+	while (len--)
+		resData[outPos++] = rleData[inPos++];
+	}
+	assert(outPos == resSize);
+
+	*data = resData;
+	return resSize;
+}
 
+void PS2Icon::setup(mcIcon *icon) {
+	char title[256];
+	memset(icon, 0, sizeof(mcIcon));
+	memcpy(icon->head, "PS2D", 4);
+	icon->nlOffset = strlen(_info) + 1;
+	strcpy(title, _info);
+	strcpy_sjis((short*)&(icon->title), title);
+	icon->trans = 0x10;
+	memcpy(icon->bgCol, _bgcolor, sizeof(_bgcolor));
+	memcpy(icon->lightDir, _lightdir, sizeof(_lightdir));
+	memcpy(icon->lightCol, _lightcol, sizeof(_lightcol));
+	memcpy(icon->lightAmbient, _ambient, sizeof(_ambient));
+	strcpy((char*)icon->view, "scummvm.icn");
+	strcpy((char*)icon->copy, "scummvm.icn");
+	strcpy((char*)icon->del, "scummvm.icn");
+}
Only in release-0-13-0-ps2/backends/platform/ps2: icon.h
diff -ur release-0-13-0/backends/platform/ps2/irxboot.cpp release-0-13-0-ps2/backends/platform/ps2/irxboot.cpp
--- release-0-13-0/backends/platform/ps2/irxboot.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/irxboot.cpp	2009-03-01 12:50:02.000000000 -0500
@@ -33,54 +33,53 @@
 #include "backends/platform/ps2/irxboot.h"
 #include "backends/platform/ps2/ps2debug.h"
 
+#include "ps2temp.h"
+
 static const char hddArg[] = "-o" "\0" "8" "\0" "-n" "\0" "20";
 static const char pfsArg[] = "-m" "\0" "2" "\0" "-o" "\0" "32" "\0" "-n" "\0" "72"; // "\0" "-debug";
+static const char netArg[] = "192.168.0.10" "\0" "255.255.255.0" "\0" "192.168.0.1";
 
 IrxFile irxFiles[] = {
 	{ "SIO2MAN", BIOS, NOTHING, NULL, 0 },
-	{ "MCMAN",   BIOS, NOTHING, NULL, 0 },
+	{ "MCMAN",   BIOS, NOTHING, NULL, 0 }, 
 	{ "MCSERV",  BIOS, NOTHING, NULL, 0 },
 	{ "PADMAN",  BIOS, NOTHING, NULL, 0 },
 	{ "LIBSD",   BIOS, NOTHING, NULL, 0 },
 
-	{ "IOMANX.IRX",   SYSTEM /*| NOT_HOST*/, NOTHING, NULL, 0 }, // already loaded by ps2link
+	{ "IOMANX.IRX",   SYSTEM, NOTHING, NULL, 0 },
 	{ "FILEXIO.IRX",  SYSTEM, NOTHING, NULL, 0 },
 	{ "CODYVDFS.IRX", SYSTEM, NOTHING, NULL, 0 },
 	{ "SJPCM.IRX",    SYSTEM, NOTHING, NULL, 0 },
 
 	{ "USBD.IRX",     USB | OPTIONAL | DEPENDANCY, USB_DRIVER, NULL, 0 },
+	{ "USB_MASS.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 },
 	{ "PS2MOUSE.IRX", USB | OPTIONAL, MOUSE_DRIVER, NULL, 0 },
 	{ "RPCKBD.IRX",   USB | OPTIONAL, KBD_DRIVER, NULL, 0 },
-	{ "USBHDFSD.IRX", USB | OPTIONAL, MASS_DRIVER, NULL, 0 },
 
-	{ "PS2DEV9.IRX",  HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, NULL, 0 },
+	{ "POWEROFF.IRX", HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 },
+	{ "PS2DEV9.IRX",  HDD | OPTIONAL | NOT_HOST | DEPENDANCY, HDD_DRIVER, NULL, 0 },
 	{ "PS2ATAD.IRX",  HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, NULL, 0 },
 	{ "PS2HDD.IRX",   HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, hddArg, sizeof(hddArg) },
 	{ "PS2FS.IRX",    HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, pfsArg, sizeof(pfsArg) },
-	{ "POWEROFF.IRX", HDD | OPTIONAL | DEPENDANCY, HDD_DRIVER, NULL, 0 }
+	{ "PS2IP.IRX",    NET | NOT_HOST, NET_DRIVER, NULL, 0 },
+	{ "PS2SMAP.IRX",  NET | NOT_HOST, NET_DRIVER, netArg, sizeof(netArg) },
+	{ "PS2HOST.IRX",  NET | NOT_HOST, NET_DRIVER, NULL, 0 }
 };
 
 static const int numIrxFiles = sizeof(irxFiles) / sizeof(irxFiles[0]);
 
-BootDevice detectBootPath(const char *elfPath, char *bootPath) {
-
-	BootDevice device;
-
-	if (strncasecmp(elfPath, "cdrom0:", 7) == 0)
-		device = CDROM;
-	else if (strncasecmp(elfPath, "host", 4) == 0)
-		device = HOST;
-	else
-		device = OTHER;
+PS2Device detectBootPath(const char *elfPath, char *bootPath) {
 
-	sioprintf("elf path: %s, device %d\n", elfPath, device);
+	PS2Device device = _getDev(elfPath);
 
+	printf("elf path: %s, device %d\n", elfPath, device);
+	
 	strcpy(bootPath, elfPath);
 
 	char *pathPos = bootPath;
 	char seperator;
 
-	if (device == CDROM) {
+	if (device == CD_DEV) {
 		// CDVD uses '\' as seperator
 		while (*pathPos) {
 			if (*pathPos == '/')
@@ -102,7 +101,7 @@
 		pathPos = strchr(bootPath, ':');
 
 	if (pathPos) {
-		if ((pathPos[0] == ':') && (device == CDROM)) {
+		if ((pathPos[0] == ':') && (device == CD_DEV)) {
 			pathPos[1] = '\\';
 			pathPos[2] = '\0';
 		} else
@@ -111,19 +110,19 @@
 	} else {
 		sioprintf("path not recognized, default to host.\n");
 		strcpy(bootPath, "host:");
-		device = UNKNOWN;
+		device = HOST_DEV; // UNKNOWN;
 	}
 	return device;
 }
 
-int loadIrxModules(int device, const char *irxPath, IrxReference **modules) {
+int loadIrxModules(int device, const char *irxPath, IrxReference **modules) {	
 
 	IrxReference *resModules = (IrxReference *)malloc(numIrxFiles * sizeof(IrxReference));
 	IrxReference *curModule = resModules;
 
 	for (int i = 0; i < numIrxFiles; i++) {
 		curModule->fileRef = irxFiles + i;
-		if ((device == HOST) && (irxFiles[i].flags & NOT_HOST))
+		if ((device == HOST_DEV) && (irxFiles[i].flags & NOT_HOST))
 			continue;
 
 		if ((irxFiles[i].flags & TYPEMASK) == BIOS) {
@@ -139,7 +138,7 @@
 			curModule->loc = IRX_BUFFER;
 			curModule->path = (char *)malloc(256);
 
-			sprintf(curModule->path, "%s%s%s", irxPath, irxFiles[i].name, (device == CDROM) ? ";1" : "");
+			sprintf(curModule->path, "%s%s%s", irxPath, irxFiles[i].name, (device == CD_DEV) ? ";1" : "");
 			int fd = fioOpen(curModule->path, O_RDONLY);
 			if (fd < 0) {
 				// IRX not found
@@ -159,7 +158,7 @@
 						// we simply can't find it.
 						sioprintf("Can't open %s: %d\n", curModule->path, fd);
 						// restore the path where we originally expected the file, for error message (later, after boot up)
-						sprintf(curModule->path, "%s%s%s", irxPath, irxFiles[i].name, (device == CDROM) ? ";1" : "");
+						sprintf(curModule->path, "%s%s%s", irxPath, irxFiles[i].name, (device == CD_DEV) ? ";1" : "");
 					}
 				}
 			}
diff -ur release-0-13-0/backends/platform/ps2/irxboot.h release-0-13-0-ps2/backends/platform/ps2/irxboot.h
--- release-0-13-0/backends/platform/ps2/irxboot.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/irxboot.h	2009-03-02 00:18:44.000000000 -0500
@@ -33,11 +33,12 @@
 	SYSTEM = 1,
 	USB = 2,
 	HDD = 3,
-	TYPEMASK = 3,
+	NET = 4,
+	TYPEMASK = 7,
 
-	OPTIONAL = 4,
-	DEPENDANCY = 8,
-	NOT_HOST = 16
+	OPTIONAL = 8,
+	DEPENDANCY = 16,
+	NOT_HOST = 32
 };
 
 enum IrxPurpose {
@@ -46,7 +47,8 @@
 	USB_DRIVER,
 	MOUSE_DRIVER,
 	KBD_DRIVER,
-	MASS_DRIVER
+	MASS_DRIVER,
+	NET_DRIVER
 };
 
 enum IrxLocation {
@@ -54,12 +56,14 @@
 	IRX_FILE
 };
 
+/*
 enum BootDevice {
 	HOST = 0,
 	CDROM,
-	OTHER,
-	UNKNOWN
+	MASS,
+	OTHER
 };
+*/
 
 struct IrxFile {
 	const char *name;
@@ -80,7 +84,6 @@
 	int errorCode;
 };
 
-BootDevice detectBootPath(const char *elfPath, char *bootPath);
 int loadIrxModules(int device, const char *irxPath, IrxReference **modules);
 
 #endif // __IRXBOOT_H__
diff -ur release-0-13-0/backends/platform/ps2/Makefile.ps2 release-0-13-0-ps2/backends/platform/ps2/Makefile.ps2
--- release-0-13-0/backends/platform/ps2/Makefile.ps2	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/Makefile.ps2	2009-03-01 16:10:42.000000000 -0500
@@ -1,9 +1,41 @@
 # $Header: Exp $
-include $(PS2SDK)/Defs.make
+ include $(PS2SDK)/Defs.make
 
+PS2_EXTRA = /media/disk-1/nw8240/extras/scummvm/ports
+PS2_EXTRA_INCS = /zlib/include /libmad/ee/include /SjPcm/ee/src /tremor
+PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /tremor/tremor
+
+ENABLED=STATIC_PLUGIN
+
+#control build
 DISABLE_SCALERS = true
 DISABLE_HQ_SCALERS = true
-# DISABLE_KYRA = true
+
+ENABLE_SCUMM = $(ENABLED)
+ENABLE_SCUMM_7_8 = $(ENABLED)
+ENABLE_HE = $(ENABLED)
+ENABLE_AGI = $(ENABLED)
+ENABLE_AGOS = $(ENABLED)
+ENABLE_CINE = $(ENABLED)
+ENABLE_CRUISE = $(ENABLED)
+ENABLE_DRASCULA = $(ENABLED)
+ENABLE_GOB = $(ENABLED)
+ENABLE_IGOR = $(ENABLED)
+ENABLE_KYRA = $(ENABLED)
+ENABLE_LURE = $(ENABLED)
+# ENABLE_M4 = $(ENABLED)
+ENABLE_MADE = $(ENABLED)
+ENABLE_PARALLACTION = $(ENABLED)
+ENABLE_QUEEN = $(ENABLED)
+ENABLE_SAGA = $(ENABLED)
+ENABLE_SAGA2 = $(ENABLED)
+ENABLE_IHNM = $(ENABLED)
+ENABLE_SKY = $(ENABLED)
+ENABLE_SWORD1 = $(ENABLED)
+ENABLE_SWORD2 = $(ENABLED)
+# ENABLE_TINSEL = $(ENABLED)
+ENABLE_TOUCHE = $(ENABLED)
+
 HAVE_GCC3 = true
 
 CC		= ee-gcc
@@ -19,22 +51,12 @@
 srcdir = ../../..
 VPATH = $(srcdir)
 INCDIR = ../../../
-DEPDIR = .deps
+# DEPDIR = .deps
 
-DEFINES  = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_MPEG2 -DUSE_ZLIB -D_EE -D__PLAYSTATION2__ -O2 -Wall -Wno-multichar
+DEFINES  = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -D_EE -D__PLAYSTATION2__ -O2 -Wall -Wno-multichar
 
-# PS2SDK-Ports from ps2dev.org's SVN repository for libmad, zlib and ucl
-PS2SDK_PORTS = /mnt/winxp/scummvm/ports
-PS2SDK_PORTS_INCS = /ucl /zlib/include /libmad/ee/include
-PS2SDK_PORTS_LIBS = /ucl /zlib/lib /libmad/ee/lib
-
-# we also need SjPcm, Tremor and libmpeg2
-MORE_LIBS_DIR = /mnt/winxp/scummvm/ports
-MORE_LIBS_INCS = /SjPcm/ee/src /mpeg2dec/include /tremor
-MORE_LIBS_LIBS = /SjPcm/ee/lib /mpeg2dec/libmpeg2 /tremor/tremor
 
-INCLUDES  = $(addprefix -I$(PS2SDK_PORTS),$(PS2SDK_PORTS_INCS)) 
-INCLUDES += $(addprefix -I$(MORE_LIBS_DIR),$(MORE_LIBS_INCS))
+INCLUDES  = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS)) 
 INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines
 
 TARGET = elf/scummvm.elf
@@ -44,12 +66,10 @@
     backends/platform/ps2/irxboot.o \
 	backends/platform/ps2/ps2input.o \
 	backends/platform/ps2/ps2pad.o \
-	backends/platform/ps2/rawsavefile.o \
-    backends/platform/ps2/savefile.o \
 	backends/platform/ps2/savefilemgr.o \
     backends/platform/ps2/fileio.o \
-    backends/platform/ps2/icon.o \
     backends/platform/ps2/asyncfio.o \
+	backends/platform/ps2/icon.o \
     backends/platform/ps2/cd.o \
     backends/platform/ps2/eecodyvdfs.o \
     backends/platform/ps2/rpckbd.o \
@@ -64,9 +84,8 @@
 
 LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T $(PS2SDK)/ee/startup/linkfile 
 LDFLAGS += -L $(PS2SDK)/ee/lib -L .
-LDFLAGS += $(addprefix -L$(MORE_LIBS_DIR),$(MORE_LIBS_LIBS))
-LDFLAGS += $(addprefix -L$(PS2SDK_PORTS),$(PS2SDK_PORTS_LIBS)) 
-LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmpeg2 -lmad -ltremor -lz -lucl -lm -lc -lfileXio -lkernel -lstdc++ 
+LDFLAGS += $(addprefix -L$(PS2_EXTRA),$(PS2_EXTRA_LIBS)) 
+LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmad -ltremor -lz -lm -lc -lfileXio -lkernel -lstdc++ 
 # LDFLAGS += -s 
 
 all: $(TARGET)
diff -ur release-0-13-0/backends/platform/ps2/ps2debug.cpp release-0-13-0-ps2/backends/platform/ps2/ps2debug.cpp
--- release-0-13-0/backends/platform/ps2/ps2debug.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/ps2debug.cpp	2009-03-01 12:24:38.000000000 -0500
@@ -1,3 +1,25 @@
+/* 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 "ps2debug.h"
 #include <stdio.h>
 #include <stdlib.h>
diff -ur release-0-13-0/backends/platform/ps2/ps2debug.h release-0-13-0-ps2/backends/platform/ps2/ps2debug.h
--- release-0-13-0/backends/platform/ps2/ps2debug.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/ps2debug.h	2009-03-01 12:25:07.000000000 -0500
@@ -26,7 +26,7 @@
 #ifndef __PS2DEBUG_H__
 #define __PS2DEBUG_H__
 
-#define dbg_printf sioprintf
+#define dbg_printf printf
 
 void sioprintf(const char *zFormat, ...);
 
Only in release-0-13-0-ps2/backends/platform/ps2: ps2temp.h
Only in release-0-13-0/backends/platform/ps2: rawsavefile.cpp
Only in release-0-13-0/backends/platform/ps2: rawsavefile.h
diff -ur release-0-13-0/backends/platform/ps2/rpckbd.h release-0-13-0-ps2/backends/platform/ps2/rpckbd.h
--- release-0-13-0/backends/platform/ps2/rpckbd.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/rpckbd.h	2009-03-01 12:29:52.000000000 -0500
@@ -1,3 +1,25 @@
+/* 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 __RPCKBD_H__
 #define __RPCKBD_H__
 
Only in release-0-13-0/backends/platform/ps2: savefile.cpp
Only in release-0-13-0/backends/platform/ps2: savefile.h
diff -ur release-0-13-0/backends/platform/ps2/savefilemgr.cpp release-0-13-0-ps2/backends/platform/ps2/savefilemgr.cpp
--- release-0-13-0/backends/platform/ps2/savefilemgr.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/savefilemgr.cpp	2009-03-01 12:50:10.000000000 -0500
@@ -23,550 +23,258 @@
  *
  */
 
-#include <tamtypes.h>
-#include <kernel.h>
-#include <sifrpc.h>
-#include <loadfile.h>
-#include <fileio.h>
-#include <malloc.h>
-#include <ucl/ucl.h>
-#include <libmc.h>
-#include "backends/platform/ps2/savefile.h"
-#include "backends/platform/ps2/Gs2dScreen.h"
-#include "backends/platform/ps2/systemps2.h"
-#include "backends/fs/abstract-fs.h"
-#include "backends/platform/ps2/ps2debug.h"
-
-#include "common/scummsys.h"
-
-#include "backends/platform/ps2/savefilemgr.h"
-#include "backends/platform/ps2/savefile.h"
-
-extern void *_gp;
-
-#define PORT 0
-#define SLOT 0
-// port 0, slot 0: memory card in first slot.
-
-McAccess::McAccess(int port, int slot) {
-	_port = port;
-	_slot = slot;
-	ee_sema_t newSema;
-	newSema.init_count = 1;
-	newSema.max_count = 1;
-	_sema = CreateSema(&newSema);
+#include "common/config-manager.h"
+#include "backends/saves/compressed/compressed-saves.h"
 
-	assert(mcInit(MC_TYPE_MC) >= 0);
-}
+#ifdef __USE_LIBMC__
+	#include <libmc.h>
+#endif
+
+#include "asyncfio.h"
+#include "savefilemgr.h"
+#include "Gs2dScreen.h"
+#include "ps2temp.h"
 
-McAccess::~McAccess(void) {
-	DeleteSema(_sema);
-}
+extern AsyncFio fio;
 
-int McAccess::open(const char *name, int mode) {
-	int res;
-	WaitSema(_sema);
-	mcOpen(_port, _slot, name, mode);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
+Ps2SaveFileManager::Ps2SaveFileManager(OSystem_PS2 *system, Gs2dScreen *screen) {
+	// _system = system;
+	_screen = screen;
 }
 
-int McAccess::close(int fd) {
-	int res;
-	WaitSema(_sema);
-	mcClose(fd);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
-}
+Ps2SaveFileManager::~Ps2SaveFileManager() {
 
-int McAccess::size(int fd) {
-	int res, size;
-	WaitSema(_sema);
-	mcSeek(fd, 0, SEEK_END);
-	mcSync(0, NULL, &size);
-	mcSeek(fd, 0, SEEK_SET);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	assert(res == 0);
-	return size;
 }
 
-int McAccess::read(int fd, void *buf, int size) {
-	int res;
-	WaitSema(_sema);
-	mcRead(fd, buf, size);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
-}
 
-int McAccess::write(int fd, const void *buf, int size) {
-	int res;
-	WaitSema(_sema);
-	mcWrite(fd, buf, size);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
-}
+bool Ps2SaveFileManager::mcCheck(const char *path) {
+	// Common::FSNode dir(Common::String(path), 1); // FIXED in gcc 3.4.x
+	const Common::String str(path);
+	Common::FSNode dir(str);
 
-int McAccess::mkDir(const char *name) {
-	int res;
-	WaitSema(_sema);
-	mcMkDir(_port, _slot, name);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
-}
+	// int res;
 
-int McAccess::remove(const char *name) {
-	int res;
-	WaitSema(_sema);
-	mcDelete(_port, _slot, name);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
-}
+	printf("mcCheck\n");
+
+	if (!dir.exists()) {
+		printf("! exist -> create : ");
+#ifdef __USE_LIBMC__
+		printf("%s\n", path+4);
+		// WaitSema(_sema);
+		mcSync(0, NULL, NULL);
+		mcMkDir(0 /*port*/, 0 /*slot*/,	path+4);
+		mcSync(0, NULL, &res);
+		printf("sync : %d\n", res);
+		// SignalSema(_sema);
+#else
+		printf("%s\n", path);
+		fio.mkdir(path);
+#endif
+	}
 
-int McAccess::getDir(const char *name, unsigned int mode, int max, void *dest) {
-	int res;
-	WaitSema(_sema);
-	mcGetDir(_port, _slot, name, mode, max, (mcTable*)dest);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
+	// TODO: res;
+	return true;
 }
 
-int McAccess::getInfo(int *type, int *free, int *format) {
-	int res;
-	WaitSema(_sema);
-	mcGetInfo(_port, _slot, type, free, format);
-	mcSync(0, NULL, &res);
-	SignalSema(_sema);
-	return res;
+void Ps2SaveFileManager::mcSplit(char *full, char *game, char *ext) {
+	// TODO
 }
 
-#define MAX_MC_ENTRIES	16
+Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
+	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
+	Common::SeekableReadStream *sf;
 
-void runSaveThread(Ps2SaveFileManager *param);
+	if (!savePath.exists() || !savePath.isDirectory())
+		return NULL;
 
-Ps2SaveFileManager::Ps2SaveFileManager(OSystem_PS2 *system, Gs2dScreen *screen) {
-	_system = system;
-	_screen = screen;
-	_mc = new McAccess(PORT, SLOT);
+	// _screen->wantAnim(true);
 
-	_mcDirList = (mcTable*)memalign(64, MAX_MC_ENTRIES * sizeof(mcTable));
-	_mcDirName[0] = '\0';
-	_mcCheckTime = 0;
-	_mcNeedsUpdate = true;
-
-	for (int mcCheckCount = 0; mcCheckCount < 3; mcCheckCount++) {
-		/* retry mcGetInfo 3 times. It slows down startup without mc considerably,
-		   but cheap 3rd party memory cards apparently fail to get detected once in a while */
-
-		int mcType, mcFree, mcFormat;
-		int res = _mc->getInfo(&mcType, &mcFree, &mcFormat);
-
-		if ((res == 0) || (res == -1)) { // mc okay
-			_mcPresent = true;
-			printf("MC okay, result = %d. Type %d, Free %d, Format %d\n", res, mcType, mcFree, mcFormat);
-			checkMainDirectory();
-			break;
-		} else {
-			_mcPresent = false;
-			printf("MC failed, not present or not formatted, code %d\n", res);
+	if (_getDev(savePath) == MC_DEV) {
+	// if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) {
+		char *game=0, *ext=0, path[32], temp[32];
+
+		// FIXME : hack for indy4 iq-points
+		if (strcmp(filename, "iq-points") == 0) {
+			mcCheck("mc0:ScummVM/indy4");
+			sprintf(path, "mc0:ScummVM/indy4/iq-points");
 		}
-	}
+		// FIXME : hack for bs1 saved games
+		else if (strcmp(filename, "SAVEGAME.INF") == 0) {
+			mcCheck("mc0:ScummVM/sword1");
+			sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF");
+		}
+		else {
+			printf("MC : filename = %s\n", filename);
+			strcpy(temp, filename);
+
+			// mcSplit(temp, game, ext);
+			game = strdup(strtok(temp, "."));
+			ext = strdup(strtok(NULL, "*"));
+			sprintf(path, "mc0:ScummVM/%s", game); // per game path
 
-	// create save thread
-	ee_sema_t newSema;
-	newSema.init_count = 0;
-	newSema.max_count = 1;
-	_autoSaveSignal = CreateSema(&newSema);
-	_autoSaveBuf = NULL;
-	_autoSaveSize = 0;
-	_systemQuit = false;
-
-	ee_thread_t saveThread, thisThread;
-	ReferThreadStatus(GetThreadId(), &thisThread);
-
-	saveThread.initial_priority = thisThread.current_priority + 1;
-	saveThread.stack_size = 8 * 1024;
-	_autoSaveStack = malloc(saveThread.stack_size);
-	saveThread.stack  = _autoSaveStack;
-	saveThread.func   = (void *)runSaveThread;
-	saveThread.gp_reg = &_gp;
-
-	_autoSaveTid = CreateThread(&saveThread);
-	assert(_autoSaveTid >= 0);
-	StartThread(_autoSaveTid, this);
-}
+			// mcCheck(path); // needed on load ?
+			sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext);
+		}
 
-Ps2SaveFileManager::~Ps2SaveFileManager(void) {
-}
+        free(game);
+        free(ext);
 
-void Ps2SaveFileManager::checkMainDirectory(void) {
-	// verify that the main directory (scummvm config + icon) exists
-	int ret, fd;
-	_mcNeedsUpdate = true;
-	ret = _mc->getDir("/ScummVM/*", 0, MAX_MC_ENTRIES, _mcDirList);
-	printf("/ScummVM/* res = %d\n", ret);
-	if (ret <= 0) { // assume directory doesn't exist
-		printf("Dir doesn't exist\n");
-		ret = _mc->mkDir("/ScummVM");
-		if (ret >= 0) {
-			fd = _mc->open("/ScummVM/scummvm.icn", O_WRONLY | O_CREAT);
-			if (fd >= 0) {
-				uint16 icoSize;
-				uint16 *icoBuf = decompressIconData(&icoSize);
-				ret = _mc->write(fd, icoBuf, icoSize * 2);
-				_mc->close(fd);
-				free(icoBuf);
-
-				printf(".icn written\n");
-				setupIcon("/ScummVM/icon.sys", "scummvm.icn", "ScummVM", "Configuration");
-			} else
-				printf("Can't create icon file: %d\n", fd);
-		} else
-			printf("can't create scummvm directory: %d\n", ret);
-	}
-}
+		Common::FSNode file(path);
 
-void Ps2SaveFileManager::splitPath(const char *fileName, char *dir, char *name) {
-	strcpy(dir, fileName);
-	char *ext = strchr(dir, '.');
-	if (ext) {
-		*ext = '\0';
-		ext++;
-	}
-	if (ext && *ext)
-		sprintf(name, "%s.ucl", ext);
-	else
-		strcpy(name, "save.ucl");
-}
+		if(!file.exists())
+			return NULL;
 
-bool Ps2SaveFileManager::mcReadyForDir(const char *dir) {
-	if (_mcNeedsUpdate || ((_system->getMillis() - _mcCheckTime) > 2000) || !_mcPresent) {
-		// check if memory card was exchanged/removed in the meantime
-		int mcType, mcFree, mcFormat, mcResult;
-		mcResult = _mc->getInfo(&mcType, &mcFree, &mcFormat);
-		if (mcResult != 0) { // memory card was exchanged
-			_mcNeedsUpdate = true;
-			if (mcResult == -1) { // yes, it was exchanged
-				checkMainDirectory(); // make sure ScummVM dir and icon are there
-			} else { // no memorycard in slot or not formatted or something like that
-				_mcPresent = false;
-				printf("MC not found, error code %d\n", mcResult);
-				return false;
-			}
-		}
-		_mcPresent = true;
-		_mcCheckTime = _system->getMillis();
-	}
-	if (_mcNeedsUpdate || strcmp(_mcDirName, dir)) {
-		strcpy(_mcDirName, dir);
-		char dirStr[256];
-		sprintf(dirStr, "/ScummVM-%s/*", dir);
-		_mcEntries = _mc->getDir(dirStr, 0, MAX_MC_ENTRIES, _mcDirList);
-		_mcNeedsUpdate = false;
-	}
-	return (_mcEntries >= 0);
-}
+		sf = file.openForReading();
 
-Common::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) {
-	_screen->wantAnim(true);
+	} else {
+		Common::FSNode file = savePath.getChild(filename);
 
-	char dir[256], name[256];
-	splitPath(filename, dir, name);
-	printf("openForLoading: \"%s\" => \"%s\" + \"%s\"\n", filename, dir, name);
-	if (mcReadyForDir(dir)) {
-		printf("Ready\n");
-		bool fileExists = false;
-		for (int i = 0; i < _mcEntries; i++)
-			if (strcmp(name, (char*)_mcDirList[i].name) == 0)
-				fileExists = true;
-		if (fileExists) {
-			printf("Found!\n");
-			char fullName[256];
-			sprintf(fullName, "/ScummVM-%s/%s", dir, name);
-			UclInSaveFile *file = new UclInSaveFile(fullName, _screen, _mc);
-			if (file) {
-				if (!file->ioFailed())
-					return file;
-				else {
-					printf("IoFailed\n");
-					delete file;
-				}
-			}
-		} else
-			printf("file %s (%s) doesn't exist\n", filename, name);
+		if(!file.exists())
+			return NULL;
+
+		sf = file.openForReading();
 	}
-	_screen->wantAnim(false);
-	return NULL;
-}
 
-Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
-	int res;
-	char dir[256], name[256];
+	// _screen->wantAnim(false);
 
-	_screen->wantAnim(true);
-	splitPath(filename, dir, name);
+	return wrapInSaveFile(sf);
+}
 
-	if (!mcReadyForDir(dir)) {
-		if (_mcPresent) { // directory doesn't seem to exist yet
-			char fullPath[256];
-			sprintf(fullPath, "/ScummVM-%s", dir);
-			res = _mc->mkDir(fullPath);
-
-			char icoSysDest[256], saveDesc[256];
-			sprintf(icoSysDest, "%s/icon.sys", fullPath);
-			strcpy(saveDesc, dir);
-			if ((saveDesc[0] >= 'a') && (saveDesc[0] <= 'z'))
-				saveDesc[0] += 'A' - 'a';
-			setupIcon(icoSysDest, "../ScummVM/scummvm.icn", saveDesc, "Savegames");
-		}
-	}
+Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
+	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
+	Common::WriteStream *sf;
 
-	if (_mcPresent) {
-		char fullPath[256];
-		sprintf(fullPath, "/ScummVM-%s/%s", dir, name);
-		if (strstr(filename, ".s00") || strstr(filename, ".ASD") || strstr(filename, ".asd")) {
-			// this is an autosave
-			AutoSaveFile *file = new AutoSaveFile(this, fullPath);
-			return file;
-		} else {
-			UclOutSaveFile *file = new UclOutSaveFile(fullPath, _system, _screen, _mc);
-			if (!file->ioFailed()) {
-				// we're creating a file, mc will have to be updated next time
-				_mcNeedsUpdate = true;
-				return file;
-			} else {
-				printf("UCL out create failed!\n");
-				delete file;
-			}
-		}
-	}
+	printf("openForSaving : %s\n", filename);
 
-	_screen->wantAnim(false);
-	return NULL;
-}
+	if (!savePath.exists() || !savePath.isDirectory())
+		return NULL;
 
-void Ps2SaveFileManager::listSavefiles(const char *prefix, bool *marks, int num) {
 	_screen->wantAnim(true);
 
-	int mcType, mcFree, mcFormat, mcResult;
-	mcResult = _mc->getInfo(&mcType, &mcFree, &mcFormat);
-
-	memset(marks, false, num * sizeof(bool));
+	if (_getDev(savePath) == MC_DEV) {
+	// if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) {
+		char *game=0, *ext=0, path[32], temp[32];
+
+		// FIXME : hack for indy4 iq-points
+		if (strcmp(filename, "iq-points") == 0) {
+			mcCheck("mc0:ScummVM/indy4");
+			sprintf(path, "mc0:ScummVM/indy4/iq-points");
+		}
+		// FIXME : hack for bs1 saved games
+        else if (strcmp(filename, "SAVEGAME.INF") == 0) {
+            mcCheck("mc0:ScummVM/sword1");
+            sprintf(path, "mc0:ScummVM/sword1/SAVEGAME.INF");
+        }
+		else {
+			strcpy(temp, filename);
+
+			// mcSplit(temp, game, ext);
+			game = strdup(strtok(temp, "."));
+			ext = strdup(strtok(NULL, "*"));
+			sprintf(path, "mc0:ScummVM/%s", game); // per game path
+			mcCheck(path);
+			sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext);
+		}
 
-	if ((mcResult == 0) || (mcResult == -1)) {
-		// there's a memory card in the slot.
-		if (mcResult == -1)
-			_mcNeedsUpdate = true;
-
-		mcTable *mcEntries = (mcTable*)memalign(64, sizeof(mcTable) * MAX_MC_ENTRIES);
-
-		char dirStr[256], ext[256], mcSearchStr[256];
-		strcpy(dirStr, prefix);
-		char *pos = strchr(dirStr, '.');
-		if (pos) {
-			strcpy(ext, pos + 1);
-			*pos = '\0';
-		} else
-			ext[0] = '\0';
-		sprintf(mcSearchStr, "/ScummVM-%s/%s*", dirStr, ext);
-
-		int numEntries = _mc->getDir(mcSearchStr, 0, MAX_MC_ENTRIES, mcEntries);
-
-		int searchLen = strlen(ext);
-		for (int i = 0; i < numEntries; i++)
-			if ((((char*)mcEntries[i].name)[0] != '.') && stricmp((char*)mcEntries[i].name, "icon.sys")) {
-				char *stopCh;
-				int destNum = (int)strtoul((char*)mcEntries[i].name + searchLen, &stopCh, 10);
-				if ((!stopCh) || strcmp(stopCh, ".ucl"))
-					printf("unexpected end %s in name %s, search %s\n", stopCh, (char*)mcEntries[i].name, prefix);
-				if (destNum < num)
-					marks[destNum] = true;
-			}
-		free(mcEntries);
+		Common::FSNode file(path);
+		sf = file.openForWriting();
+		free(game);
+		free(ext);
+	} else {
+		Common::FSNode file = savePath.getChild(filename);
+		sf = file.openForWriting();
 	}
+
 	_screen->wantAnim(false);
+	return wrapOutSaveFile(sf);
 }
 
-Common::StringList Ps2SaveFileManager::listSavefiles(const char *regex) {
-	_screen->wantAnim(true);
-	Common::StringList results;
-	int mcType, mcFree, mcFormat, mcResult;
-
-	printf("listSavefiles -> regex=%s\n", regex);
-
-	mcResult = _mc->getInfo(&mcType, &mcFree, &mcFormat);
+bool Ps2SaveFileManager::removeSavefile(const char *filename) {
+	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
+	Common::FSNode file;
 
-	if ((mcResult == 0) || (mcResult == -1)) {
-		// there's a memory card in the slot.
-		if (mcResult == -1)
-			_mcNeedsUpdate = true;
+	if (!savePath.exists() || !savePath.isDirectory())
+		return false;
 
-		mcTable *mcEntries = (mcTable*)memalign(64, sizeof(mcTable) * MAX_MC_ENTRIES);
+	if (_getDev(savePath) == MC_DEV) {
+	// if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) {
+		char *game=0, *ext=0, path[32], temp[32];
+		strcpy(temp, filename);
 
-		char temp[256], mcSearchStr[256], *dir, *ext;
-		strcpy(temp, regex);
-		dir = strdup(strtok(temp, "."));
+		// mcSplit(temp, game, ext);
+		game = strdup(strtok(temp, "."));
 		ext = strdup(strtok(NULL, "*"));
-
-		printf("dir = %s - ext = %s\n", dir, ext);
-
-		sprintf(mcSearchStr, "/ScummVM-%s/%s*", dir, ext);
-
-		int numEntries = _mc->getDir(mcSearchStr, 0, MAX_MC_ENTRIES, mcEntries);
-		char *name;
-        for (int i = 0; i < numEntries; i++) {
-			name = (char*)mcEntries[i].name;
-
-            if ((name[0] != '.') && stricmp(name, "icon.sys")) {
-				printf(" name = %s\n", (char*)mcEntries[i].name);
-				if (Common::matchString(name, "s*.ucl")) {
-					sprintf(temp, "%s.%s%c%c", dir, ext, name[1], name[2]);
-					results.push_back(temp);
-					printf("  -> match [%s] ;-)\n", temp);
-				}
-				else {
-					results.push_back(name); // ;-)
-					printf("  -> no match :-(\n");
-				}
-			}
-		}
-		free(mcEntries);
-		free(dir);
+		sprintf(path, "mc0:ScummVM/%s", game); // per game path
+		mcCheck(path);
+		sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext);
+		file = Common::FSNode(path);
+		free(game);
 		free(ext);
-    }
+	} else {
+		file = savePath.getChild(filename);
+	}
 
-    _screen->wantAnim(false);
+	if (!file.exists() || file.isDirectory())
+		return false;
 
-	return results;
+	fio.remove(file.getPath().c_str());
+
+	return true;
 }
 
-bool Ps2SaveFileManager::removeSavefile(const char *filename) {
+Common::StringList Ps2SaveFileManager::listSavefiles(const char *pattern) {
+	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
+	Common::String _dir;
+	Common::String search;
+	bool _mc = (_getDev(savePath) == MC_DEV);
+ 		// (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0);
+	char *game=0, path[32], temp[32];
 
-	char dir[64], name[64], fullPath[128];
+	if (!savePath.exists() || !savePath.isDirectory())
+		return Common::StringList();
 
-	splitPath(filename, dir, name);
-	sprintf(fullPath, "/ScummVM-%s/%s", dir, name);
+	printf("listSavefiles = %s\n", pattern);
 
-	int res = _mc->remove(fullPath);
-	return (res == 0);
-}
+	if (_mc) {
+		strcpy(temp, pattern);
 
-const char *Ps2SaveFileManager::getSavePath(void) const {
-	return "mc0:";
-}
+		// mcSplit(temp, game, ext);
+		game = strdup(strtok(temp, "."));
+		sprintf(path, "mc0:ScummVM/%s", game); // per game path
+		mcCheck(path);
 
-bool Ps2SaveFileManager::setupIcon(const char *dest, const char *ico, const char *descr1, const char *descr2) {
-	mcIcon icon_sys;
-	memset(&icon_sys, 0, sizeof(mcIcon));
-	memcpy(icon_sys.head, "PS2D", 4);
-	char title[256];
-	if (!stricmp("SAVEGAME", descr1)) { // these are broken sword 1 savegames
-		sprintf(title, "BSword1\n%s", descr2);
-		icon_sys.nlOffset = 8;
-	} else {
-		sprintf(title, "%s\n%s", descr1, descr2);
-		icon_sys.nlOffset = strlen(descr1) + 1;
+		sprintf(path, "mc0:ScummVM/%s/", game);
+		_dir = Common::String(path);
+		search = Common::String("*.sav");
 	}
-	strcpy_sjis((short*)&(icon_sys.title), title);
-	icon_sys.trans = 0x10;
-	memcpy(icon_sys.bgCol, _bgcolor, sizeof(_bgcolor));
-	memcpy(icon_sys.lightDir, _lightdir, sizeof(_lightdir));
-	memcpy(icon_sys.lightCol, _lightcol, sizeof(_lightcol));
-	memcpy(icon_sys.lightAmbient, _ambient, sizeof(_ambient));
-	strcpy((char*)icon_sys.view, ico);
-	strcpy((char*)icon_sys.copy, ico);
-	strcpy((char*)icon_sys.del, ico);
-
-	int fd, res;
-	fd = _mc->open(dest, O_WRONLY | O_CREAT);
-	if (fd >= 0) {
-		res = _mc->write(fd, &icon_sys, sizeof(icon_sys));
-		_mc->close(fd);
-        return (res == sizeof(icon_sys));
-	} else
-		return false;
-}
-
-uint16 *Ps2SaveFileManager::decompressIconData(uint16 *size) {
-	uint16 inPos = 1;
-	uint16 *rleData = (uint16*)_rleIcoData;
-	uint16 resSize = rleData[0];
-	uint16 *resData = (uint16*)malloc(resSize * sizeof(uint16));
-	uint16 outPos = 0;
-	while (outPos < resSize) {
-		uint16 len = rleData[inPos++];
-		while (len--)
-			resData[outPos++] = 0x7FFF;
-		len = rleData[inPos++];
-		while (len--)
-			resData[outPos++] = rleData[inPos++];
+	else {
+		_dir = Common::String(savePath.getPath());
+		search = Common::String(pattern);
 	}
-	*size = resSize;
-	assert(outPos == resSize);
-	return resData;
-}
 
-void runSaveThread(Ps2SaveFileManager *param) {
-	param->saveThread();
-}
+	Common::FSDirectory dir(_dir);
+	Common::ArchiveMemberList savefiles;
+	Common::StringList results;
 
-void Ps2SaveFileManager::writeSaveNonblocking(char *name, void *buf, uint32 size) {
-	if (buf && size && !_systemQuit) {
-		strcpy(_autoSaveName, name);
-		assert(!_autoSaveBuf);
-		_autoSaveBuf = (uint8*)malloc(size);
-		memcpy(_autoSaveBuf, buf, size);
-		_autoSaveSize = size;
-		SignalSema(_autoSaveSignal);
-	}
-}
+	printf("dir = %s --- reg = %s\n", _dir.c_str(), search.c_str());
 
-void Ps2SaveFileManager::saveThread(void) {
-	while (!_systemQuit) {
-		WaitSema(_autoSaveSignal);
-		if (_autoSaveBuf && _autoSaveSize) {
-			UclOutSaveFile *outSave = new UclOutSaveFile(_autoSaveName, _system, _screen, _mc);
-			if (!outSave->ioFailed()) {
-				outSave->write(_autoSaveBuf, _autoSaveSize);
-				outSave->flush();
+	if (dir.listMatchingMembers(savefiles, search) > 0) {
+		for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) {
+			if (_mc) { // convert them back in ScummVM names
+				strncpy(temp, (*file)->getName().c_str(), 3);
+				temp[3] = '\0';
+				sprintf(path, "%s.%s", game, temp);
+				results.push_back(path);
+				printf(" --> found = %s -> %s\n", (*file)->getName().c_str(), path);
+			}
+			else {
+				results.push_back((*file)->getName());
+				printf(" --> found = %s\n", (*file)->getName().c_str());
 			}
-			if (outSave->ioFailed())
-				_system->msgPrintf(5000, "Writing autosave to %s failed", _autoSaveName);
-			delete outSave;
-			free(_autoSaveBuf);
-			_autoSaveBuf = NULL;
-			_autoSaveSize = 0;
-			_mcNeedsUpdate = true; // we've created a file, mc will have to be updated
-			_screen->wantAnim(false);
 		}
 	}
-	ExitThread();
-}
 
-void Ps2SaveFileManager::quit(void) {
-	_systemQuit = true;
-	ee_thread_t statSave, statThis;
-	ReferThreadStatus(GetThreadId(), &statThis);
-	ChangeThreadPriority(_autoSaveTid, statThis.current_priority - 1);
-
-	do {	// wait until thread called ExitThread()
-		SignalSema(_autoSaveSignal);
-		ReferThreadStatus(_autoSaveTid, &statSave);
-	} while (statSave.status != 0x10);
+	free(game);
 
-	DeleteThread(_autoSaveTid);
-    free(_autoSaveStack);
-}
-
-McAccess *Ps2SaveFileManager::getMcAccess(void) {
-	return _mc;
+	return results;
 }
-
-
diff -ur release-0-13-0/backends/platform/ps2/savefilemgr.h release-0-13-0-ps2/backends/platform/ps2/savefilemgr.h
--- release-0-13-0/backends/platform/ps2/savefilemgr.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/savefilemgr.h	2009-03-01 12:30:53.000000000 -0500
@@ -26,32 +26,12 @@
 #ifndef __SAVEFILEMGR_H__
 #define __SAVEFILEMGR_H__
 
-#include <libmc.h>
-#include "common/savefile.h"
+// #include "common/savefile.h"
+#include "backends/saves/default/default-saves.h"
 
 class Gs2dScreen;
 class OSystem_PS2;
 
-
-class McAccess {
-public:
-	McAccess(int port, int slot);
-	~McAccess(void);
-	int open(const char *name, int mode);
-	int close(int fd);
-	int size(int fd);
-	int read(int fd, void *buf, int size);
-	int write(int fd, const void *buf, int size);
-	int mkDir(const char *name);
-	int getDir(const char *name, unsigned int mode, int max, void *dest);
-	int getInfo(int *type, int *free, int *format);
-	int remove(const char *name);
-
-private:
-	int _sema;
-	int _port, _slot;
-};
-
 class Ps2SaveFileManager : public Common::SaveFileManager {
 public:
 	Ps2SaveFileManager(OSystem_PS2 *system, Gs2dScreen *screen);
@@ -59,49 +39,19 @@
 
 	virtual Common::InSaveFile *openForLoading(const char *filename);
 	virtual Common::OutSaveFile *openForSaving(const char *filename);
-	virtual void listSavefiles(const char *prefix, bool *marks, int num);
-
 	virtual Common::StringList listSavefiles(const char *regex);
 	virtual bool removeSavefile(const char *filename);
 
-	/** Get the path to the save game directory. */
-	virtual const char *getSavePath() const;
-
-	void writeSaveNonblocking(char *name, void *buf, uint32 size);
-	void saveThread(void);
-	void quit(void);
+	// void writeSaveNonblocking(char *name, void *buf, uint32 size);
+	// void saveThread(void);
+	// void quit(void);
 
-	McAccess *getMcAccess(void);
 private:
-	bool setupIcon(const char *dest, const char *ico, const char *descr1, const char *descr2);
-
-	bool mcReadyForDir(const char *dir);
-
-	void checkMainDirectory(void);
-	void splitPath(const char *fileName, char *dir, char *name);
-	uint16 *decompressIconData(uint16 *size);
+	bool mcCheck(const char *dir);
+	void mcSplit(char *full, char *game, char *ext);
 
+	int _sema;
 	Gs2dScreen *_screen;
-	OSystem_PS2 *_system;
-	McAccess	*_mc;
-
-	int _autoSaveTid;
-	int _autoSaveSignal;
-	void *_autoSaveStack;
-	volatile bool _systemQuit;
-	uint8 *_autoSaveBuf;
-	uint32 _autoSaveSize;
-	char _autoSaveName[256];
-
-	mcTable *_mcDirList;
-	int		_mcEntries;
-	char	_mcDirName[256];
-	bool	_mcNeedsUpdate, _mcPresent;
-	uint32	_mcCheckTime;
-
-	static const uint8 _rleIcoData[14018];
-	static const iconIVECTOR _bgcolor[4];
-	static const iconFVECTOR _lightdir[3], _lightcol[3], _ambient;
 };
 
 #endif // __SAVEFILE_MGR_H__
diff -ur release-0-13-0/backends/platform/ps2/systemps2.cpp release-0-13-0-ps2/backends/platform/ps2/systemps2.cpp
--- release-0-13-0/backends/platform/ps2/systemps2.cpp	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/systemps2.cpp	2009-03-01 19:58:13.000000000 -0500
@@ -52,6 +52,7 @@
 #include "backends/platform/ps2/asyncfio.h"
 #include "eecodyvdfs.h"
 #include "graphics/surface.h"
+#include "graphics/scaler.h"
 #include "graphics/font.h"
 #include "backends/timer/default/default-timer.h"
 #include "sound/mixer_intern.h"
@@ -59,6 +60,12 @@
 #include "backends/platform/ps2/ps2debug.h"
 #include "backends/fs/ps2/ps2-fs-factory.h"
 
+#include "backends/saves/default/default-saves.h"
+#include "common/config-manager.h"
+
+#include "icon.h"
+#include "ps2temp.h"
+
 // asm("mfc0	%0, $9\n" : "=r"(tickStart));
 
 extern void *_gp;
@@ -76,7 +83,7 @@
 
 OSystem_PS2 *g_systemPs2;
 
-int gBitFormat = 555;
+int gBitFormat = 1555;
 
 #define FOREVER 2147483647
 
@@ -84,6 +91,8 @@
 	extern const NewFont g_sysfont;
 };
 
+PS2Device detectBootPath(const char *elfPath, char *bootPath);
+
 extern AsyncFio fio;
 
 extern "C" int scummvm_main(int argc, char *argv[]);
@@ -161,7 +170,7 @@
 
 void OSystem_PS2::startIrxModules(int numModules, IrxReference *modules) {
 
-	_usbMassLoaded = _useMouse = _useKbd = _useHdd = false;
+	_usbMassLoaded = _useMouse = _useKbd = _useHdd = _useNet = false;
 
 	int res = 0, rv = 0;
 	for (int i = 0; i < numModules; i++) {
@@ -191,13 +200,16 @@
 						case HDD_DRIVER:
 							_useHdd = true;
 							break;
+						case NET_DRIVER:
+							_useNet = true;
+							break;
 						default:
 							break;
 					}
 				}
 			} else
 				sioprintf("Module \"%s\" wasn't found: %d\n", modules[i].path, modules[i].errorCode);
-
+			
 			if ((modules[i].errorCode < 0) || (res < 0) || (rv < 0)) {
 				if (!(modules[i].fileRef->flags & OPTIONAL)) {
 					if (modules[i].errorCode < 0)
@@ -208,7 +220,7 @@
 					quit();
 				}
 			}
-
+			
 			if (modules[i].buffer)
 				free(modules[i].buffer);
 		} else {
@@ -236,13 +248,13 @@
 
 	_screen->wantAnim(true);
 
-	char irxPath[256];
-	_bootDevice = detectBootPath(elfPath, irxPath);
+	_bootPath = (char *)malloc(128);
+	_bootDevice = detectBootPath(elfPath, _bootPath);
 
 	IrxReference *modules;
-	int numModules = loadIrxModules(_bootDevice, irxPath, &modules);
+	int numModules = loadIrxModules(_bootDevice, _bootPath, &modules);
 
-	if (_bootDevice != HOST) {
+	if (_bootDevice != HOST_DEV) {
 		sioprintf("Resetting IOP.\n");
 		cdvdInit(CDVD_EXIT);
 		cdvdExit();
@@ -257,6 +269,14 @@
 		SifLoadFileInit();
 		cdvdInit(CDVD_INIT_WAIT);
 	}
+	else {
+		// romeo : HOST : pre-load
+
+		// TODO: avoid re-loading USB_MASS.IRX -> it will jam mass:
+
+		// TODO: ps2link 1.46 will stall on "poweroff" init / cb
+	}
+
 	startIrxModules(numModules, modules);
 
 	int res;
@@ -279,15 +299,11 @@
 		if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0))
 			_useHdd = false;
 
-		dbg_printf("romeo : hddCheckPresent done : %d\n", _useHdd);
+		//hddPreparePoweroff();
+		poweroffInit();
 
-		hddPreparePoweroff();
-		//poweroffInit();
-		dbg_printf("romeo : hddPreparePoweroff done\n");
-
-		hddSetUserPoweroffCallback(gluePowerOffCallback, this);
-		//poweroffSetCallback(gluePowerOffCallback, this);
-		dbg_printf("romeo : hddSetUserPoweroffCallback done\n");
+		//hddSetUserPoweroffCallback(gluePowerOffCallback, this);
+		poweroffSetCallback(gluePowerOffCallback, this);
 	}
 
 	fileXioSetBlockMode(FXIO_NOWAIT);
@@ -298,7 +314,7 @@
 	readRtcTime();
 
 	if (_useHdd) {
-		printf("romeo : trying to mount...\n");
+		// TODO : make partition path configurable
 		if (fio.mount("pfs0:", "hdd0:+ScummVM", 0) >= 0)
 			printf("Successfully mounted!\n");
 		else
@@ -322,13 +338,16 @@
 	sioprintf("Initializing ps2Input\n");
 	_input = new Ps2Input(this, _useMouse, _useKbd);
 
+	prepMC();
+	makeConfigPath();
+
 	_screen->wantAnim(false);
 	_screen->clearScreen();
-
-	// OSystem::initBackend(); // romeo
 }
 
 OSystem_PS2::~OSystem_PS2(void) {
+	free(_bootPath);
+	free(_configFile);
 }
 
 void OSystem_PS2::initTimer(void) {
@@ -459,22 +478,38 @@
 	ExitThread();
 }
 
+bool OSystem_PS2::mcPresent(void) {
+	int fd = fio.dopen("mc0:");
+
+	if (fd > 0) {
+		fio.dclose(fd);
+		return true;
+	}
+
+	return false;
+}
+
 bool OSystem_PS2::hddPresent(void) {
 	return _useHdd;
 }
 
 bool OSystem_PS2::usbMassPresent(void) {
-
 	if (_usbMassLoaded) {
-		int testFd = fio.dopen("mass:/");
-		if (testFd >= 0)
-			fio.dclose(testFd);
-		if (testFd != -ENODEV)
+		int fd = fio.dopen("mass:");
+
+		if (fd > 0) {
+			fio.dclose(fd);
 			return true;
+		}
 	}
+
 	return false;
 }
 
+bool OSystem_PS2::netPresent(void) {
+	return _useNet;
+}
+
 void OSystem_PS2::initSize(uint width, uint height) {
 	printf("initializing new size: (%d/%d)...", width, height);
 	_screen->newScreenSize(width, height);
@@ -670,7 +705,7 @@
 		while ((*lnEnd) && (*lnEnd != '\n'))
 			lnEnd++;
 		*lnEnd = '\0';
-
+		
 		Common::String str(lnSta);
 		int width = Graphics::g_sysfont.getStringWidth(str);
 		if (width > maxWidth)
@@ -700,7 +735,7 @@
 
 void OSystem_PS2::powerOffCallback(void) {
 	sioprintf("powerOffCallback\n");
-	_saveManager->quit();
+	// _saveManager->quit(); // romeo
 	if (_useHdd) {
 		sioprintf("umount\n");
 		fio.umount("pfs0:");
@@ -712,12 +747,12 @@
 }
 
 void OSystem_PS2::quit(void) {
-	sioprintf("OSystem_PS2::quit called\n");
-	if (_bootDevice == HOST) {
-		sioprintf("OSystem_PS2::quit (HOST)\n");
+	printf("OSystem_PS2::quit called\n");
+	if (_bootDevice == HOST_DEV) {
+		printf("OSystem_PS2::quit (HOST)\n");
 		SleepThread();
 	} else {
-		sioprintf("OSystem_PS2::quit (bootdev=%d)\n", _bootDevice);
+		printf("OSystem_PS2::quit (bootdev=%d)\n", _bootDevice);
 		if (_useHdd) {
 			driveStandby();
 			fio.umount("pfs0:");
@@ -726,26 +761,26 @@
 		_screen->wantAnim(false);
 		_systemQuit = true;
 		ee_thread_t statSound, statTimer;
-		sioprintf("Waiting for timer and sound thread to end\n");
+		printf("Waiting for timer and sound thread to end\n");
 		do {	// wait until both threads called ExitThread()
 			ReferThreadStatus(_timerTid, &statTimer);
 			ReferThreadStatus(_soundTid, &statSound);
 		} while ((statSound.status != 0x10) || (statTimer.status != 0x10));
-		sioprintf("Done\n");
+		printf("Done\n");
 		DeleteThread(_timerTid);
 		DeleteThread(_soundTid);
 		free(_timerStack);
 		free(_soundStack);
-		sioprintf("Stopping timer\n");
+		printf("Stopping timer\n");
 		DisableIntc(INT_TIMER0);
 		RemoveIntcHandler(INT_TIMER0, _intrId);
 
-		_saveManager->quit();
+		// _saveManager->quit(); // romeo
 		_screen->quit();
 
 		padEnd(); // stop pad library
 		cdvdInit(CDVD_EXIT);
-		sioprintf("resetting iop\n");
+		printf("resetting iop\n");
 		SifIopReset(NULL, 0);
 		SifExitRpc();
 		while (!SifIopSync());
@@ -754,41 +789,166 @@
 		SifExitRpc();
 		FlushCache(0);
 		SifLoadFileExit();
-		sioprintf("Restarting ScummVM\n");
-		LoadExecPS2("cdrom0:\\SCUMMVM.ELF", 0, NULL); // resets the console and executes the ELF
+
+		// TODO : let user choose from reboot and forking an ELF on exit
+
+		// reboot (default)
+		#if 1
+
+		LoadExecPS2("", 0, NULL);
+
+		// LoadExecPS2("rom0:OSDSYS",0,NULL);
+
+		// ("rom0:OSDSYS", NULL)
+		// ("", 0, NULL);
+
+		/* back to PS2 Browser */
+/*		
+		__asm__ __volatile__(
+			"   li $3, 0x04;"
+			"   syscall;"
+			"   nop;"
+        );
+*/
+	
+/*
+		SifIopReset("rom0:UNDL ", 0);
+		while (!SifIopSync()) ; 
+		// SifIopReboot(...);
+*/
+		#else
+		// reset + load ELF from CD
+		printf("Restarting ScummVM\n");
+		LoadExecPS2("cdrom0:\\SCUMMVM.ELF", 0, NULL);
+		#endif
 	}
 }
 
-void OSystem_PS2::makeConfigPath(char *dest) {
-	// FIXME: Maybe merge this method into openConfigFileForReading/openConfigFileForWriting ?
-	FILE *handle;
-	strcpy(dest, "cdfs:/ScummVM.ini");
-	handle = ps2_fopen(dest, "r");
-	if (usbMassPresent() && !handle) {
-		strcpy(dest, "mass:/ScummVM.ini");
-		handle = ps2_fopen(dest, "r");
+bool OSystem_PS2::runningFromHost(void) {
+	return (_bootDevice == HOST_DEV);
+}
+
+bool OSystem_PS2::prepMC() {
+	FILE *f;
+	bool prep = false;
+
+	if (!mcPresent())
+		return prep;
+
+	printf("prepMC 0\n");
+	// Common::String str("mc0:ScummVM/")
+	// Common::FSNode scumDir(str);
+	Common::FSNode scumDir("mc0:ScummVM/");
+
+	printf("prepMC 00\n");
+
+	if (!scumDir.exists()) {
+		uint16 *data, size;
+
+		PS2Icon _ico;
+		mcIcon icon;
+
+		printf("prepMC I\n");
+
+		size = _ico.decompressData(&data);
+
+		printf("prepMC II\n");
+
+		_ico.setup(&icon);
+
+#ifdef __USE_LIBMC__
+		int res;
+		mcInit(MC_TYPE_MC);
+		mcSync(0, NULL, NULL);
+		mcMkDir(0,0,"ScummVM");
+		mcSync(0, NULL, &res);
+		// TODO : icon
+#else
+		fio.mkdir("mc0:ScummVM");
+		f = ps2_fopen("mc0:ScummVM/scummvm.icn", "w");
+
+		printf("f = %p\n", f);
+
+		ps2_fwrite(data, size, 2, f);
+		ps2_fclose(f);
+
+		f = ps2_fopen("mc0:ScummVM/icon.sys", "w");
+
+		printf("f = %p\n", f);
+
+		ps2_fwrite(&icon, sizeof(icon), 1, f);
+		ps2_fclose(f);
+#endif
+		free(data);
+
+		printf("prepMC II\n");
+
+		prep = true;
 	}
-	if (handle)
-		ps2_fclose(handle);
+
+	return prep;
+}
+
+void OSystem_PS2::makeConfigPath() {
+    FILE *src, *dst;
+	char path[128], *buf;
+	int32 size;
+
+	Common::FSNode scumIni("mc0:ScummVM/ScummVM.ini"); // gcc bug !
+
+	switch (_bootDevice) {
+	case CD_DEV:
+		// Common::FSNode scumIni("mc0:ScummVM/ScummVM.ini");
+		if (!scumIni.exists()) {
+
+			src = ps2_fopen("cdfs:ScummVM.ini", "r");
+			if (src) {
+				size = ((Ps2File *)src)->size();
+				buf = (char *)malloc(size);
+				ps2_fread(buf, size, 1, src);
+				ps2_fclose(src);
+
+				dst = ps2_fopen("mc0:ScummVM/ScummVM.ini", "w");
+				if (dst) {
+					ps2_fwrite(buf, size, 1, dst);
+					ps2_fclose(dst);
+					sprintf(path, "mc0:ScummVM/ScummVM.ini");
+				}
+				else {
+					sprintf(path, "cdfs:ScummVM.ini");
+				}
+
+				free(buf);
+			}
+		}
+	break;
+
+	case MC_DEV:
+		sprintf(path, "mc0:ScummVM/ScummVM.ini");
+	break;
+
+	case HD_DEV:
+	case USB_DEV:
+	case HOST_DEV:
+		sprintf(path, "%sScummVM.ini", _bootPath);
+	break;
+	}
+
+	src = ps2_fopen(path, "r");
+	if (!src)
+		sprintf(path, "mc0:ScummVM/ScummVM.ini");
 	else
-		strcpy(dest, "mc0:ScummVM/scummvm.ini");
+		ps2_fclose(src);
+		
+	_configFile = strdup(path);
 }
 
 Common::SeekableReadStream *OSystem_PS2::openConfigFileForReading() {
-	char configFile[MAXPATHLEN];
-	makeConfigPath(configFile);
-	Common::FSNode file(configFile);
+	Common::FSNode file(_configFile);
 	return file.openForReading();
 }
-
+    
 Common::WriteStream *OSystem_PS2::openConfigFileForWriting() {
-	char configFile[MAXPATHLEN];
-	makeConfigPath(configFile);
-	Common::FSNode file(configFile);
+	Common::FSNode file(_configFile);
 	return file.openForWriting();
 }
-
-bool OSystem_PS2::runningFromHost(void) {
-	return (_bootDevice == HOST);
-}
-
diff -ur release-0-13-0/backends/platform/ps2/systemps2.h release-0-13-0-ps2/backends/platform/ps2/systemps2.h
--- release-0-13-0/backends/platform/ps2/systemps2.h	2009-03-01 11:27:22.000000000 -0500
+++ release-0-13-0-ps2/backends/platform/ps2/systemps2.h	2009-03-01 19:58:30.000000000 -0500
@@ -29,6 +29,7 @@
 #include "common/system.h"
 
 class DefaultTimerManager;
+class DefaultSaveFileManager;
 
 class Gs2dScreen;
 class Ps2Input;
@@ -110,7 +111,7 @@
 	virtual Common::SeekableReadStream *openConfigFileForReading();
 	virtual Common::WriteStream *openConfigFileForWriting();
 
-	virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<555>(); }
+	virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<1555>(); }
 
 	virtual Common::SaveFileManager *getSavefileManager();
 	virtual FilesystemFactory *getFilesystemFactory();
@@ -120,13 +121,19 @@
 	void timerThread(void);
 	void soundThread(void);
 	void msgPrintf(int millis, char *format, ...);
-	void makeConfigPath(char *dest);
+	void makeConfigPath(void);
+	bool prepMC();
 
 	void powerOffCallback(void);
+
+	bool mcPresent(void);
 	bool hddPresent(void);
 	bool usbMassPresent(void);
+	bool netPresent(void);
 
 	bool runningFromHost(void);
+	int getBootDevice() { return _bootDevice; }
+
 private:
 	void startIrxModules(int numModules, IrxReference *modules);
 
@@ -139,9 +146,10 @@
 
 
 	bool _mouseVisible;
-	bool _useMouse, _useKbd, _useHdd, _usbMassLoaded;
+	bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _useNet;
 
 	Ps2SaveFileManager *_saveManager;
+	// DefaultSaveFileManager *_saveManager;
 
 	Gs2dScreen	*_screen;
 	Ps2Input	*_input;
@@ -159,6 +167,8 @@
 	static const GraphicsMode _graphicsMode;
 
 	int			_bootDevice;
+	char		*_bootPath;
+	char		*_configFile;
 };
 
 #endif // SYSTEMPS2_H
diff -ur release-0-13-0/base/main.cpp release-0-13-0-ps2/base/main.cpp
--- release-0-13-0/base/main.cpp	2009-03-01 11:27:21.000000000 -0500
+++ release-0-13-0-ps2/base/main.cpp	2009-03-01 11:50:28.000000000 -0500
@@ -322,11 +322,14 @@
 			}
 
 			// Quit unless an error occurred, or Return to launcher was requested
+#ifndef __PLAYSTATION2__
 			if (result == 0 && !g_system->getEventManager()->shouldRTL())
 				break;
-
+#endif
 			// Reset RTL flag in case we want to load another engine
 			g_system->getEventManager()->resetRTL();
+			g_system->getEventManager()->resetQuit();
+			// TODO : restore mouse pointer properly !
 
 			// Discard any command line options. It's unlikely that the user
 			// wanted to apply them to *all* games ever launched.
diff -ur release-0-13-0/common/config-manager.cpp release-0-13-0-ps2/common/config-manager.cpp
--- release-0-13-0/common/config-manager.cpp	2009-03-01 11:27:19.000000000 -0500
+++ release-0-13-0-ps2/common/config-manager.cpp	2009-03-01 19:39:44.000000000 -0500
@@ -71,8 +71,9 @@
 
 	// ... and close it again.
 	delete stream;
-
+// #ifndef __PLAYSTATION2__
 	flushToDisk();
+// #endif
 }
 
 void ConfigManager::loadConfigFile(const String &filename) {
diff -ur release-0-13-0/common/events.h release-0-13-0-ps2/common/events.h
--- release-0-13-0/common/events.h	2009-03-01 11:27:19.000000000 -0500
+++ release-0-13-0-ps2/common/events.h	2009-03-01 12:57:24.000000000 -0500
@@ -194,6 +194,7 @@
 	 * Used when we have returned to the launcher.
 	 */
 	virtual void resetRTL() = 0;
+	virtual void resetQuit() = 0;
 
 	// Optional: check whether a given key is currently pressed ????
 	//virtual bool isKeyPressed(int keycode) = 0;
diff -ur release-0-13-0/common/hashmap.h release-0-13-0-ps2/common/hashmap.h
--- release-0-13-0/common/hashmap.h	2009-03-01 11:27:19.000000000 -0500
+++ release-0-13-0-ps2/common/hashmap.h	2009-03-01 12:52:30.000000000 -0500
@@ -262,8 +262,12 @@
  * Base constructor, creates an empty hashmap.
  */
 template<class Key, class Val, class HashFunc, class EqualFunc>
-HashMap<Key, Val, HashFunc, EqualFunc>::HashMap() :
-	_defaultVal() {
+HashMap<Key, Val, HashFunc, EqualFunc>::HashMap()
+#ifndef __PLAYSTATION2__
+	: _defaultVal() {
+#else
+{
+#endif
 	_mask = HASHMAP_MIN_CAPACITY - 1;
 	_storage = new Node *[HASHMAP_MIN_CAPACITY];
 	assert(_storage != NULL);
diff -ur release-0-13-0/gui/options.cpp release-0-13-0-ps2/gui/options.cpp
--- release-0-13-0/gui/options.cpp	2009-03-01 11:27:08.000000000 -0500
+++ release-0-13-0-ps2/gui/options.cpp	2009-03-01 14:43:54.000000000 -0500
@@ -756,7 +756,7 @@
 void GlobalOptionsDialog::open() {
 	OptionsDialog::open();
 
-#if !( defined(__DC__) || defined(__GP32__) || defined(__PLAYSTATION2__) )
+#if !( defined(__DC__) || defined(__GP32__) )
 	// Set _savePath to the current save path
 	Common::String savePath(ConfMan.get("savepath", _domain));
 	Common::String themePath(ConfMan.get("themepath", _domain));

