From da0fc565009bac0605a84f024ff1ccc289c3f835 Mon Sep 17 00:00:00 2001 From: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:54:07 +0200 Subject: [PATCH] ekt: make ports configurable, misc corrections --- dist/ekt/segatools_satellite.ini | 5 +++++ games/ekthook/config.c | 8 ++------ games/ekthook/y3.c | 22 ++++++++-------------- games/ekthook/y3.h | 5 ++--- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/dist/ekt/segatools_satellite.ini b/dist/ekt/segatools_satellite.ini index c8b2cf8..190dcb9 100644 --- a/dist/ekt/segatools_satellite.ini +++ b/dist/ekt/segatools_satellite.ini @@ -81,6 +81,11 @@ dipsw1=0 ; modding frameworks such as BepInEx. targetAssembly= +[flatPanelReader] +enable=1 +port_field=4 +port_printer=0 + ; ----------------------------------------------------------------------------- ; LED settings ; ----------------------------------------------------------------------------- diff --git a/games/ekthook/config.c b/games/ekthook/config.c index 1b1f0af..58e367b 100644 --- a/games/ekthook/config.c +++ b/games/ekthook/config.c @@ -108,13 +108,9 @@ void y3_config_load( memset(cfg->target_code_printer, ' ', sizeof(cfg->target_code_printer) - 1); cfg->target_code_printer[sizeof(cfg->target_code_printer) - 1] = '\0'; - - cfg->enable = GetPrivateProfileIntW(L"y3", L"enable", 1, filename); - cfg->ws_enable = GetPrivateProfileIntW(L"y3", L"ws_enable", 1, filename); - cfg->ws_port = GetPrivateProfileIntW(L"y3", L"ws_port", 3597, filename); - cfg->ws_timeout = GetPrivateProfileIntW(L"y3", L"ws_timeout", 30000, filename); - cfg->enable = GetPrivateProfileIntW(L"flatPanelReader", L"enable", 1, filename); + cfg->port_field = GetPrivateProfileIntW(L"flatPanelReader", L"port_field", 10, filename); + cfg->port_printer = GetPrivateProfileIntW(L"flatPanelReader", L"port_printer", 11, filename); cfg->dll_version = (float)GetPrivateProfileIntW( L"flatPanelReader", diff --git a/games/ekthook/y3.c b/games/ekthook/y3.c index b540c5c..6f4bba3 100644 --- a/games/ekthook/y3.c +++ b/games/ekthook/y3.c @@ -261,8 +261,8 @@ static struct y3_config y3_config; #define MAX_CARD_SIZE 32 static struct CardInfo card_data[MAX_CARD_SIZE]; -static const int* Y3_COM_FIELD = (int*)10; -static const int* Y3_COM_PRINT = (int*)11; +static int* Y3_COM_FIELD = (int*)10; +static int* Y3_COM_PRINT = (int*)11; void y3_hook_init(const struct y3_config* cfg, HINSTANCE self) { assert(cfg != NULL); @@ -272,12 +272,14 @@ void y3_hook_init(const struct y3_config* cfg, HINSTANCE self) { } memcpy(&y3_config, cfg, sizeof(*cfg)); + Y3_COM_FIELD = (int*)(uintptr_t)cfg->port_field; + Y3_COM_PRINT = (int*)(uintptr_t)cfg->port_printer; y3_insert_hooks(NULL); memset(card_data, 0, sizeof(card_data)); - dprintf("Y3: hook enabled\n"); + dprintf("Y3: hook enabled (field port = %d, printer port = %d)\n", cfg->port_field, cfg->port_printer); } void y3_insert_hooks(HMODULE target) { @@ -322,12 +324,6 @@ CALL uint32_t API_GetErrorMessage(uint32_t errNo, char* szMessage, CALL int* API_Connect(char* szPortName) { dprintf("Y3: %s(%s)\n", __func__, szPortName); - if ((GetAsyncKeyState(0x11) & 0x8000) && - (GetAsyncKeyState(0x42) & 0x8000)) { - dprintf("Y3: Ctrl+B is active!\n"); - return NULL; - } - if (!y3_config.enable) { return NULL; } else { @@ -367,7 +363,6 @@ CALL uint32_t API_GetFirmName(int* hDevice) { } else if (hDevice == Y3_COM_PRINT) { result = convert_string_to_uint(y3_config.firm_name_printer); dprintf("This Y3 device is PRINTER: %s\n", y3_config.firm_name_printer); - // DebugBreak(); } else { dprintf("This Y3 device is UNKNOWN\n"); } @@ -385,7 +380,6 @@ CALL uint32_t API_GetTargetCode(int* hDevice) { } else if (hDevice == Y3_COM_PRINT) { result = convert_string_to_uint(y3_config.target_code_printer); dprintf("This Y3 device is PRINTER: %s\n", y3_config.target_code_printer); - // DebugBreak(); } else { dprintf("This Y3 device is UNKNOWN\n"); } @@ -450,13 +444,13 @@ CALL int API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo) pCardInfo[i].fY = paddingY + (row * cardWidth); pCardInfo[i].fAngle = 0.0f; pCardInfo[i].eCardType = TYPE0; - pCardInfo[i].eCardStatus = MARKER; + pCardInfo[i].eCardStatus = VALID; pCardInfo[i].uID = 1000 + i; pCardInfo[i].nNumChars = 0; pCardInfo[0].ubChar0.Data = 0; - pCardInfo[0].ubChar1.Data = 0x4000; + pCardInfo[0].ubChar1.Data = 0; pCardInfo[0].ubChar2.Data = 0; - pCardInfo[0].ubChar3.Data = 0x0; // 40 + pCardInfo[0].ubChar3.Data = 0; pCardInfo[0].ubChar4.Data = 0; pCardInfo[0].ubChar5.Data = 0; } diff --git a/games/ekthook/y3.h b/games/ekthook/y3.h index b250d01..762b1c3 100644 --- a/games/ekthook/y3.h +++ b/games/ekthook/y3.h @@ -52,9 +52,6 @@ struct CardInfo { struct y3_config { bool enable; - uint8_t ws_enable; - uint16_t ws_port; - uint32_t ws_timeout; float dll_version; float firm_version; @@ -62,6 +59,8 @@ struct y3_config { char firm_name_printer[5]; char target_code_field[5]; char target_code_printer[5]; + uint8_t port_field; + uint8_t port_printer; }; void y3_hook_init(const struct y3_config *cfg, HINSTANCE self);