-added simple check if we are in dolphin-emu mode, no need to

define something or recompile wiiflow (thanks skidau)
This commit is contained in:
fix94.1 2012-09-20 16:09:32 +00:00
parent 5cf17dfae6
commit c3b3429645
9 changed files with 127 additions and 75 deletions

View File

@ -52,5 +52,3 @@ postLoader"
#define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}" #define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}"
#define DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}" #define DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"
//#define DOLPHIN true

View File

@ -31,12 +31,13 @@
#include <sdcard/gcsd.h> #include <sdcard/gcsd.h>
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#include "DeviceHandler.hpp" #include "DeviceHandler.hpp"
#include "defines.h" #include "fat.h"
#include "sdhc.h" #include "sdhc.h"
#include "usbthread.h" #include "usbthread.h"
#include "usbstorage.h" #include "usbstorage.h"
#include "usbstorage_libogc.h" #include "usbstorage_libogc.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
DeviceHandler * DeviceHandler::instance = NULL; DeviceHandler * DeviceHandler::instance = NULL;
@ -62,14 +63,23 @@ void DeviceHandler::DestroyInstance()
void DeviceHandler::MountAll() void DeviceHandler::MountAll()
{ {
if(Sys_DolphinMode())
{
DolphinSD = fatMountSimple("sd", &__io_wiisd);
return;
}
MountSD(); MountSD();
#ifndef DOLPHIN
MountAllUSB(); MountAllUSB();
#endif
} }
void DeviceHandler::UnMountAll() void DeviceHandler::UnMountAll()
{ {
if(Sys_DolphinMode())
{
fatUnmount("sd");
DolphinSD = false;
return;
}
/* Kill possible USB thread */ /* Kill possible USB thread */
KillUSBKeepAliveThread(); KillUSBKeepAliveThread();
@ -106,7 +116,7 @@ bool DeviceHandler::Mount(int dev)
bool DeviceHandler::IsInserted(int dev) bool DeviceHandler::IsInserted(int dev)
{ {
if(dev == SD) if(dev == SD)
return SD_Inserted() && sd->IsMounted(0); return Sys_DolphinMode() ? DolphinSD : SD_Inserted() && sd->IsMounted(0);
else if(dev >= USB1 && dev <= USB8) else if(dev >= USB1 && dev <= USB8)
{ {
@ -431,6 +441,9 @@ void DeviceHandler::UnMountDevolution(int CurrentPartition)
bool DeviceHandler::UsablePartitionMounted() bool DeviceHandler::UsablePartitionMounted()
{ {
if(Sys_DolphinMode())
return DolphinSD;
for(u8 i = SD; i < MAXDEVICES; i++) for(u8 i = SD; i < MAXDEVICES; i++)
{ {
if(IsInserted(i) && !GetWbfsHandle(i)) //Everything besides WBFS for configuration if(IsInserted(i) && !GetWbfsHandle(i)) //Everything besides WBFS for configuration
@ -443,6 +456,6 @@ bool DeviceHandler::PartitionUsableForNandEmu(int Partition)
{ {
if(IsInserted(Partition) && GetFSType(Partition) == PART_FS_FAT) if(IsInserted(Partition) && GetFSType(Partition) == PART_FS_FAT)
return true; return true;
return false; return false;
} }

View File

@ -65,70 +65,72 @@ const char DeviceName[MAXDEVICES][8] =
class DeviceHandler class DeviceHandler
{ {
public: public:
static DeviceHandler * Instance(); static DeviceHandler * Instance();
static void DestroyInstance(); static void DestroyInstance();
void SetModes(); void SetModes();
void MountAll(); void MountAll();
void UnMountAll(); void UnMountAll();
bool Mount(int dev); bool Mount(int dev);
bool IsInserted(int dev); bool IsInserted(int dev);
void UnMount(int dev); void UnMount(int dev);
//! Individual Mounts/UnMounts... //! Individual Mounts/UnMounts...
bool MountSD(); bool MountSD();
bool MountAllUSB(); bool MountAllUSB();
bool MountUSBPort1(); bool MountUSBPort1();
bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; } bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; }
bool USB0_Inserted() { if(usb0) return usb0->IsInserted(); return false; } bool USB0_Inserted() { if(usb0) return usb0->IsInserted(); return false; }
bool USB1_Inserted() { if(usb1) return usb1->IsInserted(); return false; } bool USB1_Inserted() { if(usb1) return usb1->IsInserted(); return false; }
bool UsablePartitionMounted(); bool UsablePartitionMounted();
bool PartitionUsableForNandEmu(int Partition); bool PartitionUsableForNandEmu(int Partition);
void WaitForDevice(const DISC_INTERFACE *Handle); void WaitForDevice(const DISC_INTERFACE *Handle);
void UnMountSD() { if(sd) delete sd; sd = NULL; } void UnMountSD() { if(sd) delete sd; sd = NULL; }
void UnMountUSB(int pos); void UnMountUSB(int pos);
void UnMountAllUSB(); void UnMountAllUSB();
PartitionHandle * GetSDHandle() const { return sd; } PartitionHandle * GetSDHandle() const { return sd; }
PartitionHandle * GetUSB0Handle() const { return usb0; } PartitionHandle * GetUSB0Handle() const { return usb0; }
PartitionHandle * GetUSB1Handle() const { return usb1; } PartitionHandle * GetUSB1Handle() const { return usb1; }
PartitionHandle * GetUSBHandleFromPartition(int part) const; PartitionHandle * GetUSBHandleFromPartition(int part) const;
static const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; } static const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; }
static const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; } static const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; }
static int PathToDriveType(const char * path); static int PathToDriveType(const char * path);
static const char * GetFSName(int dev); static const char * GetFSName(int dev);
static int GetFSType(int dev); static int GetFSType(int dev);
static u16 GetUSBPartitionCount(); static u16 GetUSBPartitionCount();
static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); } static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); }
static wbfs_t *GetWbfsHandle(int dev); static wbfs_t *GetWbfsHandle(int dev);
s32 Open_WBFS(int dev); s32 Open_WBFS(int dev);
static int PartitionToUSBPort(int part); static int PartitionToUSBPort(int part);
static int PartitionToPortPartition(int part); static int PartitionToPortPartition(int part);
/* Special Devolution Stuff */ /* Special Devolution Stuff */
bool MountDevolution(int CurrentPartition); bool MountDevolution(int CurrentPartition);
void UnMountDevolution(int CurrentPartition); void UnMountDevolution(int CurrentPartition);
private: private:
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0) { } DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0), DolphinSD(false) { }
~DeviceHandler(); ~DeviceHandler();
bool MountUSB(int part); bool MountUSB(int part);
static DeviceHandler *instance; static DeviceHandler *instance;
PartitionHandle * sd; PartitionHandle * sd;
PartitionHandle * gca; PartitionHandle * gca;
PartitionHandle * gcb; PartitionHandle * gcb;
PartitionHandle * usb0; PartitionHandle * usb0;
PartitionHandle * usb1; PartitionHandle * usb1;
/* Special Devolution Stuff */ /* Special Devolution Stuff */
PartitionHandle *OGC_Device; PartitionHandle *OGC_Device;
/* Dolphin Stuff */
bool DolphinSD;
}; };
#endif #endif

