66 Commits
Author SHA1 Message Date
Kevin 8a966b2454 port aime auth check from bananatools 2026-09-18 18:35:07 -04:00
Hay1tsme a9ca61f285 touch: add hook for RegisterClassExW 2026-08-24 01:34:24 -04:00
Hay1tsme 6d2078f966 fix MSVC failing to comepile due to mismatched paramter const-ness 2026-08-24 01:32:53 -04:00
Hay1tsme 1beeaf30b3 aimeio: Check for felica before trying to generate an access code 2026-08-24 01:28:25 -04:00
kyoubate-haruka beb54c57c3 ewf: support for FTYPE irp and file seeking, fix mono quirks (#120)
Fixes #116
Requires https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/7

This implements file seeking for files inside virtual files from ewfhook, as well as fixes a mono implementation detail where it changes it's behaviour based on the result of GetFileType. see capnhook PR for more info.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/120
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-08-10 15:43:39 +00:00
MikiraSora 31c184adf7 unity: support debugging (#99)
User can debug their Unity game with dnspy and other debugger, it needn't patch mono.dll.

most code is copied&modified from [UnityDoorstop](https://github.com/NeighTools/UnityDoorstop/blob/master/src/bootstrap.c#L328)

currently it work on SDEZ/SDDT

<details>
  <summary>How to debug and breakpoint Unity game (For example SDDT)</summary>

1.   Modify segatools.ini and set `enableDebug` and `debugAddress`
![image.png](/attachments/60a681ac-f050-4923-b955-6b3fdd93a75e)

2.   Inject mu3 with hook dll
![image.png](/attachments/b51391e8-92b4-4c6b-b531-f4171f2f4447)

3.   dnspy connect unity
![image.png](/attachments/513906d3-0f14-4e40-be9f-da87928eeaaf)

4.  open Modules tab and double click Assembly-CSharp.dll, yeah, now you can add breakpoints now.
![image.png](/attachments/5e2a1f0b-62fd-4e68-997f-c2c68efee9ef)

</details>

and make unity_config.target_assembly is optional if we just want to debug unity.

Now PR is ready to code review and merge into upstream.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/99
Co-authored-by: MikiraSora <mikirasora0409@126.com>
Co-committed-by: MikiraSora <mikirasora0409@126.com>
2026-08-10 15:42:41 +00:00
kyoubate-haruka 0e76dd832a diva: input rewrite, dinput/xinput, button alternation, auto-slide, wintouch, printer (#129)
* Rewrote the input handler

Added support for dinput and xinput, full keyboard slider cell binding (#127), hold-takeovers, button alternation and auto-sliding (PS4 behaviour). See segatools.ini for a detailed description about everything.

* Split touch handling into backends and added Wintouch touch emulation

Now you can use actual touchscreens as well as mouse emulation was not the greatest when trying to use an actual touchscreen.

* Fixed input issues

gamebtns was always uninitialized, so good luck trying to do anything. How did nobody ever complain about this? lol

* Fixed resolution issues caused by chaining both gfx hooks

The diva-specific hook is the only one we need. Stacking both has strange effects.

* Added support for the MITSUBISHI CP9550DS printer

Q: Why?
A: /shrug

![https://puu.sh/KQlev/ce2ef0efed.bmp](https://puu.sh/KQlev/ce2ef0efed.bmp)

I am not particularly good at this game (or the pass requirements are insane, 23+12 misses out of ~550 is a fail!?), so if someone could test how this feels as opposed to the PS4 version, that would help a lot!

![https://puu.sh/KQldU/fa4c848ff9.png](https://puu.sh/KQldU/fa4c848ff9.png)

Also something that happens but that I can't reliably reproduce is that my aime card reader randomly becomes NG after a dozen game starts until I delete eeprom.bin.
If that is the case, the only packet sent is SEND_HEX_DATA.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/129
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-08-10 15:41:40 +00:00
Dniel97 c92119b4c5 misc: fix path compiling, fix apm3 server detection 2026-07-23 21:25:49 +02:00
kyoubate-haruka 7593176cad fix msvc 2026-07-20 09:43:52 +02:00
kyoubate-haruka d29a3926ab apm: Fix distribution server handling, abaas log symlinks, add extra buttons for dinput (#123)
Requires https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/8

This adds the following:

1. Fixes `am::abaas::FileSearchSuite::isAvailableAbsolutePath: Line259  ERROR: folder is unavailable (Y:\SDEM\log\\SDFU)` by hooking `DeviceIoControl` with `FSCTL_SET_REPARSE_POINT`.

Sega decided to use the most bizzare way possible of creating symbolic links. These are created in the AbaaS log directory inside SDEM and point to the appdata directories for the sub-games.

Magic numbers have been taken from amdaemon decompilation. That whole API is very sparsely documented on the Microsoft side.

2. Fixes distribution server settings not applying.

Unlike most other games, the daemon config files do not have dipswitch filters in them. Instead the distribution setting is determined by running `hwvalue.exe` twice and checking it's exit code. This has been added to `launch.bat` and requires the linked addition for inject.

3. Implemented `get_opbtns` and added extra buttons for dinput.

* `get_opbtns` existed but was never implemented. Added the ability to bind dinput buttons for test/service.
* DirectInput is weird. The controller I'm using is sending directional keys as buttons rather than a D-Pad, so I was unable to bind it. These extra directional buttons can be bound in addition to the bindings that exist for a D-Pad.

4. Fixes audio in Rolling Gunner by setting the CWD to the root of the C:\ drive before starting a game.

lol. lmao even.

5. Add a `DefineDosDevice` for Y:\ to fix Blazblue crashing

They hardcoded the damn path to appdata instead of retrieving it from the apm.dll...

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/123
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-07-19 08:25:54 +00:00
kyoubate-haruka fab190272c nusec: add data persistence (#124)
Adds an opt-in toggle to make keychip data (playcount, log, etc.) persistent into a file located in the DEVICE folder.

Now why you would want to do that, I don't know myself. But higher accurracy to the real thing is always cool.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/124
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-07-19 08:21:03 +00:00
グローランプ 89bd77e306 IO: Resolve IO DLL paths from environment variables (#119)
## Summary

Adds a unified mechanism for locating third-party IO DLLs through environment
variables, on top of the existing per-game `[xxxio] path=` INI setting.

## Changes

For each IO DLL, the path is resolved in this order:

1. The section-specific INI value, e.g. `[mai2io] path=`.
2. The section-specific environment variable, e.g. `SEGATOOLS_MAI2IO_PATH`.
3. `SEGATOOLS_IO_ROOT` joined with the default IO DLL filename, e.g.
   `%SEGATOOLS_IO_ROOT%\mai2io.dll`.
4. Empty path, which keeps the built-in IO implementation (unchanged default).

INI and environment-variable paths are run through Windows environment-variable
expansion, so values such as `%SEGATOOLS_IO_ROOT%\mai2io.dll` are valid in the
INI directly.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/119
Co-authored-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
Co-committed-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
2026-07-08 20:23:08 +00:00
kyoubate-haruka 8da836ccfb epay: compatibility fixes (fixes #109) (#110)
Untested, I don't have a real e-money server to verify this with

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/110
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-07-05 15:25:57 +00:00
Hay1tsme ea0efdc080 Merge pull request 'spike: add ability to change to hex rvas' (#117) from Haruka/segatools:spike_hex into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/117
2026-06-23 00:51:04 +00:00
Hay1tsme e0d18cf5c2 Merge pull request 'nfc: add setting to change FeliCa PMm to read as FeliCa Mobile' (#118) from Haruka/segatools:mobile_felica into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/118
2026-06-23 00:48:41 +00:00
Hay1tsme fb71dab20e Merge pull request 'netenv: add redirectBroadcast toggle and stop broadcast log spam' (#104) from Gl0w1amp/segatools:feature/netenv-broadcast-toggle into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/104
2026-06-23 00:45:43 +00:00
Gl0w1amp c3af3ced3a Merge branch 'develop' into feature/netenv-broadcast-toggle 2026-06-19 17:16:08 +00:00
azaneko c1527df801 Merge branch 'develop' into develop 2026-06-18 02:18:35 +00:00
kyoubate-haruka a8f75521d5 nfc: add setting to change FeliCa PMm to read as FeliCa Mobile 2026-06-12 11:44:31 +02:00
kyoubate-haruka 700efa8d85 spike: add ability to change to hex rvas 2026-06-11 10:25:42 +02:00
Hay1tsme 5d330238d8 Merge pull request 'Get amGfetcher working ("DownloadOrder")' (#112) from Haruka/segatools:gfetcher into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/112
2026-06-09 04:11:21 +00:00
Azalea fd1e970b0a [+] chusan fullscreen alt+tab crash fix 2026-06-08 20:21:52 -04:00
Hay1tsme db85fe083e Merge pull request 'sekito: save infrared pattern to file' (#111) from Haruka/segatools:sgt_print_infrared into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/111
2026-05-31 00:13:08 +00:00
kyoubate-haruka ffe569297e vfs: add toggle to intentionally break download process 2026-05-30 11:37:17 +02:00
kyoubate-haruka ad7f6bc800 misc: rename NextProcess.txt file setting 2026-05-30 10:20:09 +02:00
kyoubate-haruka de82acf782 reg: allow opening keys multiple times 2026-05-29 12:06:27 +02:00
kyoubate-haruka 268f252d3e misc: add ability to write NextProcess to file 2026-05-28 11:15:01 +02:00
kyoubate-haruka 2a08e3f59f dns: forward AbaaS log server to configured server 2026-05-27 23:24:08 +02:00
kyoubate-haruka 31e5cdf76d reg: add various missing registry keys 2026-05-27 23:23:35 +02:00
kyoubate-haruka 6b1f494559 path: hook GetDiskFreeSpaceW for amGfetcher 2026-05-25 11:32:35 +02:00
kyoubate-haruka 0bb318f58c sekito: save infrared pattern to file 2026-05-25 11:30:35 +02:00
Dniel97 e903f206a6 Merge pull request 'sekito: fix second page overwriting first page' (#108) from Haruka/segatools:fix_sgt_print into develop
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/108
2026-05-12 07:59:59 +00:00
kyoubate-haruka abe1a9d77e sekito: fix second page overwriting first page 2026-05-06 11:28:15 +02:00
グローランプ d0d470c679 netenv: add redirectBroadcast configuration option to control UDP broadcast redirection 2026-04-13 00:18:32 +10:00
グローランプ f4841280e7 netenv: enhance broadcast logging to prevent log spamming by tracking unique source/destination pairs 2026-04-13 00:12:49 +10:00
Gl0w1amp 2c2b8b11b4 Fix mai2 memory leak via LED 15070 rate-limiting and enhance touch handling (#101)
## Overview
This PR addresses the severe memory leak and performance issues observed in `mai2`, while also introducing improvements to the touch emulation logic.

## Root Cause Analysis
As discussed previously, the root cause of the `mai2` memory leak is not a global `segatools` buffer bug. Instead, the game aggressively spams overlapped empty reads specifically on the `LED 15070` UART. On real hardware, the serial driver naturally throttles this. Under emulation, without a throttle, it hits approximately **260kHz of empty async reads**, which causes the memory usage to explode.

## The Fix
Instead of introducing complex locking mechanisms and condition variables globally in `uart.c`, this PR applies a targeted fix:
* Added a local `Sleep(1)` directly in `common/board/led15070.c` to rate-limit empty reads on the LED path.
* Because this is isolated to LED communications, it completely resolves the memory leak without introducing any lag, livelocks, or overhead to other critical inputs.

## Additional Changes in this PR
Alongside the memory leak fix, this PR includes a few touch-related improvements (as touch emulation was reviewed during the debugging process):
* Enhanced touch input handling and improved auto-scan state management.
* Implemented IOCTL handling for touch input to properly manage communication status.

## Testing
* **mai2:** Tested successfully on multiple machines. The memory leak is completely gone, and the game runs smoothly.
* **chusan:** Tested to ensure no regressions. Sliders and inputs work flawlessly without the lag.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/101
Co-authored-by: Gl0w1amp <gl0w1amp@noreply.gitea.tendokyu.moe>
Co-committed-by: Gl0w1amp <gl0w1amp@noreply.gitea.tendokyu.moe>
2026-04-03 15:13:27 +00:00
kyoubate-haruka 85b8ae02fa misc: add ability to re-enable a few things (#100)
This adds two new config flags to re-enable master registry key access and rebooting. This is needed on real hardware if you want to be able to move to System Test Mode.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/100
Reviewed-by: Dniel97 <dniel97@noreply.gitea.tendokyu.moe>
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-03-04 07:58:01 +00:00
kyoubate-harukaandDniel97 9c67f53902 Add support for Sangokushi Taisen and Eiketsu Taisen (#85)
This adds full support for the Taisen series of games, namely Sangokushi Taisen and Eiketsu Taisen.

Games added:
* Sangokushi Taisen (SDDD)
* Eiketsu Taisen (SDGY)

Devices added:
* CHC-320 printer (SGT)
* "Printer camera" (SGT, unsure what this actually really is)
* CX-7000 printer (EKT)
* Y3CR BD SIE F720MM (SGT, EKT)

Notable changes in the codebase:

* Renamed everything printer specific to seperate between CHC and CX.
* Many new function and registry hooks were added across the board.
* An error is now logged when segatools.ini (or the path in `SEGATOOLS_CONFIG_PATH`) cannot be found.
* Netenv now redirects UDP broadcasts targeted at the subnet that is specified in the keychip configuration. The terminal announces it's presence by broadcasting UDP to 192.168.189.255, this will be redirected to 255.255.255.255.
* Vfs now seperates between absolute and relative paths in `vfs_fixup_path` via an environment variable called `SEGATOOLS_VFS_RELATIVE_PATH`. This is needed because amcapture accesses files as workingdirectory-relative.
* The Y3 board emulation has support for external Y3 I/O dlls. The default implementation (y3ws) that comes with this is a websocket implementation. The docs are available under `doc\y3ws.txt` and a sample card player .html file is under `dist\ekt\card_player.html`. I already know one person that is hosting a massively improved version of it.
  * For websockets, my own websocket implementation is used as a subproject (MIT license): https://github.com/akechi-haruka/cwinwebsocket
  * For JSON, cJSON was embedded (MIT license): https://github.com/DaveGamble/cJSON
  * y3ws reads all printed cards from `DEVICE\print` by default including card back sides. It's up to the client to merge or skip them.

Remarks:
* SGT takes ~8 minutes to load. This seems to be intentional.
* SGT uses some weird TCP network implementation like IDZ. I have not bothered reversing that yet and I have confirmed everything working from the test menu.
* EKT will throw a network error if no terminal is found. You must run the terminal on another computer to be able to launch the satellite.
* EKT has a very bizzare speed glitch that will speed up the ingame unit movement by several 1000% and also slows down cutscene animations by 90%. When this effect is active, you also take a ton more damage than usual. I do not know what causes this and it seems PC specific.
* EKT is very stutter sensitive and will throw error 6401 (I/O timeout) at random when trying to alt+tab or have other things running.
* EKT features a livestream system called Enbu (or "Dojo Upload"). While you are in a match, regardless of vs. AI or another player, the game will record your screen and live-stream it to the Enbu server as defined by the game server's startup response. The application responsible for that, "AM Capture" will not limit it's recording to the game window, but also anything that overlays the game window (notifications, popups, alt+tabbed windows, web browsers, etc). Since this is live-streamed, killing the process will have no effect afterwards, as the frames showing unwanted things will already have been transmitted. To make people aware of this, a one-time dialog message will pop up when starting EKT. The flag for that is stored in the DEVICE folder.

Closes #25.

Co-authored-by: Dniel97 <Dniel97@noreply.gitea.tendokyu.moe>
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/85
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-02-26 19:31:45 +00:00
Dniel97 b9e714dd1d touch: always show cursor if enabled 2026-02-11 23:39:09 +01:00
Dniel97 ef3fa640fd diva: small touch controller improvements 2026-02-09 21:29:36 +01:00
Dniel97 c24363b65d diva: add ELO touch support, thanks @emihiok 2026-02-08 18:17:53 +01:00
Dniel97 351188d285 change MAX_REDIRECTIONS from 64 to 8 2026-02-08 12:21:04 +01:00
kyoubate-haruka a3ac466dba Vfs: Add ability to redirect arbitary paths (= serial ports) (#62)
As someone running several games on the same cabinet that share most of the hardware (like KCA and FGO), it's a bit of a hassle switching the COM ports of the hardware around all the time.

This commit adds the ability to place arbitary path redirections in segatools.ini, which is mostly useful for hardcoded serial ports.
Technically this would also allow you to redirect arbitary paths, but I haven't tested that yet.

An example that I personally use is:
```
[vfs]
amfs=amfs
appdata=.
option=option

; aime reader
redirection0from=\\.\COM10
redirection0to=\\.\COM3
; rfid reader
redirection1from=\\.\COM12
redirection1to=\\.\COM2
; POP led begone
redirection2from=\\.\COM9
redirection2to=\\.\COM90
; partition to pop
redirection3from=\\.\COM11
redirection3to=\\.\COM9
```

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/62
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-02-08 11:12:02 +00:00
グローランプ 21e5238b0a aimeio: Implement full aime reader function in aimeio (#94)
This PR implements the missing NFC, FeliCa, and Mifare command handlers in `aimeio`. This expands the reader's capability to support games and tools that utilize these specific radio functions.

**Changes:**
* Implemented NFC radio control functions.
* Added MIFARE and FeliCa command handling.
* Updated `aimeio` DLL exports and hook definitions.

**Testing Status:**
* I have verified the implementation using a virtual `aimeio` test environment, and the command handling works as expected.
   But I currently do not have access to a physical card reader, so haven't been able to verify the behavior on actual hardware yet.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/94
Co-authored-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
Co-committed-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
2026-02-08 11:01:01 +00:00
Dniel97 966eeeeb87 mercury: update mystery cmds, add fg detect, cleanup 2026-01-19 19:51:48 +01:00
Dniel97 2475b48ef3 misc: fix foreground window issues, enable by default 2026-01-09 15:36:10 +01:00
Dniel97 a2bfd840d6 idac: improve DNS hooking 2026-01-09 15:34:30 +01:00
kyoubate-haruka 3182720890 ewf: dynamic allocation to shrink output binary size (#92)
as noted on discord

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/92
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-01-08 20:20:02 +00:00
グローランプ bf8f3dd6f9 aimeio-vfd: Add VFD text forwarding and state callbacks to AIME IO (#90)
## Summary

- feat(aimeio): add VFD text forwarding API and wire through DLL/VFD backend
- feat(aimeio): add VFD state callback and export symbols across hooks
- refactor(aimeio): rename VFD callbacks and align VFD parsing
- feat(aimeio): extend VFD state fields for richer reporting

## Description
This PR expands the AIME IO VFD interface by adding text forwarding and a VFD state callback, then wires them through the AIME DLL and VFD backend.
It also renames VFD callbacks to align parsing behavior, updates all hook exports accordingly, and extends VFD state fields to carry more detailed state data.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/90
Co-authored-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
Co-committed-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
2026-01-04 08:43:52 +00:00
グローランプ 41d7ce111d mai2io/led15070: add LED control APIs and PWM/fade handling (#89)
## Summary

- feat(io4): implement PWM/GPIO support for Billboard and Code Reader lights
- feat(mai2io): expose LED control APIs to support new io4 features
- fix(led15070): correct multi-LED color logic and add fade support

## Description

**io4 & mai2io Updates**
Introduced PWM control and GPIO write support in `io4`. These additions allow `mai2io` to properly drive the **Billboard LEDs** and **Code Reader / Player Camera lights**. The APIs have been exposed through `mai2hook` to facilitate scriptable control of these peripherals.

**led15070 Improvements**
Fixed an issue with the multi-LED color changing logic in the `led15070` driver. This ensures correct color output sequence and includes improvements for fade calculation.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/89
Co-authored-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
Co-committed-by: グローランプ <130208311+Gl0w1amp@users.noreply.github.com>
2025-12-25 20:10:59 +00:00