forked from TeamTofuShop/segatools
add half-working CXB support
This commit is contained in:
61
cxbhook/config.c
Normal file
61
cxbhook/config.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "amex/amex.h"
|
||||
#include "amex/config.h"
|
||||
|
||||
#include "board/config.h"
|
||||
#include "board/sg-reader.h"
|
||||
|
||||
#include "cxbhook/config.h"
|
||||
|
||||
#include "gfxhook/config.h"
|
||||
|
||||
#include "hooklib/config.h"
|
||||
|
||||
#include "platform/config.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
void cxb_dll_config_load(
|
||||
struct cxb_dll_config *cfg,
|
||||
const wchar_t *filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void revio_config_load(struct revio_config *cfg, const wchar_t *filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void network_config_load(struct network_config *cfg, const wchar_t *filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void led_config_load(struct led_config *cfg, const wchar_t *filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cxb_hook_config_load(
|
||||
struct cxb_hook_config *cfg,
|
||||
const wchar_t *filename)
|
||||
{
|
||||
assert(cfg != NULL);
|
||||
assert(filename != NULL);
|
||||
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
|
||||
platform_config_load(&cfg->platform, filename);
|
||||
amex_config_load(&cfg->amex, filename);
|
||||
aime_config_load(&cfg->aime, filename);
|
||||
gfx_config_load(&cfg->gfx, filename);
|
||||
cxb_dll_config_load(&cfg->dll, filename);
|
||||
revio_config_load(&cfg->revio, filename);
|
||||
network_config_load(&cfg->network, filename);
|
||||
led_config_load(&cfg->led, filename);
|
||||
}
|
40
cxbhook/config.h
Normal file
40
cxbhook/config.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "amex/amex.h"
|
||||
|
||||
#include "board/sg-reader.h"
|
||||
|
||||
#include "cxbhook/cxb-dll.h"
|
||||
#include "cxbhook/revio.h"
|
||||
#include "cxbhook/led.h"
|
||||
#include "cxbhook/network.h"
|
||||
|
||||
#include "gfxhook/gfx.h"
|
||||
|
||||
#include "platform/platform.h"
|
||||
|
||||
struct cxb_hook_config {
|
||||
struct platform_config platform;
|
||||
struct amex_config amex;
|
||||
struct aime_config aime;
|
||||
struct gfx_config gfx;
|
||||
struct cxb_dll_config dll;
|
||||
struct revio_config revio;
|
||||
struct network_config network;
|
||||
struct led_config led;
|
||||
};
|
||||
|
||||
void cxb_dll_config_load(
|
||||
struct cxb_dll_config *cfg,
|
||||
const wchar_t *filename);
|
||||
|
||||
void revio_config_load(struct revio_config *cfg, const wchar_t *filename);
|
||||
void network_config_load(struct network_config *cfg, const wchar_t *filename);
|
||||
void led_config_load(struct led_config *cfg, const wchar_t *filename);
|
||||
|
||||
void cxb_hook_config_load(
|
||||
struct cxb_hook_config *cfg,
|
||||
const wchar_t *filename);
|
120
cxbhook/cxb-dll.c
Normal file
120
cxbhook/cxb-dll.c
Normal file
@ -0,0 +1,120 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cxbhook/cxb-dll.h"
|
||||
|
||||
#include "util/dll-bind.h"
|
||||
#include "util/dprintf.h"
|
||||
|
||||
const struct dll_bind_sym cxb_dll_syms[] = {
|
||||
{
|
||||
.sym = "cxb_io_revio_init",
|
||||
.off = offsetof(struct cxb_dll, revio_init),
|
||||
},
|
||||
{
|
||||
.sym = "cxb_io_revio_poll",
|
||||
.off = offsetof(struct cxb_dll, revio_poll),
|
||||
},
|
||||
{
|
||||
.sym = "cxb_io_revio_get_coins",
|
||||
.off = offsetof(struct cxb_dll, revio_get_coins),
|
||||
},
|
||||
{
|
||||
.sym = "cxb_io_revio_set_coins",
|
||||
.off = offsetof(struct cxb_dll, revio_set_coins),
|
||||
},
|
||||
{
|
||||
.sym = "cxb_io_led_init",
|
||||
.off = offsetof(struct cxb_dll, led_init),
|
||||
},
|
||||
{
|
||||
.sym = "cxb_io_led_update",
|
||||
.off = offsetof(struct cxb_dll, led_update),
|
||||
},
|
||||
};
|
||||
|
||||
struct cxb_dll cxb_dll;
|
||||
|
||||
// Copypasta DLL binding and diagnostic message boilerplate.
|
||||
// Not much of this lends itself to being easily factored out. Also there
|
||||
// will be a lot of API-specific branching code here eventually as new API
|
||||
// versions get defined, so even though these functions all look the same
|
||||
// now this won't remain the case forever.
|
||||
|
||||
HRESULT cxb_dll_init(const struct cxb_dll_config *cfg, HINSTANCE self)
|
||||
{
|
||||
uint16_t (*get_api_version)(void);
|
||||
const struct dll_bind_sym *sym;
|
||||
HINSTANCE owned;
|
||||
HINSTANCE src;
|
||||
HRESULT hr;
|
||||
|
||||
assert(cfg != NULL);
|
||||
assert(self != NULL);
|
||||
|
||||
if (cfg->path[0] != L'\0') {
|
||||
owned = LoadLibraryW(cfg->path);
|
||||
|
||||
if (owned == NULL) {
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
dprintf("Crossbeats IO: Failed to load IO DLL: %lx: %S\n",
|
||||
hr,
|
||||
cfg->path);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
dprintf("Crossbeats IO: Using custom IO DLL: %S\n", cfg->path);
|
||||
src = owned;
|
||||
} else {
|
||||
owned = NULL;
|
||||
src = self;
|
||||
}
|
||||
|
||||
get_api_version = (void *) GetProcAddress(src, "cxb_io_get_api_version");
|
||||
|
||||
if (get_api_version != NULL) {
|
||||
cxb_dll.api_version = get_api_version();
|
||||
} else {
|
||||
cxb_dll.api_version = 0x0100;
|
||||
dprintf("Custom IO DLL does not expose cxb_io_get_api_version, "
|
||||
"assuming API version 1.0.\n"
|
||||
"Please ask the developer to update their DLL.\n");
|
||||
}
|
||||
|
||||
if (cxb_dll.api_version >= 0x0200) {
|
||||
hr = E_NOTIMPL;
|
||||
dprintf("Crossbeats IO: Custom IO DLL implements an unsupported "
|
||||
"API version (%#04x). Please update Segatools.\n",
|
||||
cxb_dll.api_version);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
sym = cxb_dll_syms;
|
||||
hr = dll_bind(&cxb_dll, src, &sym, _countof(cxb_dll_syms));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
if (src != self) {
|
||||
dprintf("Crossbeats IO: Custom IO DLL does not provide function "
|
||||
"\"%s\". Please contact your IO DLL's developer for "
|
||||
"further assistance.\n",
|
||||
sym->sym);
|
||||
|
||||
goto end;
|
||||
} else {
|
||||
dprintf("Internal error: could not reflect \"%s\"\n", sym->sym);
|
||||
}
|
||||
}
|
||||
|
||||
owned = NULL;
|
||||
|
||||
end:
|
||||
if (owned != NULL) {
|
||||
FreeLibrary(owned);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
24
cxbhook/cxb-dll.h
Normal file
24
cxbhook/cxb-dll.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cxbio/cxbio.h"
|
||||
|
||||
struct cxb_dll {
|
||||
uint16_t api_version;
|
||||
HRESULT (*revio_init)(void);
|
||||
void (*revio_poll)(uint16_t *opbtn);
|
||||
void (*revio_get_coins)(long *coins);
|
||||
void (*revio_set_coins)(int coins);
|
||||
HRESULT (*led_init)(void);
|
||||
void (*led_update)(int id, int color);
|
||||
};
|
||||
|
||||
struct cxb_dll_config {
|
||||
wchar_t path[MAX_PATH];
|
||||
};
|
||||
|
||||
extern struct cxb_dll cxb_dll;
|
||||
|
||||
HRESULT cxb_dll_init(const struct cxb_dll_config *cfg, HINSTANCE self);
|
21
cxbhook/cxbhook.def
Normal file
21
cxbhook/cxbhook.def
Normal file
@ -0,0 +1,21 @@
|
||||
LIBRARY cxbhook
|
||||
|
||||
EXPORTS
|
||||
Direct3DCreate9
|
||||
aime_io_get_api_version
|
||||
aime_io_init
|
||||
aime_io_led_set_color
|
||||
aime_io_nfc_get_aime_id
|
||||
aime_io_nfc_get_felica_id
|
||||
aime_io_nfc_poll
|
||||
amDllVideoClose @2
|
||||
amDllVideoGetVBiosVersion @4
|
||||
amDllVideoOpen @1
|
||||
amDllVideoSetResolution @3
|
||||
cxb_io_get_api_version
|
||||
cxb_io_revio_init
|
||||
cxb_io_revio_poll
|
||||
cxb_io_revio_get_coins
|
||||
cxb_io_revio_set_coins
|
||||
cxb_io_led_init
|
||||
cxb_io_led_update
|
149
cxbhook/dllmain.c
Normal file
149
cxbhook/dllmain.c
Normal file
@ -0,0 +1,149 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "amex/amex.h"
|
||||
|
||||
#include "board/sg-reader.h"
|
||||
|
||||
#include "cxbhook/config.h"
|
||||
#include "cxbhook/revio.h"
|
||||
#include "cxbhook/led.h"
|
||||
#include "cxbhook/network.h"
|
||||
|
||||
#include "cxbio/cxbio.h"
|
||||
|
||||
#include "gfxhook/gfx.h"
|
||||
#include "gfxhook/d3d9.h"
|
||||
|
||||
#include "hook/process.h"
|
||||
|
||||
#include "hooklib/serial.h"
|
||||
#include "hooklib/spike.h"
|
||||
|
||||
#include "platform/platform.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
static HMODULE cxb_hook_mod;
|
||||
static process_entry_t cxb_startup;
|
||||
static struct cxb_hook_config cxb_hook_cfg;
|
||||
|
||||
static DWORD CALLBACK cxb_pre_startup(void)
|
||||
{
|
||||
HMODULE d3dc;
|
||||
HMODULE dbghelp;
|
||||
HRESULT hr;
|
||||
|
||||
dprintf("--- Begin cxb_pre_startup ---\n");
|
||||
|
||||
/* Pin the D3D shader compiler. This makes startup much faster. */
|
||||
|
||||
d3dc = LoadLibraryW(L"D3DCompiler_43.dll");
|
||||
|
||||
if (d3dc != NULL) {
|
||||
dprintf("Pinned shader compiler, hMod=%p\n", d3dc);
|
||||
} else {
|
||||
dprintf("Failed to load shader compiler!\n");
|
||||
}
|
||||
|
||||
/* Pin dbghelp so the path hooks apply to it. */
|
||||
|
||||
dbghelp = LoadLibraryW(L"dbghelp.dll");
|
||||
|
||||
if (dbghelp != NULL) {
|
||||
dprintf("Pinned debug helper library, hMod=%p\n", dbghelp);
|
||||
} else {
|
||||
dprintf("Failed to load debug helper library!\n");
|
||||
}
|
||||
|
||||
/* Config load */
|
||||
|
||||
cxb_hook_config_load(&cxb_hook_cfg, L".\\segatools.ini");
|
||||
|
||||
/* Hook Win32 APIs */
|
||||
|
||||
gfx_hook_init(&cxb_hook_cfg.gfx);
|
||||
gfx_d3d9_hook_init(&cxb_hook_cfg.gfx, cxb_hook_mod);
|
||||
serial_hook_init();
|
||||
|
||||
/* Initialize emulation hooks */
|
||||
|
||||
hr = platform_hook_init(
|
||||
&cxb_hook_cfg.platform,
|
||||
"SDCA",
|
||||
"AAV1",
|
||||
cxb_hook_mod);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = cxb_dll_init(&cxb_hook_cfg.dll, cxb_hook_mod);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = amex_hook_init(&cxb_hook_cfg.amex, NULL);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = sg_reader_hook_init(&cxb_hook_cfg.aime, 12, cxb_hook_mod);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = revio_hook_init(&cxb_hook_cfg.revio);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = network_hook_init(&cxb_hook_cfg.network);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = led_hook_init(&cxb_hook_cfg.led);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Initialize debug helpers */
|
||||
|
||||
spike_hook_init(L".\\segatools.ini");
|
||||
|
||||
dprintf("--- End cxb_pre_startup ---\n");
|
||||
|
||||
/* Jump to EXE start address */
|
||||
|
||||
return cxb_startup();
|
||||
|
||||
fail:
|
||||
ExitProcess(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (cause != DLL_PROCESS_ATTACH) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cxb_hook_mod = mod;
|
||||
|
||||
hr = process_hijack_startup(cxb_pre_startup, &cxb_startup);
|
||||
|
||||
if (!SUCCEEDED(hr)) {
|
||||
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
||||
}
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
93
cxbhook/led.c
Normal file
93
cxbhook/led.c
Normal file
@ -0,0 +1,93 @@
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cxbhook/led.h"
|
||||
#include "cxbhook/cxb-dll.h"
|
||||
|
||||
#include "hooklib/procaddr.h"
|
||||
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
|
||||
static int my_cCommLamp_Open(char *port);
|
||||
static void my_cCommLamp_Close();
|
||||
static int my_cCommLamp_Setup(int led_id);
|
||||
static int my_cCommLamp_SetColor(int led_id, int color);
|
||||
static int my_cCommLamp_Update();
|
||||
static int my_cCommLamp_UpdateDelta(float delta);
|
||||
|
||||
|
||||
static struct hook_symbol lamp_syms[] = {
|
||||
{
|
||||
.name = "cCommLamp_Open",
|
||||
.patch = my_cCommLamp_Open
|
||||
},
|
||||
{
|
||||
.name = "cCommLamp_Close",
|
||||
.patch = my_cCommLamp_Close
|
||||
},
|
||||
{
|
||||
.name = "cCommLamp_Setup",
|
||||
.patch = my_cCommLamp_Setup,
|
||||
},
|
||||
{
|
||||
.name = "cCommLamp_SetColor",
|
||||
.patch = my_cCommLamp_SetColor
|
||||
},
|
||||
{
|
||||
.name = "cCommLamp_Update",
|
||||
.patch = my_cCommLamp_Update
|
||||
},
|
||||
{
|
||||
.name = "cCommLamp_UpdateDelta",
|
||||
.patch = my_cCommLamp_UpdateDelta
|
||||
},
|
||||
};
|
||||
|
||||
HRESULT led_hook_init(struct led_config *cfg)
|
||||
{
|
||||
dprintf("LED: Init\n");
|
||||
return proc_addr_table_push("CommLamp.dll", lamp_syms, _countof(lamp_syms));
|
||||
}
|
||||
|
||||
static int my_cCommLamp_Open(char *port)
|
||||
{
|
||||
HRESULT hr = cxb_dll.led_init();
|
||||
dprintf("LED: Open %s (DLL init result %lx)\n", port, hr);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void my_cCommLamp_Close()
|
||||
{
|
||||
dprintf("LED: Close\n");
|
||||
}
|
||||
|
||||
static int my_cCommLamp_Setup(int led_id)
|
||||
{
|
||||
dprintf("LED: Setup %d\n", led_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommLamp_SetColor(int led_id, int color)
|
||||
{
|
||||
cxb_dll.led_update(led_id, color);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int my_cCommLamp_Update()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommLamp_UpdateDelta(float delta)
|
||||
{
|
||||
return 0;
|
||||
}
|
11
cxbhook/led.h
Normal file
11
cxbhook/led.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct led_config {
|
||||
bool enable;
|
||||
};
|
||||
|
||||
HRESULT led_hook_init(struct led_config *cfg);
|
36
cxbhook/meson.build
Normal file
36
cxbhook/meson.build
Normal file
@ -0,0 +1,36 @@
|
||||
shared_library(
|
||||
'cxbhook',
|
||||
name_prefix : '',
|
||||
include_directories : inc,
|
||||
implicit_include_directories : false,
|
||||
vs_module_defs : 'cxbhook.def',
|
||||
c_pch : '../precompiled.h',
|
||||
dependencies : [
|
||||
capnhook.get_variable('hook_dep'),
|
||||
capnhook.get_variable('hooklib_dep'),
|
||||
],
|
||||
link_with : [
|
||||
aimeio_lib,
|
||||
amex_lib,
|
||||
board_lib,
|
||||
cxbio_lib,
|
||||
gfxhook_lib,
|
||||
hooklib_lib,
|
||||
jvs_lib,
|
||||
platform_lib,
|
||||
util_lib,
|
||||
],
|
||||
sources : [
|
||||
'cxb-dll.c',
|
||||
'cxb-dll.h',
|
||||
'config.c',
|
||||
'config.h',
|
||||
'dllmain.c',
|
||||
'revio.c',
|
||||
'revio.h',
|
||||
'led.c',
|
||||
'led.h',
|
||||
'network.c',
|
||||
'network.h',
|
||||
],
|
||||
)
|
13
cxbhook/network.c
Normal file
13
cxbhook/network.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cxbhook/network.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
HRESULT network_hook_init(struct network_config *cfg)
|
||||
{
|
||||
dprintf("Network: Init\n");
|
||||
return S_OK;
|
||||
}
|
13
cxbhook/network.h
Normal file
13
cxbhook/network.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct network_config {
|
||||
bool enable;
|
||||
bool disable_ssl;
|
||||
char title_server[PATH_MAX];
|
||||
};
|
||||
|
||||
HRESULT network_hook_init(struct network_config *cfg);
|
226
cxbhook/revio.c
Normal file
226
cxbhook/revio.c
Normal file
@ -0,0 +1,226 @@
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#include "cxbhook/revio.h"
|
||||
#include "cxbhook/cxb-dll.h"
|
||||
|
||||
#include "hooklib/procaddr.h"
|
||||
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
static int my_cCommIo_Open(char *port);
|
||||
static int my_cCommIo_Close();
|
||||
static long my_cCommIo_GetCoin();
|
||||
static int my_cCommIo_SetCoin(int coin_ct);
|
||||
static int my_cCommIo_GetStatus();
|
||||
static int my_cCommIo_GetSwitch();
|
||||
static int my_cCommIo_GetTrigger();
|
||||
static int my_cCommIo_GetRelease();
|
||||
static long my_cCommIo_GetVolume();
|
||||
static int my_cCommIo_SetAmpVolume(int amp_id, long new_volume);
|
||||
static int my_cCommIo_GetAmpVolume(int amp_id);
|
||||
static int my_cCommIo_SetAmpMute(int amp_id, int a2);
|
||||
|
||||
int amp_volume[] = {20, 20, 20};
|
||||
int last_triggers = 0;
|
||||
int last_is_mouse_down = false;
|
||||
|
||||
static struct hook_symbol revio_syms[] = {
|
||||
{
|
||||
.name = "cCommIo_Open",
|
||||
.patch = my_cCommIo_Open
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_Close",
|
||||
.patch = my_cCommIo_Close
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetStatus",
|
||||
.patch = my_cCommIo_GetStatus
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetCoin",
|
||||
.patch = my_cCommIo_GetCoin
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_SetCoin",
|
||||
.patch = my_cCommIo_SetCoin
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetSwitch",
|
||||
.patch = my_cCommIo_GetSwitch
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetTrigger",
|
||||
.patch = my_cCommIo_GetTrigger
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetRelease",
|
||||
.patch = my_cCommIo_GetRelease
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetVolume",
|
||||
.patch = my_cCommIo_GetVolume
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_SetAmpVolume",
|
||||
.patch = my_cCommIo_SetAmpVolume
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_GetAmpVolume",
|
||||
.patch = my_cCommIo_GetAmpVolume
|
||||
},
|
||||
{
|
||||
.name = "cCommIo_SetAmpMute",
|
||||
.patch = my_cCommIo_SetAmpMute
|
||||
},
|
||||
};
|
||||
|
||||
HRESULT revio_hook_init(struct revio_config *cfg)
|
||||
{
|
||||
dprintf("Revio: Init\n");
|
||||
return proc_addr_table_push("CommIo.dll", revio_syms, _countof(revio_syms));
|
||||
}
|
||||
|
||||
static int my_cCommIo_Open(char *port)
|
||||
{
|
||||
dprintf("Revio: Open port %s\n", port);
|
||||
cxb_dll.revio_init();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int my_cCommIo_Close()
|
||||
{
|
||||
dprintf("Revio: Close\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommIo_GetStatus()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static long my_cCommIo_GetCoin()
|
||||
{
|
||||
long coins;
|
||||
cxb_dll.revio_get_coins(&coins);
|
||||
|
||||
return coins;
|
||||
}
|
||||
|
||||
static int my_cCommIo_SetCoin(int coin_ct)
|
||||
{
|
||||
// does some weird shit, not sure
|
||||
//dprintf("Revio: Set coin %d\n", coin_ct);
|
||||
cxb_dll.revio_set_coins(coin_ct);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int my_cCommIo_GetSwitch()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommIo_GetTrigger()
|
||||
{
|
||||
uint16_t btns = 0;
|
||||
int out = 0;
|
||||
|
||||
cxb_dll.revio_poll(&btns);
|
||||
|
||||
if (btns & 0x01) {
|
||||
out |= 1 << 4; // test
|
||||
}
|
||||
|
||||
if (btns & 0x02) {
|
||||
out |= 1 << 5; // service?
|
||||
}
|
||||
|
||||
if (btns & 0x04) {
|
||||
out |= 1 << 1; // up
|
||||
}
|
||||
|
||||
if (btns & 0x08) {
|
||||
out |= 1 << 3; // down
|
||||
}
|
||||
|
||||
if (btns & 0x0F) {
|
||||
out |= 1 << 2; // cancel
|
||||
}
|
||||
|
||||
out &= ~last_triggers;
|
||||
|
||||
dprintf("Revio: GetTrigger %X\n", out);
|
||||
last_triggers = out;
|
||||
return out;
|
||||
}
|
||||
|
||||
static int my_cCommIo_GetRelease()
|
||||
{
|
||||
uint16_t btns = 0;
|
||||
int out = last_triggers;
|
||||
|
||||
cxb_dll.revio_poll(&btns);
|
||||
|
||||
if (btns & 0x01) {
|
||||
out |= 1 << 4; // test
|
||||
}
|
||||
|
||||
if (btns & 0x02) {
|
||||
out |= 1 << 5; // service?
|
||||
}
|
||||
|
||||
if (btns & 0x04) {
|
||||
out |= 1 << 1; // up
|
||||
}
|
||||
|
||||
if (btns & 0x08) {
|
||||
out |= 1 << 3; // down
|
||||
}
|
||||
|
||||
if (btns & 0x0F) {
|
||||
out |= 1 << 2; // cancel
|
||||
}
|
||||
|
||||
out &= ~btns;
|
||||
|
||||
dprintf("Revio: GetRelease %X\n", out);
|
||||
last_triggers = btns;
|
||||
return out;
|
||||
}
|
||||
|
||||
static long my_cCommIo_GetVolume()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommIo_SetAmpVolume(int amp_id, long new_volume)
|
||||
{
|
||||
dprintf("Revio: SetAmpVolume id %d -> vol %ld\n", amp_id, new_volume);
|
||||
if (amp_id > _countof(amp_volume)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
amp_volume[amp_id] = new_volume;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_cCommIo_GetAmpVolume(int amp_id)
|
||||
{
|
||||
dprintf("Revio: GetAmpVolume id %d\n", amp_id);
|
||||
if (amp_id > _countof(amp_volume)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return amp_volume[amp_id];
|
||||
}
|
||||
|
||||
static int my_cCommIo_SetAmpMute(int amp_id, int a2)
|
||||
{
|
||||
dprintf("Revio: GetAmpVolume id %d unknown %d\n", amp_id, a2);
|
||||
return 0;
|
||||
}
|
17
cxbhook/revio.h
Normal file
17
cxbhook/revio.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct revio_config {
|
||||
bool enable;
|
||||
uint8_t test;
|
||||
uint8_t service;
|
||||
uint8_t coin;
|
||||
uint8_t up;
|
||||
uint8_t down;
|
||||
uint8_t cancel;
|
||||
};
|
||||
|
||||
HRESULT revio_hook_init(struct revio_config *cfg);
|
Reference in New Issue
Block a user