View File

@ -86,7 +86,6 @@ bool loadIOS(int ios, bool MountDevices)
int CurIOS = IOS_GetVersion(); int CurIOS = IOS_GetVersion();
bool ret = true; bool ret = true;
#ifndef DOLPHIN
if(ios != CurIOS) if(ios != CurIOS)
{ {
WDVD_Close(); WDVD_Close();
@ -99,7 +98,6 @@ bool loadIOS(int ios, bool MountDevices)
gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched()); gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched());
WDVD_Init(); WDVD_Init();
} }
#endif
IOS_GetCurrentIOSInfo(); IOS_GetCurrentIOSInfo();
if(CurrentIOS.Type == IOS_TYPE_HERMES) if(CurrentIOS.Type == IOS_TYPE_HERMES)

View File

@ -153,3 +153,52 @@ void Sys_SetNeekPath(const char *Path)
{ {
NeekPath = Path; NeekPath = Path;
} }
bool ModeChecked = false;
bool DolphinMode = false;
bool Sys_DolphinMode(void)
{
if(ModeChecked)
return DolphinMode;
/* Thanks to skidau for that code! */
u32 ifpr11 = 0x12345678;
u32 ifpr12 = 0x9abcdef0;
u32 ofpr1 = 0x00000000;
u32 ofpr2 = 0x00000000;
asm volatile (
"lwz 3,%[ifpr11]\n\t"
"stw 3,8(1)\n\t"
"lwz 3,%[ifpr12]\n\t"
"stw 3,12(1)\n\t"
"lfd 1,8(1)\n\t"
"frsqrte 1, 1\n\t"
"stfd 1,8(1)\n\t"
"lwz 3,8(1)\n\t"
"stw 3, %[ofpr1]\n\t"
"lwz 3,12(1)\n\t"
"stw 3, %[ofpr2]\n\t"
:
[ofpr1]"=m" (ofpr1)
,[ofpr2]"=m" (ofpr2)
:
[ifpr11]"m" (ifpr11)
,[ifpr12]"m" (ifpr12)
);
if(ofpr1 != 0x56cc62b2)
{
gprintf("Dolphin-Emu\n");
DolphinMode = true;
}
else
{
gprintf("Real Wii\n");
DolphinMode = false;
}
ModeChecked = true;
return DolphinMode;
}

