From 451a7ec49d6eab979a026e0ba0156862dc9e5b11 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Tue, 6 Feb 2024 12:34:11 +0100 Subject: [PATCH] added VFD toggle to config --- board/config.c | 9 +++++++++ board/config.h | 2 ++ board/vfd.c | 10 +++++++++- board/vfd.h | 7 ++++++- chusanhook/config.c | 1 + chusanhook/config.h | 1 + chusanhook/dllmain.c | 2 +- cmhook/config.c | 1 + cmhook/config.h | 1 + cmhook/dllmain.c | 2 +- dist/chusan/segatools.ini | 8 +++++++- dist/cm/segatools.ini | 8 +++++++- dist/fgo/segatools.ini | 8 +++++++- dist/mai2/segatools.ini | 8 +++++++- dist/mercury/segatools.ini | 11 +++++++++++ dist/mu3/segatools.ini | 8 +++++++- dist/swdc/segatools.ini | 8 +++++++- doc/config/common.md | 11 +++++++++++ fgohook/config.c | 1 + fgohook/config.h | 1 + fgohook/dllmain.c | 2 +- mai2hook/config.c | 1 + mai2hook/config.h | 1 + mai2hook/dllmain.c | 2 +- mercuryhook/config.c | 1 + mercuryhook/config.h | 1 + mercuryhook/dllmain.c | 2 +- mu3hook/config.c | 1 + mu3hook/config.h | 1 + mu3hook/dllmain.c | 2 +- swdchook/config.c | 1 + swdchook/config.h | 1 + swdchook/dllmain.c | 2 +- 33 files changed, 111 insertions(+), 15 deletions(-) diff --git a/board/config.c b/board/config.c index 9fefd4c..9b69b42 100644 --- a/board/config.c +++ b/board/config.c @@ -8,6 +8,7 @@ #include "board/aime-dll.h" #include "board/config.h" #include "board/sg-reader.h" +#include "board/vfd.h" #include "util/dprintf.h" @@ -82,3 +83,11 @@ void io4_config_load(struct io4_config *cfg, const wchar_t *filename) cfg->enable = GetPrivateProfileIntW(L"io4", L"enable", 1, filename); } + +void vfd_config_load(struct vfd_config *cfg, const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + cfg->enable = GetPrivateProfileIntW(L"vfd", L"enable", 1, filename); +} diff --git a/board/config.h b/board/config.h index f436a82..37b5b14 100644 --- a/board/config.h +++ b/board/config.h @@ -5,6 +5,8 @@ #include "board/io4.h" #include "board/sg-reader.h" +#include "board/vfd.h" void aime_config_load(struct aime_config *cfg, const wchar_t *filename); void io4_config_load(struct io4_config *cfg, const wchar_t *filename); +void vfd_config_load(struct vfd_config *cfg, const wchar_t *filename); diff --git a/board/vfd.c b/board/vfd.c index 081a8d8..0442439 100644 --- a/board/vfd.c +++ b/board/vfd.c @@ -27,14 +27,22 @@ static struct uart vfd_uart; static uint8_t vfd_written[512]; static uint8_t vfd_readable[512]; -HRESULT vfd_hook_init(unsigned int port_no) +HRESULT vfd_hook_init(const struct vfd_config *cfg, unsigned int port_no) { + assert(cfg != NULL); + + if (!cfg->enable) { + return S_FALSE; + } + uart_init(&vfd_uart, port_no); vfd_uart.written.bytes = vfd_written; vfd_uart.written.nbytes = sizeof(vfd_written); vfd_uart.readable.bytes = vfd_readable; vfd_uart.readable.nbytes = sizeof(vfd_readable); + dprintf("VFD: hook enabled.\n"); + return iohook_push_handler(vfd_handle_irp); } diff --git a/board/vfd.h b/board/vfd.h index 01cd82e..e37386f 100644 --- a/board/vfd.h +++ b/board/vfd.h @@ -2,4 +2,9 @@ #include -HRESULT vfd_hook_init(unsigned int port_no); +struct vfd_config { + bool enable; +}; + + +HRESULT vfd_hook_init(const struct vfd_config *cfg, unsigned int port_no); diff --git a/chusanhook/config.c b/chusanhook/config.c index 3796f69..fa6f19f 100644 --- a/chusanhook/config.c +++ b/chusanhook/config.c @@ -160,6 +160,7 @@ void chusan_hook_config_load( dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); gfx_config_load(&cfg->gfx, filename); + vfd_config_load(&cfg->vfd, filename); chuni_dll_config_load(&cfg->dll, filename); slider_config_load(&cfg->slider, filename); led15093_config_load(&cfg->led15093, filename); diff --git a/chusanhook/config.h b/chusanhook/config.h index 48fb696..e877be5 100644 --- a/chusanhook/config.h +++ b/chusanhook/config.h @@ -20,6 +20,7 @@ struct chusan_hook_config { struct dvd_config dvd; struct io4_config io4; struct gfx_config gfx; + struct vfd_config vfd; struct chuni_dll_config dll; struct slider_config slider; struct led15093_config led15093; diff --git a/chusanhook/dllmain.c b/chusanhook/dllmain.c index e8fce32..136db03 100644 --- a/chusanhook/dllmain.c +++ b/chusanhook/dllmain.c @@ -122,7 +122,7 @@ static DWORD CALLBACK chusan_pre_startup(void) unsigned int first_port = is_cvt ? 2 : 20; if (!is_cvt) { - hr = vfd_hook_init(2); + hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/cmhook/config.c b/cmhook/config.c index 64cbbb2..fd9186c 100644 --- a/cmhook/config.c +++ b/cmhook/config.c @@ -37,6 +37,7 @@ void cm_hook_config_load( aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + vfd_config_load(&cfg->vfd, filename); touch_screen_config_load(&cfg->touch, filename); cm_dll_config_load(&cfg->dll, filename); } diff --git a/cmhook/config.h b/cmhook/config.h index c79f47a..cf39c70 100644 --- a/cmhook/config.h +++ b/cmhook/config.h @@ -16,6 +16,7 @@ struct cm_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct vfd_config vfd; struct cm_dll_config dll; struct touch_screen_config touch; }; diff --git a/cmhook/dllmain.c b/cmhook/dllmain.c index 72587ad..0e12adb 100644 --- a/cmhook/dllmain.c +++ b/cmhook/dllmain.c @@ -60,7 +60,7 @@ static DWORD CALLBACK cm_pre_startup(void) goto fail; } - hr = vfd_hook_init(2); + hr = vfd_hook_init(&cm_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/dist/chusan/segatools.ini b/dist/chusan/segatools.ini index 926a6fe..f6959d3 100644 --- a/dist/chusan/segatools.ini +++ b/dist/chusan/segatools.ini @@ -9,12 +9,18 @@ option= appdata= [aime] -; Enable aime reader emulation. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt ; Enable high baud rate. ;highBaud=1 +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [aimeio] ; Uncomment this if you have custom (x64) aime implementation. ; Leave empty if you want to use Segatools built-in keyboard input. diff --git a/dist/cm/segatools.ini b/dist/cm/segatools.ini index 93b2151..9ca7041 100644 --- a/dist/cm/segatools.ini +++ b/dist/cm/segatools.ini @@ -9,10 +9,16 @@ option= appdata= [aime] -; Enable aime reader emulation. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/dist/fgo/segatools.ini b/dist/fgo/segatools.ini index 08218a2..4d83225 100644 --- a/dist/fgo/segatools.ini +++ b/dist/fgo/segatools.ini @@ -9,10 +9,16 @@ option= appdata= [aime] -; Controls emulation of the Aime card reader assembly. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/dist/mai2/segatools.ini b/dist/mai2/segatools.ini index f3dc0d8..d8ad3d2 100644 --- a/dist/mai2/segatools.ini +++ b/dist/mai2/segatools.ini @@ -9,10 +9,16 @@ option= appdata= [aime] -; Enable aime reader emulation. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/dist/mercury/segatools.ini b/dist/mercury/segatools.ini index 80816b4..5a7cfa3 100644 --- a/dist/mercury/segatools.ini +++ b/dist/mercury/segatools.ini @@ -7,6 +7,17 @@ amfs=amfs appdata=appdata option=option +[aime] +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. +enable=1 +aimePath=DEVICE\aime.txt + +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/dist/mu3/segatools.ini b/dist/mu3/segatools.ini index 83fe03b..a6e68fa 100644 --- a/dist/mu3/segatools.ini +++ b/dist/mu3/segatools.ini @@ -9,10 +9,16 @@ option= appdata= [aime] -; Controls emulation of the Aime card reader assembly. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/dist/swdc/segatools.ini b/dist/swdc/segatools.ini index 4e88bf3..7b64550 100644 --- a/dist/swdc/segatools.ini +++ b/dist/swdc/segatools.ini @@ -9,10 +9,16 @@ option= appdata=appdata [aime] -; Controls emulation of the Aime card reader assembly. +; Enable Aime card reader assembly emulation. Disable to use a real SEGA Aime +; reader. enable=1 aimePath=DEVICE\aime.txt +[vfd] +; Enable VFD emulation (currently just stubbed). Disable to use a real VFD +; GP1232A02A FUTABA assembly. +enable=1 + [dns] ; Insert the hostname or IP address of the server you wish to use here. ; Note that 127.0.0.1, localhost etc are specifically rejected. diff --git a/doc/config/common.md b/doc/config/common.md index 7249d49..23be911 100644 --- a/doc/config/common.md +++ b/doc/config/common.md @@ -84,6 +84,17 @@ emulates an IC card in its proximity. A variety of different IC cards can be emulated; the exact choice of card that is emulated depends on the presence or absence of the configured card ID files. +## `[vfd]` + +Controls emulation of the VFD GP1232A02A FUTABA assembly. + +### `enable` + +Default: `1` + +Enable VFD emulation (currently just stubbed). Disable to use a real VFD +GP1232A02A FUTABA assembly (COM port number varies by game). + ## `[amvideo]` Controls the `amvideo.dll` stub built into Segatools. This is a DLL that is diff --git a/fgohook/config.c b/fgohook/config.c index 24b5825..5442b32 100644 --- a/fgohook/config.c +++ b/fgohook/config.c @@ -116,6 +116,7 @@ void fgo_hook_config_load( aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + vfd_config_load(&cfg->vfd, filename); touch_screen_config_load(&cfg->touch, filename); printer_config_load(&cfg->printer, filename); fgo_deck_config_load(&cfg->deck, filename); diff --git a/fgohook/config.h b/fgohook/config.h index 59b48ee..ffffc25 100644 --- a/fgohook/config.h +++ b/fgohook/config.h @@ -20,6 +20,7 @@ struct fgo_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct vfd_config vfd; struct touch_screen_config touch; struct printer_config printer; struct deck_config deck; diff --git a/fgohook/dllmain.c b/fgohook/dllmain.c index 2e8619e..43ac26e 100644 --- a/fgohook/dllmain.c +++ b/fgohook/dllmain.c @@ -67,7 +67,7 @@ static DWORD CALLBACK fgo_pre_startup(void) goto fail; } - hr = vfd_hook_init(1); + hr = vfd_hook_init(&fgo_hook_cfg.vfd, 1); if (FAILED(hr)) { goto fail; diff --git a/mai2hook/config.c b/mai2hook/config.c index 87615e9..86b9764 100644 --- a/mai2hook/config.c +++ b/mai2hook/config.c @@ -37,5 +37,6 @@ void mai2_hook_config_load( aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + vfd_config_load(&cfg->vfd, filename); mai2_dll_config_load(&cfg->dll, filename); } diff --git a/mai2hook/config.h b/mai2hook/config.h index 3b7fc22..2def3a7 100644 --- a/mai2hook/config.h +++ b/mai2hook/config.h @@ -15,6 +15,7 @@ struct mai2_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct vfd_config vfd; struct mai2_dll_config dll; }; diff --git a/mai2hook/dllmain.c b/mai2hook/dllmain.c index 220e213..5d53368 100644 --- a/mai2hook/dllmain.c +++ b/mai2hook/dllmain.c @@ -57,7 +57,7 @@ static DWORD CALLBACK mai2_pre_startup(void) goto fail; } - hr = vfd_hook_init(2); + hr = vfd_hook_init(&mai2_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/mercuryhook/config.c b/mercuryhook/config.c index f087942..4038129 100644 --- a/mercuryhook/config.c +++ b/mercuryhook/config.c @@ -68,6 +68,7 @@ void mercury_hook_config_load( dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); gfx_config_load(&cfg->gfx, filename); + vfd_config_load(&cfg->vfd, filename); mercury_dll_config_load(&cfg->dll, filename); touch_config_load(&cfg->touch, filename); elisabeth_config_load(&cfg->elisabeth, filename); diff --git a/mercuryhook/config.h b/mercuryhook/config.h index d5bf463..2105704 100644 --- a/mercuryhook/config.h +++ b/mercuryhook/config.h @@ -19,6 +19,7 @@ struct mercury_hook_config { struct dvd_config dvd; struct io4_config io4; struct gfx_config gfx; + struct vfd_config vfd; struct mercury_dll_config dll; struct touch_config touch; struct elisabeth_config elisabeth; diff --git a/mercuryhook/dllmain.c b/mercuryhook/dllmain.c index bcec31f..06b62ad 100644 --- a/mercuryhook/dllmain.c +++ b/mercuryhook/dllmain.c @@ -64,7 +64,7 @@ static DWORD CALLBACK mercury_pre_startup(void) goto fail; } - hr = vfd_hook_init(2); + hr = vfd_hook_init(&mercury_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/mu3hook/config.c b/mu3hook/config.c index 6e3991d..bb51103 100644 --- a/mu3hook/config.c +++ b/mu3hook/config.c @@ -40,5 +40,6 @@ void mu3_hook_config_load( dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); gfx_config_load(&cfg->gfx, filename); + vfd_config_load(&cfg->vfd, filename); mu3_dll_config_load(&cfg->dll, filename); } diff --git a/mu3hook/config.h b/mu3hook/config.h index 623397c..f1b2cdf 100644 --- a/mu3hook/config.h +++ b/mu3hook/config.h @@ -20,6 +20,7 @@ struct mu3_hook_config { struct io4_config io4; struct gfx_config gfx; // struct led15093_config led15093; + struct vfd_config vfd; struct mu3_dll_config dll; }; diff --git a/mu3hook/dllmain.c b/mu3hook/dllmain.c index c27fd4d..3f940dd 100644 --- a/mu3hook/dllmain.c +++ b/mu3hook/dllmain.c @@ -76,7 +76,7 @@ static DWORD CALLBACK mu3_pre_startup(void) goto fail; } - hr = vfd_hook_init(2); + hr = vfd_hook_init(&mu3_hook_cfg.vfd, 2); if (FAILED(hr)) { goto fail; diff --git a/swdchook/config.c b/swdchook/config.c index ba4d34a..4513fd8 100644 --- a/swdchook/config.c +++ b/swdchook/config.c @@ -42,6 +42,7 @@ void swdc_hook_config_load( zinput_config_load(&cfg->zinput, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + vfd_config_load(&cfg->vfd, filename); } void zinput_config_load(struct zinput_config *cfg, const wchar_t *filename) diff --git a/swdchook/config.h b/swdchook/config.h index 5237b9f..587ab66 100644 --- a/swdchook/config.h +++ b/swdchook/config.h @@ -17,6 +17,7 @@ struct swdc_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct vfd_config vfd; struct swdc_dll_config dll; struct zinput_config zinput; }; diff --git a/swdchook/dllmain.c b/swdchook/dllmain.c index e5a47d2..9806123 100644 --- a/swdchook/dllmain.c +++ b/swdchook/dllmain.c @@ -64,7 +64,7 @@ static DWORD CALLBACK swdc_pre_startup(void) goto fail; } - hr = vfd_hook_init(4); + hr = vfd_hook_init(&swdc_hook_cfg.vfd, 4); if (FAILED(hr)) { return hr;