mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-lets give the game sound thread its own stack again to hopefully
fix that strange missing pointer problem -fixed detection of devolution r168 or newer -cleaned up the devolution code and added a few debug prints
This commit is contained in:
parent
5a827e48fc
commit
f61d9dac0c
@ -329,20 +329,20 @@ void DeviceHandler::WaitForDevice(const DISC_INTERFACE *Handle)
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountDevolution(int CurrentPartition)
|
||||
bool DeviceHandler::MountDevolution()
|
||||
{
|
||||
int NewPartition = (CurrentPartition == SD ? CurrentPartition : CurrentPartition - 1);
|
||||
const DISC_INTERFACE *handle = (CurrentPartition == SD) ? &__io_wiisd : &__io_usbstorage_ogc;
|
||||
int NewPartition = (currentPartition == SD ? currentPartition : currentPartition - 1);
|
||||
const DISC_INTERFACE *handle = (currentPartition == SD) ? &__io_wiisd : &__io_usbstorage_ogc;
|
||||
/* We need to wait for the device to get ready for a remount */
|
||||
WaitForDevice(handle);
|
||||
/* Only mount the partition we need */
|
||||
OGC_Device.SetDevice(handle);
|
||||
return OGC_Device.Mount(NewPartition, DeviceName[CurrentPartition], true);
|
||||
return OGC_Device.Mount(NewPartition, DeviceName[currentPartition], true);
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountDevolution(int CurrentPartition)
|
||||
void DeviceHandler::UnMountDevolution()
|
||||
{
|
||||
int NewPartition = (CurrentPartition == SD ? CurrentPartition : CurrentPartition - 1);
|
||||
int NewPartition = (currentPartition == SD ? currentPartition : currentPartition - 1);
|
||||
OGC_Device.UnMount(NewPartition);
|
||||
OGC_Device.Cleanup();
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ public:
|
||||
int PartitionToPortPartition(int part);
|
||||
|
||||
/* Special Devolution Stuff */
|
||||
bool MountDevolution(int CurrentPartition);
|
||||
void UnMountDevolution(int CurrentPartition);
|
||||
bool MountDevolution();
|
||||
void UnMountDevolution();
|
||||
private:
|
||||
bool MountUSB(int part);
|
||||
|
||||
|
110
source/gc/gc.cpp
110
source/gc/gc.cpp
@ -28,11 +28,13 @@
|
||||
#include <dirent.h>
|
||||
|
||||
#include "gc/gc.hpp"
|
||||
#include "gui/text.hpp"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "gecko/gecko.h"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "loader/utils.h"
|
||||
#include "loader/disc.h"
|
||||
#include "loader/sys.h"
|
||||
#include "memory/memory.h"
|
||||
|
||||
// DIOS-MIOS
|
||||
@ -42,7 +44,7 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
|
||||
const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode,
|
||||
u8 videoSetting, bool widescreen, bool new_dm_cfg, bool activity_led)
|
||||
{
|
||||
gprintf("Wiiflow GC: Launch game '%s' through memory (new method)\n", GamePath);
|
||||
gprintf("DIOS-MIOS: Launch game '%s' through memory (new method)\n", GamePath);
|
||||
memset(&DMLCfg, 0, sizeof(DML_CFG));
|
||||
|
||||
DMLCfg.Magicbytes = 0xD1050CF6;
|
||||
@ -77,7 +79,7 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
|
||||
else
|
||||
ptr = strstr(CheatPath, ":/") + 1;
|
||||
strncpy(DMLCfg.CheatPath, ptr, sizeof(DMLCfg.CheatPath));
|
||||
gprintf("Cheat Path: %s\n", ptr);
|
||||
gprintf("DIOS-MIOS: Cheat Path %s\n", ptr);
|
||||
DMLCfg.Config |= DML_CFG_CHEAT_PATH;
|
||||
}
|
||||
if(activity_led)
|
||||
@ -106,7 +108,7 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
|
||||
|
||||
void DML_Old_SetOptions(const char *GamePath)
|
||||
{
|
||||
gprintf("Wiiflow GC: Launch game '%s' through boot.bin (old method)\n", GamePath);
|
||||
gprintf("DIOS-MIOS: Launch game '%s' through boot.bin (old method)\n", GamePath);
|
||||
FILE *f;
|
||||
f = fopen("sd:/games/boot.bin", "wb");
|
||||
fwrite(GamePath, 1, strlen(GamePath) + 1, f);
|
||||
@ -122,7 +124,7 @@ void DML_Old_SetOptions(const char *GamePath)
|
||||
|
||||
void DML_New_SetBootDiscOption(bool new_dm_cfg)
|
||||
{
|
||||
gprintf("Booting GC game\n");
|
||||
gprintf("DIOS-MIOS: Booting Disc in Drive\n");
|
||||
memset(&DMLCfg, 0, sizeof(DML_CFG));
|
||||
|
||||
DMLCfg.Magicbytes = 0xD1050CF6;
|
||||
@ -153,63 +155,63 @@ extern "C" { extern void __exception_closeall(); }
|
||||
static gconfig *DEVO_CONFIG = (gconfig*)0x80000020;
|
||||
#define DEVO_Entry() ((void(*)(void))loader_bin)()
|
||||
|
||||
bool DEVO_Installed(const char* path)
|
||||
bool DEVO_Installed(const char *path)
|
||||
{
|
||||
bool devo = false;
|
||||
char loader_path[256];
|
||||
snprintf(loader_path, sizeof(loader_path), "%s/loader.bin", path);
|
||||
const char *loader_path = fmt("%s/loader.bin", path);
|
||||
FILE *f = fopen(loader_path, "rb");
|
||||
if(f)
|
||||
if(f != NULL)
|
||||
{
|
||||
u8 *tbuf = (u8 *)malloc(0x04);
|
||||
fread(tbuf, 1, 4, f);
|
||||
if(*(vu32*)tbuf == 0x4800004c)
|
||||
fseek(f, 0, SEEK_END);
|
||||
if(ftell(f) > 0x80) //Size should be more than 128b
|
||||
{
|
||||
gprintf("Devolution: Found %s\n", loader_path);
|
||||
devo = true;
|
||||
|
||||
free(tbuf);
|
||||
}
|
||||
rewind(f);
|
||||
fclose(f);
|
||||
}
|
||||
return devo;
|
||||
}
|
||||
|
||||
void DEVO_GetLoader(const char *loader)
|
||||
void DEVO_GetLoader(const char *path)
|
||||
{
|
||||
//Read in loader.bin
|
||||
char loader_path[256];
|
||||
snprintf(loader_path, sizeof(loader_path), "%s/loader.bin", loader);
|
||||
const char *loader_path = fmt("%s/loader.bin", path);
|
||||
FILE *f = fopen(loader_path, "rb");
|
||||
if(f)
|
||||
if(f != NULL)
|
||||
{
|
||||
gprintf("Read Devolution Loader: \"%s\"\n", loader_path);
|
||||
gprintf("Devolution: Reading %s\n", loader_path);
|
||||
fseek(f, 0, SEEK_END);
|
||||
u32 size = ftell(f);
|
||||
rewind(f);
|
||||
loader_bin = (u8*)memalign(32, size);
|
||||
fread(loader_bin, 1, size, f);
|
||||
DCFlushRange(loader_bin, ALIGN32(size));
|
||||
DCFlushRange(loader_bin, size);
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("Devolution loader.bin not found!\n");
|
||||
gprintf("Devolution: Loader not found!\n");
|
||||
return;
|
||||
}
|
||||
gprintf("%s\n", (char*)loader_bin + 4);
|
||||
gprintf("%s\n", (u8*)loader_bin + 4);
|
||||
}
|
||||
|
||||
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID, bool memcard_emu)
|
||||
void DEVO_SetOptions(const char *isopath, const char *gameID, bool memcard_emu)
|
||||
{
|
||||
// re-mount device we need
|
||||
DeviceHandle.MountDevolution(CurrentPartition);
|
||||
DeviceHandle.MountDevolution();
|
||||
|
||||
//start writing cfg to mem
|
||||
struct stat st;
|
||||
int data_fd;
|
||||
char iso2path[256];
|
||||
iso2path[255] = '\0';
|
||||
|
||||
stat(isopath, &st);
|
||||
FILE *f = fopen(isopath, "rb");
|
||||
gprintf("Read ISO File: \"%s\"\n", isopath);
|
||||
gprintf("Devolution: ISO Header %s\n", isopath);
|
||||
fread((u8*)0x80000000, 1, 32, f);
|
||||
fclose(f);
|
||||
|
||||
@ -221,47 +223,44 @@ void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *game
|
||||
DEVO_CONFIG->disc1_cluster = st.st_ino;
|
||||
|
||||
// If 2nd iso file tell Devo about it
|
||||
strcpy(iso2path, isopath);
|
||||
char *ptz = (char *)NULL;
|
||||
ptz = strstr(iso2path, "game.iso");
|
||||
strncpy(iso2path, isopath, 255);
|
||||
char *ptz = strstr(iso2path, "game.iso");
|
||||
if(ptz != NULL)
|
||||
strncpy(ptz, "gam1.iso", 8);
|
||||
|
||||
f = fopen(iso2path, "rb");
|
||||
if(f)
|
||||
if(f != NULL)
|
||||
{
|
||||
gprintf("Found 2nd iso file for multi DVD game: \"%s\"\n", iso2path);
|
||||
gprintf("Devolution: 2nd ISO File for Multi DVD Game %s\n", iso2path);
|
||||
stat(iso2path, &st);
|
||||
DEVO_CONFIG->disc2_cluster = st.st_ino;
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// make sure these directories exist, they are required for Devolution to function correctly
|
||||
char full_path[256];
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps", DeviceName[CurrentPartition]);
|
||||
fsop_MakeFolder(full_path);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", DeviceName[CurrentPartition]);
|
||||
fsop_MakeFolder(full_path);
|
||||
fsop_MakeFolder(fmt("%s:/apps", DeviceName[currentPartition]));
|
||||
fsop_MakeFolder(fmt("%s:/apps/gc_devo", DeviceName[currentPartition]));
|
||||
|
||||
if(memcard_emu)
|
||||
{
|
||||
const char *memcard_dir = NULL;
|
||||
// find or create a 16MB memcard file for emulation
|
||||
// this file can be located anywhere since it's passed by cluster, not name
|
||||
// it must be at least 512KB (smallest possible memcard = 59 blocks)
|
||||
if(gameID[3] == 'J') //Japanese Memory Card
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard_jap.bin", DeviceName[CurrentPartition]);
|
||||
memcard_dir = fmt("%s:/apps/gc_devo/memcard_jap.bin", DeviceName[currentPartition]);
|
||||
else
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard.bin", DeviceName[CurrentPartition]);
|
||||
|
||||
memcard_dir = fmt("%s:/apps/gc_devo/memcard.bin", DeviceName[currentPartition]);
|
||||
gprintf("Devolution: Memory Card File %s\n", memcard_dir);
|
||||
// check if file doesn't exist
|
||||
if(stat(full_path, &st) == -1 || st.st_size < (1<<19))
|
||||
if(stat(memcard_dir, &st) == -1 || st.st_size < (1<<19))
|
||||
{
|
||||
// need to enlarge or create it
|
||||
data_fd = open(full_path, O_WRONLY|O_CREAT);
|
||||
data_fd = open(memcard_dir, O_WRONLY|O_CREAT);
|
||||
if(data_fd >= 0)
|
||||
{
|
||||
// try to make it 16MB (largest possible memcard = 2043 blocks)
|
||||
gprintf("Resizing memcard file...\n");
|
||||
gprintf("Devolution: Resizing Memory Card File...\n");
|
||||
ftruncate(data_fd, 16<<20);
|
||||
if(fstat(data_fd, &st) == -1 || st.st_size < (1<<19))
|
||||
{
|
||||
@ -276,6 +275,7 @@ void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *game
|
||||
st.st_ino = 0;
|
||||
}
|
||||
}
|
||||
gprintf("Devolution: Memory Card at %08x\n", st.st_ino);
|
||||
}
|
||||
else
|
||||
st.st_ino = 0;
|
||||
@ -287,7 +287,7 @@ void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *game
|
||||
// flush disc ID and Devolution config out to memory
|
||||
DCFlushRange((void*)0x80000000, 64);
|
||||
|
||||
DeviceHandle.UnMountDevolution(CurrentPartition);
|
||||
DeviceHandle.UnMountDevolution();
|
||||
}
|
||||
|
||||
void DEVO_Boot()
|
||||
@ -437,31 +437,3 @@ void GC_SetLanguage(u8 lang)
|
||||
__SYS_UnlockSram(1); // 1 -> write changes
|
||||
while(!__SYS_SyncSram());
|
||||
}
|
||||
|
||||
int GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir)
|
||||
{
|
||||
char folder[50];
|
||||
char source[300];
|
||||
snprintf(folder, sizeof(folder), dmlgamedir, partition);
|
||||
snprintf(source, sizeof(source), "%s/%s/game.iso", folder, discid);
|
||||
|
||||
FILE *f = fopen(source, "rb");
|
||||
if(f)
|
||||
{
|
||||
gprintf("Found on %s: %s\n", partition, source);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(source, sizeof(source), "%s/%s/sys/boot.bin", folder, discid);
|
||||
f = fopen(source, "rb");
|
||||
if(f)
|
||||
{
|
||||
gprintf("Found on %s: %s\n", partition, source);
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -82,14 +82,13 @@ typedef struct global_config
|
||||
} gconfig;
|
||||
|
||||
bool DEVO_Installed(const char *path);
|
||||
void DEVO_GetLoader(const char *loader);
|
||||
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID,
|
||||
void DEVO_GetLoader(const char *path);
|
||||
void DEVO_SetOptions(const char *isopath, const char *gameID,
|
||||
bool memcard_emum);
|
||||
void DEVO_Boot();
|
||||
|
||||
// General
|
||||
void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS);
|
||||
void GC_SetLanguage(u8 lang);
|
||||
int GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir);
|
||||
|
||||
#endif //_GC_HPP_
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "dip_plugin_249.h"
|
||||
#include "mload_modules.h"
|
||||
|
||||
extern "C" { extern u8 currentPartition; }
|
||||
u8 use_port1 = 0;
|
||||
|
||||
static int load_ehc_module_ex(void)
|
||||
|
@ -41,9 +41,12 @@ void Open_Inputs(void);
|
||||
void Close_Inputs(void);
|
||||
|
||||
bool AHBRPOT_Patched(void);
|
||||
|
||||
/* All our extern C stuff */
|
||||
extern void __exception_setreload(int t);
|
||||
extern int mainIOS;
|
||||
extern bool useMainIOS;
|
||||
extern u8 currentPartition;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "loader/fs.h"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/playlog.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wbfs.h"
|
||||
#include "music/SoundHandler.hpp"
|
||||
#include "network/gcard.h"
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "gui/gui.hpp"
|
||||
#include "list/ListGenerator.hpp"
|
||||
#include "loader/disc.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/gc_disc_dump.hpp"
|
||||
#include "loader/wbfs.h"
|
||||
#include "music/gui_sound.h"
|
||||
@ -28,8 +29,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern "C" { extern u8 currentPartition; }
|
||||
|
||||
class CMenu
|
||||
{
|
||||
public:
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "channel/nand.hpp"
|
||||
#include "loader/alt_ios.h"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/sys.h"
|
||||
#include "const_str.hpp"
|
||||
|
||||
const int pixels_to_skip = 10;
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "menu.hpp"
|
||||
#include "lockMutex.hpp"
|
||||
#include "gui/text.hpp"
|
||||
#include "loader/sys.h"
|
||||
#include "network/http.h"
|
||||
|
||||
#define GECKOURL "http://geckocodes.org/codes/%c/%s.txt"
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "menu.hpp"
|
||||
#include "channel/nand.hpp"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/sys.h"
|
||||
|
||||
const int CMenu::_nbCfgPages = 6;
|
||||
static const int g_curPage = 1;
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "gecko/gecko.h"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/sys.h"
|
||||
|
||||
static const int g_curPage = 4;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "types.h"
|
||||
#include "gecko/gecko.h"
|
||||
#include "loader/wbfs.h"
|
||||
#include "loader/sys.h"
|
||||
#include "libwbfs/wiidisc.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof a / sizeof a[0])
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "gui/GameTDB.hpp"
|
||||
#include "gui/pngu.h"
|
||||
#include "loader/fs.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wbfs.h"
|
||||
#include "loader/wdvd.h"
|
||||
#include "network/http.h"
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "gui/Gekko.h"
|
||||
#include "homebrew/homebrew.h"
|
||||
#include "loader/alt_ios.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wdvd.h"
|
||||
#include "loader/alt_ios.h"
|
||||
#include "loader/playlog.h"
|
||||
@ -911,7 +910,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
|
||||
else //use cIOS instead to make sure Devolution works anyways
|
||||
loadIOS(mainIOS, false);
|
||||
ShutdownBeforeExit();
|
||||
DEVO_SetOptions(path.c_str(), currentPartition, id.c_str(), memcard_emu);
|
||||
DEVO_SetOptions(path.c_str(), id.c_str(), memcard_emu);
|
||||
DEVO_Boot();
|
||||
}
|
||||
Sys_Exit();
|
||||
@ -1618,6 +1617,8 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
m->m_soundThrdBusy = false;
|
||||
}
|
||||
|
||||
u8 *GameSoundStack = NULL;
|
||||
u32 GameSoundSize = 0x10000; //64kb
|
||||
void CMenu::_playGameSound(void)
|
||||
{
|
||||
m_gamesound_changed = false;
|
||||
@ -1626,7 +1627,8 @@ void CMenu::_playGameSound(void)
|
||||
|
||||
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||
CheckGameSoundThread();
|
||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, NULL, 0, 60);
|
||||
GameSoundStack = (u8*)MEM2_alloc(GameSoundSize);
|
||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void*)this, GameSoundStack, GameSoundSize, 60);
|
||||
}
|
||||
|
||||
void CMenu::CheckGameSoundThread()
|
||||
@ -1642,4 +1644,8 @@ void CMenu::CheckGameSoundThread()
|
||||
|
||||
LWP_JoinThread(m_gameSoundThread, NULL);
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
|
||||
if(GameSoundStack)
|
||||
free(GameSoundStack);
|
||||
GameSoundStack = NULL;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "menu.hpp"
|
||||
|
||||
#include "gui/GameTDB.hpp"
|
||||
#include "loader/sys.h"
|
||||
|
||||
extern const u8 wifi1_png[];
|
||||
extern const u8 wifi2_png[];
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "menu.hpp"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/sys.h"
|
||||
#include "const_str.hpp"
|
||||
|
||||
s16 m_homeLblTitle;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "loader/cios.h"
|
||||
#include "loader/disc.h"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wbfs.h"
|
||||
#include "loader/wdvd.h"
|
||||
#include "network/gcard.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/nk.h"
|
||||
#include "loader/sys.h"
|
||||
|
||||
// NandEmulation menu
|
||||
s16 m_nandemuLblTitle;
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "menu.hpp"
|
||||
#include "const_str.hpp"
|
||||
#include "lockMutex.hpp"
|
||||
#include "loader/sys.h"
|
||||
#include "loader/wbfs.h"
|
||||
|
||||
int version_num = 0, num_versions = 0, i;
|
||||
|
Loading…
Reference in New Issue
Block a user