mirror of
https://gitea.tendokyu.moe/TeamTofuShop/taitools.git
synced 2026-09-30 18:57:59 +03:00
127 lines
2.4 KiB
C
127 lines
2.4 KiB
C
#include <windows.h>
|
|
#include <assert.h>
|
|
|
|
#include "jvs/jvs-bus.h"
|
|
#include "idmac/fastio.h"
|
|
#include "board/io3.h"
|
|
|
|
#include "gchook/fastio.h"
|
|
#include "gchook/gc-dll.h"
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
static uint16_t coins;
|
|
static uint16_t services;
|
|
|
|
static void gc_fastio_digital_read(void *ctx, uint32_t *out);
|
|
static void gc_fastio_analog_read(void* ctx, uint8_t num, uint32_t *out);
|
|
static void gc_fastio_coin_read(void *ctx, uint8_t slot_no, uint32_t *out);
|
|
|
|
HRESULT gc_fastio_init(struct fastio_node *out)
|
|
{
|
|
HRESULT hr;
|
|
|
|
assert(out != NULL);
|
|
|
|
out->digital_in = gc_fastio_digital_read;
|
|
out->coins_in = gc_fastio_coin_read;
|
|
out->analog_in = gc_fastio_analog_read;
|
|
|
|
dprintf("Gc Nesica Fastio: Init\n");
|
|
|
|
gc_dll.init();
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
static void gc_fastio_digital_read(void *ctx, uint32_t *out)
|
|
{
|
|
uint8_t btn = 0;
|
|
uint8_t stick = 0;
|
|
*out = 0;
|
|
|
|
assert(gc_dll.get_btns != NULL);
|
|
|
|
gc_dll.get_btns(&btn, &stick);
|
|
|
|
if (btn & BTN_TEST) {
|
|
*out |= GC_SWITCH_SYS_TEST;
|
|
}
|
|
|
|
if (btn & BTN_SERVICE) {
|
|
*out |= GC_SWITCH_SYS_SERVICE;
|
|
}
|
|
|
|
if (btn & BTN_SELECT) {
|
|
*out |= GC_SWITCH_SYS_SELECT;
|
|
}
|
|
|
|
if (btn & BTN_ENTER) {
|
|
*out |= GC_SWITCH_SYS_ENTER;
|
|
}
|
|
|
|
if (btn & BTN_LEFT) {
|
|
*out |= GC_SWITCH_LEFT_BUTTON;
|
|
}
|
|
|
|
if (btn & BTN_RIGHT) {
|
|
*out |= GC_SWITCH_RIGHT_BUTTON;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_UP) {
|
|
*out |= GC_SWITCH_LEFT_UP;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_DOWN) {
|
|
*out |= GC_SWITCH_LEFT_DOWN;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_LEFT) {
|
|
*out |= GC_SWITCH_LEFT_LEFT;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_RIGHT) {
|
|
*out |= GC_SWITCH_LEFT_RIGHT;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_UP) {
|
|
*out |= GC_SWITCH_RIGHT_UP;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_DOWN) {
|
|
*out |= GC_SWITCH_RIGHT_DOWN;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_LEFT) {
|
|
*out |= GC_SWITCH_RIGHT_LEFT;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_RIGHT) {
|
|
*out |= GC_SWITCH_RIGHT_RIGHT;
|
|
}
|
|
}
|
|
|
|
static void gc_fastio_coin_read(void *ctx, uint8_t slot_no, uint32_t *out)
|
|
{
|
|
uint16_t coin = 0;
|
|
uint16_t service = 0;
|
|
|
|
assert(gc_dll.get_btns != NULL);
|
|
|
|
if (slot_no != 1) {
|
|
*out = 0;
|
|
return;
|
|
}
|
|
|
|
gc_dll.read_coin_counter(&coin, &service);
|
|
|
|
*out += coin;
|
|
*out += service;
|
|
}
|
|
|
|
static void gc_fastio_analog_read(void* ctx, uint8_t num, uint32_t *out)
|
|
{
|
|
if (num == 2) { *out = 0xff; }
|
|
else { *out = 0x00; }
|
|
}
|