View File

@ -30,6 +30,7 @@ enum
/* Prototypes */ /* Prototypes */
void Sys_Init(void); void Sys_Init(void);
void Sys_Shutdown(void); void Sys_Shutdown(void);
bool Sys_DolphinMode(void);
bool Sys_Exiting(void); bool Sys_Exiting(void);
void Sys_Exit(void); void Sys_Exit(void);
void Sys_ExitTo(int); void Sys_ExitTo(int);

View File

@ -63,9 +63,8 @@ int main(int argc, char **argv)
else if(argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL) else if(argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL)
Emulator_boot = true; Emulator_boot = true;
} }
#ifndef DOLPHIN
// Load Custom IOS // Load Custom IOS
if(neek2o()) if(neek2o() || Sys_DolphinMode())
{ {
iosOK = true; iosOK = true;
memset(&CurrentIOS, 0, sizeof(IOS_Info)); memset(&CurrentIOS, 0, sizeof(IOS_Info));
@ -86,10 +85,6 @@ int main(int argc, char **argv)
gprintf("Loading cIOS: %d\n", mainIOS); gprintf("Loading cIOS: %d\n", mainIOS);
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type); iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
} }
#else
iosOK = true;
#endif
// Init // Init
Sys_Init(); Sys_Init();
Sys_ExitTo(EXIT_TO_HBC); Sys_ExitTo(EXIT_TO_HBC);
@ -100,7 +95,7 @@ int main(int argc, char **argv)
mainMenu = new CMenu(vid); mainMenu = new CMenu(vid);
Open_Inputs(); Open_Inputs();
mainMenu->init(); mainMenu->init();
if(CurrentIOS.Version != mainIOS && !neek2o()) if(CurrentIOS.Version != mainIOS && !neek2o() && !Sys_DolphinMode())
{ {
if(useMainIOS || !DeviceHandler::Instance()->UsablePartitionMounted()) if(useMainIOS || !DeviceHandler::Instance()->UsablePartitionMounted())
{ {

View File

@ -2655,7 +2655,7 @@ void CMenu::_TempLoadIOS(int IOS)
{ {
#ifndef DOLPHIN #ifndef DOLPHIN
/* Only temp reload in IOS58 mode */ /* Only temp reload in IOS58 mode */
if(useMainIOS || neek2o()) if(useMainIOS || neek2o() || Sys_DolphinMode())
return; return;
if(IOS == IOS_TYPE_NORMAL_IOS) if(IOS == IOS_TYPE_NORMAL_IOS)

View File

@ -1180,8 +1180,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(dvd) if(dvd)
{ {
u32 cover = 0; u32 cover = 0;
#ifndef DOLPHIN if(!neek2o() && !Sys_DolphinMode())
if(!neek2o())
{ {
Disc_SetUSB(NULL, false); Disc_SetUSB(NULL, false);
if(WDVD_GetCoverStatus(&cover) < 0) if(WDVD_GetCoverStatus(&cover) < 0)
@ -1200,7 +1199,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
} while(!(cover & 0x2)); } while(!(cover & 0x2));
} }
} }
#endif
_TempLoadIOS(); _TempLoadIOS();
/* Open Disc */ /* Open Disc */
if(Disc_Open(true) < 0) if(Disc_Open(true) < 0)
@ -1357,13 +1355,11 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
m_cfg.save(true); m_cfg.save(true);
cleanup(); // wifi and sd gecko doesnt work anymore after cleanup cleanup(); // wifi and sd gecko doesnt work anymore after cleanup
#ifndef DOLPHIN if((!dvd || neek2o()) && !Sys_DolphinMode())
if(!dvd || neek2o())
{ {
if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED) if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
Sys_Exit(); Sys_Exit();
} }
#endif
DeviceHandler::Instance()->Open_WBFS(currentPartition); DeviceHandler::Instance()->Open_WBFS(currentPartition);
bool wbfs_partition = (DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS); bool wbfs_partition = (DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS);
if(!dvd && !wbfs_partition && get_frag_list((u8 *)id.c_str(), (char*)path.c_str(), currentPartition == 0 ? 0x200 : USBStorage2_GetSectorSize()) < 0) if(!dvd && !wbfs_partition && get_frag_list((u8 *)id.c_str(), (char*)path.c_str(), currentPartition == 0 ? 0x200 : USBStorage2_GetSectorSize()) < 0)