From bf00108224bbefa45b02bf9de6b46b001ea4af7a Mon Sep 17 00:00:00 2001 From: ThatzOkay Date: Wed, 21 Aug 2024 11:39:54 +0200 Subject: [PATCH] Fixed com port config and added led hook --- .vscode/settings.json | 4 +++ Package.mk | 1 + apm3hook/apm3-dll.c | 6 +++++ apm3hook/apm3-dll.h | 2 ++ apm3hook/config.c | 63 ++++++++++++++++++++++++++++++++++++++++++- apm3hook/config.h | 2 ++ apm3hook/dllmain.c | 20 +++++++++----- 7 files changed, 90 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9eb12eb..0f8dfa6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,8 @@ { "editor.formatOnSave": false, "mesonbuild.configureOnOpen": false, + "files.associations": { + "*.embeddedhtml": "html", + "config.h": "c" + }, } diff --git a/Package.mk b/Package.mk index 36fcc19..00055ea 100644 --- a/Package.mk +++ b/Package.mk @@ -257,6 +257,7 @@ $(BUILD_DIR_ZIP)/segatools.zip: \ $(BUILD_DIR_ZIP)/mu3.zip \ $(BUILD_DIR_ZIP)/mai2.zip \ $(BUILD_DIR_ZIP)/cm.zip \ + $(BUILD_DIR_ZIP)/apm3.zip \ $(BUILD_DIR_ZIP)/tokyo.zip \ $(BUILD_DIR_ZIP)/fgo.zip \ CHANGELOG.md \ diff --git a/apm3hook/apm3-dll.c b/apm3hook/apm3-dll.c index 28cde29..f3fe256 100644 --- a/apm3hook/apm3-dll.c +++ b/apm3hook/apm3-dll.c @@ -18,6 +18,12 @@ const struct dll_bind_sym apm3_dll_syms[] = { }, { .sym = "apm3_io_get_opbtns", .off = offsetof(struct apm3_dll, get_opbtns), + }, { + .sym = "apm3_io_led_init", + .off = offsetof(struct apm3_dll, led_init), + }, { + .sym = "apm3_io_led_set_colors", + .off = offsetof(struct apm3_dll, led_set_leds), } }; diff --git a/apm3hook/apm3-dll.h b/apm3hook/apm3-dll.h index 792faca..350f08d 100644 --- a/apm3hook/apm3-dll.h +++ b/apm3hook/apm3-dll.h @@ -9,6 +9,8 @@ struct apm3_dll { HRESULT (*init)(void); HRESULT (*poll)(void); void (*get_opbtns)(uint8_t *opbtn); + HRESULT (*led_init)(void); + void (*led_set_leds)(uint8_t board, uint8_t *rgb); }; struct apm3_dll_config { diff --git a/apm3hook/config.c b/apm3hook/config.c index b6ffc83..6cf9d29 100644 --- a/apm3hook/config.c +++ b/apm3hook/config.c @@ -26,6 +26,66 @@ void apm3_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 apm3_hook_config_load( struct apm3_hook_config *cfg, const wchar_t *filename) @@ -37,8 +97,9 @@ void apm3_hook_config_load( aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + led15093_config_load(&cfg->led15093, filename); vfd_config_load(&cfg->vfd, filename); touch_screen_config_load(&cfg->touch, filename); apm3_dll_config_load(&cfg->dll, filename); unity_config_load(&cfg->unity, filename); -} +} \ No newline at end of file diff --git a/apm3hook/config.h b/apm3hook/config.h index 69020c4..98839bf 100644 --- a/apm3hook/config.h +++ b/apm3hook/config.h @@ -3,6 +3,7 @@ #include #include "board/config.h" +#include "board/led15093.h" #include "hooklib/dvd.h" #include "hooklib/touch.h" @@ -19,6 +20,7 @@ struct apm3_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct led15093_config led15093; struct vfd_config vfd; struct apm3_dll_config dll; struct touch_screen_config touch; diff --git a/apm3hook/dllmain.c b/apm3hook/dllmain.c index f9a3ed7..5b8483f 100644 --- a/apm3hook/dllmain.c +++ b/apm3hook/dllmain.c @@ -1,14 +1,13 @@ /* - "Card Maker" (apm3) hook + "ALLS.NET PRAS MULTI 3" (apm3) hook Devices USB: 837-15257-01 "Type 4" I/O Board USB: 838-20006 "WinTouch" Controller Board - USB: 630-00009 Sinfonia CHC-C310 Printer - COM1: 837-15396 "Gen 3" Aime Reader - COM2: 200-6275 VFD GP1232A02A FUTABA Board - COM3: 220-5872 AS-6DB Coin Selector + COM1: 200-6275 VFD GP1232A02A FUTABA Board + COM2: 837-15093-06 LED Controller Board + COM3: 837-15396 "Gen 3" Aime Reader */ #include @@ -74,13 +73,20 @@ static DWORD CALLBACK apm3_pre_startup(void) goto fail; } - hr = sg_reader_hook_init(&apm3_hook_cfg.aime, 1, 1, apm3_hook_mod); + hr = led15093_hook_init(&apm3_hook_cfg.led15093, + apm3_dll.led_init, apm3_dll.led_set_leds, 2, 1, 1, 2); + + if (FAILED(hr)) { + return hr; + } + + hr = sg_reader_hook_init(&apm3_hook_cfg.aime, 3, 3, apm3_hook_mod); if (FAILED(hr)) { goto fail; } - hr = vfd_hook_init(&apm3_hook_cfg.vfd, 2); + hr = vfd_hook_init(&apm3_hook_cfg.vfd, 1); if (FAILED(hr)) { goto fail;