Skip to content

Commit

Permalink
Merge pull request #413 from AReim1982/master
Browse files Browse the repository at this point in the history
WII: Implement changes needed by DevKitPPC R26 and later
  • Loading branch information
David Turner committed Jan 21, 2014
2 parents 2e93f5a + eff22cb commit b098b74
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
6 changes: 4 additions & 2 deletions backends/fs/wii/wii-fs-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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");
Expand Down Expand Up @@ -179,7 +181,7 @@ void WiiFilesystemFactory::umount(FileSystemType type) {

printf("umount dvd\n");

ISO9660_Unmount();
ISO9660_Unmount("dvd:");

_dvdMounted = false;
_dvdError = false;
Expand Down
44 changes: 28 additions & 16 deletions backends/fs/wii/wii-fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion backends/fs/wii/wii-fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion backends/platform/wii/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion backends/platform/wii/osystem_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions backends/platform/wii/wii.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ webos)
wii)
_host_os=wii
_host_cpu=ppc
_host_alias=powerpc-gekko
_host_alias=powerpc-eabi
;;
wince)
_host_os=wince
Expand Down Expand Up @@ -2709,6 +2709,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'
Expand Down

0 comments on commit b098b74

Please sign in to comment.