mai2: update all LED boards to use two boards

pull/60/head
Dniel97 2025-03-02 00:01:45 +01:00
parent a1611afffc
commit 4cb76dd1ee
No known key found for this signature in database
GPG Key ID: DE105D481972329C
43 changed files with 273 additions and 265 deletions

View File

@ -103,19 +103,30 @@ HRESULT led15070_hook_init(
io_led_set_fet_output_t _led_set_fet_output, io_led_set_fet_output_t _led_set_fet_output,
io_led_dc_update_t _led_dc_update, io_led_dc_update_t _led_dc_update,
io_led_gs_update_t _led_gs_update, io_led_gs_update_t _led_gs_update,
unsigned int first_port, unsigned int port_no[2])
unsigned int num_boards)
{ {
unsigned int num_boards = 0;
assert(cfg != NULL); assert(cfg != NULL);
assert(_led_init != NULL);
if (!cfg->enable) { if (!cfg->enable) {
return S_FALSE; return S_FALSE;
} }
if (cfg->port_no != 0) { for (int i = 0; i < led15070_nboards; i++)
first_port = cfg->port_no; {
if (cfg->port_no[i] != 0) {
port_no[i] = cfg->port_no[i];
}
if (port_no[i] != 0) {
num_boards++;
}
} }
assert(num_boards != 0);
led_init = _led_init; led_init = _led_init;
led_set_fet_output = _led_set_fet_output; led_set_fet_output = _led_set_fet_output;
led_dc_update = _led_dc_update; led_dc_update = _led_dc_update;
@ -131,10 +142,7 @@ HRESULT led15070_hook_init(
InitializeCriticalSection(&v->lock); InitializeCriticalSection(&v->lock);
// TODO: IMPROVE! uart_init(&v->boarduart, port_no[i]);
first_port = i == 1 ? first_port + 2 : first_port;
uart_init(&v->boarduart, first_port);
v->boarduart.baud.BaudRate = 115200; v->boarduart.baud.BaudRate = 115200;
v->boarduart.written.bytes = v->written_bytes; v->boarduart.written.bytes = v->written_bytes;
v->boarduart.written.nbytes = sizeof(v->written_bytes); v->boarduart.written.nbytes = sizeof(v->written_bytes);
@ -681,7 +689,7 @@ static HRESULT led15070_req_set_fet_output(int board, const struct led15070_req_
led15070_per_board_vars[board].fet[2] = req->payload[2]; // B or FET2 intensity led15070_per_board_vars[board].fet[2] = req->payload[2]; // B or FET2 intensity
if (led_set_fet_output) if (led_set_fet_output)
led_set_fet_output((const uint8_t*)led15070_per_board_vars[board].fet); led_set_fet_output(board, (const uint8_t*)led15070_per_board_vars[board].fet);
if (!led15070_per_board_vars[board].enable_response) if (!led15070_per_board_vars[board].enable_response)
return S_OK; return S_OK;
@ -737,7 +745,7 @@ static HRESULT led15070_req_dc_update(int board, const struct led15070_req_any *
#endif #endif
if (led_dc_update) if (led_dc_update)
led_dc_update((const uint8_t*)led15070_per_board_vars[board].dc); led_dc_update(board, (const uint8_t*)led15070_per_board_vars[board].dc);
if (!led15070_per_board_vars[board].enable_response) if (!led15070_per_board_vars[board].enable_response)
return S_OK; return S_OK;
@ -764,7 +772,7 @@ static HRESULT led15070_req_gs_update(int board, const struct led15070_req_any *
#endif #endif
if (led_gs_update) if (led_gs_update)
led_gs_update((const uint8_t*)led15070_per_board_vars[board].gs); led_gs_update(board, (const uint8_t*)led15070_per_board_vars[board].gs);
if (!led15070_per_board_vars[board].enable_response) if (!led15070_per_board_vars[board].enable_response)
return S_OK; return S_OK;

View File

@ -7,7 +7,7 @@
struct led15070_config { struct led15070_config {
bool enable; bool enable;
unsigned int port_no; unsigned int port_no[2];
char board_number[8]; char board_number[8];
uint8_t fw_ver; uint8_t fw_ver;
uint16_t fw_sum; uint16_t fw_sum;
@ -15,9 +15,9 @@ struct led15070_config {
}; };
typedef HRESULT (*io_led_init_t)(void); typedef HRESULT (*io_led_init_t)(void);
typedef void (*io_led_set_fet_output_t)(const uint8_t *rgb); typedef void (*io_led_set_fet_output_t)(uint8_t board, const uint8_t *rgb);
typedef void (*io_led_dc_update_t)(const uint8_t *rgb); typedef void (*io_led_dc_update_t)(uint8_t board, const uint8_t *rgb);
typedef void (*io_led_gs_update_t)(const uint8_t *rgb); typedef void (*io_led_gs_update_t)(uint8_t board, const uint8_t *rgb);
HRESULT led15070_hook_init( HRESULT led15070_hook_init(
const struct led15070_config *cfg, const struct led15070_config *cfg,
@ -25,5 +25,4 @@ HRESULT led15070_hook_init(
io_led_set_fet_output_t _led_set_fet_output, io_led_set_fet_output_t _led_set_fet_output,
io_led_dc_update_t _led_dc_update, io_led_dc_update_t _led_dc_update,
io_led_gs_update_t _led_gs_update, io_led_gs_update_t _led_gs_update,
unsigned int first_port, unsigned int port_no[2]);
unsigned int num_boards);

View File

@ -107,9 +107,13 @@ static uint8_t led15093_host_adr = 1;
static io_led_init_t led_init; static io_led_init_t led_init;
static io_led_set_leds_t set_leds; static io_led_set_leds_t set_leds;
HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init, HRESULT led15093_hook_init(
io_led_set_leds_t _set_leds, unsigned int first_port, unsigned int num_boards, uint8_t board_adr, uint8_t host_adr) const struct led15093_config *cfg,
io_led_init_t _led_init,
io_led_set_leds_t _set_leds,
unsigned int port_no[2])
{ {
unsigned int num_boards = 0;
assert(cfg != NULL); assert(cfg != NULL);
assert(_led_init != NULL); assert(_led_init != NULL);
@ -119,14 +123,24 @@ HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led
return S_FALSE; return S_FALSE;
} }
if (cfg->port_no != 0) { for (int i = 0; i < led15093_nboards; i++)
first_port = cfg->port_no; {
if (cfg->port_no[i] != 0) {
port_no[i] = cfg->port_no[i];
}
if (port_no[i] != 0) {
num_boards++;
}
} }
assert(num_boards != 0);
led15093_board_adr = num_boards;
led15093_host_adr = num_boards == 2 ? 1 : 2;
led_init = _led_init; led_init = _led_init;
set_leds = _set_leds; set_leds = _set_leds;
led15093_board_adr = board_adr;
led15093_host_adr = host_adr;
memcpy(led15093_board_num, cfg->board_number, sizeof(led15093_board_num)); memcpy(led15093_board_num, cfg->board_number, sizeof(led15093_board_num));
memcpy(led15093_chip_num, cfg->chip_number, sizeof(led15093_chip_num)); memcpy(led15093_chip_num, cfg->chip_number, sizeof(led15093_chip_num));
@ -140,7 +154,7 @@ HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led
InitializeCriticalSection(&vb->lock); InitializeCriticalSection(&vb->lock);
uart_init(&vb->boarduart, first_port + i); uart_init(&vb->boarduart, port_no[i]);
if (cfg->high_baudrate) { if (cfg->high_baudrate) {
vb->boarduart.baud.BaudRate = 460800; vb->boarduart.baud.BaudRate = 460800;
} else { } else {
@ -209,7 +223,6 @@ static HRESULT led15093_handle_irp_locked(int board, struct irp *irp)
_led15093_per_board_vars *v = &led15093_per_board_vars[board]; _led15093_per_board_vars *v = &led15093_per_board_vars[board];
struct uart *boarduart = &led15093_per_board_vars[board].boarduart; struct uart *boarduart = &led15093_per_board_vars[board].boarduart;
/*
if (irp->op == IRP_OP_OPEN) { if (irp->op == IRP_OP_OPEN) {
// Unfortunately the LED board UART gets opened and closed repeatedly // Unfortunately the LED board UART gets opened and closed repeatedly
@ -236,30 +249,6 @@ static HRESULT led15093_handle_irp_locked(int board, struct irp *irp)
} }
} }
} }
*/
if (irp->op == IRP_OP_OPEN) {
dprintf("LED 15093: Starting backend DLL\n");
// int res = led_init();
hr = led_init();
/*
if (res != 0) {
dprintf("LED 15093: Backend error, LED board disconnected: "
"%d\n",
res);
return E_FAIL;
}
*/
if (FAILED(hr)) {
dprintf("LED 15093: Backend error, LED board disconnected: "
"%x\n",
(int) hr);
return hr;
}
}
hr = uart_handle_irp(boarduart, irp); hr = uart_handle_irp(boarduart, irp);
@ -688,16 +677,6 @@ static HRESULT led15093_req_set_imm_led(int board, const struct led15093_req_set
return E_INVALIDARG; return E_INVALIDARG;
} }
/*
if (board == 0) {
dprintf("board %d: red: %d, green: %d, blue: %d\n", board, req->data[0x96], req->data[0x97], req->data[0x98]);
}
else if (board == 1)
{
dprintf("board %d: red: %d, green: %d, blue: %d\n", board, req->data[0xb4], req->data[0xb5], req->data[0xb6]);
}
*/
// Return the current LED data, remove const qualifier // Return the current LED data, remove const qualifier
set_leds(board, (uint8_t *) req->data); set_leds(board, (uint8_t *) req->data);

View File

@ -8,7 +8,7 @@
struct led15093_config { struct led15093_config {
bool enable; bool enable;
bool high_baudrate; bool high_baudrate;
unsigned int port_no; unsigned int port_no[2];
char board_number[8]; char board_number[8];
char chip_number[5]; char chip_number[5];
char boot_chip_number[5]; char boot_chip_number[5];
@ -20,5 +20,5 @@ typedef HRESULT (*io_led_init_t)(void);
typedef void (*io_led_set_leds_t)(uint8_t board, uint8_t *rgb); typedef void (*io_led_set_leds_t)(uint8_t board, uint8_t *rgb);
HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init, HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init,
io_led_set_leds_t _set_leds, unsigned int first_port, unsigned int num_boards, uint8_t board_adr, uint8_t host_adr); io_led_set_leds_t _set_leds, unsigned int port_no[2]);

View File

@ -56,7 +56,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = 0; cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xadf7, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xadf7, filename);

View File

@ -114,8 +114,9 @@ static DWORD CALLBACK chuni_pre_startup(void)
{ {
dprintf("IO DLL doesn't support led_init/led_set_leds, cannot start LED15093 hook\n"); dprintf("IO DLL doesn't support led_init/led_set_leds, cannot start LED15093 hook\n");
} else { } else {
unsigned int led_port_no[2] = {10, 11};
hr = led15093_hook_init(&chuni_hook_cfg.led15093, hr = led15093_hook_init(&chuni_hook_cfg.led15093,
chuni_dll.led_init, chuni_dll.led_set_leds, 10, 2, 2, 1); chuni_dll.led_init, chuni_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -174,6 +174,20 @@ HRESULT chuni_io_led_init(void)
} }
void chuni_io_led_set_colors(uint8_t board, uint8_t *rgb) void chuni_io_led_set_colors(uint8_t board, uint8_t *rgb)
{ {
#if 0
if (board == 0) {
dprintf("CHUNI LED: Left Air 1: red: %d, green: %d, blue: %d\n", rgb[0x96], rgb[0x97], rgb[0x98]);
dprintf("CHUNI LED: Left Air 2: red: %d, green: %d, blue: %d\n", rgb[0x99], rgb[0x9A], rgb[0x9B]);
dprintf("CHUNI LED: Left Air 3: red: %d, green: %d, blue: %d\n", rgb[0x9C], rgb[0x9D], rgb[0x9E]);
}
else if (board == 1)
{
dprintf("CHUNI LED: Right Air 1: red: %d, green: %d, blue: %d\n", rgb[0xB4], rgb[0xB5], rgb[0xB6]);
dprintf("CHUNI LED: Right Air 2: red: %d, green: %d, blue: %d\n", rgb[0xB7], rgb[0xB8], rgb[0xB9]);
dprintf("CHUNI LED: Right Air 3: red: %d, green: %d, blue: %d\n", rgb[0xBA], rgb[0xBB], rgb[0xBC]);
}
#endif
led_output_update(board, rgb); led_output_update(board, rgb);
} }

View File

@ -96,7 +96,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = 0; cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xadf7, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xadf7, filename);

View File

@ -22,32 +22,23 @@
COM4: 837-15396 "Gen 3" Aime Reader COM4: 837-15396 "Gen 3" Aime Reader
*/ */
#include <windows.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
#include "amex/amex.h" #include "amex/amex.h"
#include "board/sg-reader.h" #include "board/sg-reader.h"
#include "board/vfd.h" #include "board/vfd.h"
#include "chuniio/chuniio.h"
#include "chusanhook/config.h" #include "chusanhook/config.h"
#include "chusanhook/io4.h" #include "chusanhook/io4.h"
#include "chusanhook/slider.h" #include "chusanhook/slider.h"
#include "chuniio/chuniio.h"
#include "hook/process.h"
#include "gfxhook/d3d9.h" #include "gfxhook/d3d9.h"
#include "gfxhook/gfx.h" #include "gfxhook/gfx.h"
#include "hook/process.h"
#include "hooklib/serial.h" #include "hooklib/serial.h"
#include "hooklib/spike.h" #include "hooklib/spike.h"
#include "platform/platform.h" #include "platform/platform.h"
#include "util/dprintf.h" #include "util/dprintf.h"
#include "util/env.h" #include "util/env.h"
@ -55,8 +46,7 @@ static HMODULE chusan_hook_mod;
static process_entry_t chusan_startup; static process_entry_t chusan_startup;
static struct chusan_hook_config chusan_hook_cfg; static struct chusan_hook_config chusan_hook_cfg;
static DWORD CALLBACK chusan_pre_startup(void) static DWORD CALLBACK chusan_pre_startup(void) {
{
HMODULE d3dc; HMODULE d3dc;
HMODULE dbghelp; HMODULE dbghelp;
HRESULT hr; HRESULT hr;
@ -88,7 +78,7 @@ static DWORD CALLBACK chusan_pre_startup(void)
chusan_hook_config_load(&chusan_hook_cfg, get_config_path()); chusan_hook_config_load(&chusan_hook_cfg, get_config_path());
/* Hook Win32 APIs */ /* Hook Win32 APIs */
dvd_hook_init(&chusan_hook_cfg.dvd, chusan_hook_mod); dvd_hook_init(&chusan_hook_cfg.dvd, chusan_hook_mod);
gfx_hook_init(&chusan_hook_cfg.gfx); gfx_hook_init(&chusan_hook_cfg.gfx);
gfx_d3d9_hook_init(&chusan_hook_cfg.gfx, chusan_hook_mod); gfx_d3d9_hook_init(&chusan_hook_cfg.gfx, chusan_hook_mod);
@ -154,19 +144,31 @@ static DWORD CALLBACK chusan_pre_startup(void)
} }
} }
if ( chuni_dll.led_init == NULL || chuni_dll.led_set_leds == NULL ) unsigned int led_port_no[2];
{
dprintf("IO DLL doesn't support led_init/led_set_leds, cannot start LED15093 hook\n"); if (is_cvt) {
led_port_no[0] = 2;
led_port_no[1] = 3;
} else { } else {
hr = led15093_hook_init(&chusan_hook_cfg.led15093, led_port_no[0] = 20;
chuni_dll.led_init, chuni_dll.led_set_leds, first_port, 2, 2, 1); led_port_no[1] = 21;
}
if (chuni_dll.led_init == NULL || chuni_dll.led_set_leds == NULL) {
dprintf(
"IO DLL doesn't support led_init/led_set_leds, cannot start "
"LED15093 hook\n");
} else {
hr = led15093_hook_init(&chusan_hook_cfg.led15093, chuni_dll.led_init,
chuni_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;
} }
} }
hr = sg_reader_hook_init(&chusan_hook_cfg.aime, 4, is_cvt ? 2: 3, chusan_hook_mod); hr = sg_reader_hook_init(&chusan_hook_cfg.aime, 4, is_cvt ? 2 : 3,
chusan_hook_mod);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;
@ -186,8 +188,7 @@ fail:
ExitProcess(EXIT_FAILURE); ExitProcess(EXIT_FAILURE);
} }
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx) BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx) {
{
HRESULT hr; HRESULT hr;
if (cause != DLL_PROCESS_ATTACH) { if (cause != DLL_PROCESS_ATTACH) {
@ -199,7 +200,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
hr = process_hijack_startup(chusan_pre_startup, &chusan_startup); hr = process_hijack_startup(chusan_pre_startup, &chusan_startup);
if (!SUCCEEDED(hr)) { if (!SUCCEEDED(hr)) {
dprintf("Failed to hijack process startup: %x\n", (int) hr); dprintf("Failed to hijack process startup: %x\n", (int)hr);
} }
return SUCCEEDED(hr); return SUCCEEDED(hr);

View File

@ -69,6 +69,15 @@ freeplay=0
; this to 1 on exactly one machine and set this to 0 on all others. ; this to 1 on exactly one machine and set this to 0 on all others.
dipsw1=1 dipsw1=1
; -----------------------------------------------------------------------------
; LED settings
; -----------------------------------------------------------------------------
[led15070]
; Enable emulation of the 837-15070-04 controlled lights, which handle the
; cabinet and button LEDs.
enable=1
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
; Misc. hook settings ; Misc. hook settings
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
@ -145,8 +154,3 @@ p2Enable=1
;p1TouchA2=0x53 ;p1TouchA2=0x53
; ... etc ... ; ... etc ...
;p1TouchE8=0x53 ;p1TouchE8=0x53
[led15070]
; Enable emulation of the 837-15070-02 controlled lights, which handle the
; cabinet and seat LEDs.
enable=1

View File

@ -48,7 +48,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15093", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename);

View File

@ -133,8 +133,9 @@ static DWORD CALLBACK fgo_pre_startup(void)
goto fail; goto fail;
} }
unsigned int led_port_no[2] = {17, 0};
hr = led15093_hook_init(&fgo_hook_cfg.led15093, hr = led15093_hook_init(&fgo_hook_cfg.led15093,
fgo_dll.led_init, fgo_dll.led_set_leds, 17, 1, 1, 2); fgo_dll.led_init, fgo_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -23,7 +23,8 @@ void led15070_config_load(struct led15070_config *cfg, const wchar_t *filename)
wchar_t tmpstr[16]; wchar_t tmpstr[16];
cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15070", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15070", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15070", L"portNo2", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename);
/* TODO: Unknown, no firmware file available */ /* TODO: Unknown, no firmware file available */
cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x0000, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x0000, filename);

View File

@ -94,8 +94,9 @@ static DWORD CALLBACK idac_pre_startup(void)
goto fail; goto fail;
} }
unsigned int led_port_no[2] = {2, 0};
hr = led15070_hook_init(&idac_hook_cfg.led15070, idac_dll.led_init, hr = led15070_hook_init(&idac_hook_cfg.led15070, idac_dll.led_init,
idac_dll.led_set_fet_output, NULL, idac_dll.led_gs_update, 2, 1); idac_dll.led_set_fet_output, NULL, idac_dll.led_gs_update, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -12,9 +12,9 @@ struct idac_dll {
void (*get_shifter)(uint8_t *gear); void (*get_shifter)(uint8_t *gear);
void (*get_analogs)(struct idac_io_analog_state *out); void (*get_analogs)(struct idac_io_analog_state *out);
HRESULT (*led_init)(void); HRESULT (*led_init)(void);
void (*led_set_fet_output)(const uint8_t *rgb); void (*led_set_fet_output)(uint8_t board, const uint8_t *rgb);
void (*led_gs_update)(const uint8_t *rgb); void (*led_gs_update)(uint8_t board, const uint8_t *rgb);
void (*led_set_leds)(const uint8_t *rgb); void (*led_set_leds)(uint8_t board, const uint8_t *rgb);
HRESULT (*ffb_init)(void); HRESULT (*ffb_init)(void);
void (*ffb_toggle)(bool active); void (*ffb_toggle)(bool active);
void (*ffb_constant_force)(uint8_t direction, uint8_t force); void (*ffb_constant_force)(uint8_t direction, uint8_t force);

View File

@ -159,7 +159,7 @@ static HRESULT idac_io4_write_gpio(uint8_t* payload, size_t len)
lights_data & IDAC_IO_LED_LEFT ? 0xFF : 0x00, lights_data & IDAC_IO_LED_LEFT ? 0xFF : 0x00,
}; };
idac_dll.led_set_leds(rgb_out); idac_dll.led_set_leds(0, rgb_out);
return S_OK; return S_OK;
} }

