This commit is contained in:
Kay Houwertjes 2024-06-26 01:02:20 +02:00
parent 0111263444
commit 2c8d5784a7
18 changed files with 25 additions and 245 deletions

View File

@ -14,6 +14,7 @@
"platform.h": "c",
"procaddr.h": "c",
"table.h": "c",
"serial.h": "c"
"serial.h": "c",
"sg-reader.h": "c"
},
}

View File

@ -31,6 +31,7 @@
static HMODULE hkb_hook_mod;
static process_entry_t hkb_startup;
static struct hkb_hook_config hkb_hook_cfg;
static struct vfd_config vfd_config;
static DWORD CALLBACK hkb_pre_startup(void)
{
@ -41,6 +42,7 @@ static DWORD CALLBACK hkb_pre_startup(void)
/* Load config */
hkb_hook_config_load(&hkb_hook_cfg, L".\\segatools.ini");
vfd_config_load(&vfd_config, L".\\segatools.ini");
/* Hook Win32 APIs */
@ -77,11 +79,11 @@ static DWORD CALLBACK hkb_pre_startup(void)
if (FAILED(hr)) {
goto fail;
}
hr = sg_reader_hook_init(&hkb_hook_cfg.aime, 1, hkb_hook_mod);
hr = sg_reader_hook_init(&hkb_hook_cfg.aime, 1, 1, hkb_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = vfd_hook_init(4);
hr = vfd_hook_init(&vfd_config, 4);
}
else {
@ -89,11 +91,11 @@ static DWORD CALLBACK hkb_pre_startup(void)
if (FAILED(hr)) {
goto fail;
}
hr = sg_reader_hook_init(&hkb_hook_cfg.aime, 3, hkb_hook_mod);
hr = sg_reader_hook_init(&hkb_hook_cfg.aime, 3, 1, hkb_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = vfd_hook_init(1);
hr = vfd_hook_init(&vfd_config, 1);
}

View File

@ -3,8 +3,6 @@
#include "board/config.h"
#include "gfxhook/config.h"
#include "hooklib/config.h"
#include "hooklib/dvd.h"
@ -28,26 +26,6 @@ void mai2_dll_config_load(
filename);
}
void touch_config_load(
struct touch_config *cfg,
const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"touch", L"enable", 1, filename);
}
void led_config_load(
struct led_config *cfg,
const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"led", L"enable", 1, filename);
}
void mai2_hook_config_load(
struct mai2_hook_config *cfg,
const wchar_t *filename)
@ -59,11 +37,7 @@ void mai2_hook_config_load(
aime_config_load(&cfg->aime, filename);
dvd_config_load(&cfg->dvd, filename);
io4_config_load(&cfg->io4, filename);
gfx_config_load(&cfg->gfx, filename);
mai2_dll_config_load(&cfg->dll, filename);
touch_config_load(&cfg->touch, filename);
led_config_load(&cfg->led, filename);
vfd_config_load(&cfg->vfd, filename);
mai2_dll_config_load(&cfg->dll, filename);
unity_config_load(&cfg->unity, filename);
}
}

View File

