mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-22 07:18:52 -05:00
Tool features
This commit is contained in:
parent
2ca06a72b9
commit
05224c5eab
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
/* Return many unknown bits, but two are about the expansion port. */
|
/* Return many unknown bits, but two are about the expansion port. */
|
||||||
#define N64_GET_CAPABILITIES 0x00
|
#define N64_GET_CAPABILITIES 0x00
|
||||||
|
#define N64_RESET 0xFF
|
||||||
#define N64_CAPS_REPLY_LENGTH 24
|
#define N64_CAPS_REPLY_LENGTH 24
|
||||||
|
|
||||||
#define OFFSET_EXT_REMOVED 22
|
#define OFFSET_EXT_REMOVED 22
|
||||||
|
@ -217,3 +217,4 @@ int gcn64_exchange(gcn64_hdl_t hdl, unsigned char *outcmd, int outlen, unsigned
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "gcn64lib.h"
|
#include "gcn64lib.h"
|
||||||
#include "../requests.h"
|
#include "../requests.h"
|
||||||
|
#include "hexdump.h"
|
||||||
|
|
||||||
int gcn64lib_getConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *rx, unsigned char rx_max)
|
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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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_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_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__
|
#endif // _gcn64_lib_h__
|
||||||
|
26
tool/main.c
26
tool/main.c
@ -62,6 +62,13 @@ static void printUsage(void)
|
|||||||
printf(" --n64_getcaps Get N64 controller capabilities (or status such as pak present)\n");
|
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_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(" --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_SET_POLL_INTERVAL 308
|
||||||
#define OPT_GET_POLL_INTERVAL 309
|
#define OPT_GET_POLL_INTERVAL 309
|
||||||
#define OPT_N64_MEMPAK_WRITE 310
|
#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[] = {
|
struct option longopts[] = {
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
@ -98,6 +108,9 @@ struct option longopts[] = {
|
|||||||
{ "set_poll_rate", 1, NULL, OPT_SET_POLL_INTERVAL },
|
{ "set_poll_rate", 1, NULL, OPT_SET_POLL_INTERVAL },
|
||||||
{ "get_poll_rate", 0, NULL, OPT_GET_POLL_INTERVAL },
|
{ "get_poll_rate", 0, NULL, OPT_GET_POLL_INTERVAL },
|
||||||
{ "n64_mempak_write", 1, NULL, OPT_N64_MEMPAK_WRITE },
|
{ "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:
|
case OPT_N64_GETCAPS:
|
||||||
cmd[0] = N64_GET_CAPABILITIES;
|
cmd[0] = N64_GET_CAPABILITIES;
|
||||||
|
//cmd[0] = 0xff;
|
||||||
n = gcn64lib_rawSiCommand(hdl, 0, cmd, 1, cmd, sizeof(cmd));
|
n = gcn64lib_rawSiCommand(hdl, 0, cmd, 1, cmd, sizeof(cmd));
|
||||||
if (n >= 0) {
|
if (n >= 0) {
|
||||||
printf("N64 Get caps[%d]: ", n);
|
printf("N64 Get caps[%d]: ", n);
|
||||||
@ -315,6 +329,18 @@ int main(int argc, char **argv)
|
|||||||
printf("Input file: %s\n", optarg);
|
printf("Input file: %s\n", optarg);
|
||||||
mempak_writeFromFile(hdl, optarg);
|
mempak_writeFromFile(hdl, optarg);
|
||||||
break;
|
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) {
|
if (do_exchange) {
|
||||||
|
Loading…
Reference in New Issue
Block a user