View File

@ -127,7 +127,7 @@ HRESULT idac_io_led_init(void)
return S_OK; return S_OK;
} }
void idac_io_led_set_fet_output(const uint8_t *rgb) void idac_io_led_set_fet_output(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("IDAC LED: LEFT SEAT LED: %02X\n", rgb[0]); dprintf("IDAC LED: LEFT SEAT LED: %02X\n", rgb[0]);
@ -137,7 +137,7 @@ void idac_io_led_set_fet_output(const uint8_t *rgb)
return; return;
} }
void idac_io_led_gs_update(const uint8_t *rgb) void idac_io_led_gs_update(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
@ -149,7 +149,7 @@ void idac_io_led_gs_update(const uint8_t *rgb)
return; return;
} }
void idac_io_led_set_leds(const uint8_t *rgb) void idac_io_led_set_leds(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("IDAC LED: START: %02X\n", rgb[0]); dprintf("IDAC LED: START: %02X\n", rgb[0]);

View File

@ -127,7 +127,7 @@ HRESULT idac_io_led_init(void);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idac_io_led_set_fet_output(const uint8_t *rgb); void idac_io_led_set_fet_output(uint8_t board, const uint8_t *rgb);
/* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes. /* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes.
@ -144,7 +144,7 @@ void idac_io_led_set_fet_output(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idac_io_led_gs_update(const uint8_t *rgb); void idac_io_led_gs_update(uint8_t board, const uint8_t *rgb);
/* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes. /* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes.
@ -160,7 +160,7 @@ void idac_io_led_gs_update(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idac_io_led_set_leds(const uint8_t *rgb); void idac_io_led_set_leds(uint8_t board, const uint8_t *rgb);
/* Initialize FFB emulation. This function will be called before any /* Initialize FFB emulation. This function will be called before any
other idac_io_ffb_*() function calls. other idac_io_ffb_*() function calls.

View File

@ -27,7 +27,8 @@ void led15070_config_load(struct led15070_config *cfg, const wchar_t *filename)
wchar_t tmpstr[16]; wchar_t tmpstr[16];
cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15070", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15070", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15070", L"portNo2", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename);
/* TODO: Unknown, no firmware file available */ /* TODO: Unknown, no firmware file available */
cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x0000, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x0000, filename);

