-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 DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"
//#define DOLPHIN true

View File

@ -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

View File

@ -115,7 +115,7 @@ class DeviceHandler
bool MountDevolution(int CurrentPartition);
void UnMountDevolution(int CurrentPartition);
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();
bool MountUSB(int part);
@ -129,6 +129,8 @@ class DeviceHandler
/* Special Devolution Stuff */
PartitionHandle *OGC_Device;
/* Dolphin Stuff */
bool DolphinSD;
};
#endif

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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())
{

View File

@ -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)

View File

@ -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)