From 2bca032852a61f8572b264dd4cc676beb01c7b8f Mon Sep 17 00:00:00 2001 From: AReim1982 Date: Fri, 22 Nov 2013 15:13:56 +0100 Subject: [PATCH] WII: Implement changes needed by DevKitPPC R26 and later This changes makes ScummVM compilable with newer versions of DevKitPPC. ScummVM can be linked against the original libogc and libfat. That makes some newer WiiMotes work, improves audio-/video-playback and contains various improvements. --- backends/fs/wii/wii-fs-factory.cpp | 6 ++-- backends/fs/wii/wii-fs.cpp | 44 +++++++++++++++--------- backends/fs/wii/wii-fs.h | 2 +- backends/platform/wii/main.cpp | 3 +- backends/platform/wii/osystem_events.cpp | 2 +- backends/platform/wii/wii.mk | 4 +-- configure | 3 +- 7 files changed, 40 insertions(+), 24 deletions(-) diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index 760e5316e772..987e7f56bf36 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -125,6 +125,8 @@ bool WiiFilesystemFactory::failedToMount(FileSystemType type) { return false; } +const DISC_INTERFACE* dvd = &__io_wiidvd; + void WiiFilesystemFactory::mount(FileSystemType type) { switch (type) { case kDVD: @@ -133,7 +135,7 @@ void WiiFilesystemFactory::mount(FileSystemType type) { break; printf("mount dvd\n"); - if (ISO9660_Mount()) { + if (ISO9660_Mount("dvd", dvd)) { _dvdMounted = true; _dvdError = false; printf("ISO9660 mounted\n"); @@ -179,7 +181,7 @@ void WiiFilesystemFactory::umount(FileSystemType type) { printf("umount dvd\n"); - ISO9660_Unmount(); + ISO9660_Unmount("dvd:"); _dvdMounted = false; _dvdError = false; diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp index 4a19e1824044..43f4f592b782 100644 --- a/backends/fs/wii/wii-fs.cpp +++ b/backends/fs/wii/wii-fs.cpp @@ -80,9 +80,9 @@ void WiiFilesystemNode::clearFlags() { void WiiFilesystemNode::setFlags(const struct stat *st) { _exists = true; - _isDirectory = S_ISDIR(st->st_mode); - _isReadable = (st->st_mode & S_IRUSR) > 0; - _isWritable = (st->st_mode & S_IWUSR) > 0; + _isDirectory = ( (st->st_mode & S_IFDIR) != 0 ); + _isReadable = ( (st->st_mode & S_IRUSR) != 0 ); + _isWritable = ( (st->st_mode & S_IWUSR) != 0 ); } WiiFilesystemNode::WiiFilesystemNode() { @@ -106,7 +106,7 @@ WiiFilesystemNode::WiiFilesystemNode(const Common::String &p) { _displayName = lastPathComponent(_path, '/'); struct stat st; - if (!stat(_path.c_str(), &st)) + if(stat(_path.c_str(), &st) != -1) setFlags(&st); else clearFlags(); @@ -152,33 +152,45 @@ bool WiiFilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi if (_path.empty()) return getDevopChildren(list, mode, hidden); - DIR_ITER* dp = diropen (_path.c_str()); + DIR* dp = opendir (_path.c_str()); + DIR* tmpdir; if (dp == NULL) return false; - char filename[MAXPATHLEN]; - struct stat st; + struct dirent *pent; - while (dirnext(dp, filename, &st) == 0) { - if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) + while ((pent = readdir(dp)) != NULL) { + if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) continue; Common::String newPath(_path); if (newPath.lastChar() != '/') - newPath += '/'; - newPath += filename; - - bool isDir = S_ISDIR(st.st_mode); - + newPath += '/'; + newPath += pent->d_name; + + bool isDir = false; + tmpdir = opendir(newPath.c_str()); + if(tmpdir) + { + isDir = true; + closedir(tmpdir); + } + if ((mode == Common::FSNode::kListFilesOnly && isDir) || (mode == Common::FSNode::kListDirectoriesOnly && !isDir)) continue; - + + struct stat st; + st.st_mode = 0; + st.st_mode |= ( isDir ? S_IFDIR : 0 ); + st.st_mode |= S_IRUSR; + st.st_mode |= S_IWUSR; + list.push_back(new WiiFilesystemNode(newPath, &st)); } - dirclose(dp); + closedir(dp); return true; } diff --git a/backends/fs/wii/wii-fs.h b/backends/fs/wii/wii-fs.h index 11679d0c3630..f785101099b5 100644 --- a/backends/fs/wii/wii-fs.h +++ b/backends/fs/wii/wii-fs.h @@ -51,7 +51,7 @@ class WiiFilesystemNode : public AbstractFSNode { * * @param path Common::String with the path the new node should point to. */ - WiiFilesystemNode(const Common::String &path); + WiiFilesystemNode(const Common::String &p); WiiFilesystemNode(const Common::String &p, const struct stat *st); virtual bool exists() const; diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp index affe053b6a60..ec6231522ee9 100644 --- a/backends/platform/wii/main.cpp +++ b/backends/platform/wii/main.cpp @@ -225,7 +225,8 @@ int main(int argc, char *argv[]) { printf("shutdown\n"); SYS_UnregisterResetFunc(&resetinfo); - fatUnmountDefault(); + fatUnmount("usb:/"); + fatUnmount("sd:/"); if (res) show_console(res); diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp index 3ba66aed8935..aa63c8aa22e1 100644 --- a/backends/platform/wii/osystem_events.cpp +++ b/backends/platform/wii/osystem_events.cpp @@ -188,7 +188,7 @@ void OSystem_Wii::initEvents() { _padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration"); #ifdef USE_WII_KBD - _kbd_active = KEYBOARD_Init() >= 0; + _kbd_active = KEYBOARD_Init(NULL) >= 0; #endif } diff --git a/backends/platform/wii/wii.mk b/backends/platform/wii/wii.mk index 7d2db68b4e2c..99ef46338cc4 100644 --- a/backends/platform/wii/wii.mk +++ b/backends/platform/wii/wii.mk @@ -17,10 +17,10 @@ geckoupload: $(WII_EXE_STRIPPED) $(DEVKITPPC)/bin/geckoupload $< wiigdb: - $(DEVKITPPC)/bin/powerpc-gekko-gdb -n $(EXECUTABLE) + $(DEVKITPPC)/bin/powerpc-eabi-gdb -n $(EXECUTABLE) wiidebug: - $(DEVKITPPC)/bin/powerpc-gekko-gdb -n $(EXECUTABLE) -x $(srcdir)/backends/platform/wii/gdb.txt + $(DEVKITPPC)/bin/powerpc-eabi-gdb -n $(EXECUTABLE) -x $(srcdir)/backends/platform/wii/gdb.txt # target to create a Wii snapshot wiidist: all diff --git a/configure b/configure index 4f647a051686..76bbcdf77f0d 100755 --- a/configure +++ b/configure @@ -1412,7 +1412,7 @@ webos) wii) _host_os=wii _host_cpu=ppc - _host_alias=powerpc-gekko + _host_alias=powerpc-eabi ;; wince) _host_os=wince @@ -2707,6 +2707,7 @@ if test -n "$_host"; then _backend="wii" _build_scalers=no _vkeybd=yes + _taskbar=no _port_mk="backends/platform/wii/wii.mk" add_line_to_config_mk 'GAMECUBE = 0' add_line_to_config_h '#define AUDIO_REVERSE_STEREO'