View File

@ -128,8 +128,9 @@ static DWORD CALLBACK idz_pre_startup(void)
goto fail; goto fail;
} }
unsigned int led_port_no[2] = {11, 0};
hr = led15070_hook_init(&idz_hook_cfg.led15070, idz_dll.led_init, hr = led15070_hook_init(&idz_hook_cfg.led15070, idz_dll.led_init,
idz_dll.led_set_fet_output, NULL, idz_dll.led_gs_update, 11, 1); idz_dll.led_set_fet_output, NULL, idz_dll.led_gs_update, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -12,9 +12,9 @@ struct idz_dll {
void (*jvs_read_shifter)(uint8_t *gear); void (*jvs_read_shifter)(uint8_t *gear);
void (*jvs_read_coin_counter)(uint16_t *total); void (*jvs_read_coin_counter)(uint16_t *total);
HRESULT (*led_init)(void); HRESULT (*led_init)(void);
void (*led_set_fet_output)(const uint8_t *rgb); void (*led_set_fet_output)(uint8_t board, const uint8_t *rgb);
void (*led_gs_update)(const uint8_t *rgb); void (*led_gs_update)(uint8_t board, const uint8_t *rgb);
void (*led_set_leds)(const uint8_t *rgb); void (*led_set_leds)(uint8_t board, const uint8_t *rgb);
HRESULT (*ffb_init)(void); HRESULT (*ffb_init)(void);
void (*ffb_toggle)(bool active); void (*ffb_toggle)(bool active);
void (*ffb_constant_force)(uint8_t direction, uint8_t force); void (*ffb_constant_force)(uint8_t direction, uint8_t force);

View File

@ -192,5 +192,5 @@ static void idz_jvs_write_gpio(void *ctx, uint32_t state)
state & IDZ_IO_LED_LEFT ? 0xFF : 0x00, state & IDZ_IO_LED_LEFT ? 0xFF : 0x00,
}; };
idz_dll.led_set_leds(rgb_out); idz_dll.led_set_leds(0, rgb_out);
} }

