CDVDiso: Add the ability to create block dumps to the Linux port.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@449 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-08 02:39:15 +00:00
parent 5ad9f85500
commit d0490889d4
10 changed files with 613 additions and 560 deletions

View File

@ -179,13 +179,14 @@ EXPORT_C(s32) CDVDopen(const char* pTitle)
if (BlockDump)
{
char fname_only[MAX_PATH];
char* p, *plast;
#ifdef _WIN32
char fname[MAX_PATH], ext[MAX_PATH];
_splitpath(IsoFile, NULL, NULL, fname, ext);
_makepath(fname_only, NULL, NULL, fname, NULL);
#else
char* p, *plast;
plast = p = strchr(IsoFile, '/');
while (p != NULL)
{
@ -193,10 +194,12 @@ EXPORT_C(s32) CDVDopen(const char* pTitle)
p = strchr(p + 1, '/');
}
// Lets not create dumps in the plugin directory.
strcpy(fname_only, "../");
if (plast != NULL)
strcpy(fname_only, plast + 1);
strcat(fname_only, plast + 1);
else
strcpy(fname_only, IsoFile);
strcat(fname_only, IsoFile);
plast = p = strchr(fname_only, '.');

View File

@ -358,6 +358,25 @@
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="checkBlockDump">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Create a dump of the running iso</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>

View File

@ -48,7 +48,7 @@ void LoadConf()
fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
fscanf(f, "CdDev = %[^\n]\n", CdDev);
fscanf(f, "BlockDump = %[^\n]\n", &BlockDump);
fscanf(f, "BlockDump = %d\n", &BlockDump);
if (!strncmp(IsoFile, "CdDev =", 9)) *IsoFile = 0; // quick fix
if (*CdDev == 0) strcpy(CdDev, CDDEV_DEF);
@ -76,7 +76,7 @@ void SaveConf()
fprintf(f, "IsoFile = %s\n", IsoFile);
fprintf(f, "CdDev = %s\n", CdDev);
fprintf(f, "BlockDump = %s\n", &BlockDump);
fprintf(f, "BlockDump = %d\n", BlockDump);
fclose(f);
}

View File

@ -35,6 +35,11 @@
#include "CDVDiso.h"
#include "Config.h"
// Make it easier to check and set checkmarks in the gui
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
extern char *LibName;
@ -162,6 +167,12 @@ void OnOk(GtkMenuItem * menuitem, gpointer userdata)
strcpy(IsoFile, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
strcpy(CdDev, tmp);
if is_checked(ConfDlg, "checkBlockDump")
BlockDump = 1;
else
BlockDump = 0;
SaveConf();
gtk_widget_destroy(ConfDlg);
gtk_main_quit();
@ -323,8 +334,12 @@ void OnDecompress()
{
return;
}
if (Zmode == 1) c = s = buf.st_size / 6;
else c = s = (buf.st_size / 4) - 1;
if (Zmode == 1)
c = s = buf.st_size / 6;
else
c = s = (buf.st_size / 4) - 1;
f = fopen(table, "rb");
Ztable = (char*)malloc(buf.st_size);
fread(Ztable, 1, buf.st_size, f);
@ -336,8 +351,10 @@ void OnDecompress()
return;
}
if (Zmode == 1) IsoFile[strlen(IsoFile) - 2] = 0;
else IsoFile[strlen(IsoFile) - 3] = 0;
if (Zmode == 1)
IsoFile[strlen(IsoFile) - 2] = 0;
else
IsoFile[strlen(IsoFile) - 3] = 0;
f = fopen(IsoFile, "wb");
if (f == NULL)
@ -383,16 +400,20 @@ void OnDecompress()
}
size = CD_FRAMESIZE_RAW * blocks;
if (Zmode == 1) uncompress(cdbuffer, &size, Zbuf, ssize);
else BZ2_bzBuffToBuffDecompress(cdbuffer, (unsigned int*)&size, Zbuf, ssize, 0, 0);
if (Zmode == 1)
uncompress(cdbuffer, &size, Zbuf, ssize);
else
BZ2_bzBuffToBuffDecompress(cdbuffer, (unsigned int*)&size, Zbuf, ssize, 0, 0);
fwrite(cdbuffer, 1, size, f);
p++;
per = ((float)p / s);
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
while (gtk_events_pending()) gtk_main_iteration();
if (stop) break;
}
if (!stop) gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
@ -860,11 +881,15 @@ long CDRconfigure(void)
methodlist = NULL;
for (i = 0; i < 2; i++)
methodlist = g_list_append(methodlist, methods[i]);
Method = lookup_widget(ConfDlg, "GtkCombo_Method");
gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
if (strstr(IsoFile, ".Z") != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
else gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
else
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
gtk_widget_show_all(ConfDlg);
gtk_main();

View File

@ -51,6 +51,7 @@ create_Config (void)
GtkWidget *hbuttonbox3;
GtkWidget *GtkButton_Create;
GtkWidget *GtkButton_CreateZ;
GtkWidget *checkBlockDump;
GtkWidget *hbuttonbox1;
GtkWidget *button1;
GtkWidget *button2;
@ -150,6 +151,10 @@ create_Config (void)
gtk_container_add (GTK_CONTAINER (hbuttonbox3), GtkButton_CreateZ);
GTK_WIDGET_SET_FLAGS (GtkButton_CreateZ, GTK_CAN_DEFAULT);
checkBlockDump = gtk_check_button_new_with_mnemonic (_("Create a dump of the running iso"));
gtk_widget_show (checkBlockDump);
gtk_box_pack_start (GTK_BOX (vbox1), checkBlockDump, FALSE, FALSE, 0);
hbuttonbox1 = gtk_hbutton_box_new ();
gtk_widget_show (hbuttonbox1);
gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, TRUE, TRUE, 0);
@ -211,6 +216,7 @@ create_Config (void)
GLADE_HOOKUP_OBJECT (Config, hbuttonbox3, "hbuttonbox3");
GLADE_HOOKUP_OBJECT (Config, GtkButton_Create, "GtkButton_Create");
GLADE_HOOKUP_OBJECT (Config, GtkButton_CreateZ, "GtkButton_CreateZ");
GLADE_HOOKUP_OBJECT (Config, checkBlockDump, "checkBlockDump");
GLADE_HOOKUP_OBJECT (Config, hbuttonbox1, "hbuttonbox1");
GLADE_HOOKUP_OBJECT (Config, button1, "button1");
GLADE_HOOKUP_OBJECT (Config, button2, "button2");