Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@)
Expand Down Expand Up @@ -457,6 +458,7 @@ dist:
cp third_party/fonts/NotoSansThai/OFL.txt "$(DIST)/NotoSansThai-OFL.txt"
cp third_party/fonts/NotoSansHebrew/NotoSansHebrew-Medium.ttf "$(DIST)/" # (Hebrew menus, OFL)
cp third_party/fonts/NotoSansHebrew/OFL.txt "$(DIST)/NotoSansHebrew-OFL.txt"
cp third_party/unihan/LICENSE.txt "$(DIST)/Unihan-LICENSE.txt"
cp third_party/FidelityFX/LICENSE.txt "$(DIST)/FidelityFX-LICENSE.txt" # (AMD FidelityFX SDK, MIT: README "License")
if [ -f build/fsr-dlls/amd_fidelityfx_loader_vk.dll ]; then cp build/fsr-dlls/amd_fidelityfx_*_vk.dll \
build/fsr-dlls/AMD-FidelityFX-DLL-LICENSE.txt "$(DIST)/"; fi # (AMD FSR 4: tools/fetch_fsr_dlls.py; AMD's licence allows binary redistribution with this notice)
Expand Down Expand Up @@ -723,6 +725,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
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTROL.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Most of them rely on addresses found in game version 1.9.0 and are untested on o
| `mem write <addr> <type> <value>` | Write one numeric value; rejects inaccessible ranges and values outside the type |
| `mem scan <type> <value> [tolerance] [region=..] [from=.. to=..] [resident=1]`, `mem scan status`, `mem rescan <changed\|unchanged\|increased\|decreased\|equal <v>\|near <v> <tol>>`, `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 <root> <target> [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 <actor or part of a name> [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] <actor>: value <n>, <added> of <asked>`): weapons, bows and shields stop when the player has no free slot |
| `give <actor, part of a name or its pinyin> [count]` | Put an item in the pouch through the game's own item get, on the next frame in play. An exact actor has priority, followed by partial name and actor matches. If those find nothing, the command looks for pinyin, so `give luyu` finds 鲈鱼 in a Chinese game. A single match is given. Several matches are listed. The log shows what went in the pouch (`[items] <actor>: value <n>, <added> of <asked>`). Weapons, bows and shields stop when the player has no free slot |
| `press <button> [frames]`, `hold <button>`, `release [<button>\|all]`, `stick <l\|r> <x> <y> [frames]`, `input` | Scripted controller input, merged with the real one. Buttons: a b x y l r zl zr plus minus up down left right lstick rstick. Sticks run from -1 to 1, positive y is up |

