-fixed wiimote doesnt properly resync on entering emu nand

-fixed installing gamecube disc 2 with wiiflow installer
-fixed exit to neek2o for people who got their nand in a folder
-some general cleanup and speedup
This commit is contained in:
fix94.1 2012-08-26 12:05:04 +00:00
parent 21078c74fb
commit 75ff081c0c
11 changed files with 75 additions and 113 deletions

View File

@ -43,6 +43,7 @@
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
#include "memory/memory.h" #include "memory/memory.h"
#include "wiiuse/wpad.h"
u8 *confbuffer ATTRIBUTE_ALIGN(32); u8 *confbuffer ATTRIBUTE_ALIGN(32);
u8 CCode[0x1008]; u8 CCode[0x1008];
@ -157,11 +158,6 @@ s32 Nand::Enable_Emu()
{ {
if(emu_enabled) if(emu_enabled)
return 0; return 0;
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS)
{
loadIOS(mainIOS, true);
Open_Inputs();
}
NandDevice *Device = &NandDeviceList[EmuDevice]; NandDevice *Device = &NandDeviceList[EmuDevice];
s32 ret = Nand_Mount(Device); s32 ret = Nand_Mount(Device);

View File

@ -170,34 +170,31 @@ s32 USBStorage2_GetCapacity(u32 port, u32 *_sector_size)
if((usb_libogc_mode && !__io_usbstorage_ogc.isInserted()) || (!usb_libogc_mode && fd < 0)) if((usb_libogc_mode && !__io_usbstorage_ogc.isInserted()) || (!usb_libogc_mode && fd < 0))
return 0; return 0;
s32 ret; u32 numSectors = 0;
u32 sector_size = 0; u32 sectorSize = 0;
USBStorage2_SetPort(port); USBStorage2_SetPort(port);
if(usb_libogc_mode) if(usb_libogc_mode)
{ USB_OGC_GetCapacity(&numSectors, &sectorSize);
sector_size = USB_OGC_GetSectorSize();
ret = USB_OGC_GetCapacity();
}
else else
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", &sector_size); numSectors = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", &sectorSize);
if(first) if(first)
{ {
gprintf(" * * * * * * * * * * * *\n"); gprintf(" * * * * * * * * * * * *\n");
gprintf(" * HDD Information\n * Sectors: %lu\n", ret); gprintf(" * HDD Information\n * Sectors: %lu\n", numSectors);
u32 size = ((((ret / 1024U) * sector_size) / 1024U) / 1024U); u32 size = ((((numSectors / 1024U) * sectorSize) / 1024U) / 1024U);
if(size >= 1000U) if(size >= 1000U)
gprintf(" * Size [Sector Size]: %lu.%lu TB [%u]\n", size / 1024U, (size * 100U) % 1024U, sector_size); gprintf(" * Size [Sector Size]: %lu.%lu TB [%u]\n", size / 1024U, (size * 100U) % 1024U, sectorSize);
else else
gprintf(" * Size [Sector Size]: %lu GB [%u]\n", size, sector_size); gprintf(" * Size [Sector Size]: %lu GB [%u]\n", size, sectorSize);
gprintf(" * * * * * * * * * * * *\n"); gprintf(" * * * * * * * * * * * *\n");
first = false; first = false;
} }
if(ret && _sector_size) if(numSectors && _sector_size)
*_sector_size = sector_size; *_sector_size = sectorSize;
return ret; return numSectors;
} }
s32 USBStorage2_ReadSectors(u32 port, u32 sector, u32 numSectors, void *buffer) s32 USBStorage2_ReadSectors(u32 port, u32 sector, u32 numSectors, void *buffer)

View File

@ -1006,20 +1006,9 @@ DISC_INTERFACE __io_usbstorage_ogc = {
(FN_MEDIUM_SHUTDOWN)&__usbstorage_ogc_Shutdown (FN_MEDIUM_SHUTDOWN)&__usbstorage_ogc_Shutdown
}; };
u32 USB_OGC_GetSectorSize() u32 USB_OGC_GetCapacity(u32 *numSectors, u32 *sectorSize)
{ {
u32 numSectors = 0; return USBStorage_OGC_ReadCapacity(&__usbfd, __lun, sectorSize, numSectors);
u32 sectorsize = 0;
USBStorage_OGC_ReadCapacity(&__usbfd, __lun, &sectorsize, &numSectors);
return sectorsize;
}
u32 USB_OGC_GetCapacity()
{
u32 numSectors = 0;
u32 sectorsize = 0;
USBStorage_OGC_ReadCapacity(&__usbfd, __lun, &sectorsize, &numSectors);
return numSectors;
} }
#endif /* HW_RVL */ #endif /* HW_RVL */

