switched to new capnhook, updated unityhook, added LED 15093 to MU3

This commit is contained in:
2024-05-12 19:36:08 +02:00
parent 1069cfee26
commit 517469a60c
27 changed files with 406 additions and 186 deletions

View File

@ -28,6 +28,66 @@ void mu3_dll_config_load(
filename);
}
void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
wchar_t tmpstr[16];
memset(cfg->board_number, ' ', sizeof(cfg->board_number));
memset(cfg->chip_number, ' ', sizeof(cfg->chip_number));
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15093", L"portNo", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename);
GetPrivateProfileStringW(
L"led15093",
L"boardNumber",
L"15093-06",
tmpstr,
_countof(tmpstr),
filename);
size_t n = wcstombs(cfg->board_number, tmpstr, sizeof(cfg->board_number));
for (int i = n; i < sizeof(cfg->board_number); i++)
{
cfg->board_number[i] = ' ';
}
GetPrivateProfileStringW(
L"led15093",
L"chipNumber",
L"6710A",
tmpstr,
_countof(tmpstr),
filename);
n = wcstombs(cfg->chip_number, tmpstr, sizeof(cfg->chip_number));
for (int i = n; i < sizeof(cfg->chip_number); i++)
{
cfg->chip_number[i] = ' ';
}
GetPrivateProfileStringW(
L"led15093",
L"bootChipNumber",
L"6709 ",
tmpstr,
_countof(tmpstr),
filename);
n = wcstombs(cfg->boot_chip_number, tmpstr, sizeof(cfg->boot_chip_number));
for (int i = n; i < sizeof(cfg->boot_chip_number); i++)
{
cfg->boot_chip_number[i] = ' ';
}
}
void mu3_hook_config_load(
struct mu3_hook_config *cfg,
const wchar_t *filename)
@ -40,6 +100,7 @@ void mu3_hook_config_load(
dvd_config_load(&cfg->dvd, filename);
io4_config_load(&cfg->io4, filename);
gfx_config_load(&cfg->gfx, filename);
led15093_config_load(&cfg->led15093, filename);
vfd_config_load(&cfg->vfd, filename);
mu3_dll_config_load(&cfg->dll, filename);
unity_config_load(&cfg->unity, filename);

View File

@ -3,7 +3,7 @@
#include <stddef.h>
#include "board/config.h"
// #include "board/led15093.h"
#include "board/led15093.h"
#include "gfxhook/gfx.h"
@ -21,7 +21,7 @@ struct mu3_hook_config {
struct dvd_config dvd;
struct io4_config io4;
struct gfx_config gfx;
// struct led15093_config led15093;
struct led15093_config led15093;
struct vfd_config vfd;
struct mu3_dll_config dll;
struct unity_config unity;

View File

@ -62,14 +62,18 @@ static DWORD CALLBACK mu3_pre_startup(void)
goto fail;
}
/*
// Does not work, Unity moment
hr = led15093_hook_init(&mu3_hook_cfg.led15093, 3, 1, 1, 2);
hr = mu3_dll_init(&mu3_hook_cfg.dll, mu3_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = led15093_hook_init(&mu3_hook_cfg.led15093,
mu3_dll.led_init, mu3_dll.led_set_leds, 3, 1, 1, 2);
if (FAILED(hr)) {
return hr;
}
*/
hr = sg_reader_hook_init(&mu3_hook_cfg.aime, 1, 1, mu3_hook_mod);
@ -83,12 +87,6 @@ static DWORD CALLBACK mu3_pre_startup(void)
goto fail;
}
hr = mu3_dll_init(&mu3_hook_cfg.dll, mu3_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = mu3_io4_hook_init(&mu3_hook_cfg.io4);
if (FAILED(hr)) {

View File

@ -24,9 +24,28 @@ const struct dll_bind_sym mu3_dll_syms[] = {
}, {
.sym = "mu3_io_get_lever",
.off = offsetof(struct mu3_dll, get_lever),
}, {
.sym = "mu3_io_led_init",
.off = offsetof(struct mu3_dll, led_init),
}, {
.sym = "mu3_io_led_set_colors",
.off = offsetof(struct mu3_dll, led_set_leds),
}
};
/* Helper function to determine upon dll_bind failure whether the required functions were found
NOTE: relies on symbols order declared above */
static HRESULT has_enough_symbols(uint16_t version, uint8_t count)
{
if ( version <= 0x0100 && count == 5 )
return S_OK;
if ( version >= 0x0101 && count == 7 )
return S_OK;
return E_FAIL;
}
struct mu3_dll mu3_dll;
// Copypasta DLL binding and diagnostic message boilerplate.
@ -86,16 +105,25 @@ HRESULT mu3_dll_init(const struct mu3_dll_config *cfg, HINSTANCE self)
}
sym = mu3_dll_syms;
const struct dll_bind_sym *init_sym = &sym[0];
hr = dll_bind(&mu3_dll, src, &sym, _countof(mu3_dll_syms));
if (FAILED(hr)) {
if (src != self) {
dprintf("Ongeki IO: Custom IO DLL does not provide function "
"\"%s\". Please contact your IO DLL's developer for "
"further assistance.\n",
sym->sym);
// Might still be ok depending on external dll API version
int bind_count = sym - init_sym;
if (has_enough_symbols(mu3_dll.api_version, bind_count) == S_OK)
{
hr = S_OK;
} else {
dprintf("Ongeki IO: Custom IO DLL does not provide function "
"\"%s\". Please contact your IO DLL's developer for "
"further assistance.\n",
sym->sym);
goto end;
goto end;
}
} else {
dprintf("Internal error: could not reflect \"%s\"\n", sym->sym);
}

View File

@ -11,6 +11,8 @@ struct mu3_dll {
void (*get_opbtns)(uint8_t *opbtn);
void (*get_gamebtns)(uint8_t *left, uint8_t *right);
void (*get_lever)(int16_t *pos);
HRESULT (*led_init)(void);
void (*led_set_leds)(uint8_t board, uint8_t *rgb);
};
struct mu3_dll_config {

View File

@ -23,3 +23,5 @@ EXPORTS
mu3_io_get_opbtns
mu3_io_init
mu3_io_poll
mu3_io_led_init
mu3_io_led_set_colors