mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
-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:
parent
5cf17dfae6
commit
c3b3429645
@ -52,5 +52,3 @@ postLoader"
|
||||
|
||||
#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 DOLPHIN true
|
||||
|
@ -31,12 +31,13 @@
|
||||
#include <sdcard/gcsd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "defines.h"
|
||||
#include "fat.h"
|
||||
#include "sdhc.h"
|
||||
#include "usbthread.h"
|
||||
#include "usbstorage.h"
|
||||
#include "usbstorage_libogc.h"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wbfs.h"
|
||||
|
||||
DeviceHandler * DeviceHandler::instance = NULL;
|
||||
@ -62,14 +63,23 @@ void DeviceHandler::DestroyInstance()
|
||||
|
||||
void DeviceHandler::MountAll()
|
||||
{
|
||||
if(Sys_DolphinMode())
|
||||
{
|
||||
DolphinSD = fatMountSimple("sd", &__io_wiisd);
|
||||
return;
|
||||
}
|
||||
MountSD();
|
||||
#ifndef DOLPHIN
|
||||
MountAllUSB();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountAll()
|
||||
{
|
||||
if(Sys_DolphinMode())
|
||||
{
|
||||
fatUnmount("sd");
|
||||
DolphinSD = false;
|
||||
return;
|
||||
}
|
||||
/* Kill possible USB thread */
|
||||
KillUSBKeepAliveThread();
|
||||
|
||||
@ -106,7 +116,7 @@ bool DeviceHandler::Mount(int dev)
|
||||
bool DeviceHandler::IsInserted(int dev)
|
||||
{
|
||||
if(dev == SD)
|
||||
return SD_Inserted() && sd->IsMounted(0);
|
||||
return Sys_DolphinMode() ? DolphinSD : SD_Inserted() && sd->IsMounted(0);
|
||||
|
||||
else if(dev >= USB1 && dev <= USB8)
|
||||
{
|
||||
@ -431,6 +441,9 @@ void DeviceHandler::UnMountDevolution(int CurrentPartition)
|
||||
|
||||
bool DeviceHandler::UsablePartitionMounted()
|
||||
{
|
||||
if(Sys_DolphinMode())
|
||||
return DolphinSD;
|
||||
|
||||
for(u8 i = SD; i < MAXDEVICES; i++)
|
||||
{
|
||||
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)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -65,70 +65,72 @@ const char DeviceName[MAXDEVICES][8] =
|
||||
|
||||
class DeviceHandler
|
||||
{
|
||||
public:
|
||||
static DeviceHandler * Instance();
|
||||
static void DestroyInstance();
|
||||
public:
|
||||
static DeviceHandler * Instance();
|
||||
static void DestroyInstance();
|
||||
|
||||
void SetModes();
|
||||
void SetModes();
|
||||
|
||||
void MountAll();
|
||||
void UnMountAll();
|
||||
bool Mount(int dev);
|
||||
bool IsInserted(int dev);
|
||||
void UnMount(int dev);
|
||||
void MountAll();
|
||||
void UnMountAll();
|
||||
bool Mount(int dev);
|
||||
bool IsInserted(int dev);
|
||||
void UnMount(int dev);
|
||||
|
||||
//! Individual Mounts/UnMounts...
|
||||
bool MountSD();
|
||||
bool MountAllUSB();
|
||||
bool MountUSBPort1();
|
||||
//! Individual Mounts/UnMounts...
|
||||
bool MountSD();
|
||||
bool MountAllUSB();
|
||||
bool MountUSBPort1();
|
||||
|
||||
bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; }
|
||||
bool USB0_Inserted() { if(usb0) return usb0->IsInserted(); return false; }
|
||||
bool USB1_Inserted() { if(usb1) return usb1->IsInserted(); return false; }
|
||||
bool UsablePartitionMounted();
|
||||
bool PartitionUsableForNandEmu(int Partition);
|
||||
void WaitForDevice(const DISC_INTERFACE *Handle);
|
||||
bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; }
|
||||
bool USB0_Inserted() { if(usb0) return usb0->IsInserted(); return false; }
|
||||
bool USB1_Inserted() { if(usb1) return usb1->IsInserted(); return false; }
|
||||
bool UsablePartitionMounted();
|
||||
bool PartitionUsableForNandEmu(int Partition);
|
||||
void WaitForDevice(const DISC_INTERFACE *Handle);
|
||||
|
||||
void UnMountSD() { if(sd) delete sd; sd = NULL; }
|
||||
void UnMountUSB(int pos);
|
||||
void UnMountAllUSB();
|
||||
void UnMountSD() { if(sd) delete sd; sd = NULL; }
|
||||
void UnMountUSB(int pos);
|
||||
void UnMountAllUSB();
|
||||
|
||||
PartitionHandle * GetSDHandle() const { return sd; }
|
||||
PartitionHandle * GetUSB0Handle() const { return usb0; }
|
||||
PartitionHandle * GetUSB1Handle() const { return usb1; }
|
||||
PartitionHandle * GetSDHandle() const { return sd; }
|
||||
PartitionHandle * GetUSB0Handle() const { return usb0; }
|
||||
PartitionHandle * GetUSB1Handle() const { return usb1; }
|
||||
|
||||
PartitionHandle * GetUSBHandleFromPartition(int part) const;
|
||||
static const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; }
|
||||
static const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; }
|
||||
PartitionHandle * GetUSBHandleFromPartition(int part) const;
|
||||
static const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; }
|
||||
static const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; }
|
||||
|
||||
static int PathToDriveType(const char * path);
|
||||
static const char * GetFSName(int dev);
|
||||
static int GetFSType(int dev);
|
||||
static u16 GetUSBPartitionCount();
|
||||
static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); }
|
||||
static wbfs_t *GetWbfsHandle(int dev);
|
||||
s32 Open_WBFS(int dev);
|
||||
static int PartitionToUSBPort(int part);
|
||||
static int PartitionToPortPartition(int part);
|
||||
static int PathToDriveType(const char * path);
|
||||
static const char * GetFSName(int dev);
|
||||
static int GetFSType(int dev);
|
||||
static u16 GetUSBPartitionCount();
|
||||
static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); }
|
||||
static wbfs_t *GetWbfsHandle(int dev);
|
||||
s32 Open_WBFS(int dev);
|
||||
static int PartitionToUSBPort(int part);
|
||||
static int PartitionToPortPartition(int part);
|
||||
|
||||
/* Special Devolution Stuff */
|
||||
bool MountDevolution(int CurrentPartition);
|
||||
void UnMountDevolution(int CurrentPartition);
|
||||
private:
|
||||
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0) { }
|
||||
~DeviceHandler();
|
||||
bool MountUSB(int part);
|
||||
/* Special Devolution Stuff */
|
||||
bool MountDevolution(int CurrentPartition);
|
||||
void UnMountDevolution(int CurrentPartition);
|
||||
private:
|
||||
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0), DolphinSD(false) { }
|
||||
~DeviceHandler();
|
||||
bool MountUSB(int part);
|
||||
|
||||
static DeviceHandler *instance;
|
||||
static DeviceHandler *instance;
|
||||
|
||||
PartitionHandle * sd;
|
||||
PartitionHandle * gca;
|
||||
PartitionHandle * gcb;
|
||||
PartitionHandle * usb0;
|
||||
PartitionHandle * usb1;
|
||||
PartitionHandle * sd;
|
||||
PartitionHandle * gca;
|
||||
PartitionHandle * gcb;
|
||||
PartitionHandle * usb0;
|
||||
PartitionHandle * usb1;
|
||||
|
||||
/* Special Devolution Stuff */
|
||||
PartitionHandle *OGC_Device;
|
||||
/* Special Devolution Stuff */
|
||||
PartitionHandle *OGC_Device;
|
||||
/* Dolphin Stuff */
|
||||
bool DolphinSD;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -86,7 +86,6 @@ bool loadIOS(int ios, bool MountDevices)
|
||||
int CurIOS = IOS_GetVersion();
|
||||
bool ret = true;
|
||||
|
||||
#ifndef DOLPHIN
|
||||
if(ios != CurIOS)
|
||||
{
|
||||
WDVD_Close();
|
||||
@ -99,7 +98,6 @@ bool loadIOS(int ios, bool MountDevices)
|
||||
gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched());
|
||||
WDVD_Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
IOS_GetCurrentIOSInfo();
|
||||
if(CurrentIOS.Type == IOS_TYPE_HERMES)
|
||||
|
@ -153,3 +153,52 @@ void Sys_SetNeekPath(const char *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;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ enum
|
||||
/* Prototypes */
|
||||
void Sys_Init(void);
|
||||
void Sys_Shutdown(void);
|
||||
bool Sys_DolphinMode(void);
|
||||
bool Sys_Exiting(void);
|
||||
void Sys_Exit(void);
|
||||
void Sys_ExitTo(int);
|
||||
|
@ -63,9 +63,8 @@ int main(int argc, char **argv)
|
||||
else if(argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL)
|
||||
Emulator_boot = true;
|
||||
}
|
||||
#ifndef DOLPHIN
|
||||
// Load Custom IOS
|
||||
if(neek2o())
|
||||
if(neek2o() || Sys_DolphinMode())
|
||||
{
|
||||
iosOK = true;
|
||||
memset(&CurrentIOS, 0, sizeof(IOS_Info));
|
||||
@ -86,10 +85,6 @@ int main(int argc, char **argv)
|
||||
gprintf("Loading cIOS: %d\n", mainIOS);
|
||||
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
|
||||
}
|
||||
#else
|
||||
iosOK = true;
|
||||
#endif
|
||||
|
||||
// Init
|
||||
Sys_Init();
|
||||
Sys_ExitTo(EXIT_TO_HBC);
|
||||
@ -100,7 +95,7 @@ int main(int argc, char **argv)
|
||||
mainMenu = new CMenu(vid);
|
||||
Open_Inputs();
|
||||
mainMenu->init();
|
||||
if(CurrentIOS.Version != mainIOS && !neek2o())
|
||||
if(CurrentIOS.Version != mainIOS && !neek2o() && !Sys_DolphinMode())
|
||||
{
|
||||
if(useMainIOS || !DeviceHandler::Instance()->UsablePartitionMounted())
|
||||
{
|
||||
|
@ -2655,7 +2655,7 @@ void CMenu::_TempLoadIOS(int IOS)
|
||||
{
|
||||
#ifndef DOLPHIN
|
||||
/* Only temp reload in IOS58 mode */
|
||||
if(useMainIOS || neek2o())
|
||||
if(useMainIOS || neek2o() || Sys_DolphinMode())
|
||||
return;
|
||||
|
||||
if(IOS == IOS_TYPE_NORMAL_IOS)
|
||||
|
@ -1180,8 +1180,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
if(dvd)
|
||||
{
|
||||
u32 cover = 0;
|
||||
#ifndef DOLPHIN
|
||||
if(!neek2o())
|
||||
if(!neek2o() && !Sys_DolphinMode())
|
||||
{
|
||||
Disc_SetUSB(NULL, false);
|
||||
if(WDVD_GetCoverStatus(&cover) < 0)
|
||||
@ -1200,7 +1199,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
} while(!(cover & 0x2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
_TempLoadIOS();
|
||||
/* Open Disc */
|
||||
if(Disc_Open(true) < 0)
|
||||
@ -1357,13 +1355,11 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
m_cfg.save(true);
|
||||
cleanup(); // wifi and sd gecko doesnt work anymore after cleanup
|
||||
|
||||
#ifndef DOLPHIN
|
||||
if(!dvd || neek2o())
|
||||
if((!dvd || neek2o()) && !Sys_DolphinMode())
|
||||
{
|
||||
if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
|
||||
Sys_Exit();
|
||||
}
|
||||
#endif
|
||||
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user