@ -4,16 +4,6 @@
#include "board/config.h"
#include "gfxhook/gfx.h"
#include "hooklib/dvd.h"
#include "mai2hook/mai2-dll.h"
#include "mai2hook/touch.h"
#include "mai2hook/led.h"
#include "platform/config.h"
#include "hooklib/dvd.h"
#include "mai2hook/mai2-dll.h"
@ -27,10 +17,6 @@ struct mai2_hook_config {
struct aime_config aime;
struct dvd_config dvd;
struct io4_config io4;
struct gfx_config gfx;
struct mai2_dll_config dll;
struct touch_config touch;
struct led_config led;
struct vfd_config vfd;
struct mai2_dll_config dll;
struct unity_config unity;
@ -42,4 +28,4 @@ void mai2_dll_config_load(
void mai2_hook_config_load(
struct mai2_hook_config *cfg,
const wchar_t *filename);
const wchar_t *filename);

View File

@ -19,26 +19,10 @@
#include <windows.h>
#include <stdlib.h>
#include "board/io4.h"
#include "board/sg-reader.h"
#include "board/vfd.h"
#include "gfxhook/d3d9.h"
#include "gfxhook/d3d11.h"
#include "gfxhook/dxgi.h"
#include "gfxhook/gfx.h"
#include "hook/process.h"
#include "hook/table.h"
#include "hooklib/dvd.h"
#include "hooklib/spike.h"
#include "hooklib/path.h"
#include "hooklib/reg.h"
#include "hook/procaddr.h"
#include "hooklib/serial.h"
#include "hook/process.h"
#include "hook/table.h"
#include "hook/iohook.h"
@ -49,12 +33,6 @@
#include "mai2hook/config.h"
#include "mai2hook/io4.h"
#include "mai2hook/mai2-dll.h"
#include "mai2hook/unity.h"
#include "mai2hook/touch.h"
#include "mai2hook/led.h"
#include "platform/platform.h"
#include "platform/platform.h"
@ -81,10 +59,6 @@ static DWORD CALLBACK mai2_pre_startup(void)
/* Hook Win32 APIs */
dvd_hook_init(&mai2_hook_cfg.dvd, mai2_hook_mod);
gfx_hook_init(&mai2_hook_cfg.gfx);
gfx_d3d9_hook_init(&mai2_hook_cfg.gfx, mai2_hook_mod);
gfx_d3d11_hook_init(&mai2_hook_cfg.gfx, mai2_hook_mod);
gfx_dxgi_hook_init(&mai2_hook_cfg.gfx, mai2_hook_mod);
serial_hook_init();
/* Initialize emulation hooks */
@ -123,26 +97,11 @@ static DWORD CALLBACK mai2_pre_startup(void)
goto fail;
}
// TODO: The handling of the fake registry COM values is extraordinarly lazy
// and I need to make a better method for tacking fake values onto common keys
// that multiple modules may try to use.
hr = led_hook_init(&mai2_hook_cfg.led);
if (FAILED(hr)) {
goto fail;
}
hr = touch_hook_init(&mai2_hook_cfg.touch);
if (FAILED(hr)) {
goto fail;
}
/* Initialize Unity native plugin DLL hooks
There seems to be an issue with other DLL hooks if `LoadLibraryW` is
hooked earlier in the `mai2hook` initialization. */
unity_hook_init(&mai2_hook_cfg.unity, mai2_hook_mod);
/* Initialize debug helpers */
@ -176,4 +135,4 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
}
return SUCCEEDED(hr);
}
}

View File

@ -3,7 +3,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "board/io4.h"
@ -11,9 +10,6 @@
#include "util/dprintf.h"
bool mai2_io_coin = false;
uint16_t mai2_io_coins = 0;
static HRESULT mai2_io4_poll(void *ctx, struct io4_state *state);
static uint16_t coins;
@ -38,14 +34,6 @@ HRESULT mai2_io4_hook_init(const struct io4_config *cfg)
static HRESULT mai2_io4_poll(void *ctx, struct io4_state *state)
{
uint8_t opbtn = 0;
uint8_t player1 = 0;
uint8_t player2 = 0;
HRESULT hr;
assert(mai2_dll.poll != NULL);
hr = mai2_dll.poll(&opbtn, &player1, &player2);
uint8_t opbtn;
uint16_t player1;
uint16_t player2;
@ -78,14 +66,6 @@ static HRESULT mai2_io4_poll(void *ctx, struct io4_state *state)
state->buttons[0] |= IO4_BUTTON_SERVICE;
}
if (opbtn & MAI2_IO_P1_START) {
state->buttons[0] |= 1 << 1;
}
if (opbtn & MAI2_IO_P2_START) {
state->buttons[1] |= 1 << 4;
}
if (opbtn & MAI2_IO_OPBTN_COIN) {
coins++;
}
@ -165,21 +145,9 @@ static HRESULT mai2_io4_poll(void *ctx, struct io4_state *state)
state->buttons[1] |= 1 << 11;
}
if (opbtn & MAI2_IO_OPBTN_COIN) {
if (!mai2_io_coin) {
mai2_io_coin = true;
mai2_io_coins++;
}
}
else {
mai2_io_coin = false;
}
state->chutes[0] = 128 + 256 * mai2_io_coins;
if (player2 & MAI2_IO_GAMEBTN_SELECT) {
state->buttons[1] |= 1 << 4;
}
return S_OK;
}
}

