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

Add expansionWrite command

This commit is contained in:
Raphael Assenat 2015-11-01 14:12:00 -05:00
parent f09c77689d
commit 4374cd879a
2 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include "gcn64lib.h"
#include "../requests.h"
#include "../gcn64_protocol.h"
#include "hexdump.h"
int gcn64lib_getConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *rx, unsigned char rx_max)
@ -201,3 +202,25 @@ int gcn64lib_bootloader(gcn64_hdl_t hdl)
return 0;
}
int gcn64lib_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32])
{
unsigned char cmd[40];
int cmdlen;
int n;
cmd[0] = N64_EXPANSION_WRITE;
cmd[1] = addr>>8; // Address high byte
cmd[2] = addr&0xff; // Address low byte
memcpy(cmd + 3, data, 0x20);
cmdlen = 3 + 0x20;
n = gcn64lib_rawSiCommand(hdl, 0, cmd, cmdlen, cmd, sizeof(cmd));
if (n != 1) {
printf("write block returned != 1 (%d)\n", n);
return -1;
}
return cmd[0];
}

View File

@ -18,6 +18,8 @@ int gcn64lib_getControllerType(gcn64_hdl_t hdl, int chn);
const char *gcn64lib_controllerName(int type);
int gcn64lib_bootloader(gcn64_hdl_t hdl);
int gcn64lib_n64_expansionWrite(gcn64_hdl_t hdl, unsigned short addr, unsigned char data[32]);
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);