add half-working CXB support

This commit is contained in:
2022-12-11 17:01:51 -05:00
committed by Hay1tsme
parent 60eddedccf
commit edd85ee818
25 changed files with 1082 additions and 0 deletions

22
cxbio/config.c Normal file
View File

@ -0,0 +1,22 @@
#include <windows.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include "cxbio/config.h"
void cxb_io_config_load(
struct cxb_io_config *cfg,
const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->test = GetPrivateProfileIntW(L"revio", L"test", '1', filename);
cfg->service = GetPrivateProfileIntW(L"revio", L"service", '2', filename);
cfg->coin = GetPrivateProfileIntW(L"revio", L"coin", '3', filename);
cfg->cancel = GetPrivateProfileIntW(L"revio", L"cancel", '4', filename);
cfg->up = GetPrivateProfileIntW(L"revio", L"up", VK_UP, filename);
cfg->down = GetPrivateProfileIntW(L"revio", L"down", VK_DOWN, filename);
}

17
cxbio/config.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
struct cxb_io_config {
uint8_t test;
uint8_t service;
uint8_t coin;
uint8_t cancel;
uint8_t up;
uint8_t down;
};
void cxb_io_config_load(
struct cxb_io_config *cfg,
const wchar_t *filename);

78
cxbio/cxbio.c Normal file
View File

@ -0,0 +1,78 @@
#include <windows.h>
#include <process.h>
#include <stdbool.h>
#include <stdint.h>
#include "cxbio/cxbio.h"
#include "cxbio/config.h"
#include "util/dprintf.h"
static bool cxb_io_coin;
static int cxb_io_coins;
static struct cxb_io_config cxb_io_cfg;
uint16_t cxb_io_get_api_version(void)
{
return 0x0100;
}
HRESULT cxb_io_revio_init(void)
{
dprintf("CXB IO: REVIO init\n");
cxb_io_config_load(&cxb_io_cfg, L".\\segatools.ini");
return S_OK;
}
void cxb_io_revio_poll(uint16_t *opbtn)
{
if (GetAsyncKeyState(cxb_io_cfg.test)) {
*opbtn |= 0x01; /* Test */
}
if (GetAsyncKeyState(cxb_io_cfg.service)) {
*opbtn |= 0x02; /* Service */
}
if (GetAsyncKeyState(cxb_io_cfg.cancel)) {
*opbtn |= 0x04; /* Cancel */
}
if (GetAsyncKeyState(cxb_io_cfg.up)) {
*opbtn |= 0x08; /* Up */
}
if (GetAsyncKeyState(cxb_io_cfg.down)) {
*opbtn |= 0x10; /* Down */
}
}
void cxb_io_revio_get_coins(long *coins)
{
if (GetAsyncKeyState(cxb_io_cfg.coin)) {
if (!cxb_io_coin) {
cxb_io_coin = true;
cxb_io_coins++;
}
} else {
cxb_io_coin = false;
}
*coins = cxb_io_coins;
}
void cxb_io_revio_set_coins(int coins)
{
cxb_io_coins = coins;
}
HRESULT cxb_io_led_init(void)
{
dprintf("CXB IO: LED init\n");
return S_OK;
}
void cxb_io_led_update(int id, int color)
{}

19
cxbio/cxbio.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
uint16_t cxb_io_get_api_version(void);
HRESULT cxb_io_revio_init(void);
void cxb_io_revio_poll(uint16_t *opbtn);
void cxb_io_revio_get_coins(long *coins);
void cxb_io_revio_set_coins(int coins);
HRESULT cxb_io_led_init(void);
void cxb_io_led_update(int id, int color);

13
cxbio/meson.build Normal file
View File

@ -0,0 +1,13 @@
cxbio_lib = static_library(
'cxbio',
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
sources : [
'cxbio.c',
'cxbio.h',
'config.c',
'config.h',
],
)