-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:
fix94.1 2012-02-26 15:03:54 +00:00
parent 714047d220
commit fa7da0a437
3 changed files with 67 additions and 64 deletions

View File

@ -122,25 +122,11 @@ s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t
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);
u32 toread = 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)
{
@ -154,22 +140,11 @@ s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignme
else if (ret > 1)
return 0;
if (aligned)
{
fwrite(ReadBuffer, 1, (toread+32767)&(~32767), f);
wrote += (toread+32767)&(~32767);
fwrite(ReadBuffer, 1, toread, f);
wrote += toread;
offset += 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);
return wrote;
}
@ -228,6 +203,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
ret = __DiscReadRaw(FSTBuffer, FSTOffset, (FSTSize+31)&(~31));
if(ret > 0)
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 size : %d\n", FSTSize);
gprintf("Num FST entries: %d\n", FSTEnt);
gprintf("Data Offset : 0x%08x\n", FSTOffset+FSTSize);
gprintf("Disc size : %d\n", DiscSize);
if(writeexfiles)
@ -268,10 +245,14 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
gprintf("Writing %s\n", gamepath);
if(compressed)
{
int alignment;
u32 align;
u32 correction;
ret = __DiscWriteAligned(gamepath, 0, GamePartOffset, &alignment);
wrote += ret;
FILE *f;
f = fopen(gamepath, "ab");
ret = __DiscWriteAligned(f, 0, (FSTOffset + FSTSize));
wrote += (FSTOffset + FSTSize);
u32 i;
@ -283,8 +264,28 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
}
else
{
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);
correction = 0x00;
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 )
{
fst[i].FileOffset = wrote;
@ -295,14 +296,16 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
{
spinner(FSTEnt, FSTEnt, spinner_data);
MEM2_free(FSTBuffer);
SAFE_CLOSE(f);
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);
fwrite(fst, 1, FSTSize, f);
SAFE_CLOSE(f);

View File

@ -38,7 +38,7 @@ public:
skiponerror = skip;
compressed = comp;
writeexfiles = wexf;
aligned = align;
force_32k_align = align;
gc_nbrretry = nretry;
gc_readsize = rsize;
gc_skipped = 0;
@ -46,7 +46,7 @@ public:
s32 DumpGame(progress_callback_t spinner, void *spinner_data);
s32 CheckSpace(u32 *needed, bool comp);
private:
bool aligned;
bool force_32k_align;
bool skiponerror;
bool compressed;
bool writeexfiles;
@ -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, int *alignment);
s32 __DiscWriteAligned(FILE *f, u32 offset, u32 length);
};
#endif

View File

@ -115,7 +115,7 @@ int CMenu::_GCgameInstaller(void *obj)
bool skip = m.m_cfg.getBool("DML", "skip_on_error", false);
bool comp = m.m_cfg.getBool("DML", "compressed_dump", 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 rsize = 32768;