From b1d7cb392a7acff21aebf5fd6ee045aed5613f72 Mon Sep 17 00:00:00 2001 From: jiangyangyang Date: Sat, 21 Nov 2026 22:56:09 +0800 Subject: [PATCH 1/2] Cheats: find Chinese item names by their pinyin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Cheats tab lists the items under the name the game's text language gives them, and a controller types its Search on the on-screen keyboard (runtime/ui/osk.mm), which has only ASCII keys and no input method. A Chinese name therefore could not be searched for at all: "fish" did find the fish, since the actors are English (Item_FishGet_C), but 鱼 matched nothing that a controller could type. The names now come with their pinyin readings, and the search looks at them too: `luyu` finds 鲈鱼 and everything cooked from it, `kaoluyu` 烤鲈鱼, `bingleng` the frozen fish, `yu` all 57 names with 鱼 in it. The readings are the Unicode Han Database's kMandarin (Unicode License v3, third_party/unihan), not the game's, so nothing of the game is shipped and every character has one: all 819 names of a 1.9.0 game get a full reading. Tones are dropped and ü is written u, which a `v` (a pinyin IME's key for it) also matches. - runtime/pinyin.c, pinyin.h: a text's readings, and a search over them that leaves the spaces out on both sides, so syllables may be typed together. - runtime/items.c, items.h: GameItem.pinyin, and items_matches() - the name, the actor or the pinyin - which the Cheats tab and the console's `give` command both use now (`give luyu`). - runtime/pinyin_data.inc: 26,712 characters, from tools/gen_pinyin_table.py. - The Search hint says it, in all 13 menu languages. Tested: make test-pinyin (the C unit test, with gcc -fsanitize=address,undefined too, and the table's consistency), clang -fsyntax-only on items.c with the runtime's warning flags, and items_matches' rule run over the 819 names of a 1.9.0 RomFS: luyu 0 -> 8, kaoluyu 0 -> 1, bingleng 0 -> 8, yu 0 -> 57, and every search that matched before still matches (fish 34 -> 34). --- CHANGELOG.md | 5 + Makefile | 13 + docs/CONTROL.md | 2 +- docs/cheats-and-assists.md | 6 + docs/third-party.md | 3 + runtime/items.c | 23 +- runtime/items.h | 4 + runtime/pinyin.c | 89 + runtime/pinyin.h | 25 + runtime/pinyin_data.inc | 3778 ++++++++++++++++++++++++++++++++ runtime/ui/i18n/de.inc | 2 +- runtime/ui/i18n/es.inc | 2 +- runtime/ui/i18n/fr.inc | 2 +- runtime/ui/i18n/he.inc | 2 +- runtime/ui/i18n/it.inc | 2 +- runtime/ui/i18n/ja.inc | 2 +- runtime/ui/i18n/ko.inc | 2 +- runtime/ui/i18n/nl.inc | 2 +- runtime/ui/i18n/pt.inc | 2 +- runtime/ui/i18n/ru.inc | 2 +- runtime/ui/i18n/th.inc | 2 +- runtime/ui/i18n/zh-Hans.inc | 2 +- runtime/ui/i18n/zh-Hant.inc | 2 +- runtime/ui/menu.mm | 4 +- third_party/unihan/LICENSE.txt | 39 + tools/gen_pinyin_table.py | 143 ++ tools/test_pinyin.c | 88 + tools/test_pinyin_table.py | 96 + 28 files changed, 4321 insertions(+), 23 deletions(-) create mode 100644 runtime/pinyin.c create mode 100644 runtime/pinyin.h create mode 100644 runtime/pinyin_data.inc create mode 100644 third_party/unihan/LICENSE.txt create mode 100644 tools/gen_pinyin_table.py create mode 100644 tools/test_pinyin.c create mode 100644 tools/test_pinyin_table.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f22379811..4b5a5ed1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ What changed in each Savage Wind release. The `test` branch holds what the next 2.5 GB less memory (RTX 3060, 1080p: 8.3 -> 5.9 GB) and no longer grows by hundreds of megabytes as you travel. - **Vulkan 1.2 drivers** are taken when they have dynamic rendering, synchronization2 and extended dynamic state 1 and 2 as extensions (without FSR 3, FSR 4 or frame generation). Not confirmed on such a card yet. +- **Cheats: Chinese item names are found by pinyin.** The items are listed under the name your game's text language + gives them, but the search is typed on the on-screen keyboard a controller drives, which has no input method, so a + Chinese name could not be searched for at all. `luyu` now finds 鲈鱼, `kaoluyu` 烤鲈鱼, `bingleng` the frozen fish, + and `yu` every name with 鱼 in it, on a controller or a keyboard. The readings are the Unicode Han Database's, not + the game's (`runtime/pinyin.c`); the console's `give` command reads them the same way. ## Alpha 6 (0.6.0-alpha.6) - 2026-11-15 diff --git a/Makefile b/Makefile index 6df1bf29c..49633f1e0 100644 --- a/Makefile +++ b/Makefile @@ -296,6 +296,7 @@ $(B)/rt/prof_sampler.o: RTFLAGS += -fms-extensions $(B)/rt/memscan_os.o: RTFLAGS += -fms-extensions $(B)/rt/control_places.o: runtime/control_places_data.inc # (the generated table of shrines, Koroks ...) +$(B)/rt/pinyin.o: runtime/pinyin_data.inc # (the hanzi readings, tools/gen_pinyin_table.py) $(B)/rt/%.o: runtime/%.c $(RT_HDRS) @mkdir -p $(dir $@) @@ -723,6 +724,18 @@ test-mods: $(B)/test_mods .PHONY: test-mods +# Pinyin for the search fields (runtime/pinyin.c): the readings of a few ordinary Chinese names, and what a search +# typed on a controller's ASCII on-screen keyboard finds with them +$(B)/test_pinyin: tools/test_pinyin.c runtime/pinyin.c runtime/pinyin.h runtime/pinyin_data.inc + @mkdir -p $(B) + $(CC) -O1 -Wall -Wextra -Werror -std=gnu11 -Iruntime -o $@ tools/test_pinyin.c runtime/pinyin.c + +test-pinyin: $(B)/test_pinyin + $(B)/test_pinyin + $(firstword $(PY) python3) tools/test_pinyin_table.py + +.PHONY: test-pinyin + $(B)/test_game_file_size: tools/test_game_file_size.c runtime/game_file_size.c runtime/game_file_size.h runtime/game_files.h @mkdir -p $(B) $(CC) -O1 -Wall $(OSFLAGS) -Iruntime -o $@ tools/test_game_file_size.c runtime/game_file_size.c diff --git a/docs/CONTROL.md b/docs/CONTROL.md index 51192ae5d..d8196d44a 100644 --- a/docs/CONTROL.md +++ b/docs/CONTROL.md @@ -103,7 +103,7 @@ Most of them rely on addresses found in game version 1.9.0 and are untested on o | `mem write ` | Write one numeric value; rejects inaccessible ranges and values outside the type | | `mem scan [tolerance] [region=..] [from=.. to=..] [resident=1]`, `mem scan status`, `mem rescan \|near >`, `mem list [n]`, `mem reset` | Search guest memory for a value on a background thread and narrow the candidates, like a memory scanner. One session is shared by all clients. Poll `mem scan status` | | `mem path [depth=1..6] [window=16..65528]` | Find how to reach `target` from the object at `root`, as pointer offsets. Poll `mem path status`. Heap addresses move between runs but layouts do not, so a chain found once keeps working | -| `give [count]` | Put an item in the pouch through the game's own item get, on the next frame in play. Not an exact actor: the items whose name or actor has that text in them; one is given, several are listed. What went in the pouch is in the log (`[items] : value , of `): weapons, bows and shields stop when the player has no free slot | +| `give [count]` | Put an item in the pouch through the game's own item get, on the next frame in play. Not an exact actor: the items whose name, actor or pinyin has that text in them; one is given, several are listed. The pinyin is what the overlay's Search uses, so `give luyu` finds 鲈鱼 in a Chinese game. What went in the pouch is in the log (`[items] : value , of `): weapons, bows and shields stop when the player has no free slot | | `press