changes for SD Gecko / DVD support on GameCube (thanks emukidid!)

This commit is contained in:
dborth 2010-04-02 21:02:16 +00:00
parent 2ffffc7cbb
commit 078d2756a5
4 changed files with 96 additions and 62 deletions

View File

@ -63,6 +63,10 @@ int autoLoadMethod()
device = DEVICE_SD; device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT)) else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB; device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_DVD, SILENT)) else if(ChangeInterface(DEVICE_DVD, SILENT))
device = DEVICE_DVD; device = DEVICE_DVD;
else if(ChangeInterface(DEVICE_SMB, SILENT)) else if(ChangeInterface(DEVICE_SMB, SILENT))
@ -92,6 +96,10 @@ int autoSaveMethod(bool silent)
device = DEVICE_SD; device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT)) else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB; device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_SMB, SILENT)) else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB; device = DEVICE_SMB;
else if(!silent) else if(!silent)
@ -172,10 +180,12 @@ bool IsDeviceRoot(char * path)
if(path == NULL || path[0] == 0) if(path == NULL || path[0] == 0)
return false; return false;
if(strcmp(path, "sd:/") == 0 || if( strcmp(path, "sd:/") == 0 ||
strcmp(path, "usb:/") == 0 || strcmp(path, "usb:/") == 0 ||
strcmp(path, "dvd:/") == 0 || strcmp(path, "dvd:/") == 0 ||
strcmp(path, "smb:/") == 0) strcmp(path, "smb:/") == 0 ||
strcmp(path, "carda:/") == 0 ||
strcmp(path, "cardb:/") == 0)
{ {
return true; return true;
} }
@ -564,6 +574,7 @@ int BrowserChangeFolder()
browser.dir[0] = 0; browser.dir[0] = 0;
int i=0; int i=0;
#ifdef HW_RVL
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "sd:/"); sprintf(browserList[i].filename, "sd:/");
sprintf(browserList[i].displayname, "SD Card"); sprintf(browserList[i].displayname, "SD Card");
@ -582,7 +593,6 @@ int BrowserChangeFolder()
browserList[i].icon = ICON_USB; browserList[i].icon = ICON_USB;
i++; i++;
#ifdef HW_RVL
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "smb:/"); sprintf(browserList[i].filename, "smb:/");
sprintf(browserList[i].displayname, "Network Share"); sprintf(browserList[i].displayname, "Network Share");
@ -591,8 +601,25 @@ int BrowserChangeFolder()
browserList[i].isdir = 1; browserList[i].isdir = 1;
browserList[i].icon = ICON_SMB; browserList[i].icon = ICON_SMB;
i++; i++;
#endif #else
AddBrowserEntry();
sprintf(browserList[i].filename, "carda:/");
sprintf(browserList[i].displayname, "SD Gecko Slot A");
browserList[i].length = 0;
browserList[i].mtime = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
AddBrowserEntry();
sprintf(browserList[i].filename, "cardb:/");
sprintf(browserList[i].displayname, "SD Gecko Slot B");
browserList[i].length = 0;
browserList[i].mtime = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
#endif
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "dvd:/"); sprintf(browserList[i].filename, "dvd:/");
sprintf(browserList[i].displayname, "Data DVD"); sprintf(browserList[i].displayname, "Data DVD");

View File

