1
0
mirror of https://github.com/raphnet/gc_n64_usb-v3 synced 2024-12-21 23:08:53 -05:00

Tool features

This commit is contained in:
Raphael Assenat 2015-10-01 00:02:28 -04:00
parent 2ca06a72b9
commit 05224c5eab
5 changed files with 96 additions and 0 deletions

View File

@ -10,6 +10,7 @@
/* Return many unknown bits, but two are about the expansion port. */
#define N64_GET_CAPABILITIES 0x00
#define N64_RESET 0xFF
#define N64_CAPS_REPLY_LENGTH 24
#define OFFSET_EXT_REMOVED 22

View File

@ -217,3 +217,4 @@ int gcn64_exchange(gcn64_hdl_t hdl, unsigned char *outcmd, int outlen, unsigned
return n;
}

View File

@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "gcn64lib.h"
#include "../requests.h"
#include "hexdump.h"
int gcn64lib_getConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *rx, unsigned char rx_max)
{
@ -75,3 +77,65 @@ int gcn64lib_rawSiCommand(gcn64_hdl_t hdl, unsigned char channel, unsigned char
return rx_len;
}
int gcn64lib_16bit_scan(gcn64_hdl_t hdl, unsigned short min, unsigned short max)
{
int id, n;
unsigned char buf[64];
for (id = min; id<=max; id++) {
buf[0] = id >> 8;
buf[1] = id & 0xff;
n = gcn64lib_rawSiCommand(hdl, 0, buf, 2, buf, sizeof(buf));
if (n > 0) {
printf("CMD 0x%04x answer: ", id);
printHexBuf(buf, n);
}
}
return 0;
}
int gcn64lib_8bit_scan(gcn64_hdl_t hdl, unsigned char min, unsigned char max)
{
int id, n;
unsigned char buf[64];
for (id = min; id<=max; id++) {
buf[0] = id;
n = gcn64lib_rawSiCommand(hdl, 0, buf, 1, buf, sizeof(buf));
if (n > 0) {
printf("CMD 0x%02x answer: ", id);
printHexBuf(buf, n);
}
}
return 0;
}
int gcn64lib_raphnet_gc_to_n64_getInfo(gcn64_hdl_t hdl)
{
unsigned char buf[64];
int n;
buf[0] = 'R';
buf[1] = 0x01; // Get device info
n = gcn64lib_rawSiCommand(hdl, 0, buf, 2, buf, sizeof(buf));
if (n<0)
return n;
if (n > 0) {
printf("gc_to_n64 adapter info: {\n");
printf("\tFirmware version: %s\n", buf+10);
printf("\tDefault mapping id: %d\n", buf[0]);
printf("\tDeadzone enabled: %d\n", buf[1]);
printf("\tOld v1.5 conversion: %d\n", buf[2]);
printf("}\n");
} else {
printf("No answer (old version?)\n");
}
return 0;
}

View File

@ -8,4 +8,8 @@ int gcn64lib_setConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *data
int gcn64lib_getConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *rx, unsigned char rx_max);
int gcn64lib_rawSiCommand(gcn64_hdl_t hdl, unsigned char channel, unsigned char *tx, unsigned char tx_len, unsigned char *rx, unsigned char max_rx);
int gcn64lib_8bit_scan(gcn64_hdl_t hdl, unsigned char min, unsigned char max);
int gcn64lib_16bit_scan(gcn64_hdl_t hdl, unsigned short min, unsigned short max);
int gcn64lib_raphnet_gc_to_n64_getInfo(gcn64_hdl_t hdl);
#endif // _gcn64_lib_h__

View File

@ -62,6 +62,13 @@ static void printUsage(void)
printf(" --n64_getcaps Get N64 controller capabilities (or status such as pak present)\n");
printf(" --n64_mempak_dump Dump N64 mempak contents (Use with --outfile to write to file)\n");
printf(" --n64_mempak_write file Write file to N64 mempak\n");
printf("\n");
printf("GC to N64 adapter commands: (For GC to N64 adapter connected to GC/N64 to USB adapter)\n");
printf(" --gc_to_n64_info Display info on adapter (version, config, etc)\n");
printf("\n");
printf("Development/Experimental/Research commands: (use at your own risk)\n");
printf(" --si_8bit_scan Try all possible 1-byte commands, to see which one a controller responds to.\n");
printf(" --si_16bit_scan Try all possible 2-byte commands, to see which one a controller responds to.\n");
}
@ -79,6 +86,9 @@ static void printUsage(void)
#define OPT_SET_POLL_INTERVAL 308
#define OPT_GET_POLL_INTERVAL 309
#define OPT_N64_MEMPAK_WRITE 310
#define OPT_SI8BIT_SCAN 311
#define OPT_SI16BIT_SCAN 312
#define OPT_GC_TO_N64_INFO 313
struct option longopts[] = {
{ "help", 0, NULL, 'h' },
@ -98,6 +108,9 @@ struct option longopts[] = {
{ "set_poll_rate", 1, NULL, OPT_SET_POLL_INTERVAL },
{ "get_poll_rate", 0, NULL, OPT_GET_POLL_INTERVAL },
{ "n64_mempak_write", 1, NULL, OPT_N64_MEMPAK_WRITE },
{ "si_8bit_scan", 0, NULL, OPT_SI8BIT_SCAN },
{ "si_16bit_scan", 0, NULL, OPT_SI16BIT_SCAN },
{ "gc_to_n64_info", 0, NULL, OPT_GC_TO_N64_INFO },
{ },
};
@ -296,6 +309,7 @@ int main(int argc, char **argv)
case OPT_N64_GETCAPS:
cmd[0] = N64_GET_CAPABILITIES;
//cmd[0] = 0xff;
n = gcn64lib_rawSiCommand(hdl, 0, cmd, 1, cmd, sizeof(cmd));
if (n >= 0) {
printf("N64 Get caps[%d]: ", n);
@ -315,6 +329,18 @@ int main(int argc, char **argv)
printf("Input file: %s\n", optarg);
mempak_writeFromFile(hdl, optarg);
break;
case OPT_SI8BIT_SCAN:
gcn64lib_8bit_scan(hdl, 0, 255);
break;
case OPT_SI16BIT_SCAN:
gcn64lib_16bit_scan(hdl, 0, 0xffff);
break;
case OPT_GC_TO_N64_INFO:
gcn64lib_raphnet_gc_to_n64_getInfo(hdl);
break;
}
if (do_exchange) {