investigate TAS-ing this

This commit is contained in:
Cadey Ratio 2020-05-07 23:30:08 -04:00
parent c52fdb27f8
commit 5e138304d8
1 changed files with 17 additions and 7 deletions

View File

@ -1,25 +1,35 @@
#include <stdio.h>
#include <ultra64.h>
#include <assert.h>
#include <fcntl.h>
#include "controller_api.h"
static FILE *fp;
static int fd;
static int counter;
#define OFFSET 0x400
static void tas_init(void) {
fp = fopen("cont.m64", "rb");
if (fp != NULL) {
uint8_t buf[0x400];
fread(buf, 1, sizeof(buf), fp);
fd = open("cont.m64", O_RDONLY);
if (fd != 0) {
uint8_t buf[OFFSET];
read(fd, buf, sizeof(buf));
counter = 0;
}
}
static void tas_read(OSContPad *pad) {
if (fp != NULL) {
if (fd != 0) {
uint8_t bytes[4] = {0};
fread(bytes, 1, 4, fp);
int result = read(fd, bytes, 4);
assert(result > 0);
pad->button = (bytes[0] << 8) | bytes[1];
pad->stick_x = bytes[2];
pad->stick_y = bytes[3];
counter+=4;
printf("%x called %04x %d %d\n", (counter + OFFSET), pad->button, bytes[2], bytes[3]);
fflush(stdout);
}
}