Add carolhook for Wonderland Wars

This commit is contained in:
2022-12-10 22:01:52 -05:00
committed by Hay1tsme
parent 04ca905467
commit 376dad0bc8
29 changed files with 1296 additions and 1 deletions

79
carolio/carolio.c Normal file
View File

@ -0,0 +1,79 @@
#include <windows.h>
#include <process.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "carolio/carolio.h"
#include "carolio/config.h"
static bool carol_io_coin;
static uint16_t carol_io_coins;
static struct carol_io_config carol_io_cfg;
uint16_t carol_io_get_api_version(void)
{
return 0x0100;
}
HRESULT carol_io_jvs_init(void)
{
carol_io_config_load(&carol_io_cfg, L".\\segatools.ini");
return S_OK;
}
void carol_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out)
{
uint8_t opbtn;
uint8_t gamebtn;
size_t i;
opbtn = 0;
if (GetAsyncKeyState(carol_io_cfg.vk_test) & 0x8000) {
opbtn |= 1;
}
if (GetAsyncKeyState(carol_io_cfg.vk_service) & 0x8000) {
opbtn |= 2;
}
for (i = 0 ; i < _countof(carol_io_cfg.vk_buttons) ; i++) {
if (GetAsyncKeyState(carol_io_cfg.vk_buttons[i]) & 0x8000) {
gamebtn |= 1 << i;
}
}
*opbtn_out = opbtn;
*gamebtn_out = gamebtn;
}
void carol_io_jvs_read_coin_counter(uint16_t *out)
{
if (out == NULL) {
return;
}
if (GetAsyncKeyState(carol_io_cfg.vk_coin) & 0x8000) {
if (!carol_io_coin) {
carol_io_coin = true;
carol_io_coins++;
}
} else {
carol_io_coin = false;
}
*out = carol_io_coins;
}
HRESULT carol_io_touch_init()
{
return S_OK;
}
HRESULT carol_io_controlbd_init()
{
return S_OK;
}

52
carolio/carolio.h Normal file
View File

@ -0,0 +1,52 @@
#pragma once
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
/* Get the version of the Project carol IO API that this DLL supports. This
function should return a positive 16-bit integer, where the high byte is
the major version and the low byte is the minor version (as defined by the
Semantic Versioning standard).
The latest API version as of this writing is 0x0100. */
uint16_t carol_io_get_api_version(void);
/* Initialize JVS-based input. This function will be called before any other
carol_io_jvs_*() function calls. Errors returned from this function will
manifest as a disconnected JVS bus.
All subsequent calls may originate from arbitrary threads and some may
overlap with each other. Ensuring synchronization inside your IO DLL is
your responsibility.
Minimum API version: 0x0100 */
HRESULT carol_io_jvs_init(void);
/* Poll JVS input.
opbtn returns the cabinet test/service state, where bit 0 is Test and Bit 1
is Service.
gamebtn bits, from least significant to most significant, are:
Circle Cross Square Triangle Start UNUSED UNUSED UNUSED
Minimum API version: 0x0100 */
void carol_io_jvs_poll(uint8_t *opbtn, uint8_t *gamebtn);
/* Read the current state of the coin counter. This value should be incremented
for every coin detected by the coin acceptor mechanism. This count does not
need to persist beyond the lifetime of the process.
Minimum API Version: 0x0100 */
void carol_io_jvs_read_coin_counter(uint16_t *out);
HRESULT carol_io_touch_init();
HRESULT carol_io_controlbd_init();

20
carolio/config.c Normal file
View File

@ -0,0 +1,20 @@
#include <windows.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "carolio/config.h"
void carol_io_config_load(
struct carol_io_config *cfg,
const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->vk_test = GetPrivateProfileIntW(L"io3", L"test", '1', filename);
cfg->vk_service = GetPrivateProfileIntW(L"io3", L"service", '2', filename);
cfg->vk_coin = GetPrivateProfileIntW(L"io3", L"coin", '3', filename);
}

16
carolio/config.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
struct carol_io_config {
uint8_t vk_buttons[5];
uint8_t vk_slider[8];
uint8_t vk_test;
uint8_t vk_service;
uint8_t vk_coin;
};
void carol_io_config_load(
struct carol_io_config *cfg,
const wchar_t *filename);

13
carolio/meson.build Normal file
View File

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