-fixed gamercards for sure now

-updated gamecube installer, compression+32k align works fine, just 
compression still doesnt work properly with audio streaming games
This commit is contained in:
fix94.1 2012-02-24 21:08:24 +00:00
parent 02ea975071
commit 925900a393
3 changed files with 46 additions and 43 deletions

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2012
* by OverjoY for Wiiflow
* by OverjoY and FIX94 for Wiiflow
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
@ -122,11 +122,12 @@ s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t
return wrote;
}
s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length)
s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment)
{
u8 *ReadBuffer = (u8 *)memalign(32, gc_readsize+4);
u32 toread = 0;
u32 wrote = 0;
*alignment = 32768;
FILE *f = fopen(path, "ab");
while(length)
@ -138,25 +139,32 @@ s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length)
s32 ret = __DiscReadRaw(ReadBuffer, offset, (toread+31)&(~31));
if (ret == 1)
memset(ReadBuffer, 0, gc_readsize);
if( ret > 1 )
return -1;
else if (ret > 1)
return 0;
if (aligned)
{
fwrite(ReadBuffer, 1, (toread+31)&(~31), f);
wrote += (toread+31)&(~31);
}
else
{
fwrite(ReadBuffer, 1, (toread+3)&(~3), f);
wrote += (toread+3)&(~3);
}
fwrite(ReadBuffer, 1, (toread+32767)&(~32767), f);
wrote += (toread+32767)&(~32767);
offset += toread;
length -= toread;
}
else
{
for(unsigned int align = 0x8000; align > 2; align/=2)
{
if((offset & (align-1)) == 0)
{
fwrite(ReadBuffer, 1, (toread+(align-1))&(~(align-1)), f);
wrote += (toread+(align-1))&(~(align-1));
offset += toread;
length -= toread;
*alignment = (int)align;
break;
}
}
}
}
fclose(f);
free(ReadBuffer);
return wrote;
@ -256,7 +264,9 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
gprintf("Writing %s\n", gamepath);
if(compressed)
{
ret = __DiscWriteAligned(gamepath, 0, GamePartOffset);
int alignment;
ret = __DiscWriteAligned(gamepath, 0, GamePartOffset, &alignment);
wrote += ret;
u32 i;
@ -269,8 +279,8 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
}
else
{
ret = __DiscWriteAligned(gamepath, fst[i].FileOffset, fst[i].FileLength);
gprintf("Writing: %d/%d: %s from 0x%08x to 0x%08x\n", i, FSTEnt, FSTNameOff + fst[i].NameOffset, fst[i].FileOffset, wrote);
ret = __DiscWriteAligned(gamepath, fst[i].FileOffset, fst[i].FileLength, &alignment);
gprintf("Writing: %d/%d: %s from 0x%08x to 0x%08x(%i)\n", i, FSTEnt, FSTNameOff + fst[i].NameOffset, fst[i].FileOffset, wrote, alignment);
if( ret >= 0 )
{
fst[i].FileOffset = wrote;

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2012
* by OverjoY for Wiiflow
* by OverjoY and FIX94 for Wiiflow
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
@ -84,6 +84,6 @@ private:
} FST;
s32 __DiscReadRaw(void *outbuf, u32 offset, u32 length);
s32 __DiscWrite(char * path, u32 offset, u32 length, progress_callback_t spinner , void *spinner_data);
s32 __DiscWriteAligned(char * path, u32 offset, u32 length);
s32 __DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment);
};
#endif

View File

@ -19,9 +19,9 @@ int amount_of_providers = 0;
u8 register_card_provider(const char *url, const char *key)
{
if (strlen(url) > 0 && strlen(key) > 0)
if (strlen(url) > 0 && strlen(key) > 0 && strstr(url, "{KEY}") != NULL && strstr(url, "{ID6}") != NULL)
{
providers = (struct provider *) realloc(providers, (amount_of_providers + 1) * sizeof(struct provider));;
providers = (struct provider *) realloc(providers, (amount_of_providers + 1) * sizeof(struct provider));
memset(&providers[amount_of_providers], 0, sizeof(struct provider));
strncpy((char *) providers[amount_of_providers].url, url, 128);
strncpy((char *) providers[amount_of_providers].key, key, 48);
@ -35,12 +35,8 @@ u8 register_card_provider(const char *url, const char *key)
u8 has_enabled_providers()
{
int i;
for (i = 0; i < amount_of_providers && providers != NULL; i++)
{
if (strlen(providers[i].url) > 0 && strlen(providers[i].key) > 0)
if (amount_of_providers != 0 && providers != NULL)
return 1;
}
return 0;
}
@ -52,8 +48,6 @@ void add_game_to_card(const char *gameid)
memset(url, 0, sizeof(url));
for (i = 0; i < amount_of_providers && providers != NULL; i++)
{
if (strlen(providers[i].url) > 0 && strlen(providers[i].key) > 0)
{
strcpy(url, (char *) providers[i].url);
str_replace(url, (char *) "{KEY}", (char *) providers[i].key, MAX_URL_SIZE);
@ -62,6 +56,5 @@ void add_game_to_card(const char *gameid)
gprintf("Gamertag URL:\n%s\n",(char*)url);
downloadfile(NULL, 0, (char *) url, NULL, NULL);
}
}
SAFE_FREE(url);
}