To use `goto` with a line from an issue, run it in developer mode: `swctl goto "swr:1 x=... y=... z=... yaw=... pitch=... hour=..."`.
Expand Down
7 changes: 7 additions & 0 deletions docs/cheats-and-assists.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Savage Wind was started with `-dev` (see [Teleport and console cheats](#teleport
2. Set the **Amount** (1 to 99). Stackable items such as arrows and materials take the whole amount at once.
3. Press **Add** next to the item. It goes into your pouch through the game's own item pickup.

**Searching a Chinese name** goes by the name's pinyin. The search is typed on the on-screen keyboard, which a
controller drives and which has no input method, so the hanzi themselves can't be typed there: type the readings
instead, without tones, run together or apart. `luyu` finds 鲈鱼, `kaoluyu` 烤鲈鱼, `bingleng` the frozen fish, and `yu`
every name with 鱼 in it. Type `u` or `v` for ü. Search uses one reading per character, so words with a different
reading in context may need a shorter query. With a physical keyboard and an input method, you can also type the
hanzi directly.

If the pouch is full, you get as many as fit, and the tab says how many were added. If you are in a menu or a
cutscene, the request waits until you are back in play. The item list comes from your own game files; nothing of the
game is shipped with Savage Wind.
Expand Down
3 changes: 3 additions & 0 deletions docs/third-party.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
(public domain / MIT), [shaderc](https://github.com/google/shaderc)
(Apache 2.0), [Zig](https://ziglang.org) (MIT), [Capstone](https://www.capstone-engine.org) (BSD),
[Unicorn](https://www.unicorn-engine.org) (GPL 2.0), [python-lz4](https://github.com/python-lz4/python-lz4) (BSD).
- [Unicode Han Database (Unihan 18.0.0)](https://www.unicode.org/Public/18.0.0/ucd/Unihan.zip) - the readings behind the
menus' pinyin search, `kMandarin` of `Unihan_Readings.txt` (`runtime/pinyin_data.inc`, `tools/gen_pinyin_table.py`;
Unicode License v3, `third_party/unihan/LICENSE.txt`).
- Colour LUTs from [FreshLUTs](https://freshluts.com), CC0 1.0, renamed: "Savage Wind" is
[CINEMA 3](https://freshluts.com/luts/219) and "Dormant" is [CARIBE](https://freshluts.com/luts/217), both
uploaded by Andy; "Ember" is [powerful cold](https://freshluts.com/luts/107), uploaded by sagi hershkovich
Expand Down
48 changes: 37 additions & 11 deletions runtime/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// quest items, Korok seeds), cooked dishes (CookResult: they need their effects) and rupees. Each has the name the
// game gives it, <actor>_Name in Message/Msg_<lang>.product.ssarc's ActorType/*.msbt inside Pack/Bootup_<lang>.pack;
// one without a name is left out, and of several actors with one name (armour's upgrade levels, dyes) the first by
// actor name stays.
// actor name stays. The name's pinyin comes with it (runtime/pinyin.h): the menu's search is typed on a controller's
// on-screen keyboard, which has no IME and only ASCII keys, so 鲈鱼 is found by "luyu".
//
// Adding: the pause menu data's item get (1.9.0 0x7000d921bc; x0 the pause menu data, x1 the item's name as a
// sead::SafeString, w2 its value, x3 its weapon modifier or NULL) is what picking an item up calls: a stack's value
Expand All @@ -27,6 +28,7 @@
#include "kernel.h"
#include "language.h"
#include "nvn/tegra.h"
#include "pinyin.h"
#include "rt.h"
#include "services/archive.h"
#include "settings.h"
Expand Down Expand Up @@ -76,6 +78,8 @@ static int byml_get_int(const Byml *b, uint32_t node, const char *key, int def)
}

// ---- MSBT: the label's text, UTF-16 to UTF-8, control tags left out
enum { ITEM_NAME_BYTES = 160 };

static void utf8_put(char **o, char *end, uint32_t c) {
char *p = *o;
if (c < 0x80) { if (p + 1 < end) *p++ = (char)c; }
Expand Down Expand Up @@ -110,7 +114,7 @@ static void msbt_read(const uint8_t *d, size_t n) {
if (len > 5 && !memcmp(d + p + 1 + len - 5, "_Name", 5) && idx < ntxt) {
size_t t0 = txt + rd32(d + txt + 4 + 4 * idx);
size_t t1 = idx + 1 < ntxt ? txt + rd32(d + txt + 8 + 4 * idx) : txt + txt_size;
char buf[160], *o = buf;
char buf[ITEM_NAME_BYTES], *o = buf;
for (size_t q = t0; q + 1 < t1 && q + 1 < n;) {
uint16_t c = rd16(d + q);
q += 2;
Expand Down Expand Up @@ -277,7 +281,12 @@ static void list_read(void) {
for (int i = 0; i < g_nitems; i++)
if (!w || g_items[w - 1].cat != g_items[i].cat || strcmp(g_items[w - 1].name, g_items[i].name)) g_items[w++] = g_items[i];
g_nitems = w;
for (int i = 0; i < g_nitems; i++) ui_register_glyphs(g_items[i].name);
for (int i = 0; i < g_nitems; i++) {
GameItem *it = &g_items[i];
char py[ITEM_NAME_BYTES * PINYIN_UTF8_EXPANSION];
if (pinyin_text(it->name, py, sizeof py)) it->pinyin = copy(py, strlen(py));
ui_register_glyphs(it->name);
}
LOG("[items] %d items can be added\n", g_nitems);
free(d);
}
Expand Down Expand Up @@ -470,24 +479,41 @@ static bool has_text(const char *s, const char *t) { // (ignoring case)
return false;
}

static bool item_has_text(const GameItem *it, const char *text) {
return has_text(it->name, text) || has_text(it->actor, text);
}

static bool item_has_pinyin(const GameItem *it, const char *text) {
return it->pinyin && pinyin_match(it->pinyin, text);
}

bool items_matches(int i, const char *text) {
const GameItem *it = items_at(i);
return it && (item_has_text(it, text) || item_has_pinyin(it, text));
}

static void cmd_give(int argc, char **argv, ControlReply *r) {
if (argc < 2 || argc > 3) { control_fail(r, "Usage: give <actor or part of a name> [count]"); return; }
if (argc < 2 || argc > 3) { control_fail(r, "Usage: give <actor, part of a name or its pinyin> [count]"); return; }
int count = argc == 3 ? atoi(argv[2]) : 1, i = 0, n = items_count();
while (i < n && strcmp(g_items[i].actor, argv[1])) i++;
if (i == n) { // not an actor: the items whose name or actor has this in it. One is given, several are listed
if (i == n) { // keep old name/actor queries working even when a new pinyin match also exists
int found = 0, first = n;
for (int k = 0; k < n; k++) {
if (!has_text(g_items[k].name, argv[1]) && !has_text(g_items[k].actor, argv[1])) continue;
if (!found++) first = k;
bool (*matches)(const GameItem *, const char *);
for (int pass = 0; pass < 2 && !found; pass++) {
matches = pass == 0 ? item_has_text : item_has_pinyin;
for (int k = 0; k < n; k++) {
if (!matches(&g_items[k], argv[1])) continue;
if (!found++) first = k;
}
}
if (!found) { control_fail(r, "No item has this in its name or actor"); return; }
if (!found) { control_fail(r, "No item has this in its name, actor or pinyin"); return; }
if (found > 1) {
// (the fields for scripts, the lines for the console, which prints them instead)
char list[2048] = "";
size_t at = 0;
int shown = 0;
for (int k = first; k < n && shown < 30; k++) {
if (!has_text(g_items[k].name, argv[1]) && !has_text(g_items[k].actor, argv[1])) continue;
if (!matches(&g_items[k], argv[1])) continue;
control_text(r, "%s %s", g_items[k].actor, g_items[k].name);
if (at < sizeof list) at += (size_t)snprintf(list + at, sizeof list - at, "%s%s", shown ? " " : "", g_items[k].actor);
shown++;
Expand All @@ -508,7 +534,7 @@ static void cmd_give(int argc, char **argv, ControlReply *r) {

void control_items_init(void) {
static const ControlCmd cmds[] = {
{"give", "<actor or part of a name> [count]", "Put an item in the pouch, in play (several matches: lists them)", cmd_give},
{"give", "<actor, part of a name or its pinyin> [count]", "Put an item in the pouch, in play (several matches: lists them)", cmd_give},
};
control_register(cmds, (int)(sizeof cmds / sizeof *cmds));
}
4 changes: 4 additions & 0 deletions runtime/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum { ITEMFX_NONE, ITEMFX_ATTACK, ITEMFX_DEFENSE, ITEMFX_CLIMB, ITEMFX_BEAM, IT
typedef struct {
const char *actor; // "Weapon_Sword_001"
const char *name; // in the text language, UTF-8
const char *pinyin; // the name's readings, syllables spaced ("kao lu yu"): what the search finds it by too
int cat; // ITEMCAT_*
int value; // what the item get is given for one: durability x 100 (weapons, bows, shields), else 1
bool stack; // one pouch entry holds many (arrows, materials)
Expand All @@ -36,6 +37,9 @@ typedef struct {
// item get in the game code)
int items_count(void);
const GameItem *items_at(int i);
// Does item i match a search text: its name, its actor, or the pinyin of its name ("luyu" finds 烤鲈鱼 - the menu's
// search is typed on a controller's ASCII keyboard, which has no IME, so a Chinese name needs the reading)
bool items_matches(int i, const char *text);
bool items_available(void); // the game code has the item get (its sites were found)
// Puts `count` of item i in the pouch on the game thread's next frame in play (a stack takes them at once, anything
// else one entry each, at most ITEMS_MAX_EACH). false: the queue is full.
Expand Down
89 changes: 89 additions & 0 deletions runtime/pinyin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Pinyin for the menus' search fields: see runtime/pinyin.h. The table is the Unicode Han Database's kMandarin
// (runtime/pinyin_data.inc), so nothing here comes from the game: a character the table has no reading for (or one
// that is no hanzi at all) simply keeps its own text in the search string.
#include "pinyin.h"

#include <ctype.h>
#include <stdint.h>
#include <string.h>

#include "pinyin_data.inc"

_Static_assert(PINYIN_REQUIRED_EXPANSION <= PINYIN_UTF8_EXPANSION, "pinyin table exceeds the output capacity bound");

// The reading of a codepoint, NULL when the table has none
static const char *reading_of(uint32_t cp) {
int lo = 0, hi = PINYIN_CODEPOINTS - 1;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
uint32_t c = g_pinyin_codepoints[mid];
if (c == cp) return g_pinyin_readings + g_pinyin_offsets[mid];
if (c < cp) lo = mid + 1;
else hi = mid - 1;
}
return NULL;
}

// The next UTF-8 codepoint, *p moved past it; -1 for a byte that isn't the start of one (one byte on)
static uint32_t utf8_next(const char **p) {
const unsigned char *s = (const unsigned char *)*p;
uint32_t c = s[0];
int more = c >= 0xf0 ? 3 : c >= 0xe0 ? 2 : c >= 0xc0 ? 1 : 0;
if (!more) { *p += 1; return c; }
for (int k = 1; k <= more; k++)
if ((s[k] & 0xc0) != 0x80) { *p += 1; return (uint32_t)-1; }
uint32_t cp = more == 3 ? c & 0x07 : more == 2 ? c & 0x0f : c & 0x1f;
for (int k = 1; k <= more; k++) cp = cp << 6 | (s[k] & 0x3f);
*p += more + 1;
return cp;
}

static void put(char *out, size_t cap, size_t *at, bool *fits, char c) {
if (*at + 1 < cap) out[(*at)++] = c;
else *fits = false;
}

// pinyin_text lowercases literal ASCII, so only a reading containing ü can emit V.
static bool same_letter(unsigned char have, unsigned char want) {
if (want >= 'A' && want <= 'Z') want = (unsigned char)(want - 'A' + 'a');
return have == 'V' ? want == 'u' || want == 'v' : have == want;
}

bool pinyin_text(const char *utf8, char *out, size_t cap) {
size_t at = 0;
bool fits = true;
if (!cap) return false;
out[0] = 0;
for (const char *p = utf8; *p;) {
const char *start = p;
uint32_t cp = utf8_next(&p);
const char *r = reading_of(cp);
if (r) {
if (at) put(out, cap, &at, &fits, ' '); // (syllables apart: what pinyin_text gives out reads back)
for (; *r; r++) put(out, cap, &at, &fits, *r);
} else if (cp < 0x80) {
put(out, cap, &at, &fits, (char)tolower((int)cp));
} else { // no reading: kana, hangul, a broken byte, ... keep the bytes it was
for (const char *q = start; q < p; q++) put(out, cap, &at, &fits, *q);
}
}
out[at] = 0; // (put never goes past cap - 1)
return fits;
}

bool pinyin_match(const char *pinyin, const char *needle) {
while (*needle == ' ') needle++;
if (!*needle) return true;
for (; *pinyin; pinyin++) {
if (*pinyin == ' ') continue;
const char *h = pinyin, *n = needle;
for (;;) {
while (*n == ' ') n++;
while (*h == ' ') h++;
if (!*n) return true;
if (!same_letter((unsigned char)*h, (unsigned char)*n)) break;
h++, n++;
}
}
return false;
}
28 changes: 28 additions & 0 deletions runtime/pinyin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Pinyin for the menus' search fields (runtime/pinyin.c): the reading of each hanzi, from the Unicode Han Database
// (runtime/pinyin_data.inc, tools/gen_pinyin_table.py). A controller types on the on-screen keyboard, which has no
// IME and only ASCII keys (runtime/ui/osk.mm), so a Chinese name is otherwise impossible to search for: with this,
// "luyu" finds 鲈鱼 and everything cooked from it.
#pragma once
#include <stdbool.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

// A capacity of this many times the input's UTF-8 byte capacity (including NUL) always fits.
enum { PINYIN_UTF8_EXPANSION = 3 };

// The readings of a UTF-8 text, syllable by syllable ("烤鲈鱼" -> "kao lu yu"), with V marking ü for pinyin_match.
// Characters without a reading keep their bytes (ASCII letters lowercased). Writes at most cap - 1 bytes and a NUL.
// Returns false when the text needed more room (out then holds what fit).
bool pinyin_text(const char *utf8, char *out, size_t cap);

// Does the pinyin of a name (what pinyin_text writes) hold `needle`? Spaces are left out of the comparison, so
// "luyu", "lu yu", "lu" and "kaolu" all find 烤鲈鱼. The case is ignored and both u and v match a pinyin ü.
// An empty needle matches, like has_text.
bool pinyin_match(const char *pinyin, const char *needle);

#ifdef __cplusplus
}
#endif
Loading