From 152bde2c365dbc384d170ded1963c3dc00d00f56 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Thu, 1 Mar 2012 19:36:17 +0000 Subject: [PATCH] -size calculation of gamecube dumper should be more accurate now -changed another path limit from 64 to 1024, to prevent errors when trying to install gamecube games from usb to sd with long name --- source/loader/gc_disc.cpp | 50 +++++++++++++++++++++++++-------------- source/menu/menu_game.cpp | 2 +- source/menu/menu_wbfs.cpp | 4 ++-- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/source/loader/gc_disc.cpp b/source/loader/gc_disc.cpp index 08109096..e8b9629d 100644 --- a/source/loader/gc_disc.cpp +++ b/source/loader/gc_disc.cpp @@ -400,13 +400,13 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo s32 GCDump::CheckSpace(u32 *needed, bool comp, message_callback_t message, void *message_data) { static gc_discHdr gcheader ATTRIBUTE_ALIGN(32); - + u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440); u32 size = 0; u32 j; - + char minfo[74]; - + for( j=0; j<2; ++j) { s32 ret = __DiscReadRaw(ReadBuffer, 0, 0x440); @@ -415,7 +415,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp, message_callback_t message, void MEM2_free(ReadBuffer); return 1; } - + ID = *(vu32*)(ReadBuffer); ID2 = 0; Disc = *(vu8*)(ReadBuffer+0x06); @@ -426,24 +426,23 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp, message_callback_t message, void FSTTotal = *(vu32*)(ReadBuffer+0x42c); GamePartOffset = *(vu32*)(ReadBuffer+0x434); DataSize = *(vu32*)(ReadBuffer+0x438); - DiscSize = DataSize + GamePartOffset; - + bool done = false; - + Disc_ReadGCHeader(&gcheader); Asciify2(gcheader.title); - + snprintf(minfo, sizeof(minfo), "[%.06s] %s", (char *)gcheader.id, gcheader.title); - + message( 2, 0, minfo, message_data); - + if(writeexfiles) { size += 0xa440; size += ApploaderSize; } - + if(!comp) { size += DiscSize; @@ -458,27 +457,42 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp, message_callback_t message, void MEM2_free(FSTBuffer); return 1; } - + FSTable = (u8*)FSTBuffer; u32 FSTEnt = *(u32*)(FSTable+0x08); FST *fst = (FST *)(FSTable); - + + size += (FSTOffset + FSTSize); + u32 i; - + u32 correction; + u32 align; + for( i=1; i < FSTEnt; ++i ) { if( fst[i].Type ) { continue; } - else - { - size += (fst[i].FileLength+31)&(~31); + else + { + for(align = 0x8000; align > 2; align/=2) + { + if((fst[i].FileOffset & (align-1)) == 0 || force_32k_align) + { + correction = 0x00; + while(((size+correction) & (align-1)) != 0) + correction++; + size += correction; + break; + } + } + size += fst[i].FileLength; } } MEM2_free(FSTBuffer); } - + if(FSTTotal > FSTSize) { u32 cover = 0; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 9d68c8f5..46d130cc 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -429,7 +429,7 @@ void CMenu::_game(bool launch) { char gcfolder[MAX_FAT_PATH]; sprintf(gcfolder, "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id); - memset(hdr->path,0,256); + memset(hdr->path,0,sizeof(hdr->path)); if (DML_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD])) sprintf(hdr->path,"%s",(char*)hdr->hdr.id); else if (DML_GameIsInstalled(gcfolder, DeviceName[SD])) diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index eacf860d..99fd137a 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -226,8 +226,8 @@ int CMenu::_GCcopyGame(void *obj) m._setThrdMsg(L"", 0); if (!fsop_DirExist((char*)"sd:/games")) fsop_MakeFolder((char*)"sd:/games"); - char source[64]; - char target[64]; + char source[MAX_FAT_PATH]; + char target[MAX_FAT_PATH]; sprintf(source, "%s:/games/%s", DeviceName[currentPartition], m.m_cf.getHdr()->path); sprintf(target, "sd:/games/%s", m.m_cf.getHdr()->path); gprintf("Copying from: \n%s \nto: \n%s\n",source,target);