View File

@ -30,8 +30,7 @@ s32 USBStorage_OGC_StartStop(usbstorage_handle *dev, u8 lun, u8 lo_ej, u8 start,
extern DISC_INTERFACE __io_usbstorage_ogc; extern DISC_INTERFACE __io_usbstorage_ogc;
u32 USB_OGC_GetSectorSize(); u32 USB_OGC_GetCapacity(u32 *numSectors, u32 *sectorSize);
u32 USB_OGC_GetCapacity();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -201,7 +201,7 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
if(Disc_Wait() < 0) if(Disc_Wait() < 0)
continue; continue;
if(Disc_Open(true) < 0) if(Disc_Open(false) < 0)
{ {
MEM2_free(ReadBuffer); MEM2_free(ReadBuffer);
return false; return false;

View File

@ -22,17 +22,10 @@
bool reset = false; bool reset = false;
bool shutdown = false; bool shutdown = false;
bool exiting = false; bool exiting = false;
u8 ExitOption = 0;
bool priiloader_def = false; const char *NeekPath = NULL;
bool return_to_hbc = false;
bool return_to_menu = false;
bool return_to_priiloader = false;
bool return_to_disable = false;
bool return_to_bootmii = false;
bool return_to_neek2o = false;
extern void __exception_closeall(); extern void __exception_closeall();
extern u32 __PADDisableRecalibration(s32 disable);
void __Wpad_PowerCallback() void __Wpad_PowerCallback()
{ {
@ -79,23 +72,20 @@ void Sys_Test(void)
else if (shutdown) SYS_ResetSystem(SYS_POWEROFF, 0, 0); else if (shutdown) SYS_ResetSystem(SYS_POWEROFF, 0, 0);
} }
int Sys_GetExitTo(void)
{
return ExitOption;
}
void Sys_ExitTo(int option) void Sys_ExitTo(int option)
{ {
priiloader_def = option == PRIILOADER_DEF; ExitOption = option;
return_to_hbc = option == EXIT_TO_HBC;
return_to_menu = option == EXIT_TO_MENU;
return_to_priiloader = option == EXIT_TO_PRIILOADER;
return_to_disable = option == EXIT_TO_DISABLE;
return_to_bootmii = option == EXIT_TO_BOOTMII;
return_to_neek2o = option == EXIT_TO_NEEK2O;
//magic word to force wii menu in priiloader. //magic word to force wii menu in priiloader.
if(return_to_menu) if(ExitOption == EXIT_TO_MENU)
{ {
*Priiloader_CFG1 = 0x50756E65; *Priiloader_CFG1 = 0x50756E65;
*Priiloader_CFG2 = 0x50756E65; *Priiloader_CFG2 = 0x50756E65;
} }
else if(return_to_priiloader) else if(ExitOption == EXIT_TO_PRIILOADER)
{ {
*Priiloader_CFG1 = 0x4461636F; *Priiloader_CFG1 = 0x4461636F;
*Priiloader_CFG2 = 0x4461636F; *Priiloader_CFG2 = 0x4461636F;
@ -111,29 +101,24 @@ void Sys_ExitTo(int option)
void Sys_Exit(void) void Sys_Exit(void)
{ {
if(return_to_disable) if(ExitOption == EXIT_TO_DISABLE)
return; return;
/* Shutdown Inputs */ /* Shutdown Inputs */
Close_Inputs(); Close_Inputs();
if(return_to_neek2o)
{
Launch_nk(0x1000144574641LL, NULL);
while(1);
}
WII_Initialize(); WII_Initialize();
if(return_to_menu || return_to_priiloader || priiloader_def) if(ExitOption == EXIT_TO_NEEK2O)
Sys_LoadMenu(); Launch_nk(0x1000144574641LL, NeekPath);
else if(return_to_bootmii) else if(ExitOption == EXIT_TO_BOOTMII)
IOS_ReloadIOS(254); IOS_ReloadIOS(0xfe);
else if(ExitOption == EXIT_TO_HBC)
//else {
WII_LaunchTitle(HBC_108); WII_LaunchTitle(HBC_108);
WII_LaunchTitle(HBC_JODI); WII_LaunchTitle(HBC_JODI);
WII_LaunchTitle(HBC_HAXX); WII_LaunchTitle(HBC_HAXX);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); }
//else boot system menu
Sys_LoadMenu();
} }
void __Sys_ResetCallback(void) void __Sys_ResetCallback(void)
@ -163,3 +148,8 @@ bool AHBRPOT_Patched(void)
{ {
return (*HW_AHBPROT == 0xFFFFFFFF); return (*HW_AHBPROT == 0xFFFFFFFF);
} }
void Sys_SetNeekPath(const char *Path)
{
NeekPath = Path;
}

View File

@ -32,6 +32,8 @@ bool Sys_Exiting(void);
void Sys_Test(void); void Sys_Test(void);
void Sys_Exit(void); void Sys_Exit(void);
void Sys_ExitTo(int); void Sys_ExitTo(int);
int Sys_GetExitTo(void);
void Sys_SetNeekPath(const char*);
void Open_Inputs(void); void Open_Inputs(void);
void Close_Inputs(void); void Close_Inputs(void);

View File

@ -92,11 +92,8 @@ int main(int argc, char **argv)
// Init // Init
Sys_Init(); Sys_Init();
Sys_ExitTo(EXIT_TO_HBC); Sys_ExitTo(EXIT_TO_HBC);
Open_Inputs(); //(re)init wiimote
#ifndef DOLPHIN #ifndef DOLPHIN
const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface(); const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface();
bool deviceAvailable = false;
u8 timeout = time(NULL); u8 timeout = time(NULL);
while(time(NULL) - timeout < 20) while(time(NULL) - timeout < 20)
{ {
@ -110,15 +107,20 @@ int main(int argc, char **argv)
bool dipOK = Disc_Init() >= 0; bool dipOK = Disc_Init() >= 0;
mainMenu = new CMenu(vid); mainMenu = new CMenu(vid);
Open_Inputs();
mainMenu->init(); mainMenu->init();
if(CurrentIOS.Version != mainIOS && useMainIOS) if(CurrentIOS.Version != mainIOS && !neek2o())
iosOK = loadIOS(mainIOS, true) && CustomIOS(CurrentIOS.Type); {
if(DeviceHandler::Instance()->IsInserted(SD) || DeviceHandler::Instance()->IsInserted(USB1)) if(useMainIOS || (!DeviceHandler::Instance()->IsInserted(SD) && !DeviceHandler::Instance()->IsInserted(USB1)))
deviceAvailable = true; {
iosOK = loadIOS(mainIOS, true) && CustomIOS(CurrentIOS.Type);
Open_Inputs();
mainMenu->init();
}
}
if(!iosOK) if(!iosOK)
mainMenu->terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games."); mainMenu->terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
else if(!deviceAvailable) else if(!DeviceHandler::Instance()->IsInserted(SD) && !DeviceHandler::Instance()->IsInserted(USB1))
mainMenu->terror("errboot2", L"Could not find a device to save configuration files on!"); mainMenu->terror("errboot2", L"Could not find a device to save configuration files on!");
else if(!dipOK) else if(!dipOK)
mainMenu->terror("errboot3", L"Could not initialize the DIP module!"); mainMenu->terror("errboot3", L"Could not initialize the DIP module!");
@ -130,7 +132,7 @@ int main(int argc, char **argv)
mainMenu->m_Emulator_boot = true; mainMenu->m_Emulator_boot = true;
mainMenu->main(); mainMenu->main();
} }
//Exit WiiFlow, no game booted...
mainMenu->cleanup(); mainMenu->cleanup();
DeviceHandler::Instance()->UnMountAll(); DeviceHandler::Instance()->UnMountAll();
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();

View File

@ -137,7 +137,6 @@ CMenu::CMenu(CVideo &vid) :
m_bnr_settings = true; m_bnr_settings = true;
m_directLaunch = false; m_directLaunch = false;
m_exit = false; m_exit = false;
m_initialCoverStatusComplete = false;
m_reload = false; m_reload = false;
m_gamesound_changed = false; m_gamesound_changed = false;
m_video_playing = false; m_video_playing = false;
@ -2051,6 +2050,13 @@ bool CMenu::_loadChannelList(void)
Nand::Instance()->Disable_Emu(); Nand::Instance()->Disable_Emu();
if(!disable_emu) if(!disable_emu)
{ {
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS)
{
loadIOS(mainIOS, true);
Open_Inputs();
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
}
if(!DeviceHandler::Instance()->IsInserted(lastPartition)) if(!DeviceHandler::Instance()->IsInserted(lastPartition))
DeviceHandler::Instance()->Mount(lastPartition); DeviceHandler::Instance()->Mount(lastPartition);

View File

@ -581,8 +581,7 @@ private:
SZone m_mainButtonsZone3; SZone m_mainButtonsZone3;
SZone m_gameButtonsZone; SZone m_gameButtonsZone;
bool m_reload; bool m_reload;
bool m_initialCoverStatusComplete;
WPADData *wd[WPAD_MAX_WIIMOTES]; WPADData *wd[WPAD_MAX_WIIMOTES];
void LeftStick(); void LeftStick();
u8 pointerhidedelay[WPAD_MAX_WIIMOTES]; u8 pointerhidedelay[WPAD_MAX_WIIMOTES];
@ -1050,7 +1049,6 @@ private:
bool _isNetworkAvailable(); bool _isNetworkAvailable();
int _initNetwork(); int _initNetwork();
void _deinitNetwork(); void _deinitNetwork();
static int GetCoverStatusAsync(CMenu *m);
void LoadView(void); void LoadView(void);
void _getGrabStatus(void); void _getGrabStatus(void);
static void _addDiscProgress(int status, int total, void *user_data); static void _addDiscProgress(int status, int total, void *user_data);

View File

@ -179,14 +179,6 @@ void CMenu::_showMain(void)
Nand::Instance()->Enable_Emu(); Nand::Instance()->Enable_Emu();
} }
int CMenu::GetCoverStatusAsync(CMenu *m)
{
u32 disc_check = 0;
WDVD_GetCoverStatus(&disc_check);
m->m_initialCoverStatusComplete = true;
return 0;
}
void CMenu::LoadView(void) void CMenu::LoadView(void)
{ {
m_curGameId = m_cf.getId(); m_curGameId = m_cf.getId();
@ -268,7 +260,7 @@ int CMenu::main(void)
bool bUsed = false; bool bUsed = false;
m_reload = false; m_reload = false;
static u32 disc_check = 0; u32 disc_check = 0;
int done = 0; int done = 0;
if (m_cfg.getBool("GENERAL", "async_network", false) || has_enabled_providers()) if (m_cfg.getBool("GENERAL", "async_network", false) || has_enabled_providers())
@ -304,23 +296,13 @@ int CMenu::main(void)
if(BTN_B_HELD) if(BTN_B_HELD)
bUsed = true; bUsed = true;
} }
lwp_t coverStatus = LWP_THREAD_NULL;
unsigned int stack_size = (unsigned int)32768;
SmartBuf coverstatus_stack = smartMem2Alloc(stack_size);
LWP_CreateThread(&coverStatus, (void *(*)(void *))CMenu::GetCoverStatusAsync, (void *)this, coverstatus_stack.get(), stack_size, 40);
while(true) while(true)
{ {
/* IMPORTANT check if a disc is inserted */
WDVD_GetCoverStatus(&disc_check);
/* Main Loop */
_mainLoopCommon(true); _mainLoopCommon(true);
if(m_initialCoverStatusComplete)
{
LWP_JoinThread(coverStatus, NULL);
coverStatus = LWP_THREAD_NULL;
if(coverstatus_stack.get())
coverstatus_stack.release();
WDVD_GetCoverStatus(&disc_check);
}
if(bheld && !BTN_B_HELD) if(bheld && !BTN_B_HELD)
{ {
bheld = false; bheld = false;
@ -867,15 +849,16 @@ int CMenu::main(void)
_launchHomebrew(fmt("%s/boot.dol", m_appDir.c_str()), m_homebrewArgs); _launchHomebrew(fmt("%s/boot.dol", m_appDir.c_str()), m_homebrewArgs);
return 0; return 0;
} }
else if(Sys_GetExitTo() == EXIT_TO_NEEK2O)
{
string emuPath;
_FindEmuPart(&emuPath, m_cfg.getInt("NAND", "partition", 0), false);
Sys_SetNeekPath(emuPath.size() > 1 ? emuPath.c_str() : NULL);
}
gprintf("Saving configuration files\n"); gprintf("Saving configuration files\n");
m_cfg.save(); m_cfg.save();
m_cat.unload(); m_cat.unload();
// m_loc.save(); // m_loc.save();
gprintf("Wait for dvd\n");
LWP_JoinThread(coverStatus, NULL);
coverStatus = LWP_THREAD_NULL;
if(coverstatus_stack.get())
coverstatus_stack.release();
return 0; return 0;
} }