diff --git a/tool/Makefile b/tool/Makefile index 235e484..609278f 100644 --- a/tool/Makefile +++ b/tool/Makefile @@ -25,10 +25,10 @@ PREFIX=/usr/local all: gcn64ctl gcn64ctl_gui -gcn64ctl_gui: gcn64ctl_gui.o gcn64.o gcn64lib.o mempak.o hexdump.o ihex.o $(COMPAT_OBJS) +gcn64ctl_gui: gcn64ctl_gui.o gcn64.o gcn64lib.o mempak_old.o hexdump.o ihex.o $(COMPAT_OBJS) $(LD) $^ $(LDFLAGS) $(GTK_LDFLAGS) -o $@ -gcn64ctl: main.o gcn64.o mempak.o gcn64lib.o hexdump.o gc2n64_adapter.o ihex.o delay.o $(COMPAT_OBJS) +gcn64ctl: main.o gcn64.o mempak_old.o gcn64lib.o hexdump.o gc2n64_adapter.o ihex.o delay.o $(COMPAT_OBJS) $(LD) $^ $(LDFLAGS) -o $@ gcn64ctl_gui.o: gcn64ctl_gui.c diff --git a/tool/main.c b/tool/main.c index f9bbcf7..0d83b8b 100644 --- a/tool/main.c +++ b/tool/main.c @@ -29,7 +29,7 @@ #include "gcn64.h" #include "gcn64lib.h" #include "gc2n64_adapter.h" -#include "mempak.h" +#include "mempak_old.h" #include "../requests.h" #include "../gcn64_protocol.h" diff --git a/tool/mempak.c b/tool/mempak_old.c similarity index 93% rename from tool/mempak.c rename to tool/mempak_old.c index cc818dc..0be28db 100644 --- a/tool/mempak.c +++ b/tool/mempak_old.c @@ -5,7 +5,7 @@ #include "hexdump.h" #include "gcn64.h" #include "gcn64lib.h" -#include "mempak.h" +#include "mempak_old.h" #include "../gcn64_protocol.h" #include "../requests.h" @@ -98,7 +98,7 @@ static uint8_t __calc_data_crc( uint8_t *data ) int mempak_writeBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32]) { - unsigned char cmd[64]; + unsigned char cmd[40]; int cmdlen; int n; uint16_t addr_crc; @@ -140,11 +140,6 @@ int mempak_readBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned char dst[32] return -1; } -// n = gcn64_exchange(hdl, cmd, cmdlen, cmd, sizeof(cmd)); -// if (n != 35) -// return -1; - - //memcpy(dst, cmd + 2, 0x20); memcpy(dst, cmd, 0x20); crc = __calc_data_crc(dst); @@ -162,7 +157,7 @@ int mempak_init(gcn64_hdl_t hdl) int res; memset(buf, 0xfe, 32); - res = mempak_writeBlock(hdl, 0x8001, buf); + res = mempak_readBlock(hdl, 0x8001, buf); if (res == 0xe1) { return 0; @@ -188,22 +183,12 @@ int mempak_writeAll(gcn64_hdl_t hdl, unsigned char srcbuf[0x8000]) return -1; } - printf("\nwrite returned:0x %02x\n", res); - printHexBuf(&srcbuf[addr], res); - - if (0x20 != mempak_readBlock(hdl, addr, readback)) { + // TODO : Why not retry? fprintf(stderr, "readback failed\n"); return -2; } - printf("Wrote: "); - printHexBuf(&srcbuf[addr], 0x20); - - printf("Read: "); - printHexBuf(readback, 0x20); - - break; } printf("\nDone!\n"); @@ -315,9 +300,9 @@ int mempak_writeFromFile(gcn64_hdl_t hdl, const char *in_filename) /* Raw binary images. Those can contain more than one card's data. For * instance, Mupen64 seems to contain four saves. */ - for (i=0; i<4; i++) { + for (i=1; i<=4; i++) { if (file_size == 0x8000*i) { - num_images = i+1; + num_images = i; printf("MPK file Contains %d image(s)\n", num_images); } } diff --git a/tool/mempak.h b/tool/mempak_old.h similarity index 93% rename from tool/mempak.h rename to tool/mempak_old.h index d311a1f..3c9174e 100644 --- a/tool/mempak.h +++ b/tool/mempak_old.h @@ -1,4 +1,6 @@ +// TO BE REMOVED + int mempak_dump(gcn64_hdl_t hdl); int mempak_readBlock(gcn64_hdl_t hdl, unsigned short addr, unsigned char dst[32]); int mempak_dumpToFile(gcn64_hdl_t hdl, const char *out_filename);