diff --git a/tool/gcn64cfg.glade b/tool/gcn64cfg.glade
index a05310d..8b99ee7 100644
--- a/tool/gcn64cfg.glade
+++ b/tool/gcn64cfg.glade
@@ -666,6 +666,7 @@ Author: Raphaël Assénat
True
True
True
+
True
@@ -1056,4 +1057,84 @@ Author: Raphaël Assénat
+
diff --git a/tool/gcn64ctl_gui.c b/tool/gcn64ctl_gui.c
index 0b7a045..979174a 100644
--- a/tool/gcn64ctl_gui.c
+++ b/tool/gcn64ctl_gui.c
@@ -4,8 +4,10 @@
#include
#include "../requests.h"
#include "ihex.h"
-
+#include "mempak.h"
#include "gcn64ctl_gui.h"
+#include "mempak_gcn64usb.h"
+#include "gcn64lib.h"
static void updateGuiFromAdapter(struct application *app);
gboolean rebuild_device_list_store(gpointer data);
@@ -566,6 +568,56 @@ G_MODULE_EXPORT void onFileRescan(GtkWidget *wid, gpointer data)
rebuild_device_list_store(data);
}
+static void mempak_io_progress_cb(int progress, void *ctx)
+{
+ struct application *app = ctx;
+ GET_UI_ELEMENT(GtkProgressBar, mempak_io_progress);
+ gdouble fract;
+
+ fract = progress/MEMPAK_BLOCK_SIZE;
+
+ gtk_progress_bar_set_fraction(mempak_io_progress, progress/((gdouble)MEMPAK_MEM_SIZE));
+ while (gtk_events_pending()) {
+ gtk_main_iteration_do(FALSE);
+ }
+
+}
+
+G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data)
+{
+ struct application *app = data;
+ GET_UI_ELEMENT(GtkWindow, win_mempak_edit);
+ GET_UI_ELEMENT(GtkDialog, mempak_io_dialog);
+ GET_UI_ELEMENT(GtkLabel, mempak_op_label);
+ mempak_structure_t *mpk;
+ int res;
+
+ printf("N64 read mempak\n");
+ if (!app->current_adapter_handle)
+ return;
+
+ gtk_widget_show(GTK_WIDGET(mempak_io_dialog));
+ gtk_label_set_text(mempak_op_label, "Reading memory pack...");
+
+ res = gcn64lib_mempak_download(app->current_adapter_handle, 0, &mpk, mempak_io_progress_cb, app);
+
+ gtk_widget_hide(GTK_WIDGET(mempak_io_dialog));
+ if (res != 0) {
+ switch(res)
+ {
+ case -1: errorPopop(app, "No mempak detected"); break;
+ case -2: errorPopop(app, "I/O error reading mempak"); break;
+ default:
+ case -3: errorPopop(app, "Error reading mempak"); break;
+ }
+ }
+ else {
+ mpke_replaceMpk(app, mpk, NULL);
+ gtk_widget_show(GTK_WIDGET(win_mempak_edit));
+ }
+}
+
+
int
main( int argc,
char **argv )
@@ -597,9 +649,6 @@ main( int argc,
/* Connect signals */
gtk_builder_connect_signals( app.builder, &app );
- /* Destroy builder, since we don't need it anymore */
-// g_object_unref( G_OBJECT( builder ) );
-
/* Show window. All other widgets are automatically shown by GtkBuilder */
gtk_widget_show( GTK_WIDGET(window) );
@@ -610,4 +659,3 @@ main( int argc,
return( 0 );
}
-
diff --git a/tool/gcn64ctl_gui_mpkedit.h b/tool/gcn64ctl_gui_mpkedit.h
index e94795d..1804824 100644
--- a/tool/gcn64ctl_gui_mpkedit.h
+++ b/tool/gcn64ctl_gui_mpkedit.h
@@ -1,10 +1,13 @@
#ifndef gcn64ctl_gui_mpkedit_h__
#define gcn64ctl_gui_mpkedit_h__
+#include "mempak.h"
+
struct mpkedit_data;
struct application;
struct mpkedit_data *mpkedit_new(struct application *app);
void mpkedit_free(struct mpkedit_data *mpke);
+void mpke_replaceMpk(struct application *app, mempak_structure_t *mpk, char *filename);
#endif