View File

@ -4,4 +4,4 @@
#include "board/io4.h"
HRESULT mai2_io4_hook_init(const struct io4_config *cfg);
HRESULT mai2_io4_hook_init(const struct io4_config *cfg);

View File

@ -15,13 +15,10 @@ const struct dll_bind_sym mai2_dll_syms[] = {
}, {
.sym = "mai2_io_poll",
.off = offsetof(struct mai2_dll, poll),
},
},
{
}, {
.sym = "mai2_io_get_opbtns",
.off = offsetof(struct mai2_dll, get_opbtns),
},
{
}, {
.sym = "mai2_io_get_gamebtns",
.off = offsetof(struct mai2_dll, get_gamebtns),
}
@ -109,4 +106,4 @@ end:
}
return hr;
}
}

View File

@ -18,4 +18,4 @@ struct mai2_dll_config {
extern struct mai2_dll mai2_dll;
HRESULT mai2_dll_init(const struct mai2_dll_config *cfg, HINSTANCE self);
HRESULT mai2_dll_init(const struct mai2_dll_config *cfg, HINSTANCE self);

View File

@ -1,12 +1,6 @@
LIBRARY mai2hook
EXPORTS
CreateDXGIFactory
CreateDXGIFactory1
CreateDXGIFactory2
D3D11CreateDevice
D3D11CreateDeviceAndSwapChain
Direct3DCreate9
aime_io_get_api_version
aime_io_init
aime_io_led_set_color
@ -18,9 +12,7 @@ EXPORTS
amDllVideoOpen @1
amDllVideoSetResolution @3
mai2_io_get_api_version
mai2_io_init
mai2_io_poll
mai2_io_get_gamebtns
mai2_io_get_opbtns
mai2_io_init
mai2_io_poll
mai2_io_poll

View File

@ -8,15 +8,10 @@ shared_library(
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),
xinput_lib,
],
link_with : [
aimeio_lib,
board_lib,
gfxhook_lib,
hooklib_lib,
mai2io_lib,
platform_lib,
hooklib_lib,
mai2io_lib,
platform_lib,
@ -27,15 +22,9 @@ shared_library(
'config.c',
'config.h',
'dllmain.c',
'led.c',
'led.h',
'io4.c',
'io4.h',
'mai2-dll.c',
'mai2-dll.h',
'touch.c',
'touch.h',
'unity.h',
'unity.c',
],
)
)

View File

@ -24,12 +24,6 @@ void mai2_io_config_load(
assert(cfg != NULL);
assert(filename != NULL);
cfg->vk_p1_start = GetPrivateProfileIntW(L"io4", L"p1_start", '1', filename);
cfg->vk_p2_start = GetPrivateProfileIntW(L"io4", L"p2_start", '2', filename);
for (i = 0 ; i < 8 ; i++) {
swprintf_s(key, _countof(key), L"1p_btn%i", i + 1);
cfg->vk_p1_btn[i] = GetPrivateProfileIntW(
cfg->vk_test = GetPrivateProfileIntW(L"io4", L"test", VK_F1, filename);
cfg->vk_service = GetPrivateProfileIntW(L"io4", L"service", VK_F2, filename);
cfg->vk_coin = GetPrivateProfileIntW(L"io4", L"coin", VK_F3, filename);
@ -51,4 +45,4 @@ void mai2_io_config_load(
mai2_io_2p_default[i],
filename);
}
}
}

View File

@ -9,12 +9,10 @@ struct mai2_io_config {
uint8_t vk_test;
uint8_t vk_service;
uint8_t vk_coin;
uint8_t vk_p1_start;
uint8_t vk_p2_start;
uint8_t vk_1p_btn[9];
uint8_t vk_2p_btn[9];
};
void mai2_io_config_load(
struct mai2_io_config *cfg,
const wchar_t *filename);
const wchar_t *filename);

View File

