mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-22 07:18:52 -05:00
Merge branch 'master' of ssh://git.lan.raphnet.net/raphnet/gc_n64_usb-v3
This commit is contained in:
commit
b6588d9b76
@ -28,8 +28,6 @@ void intervaltimer_set(int interval_ms)
|
||||
|
||||
char intervaltimer_get(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
if (TIFR1 & (1<<OCF1A)) {
|
||||
TIFR1 = 1<<OCF1A;
|
||||
return 1;
|
||||
|
2
main.c
2
main.c
@ -270,7 +270,7 @@ int main(void)
|
||||
gamepad_data pad_data;
|
||||
unsigned char gamepad_vibrate = 0;
|
||||
unsigned char state = STATE_WAIT_POLLTIME;
|
||||
int error_count;
|
||||
int error_count=0;
|
||||
|
||||
hwinit();
|
||||
usart1_init();
|
||||
|
@ -666,6 +666,7 @@ Author: Raphaël Assénat
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="read_n64_pak" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
@ -1056,4 +1057,84 @@ Author: Raphaël Assénat
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkDialog" id="mempak_io_dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="attached_to">win_mempak_edit</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox2">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="dialog-action_area2">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="mempak_io_stop">
|
||||
<property name="label">gtk-stop</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="xalign">0.49000000953674316</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="mempak_io_stop" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="mempak_op_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Mempak operation in progress...</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkProgressBar" id="mempak_io_progress">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="show_text">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -4,8 +4,10 @@
|
||||
#include <string.h>
|
||||
#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 );
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
13
tool/main.c
13
tool/main.c
@ -157,14 +157,9 @@ struct option longopts[] = {
|
||||
{ },
|
||||
};
|
||||
|
||||
static void mempak_read_progress_cb(int addr)
|
||||
static void mempak_progress_cb(int addr, void *ctx)
|
||||
{
|
||||
printf("\rReading address 0x%04x / 0x%04x ", addr, MEMPAK_MEM_SIZE); fflush(stdout);
|
||||
}
|
||||
|
||||
static void mempak_write_progress_cb(int addr)
|
||||
{
|
||||
printf("\rWriting address 0x%04x / 0x%04x ", addr, MEMPAK_MEM_SIZE); fflush(stdout);
|
||||
printf("\r%s 0x%04x / 0x%04x ", (char*)ctx, addr, MEMPAK_MEM_SIZE); fflush(stdout);
|
||||
}
|
||||
|
||||
static int listDevices(void)
|
||||
@ -384,7 +379,7 @@ int main(int argc, char **argv)
|
||||
int res;
|
||||
|
||||
printf("Reading mempak...\n");
|
||||
res = gcn64lib_mempak_download(hdl, 0, &pak, mempak_read_progress_cb);
|
||||
res = gcn64lib_mempak_download(hdl, 0, &pak, mempak_progress_cb, "Reading address");
|
||||
printf("\n");
|
||||
switch (res)
|
||||
{
|
||||
@ -436,7 +431,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
printf("Writing to mempak...\n");
|
||||
res = gcn64lib_mempak_upload(hdl, 0, pak, mempak_write_progress_cb);
|
||||
res = gcn64lib_mempak_upload(hdl, 0, pak, mempak_progress_cb, "Writing address");
|
||||
printf("\n");
|
||||
if (res) {
|
||||
switch(res)
|
||||
|
@ -162,7 +162,7 @@ int gcn64lib_mempak_writeBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned ch
|
||||
* \param progressCb Callback to notify read progress (called after each block)
|
||||
* \return 0: Success, -1: No mempak, -2: IO/error, -3: Other errors
|
||||
*/
|
||||
int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **mempak, void (*progressCb)(int cur_addr))
|
||||
int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **mempak, void (*progressCb)(int cur_addr, void *ctx), void *ctx)
|
||||
{
|
||||
mempak_structure_t *pak;
|
||||
unsigned short addr;
|
||||
@ -189,7 +189,7 @@ int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **
|
||||
return -2;
|
||||
}
|
||||
if (progressCb) {
|
||||
progressCb(addr);
|
||||
progressCb(addr, ctx);
|
||||
}
|
||||
}
|
||||
*mempak = pak;
|
||||
@ -197,7 +197,7 @@ int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gcn64lib_mempak_upload(gcn64_hdl_t hdl, int channel, mempak_structure_t *pak, void (*progressCb)(int cur_addr))
|
||||
int gcn64lib_mempak_upload(gcn64_hdl_t hdl, int channel, mempak_structure_t *pak, void (*progressCb)(int cur_addr, void *ctx), void *ctx)
|
||||
{
|
||||
unsigned short addr;
|
||||
unsigned char readback[0x20];
|
||||
@ -230,7 +230,7 @@ int gcn64lib_mempak_upload(gcn64_hdl_t hdl, int channel, mempak_structure_t *pak
|
||||
}
|
||||
|
||||
if (progressCb) {
|
||||
progressCb(addr);
|
||||
progressCb(addr, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ int gcn64lib_mempak_detect(gcn64_hdl_t hdl);
|
||||
int gcn64lib_mempak_readBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned char dst[32]);
|
||||
int gcn64lib_mempak_writeBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32]);
|
||||
|
||||
int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **mempak, void (*progressCb)(int cur_addr));
|
||||
int gcn64lib_mempak_upload(gcn64_hdl_t hdl, int channel, mempak_structure_t *pak, void (*progressCb)(int cur_addr));
|
||||
int gcn64lib_mempak_download(gcn64_hdl_t hdl, int channel, mempak_structure_t **mempak, void (*progressCb)(int cur_addr, void *ctx), void *ctx);
|
||||
int gcn64lib_mempak_upload(gcn64_hdl_t hdl, int channel, mempak_structure_t *pak, void (*progressCb)(int cur_addr, void *ctx), void *ctx);
|
||||
|
||||
#endif // _mempak_gcn64usb_h__
|
||||
|
Loading…
Reference in New Issue
Block a user