-set compressed dump and write ex files to yes

by default
-updated and cleaned up gamecube disc dumper, in
compressed mode it now shows the percentage of how
much wrote in size instead of the files wrote, this
avoids confusion why it freeze at some % and is more
accurate
This commit is contained in:
fix94.1 2012-03-04 13:22:36 +00:00
parent 5843737575
commit 5aef0bed27
3 changed files with 23 additions and 36 deletions

View File

@ -92,34 +92,19 @@ s32 GCDump::__DiscReadRaw(void *outbuf, u32 offset, u32 length)
return -1;
}
s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, u8 *ReadBuffer, progress_callback_t spinner, void *spinner_data)
s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, u32 already_done, u8 *ReadBuffer, progress_callback_t spinner, void *spinner_data)
{
gprintf("__DiscWrite(%s, 0x%08x, %x)\n", path, offset, length);
u32 toread = 0;
u32 wrote = 0;
FILE *f = fopen(path, "wb");
while(length)
{
toread = min(length,gc_readsize);
s32 ret = __DiscReadRaw(ReadBuffer, offset, (toread+31)&(~31));
if( ret == 1 )
memset(ReadBuffer, 0, gc_readsize);
else if( ret > 1 )
return 0;
fwrite(ReadBuffer, 1, toread, f);
wrote += toread;
offset += toread;
length -= toread;
if(spinner)
spinner(wrote, DiscSize, spinner_data);
}
wrote = __DiscWriteFile(f, offset, length, already_done, ReadBuffer, spinner, spinner_data);
SAFE_CLOSE(f);
return wrote;
}
s32 GCDump::__DiscWriteAligned(FILE *f, u32 offset, u32 length, u8 *ReadBuffer)
s32 GCDump::__DiscWriteFile(FILE *f, u32 offset, u32 length, u32 already_done, u8 *ReadBuffer, progress_callback_t spinner, void *spinner_data)
{
u32 toread = 0;
u32 wrote = 0;
@ -136,6 +121,8 @@ s32 GCDump::__DiscWriteAligned(FILE *f, u32 offset, u32 length, u8 *ReadBuffer)
wrote += toread;
offset += toread;
length -= toread;
if(spinner)
spinner(already_done+wrote, DiscSizeCalculated, spinner_data);
}
return wrote;
}
@ -189,7 +176,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
DataSize = *(vu32*)(ReadBuffer+0x438);
DOLSize = FSTOffset - DOLOffset;
DiscSize = DataSize + GamePartOffset;
DiscSize = DataSize + GamePartOffset;
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
@ -212,9 +199,9 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
snprintf(minfo, sizeof(minfo), "[%.06s] %s", (char *)gcheader.id, gcheader.title);
if(FSTTotal > FSTSize)
message( 4, j+1, minfo, spinner_data);
message(4, j+1, minfo, spinner_data);
else
message( 3, 0, minfo, spinner_data);
message(3, 0, minfo, spinner_data);
gprintf("Dumping: %s %s\n", gcheader.title, compressed ? "compressed" : "full");
@ -235,15 +222,15 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
gprintf("Writing %s/boot.bin\n", folder);
snprintf(gamepath, sizeof(gamepath), "%s/boot.bin", folder);
__DiscWrite(gamepath, 0, 0x440, ReadBuffer, spinner, spinner_data);
__DiscWrite(gamepath, 0, 0x440, wrote, ReadBuffer, spinner, spinner_data);
gprintf("Writing %s/bi2.bin\n", folder);
snprintf(gamepath, sizeof(gamepath), "%s/bi2.bin", folder);
__DiscWrite(gamepath, 0x440, 0x2000, ReadBuffer, spinner, spinner_data);
snprintf(gamepath, sizeof(gamepath), "%s/bi2.bin", folder);
__DiscWrite(gamepath, 0x440, 0x2000, wrote, ReadBuffer, spinner, spinner_data);
gprintf("Writing %s/apploader.img\n", folder);
snprintf(gamepath, sizeof(gamepath), "%s/apploader.img", folder);
__DiscWrite(gamepath, 0x2440, ApploaderSize, ReadBuffer, spinner, spinner_data);
snprintf(gamepath, sizeof(gamepath), "%s/apploader.img", folder);
__DiscWrite(gamepath, 0x2440, ApploaderSize, wrote, ReadBuffer, spinner, spinner_data);
}
snprintf(gamepath, sizeof(gamepath), "%s:/games/%s [%.06s]%s/game.iso", gamepartition, gcheader.title, (char *)gcheader.id, j ? "2" : "");
@ -258,7 +245,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
FILE *f;
f = fopen(gamepath, "wb");
ret = __DiscWriteAligned(f, 0, (FSTOffset + FSTSize), ReadBuffer);
ret = __DiscWriteFile(f, 0, (FSTOffset + FSTSize), wrote, ReadBuffer, spinner, spinner_data);
wrote += (FSTOffset + FSTSize);
u32 i;
@ -290,17 +277,15 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
break;
}
}
ret = __DiscWriteAligned(f, fst[i].FileOffset, fst[i].FileLength, ReadBuffer);
ret = __DiscWriteFile(f, fst[i].FileOffset, fst[i].FileLength, wrote, ReadBuffer, spinner, spinner_data);
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;
wrote += ret;
spinner(i, FSTEnt, spinner_data);
}
else
{
spinner(FSTEnt, FSTEnt, spinner_data);
MEM2_free(ReadBuffer);
MEM2_free(FSTBuffer);
SAFE_CLOSE(f);
@ -318,7 +303,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
}
else
{
ret = __DiscWrite(gamepath, 0, DiscSize, ReadBuffer, spinner, spinner_data);
ret = __DiscWrite(gamepath, 0, DiscSize, wrote, ReadBuffer, spinner, spinner_data);
if( ret < 0 )
{
MEM2_free(ReadBuffer);
@ -719,6 +704,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp, message_callback_t message, void
break;
}
MEM2_free(ReadBuffer);
DiscSizeCalculated = size;
*needed = size/0x8000;
gprintf("Free space needed: %d Mb (%x blocks)\n", (size/1024)/1024, size/0x8000);
return 0;

View File

@ -72,6 +72,7 @@ private:
u32 GamePartOffset;
u32 DataSize;
u32 DiscSize;
u32 DiscSizeCalculated;
typedef struct
{
union
@ -99,7 +100,7 @@ private:
};
} FST;
s32 __DiscReadRaw(void *outbuf, u32 offset, u32 length);
s32 __DiscWrite(char * path, u32 offset, u32 length, u8 *ReadBuffer, progress_callback_t spinner , void *spinner_data);
s32 __DiscWriteAligned(FILE *f, u32 offset, u32 length, u8 *ReadBuffer);
s32 __DiscWrite(char * path, u32 offset, u32 length, u32 already_done, u8 *ReadBuffer, progress_callback_t spinner, void *spinner_data);
s32 __DiscWriteFile(FILE *f, u32 offset, u32 length, u32 already_done, u8 *ReadBuffer, progress_callback_t spinner, void *spinner_data);
};
#endif

View File

@ -145,8 +145,8 @@ int CMenu::_GCgameInstaller(void *obj)
GCDump m_gcdump;
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 comp = m.m_cfg.getBool("DML", "compressed_dump", true);
bool wexf = m.m_cfg.getBool("DML", "write_ex_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 = 1048576; //1MB