From ff28d4ff09865b883cb65c3b8544a8d280080a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B0=E3=83=AD=E3=83=BC=E3=83=A9=E3=83=B3=E3=83=97?= <130208311+Gl0w1amp@users.noreply.github.com> Date: Sun, 4 Jan 2026 08:41:56 +0000 Subject: [PATCH] mai2io: add camera LED control functions (#91) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow-up to the previous PR. I realized I omitted the camera LED control interface, so I'm adding it now to complete the v1.02 API set. **Changes:** * Added `mai2_io_led_cam_set` to the 0x0102 API. * Wired IO4 GPIO outputs to forward code reader/player camera light states. * Updated `mai2hook.def` to export the new symbol. * Updated `MAI2_DLL_SYM_COUNT_V102` to reflect the additional symbol count. **Versioning Note:** Since the previous PR was just merged and v1.02 hasn't been officially released yet, I've opted to include this in the existing **0x0102** version rather than bumping to 0x0103. Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/91 Co-authored-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com> Co-committed-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com> --- games/mai2hook/io4.c | 24 +++++++++++++++++++++++- games/mai2hook/mai2-dll.c | 5 ++++- games/mai2hook/mai2-dll.h | 1 + games/mai2hook/mai2hook.def | 1 + games/mai2io/mai2io.c | 11 +++++++++++ games/mai2io/mai2io.h | 14 ++++++++++++++ 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/games/mai2hook/io4.c b/games/mai2hook/io4.c index a1903d2..f0f9a67 100644 --- a/games/mai2hook/io4.c +++ b/games/mai2hook/io4.c @@ -177,6 +177,28 @@ static HRESULT mai2_io4_write_gpio(uint8_t* payload, size_t len) { dprintf(" Camera Ring: %s\n", (payload[1] & 0x80) ? "ON" : "OFF"); dprintf(" Camera Rec: %s\n", (payload[1] & 0x40) ? "ON" : "OFF"); #endif + + if (mai2_dll.led_cam_set != NULL) { + uint8_t state = 0; + + if (payload[0] & 0x20) { + state |= MAI2_IO_LED_CAM_CODE_READER_1P; + } + + if (payload[0] & 0x04) { + state |= MAI2_IO_LED_CAM_CODE_READER_2P; + } + + if (payload[1] & 0x80) { + state |= MAI2_IO_LED_CAM_RING; + } + + if (payload[1] & 0x40) { + state |= MAI2_IO_LED_CAM_REC; + } + + mai2_dll.led_cam_set(state); + } } return S_OK; } @@ -212,4 +234,4 @@ static HRESULT mai2_io4_write_unique(uint8_t* payload, size_t len) { } return S_OK; -} \ No newline at end of file +} diff --git a/games/mai2hook/mai2-dll.c b/games/mai2hook/mai2-dll.c index 9fa591d..c414340 100644 --- a/games/mai2hook/mai2-dll.c +++ b/games/mai2hook/mai2-dll.c @@ -10,7 +10,7 @@ enum { MAI2_DLL_SYM_COUNT_V101 = 11, - MAI2_DLL_SYM_COUNT_V102 = 12, + MAI2_DLL_SYM_COUNT_V102 = 13, }; const struct dll_bind_sym mai2_dll_syms[] = { @@ -50,6 +50,9 @@ const struct dll_bind_sym mai2_dll_syms[] = { }, { .sym = "mai2_io_led_billboard_set", .off = offsetof(struct mai2_dll, led_set_leds), + }, { + .sym = "mai2_io_led_cam_set", + .off = offsetof(struct mai2_dll, led_cam_set), }, }; diff --git a/games/mai2hook/mai2-dll.h b/games/mai2hook/mai2-dll.h index ac456e8..bbaf69a 100644 --- a/games/mai2hook/mai2-dll.h +++ b/games/mai2hook/mai2-dll.h @@ -18,6 +18,7 @@ struct mai2_dll { void (*led_dc_update)(uint8_t board, const uint8_t *rgb); void (*led_gs_update)(uint8_t board, const uint8_t *rgb); void (*led_set_leds)(uint8_t board, const uint8_t *rgb); + void (*led_cam_set)(uint8_t state); }; struct mai2_dll_config { diff --git a/games/mai2hook/mai2hook.def b/games/mai2hook/mai2hook.def index a3b3df8..4b32c24 100644 --- a/games/mai2hook/mai2hook.def +++ b/games/mai2hook/mai2hook.def @@ -24,3 +24,4 @@ EXPORTS mai2_io_led_dc_update mai2_io_led_gs_update mai2_io_led_billboard_set + mai2_io_led_cam_set diff --git a/games/mai2io/mai2io.c b/games/mai2io/mai2io.c index 4864887..6a15bdf 100644 --- a/games/mai2io/mai2io.c +++ b/games/mai2io/mai2io.c @@ -273,3 +273,14 @@ void mai2_io_led_billboard_set(uint8_t board, const uint8_t *rgb) { #endif return; } + +void mai2_io_led_cam_set(uint8_t state) { +#if 0 + dprintf("Mai2 LED cam: CodeReader1P=%s CodeReader2P=%s Ring=%s Rec=%s\n", + (state & MAI2_IO_LED_CAM_CODE_READER_1P) ? "ON" : "OFF", + (state & MAI2_IO_LED_CAM_CODE_READER_2P) ? "ON" : "OFF", + (state & MAI2_IO_LED_CAM_RING) ? "ON" : "OFF", + (state & MAI2_IO_LED_CAM_REC) ? "ON" : "OFF"); +#endif + return; +} diff --git a/games/mai2io/mai2io.h b/games/mai2io/mai2io.h index 4519a01..297f35c 100644 --- a/games/mai2io/mai2io.h +++ b/games/mai2io/mai2io.h @@ -199,3 +199,17 @@ void mai2_io_led_gs_update(uint8_t board, const uint8_t *rgb); Minimum API version: 0x0102 */ void mai2_io_led_billboard_set(uint8_t board, const uint8_t *rgb); + +enum { + MAI2_IO_LED_CAM_CODE_READER_1P = 0x01, + MAI2_IO_LED_CAM_CODE_READER_2P = 0x02, + MAI2_IO_LED_CAM_RING = 0x04, + MAI2_IO_LED_CAM_REC = 0x08, +}; + +/* Update the Code Reader and Player Camera lights. State is a bitmask of + MAI2_IO_LED_CAM_* values. + + Minimum API version: 0x0102 */ + +void mai2_io_led_cam_set(uint8_t state);