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

Add n64 expansion read to lib

This commit is contained in:
Raphael Assenat 2015-11-07 01:35:40 -05:00
parent b49e0e38e4
commit 7e0ed7de50
2 changed files with 22 additions and 6 deletions

View File

@ -218,25 +218,40 @@ int gcn64lib_bootloader(gcn64_hdl_t hdl)
return 0; return 0;
} }
int gcn64lib_n64_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32]) int gcn64lib_n64_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char *data, int len)
{ {
unsigned char cmd[40]; unsigned char cmd[3 + len];
int cmdlen; int cmdlen;
int n; int n;
cmd[0] = N64_EXPANSION_WRITE; cmd[0] = N64_EXPANSION_WRITE;
cmd[1] = addr>>8; // Address high byte cmd[1] = addr>>8; // Address high byte
cmd[2] = addr&0xff; // Address low byte cmd[2] = addr&0xff; // Address low byte
memcpy(cmd + 3, data, 0x20); memcpy(cmd + 3, data, len);
cmdlen = 3 + 0x20; cmdlen = 3 + len;
n = gcn64lib_rawSiCommand(hdl, 0, cmd, cmdlen, cmd, sizeof(cmd)); n = gcn64lib_rawSiCommand(hdl, 0, cmd, cmdlen, cmd, sizeof(cmd));
if (n != 1) { if (n != 1) {
printf("write block returned != 1 (%d)\n", n); printf("expansion write returned != 1 (%d)\n", n);
return -1; return -1;
} }
return cmd[0]; return cmd[0];
} }
int gcn64lib_n64_expansionRead(gcn64_hdl_t hdl, unsigned short addr, unsigned char *dst, int max_len)
{
unsigned char cmd[3];
int n;
cmd[0] = N64_EXPANSION_READ;
cmd[1] = addr>>8; // Address high byte
cmd[2] = addr&0xff; // Address low byte
n = gcn64lib_rawSiCommand(hdl, 0, cmd, 3, dst, max_len);
if (n < 0)
return n;
return n;
}

View File

@ -19,7 +19,8 @@ int gcn64lib_getControllerType(gcn64_hdl_t hdl, int chn);
const char *gcn64lib_controllerName(int type); const char *gcn64lib_controllerName(int type);
int gcn64lib_bootloader(gcn64_hdl_t hdl); int gcn64lib_bootloader(gcn64_hdl_t hdl);
int gcn64lib_n64_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32]); int gcn64lib_n64_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char *data, int len);
int gcn64lib_n64_expansionRead(gcn64_hdl_t hdl, unsigned short addr, unsigned char *dst, int max_len);
int gcn64lib_8bit_scan(gcn64_hdl_t hdl, unsigned char min, unsigned char max); 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_16bit_scan(gcn64_hdl_t hdl, unsigned short min, unsigned short max);