@ -1,5 +1,4 @@
#include <windows.h>
#include <xinput.h>
#include <limits.h>
#include <stdint.h>
@ -7,7 +6,6 @@
#include "mai2io/mai2io.h"
#include "mai2io/config.h"
static struct mai2_io_config mai2_io_cfg;
static uint8_t mai2_opbtn;
static uint16_t mai2_player1_btn;
static uint16_t mai2_player2_btn;
@ -22,70 +20,6 @@ uint16_t mai2_io_get_api_version(void)
HRESULT mai2_io_init(void)
{
mai2_io_config_load(&mai2_io_cfg, L".\\segatools.ini");
return S_OK;
}
HRESULT mai2_io_poll(uint8_t *opbtn, uint8_t *player1, uint8_t *player2)
{
uint8_t opts = 0;
uint8_t p1 = 0;
uint8_t p2 = 0;
if (GetAsyncKeyState(mai2_io_cfg.vk_test) & 0x8000) {
opts |= MAI2_IO_OPBTN_TEST;
}if (GetAsyncKeyState(mai2_io_cfg.vk_service) & 0x8000) {
opts |= MAI2_IO_OPBTN_SERVICE;
}if (GetAsyncKeyState(mai2_io_cfg.vk_coin) & 0x8000) {
opts |= MAI2_IO_OPBTN_COIN;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_start) & 0x8000) {
opts |= MAI2_IO_P1_START;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_start) & 0x8000) {
opts |= MAI2_IO_P2_START;
}
*opbtn = opts;
if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[0]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_1;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[1]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_2;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[2]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_3;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[3]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_4;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[4]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_5;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[5]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_6;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[6]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_7;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p1_btn[7]) & 0x8000) {
p1 |= MAI2_IO_GAMEBTN_8;
}
*player1 = p1;
if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[0]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_1;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[1]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_2;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[2]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_3;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[3]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_4;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[4]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_5;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[5]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_6;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[6]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_7;
}if (GetAsyncKeyState(mai2_io_cfg.vk_p2_btn[7]) & 0x8000) {
p2 |= MAI2_IO_GAMEBTN_8;
}
*player2 = p2;
return S_OK;
}
return S_OK;
}
@ -206,4 +140,4 @@ void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2)
if (player2 != NULL ){
*player2 = mai2_player2_btn;
}
}
}

View File

@ -8,8 +8,6 @@ enum {
MAI2_IO_OPBTN_TEST = 0x01,
MAI2_IO_OPBTN_SERVICE = 0x02,
MAI2_IO_OPBTN_COIN = 0x04,
MAI2_IO_P1_START = 0x08,
MAI2_IO_P2_START = 0x10,
};
enum {
@ -21,9 +19,6 @@ enum {
MAI2_IO_GAMEBTN_6 = 0x20,
MAI2_IO_GAMEBTN_7 = 0x40,
MAI2_IO_GAMEBTN_8 = 0x80,
};
/* Get the version of the Mai2 IO API that this DLL supports. This
MAI2_IO_GAMEBTN_SELECT = 0x100,
};
@ -50,7 +45,6 @@ HRESULT mai2_io_init(void);
Minimum API version: 0x0100 */
HRESULT mai2_io_poll(uint8_t *opbtn, uint8_t *player1, uint8_t *player2);
HRESULT mai2_io_poll(void);
/* Get the state of the cabinet's operator buttons as of the last poll. See
@ -71,4 +65,4 @@ void mai2_io_get_opbtns(uint8_t *opbtn);
Minimum API version: 0x0100 */
void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2);
void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2);

View File

@ -4,13 +4,10 @@ mai2io_lib = static_library(
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],
sources : [
'mai2io.c',
'mai2io.h',
'config.c',
'config.h',
],
)
)

View File

@ -71,7 +71,6 @@ subdir('mai2io')
subdir('cmio')
subdir('mercuryio')
subdir('cxbio')
subdir('mai2io')
subdir('hkbio')
subdir('fgoio')
@ -88,6 +87,5 @@ subdir('mai2hook')
subdir('cmhook')
subdir('mercuryhook')
subdir('cxbhook')
subdir('mai2hook')
subdir('hkbhook')
subdir('fgohook')

View File

@ -214,9 +214,6 @@ static HRESULT nusec_handle_ioctl(struct irp *irp)
case NUSEC_IOCTL_TD_ERASE_USED:
return nusec_ioctl_td_erase_used(irp);
case NUSEC_IOCTL_TD_ERASE_USED:
return nusec_ioctl_td_erase_used(irp);
case NUSEC_IOCTL_ADD_PLAY_COUNT:
return nusec_ioctl_add_play_count(irp);