-updated gamecube dumper again, enabled

32k align by default now, compression without 
32k still doesnt work properly
-fixed stupid bug which may deletes all your
games when deleting one game (thanks Miigotu)
-reverted video change of r154 for now
This commit is contained in:
fix94.1 2012-02-25 18:27:11 +00:00
parent 925900a393
commit cb478c4dd3
4 changed files with 41 additions and 35 deletions

View File

@ -519,7 +519,7 @@ void CVideo::_showWaitMessages(CVideo *m)
m->m_waitMessages.clear(); m->m_waitMessages.clear();
//gprintf("Stop showing images\n"); //gprintf("Stop showing images\n");
m->m_showingWaitMessages = false; m->m_showingWaitMessages = false;
//m->CheckWaitThread(false); m->CheckWaitThread(false);
gprintf("Stop showing images\n"); gprintf("Stop showing images\n");
} }

View File

@ -26,10 +26,10 @@
***************************************************************************/ ***************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <malloc.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include "mem2.hpp"
#include "gc_disc.hpp" #include "gc_disc.hpp"
#include "DeviceHandler.hpp" #include "DeviceHandler.hpp"
#include "disc.h" #include "disc.h"
@ -90,7 +90,7 @@ s32 GCDump::__DiscReadRaw(void *outbuf, u32 offset, u32 length)
s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t spinner, void *spinner_data) s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t spinner, void *spinner_data)
{ {
gprintf("__DiscWrite(%s, 0x%08x, %x)\n", path, offset, length); gprintf("__DiscWrite(%s, 0x%08x, %x)\n", path, offset, length);
u8 *ReadBuffer = (u8 *)memalign(32, gc_readsize); u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize);
u32 toread = 0; u32 toread = 0;
u32 wrote = 0; u32 wrote = 0;
FILE *f = fopen(path, "ab"); FILE *f = fopen(path, "ab");
@ -117,19 +117,31 @@ s32 GCDump::__DiscWrite(char * path, u32 offset, u32 length, progress_callback_t
spinner(wrote, DiscSize, spinner_data); spinner(wrote, DiscSize, spinner_data);
} }
fclose(f); SAFE_CLOSE(f);
free(ReadBuffer); MEM2_free(ReadBuffer);
return wrote; return wrote;
} }
s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment) s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignment)
{ {
u8 *ReadBuffer = (u8 *)memalign(32, 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; *alignment = 32768;
FILE *f = fopen(path, "ab"); 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)
{ {
toread = gc_readsize; toread = gc_readsize;
@ -151,22 +163,14 @@ s32 GCDump::__DiscWriteAligned(char * path, u32 offset, u32 length, int *alignme
} }
else else
{ {
for(unsigned int align = 0x8000; align > 2; align/=2) fwrite(ReadBuffer, 1, ((toread+(align-1))&(~(align-1))), f);
{ wrote += ((toread+(align-1))&(~(align-1)));
if((offset & (align-1)) == 0)
{
fwrite(ReadBuffer, 1, (toread+(align-1))&(~(align-1)), f);
wrote += (toread+(align-1))&(~(align-1));
offset += toread; offset += toread;
length -= toread; length -= toread;
*alignment = (int)align;
break;
} }
} }
} SAFE_CLOSE(f);
} MEM2_free(ReadBuffer);
fclose(f);
free(ReadBuffer);
return wrote; return wrote;
} }
@ -174,7 +178,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
{ {
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32); static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
u8 *ReadBuffer = (u8 *)memalign(32, 0x40); u8 *ReadBuffer = (u8 *)MEM2_alloc(0x40);
u8 *FSTBuffer; u8 *FSTBuffer;
u32 wrote = 0; u32 wrote = 0;
@ -216,12 +220,12 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
GamePartOffset = *(vu32*)(ReadBuffer+0x34); GamePartOffset = *(vu32*)(ReadBuffer+0x34);
DataSize = *(vu32*)(ReadBuffer+0x38); DataSize = *(vu32*)(ReadBuffer+0x38);
free(ReadBuffer); MEM2_free(ReadBuffer);
DOLSize = FSTOffset - DOLOffset; DOLSize = FSTOffset - DOLOffset;
DiscSize = DataSize + GamePartOffset; DiscSize = DataSize + GamePartOffset;
FSTBuffer = (u8 *)memalign(32, (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)
@ -290,7 +294,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
else else
{ {
spinner(FSTEnt, FSTEnt, spinner_data); spinner(FSTEnt, FSTEnt, spinner_data);
free(FSTBuffer); MEM2_free(FSTBuffer);
return gc_error; return gc_error;
} }
} }
@ -301,7 +305,7 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
FILE *f = fopen(gamepath, "r+"); FILE *f = fopen(gamepath, "r+");
fseek(f, FSTOffset, SEEK_SET); fseek(f, FSTOffset, SEEK_SET);
fwrite(fst, 1, FSTSize, f); fwrite(fst, 1, FSTSize, f);
fclose(f); SAFE_CLOSE(f);
gprintf("Done!! Disc old size: %d, disc new size: %d, saved: %d\n", DiscSize, wrote, DiscSize - wrote); gprintf("Done!! Disc old size: %d, disc new size: %d, saved: %d\n", DiscSize, wrote, DiscSize - wrote);
} }
@ -310,20 +314,20 @@ s32 GCDump::DumpGame(progress_callback_t spinner, void *spinner_data)
ret = __DiscWrite(gamepath, 0, DiscSize, spinner, spinner_data); ret = __DiscWrite(gamepath, 0, DiscSize, spinner, spinner_data);
if( ret < 0 ) if( ret < 0 )
{ {
free(FSTBuffer); MEM2_free(FSTBuffer);
return gc_error; return gc_error;
} }
gprintf("Done!! Disc size: %d\n", DiscSize); gprintf("Done!! Disc size: %d\n", DiscSize);
} }
free(FSTBuffer); MEM2_free(FSTBuffer);
return gc_skipped; return gc_skipped;
} }
s32 GCDump::CheckSpace(u32 *needed, bool comp) s32 GCDump::CheckSpace(u32 *needed, bool comp)
{ {
u8 *ReadBuffer = (u8 *)memalign(32, 0x40); u8 *ReadBuffer = (u8 *)MEM2_alloc(0x40);
s32 ret = __DiscReadRaw(ReadBuffer, 0x400, 0x40); s32 ret = __DiscReadRaw(ReadBuffer, 0x400, 0x40);
if(ret > 0) if(ret > 0)
@ -337,7 +341,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
u32 DiscSize = DataSize + GamePartOffset; u32 DiscSize = DataSize + GamePartOffset;
free(ReadBuffer); MEM2_free(ReadBuffer);
u32 size = 0; u32 size = 0;
@ -353,12 +357,12 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
} }
else else
{ {
u8 *FSTBuffer = (u8 *)memalign(32, (FSTSize+31)&(~31)); u8 *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)
{ {
free(FSTBuffer); MEM2_free(FSTBuffer);
return 1; return 1;
} }
@ -379,7 +383,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
size += (fst[i].FileLength+31)&(~31); size += (fst[i].FileLength+31)&(~31);
} }
} }
free(FSTBuffer); MEM2_free(FSTBuffer);
} }
*needed = size/0x8000; *needed = size/0x8000;
gprintf("Free space needed on SD: %d bytes (%x blocks)\n", size, size/0x8000); gprintf("Free space needed on SD: %d bytes (%x blocks)\n", size, size/0x8000);

View File

@ -163,9 +163,11 @@ s32 WBFS_Ext_RemoveGame(u8 *discid, char *gamepath)
if (ent->d_name[0] == '.') continue; if (ent->d_name[0] == '.') continue;
snprintf(file, sizeof(file), "%s/%s", folder, ent->d_name); snprintf(file, sizeof(file), "%s/%s", folder, ent->d_name);
if(discid != NULL && strstr(file, (char*)discid) != NULL)
remove(file); remove(file);
} }
closedir(dir_iter); closedir(dir_iter);
if(strlen(folder) > 11)
unlink(folder); unlink(folder);
return 0; return 0;
} }

View File

@ -114,7 +114,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", false); bool alig = m.m_cfg.getBool("DML", "align_files", true);
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;