From e6794807a61032be51d8456ebefa7ee1ec0d2c06 Mon Sep 17 00:00:00 2001 From: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:20:05 +0200 Subject: [PATCH] add default port fallback for vfd --- board/vfd.c | 11 ++++++++--- board/vfd.h | 2 +- chusanhook/dllmain.c | 2 +- cmhook/dllmain.c | 2 +- fgohook/dllmain.c | 2 +- mai2hook/dllmain.c | 2 +- mercuryhook/dllmain.c | 2 +- mu3hook/dllmain.c | 2 +- swdchook/dllmain.c | 2 +- 9 files changed, 16 insertions(+), 11 deletions(-) diff --git a/board/vfd.c b/board/vfd.c index 1b6c626..abc487a 100644 --- a/board/vfd.c +++ b/board/vfd.c @@ -50,7 +50,7 @@ HRESULT vfd_handle_create_char2(struct const_iobuf* reader, struct iobuf* writer static bool utf_enabled; -HRESULT vfd_hook_init(struct vfd_config *cfg) +HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port) { if (!cfg->enable){ return S_FALSE; @@ -58,8 +58,13 @@ HRESULT vfd_hook_init(struct vfd_config *cfg) utf_enabled = cfg->utf_conversion; - dprintf("VFD: enabling (port=%d)\n", cfg->port); - uart_init(&vfd_uart, cfg->port); + int port = cfg->port; + if (port == 0){ + port = default_port; + } + + dprintf("VFD: enabling (port=%d)\n", port); + uart_init(&vfd_uart, port); vfd_uart.written.bytes = vfd_written; vfd_uart.written.nbytes = sizeof(vfd_written); vfd_uart.readable.bytes = vfd_readable; diff --git a/board/vfd.h b/board/vfd.h index 42c2e04..3e67061 100644 --- a/board/vfd.h +++ b/board/vfd.h @@ -9,5 +9,5 @@ struct vfd_config { }; -HRESULT vfd_hook_init(struct vfd_config *cfg); +HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port); diff --git a/chusanhook/dllmain.c b/chusanhook/dllmain.c index 43509ef..85c6228 100644 --- a/chusanhook/dllmain.c +++ b/chusanhook/dllmain.c @@ -146,7 +146,7 @@ static DWORD CALLBACK chusan_pre_startup(void) unsigned int first_port = is_cvt ? 2 : 20; if (!is_cvt) { - hr = vfd_hook_init(&chusan_hook_cfg.vfd); + hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/cmhook/dllmain.c b/cmhook/dllmain.c index 4123443..ac54a9d 100644 --- a/cmhook/dllmain.c +++ b/cmhook/dllmain.c @@ -84,7 +84,7 @@ static DWORD CALLBACK cm_pre_startup(void) goto fail; } - hr = vfd_hook_init(&cm_hook_cfg.vfd); + hr = vfd_hook_init(&cm_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/fgohook/dllmain.c b/fgohook/dllmain.c index 9b8613d..dfbbdb5 100644 --- a/fgohook/dllmain.c +++ b/fgohook/dllmain.c @@ -84,7 +84,7 @@ static DWORD CALLBACK fgo_pre_startup(void) goto fail; } - hr = vfd_hook_init(&fgo_hook_cfg.vfd); + hr = vfd_hook_init(&fgo_hook_cfg.vfd, 1); if (FAILED(hr)) { goto fail; diff --git a/mai2hook/dllmain.c b/mai2hook/dllmain.c index 3b4f6a7..02f32a4 100644 --- a/mai2hook/dllmain.c +++ b/mai2hook/dllmain.c @@ -79,7 +79,7 @@ static DWORD CALLBACK mai2_pre_startup(void) goto fail; } - hr = vfd_hook_init(&mai2_hook_cfg.vfd); + hr = vfd_hook_init(&mai2_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/mercuryhook/dllmain.c b/mercuryhook/dllmain.c index 2810574..ea30458 100644 --- a/mercuryhook/dllmain.c +++ b/mercuryhook/dllmain.c @@ -77,7 +77,7 @@ static DWORD CALLBACK mercury_pre_startup(void) goto fail; } - hr = vfd_hook_init(&mercury_hook_cfg.vfd); + hr = vfd_hook_init(&mercury_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/mu3hook/dllmain.c b/mu3hook/dllmain.c index 10e1226..bab6c0b 100644 --- a/mu3hook/dllmain.c +++ b/mu3hook/dllmain.c @@ -93,7 +93,7 @@ static DWORD CALLBACK mu3_pre_startup(void) goto fail; } - hr = vfd_hook_init(&mu3_hook_cfg.vfd); + hr = vfd_hook_init(&mu3_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/swdchook/dllmain.c b/swdchook/dllmain.c index d40cc52..94d68ea 100644 --- a/swdchook/dllmain.c +++ b/swdchook/dllmain.c @@ -79,7 +79,7 @@ static DWORD CALLBACK swdc_pre_startup(void) goto fail; } - hr = vfd_hook_init(&swdc_hook_cfg.vfd); + hr = vfd_hook_init(&swdc_hook_cfg.vfd, 4); if (FAILED(hr)) { return hr;