View File

@ -130,7 +130,7 @@ HRESULT idz_io_led_init(void)
return S_OK; return S_OK;
} }
void idz_io_led_set_fet_output(const uint8_t *rgb) void idz_io_led_set_fet_output(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("IDZ LED: LEFT SEAT LED: %02X\n", rgb[0]); dprintf("IDZ LED: LEFT SEAT LED: %02X\n", rgb[0]);
@ -140,7 +140,7 @@ void idz_io_led_set_fet_output(const uint8_t *rgb)
return; return;
} }
void idz_io_led_gs_update(const uint8_t *rgb) void idz_io_led_gs_update(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
@ -152,7 +152,7 @@ void idz_io_led_gs_update(const uint8_t *rgb)
return; return;
} }
void idz_io_led_set_leds(const uint8_t *rgb) void idz_io_led_set_leds(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("IDZ LED: START: %02X\n", rgb[0]); dprintf("IDZ LED: START: %02X\n", rgb[0]);

View File

@ -138,7 +138,7 @@ HRESULT idz_io_led_init(void);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idz_io_led_set_fet_output(const uint8_t *rgb); void idz_io_led_set_fet_output(uint8_t board, const uint8_t *rgb);
/* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes. /* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes.
@ -155,7 +155,7 @@ void idz_io_led_set_fet_output(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idz_io_led_gs_update(const uint8_t *rgb); void idz_io_led_gs_update(uint8_t board, const uint8_t *rgb);
/* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes. /* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes.
@ -171,7 +171,7 @@ void idz_io_led_gs_update(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void idz_io_led_set_leds(const uint8_t *rgb); void idz_io_led_set_leds(uint8_t board, const uint8_t *rgb);
/* Initialize FFB emulation. This function will be called before any /* Initialize FFB emulation. This function will be called before any
other idz_io_ffb_*() function calls. other idz_io_ffb_*() function calls.

View File

@ -65,7 +65,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15093", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 1, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename);

View File

@ -1,28 +1,21 @@
#include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
#include "board/io4.h" #include "board/io4.h"
#include "board/sg-reader.h" #include "board/sg-reader.h"
#include "board/vfd.h" #include "board/vfd.h"
#include "hook/iohook.h"
#include "hook/process.h" #include "hook/process.h"
#include "hook/table.h" #include "hook/table.h"
#include "hook/iohook.h"
#include "hooklib/printer.h" #include "hooklib/printer.h"
#include "hooklib/serial.h" #include "hooklib/serial.h"
#include "hooklib/spike.h" #include "hooklib/spike.h"
#include "kemonohook/config.h" #include "kemonohook/config.h"
#include "kemonohook/hooks.h" #include "kemonohook/hooks.h"
#include "kemonohook/jvs.h" #include "kemonohook/jvs.h"
#include "kemonohook/kemono-dll.h" #include "kemonohook/kemono-dll.h"
#include "platform/platform.h" #include "platform/platform.h"
#include "unityhook/hook.h" #include "unityhook/hook.h"
#include "util/dprintf.h" #include "util/dprintf.h"
#include "util/env.h" #include "util/env.h"
@ -47,29 +40,38 @@ static DWORD CALLBACK kemono_pre_startup(void) {
// 2.02 does not call printer update functions // 2.02 does not call printer update functions
uint16_t ret; uint16_t ret;
fwdlusb_updateFirmware_main(1, "UnityApp\\Parade_Data\\StreamingAssets\\Printer\\E0223100-014E-C300-MAINAPP.BIN", &ret); fwdlusb_updateFirmware_main(
if (ret != 0){ 1,
"UnityApp\\Parade_Data\\StreamingAssets\\Printer\\E0223100-014E-C300-"
"MAINAPP.BIN",
&ret);
if (ret != 0) {
goto fail; goto fail;
} }
fwdlusb_updateFirmware_dsp(2, "UnityApp\\Parade_Data\\StreamingAssets\\Printer\\E0223200-0101-C300-DSPAPP.BIN", &ret); fwdlusb_updateFirmware_dsp(
if (ret != 0){ 2,
"UnityApp\\Parade_Data\\StreamingAssets\\Printer\\E0223200-0101-C300-"
"DSPAPP.BIN",
&ret);
if (ret != 0) {
goto fail; goto fail;
} }
fwdlusb_updateFirmware_param(3, "UnityApp\\Parade_Data\\StreamingAssets\\Printer\\D0460700-0101-C300-PARAM.BIN", &ret); fwdlusb_updateFirmware_param(
if (ret != 0){ 3,
"UnityApp\\Parade_Data\\StreamingAssets\\Printer\\D0460700-0101-C300-"
"PARAM.BIN",
&ret);
if (ret != 0) {
goto fail; goto fail;
} }
printer_hook_init(&kemono_hook_cfg.printer, 0, kemono_hook_mod); printer_hook_init(&kemono_hook_cfg.printer, 0, kemono_hook_mod);
printer_set_dimensions(720, 1028); // printer doesn't call setimageformat printer_set_dimensions(720, 1028); // printer doesn't call setimageformat
/* Initialize emulation hooks */ /* Initialize emulation hooks */
hr = platform_hook_init( hr = platform_hook_init(&kemono_hook_cfg.platform, "SDFL", "AAW1",
&kemono_hook_cfg.platform, kemono_hook_mod);
"SDFL",
"AAW1",
kemono_hook_mod);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;
@ -93,7 +95,9 @@ static DWORD CALLBACK kemono_pre_startup(void) {
goto fail; goto fail;
} }
hr = led15093_hook_init(&kemono_hook_cfg.led15093, kemono_dll.led_init, kemono_dll.led_set_leds, 10, 1, 1, 2); unsigned int led_port_no[2] = {10, 0};
hr = led15093_hook_init(&kemono_hook_cfg.led15093, kemono_dll.led_init,
kemono_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;
@ -106,7 +110,8 @@ static DWORD CALLBACK kemono_pre_startup(void) {
There seems to be an issue with other DLL hooks if `LoadLibraryW` is There seems to be an issue with other DLL hooks if `LoadLibraryW` is
hooked earlier in the `kemonohook` initialization. */ hooked earlier in the `kemonohook` initialization. */
unity_hook_init(&kemono_hook_cfg.unity, kemono_hook_mod, kemono_extra_hooks_load); unity_hook_init(&kemono_hook_cfg.unity, kemono_hook_mod,
kemono_extra_hooks_load);
/* Initialize debug helpers */ /* Initialize debug helpers */
@ -118,7 +123,7 @@ static DWORD CALLBACK kemono_pre_startup(void) {
return kemono_startup(); return kemono_startup();
fail: fail:
ExitProcess(EXIT_FAILURE); ExitProcess(EXIT_FAILURE);
} }
@ -134,7 +139,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx) {
hr = process_hijack_startup(kemono_pre_startup, &kemono_startup); hr = process_hijack_startup(kemono_pre_startup, &kemono_startup);
if (!SUCCEEDED(hr)) { if (!SUCCEEDED(hr)) {
dprintf("Failed to hijack process startup: %x\n", (int) hr); dprintf("Failed to hijack process startup: %x\n", (int)hr);
} }
return SUCCEEDED(hr); return SUCCEEDED(hr);

View File

@ -46,7 +46,8 @@ void led15070_config_load(struct led15070_config *cfg, const wchar_t *filename)
wchar_t tmpstr[16]; wchar_t tmpstr[16];
cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15070", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15070", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15070", L"portNo2", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x00, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x00, filename);

View File

@ -93,12 +93,13 @@ static DWORD CALLBACK mai2_pre_startup(void)
} }
// LED board uses COM21 and COM23 // LED board uses COM21 and COM23
unsigned int led_port_no[2] = {21, 23};
hr = led15070_hook_init(&mai2_hook_cfg.led15070, hr = led15070_hook_init(&mai2_hook_cfg.led15070,
mai2_dll.led_init, mai2_dll.led_init,
mai2_dll.led_set_fet_output, mai2_dll.led_set_fet_output,
mai2_dll.led_dc_update, mai2_dll.led_dc_update,
mai2_dll.led_gs_update, mai2_dll.led_gs_update,
21, 2); led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -14,9 +14,9 @@ struct mai2_dll {
void (*touch_set_sens)(uint8_t *bytes); void (*touch_set_sens)(uint8_t *bytes);
void (*touch_update)(bool player1, bool player2); void (*touch_update)(bool player1, bool player2);
HRESULT (*led_init)(void); HRESULT (*led_init)(void);
void (*led_set_fet_output)(const uint8_t *rgb); void (*led_set_fet_output)(uint8_t board, const uint8_t *rgb);
void (*led_dc_update)(const uint8_t *rgb); void (*led_dc_update)(uint8_t board, const uint8_t *rgb);
void (*led_gs_update)(const uint8_t *rgb); void (*led_gs_update)(uint8_t board, const uint8_t *rgb);
}; };
struct mai2_dll_config { struct mai2_dll_config {

View File

@ -1,5 +1,16 @@
#include <assert.h>
#include <stdlib.h>
#include "hooklib/fdshark.h"
#include "hooklib/reg.h"
#include "mai2hook/mai2-dll.h"
#include "mai2hook/touch.h" #include "mai2hook/touch.h"
#include "util/dprintf.h"
#include "util/dump.h"
static HRESULT read_reg_touch_1p(void *bytes, uint32_t *nbytes) static HRESULT read_reg_touch_1p(void *bytes, uint32_t *nbytes)
{ {
return reg_hook_read_wstr(bytes, nbytes, L"COM3"); return reg_hook_read_wstr(bytes, nbytes, L"COM3");
@ -83,7 +94,7 @@ HRESULT touch_hook_init(const struct touch_config *cfg)
if (cfg->enable_2p) if (cfg->enable_2p)
{ {
dprintf("Mai2 touch port 2P: Init.\n"); dprintf("Mai2 touch 2P: Init.\n");
InitializeCriticalSection(&touch_2p_lock); InitializeCriticalSection(&touch_2p_lock);
uart_init(&touch_2p_uart, 4); uart_init(&touch_2p_uart, 4);
@ -245,4 +256,4 @@ static void touch_auto_scan(const uint8_t player, const uint8_t state[7])
memcpy(&touch_uart->readable.bytes[1], state, 7); memcpy(&touch_uart->readable.bytes[1], state, 7);
touch_uart->readable.bytes[8] = res_end; touch_uart->readable.bytes[8] = res_end;
touch_uart->readable.pos = 9; touch_uart->readable.pos = 9;
} }

View File

@ -1,15 +1,10 @@
#pragma once #pragma once
#include <assert.h>
#include <windows.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <windows.h>
#include "hooklib/fdshark.h"
#include "hooklib/reg.h"
#include "hooklib/uart.h" #include "hooklib/uart.h"
#include "mai2hook/mai2-dll.h"
#include "util/dprintf.h"
#include "util/dump.h"
struct touch_config struct touch_config
{ {
@ -40,4 +35,4 @@ static HRESULT touch_handle_irp_locked(struct irp *irp, struct uart *uart);
/* Called in mai2io to send touch data. /* Called in mai2io to send touch data.
Similar to chuni slider_res_auto_scan, but the host does not require periodic updates. Similar to chuni slider_res_auto_scan, but the host does not require periodic updates.
Touch data is sent only when there is a change. */ Touch data is sent only when there is a change. */
static void touch_auto_scan(const uint8_t player, const uint8_t state[7]); static void touch_auto_scan(const uint8_t player, const uint8_t state[7]);

View File

@ -1,9 +1,11 @@
#include <process.h>
#include <limits.h>
#include "mai2io/mai2io.h" #include "mai2io/mai2io.h"
#include "mai2io/config.h"
#include <limits.h>
#include <process.h>
#include "mai2hook/touch.h" #include "mai2hook/touch.h"
#include "mai2io/config.h"
#include "util/dprintf.h"
#include "util/env.h" #include "util/env.h"
static uint8_t mai2_opbtn; static uint8_t mai2_opbtn;
@ -17,20 +19,15 @@ static bool mai2_io_touch_1p_stop_flag;
static HANDLE mai2_io_touch_2p_thread; static HANDLE mai2_io_touch_2p_thread;
static bool mai2_io_touch_2p_stop_flag; static bool mai2_io_touch_2p_stop_flag;
uint16_t mai2_io_get_api_version(void) uint16_t mai2_io_get_api_version(void) { return 0x0101; }
{
return 0x0101;
}
HRESULT mai2_io_init(void) HRESULT mai2_io_init(void) {
{
mai2_io_config_load(&mai2_io_cfg, get_config_path()); mai2_io_config_load(&mai2_io_cfg, get_config_path());
return S_OK; return S_OK;
} }
HRESULT mai2_io_poll(void) HRESULT mai2_io_poll(void) {
{
mai2_opbtn = 0; mai2_opbtn = 0;
mai2_player1_btn = 0; mai2_player1_btn = 0;
mai2_player2_btn = 0; mai2_player2_btn = 0;
@ -51,12 +48,13 @@ HRESULT mai2_io_poll(void)
} else { } else {
mai2_io_coin = false; mai2_io_coin = false;
} }
// If sinmai has enabled DebugInput, there is no need to input buttons through hook amdaemon. // If sinmai has enabled DebugInput, there is no need to input buttons
// through hook amdaemon.
if (!mai2_io_cfg.vk_btn_enable) { if (!mai2_io_cfg.vk_btn_enable) {
return S_OK; return S_OK;
} }
//Player 1 // Player 1
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[0])) { if (GetAsyncKeyState(mai2_io_cfg.vk_1p_btn[0])) {
mai2_player1_btn |= MAI2_IO_GAMEBTN_1; mai2_player1_btn |= MAI2_IO_GAMEBTN_1;
} }
@ -93,7 +91,7 @@ HRESULT mai2_io_poll(void)
mai2_player1_btn |= MAI2_IO_GAMEBTN_SELECT; mai2_player1_btn |= MAI2_IO_GAMEBTN_SELECT;
} }
//Player 2 // Player 2
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[0])) { if (GetAsyncKeyState(mai2_io_cfg.vk_2p_btn[0])) {
mai2_player2_btn |= MAI2_IO_GAMEBTN_1; mai2_player2_btn |= MAI2_IO_GAMEBTN_1;
} }
@ -133,54 +131,40 @@ HRESULT mai2_io_poll(void)
return S_OK; return S_OK;
} }
void mai2_io_get_opbtns(uint8_t *opbtn) void mai2_io_get_opbtns(uint8_t *opbtn) {
{
if (opbtn != NULL) { if (opbtn != NULL) {
*opbtn = mai2_opbtn; *opbtn = mai2_opbtn;
} }
} }
void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2) void mai2_io_get_gamebtns(uint16_t *player1, uint16_t *player2) {
{
if (player1 != NULL) { if (player1 != NULL) {
*player1 = mai2_player1_btn; *player1 = mai2_player1_btn;
} }
if (player2 != NULL ){ if (player2 != NULL) {
*player2 = mai2_player2_btn; *player2 = mai2_player2_btn;
} }
} }
HRESULT mai2_io_touch_init(mai2_io_touch_callback_t callback) HRESULT mai2_io_touch_init(mai2_io_touch_callback_t callback) {
{
_callback = callback; _callback = callback;
return S_OK; return S_OK;
} }
void mai2_io_touch_set_sens(uint8_t *bytes) void mai2_io_touch_set_sens(uint8_t *bytes) {
{
#if 0 #if 0
dprintf("Mai2 touch side %c: set sensor %s sensitivity to %d\n", bytes[1], sensor_to_str(bytes[2]), bytes[4]); dprintf("Mai2 touch side %c: set sensor %s sensitivity to %d\n", bytes[1], sensor_to_str(bytes[2]), bytes[4]);
#endif #endif
return; return;
} }
void mai2_io_touch_update(bool player1, bool player2) void mai2_io_touch_update(bool player1, bool player2) {
{ if (mai2_io_cfg.debug_input_1p) {
if (mai2_io_cfg.debug_input_1p) if (player1 && mai2_io_touch_1p_thread == NULL) {
{
if (player1 && mai2_io_touch_1p_thread == NULL)
{
mai2_io_touch_1p_thread = (HANDLE)_beginthreadex( mai2_io_touch_1p_thread = (HANDLE)_beginthreadex(
NULL, NULL, 0, mai2_io_touch_1p_thread_proc, _callback, 0, NULL);
0, } else if (!player1 && mai2_io_touch_1p_thread != NULL) {
mai2_io_touch_1p_thread_proc,
_callback,
0,
NULL);
}
else if (!player1 && mai2_io_touch_1p_thread != NULL)
{
mai2_io_touch_1p_stop_flag = true; mai2_io_touch_1p_stop_flag = true;
WaitForSingleObject(mai2_io_touch_1p_thread, INFINITE); WaitForSingleObject(mai2_io_touch_1p_thread, INFINITE);
@ -190,20 +174,12 @@ void mai2_io_touch_update(bool player1, bool player2)
mai2_io_touch_1p_stop_flag = false; mai2_io_touch_1p_stop_flag = false;
} }
} }
if (mai2_io_cfg.debug_input_2p)
{ if (mai2_io_cfg.debug_input_2p) {
if (player2 && mai2_io_touch_2p_thread == NULL) if (player2 && mai2_io_touch_2p_thread == NULL) {
{
mai2_io_touch_2p_thread = (HANDLE)_beginthreadex( mai2_io_touch_2p_thread = (HANDLE)_beginthreadex(
NULL, NULL, 0, mai2_io_touch_2p_thread_proc, _callback, 0, NULL);
0, } else if (!player2 && mai2_io_touch_2p_thread != NULL) {
mai2_io_touch_2p_thread_proc,
_callback,
0,
NULL);
}
else if (!player2 && mai2_io_touch_2p_thread != NULL)
{
mai2_io_touch_2p_stop_flag = true; mai2_io_touch_2p_stop_flag = true;
WaitForSingleObject(mai2_io_touch_2p_thread, INFINITE); WaitForSingleObject(mai2_io_touch_2p_thread, INFINITE);
@ -215,18 +191,14 @@ void mai2_io_touch_update(bool player1, bool player2)
} }
} }
static unsigned int __stdcall mai2_io_touch_1p_thread_proc(void *ctx) static unsigned int __stdcall mai2_io_touch_1p_thread_proc(void *ctx) {
{
mai2_io_touch_callback_t callback = ctx; mai2_io_touch_callback_t callback = ctx;
while (!mai2_io_touch_1p_stop_flag) while (!mai2_io_touch_1p_stop_flag) {
{
uint8_t state[7] = {0, 0, 0, 0, 0, 0, 0}; uint8_t state[7] = {0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i < 34; i++) for (int i = 0; i < 34; i++) {
{ if (GetAsyncKeyState(mai2_io_cfg.vk_1p_touch[i])) {
if (GetAsyncKeyState(mai2_io_cfg.vk_1p_touch[i]))
{
int byteIndex = i / 5; int byteIndex = i / 5;
int bitIndex = i % 5; int bitIndex = i % 5;
state[byteIndex] |= (1 << bitIndex); state[byteIndex] |= (1 << bitIndex);
@ -238,18 +210,14 @@ static unsigned int __stdcall mai2_io_touch_1p_thread_proc(void *ctx)
return 0; return 0;
} }
static unsigned int __stdcall mai2_io_touch_2p_thread_proc(void *ctx) static unsigned int __stdcall mai2_io_touch_2p_thread_proc(void *ctx) {
{
mai2_io_touch_callback_t callback = ctx; mai2_io_touch_callback_t callback = ctx;
while (!mai2_io_touch_2p_stop_flag) while (!mai2_io_touch_2p_stop_flag) {
{
uint8_t state[7] = {0, 0, 0, 0, 0, 0, 0}; uint8_t state[7] = {0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i < 34; i++) for (int i = 0; i < 34; i++) {
{ if (GetAsyncKeyState(mai2_io_cfg.vk_2p_touch[i])) {
if (GetAsyncKeyState(mai2_io_cfg.vk_2p_touch[i]))
{
int byteIndex = i / 5; int byteIndex = i / 5;
int bitIndex = i % 5; int bitIndex = i % 5;
state[byteIndex] |= (1 << bitIndex); state[byteIndex] |= (1 << bitIndex);
@ -261,38 +229,38 @@ static unsigned int __stdcall mai2_io_touch_2p_thread_proc(void *ctx)
return 0; return 0;
} }
HRESULT mai2_io_led_init(void) HRESULT mai2_io_led_init(void) { return S_OK; }
{
return S_OK;
}
void mai2_io_led_set_fet_output(const uint8_t *rgb) void mai2_io_led_set_fet_output(uint8_t board, const uint8_t *rgb) {
{
#if 0 #if 0
dprintf("mai2 LED: BodyLed brightness: %d%%\n", (rgb[0] * 100) / 255); uint8_t player = board + 1;
dprintf("mai2 LED: ExtLed brightness: %d%%\n", (rgb[1] * 100) / 255); dprintf("MAI2 LED %dP: BodyLed brightness: %d%%\n", player,
dprintf("mai2 LED: SideLed brightness: %d%%\n", (rgb[2] * 100) / 255); (rgb[0] * 100) / 255);
dprintf("MAI2 LED %dP: ExtLed brightness: %d%%\n", player,
(rgb[1] * 100) / 255);
dprintf("MAI2 LED %dP: SideLed brightness: %d%%\n", player,
(rgb[2] * 100) / 255);
#endif #endif
return; return;
} }
void mai2_io_led_dc_update(const uint8_t *rgb) void mai2_io_led_dc_update(uint8_t board, const uint8_t *rgb) {
{
#if 0 #if 0
uint8_t player = board + 1;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
dprintf("mai2 LED: LED %d: %02X %02X %02X Speed: %02X\n", dprintf("Mai2 LED %dP: LED %d: %02X %02X %02X Speed: %02X\n", player
i, rgb[i * 4], rgb[i * 4 + 1], rgb[i * 4 + 2], rgb[i * 4 + 3]); i, rgb[i * 4], rgb[i * 4 + 1], rgb[i * 4 + 2], rgb[i * 4 + 3]);
} }
#endif #endif
return; return;
} }
void mai2_io_led_gs_update(const uint8_t *rgb) void mai2_io_led_gs_update(uint8_t board, const uint8_t *rgb) {
{
#if 0 #if 0
uint8_t player = board + 1;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
dprintf("mai2 LED: LED %d: %02X %02X %02X Speed: %02X\n", dprintf("Mai2 LED %dP: LED %d: %02X %02X %02X Speed: %02X\n", player, i,
i, rgb[i * 4], rgb[i * 4 + 1], rgb[i * 4 + 2], rgb[i * 4 + 3]); rgb[i * 4], rgb[i * 4 + 1], rgb[i * 4 + 2], rgb[i * 4 + 3]);
} }
#endif #endif
return; return;

View File

@ -156,6 +156,9 @@ HRESULT mai2_io_led_init(void);
/* Update the FET outputs. rgb is a pointer to an array up to 3 bytes. /* Update the FET outputs. rgb is a pointer to an array up to 3 bytes.
maimai DX uses two boards. Board 0 is for the player 1 side (left) and board 1
is for the player 2 side (right).
Set the brightness of the white light on the machine's outer shell. Set the brightness of the white light on the machine's outer shell.
The program will continuously send changed values to request the blinking effect. The program will continuously send changed values to request the blinking effect.
@ -167,13 +170,16 @@ HRESULT mai2_io_led_init(void);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void mai2_io_led_set_fet_output(const uint8_t *rgb); void mai2_io_led_set_fet_output(uint8_t board, const uint8_t *rgb);
/* The effect of this command is unknown, it is triggered after LED_15070_CMD_EEPROM_READ. */ /* The effect of this command is unknown, it is triggered after LED_15070_CMD_EEPROM_READ. */
void mai2_io_led_dc_update(const uint8_t *rgb); void mai2_io_led_dc_update(uint8_t board, const uint8_t *rgb);
/* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes. /* Update the RGB LEDs. rgb is a pointer to an array up to 8 * 4 = 32 bytes.
maimai DX uses two boards. Board 0 is for the player 1 side (left) and board 1
is for the player 2 side (right).
The LEDs are laid out as follows: The LEDs are laid out as follows:
[0-7]: 8 button LED [0-7]: 8 button LED
@ -183,4 +189,4 @@ void mai2_io_led_dc_update(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void mai2_io_led_gs_update(const uint8_t *rgb); void mai2_io_led_gs_update(uint8_t board, const uint8_t *rgb);

View File

@ -41,7 +41,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15093", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0xA0, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAA53, filename);

View File

@ -81,8 +81,9 @@ static DWORD CALLBACK mu3_pre_startup(void)
goto fail; goto fail;
} }
unsigned int led_port_no[2] = {3, 0};
hr = led15093_hook_init(&mu3_hook_cfg.led15093, hr = led15093_hook_init(&mu3_hook_cfg.led15093,
mu3_dll.led_init, mu3_dll.led_set_leds, 3, 1, 1, 2); mu3_dll.led_init, mu3_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
return hr; return hr;

View File

@ -23,7 +23,8 @@ void led15070_config_load(struct led15070_config *cfg, const wchar_t *filename)
wchar_t tmpstr[16]; wchar_t tmpstr[16];
cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15070", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15070", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15070", L"portNo2", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename);
/* TODO: Unknown, no firmware file available */ /* TODO: Unknown, no firmware file available */
cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0xdead, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0xdead, filename);

View File

@ -100,8 +100,9 @@ static DWORD CALLBACK swdc_pre_startup(void)
} }
/* Not working, different board -04 instead of -02? */ /* Not working, different board -04 instead of -02? */
unsigned int led_port_no[2] = {2, 0};
hr = led15070_hook_init(&swdc_hook_cfg.led15070, swdc_dll.led_init, hr = led15070_hook_init(&swdc_hook_cfg.led15070, swdc_dll.led_init,
swdc_dll.led_set_fet_output, NULL, swdc_dll.led_gs_update, 2, 1); swdc_dll.led_set_fet_output, NULL, swdc_dll.led_gs_update, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
goto fail; goto fail;

View File

@ -203,7 +203,7 @@ static HRESULT swdc_io4_write_gpio(uint8_t* payload, size_t len)
lights_data & SWDC_IO_LED_LEFT ? 0xFF : 0x00, lights_data & SWDC_IO_LED_LEFT ? 0xFF : 0x00,
}; };
swdc_dll.led_set_leds(rgb_out); swdc_dll.led_set_leds(0, rgb_out);
return S_OK; return S_OK;
} }

View File

@ -11,9 +11,9 @@ struct swdc_dll {
void (*get_gamebtns)(uint16_t *gamebtn); void (*get_gamebtns)(uint16_t *gamebtn);
void (*get_analogs)(struct swdc_io_analog_state *out); void (*get_analogs)(struct swdc_io_analog_state *out);
HRESULT (*led_init)(void); HRESULT (*led_init)(void);
void (*led_set_fet_output)(const uint8_t *rgb); void (*led_set_fet_output)(uint8_t board, const uint8_t *rgb);
void (*led_gs_update)(const uint8_t *rgb); void (*led_gs_update)(uint8_t board, const uint8_t *rgb);
void (*led_set_leds)(const uint8_t *rgb); void (*led_set_leds)(uint8_t board, const uint8_t *rgb);
HRESULT (*ffb_init)(void); HRESULT (*ffb_init)(void);
void (*ffb_toggle)(bool active); void (*ffb_toggle)(bool active);
void (*ffb_constant_force)(uint8_t direction, uint8_t force); void (*ffb_constant_force)(uint8_t direction, uint8_t force);

View File

@ -119,7 +119,7 @@ HRESULT swdc_io_led_init(void)
return S_OK; return S_OK;
} }
void swdc_io_led_set_fet_output(const uint8_t *rgb) void swdc_io_led_set_fet_output(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("SWDC LED: LEFT SEAT LED: %02X\n", rgb[0]); dprintf("SWDC LED: LEFT SEAT LED: %02X\n", rgb[0]);
@ -129,7 +129,7 @@ void swdc_io_led_set_fet_output(const uint8_t *rgb)
return; return;
} }
void swdc_io_led_gs_update(const uint8_t *rgb) void swdc_io_led_gs_update(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
@ -141,7 +141,7 @@ void swdc_io_led_gs_update(const uint8_t *rgb)
return; return;
} }
void swdc_io_led_set_leds(const uint8_t *rgb) void swdc_io_led_set_leds(uint8_t board, const uint8_t *rgb)
{ {
#if 0 #if 0
dprintf("SWDC LED: START: %02X\n", rgb[0]); dprintf("SWDC LED: START: %02X\n", rgb[0]);

View File

@ -123,7 +123,7 @@ HRESULT swdc_io_led_init(void);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void swdc_io_led_set_fet_output(const uint8_t *rgb); void swdc_io_led_set_fet_output(uint8_t board, const uint8_t *rgb);
/* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes. /* Update the RGB LEDs. rgb is a pointer to an array up to 32 * 4 = 128 bytes.
@ -140,7 +140,7 @@ void swdc_io_led_set_fet_output(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void swdc_io_led_gs_update(const uint8_t *rgb); void swdc_io_led_gs_update(uint8_t board, const uint8_t *rgb);
/* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes. /* Update the cabinet button LEDs. rgb is a pointer to an array up to 6 bytes.
@ -156,7 +156,7 @@ void swdc_io_led_gs_update(const uint8_t *rgb);
Minimum API version: 0x0101 */ Minimum API version: 0x0101 */
void swdc_io_led_set_leds(const uint8_t *rgb); void swdc_io_led_set_leds(uint8_t board, const uint8_t *rgb);
/* Initialize FFB emulation. This function will be called before any /* Initialize FFB emulation. This function will be called before any
other swdc_io_ffb_*() function calls. other swdc_io_ffb_*() function calls.

View File

@ -40,7 +40,8 @@ void led15093_config_load(struct led15093_config *cfg, const wchar_t *filename)
memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number)); memset(cfg->boot_chip_number, ' ', sizeof(cfg->boot_chip_number));
cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename); cfg->enable = GetPrivateProfileIntW(L"led15093", L"enable", 1, filename);
cfg->port_no = GetPrivateProfileIntW(L"led15093", L"portNo", 0, filename); cfg->port_no[0] = GetPrivateProfileIntW(L"led15093", L"portNo1", 0, filename);
cfg->port_no[1] = GetPrivateProfileIntW(L"led15093", L"portNo2", 0, filename);
cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename); cfg->high_baudrate = GetPrivateProfileIntW(L"led15093", L"highBaud", 0, filename);
cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename); cfg->fw_ver = GetPrivateProfileIntW(L"led15093", L"fwVer", 0x90, filename);
cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAED9, filename); cfg->fw_sum = GetPrivateProfileIntW(L"led15093", L"fwSum", 0xAED9, filename);

View File

@ -66,8 +66,9 @@ static DWORD CALLBACK tokyo_pre_startup(void)
goto fail; goto fail;
} }
unsigned int led_port_no[2] = {1, 0};
hr = led15093_hook_init(&tokyo_hook_cfg.led15093, hr = led15093_hook_init(&tokyo_hook_cfg.led15093,
tokyo_dll.led_init, tokyo_dll.led_set_leds, 1, 1, 1, 2); tokyo_dll.led_init, tokyo_dll.led_set_leds, led_port_no);
if (FAILED(hr)) { if (FAILED(hr)) {
return hr; return hr;