From 57d118e9308137c62a6023323d5df9be6a429469 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Mon, 19 Jan 2009 23:57:49 +0000 Subject: Added ISO9660/Joliet DVD support svn-id: r35930 --- backends/fs/wii/wii-fs-factory.cpp | 5 ++++ backends/fs/wii/wii-fs-factory.h | 2 ++ backends/fs/wii/wii-fs.cpp | 60 ++++++++++++++++++++++++++++++++++++++ backends/platform/wii/Makefile | 2 +- backends/platform/wii/main.cpp | 19 +++++++++++- backends/platform/wii/osystem.cpp | 8 +++++ backends/platform/wii/osystem.h | 6 ++-- 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 +#ifndef GAMECUBE +#include +#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 #include -#include "osystem.h" +#ifndef GAMECUBE +#include +#endif #ifdef DEBUG_WII_GDB #include #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 -- cgit v1.2.3