aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heider2009-01-19 23:57:49 +0000
committerAndre Heider2009-01-19 23:57:49 +0000
commit57d118e9308137c62a6023323d5df9be6a429469 (patch)
tree42ec7f90b0c57cb938479721fd843c56e32dafca
parent017b39eae0891c485671f52d53b5a60ac1dff195 (diff)
downloadscummvm-rg350-57d118e9308137c62a6023323d5df9be6a429469.tar.gz
scummvm-rg350-57d118e9308137c62a6023323d5df9be6a429469.tar.bz2
scummvm-rg350-57d118e9308137c62a6023323d5df9be6a429469.zip
Added ISO9660/Joliet DVD support
svn-id: r35930
-rw-r--r--backends/fs/wii/wii-fs-factory.cpp5
-rw-r--r--backends/fs/wii/wii-fs-factory.h2
-rw-r--r--backends/fs/wii/wii-fs.cpp60
-rw-r--r--backends/platform/wii/Makefile2
-rw-r--r--backends/platform/wii/main.cpp19
-rw-r--r--backends/platform/wii/osystem.cpp8
-rw-r--r--backends/platform/wii/osystem.h6
7 files changed, 98 insertions, 4 deletions
diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp
index 6bc07dd161..c9513f7784 100644
--- a/backends/fs/wii/wii-fs-factory.cpp
+++ b/backends/fs/wii/wii-fs-factory.cpp
@@ -45,5 +45,10 @@ AbstractFSNode *WiiFilesystemFactory::makeCurrentDirectoryFileNode() const {
AbstractFSNode *WiiFilesystemFactory::makeFileNodePath(const Common::String &path) const {
return new WiiFilesystemNode(path);
}
+
+void WiiFilesystemFactory::asyncHandler(bool mount, const Common::String *path) {
+ WiiFilesystemNode::asyncHandler(mount, path);
+}
+
#endif
diff --git a/backends/fs/wii/wii-fs-factory.h b/backends/fs/wii/wii-fs-factory.h
index be20244a0e..f58371d194 100644
--- a/backends/fs/wii/wii-fs-factory.h
+++ b/backends/fs/wii/wii-fs-factory.h
@@ -37,6 +37,8 @@ public:
virtual AbstractFSNode *makeCurrentDirectoryFileNode() const;
virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const;
+ static void asyncHandler(bool mount, const Common::String *path);
+
protected:
WiiFilesystemFactory() {};
diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp
index 7c42eb6e4a..6764a596a5 100644
--- a/backends/fs/wii/wii-fs.cpp
+++ b/backends/fs/wii/wii-fs.cpp
@@ -33,6 +33,10 @@
#include <gctypes.h>
+#ifndef GAMECUBE
+#include <di/di.h>
+#endif
+
/**
* Implementation of the ScummVM file system API based on Wii.
*
@@ -77,8 +81,60 @@ public:
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
+
+ static void asyncHandler(bool umount, const Common::String *path);
};
+void WiiFilesystemNode::asyncHandler(bool mount, const Common::String *path) {
+#ifndef GAMECUBE
+ static bool di_tryMount = true;
+ static bool di_isMounted = false;
+
+ // umount not required filesystems
+ if (!mount) {
+ if (di_isMounted && (!path || (path && !path->hasPrefix("dvd:/")))) {
+ printf("umount ISO9660\n");
+ ISO9660_Unmount();
+ DI_StopMotor();
+ di_tryMount = false;
+ di_isMounted = false;
+ }
+
+ if (!path)
+ return;
+ }
+
+ // re-mount DVD if data from its path has been requested. in this case, we
+ // have to wait for DI_Mount() to finish
+ if (!di_tryMount && !di_isMounted && path && path->hasPrefix("dvd:/")) {
+ printf("remount ISO9660\n");
+ DI_Mount();
+
+ while (DI_GetStatus() & DVD_INIT)
+ usleep(20 * 1000);
+
+ di_tryMount = true;
+ }
+
+ if (!di_tryMount)
+ return;
+
+ // check if the async DI_Mount() call has finished
+ if (DI_GetStatus() & DVD_READY) {
+ di_tryMount = false;
+
+ printf("mount ISO9660\n");
+ if (ISO9660_Mount()) {
+ di_isMounted = true;
+ printf("ISO9660 mounted\n");
+ } else {
+ DI_StopMotor();
+ printf("ISO9660 mount failed\n");
+ }
+ }
+#endif
+}
+
// gets all registered devoptab devices
bool WiiFilesystemNode::getDevopChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
u8 i;
@@ -87,6 +143,8 @@ bool WiiFilesystemNode::getDevopChildren(AbstractFSList &list, ListMode mode, bo
if (mode == Common::FSNode::kListFilesOnly)
return true;
+ asyncHandler(true, NULL);
+
// skip in, out and err
for (i = 3; i < STD_MAX; ++i) {
dt = devoptab_list[i];
@@ -142,6 +200,8 @@ WiiFilesystemNode::WiiFilesystemNode(const Common::String &p) {
_displayName = lastPathComponent(_path, '/');
+ asyncHandler(true, &_path);
+
struct stat st;
if (!stat(_path.c_str(), &st))
setFlags(&st);
diff --git a/backends/platform/wii/Makefile b/backends/platform/wii/Makefile
index 8ee7ad7d42..54a10acf97 100644
--- a/backends/platform/wii/Makefile
+++ b/backends/platform/wii/Makefile
@@ -100,7 +100,7 @@ TARGET = scummvm-wii
MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float \
-ffunction-sections -fdata-sections -fmodulo-sched
LIBDIR = $(DEVKITPRO)/libogc/lib/wii
-LIBS = -lstdc++ -lfat -lwiiuse -lbte -logc -lm
+LIBS = -lstdc++ -ldi -lfat -lwiiuse -lbte -logc -lm
endif
INCDIR = $(srcdir) . $(srcdir)/engines/ $(DEVKITPRO)/libogc/include
diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp
index 3b5ce3762f..3c53039ea2 100644
--- a/backends/platform/wii/main.cpp
+++ b/backends/platform/wii/main.cpp
@@ -27,12 +27,16 @@
#include <ogc/machine/processor.h>
#include <fat.h>
-#include "osystem.h"
+#ifndef GAMECUBE
+#include <di/di.h>
+#endif
#ifdef DEBUG_WII_GDB
#include <debug.h>
#endif
+#include "osystem.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -79,6 +83,10 @@ void wii_memstats(void) {
int main(int argc, char *argv[]) {
s32 res;
+#ifndef GAMECUBE
+ DI_Init();
+#endif
+
VIDEO_Init();
PAD_Init();
AUDIO_Init(NULL);
@@ -102,6 +110,11 @@ int main(int argc, char *argv[]) {
SYS_SetPowerCallback(power_cb);
#endif
+#ifndef GAMECUBE
+ // initial async mount for the browser, see wii-fs.cpp
+ DI_Mount();
+#endif
+
if (!fatInitDefault()) {
printf("fatInitDefault failed\n");
} else {
@@ -136,6 +149,10 @@ int main(int argc, char *argv[]) {
fatUnmountDefault();
#endif
+#ifndef GAMECUBE
+ DI_Close();
+#endif
+
if (power_btn_pressed) {
printf("shutting down\n");
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 885a460bac..12fe5341cd 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -115,6 +115,9 @@ void OSystem_Wii::quit() {
deinitEvents();
deinitSfx();
deinitGfx();
+
+ // umount all async filesystems
+ WiiFilesystemFactory::asyncHandler(false, NULL);
}
bool OSystem_Wii::hasFeature(Feature f) {
@@ -212,3 +215,8 @@ void OSystem_Wii::getTimeAndDate(struct tm &t) const {
t = *localtime(&curTime);
}
+void OSystem_Wii::engineInit() {
+ // umount not required filesystems for this game
+ WiiFilesystemFactory::asyncHandler(false, &ConfMan.get("path"));
+}
+
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index 807b825097..b5476a21d0 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -167,8 +167,10 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual Audio::Mixer *getMixer();
virtual Common::TimerManager *getTimerManager();
- FilesystemFactory *getFilesystemFactory();
- void getTimeAndDate(struct tm &t) const;
+ virtual FilesystemFactory *getFilesystemFactory();
+ virtual void getTimeAndDate(struct tm &t) const;
+
+ virtual void engineInit();
};
#endif