@ -40,8 +40,8 @@
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32); unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32);
static mutex_t bufferLock = LWP_MUTEX_NULL; static mutex_t bufferLock = LWP_MUTEX_NULL;
FILE * file; // file pointer - the only one we should ever use! FILE * file; // file pointer - the only one we should ever use!
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false }; bool unmountRequired[7] = { false, false, false, false, false, false, false };
bool isMounted[9] = { false, false, false, false, false, false, false, false, false }; bool isMounted[7] = { false, false, false, false, false, false, false };
#ifdef HW_RVL #ifdef HW_RVL
const DISC_INTERFACE* sd = &__io_wiisd; const DISC_INTERFACE* sd = &__io_wiisd;
@ -84,6 +84,7 @@ ResumeDeviceThread()
void void
HaltDeviceThread() HaltDeviceThread()
{ {
#ifdef HW_RVL
deviceHalt = true; deviceHalt = true;
#ifdef HW_RVL #ifdef HW_RVL
@ -94,6 +95,7 @@ HaltDeviceThread()
// wait for thread to finish // wait for thread to finish
while(!LWP_ThreadIsSuspended(devicethread)) while(!LWP_ThreadIsSuspended(devicethread))
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);
#endif
} }
/**************************************************************************** /****************************************************************************
@ -110,12 +112,14 @@ HaltParseThread()
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);
} }
/**************************************************************************** /****************************************************************************
* devicecallback * devicecallback
* *
* This checks our devices for changes (SD/USB removed) and * This checks our devices for changes (SD/USB removed) and
* initializes the network in the background * initializes the network in the background
***************************************************************************/ ***************************************************************************/
#ifdef HW_RVL
static int devsleep = 1*1000*1000; static int devsleep = 1*1000*1000;
static void * static void *
@ -131,7 +135,6 @@ devicecallback (void *arg)
while (1) while (1)
{ {
#ifdef HW_RVL
if(isMounted[DEVICE_SD]) if(isMounted[DEVICE_SD])
{ {
if(!sd->isInserted()) // check if the device was removed if(!sd->isInserted()) // check if the device was removed
@ -152,24 +155,7 @@ devicecallback (void *arg)
UpdateCheck(); UpdateCheck();
InitializeNetwork(SILENT); InitializeNetwork(SILENT);
#else
if(isMounted[DEVICE_SD_SLOTA])
{
if(!carda->isInserted()) // check if the device was removed
{
unmountRequired[DEVICE_SD_SLOTA] = true;
isMounted[DEVICE_SD_SLOTA] = false;
}
}
if(isMounted[DEVICE_SD_SLOTB])
{
if(!cardb->isInserted()) // check if the device was removed
{
unmountRequired[DEVICE_SD_SLOTB] = true;
isMounted[DEVICE_SD_SLOTB] = false;
}
}
#endif
if(isMounted[DEVICE_DVD]) if(isMounted[DEVICE_DVD])
{ {
if(!dvd->isInserted()) // check if the device was removed if(!dvd->isInserted()) // check if the device was removed
@ -191,6 +177,7 @@ devicecallback (void *arg)
} }
return NULL; return NULL;
} }
#endif
static void * static void *
parsecallback (void *arg) parsecallback (void *arg)
@ -213,7 +200,9 @@ parsecallback (void *arg)
void void
InitDeviceThread() InitDeviceThread()
{ {
#ifdef HW_RVL
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40); LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40);
#endif
LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80); LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80);
} }
@ -293,10 +282,14 @@ static bool MountFAT(int device, int silent)
if(mounted || silent) if(mounted || silent)
break; break;
#ifdef HW_RVL
if(device == DEVICE_SD) if(device == DEVICE_SD)
retry = ErrorPromptRetry("SD card not found!"); retry = ErrorPromptRetry("SD card not found!");
else else
retry = ErrorPromptRetry("USB drive not found!"); retry = ErrorPromptRetry("USB drive not found!");
#else
retry = ErrorPromptRetry("SD card not found!");
#endif
} }
isMounted[device] = mounted; isMounted[device] = mounted;
@ -382,26 +375,26 @@ bool FindDevice(char * filepath, int * device)
*device = DEVICE_USB; *device = DEVICE_USB;
return true; return true;
} }
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
else if(strncmp(filepath, "smb:", 4) == 0) else if(strncmp(filepath, "smb:", 4) == 0)
{ {
*device = DEVICE_SMB; *device = DEVICE_SMB;
return true; return true;
} }
else if(strncmp(filepath, "carda:", 5) == 0) else if(strncmp(filepath, "carda:", 6) == 0)
{ {
*device = DEVICE_SD_SLOTA; *device = DEVICE_SD_SLOTA;
return true; return true;
} }
else if(strncmp(filepath, "cardb:", 5) == 0) else if(strncmp(filepath, "cardb:", 6) == 0)
{ {
*device = DEVICE_SD_SLOTB; *device = DEVICE_SD_SLOTB;
return true; return true;
} }
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
return false; return false;
} }
@ -431,16 +424,23 @@ bool ChangeInterface(int device, bool silent)
switch(device) switch(device)
{ {
#ifdef HW_RVL
case DEVICE_SD: case DEVICE_SD:
case DEVICE_USB: case DEVICE_USB:
#else
case DEVICE_SD_SLOTA:
case DEVICE_SD_SLOTB:
#endif
mounted = MountFAT(device, silent); mounted = MountFAT(device, silent);
break; break;
case DEVICE_DVD: case DEVICE_DVD:
mounted = MountDVD(silent); mounted = MountDVD(silent);
break; break;
#ifdef HW_RVL
case DEVICE_SMB: case DEVICE_SMB:
mounted = ConnectShare(silent); mounted = ConnectShare(silent);
break; break;
#endif
} }
return mounted; return mounted;
@ -645,12 +645,12 @@ ParseDirectory(bool waitParse)
parseHalt = false; parseHalt = false;
ParseDirEntries(); // index first 20 entries ParseDirEntries(); // index first 20 entries
LWP_ResumeThread(parsethread); // index remaining entries LWP_ResumeThread(parsethread); // index remaining entries
if(waitParse) // wait for complete parsing if(waitParse) // wait for complete parsing
{ {
ShowAction("Loading..."); ShowAction("Loading...");
while(!LWP_ThreadIsSuspended(parsethread)) while(!LWP_ThreadIsSuspended(parsethread))
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);

View File

@ -174,6 +174,10 @@
Nintendo Co., Limited and its subsidiary companies. Nintendo Co., Limited and its subsidiary companies.
***********************************************************************************/ ***********************************************************************************/
#ifdef GEKKO
#include <gccore.h>
#include <malloc.h>
#endif
#include <string> #include <string>
#include <numeric> #include <numeric>
@ -971,7 +975,7 @@ static void S9xDeinterleaveType1 (int size, uint8 *base)
blocks[i * 2 + 1] = i; blocks[i * 2 + 1] = i;
} }
uint8 *tmp = (uint8 *) malloc(0x8000); uint8 *tmp = (uint8 *) memalign(32,0x8000);
if (tmp) if (tmp)
{ {
for (int i = 0; i < nblocks * 2; i++) for (int i = 0; i < nblocks * 2; i++)
@ -1012,7 +1016,7 @@ static void S9xDeinterleaveType2 (int size, uint8 *base)
for (int i = 0; i < nblocks * 2; i++) for (int i = 0; i < nblocks * 2; i++)
blocks[i] = (i & ~0xf) | ((i & 3) << 2) | ((i & 12) >> 2); blocks[i] = (i & ~0xf) | ((i & 3) << 2) | ((i & 12) >> 2);
uint8 *tmp = (uint8 *) malloc(0x10000); uint8 *tmp = (uint8 *) memalign(32,0x10000);
if (tmp) if (tmp)
{ {
for (int i = 0; i < nblocks * 2; i++) for (int i = 0; i < nblocks * 2; i++)
@ -1045,7 +1049,7 @@ static void S9xDeinterleaveGD24 (int size, uint8 *base)
Settings.DisplayColor = BUILD_PIXEL(0, 31, 31); Settings.DisplayColor = BUILD_PIXEL(0, 31, 31);
SET_UI_COLOR(0, 255, 255); SET_UI_COLOR(0, 255, 255);
uint8 *tmp = (uint8 *) malloc(0x80000); uint8 *tmp = (uint8 *) memalign(32,0x80000);
if (tmp) if (tmp)
{ {
memmove(tmp, &base[0x180000], 0x80000); memmove(tmp, &base[0x180000], 0x80000);
@ -1063,26 +1067,26 @@ static void S9xDeinterleaveGD24 (int size, uint8 *base)
bool8 CMemory::Init (void) bool8 CMemory::Init (void)
{ {
RAM = (uint8 *) malloc(0x20000); RAM = (uint8 *) memalign(32,0x20000);
SRAM = (uint8 *) malloc(0x20000); SRAM = (uint8 *) memalign(32,0x20000);
VRAM = (uint8 *) malloc(0x10000); VRAM = (uint8 *) memalign(32,0x10000);
ROM = (uint8 *) malloc(MAX_ROM_SIZE + 0x200 + 0x8000); ROM = (uint8 *) memalign(32,MAX_ROM_SIZE + 0x200 + 0x8000);
IPPU.TileCache[TILE_2BIT] = (uint8 *) malloc(MAX_2BIT_TILES * 64); IPPU.TileCache[TILE_2BIT] = (uint8 *) memalign(32,MAX_2BIT_TILES * 64);
IPPU.TileCache[TILE_4BIT] = (uint8 *) malloc(MAX_4BIT_TILES * 64); IPPU.TileCache[TILE_4BIT] = (uint8 *) memalign(32,MAX_4BIT_TILES * 64);
IPPU.TileCache[TILE_8BIT] = (uint8 *) malloc(MAX_8BIT_TILES * 64); IPPU.TileCache[TILE_8BIT] = (uint8 *) memalign(32,MAX_8BIT_TILES * 64);
IPPU.TileCache[TILE_2BIT_EVEN] = (uint8 *) malloc(MAX_2BIT_TILES * 64); IPPU.TileCache[TILE_2BIT_EVEN] = (uint8 *) memalign(32,MAX_2BIT_TILES * 64);
IPPU.TileCache[TILE_2BIT_ODD] = (uint8 *) malloc(MAX_2BIT_TILES * 64); IPPU.TileCache[TILE_2BIT_ODD] = (uint8 *) memalign(32,MAX_2BIT_TILES * 64);
IPPU.TileCache[TILE_4BIT_EVEN] = (uint8 *) malloc(MAX_4BIT_TILES * 64); IPPU.TileCache[TILE_4BIT_EVEN] = (uint8 *) memalign(32,MAX_4BIT_TILES * 64);
IPPU.TileCache[TILE_4BIT_ODD] = (uint8 *) malloc(MAX_4BIT_TILES * 64); IPPU.TileCache[TILE_4BIT_ODD] = (uint8 *) memalign(32,MAX_4BIT_TILES * 64);
IPPU.TileCached[TILE_2BIT] = (uint8 *) malloc(MAX_2BIT_TILES); IPPU.TileCached[TILE_2BIT] = (uint8 *) memalign(32,MAX_2BIT_TILES);
IPPU.TileCached[TILE_4BIT] = (uint8 *) malloc(MAX_4BIT_TILES); IPPU.TileCached[TILE_4BIT] = (uint8 *) memalign(32,MAX_4BIT_TILES);
IPPU.TileCached[TILE_8BIT] = (uint8 *) malloc(MAX_8BIT_TILES); IPPU.TileCached[TILE_8BIT] = (uint8 *) memalign(32,MAX_8BIT_TILES);
IPPU.TileCached[TILE_2BIT_EVEN] = (uint8 *) malloc(MAX_2BIT_TILES); IPPU.TileCached[TILE_2BIT_EVEN] = (uint8 *) memalign(32,MAX_2BIT_TILES);
IPPU.TileCached[TILE_2BIT_ODD] = (uint8 *) malloc(MAX_2BIT_TILES); IPPU.TileCached[TILE_2BIT_ODD] = (uint8 *) memalign(32,MAX_2BIT_TILES);
IPPU.TileCached[TILE_4BIT_EVEN] = (uint8 *) malloc(MAX_4BIT_TILES); IPPU.TileCached[TILE_4BIT_EVEN] = (uint8 *) memalign(32,MAX_4BIT_TILES);
IPPU.TileCached[TILE_4BIT_ODD] = (uint8 *) malloc(MAX_4BIT_TILES); IPPU.TileCached[TILE_4BIT_ODD] = (uint8 *) memalign(32,MAX_4BIT_TILES);
if (!RAM || !SRAM || !VRAM || !ROM || if (!RAM || !SRAM || !VRAM || !ROM ||
!IPPU.TileCache[TILE_2BIT] || !IPPU.TileCache[TILE_2BIT] ||
@ -1719,7 +1723,7 @@ again:
if (tales) if (tales)
{ {
uint8 *tmp = (uint8 *) malloc(CalculatedSize - 0x400000); uint8 *tmp = (uint8 *) memalign(32,CalculatedSize - 0x400000);
if (tmp) if (tmp)
{ {
S9xMessage(S9X_INFO, S9X_ROM_INTERLEAVED_INFO, "Fixing swapped ExHiROM..."); S9xMessage(S9X_INFO, S9X_ROM_INTERLEAVED_INFO, "Fixing swapped ExHiROM...");
@ -2162,7 +2166,7 @@ char * CMemory::Safe (const char *s)
free(safe); free(safe);
safe_len = len + 1; safe_len = len + 1;
safe = (char *) malloc(safe_len); safe = (char *) memalign(32,safe_len);
} }
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
@ -2201,7 +2205,7 @@ char * CMemory::SafeANK (const char *s)
free(safe); free(safe);
safe_len = len + 1; safe_len = len + 1;
safe = (char *) malloc(safe_len); safe = (char *) memalign(32,safe_len);
} }
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)

View File

@ -186,8 +186,11 @@
struct CMemory struct CMemory
{ {
enum enum
#ifdef HW_DOL
{ MAX_ROM_SIZE = 0x600000 };
#else
{ MAX_ROM_SIZE = 0x800000 }; { MAX_ROM_SIZE = 0x800000 };
#endif
enum file_formats enum file_formats
{ FILE_ZIP, FILE_JMA, FILE_DEFAULT }; { FILE_ZIP, FILE_JMA, FILE_DEFAULT };