mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-30 15:14:18 +01:00
-updated gamecube game installer,
images now got the same md5 as the one compressed with discex, compresion without force 32k align works fine too now
This commit is contained in:
parent
714047d220
commit
fa7da0a437
@ -122,25 +122,11 @@ s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t
|
|||||||
return wrote;
|
return wrote;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment)
|
s32 GCDump::__DiscWriteAligned(FILE *f, u32 offset, u32 length)
|
||||||
{
|
{
|
||||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize+4);
|
u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize+4);
|
||||||
u32 toread = 0;
|
u32 toread = 0;
|
||||||
u32 wrote = 0;
|
u32 wrote = 0;
|
||||||
*alignment = 32768;
|
|
||||||
FILE *f = fopen(path, "ab");
|
|
||||||
|
|
||||||
unsigned int align = 0x8000;
|
|
||||||
|
|
||||||
for(align = 0x8000; align > 2; align/=2)
|
|
||||||
{
|
|
||||||
if((offset & (align-1)) == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*alignment = (int)align;
|
|
||||||
|
|
||||||
while(length)
|
while(length)
|
||||||
{
|
{
|
||||||
@ -154,22 +140,11 @@ s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignme
|
|||||||
else if (ret > 1)
|
else if (ret > 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (aligned)
|
fwrite(ReadBuffer, 1, toread, f);
|
||||||
{
|
wrote += toread;
|
||||||
fwrite(ReadBuffer, 1, (toread+32767)&(~32767), f);
|
|
||||||
wrote += (toread+32767)&(~32767);
|
|
||||||
offset += toread;
|
offset += toread;
|
||||||
length -= toread;
|
length -= toread;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
fwrite(ReadBuffer, 1, ((toread+(align-1))&(~(align-1))), f);
|
|
||||||
wrote += ((toread+(align-1))&(~(align-1)));
|
|
||||||
offset += toread;
|
|
||||||
length -= toread;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SAFE_CLOSE(f);
|
|
||||||
MEM2_free(ReadBuffer);
|
MEM2_free(ReadBuffer);
|
||||||
return wrote;
|
return wrote;
|
||||||
}
|
}
|
||||||
@ -228,6 +203,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
|
|||||||
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
||||||
|
|
||||||
ret = __DiscReadRaw(FSTBuffer, FSTOffset, (FSTSize+31)&(~31));
|
ret = __DiscReadRaw(FSTBuffer, FSTOffset, (FSTSize+31)&(~31));
|
||||||
|
|
||||||
if(ret > 0)
|
if(ret > 0)
|
||||||
return 0x31100;
|
return 0x31100;
|
||||||
|
|
||||||
@ -246,6 +222,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
|
|||||||
gprintf("FST offset : 0x%08x\n", FSTOffset);
|
gprintf("FST offset : 0x%08x\n", FSTOffset);
|
||||||
gprintf("FST size : %d\n", FSTSize);
|
gprintf("FST size : %d\n", FSTSize);
|
||||||
gprintf("Num FST entries: %d\n", FSTEnt);
|
gprintf("Num FST entries: %d\n", FSTEnt);
|
||||||
|
gprintf("Data Offset : 0x%08x\n", FSTOffset+FSTSize);
|
||||||
gprintf("Disc size : %d\n", DiscSize);
|
gprintf("Disc size : %d\n", DiscSize);
|
||||||
|
|
||||||
if(writeexfiles)
|
if(writeexfiles)
|
||||||
@ -268,10 +245,14 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
|
|||||||
gprintf("Writing %s\n", gamepath);
|
gprintf("Writing %s\n", gamepath);
|
||||||
if(compressed)
|
if(compressed)
|
||||||
{
|
{
|
||||||
int alignment;
|
u32 align;
|
||||||
|
u32 correction;
|
||||||
|
|
||||||
ret = __DiscWriteAligned(gamepath, 0, GamePartOffset, &alignment);
|
FILE *f;
|
||||||
wrote += ret;
|
f = fopen(gamepath, "ab");
|
||||||
|
|
||||||
|
ret = __DiscWriteAligned(f, 0, (FSTOffset + FSTSize));
|
||||||
|
wrote += (FSTOffset + FSTSize);
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
@ -283,8 +264,28 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = __DiscWriteAligned(gamepath, fst[i].FileOffset, fst[i].FileLength, &alignment);
|
correction = 0x00;
|
||||||
gprintf("Writing: %d/%d: %s from 0x%08x to 0x%08x(%i)\n", i, FSTEnt, FSTNameOff + fst[i].NameOffset, fst[i].FileOffset, wrote, alignment);
|
for(align = 0x8000; align > 2; align/=2)
|
||||||
|
{
|
||||||
|
if((fst[i].FileOffset & (align-1)) == 0 || force_32k_align)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while(((wrote+correction) & (align-1)) != 0)
|
||||||
|
correction++;
|
||||||
|
|
||||||
|
if(correction>0x00)
|
||||||
|
{
|
||||||
|
u32 j;
|
||||||
|
for(j=0x00;j<correction;j++)
|
||||||
|
fwrite("", 1, 1, f);
|
||||||
|
wrote += correction;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __DiscWriteAligned(f, fst[i].FileOffset, fst[i].FileLength);
|
||||||
|
gprintf("Writing: %d/%d: %s from 0x%08x to 0x%08x(%i)\n", i, FSTEnt, FSTNameOff + fst[i].NameOffset, fst[i].FileOffset, wrote, align);
|
||||||
if( ret >= 0 )
|
if( ret >= 0 )
|
||||||
{
|
{
|
||||||
fst[i].FileOffset = wrote;
|
fst[i].FileOffset = wrote;
|
||||||
@ -295,14 +296,16 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
|
|||||||
{
|
{
|
||||||
spinner(FSTEnt, FSTEnt, spinner_data);
|
spinner(FSTEnt, FSTEnt, spinner_data);
|
||||||
MEM2_free(FSTBuffer);
|
MEM2_free(FSTBuffer);
|
||||||
|
SAFE_CLOSE(f);
|
||||||
return gc_error;
|
return gc_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gprintf("Updating FST\n");
|
SAFE_CLOSE(f);
|
||||||
|
|
||||||
FILE *f = fopen(gamepath, "r+");
|
gprintf("Updating FST\n");
|
||||||
|
f = fopen(gamepath, "r+");
|
||||||
fseek(f, FSTOffset, SEEK_SET);
|
fseek(f, FSTOffset, SEEK_SET);
|
||||||
fwrite(fst, 1, FSTSize, f);
|
fwrite(fst, 1, FSTSize, f);
|
||||||
SAFE_CLOSE(f);
|
SAFE_CLOSE(f);
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
skiponerror = skip;
|
skiponerror = skip;
|
||||||
compressed = comp;
|
compressed = comp;
|
||||||
writeexfiles = wexf;
|
writeexfiles = wexf;
|
||||||
aligned = align;
|
force_32k_align = align;
|
||||||
gc_nbrretry = nretry;
|
gc_nbrretry = nretry;
|
||||||
gc_readsize = rsize;
|
gc_readsize = rsize;
|
||||||
gc_skipped = 0;
|
gc_skipped = 0;
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
s32 DumpGame(progress_callback_t spinner, void *spinner_data);
|
s32 DumpGame(progress_callback_t spinner, void *spinner_data);
|
||||||
s32 CheckSpace(u32 *needed, bool comp);
|
s32 CheckSpace(u32 *needed, bool comp);
|
||||||
private:
|
private:
|
||||||
bool aligned;
|
bool force_32k_align;
|
||||||
bool skiponerror;
|
bool skiponerror;
|
||||||
bool compressed;
|
bool compressed;
|
||||||
bool writeexfiles;
|
bool writeexfiles;
|
||||||
@ -84,6 +84,6 @@ private:
|
|||||||
} FST;
|
} FST;
|
||||||
s32 __DiscReadRaw(void *outbuf, u32 offset, u32 length);
|
s32 __DiscReadRaw(void *outbuf, u32 offset, u32 length);
|
||||||
s32 __DiscWrite(char * path, u32 offset, u32 length, progress_callback_t spinner , void *spinner_data);
|
s32 __DiscWrite(char * path, u32 offset, u32 length, progress_callback_t spinner , void *spinner_data);
|
||||||
s32 __DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment);
|
s32 __DiscWriteAligned(FILE *f, u32 offset, u32 length);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
@ -115,7 +115,7 @@ int CMenu::_GCgameInstaller(void *obj)
|
|||||||
bool skip = m.m_cfg.getBool("DML", "skip_on_error", false);
|
bool skip = m.m_cfg.getBool("DML", "skip_on_error", false);
|
||||||
bool comp = m.m_cfg.getBool("DML", "compressed_dump", false);
|
bool comp = m.m_cfg.getBool("DML", "compressed_dump", false);
|
||||||
bool wexf = m.m_cfg.getBool("DML", "write_ex_files", false);
|
bool wexf = m.m_cfg.getBool("DML", "write_ex_files", false);
|
||||||
bool alig = m.m_cfg.getBool("DML", "align_files", true);
|
bool alig = m.m_cfg.getBool("DML", "force_32k_align_files", false);
|
||||||
u32 nretry = m.m_cfg.getUInt("DML", "num_retries", 5);
|
u32 nretry = m.m_cfg.getUInt("DML", "num_retries", 5);
|
||||||
u32 rsize = 32768;
|
u32 rsize = 32768;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user