From ac69f3952900e36db3dbe63b68e66b8f2025d78f Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Sun, 1 Nov 2026 14:05:31 +0300 Subject: [PATCH] Read cheat files from the mods folder instead of shipping them A cheat file is now part of a mod: mods//cheats/.txt, or the Atmosphere places inside the mod folder, the file name in any case. The port ships no cheat files any more (the MyNXCheats files and their notice row are gone). - tools/cheats.py --mods builds the code cheats of every mod folder; a cheat's key hashes "/", so two mods' cheats of one name keep their own switches. - The setup reads the cheats from /mods and writes the status to build-cache/cheats.status. - runtime/cheats.c reads the files of the enabled mods the port can use, in the Mods tab order, and the status from build-cache. - A mod with only cheats is usable. The Cheats tab groups the cheats by mod, and the Mods tab says how many cheats a mod brought. - The cheat texts are in all four menu languages. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- THIRD_PARTY_NOTICES.md | 1 - docs/cheats.md | 27 +- docs/tester-guide.md | 5 +- installer/steps.py | 67 ++-- installer/text/en.json | 2 +- installer/text/pt-BR.json | 1 + installer/text/ru.json | 2 +- installer/text/zh-Hans.json | 1 + runtime/cheats.c | 106 ++++-- runtime/cheats.h | 11 +- runtime/mods.c | 12 +- runtime/mods.h | 1 - runtime/mods_probe.c | 2 +- runtime/ui/cheats_tab.cpp | 21 +- runtime/ui/menu.cpp | 14 +- runtime/ui_text.c | 81 +++- runtime/ui_text.h | 8 +- tests/installer_test.py | 29 +- tools/cheats.py | 51 ++- tools/data/cheats/277178B7DBA1B6D4.txt | 444 ---------------------- tools/data/cheats/9B4E43650501A4D4.txt | 496 ------------------------- totk.ini.example | 5 +- 23 files changed, 296 insertions(+), 1093 deletions(-) delete mode 100644 tools/data/cheats/277178B7DBA1B6D4.txt delete mode 100644 tools/data/cheats/9B4E43650501A4D4.txt diff --git a/README.md b/README.md index 8f330b0c..edb0fdf6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md). - Keyboard, mouse and gamepad with remapping, rumble and gyro - Xbox button prompts: LB, RB, LT, RT, Menu and View, and A, B, X and Y as labelled on the button to press, with either button layout - Shaders prepared at install instead of during play -- Atmosphère cheats: files for 1.2.1 and 1.4.3 included, switch them in the menu, or bring your own ([docs/cheats.md](docs/cheats.md)) +- Atmosphère cheats: put a cheat file into a mod and switch its cheats in the menu ([docs/cheats.md](docs/cheats.md)) ## Planned diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 3c744541..2d890f97 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -103,4 +103,3 @@ folder's `licenses/` and in each component's own folder. | `totk_xlate` (NativeAOT linux-x64 build of `tools/xlate/`, linked with the folder's clang, lld and sysroot) | built by `tools/build_xlate.py --llvm --sysroot` | MIT | `bin/totk_xlate` | | AppImage type-2 runtime (static; includes libfuse and squashfuse), the AppImage's first part; appimagetool packs the folder and is not distributed | https://github.com/AppImage/type2-runtime | MIT; libfuse LGPL-2.1; squashfuse BSD-2-Clause | the AppImage header | | MacNativeGames shader variant list | as in the installer release row above | MIT | `data/shader_list.tsv` | -| MyNXCheats cheat files for TotK 1.2.1 and 1.4.3 (data, unchanged below an added credit comment) | https://github.com/Arch9SK7/MyNXCheats @ `6066c82322d4668dd71ff94354fe9e0653a6a4f1` (`The Legend Of Zelda Tears Of The Kingdom/0100F2C0115B6000/cheats/`), by Skyla Kikari (Arch9SK7) and the people that repository credits | None stated: the repository has no licence file, so reuse rests on the author's permission, which is not recorded here | `tools/data/cheats/` | diff --git a/docs/cheats.md b/docs/cheats.md index 2fc271f4..f1646fec 100644 --- a/docs/cheats.md +++ b/docs/cheats.md @@ -1,24 +1,23 @@ # Cheats -The port reads Atmosphère cheat files, the format Switch homebrew and the emulators use. The setup installs a cheat file for 1.2.1 and for 1.4.3, all cheats off: open the menu (F1) and switch them on the Cheats tab. The switches are saved under `[cheats]` in `totk.ini`. +The port reads Atmosphère cheat files, the format Switch homebrew and the emulators use. It ships no cheat files: a cheat file goes into a mod in the `mods` folder next to `totk.exe`, like any other mod ([tester-guide.md](tester-guide.md), "Mods"). Open the menu (F1) and switch the cheats on the Cheats tab. The switches are saved under `[cheats]` in `totk.ini`. -The two files are from [MyNXCheats](https://github.com/Arch9SK7/MyNXCheats) by Skyla Kikari (Arch9SK7) and stay in `tools/data/cheats/` with that credit at the top. The 1.2.1 file has not been tried in game. +## Adding a cheat file -## Adding your own cheat file - -A file of your own replaces the one the setup installed. The setup never overwrites a file you changed. - -1. Find the cheat file for your update. It is named after the first 8 bytes of the game's build id: +1. Find the cheat file for your update. Cheat sites and collections name it after the first 8 bytes of the game's build id: | Update | File | |---|---| | 1.2.1 | `9B4E43650501A4D4.txt` | | 1.4.3 | `277178B7DBA1B6D4.txt` | - The Cheats tab of the menu names the file the installed game reads, and `logs\totk.log` says `cheats: no cheats\.txt` when it is missing. -2. Put it in a `cheats` folder next to `totk.exe`: `cheats\277178B7DBA1B6D4.txt`. -3. Run `TotK-Setup.exe` again on the same folder. It builds the cheats that change the game's code into the game (about three minutes); saves and settings are kept. A file with only data cheats works without this step. -4. Switch the cheats on the Cheats tab of the menu. + The Cheats tab names the file the installed game reads when no mod holds one, and `logs\totk.log` says `cheats: no enabled mod holds cheats/.txt`. +2. Put it in the `cheats` folder of a mod: `mods\My cheats\cheats\277178B7DBA1B6D4.txt`. A download laid out for the Switch's SD card or an emulator works as it is: unpack it into a folder of its own under `mods`, and the port finds `atmosphere\contents\0100F2C0115B6000\cheats`, `contents\0100F2C0115B6000\cheats` or `0100F2C0115B6000\cheats` inside it. The file name's case does not matter. +3. Start the game. Cheats that write the game's memory work now. +4. Cheats that change the game's code are greyed out with "run the setup again" until you run `TotK-Setup.exe` again on the same folder. It builds the code cheats of every mod into the game; saves and settings are kept. +5. Switch the cheats on the Cheats tab of the menu. + +The Cheats tab lists the cheats grouped by mod, in the order of the Mods tab. A mod switched off on the Mods tab, or one the port cannot use, contributes no cheats; the change applies at the next start. The Mods tab says how many cheats each mod brought. ## The file format @@ -40,7 +39,7 @@ Standard Atmosphère: a `[name]` line starts a cheat, `{name}` a master cheat th The words above are placeholders: `XXXXXXXX` an offset, `YYYYYYYY` a value. -Each cheat's switch is `cheat_ = 1`, where the hash is FNV-1a 32 of the cheat's name. Two files that use the same names, for example one per update, share their switches. +Each cheat's switch is `cheat_ = 1`, where the hash is FNV-1a 32 of `/`. A name repeated in one file gets `#2`, `#3` and so on. Renaming a mod's folder resets its cheats' switches to off. ## How cheats run @@ -54,7 +53,7 @@ The game's code is compiled ahead of time, so a cheat cannot write new instructi | master | `{name}` with code writes | A patch set that is always on. | | restore | Writes back only the game's original instructions | Not needed: switching a cheat off restores them. Greyed out. | -A cheat whose code writes call or jump into a code cave the cheat writes itself (into main's zero padding) gets the cave inlined at the call site. A code cheat added to the file or edited after the setup ran is greyed out until the setup runs again; a data cheat runs at once. +A cheat whose code writes call or jump into a code cave the cheat writes itself (into main's zero padding) gets the cave inlined at the call site. The setup builds the code cheats of every mod in the `mods` folder, switched on or off, so switching a mod on later needs only a restart. A code cheat added or edited after the setup ran is greyed out until the setup runs again; a data cheat runs at the next start. Not supported, and shown greyed out with the reason: @@ -63,4 +62,4 @@ Not supported, and shown greyed out with the reason: - code writes mixed with other opcodes, except the button pattern above; - code writes that change the CPU flags differently from the game's instruction, or code caves with branches or pc-relative instructions. -`cheats\.status`, written by the setup, records which cheats were built and how; the log line `cheats: ...` sums it up at start. +`build-cache\cheats.status` next to `totk.exe`, written by the setup, records which cheats were built and how; the log line `cheats: ...` sums them up at start. When the code cheats cannot be built, the setup warns and installs the game without them. diff --git a/docs/tester-guide.md b/docs/tester-guide.md index acab477d..72405204 100644 --- a/docs/tester-guide.md +++ b/docs/tester-guide.md @@ -68,7 +68,10 @@ it up or down. When two mods change the same file, the higher one wins. of files stays off as a whole until they are. - Mods with their own code (`exefs/subsdk*` or a replaced `exefs/main`, such as UltraCam) never load, their RomFS files included. -- Cheat files (`/cheats/.txt`) are listed but not loaded yet. +- Cheats: an Atmosphère cheat file goes into a mod's `cheats` folder (`mods//cheats/.txt`, the + build id `277178B7DBA1B6D4` for 1.4.3, `9B4E43650501A4D4` for 1.2.1). The Cheats tab of the menu switches them. + Cheats that write memory work at the next start; cheats that change the game's code need the setup run again on + the install folder. The port ships no cheat files. Details: [cheats.md](cheats.md). The log names every mod at the start (`mods: : ...`) and how many of its files it serves. diff --git a/installer/steps.py b/installer/steps.py index 23ba1688..fa6a67e0 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -711,31 +711,26 @@ EMITTED = re.compile(r'^emitted (\d+)/(\d+) chunks') DISCOVERED = re.compile(r'^(\w+): \d+ functions \(.*discovery') -def bundled_cheats(ctx): - """The folder of cheat files the release carries, one per update, tools/data/cheats/.txt.""" - return ctx.layout.tools / 'data' / 'cheats' +CHEAT_PLACES = ('cheats', 'atmosphere/contents/0100F2C0115B6000/cheats', 'contents/0100F2C0115B6000/cheats', + '0100F2C0115B6000/cheats') def cheat_files(ctx): - """The Atmosphere cheat files in /cheats, for the lift key. All of them: the one the build reads goes by the - build id of the installed main, and the keys are computed before Extract runs (runner plan), when a fresh install - has no main and an update may still have another version's. The .status files beside them are lift's own output. - A file the same as the bundled one of its name is left out, or installing it would change the key of the next run: - the key covers the bundled folder anyway.""" - bundled = bundled_cheats(ctx) - return [f for f in sorted((ctx.dest / 'cheats').glob('*.txt')) - if not (bundled / f.name).is_file() or f.read_bytes() != (bundled / f.name).read_bytes()] + """The Atmosphere cheat files of the mods folder (/mods//cheats/*.txt and the Atmosphere places, as + tools/cheats.py finds them), for the lift key. All of them: the ones the build reads go by the build id of the + installed main, and the keys are computed before Extract runs (runner plan), when a fresh install has no main and an + update may still have another version's.""" + mods = ctx.dest / 'mods' + if not mods.is_dir(): + return [] + return sorted(f for mod in mods.iterdir() if mod.is_dir() for where in CHEAT_PLACES + for f in ((mod / where).glob('*.txt') if (mod / where).is_dir() else ())) -def cheats_file(ctx): - """/cheats/.txt, the Atmosphere cheat file of the installed main (tools/cheats.py), whether or not - it exists.""" - try: - with open(ctx.dest / 'exefs' / 'main', 'rb') as f: - bid = f.read(0x48)[0x40:0x48].hex().upper() - except OSError: - bid = 'unknown' - return ctx.dest / 'cheats' / f'{bid}.txt' +def cheats_status(ctx): + """The build's cheat status file (tools/cheats.py --status), which runtime/cheats.c reads: in build-cache, not in a + mod's own cheats folder, which the player (or TKMM's merge) may empty.""" + return ctx.dest / 'build-cache' / 'cheats.status' class Lift(Step): @@ -743,8 +738,8 @@ class Lift(Step): transient = True def key(self, ctx): - return fingerprint('lift-2', ctx.keys['extract'], ctx.layout.recomp, ctx.layout.patches(game_version(ctx)), - ctx.layout.tools / 'cheats.py', bundled_cheats(ctx), *cheat_files(ctx)) + return fingerprint('lift-3', ctx.keys['extract'], ctx.layout.recomp, ctx.layout.patches(game_version(ctx)), + ctx.layout.tools / 'cheats.py', *cheat_files(ctx)) def current(self, ctx, record): gen = ctx.temp / 'gen' @@ -761,27 +756,25 @@ class Lift(Step): if m: rep.progress('lift', 'emit', int(m.group(1)), int(m.group(2)), 'chunks') - # The code cheats of the cheat file become patch sets (tools/cheats.py); its status file tells the runtime - # which cheats the build has. A player's own file wins over the bundled one, which is installed when there is - # none. The player did not choose a bundled file, so one the tools refuse costs its cheats, not the install. - plain, cheats = layout.patches(game_version(ctx)), cheats_file(ctx) - patches, skipped, bundled = plain, None, bundled_cheats(ctx) / cheats.name - ours = bundled.is_file() and (not cheats.is_file() or cheats.read_bytes() == bundled.read_bytes()) - if ours and not cheats.is_file(): - cheats.parent.mkdir(exist_ok=True) - shutil.copyfile(bundled, cheats) - if cheats.is_file(): + # The code cheats of the mods' cheat files become patch sets (tools/cheats.py); its status file tells the + # runtime which cheats the build has. A cheat file is the player's download, so one the tools refuse costs the + # cheats, not the install: the game is built without them and the setup warns. + plain, status = layout.patches(game_version(ctx)), cheats_status(ctx) + patches, skipped = plain, None + status.unlink(missing_ok=True) # no status: the runtime treats every code cheat as not built + if cheat_files(ctx): combined = ctx.temp / 'patches-cheats.txt' code, log = run_tool(ctx, 'lift', layout.tools / 'cheats.py', - ['--exefs', ctx.dest / 'exefs', '--cheats', cheats, '--patches', patches, - '--out', combined, '--status', cheats.with_suffix('.status')]) - if code and not ours: - raise InstallError('lift.failed', code=code, log=str(log)) + ['--exefs', ctx.dest / 'exefs', '--mods', ctx.dest / 'mods', '--patches', plain, + '--out', combined, '--status', status]) patches, skipped = (plain, log) if code else (combined, None) + if code: + status.unlink(missing_ok=True) args = ['--exefs', ctx.dest / 'exefs', '--out', gen] code, log = run_tool(ctx, 'lift', layout.recomp / 'gen.py', args + ['--patches', patches], parse) - if code and ours and patches != plain: + if code and patches != plain: skipped = log + status.unlink(missing_ok=True) remove(gen) code, log = run_tool(ctx, 'lift', layout.recomp / 'gen.py', args + ['--patches', plain], parse) if code: diff --git a/installer/text/en.json b/installer/text/en.json index 3e9f76cb..f83a62d4 100644 --- a/installer/text/en.json +++ b/installer/text/en.json @@ -94,7 +94,7 @@ "warn.lang_needs_fonts": "Text in {lang} needs the Switch system fonts. Choose the firmware folder (Contents/registered) to install them; without it some text may not show.", "warn.npdm_differs": "main.npdm differs from the reference {version} dump; only the code modules are used.", - "warn.cheats_skipped": "The bundled cheats that change the game's code could not be built; the game installs without them. Details: {log}", + "warn.cheats_skipped": "The cheats of the mods folder that change the game's code could not be built; the game installs without them. Details: {log}", "warn.xbox_prompts_failed": "The Xbox button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}", "warn.shaders_skipped": "The graphics driver crashed while building some shaders, so {count} were left out of the preparation. The game builds them when it first needs them, and the driver may crash there too; a driver update may fix it. Details: {log}", "warn.kernel_old": "Linux {version} lacks the write tracking the game relies on (6.7 or later); the game may run very slowly. Updating the system fixes this.", diff --git a/installer/text/pt-BR.json b/installer/text/pt-BR.json index f56a5f85..08eb8d06 100644 --- a/installer/text/pt-BR.json +++ b/installer/text/pt-BR.json @@ -93,6 +93,7 @@ "cleanup.ini_failed": "Não foi possível gravar o totk.ini: {detail}", "warn.lang_needs_fonts": "Textos em {lang} precisam das fontes de sistema do Switch, que o instalador não extrai; parte do texto pode não aparecer.", + "warn.cheats_skipped": "Não foi possível compilar os cheats da pasta de mods que alteram o código do jogo; o jogo é instalado sem eles. Detalhes: {log}", "warn.npdm_differs": "O main.npdm difere do dump de referência da versão {version}; só os módulos de código são usados.", "warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}", "warn.shaders_skipped": "O driver gráfico travou ao compilar alguns shaders, então {count} ficaram fora da preparação. O jogo os compila quando precisar deles pela primeira vez, e o driver pode travar ali também; uma atualização do driver pode resolver. Detalhes: {log}", diff --git a/installer/text/ru.json b/installer/text/ru.json index 32caa0ca..cf8d4c33 100644 --- a/installer/text/ru.json +++ b/installer/text/ru.json @@ -94,7 +94,7 @@ "warn.lang_needs_fonts": "Для языка «{lang}» нужны системные шрифты Switch. Выберите папку прошивки (Contents/registered), чтобы установить их; без неё часть текста может не отображаться.", "warn.npdm_differs": "main.npdm отличается от эталонного дампа {version}; используются только модули с кодом.", - "warn.cheats_skipped": "Не удалось собрать встроенные читы, меняющие код игры; игра установится без них. Подробности: {log}", + "warn.cheats_skipped": "Не удалось собрать читы из папки модов, меняющие код игры; игра установится без них. Подробности: {log}", "warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}", "warn.shaders_skipped": "Графический драйвер аварийно завершился при сборке части шейдеров, поэтому {count} из них пропущены при подготовке. Игра соберёт их, когда они впервые понадобятся, и драйвер может упасть и там; обновление драйвера может это исправить. Подробности: {log}", "warn.kernel_old": "В Linux {version} нет отслеживания записи, на которое опирается игра (нужна версия 6.7 или новее); игра может работать очень медленно. Обновление системы это исправит.", diff --git a/installer/text/zh-Hans.json b/installer/text/zh-Hans.json index a0c317ed..7a80f25b 100644 --- a/installer/text/zh-Hans.json +++ b/installer/text/zh-Hans.json @@ -93,6 +93,7 @@ "cleanup.ini_failed": "无法写入 totk.ini:{detail}", "warn.lang_needs_fonts": "{lang}文本需要 Switch 系统字体,而安装程序不会提取这些字体;部分文字可能无法显示。", + "warn.cheats_skipped": "无法构建 mods 文件夹中修改游戏代码的金手指;游戏将不含它们进行安装。详情:{log}", "warn.npdm_differs": "main.npdm 与参考的 {version} 导出不同;只使用其中的代码模块。", "warn.xbox_prompts_failed": "无法准备 Xbox 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}", "warn.shaders_skipped": "显卡驱动在编译部分着色器时崩溃,因此有 {count} 个着色器未被预先准备。游戏会在首次需要时编译它们,驱动在那时也可能崩溃;更新驱动可能会解决。详情:{log}", diff --git a/runtime/cheats.c b/runtime/cheats.c index 132b3ebf..4fa54d71 100644 --- a/runtime/cheats.c +++ b/runtime/cheats.c @@ -1,12 +1,14 @@ -// Cheats of an Atmosphere cheat file (cheats.h). The file is cheats\.txt next to totk.exe, the build id the -// first 8 bytes of main's NSO build id, as Atmosphere and the emulators name it. Each cheat's switch is the setting -// TOTK_CHEAT_ (cheat_ under [cheats] in totk.ini). +// Cheats of the mods' Atmosphere cheat files (cheats.h). Each enabled mod the port can use (mods.h) may hold +// .txt in its cheats folder, the build id the first 8 bytes of main's NSO build id, as Atmosphere and the +// emulators name it; the file name's case does not matter. Each cheat's switch is the setting TOTK_CHEAT_ +// (cheat_ under [cheats] in totk.ini), the hash FNV-1a 32 of "/", so two mods' +// cheats of one name keep their own switches. // // Code cheats (opcode 0 writes into main's code) cannot be applied here: the game's code is lifted C. tools/cheats.py -// turns them into patch sets cheat_ when the game is built and writes cheats\.status, one line per -// cheat: name hash, content hash, kind, buttons, note (tools/cheats.py has the format). A cheat whose status line is -// missing or has another content hash was added or edited after the build: a data cheat runs anyway, a code cheat waits -// for the setup to run again. +// turns the code cheats of every mod into patch sets cheat_ when the game is built and writes +// build-cache\cheats.status next to totk.exe, one line per cheat: name hash, content hash, kind, buttons, note +// (tools/cheats.py has the format). A cheat whose status line is missing or has another content hash was added or +// edited after the build: a data cheat runs anyway, a code cheat waits for the setup to run again. // // Data cheats run in a VM after Atmosphere's dmnt cheat VM (opcodes 0-A; the 0xC.. and 0xF.. extensions are not // supported), every presented frame while their switch is on, with registers cleared before each cheat. Memory is the @@ -18,11 +20,13 @@ #include #include #include +#include #include "cfg.h" #include "cheats.h" #include "host.h" #include "input.h" +#include "mods.h" #include "platform/platform.h" #ifdef _WIN32 @@ -37,14 +41,16 @@ typedef struct { CheatInfo info; uint32_t *words; int n; + int dup; // 1 for the first cheat of its name in its file, 2 for the next ... int set; // patch set, -1 none volatile int32_t on; char note[STATUS_MAX]; } Cheat; static Cheat *g_cheats; -static int g_n, g_vm; // g_vm: some cheat needs cheats_frame -static char g_file[64]; +static int g_n, g_cap, g_vm; // g_vm: some cheat needs cheats_frame +static char g_file[64]; // ".txt" +static int g_files; // mods whose file was read static uint64_t g_main, g_main_size, g_code_end; // main's image; its code with the padding up to .rodata static uint32_t fnv(const char *s, size_t n) { @@ -340,8 +346,9 @@ static void add_word(Cheat *c, uint32_t v, int *cap) { c->words[c->n++] = v; } -static void parse(char *s) { - int cap = 0, wcap = 0; +// Appends the cheats of one mod's file; mod: the mod's folder name (kept). +static void parse(char *s, const char *mod) { + int first = g_n, wcap = 0; for (char *line = s; line && *line;) { char *end = strchr(line, '\n'), *next = end ? end + 1 : NULL; if (end) *end = 0; @@ -349,9 +356,9 @@ static void parse(char *s) { size_t len = strlen(line); while (len && (line[len - 1] == '\r' || line[len - 1] == ' ' || line[len - 1] == '\t')) line[--len] = 0; if (len >= 2 && (line[0] == '[' || line[0] == '{') && (line[len - 1] == ']' || line[len - 1] == '}')) { - if (g_n == cap) { - cap = cap ? cap * 2 : 32; - g_cheats = (Cheat *)realloc(g_cheats, sizeof *g_cheats * (size_t)cap); + if (g_n == g_cap) { + g_cap = g_cap ? g_cap * 2 : 32; + g_cheats = (Cheat *)realloc(g_cheats, sizeof *g_cheats * (size_t)g_cap); if (!g_cheats) rt_fatal("cheats: out of memory"); } Cheat *c = &g_cheats[g_n++]; @@ -362,10 +369,13 @@ static void parse(char *s) { size_t k = strlen(name); while (k && (name[k - 1] == ' ' || name[k - 1] == '\t')) name[--k] = 0; c->info.name = strdup(name); + c->info.mod = mod; c->info.kind = line[0] == '{' ? CHEAT_MASTER : CHEAT_HEADING; c->set = -1; + c->dup = 1; // a repeated name gets "#2", "#3" ... (tools/cheats.py parse) + for (int j = first; j < g_n - 1; j++) c->dup += !strcmp(g_cheats[j].info.name, c->info.name); wcap = 0; - } else if (g_n) { + } else if (g_n > first) { for (char *tok = strtok(line, " \t"); tok; tok = strtok(NULL, " \t")) { char *e; unsigned long v = strtoul(tok, &e, 16); @@ -376,6 +386,27 @@ static void parse(char *s) { } } +// The file g_file in folder, its name in any case, into out; 0 when there is none. +typedef struct { + const char *dir; + char *out; + size_t cap; + int found; +} FindFile; +static int find_cb(const char *name, int kind, uint64_t size, void *ctx) { + (void)size; + FindFile *f = (FindFile *)ctx; + if (kind == PLAT_FS_FILE && !strcasecmp(name, g_file) && + snprintf(f->out, f->cap, "%s/%s", f->dir, name) < (int)f->cap) + f->found = 1; + return !f->found; +} +static int find_file(const char *folder, char *out, size_t cap) { + FindFile f = {folder, out, cap, 0}; + plat_fs_list(folder, find_cb, &f); + return f.found; +} + // The status line of key, its fields split in place; 0 when none. static int status_of(char *status, const char *key, char **fields) { for (char *line = status; line && *line;) { @@ -409,31 +440,38 @@ static void plain_name(char *s) { void cheats_init(void) { const RtLoaded *m = ldr_count() ? ldr_module(0) : NULL; - char dir[PLAT_PATH_MAX], bid[17], path[PLAT_PATH_MAX + 64]; + char dir[PLAT_PATH_MAX], bid[17], path[2400]; // path: a mod's cheats folder (ModInfo.cheats) + the file if (!m || !exe_dir(dir, sizeof dir) || !build_id(bid)) return; g_main = m->base; g_main_size = m->size; g_code_end = m->base + ((m->text_end + 0xFFF) & ~0xFFFull); - snprintf(g_file, sizeof g_file, "cheats" SEP "%s.txt", bid); - snprintf(path, sizeof path, "%s%s", dir, g_file); - char *text = read_text(path); - if (!text) { - rt_log("cheats: no %s", g_file); + snprintf(g_file, sizeof g_file, "%s.txt", bid); + mods_scan(); + for (int k = 0; k < mods_count(); k++) { // the Mods tab's order, top first + const ModInfo *mod = mods_at(k); + if (!mod->enabled || mod->problem != MOD_OK || !mod->cheats[0] || !find_file(mod->cheats, path, sizeof path)) + continue; + char *text = read_text(path); + if (!text) { + rt_log("cheats: %s: cannot read %s", mod->name, path); + continue; + } + parse(text, strdup(mod->name)); + free(text); + g_files++; + } + if (!g_files) { + rt_log("cheats: no enabled mod holds cheats/%s", g_file); return; } - parse(text); - free(text); - snprintf(path, sizeof path, "%scheats" SEP "%s.status", dir, bid); + snprintf(path, sizeof path, "%sbuild-cache" SEP "cheats.status", dir); char *status = read_text(path); int counts[CHEAT_UNSUPPORTED + 1] = {0}, seen_dups = 0; for (int i = 0; i < g_n; i++) { Cheat *c = &g_cheats[i]; - // the name hash: a repeated name gets "#2", "#3" ... (tools/cheats.py parse) - int dup = 1; - for (int j = 0; j < i; j++) dup += !strcmp(g_cheats[j].info.name, c->info.name); - char named[600]; - snprintf(named, sizeof named, dup > 1 ? "%s#%d" : "%s", c->info.name, dup); - seen_dups += dup > 1; + char named[900]; + snprintf(named, sizeof named, c->dup > 1 ? "%s/%s#%d" : "%s/%s", c->info.mod, c->info.name, c->dup); + seen_dups += c->dup > 1; char key[9], content[9]; snprintf(key, sizeof key, "%08X", fnv(named, strlen(named))); size_t tn = (size_t)c->n * 9 + 1, tl = 0; @@ -476,9 +514,9 @@ void cheats_init(void) { for (int i = 0; i < g_n; i++) plain_name((char *)g_cheats[i].info.name); // the hashes above read the file's bytes int on = 0; for (int i = 0; i < g_n; i++) on += g_cheats[i].on && g_cheats[i].info.kind != CHEAT_HEADING; - rt_log("cheats: %s: %d cheats, %d on; %d code, %d while buttons are held, %d data, %d master, %d restore, " - "%d headings, %d need the setup again, %d not supported%s", - g_file, g_n, on, counts[CHEAT_CODE], counts[CHEAT_KEY], counts[CHEAT_DATA], counts[CHEAT_MASTER], + rt_log("cheats: %s in %d mods: %d cheats, %d on; %d code, %d while buttons are held, %d data, %d master, " + "%d restore, %d headings, %d need the setup again, %d not supported%s", + g_file, g_files, g_n, on, counts[CHEAT_CODE], counts[CHEAT_KEY], counts[CHEAT_DATA], counts[CHEAT_MASTER], counts[CHEAT_RESTORE], counts[CHEAT_HEADING], counts[CHEAT_REBUILD], counts[CHEAT_UNSUPPORTED], seen_dups ? " (repeated names numbered)" : ""); } @@ -498,7 +536,7 @@ void cheats_set(int i, int on) { plat_xchg32(&c->on, on != 0); if (c->info.kind == CHEAT_CODE) rt_patch_switch(c->set, on); // CHEAT_KEY: cheats_frame follows the buttons cfg_set(c->info.key, on ? "1" : "0"); - rt_log("cheats: %s %s", c->info.name, on ? "on" : "off"); + rt_log("cheats: %s/%s %s", c->info.mod, c->info.name, on ? "on" : "off"); } void cheats_frame(uint64_t frame) { diff --git a/runtime/cheats.h b/runtime/cheats.h index a6746890..09589b1f 100644 --- a/runtime/cheats.h +++ b/runtime/cheats.h @@ -1,5 +1,5 @@ -// Cheats of an Atmosphere cheat file (cheats.c): cheats\.txt next to totk.exe, switched from the menu's -// Cheats tab. A cheat that writes the game's instructions is a code patch set that tools/cheats.py built into the game +// Cheats of the mods' Atmosphere cheat files (cheats.c): mods\\cheats\.txt of each enabled mod, +// switched from the menu's Cheats tab. A cheat that writes the game's instructions is a code patch set that tools/cheats.py built into the game // (switched with rt_patch_switch); one that writes data runs in the cheat VM every presented frame. #pragma once #include @@ -21,18 +21,19 @@ typedef enum { typedef struct { const char *name; // UTF-8, as in the file + const char *mod; // the mod's folder name; cheats come grouped by mod, in the Mods tab's order const char *note; // why it is unsupported ("" otherwise) CheatKind kind; uint32_t buttons; // CHEAT_KEY: HidNpadButton mask - char key[24]; // its setting, TOTK_CHEAT_ + char key[24]; // its setting, TOTK_CHEAT_/"> } CheatInfo; -void cheats_init(void); // after rt_patches_init: reads the file and its build status +void cheats_init(void); // after rt_patches_init: reads the mods' files and their build status int cheats_count(void); const CheatInfo *cheats_info(int i); int cheats_on(int i); // the player's switch (1 for a master cheat) void cheats_set(int i, int on); // switches at once and sets the cheat's setting (the menu saves totk.ini) -const char *cheats_file(void); // "cheats\.txt" +const char *cheats_file(void); // ".txt", the name the files have for this game version // Every presented frame (the present path): the data cheats' VM and the button state of CHEAT_KEY cheats. void cheats_frame(uint64_t frame); // The button names of a mask ("ZL + Right stick left"), into buf. diff --git a/runtime/mods.c b/runtime/mods.c index 73508222..af350893 100644 --- a/runtime/mods.c +++ b/runtime/mods.c @@ -120,7 +120,6 @@ static const char *problem_name(ModProblem p) { case MOD_EMPTY: return "empty"; case MOD_PLUGIN: return "has a code module (subsdk or main), not supported; the whole mod stays off"; case MOD_EXEFS_LATER: return "ExeFS patches need a game code rebuild, not applied; the whole mod stays off"; - case MOD_CHEATS_LATER: return "cheats only, not loaded yet"; case MOD_BAD_NAME: return "its folder name holds '|', which the order list uses; rename the folder"; default: return "ok"; } @@ -151,12 +150,11 @@ static int scan_cb(const char *name, int kind, uint64_t size, void *ctx) { if (m->exefs[0]) plat_fs_list(m->exefs, exefs_cb, &m->kind); if (m->cheats[0]) plat_fs_list(m->cheats, cheats_cb, &m->kind); // a mod whose code part the port cannot use is off as a whole: its RomFS files may expect that code - m->problem = strchr(m->name, '|') ? MOD_BAD_NAME - : m->kind & MOD_SUBSDK ? MOD_PLUGIN - : m->kind & MOD_EXEFS ? MOD_EXEFS_LATER - : m->kind & MOD_ROMFS ? MOD_OK - : m->kind & MOD_CHEATS ? MOD_CHEATS_LATER - : MOD_EMPTY; + m->problem = strchr(m->name, '|') ? MOD_BAD_NAME + : m->kind & MOD_SUBSDK ? MOD_PLUGIN + : m->kind & MOD_EXEFS ? MOD_EXEFS_LATER + : m->kind & (MOD_ROMFS | MOD_CHEATS) ? MOD_OK + : MOD_EMPTY; m->enabled = !listed(disabled, m->name); nmods++; return 1; diff --git a/runtime/mods.h b/runtime/mods.h index 07d4c311..f4d77917 100644 --- a/runtime/mods.h +++ b/runtime/mods.h @@ -14,7 +14,6 @@ typedef enum { // whole mod stays off (its RomFS files may expect that code) MOD_EXEFS_LATER, // has ExeFS patches (.ips, .pchtxt): a rebuild of the game code applies them, not yet here; the // whole mod stays off until then - MOD_CHEATS_LATER, // only cheat files, which the port does not load yet MOD_BAD_NAME, // its folder name holds '|', the separator of the order keys } ModProblem; diff --git a/runtime/mods_probe.c b/runtime/mods_probe.c index 349d82d5..1307a7c5 100644 --- a/runtime/mods_probe.c +++ b/runtime/mods_probe.c @@ -93,7 +93,7 @@ int probe_mods(void) { CHECK(e->problem == MOD_PLUGIN, "subsdk-only mod is a plugin mod"); CHECK(f->problem == MOD_EMPTY, "empty RomFS folder"); CHECK(g->kind == (MOD_ROMFS | MOD_EXEFS) && g->problem == MOD_EXEFS_LATER, "RomFS + ExeFS mod"); - CHECK(jm->kind == MOD_CHEATS && jm->problem == MOD_CHEATS_LATER && ends_with(jm->cheats, "J/cheats"), + CHECK(jm->kind == MOD_CHEATS && jm->problem == MOD_OK && ends_with(jm->cheats, "J/cheats"), "cheats-only mod"); CHECK(km->kind == MOD_ROMFS && km->problem == MOD_OK && ends_with(km->romfs, "K/romfslite"), "TKMM romfslite"); CHECK(lm->kind == (MOD_ROMFS | MOD_CHEATS) && lm->problem == MOD_OK, "RomFS + cheats, main.npdm is no code"); diff --git a/runtime/ui/cheats_tab.cpp b/runtime/ui/cheats_tab.cpp index cd1967ba..5ab59500 100644 --- a/runtime/ui/cheats_tab.cpp +++ b/runtime/ui/cheats_tab.cpp @@ -1,5 +1,6 @@ -// The Cheats tab of the in-game menu: the cheats of cheats\.txt (cheats.c), a row per cheat in file order and -// a heading per group label; a cheat that cannot be switched here is greyed out with the reason. +// The Cheats tab of the in-game menu: the cheats of the mods' cheat files (cheats.c), a heading per mod in the Mods +// tab's order, then a row per cheat in file order and a line per group label of the file; a cheat that cannot be +// switched here is greyed out with the reason. #include #include @@ -16,22 +17,24 @@ extern "C" void tab_cheats(float scale) { static char line[512], desc[768], buttons[192]; int n = cheats_count(); if (!n) { - snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_NONE), - cheats_file()[0] ? cheats_file() : "cheats\\.txt"); + snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_NONE), cheats_file()[0] ? cheats_file() : ".txt"); opt_text_str(line); opt_end(); return; } - int listed = 0; - for (int i = 0; i < n; i++) listed += cheats_info(i)->kind != CHEAT_HEADING; - snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_FILE), cheats_file(), listed); - opt_text_str(line); for (int i = 0; i < n; i++) { const CheatInfo *c = cheats_info(i); + if (!i || strcmp(c->mod, cheats_info(i - 1)->mod)) { + int listed = 0; + for (int j = i; j < n && !strcmp(cheats_info(j)->mod, c->mod); j++) + listed += cheats_info(j)->kind != CHEAT_HEADING; + snprintf(line, sizeof line, menu_text(UI_MENU_CHEATS_MOD), c->mod, listed); + opt_group_text(line); + } UiTextId text = UI_MENU_CHEAT_CODE_DESC; switch (c->kind) { case CHEAT_HEADING: - if (!strstr(c->name, "TID=")) opt_group_text(c->name); // the file's title line only names the game + if (!strstr(c->name, "TID=")) opt_text_str(c->name); // the file's title line only names the game continue; case CHEAT_CODE: break; case CHEAT_KEY: text = UI_MENU_CHEAT_KEY_DESC; break; diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index d3f100d4..53b7fef2 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -36,6 +36,7 @@ static int g_font_bad; extern "C" { #include "amiibo.h" +#include "cheats.h" #include "cfg.h" #include "fs.h" #include "input.h" @@ -1048,16 +1049,23 @@ static void tab_mods(float scale) { char over[512] = "", other[512] = ""; if (m->overridden) snprintf(over, sizeof over, menu_text(UI_MENU_MODS_OVERRIDDEN), m->overridden, m->overridden_by); if (m->other_version) snprintf(other, sizeof other, menu_text(UI_MENU_MODS_OTHER_VERSION), m->other_version); + char cheat[256] = ""; + if (m->kind & MOD_CHEATS) { // its cheats as read at start, or the file they come from + int count = 0; + for (int j = 0; j < cheats_count(); j++) + count += !strcmp(cheats_info(j)->mod, m->name) && cheats_info(j)->kind != CHEAT_HEADING; + if (count) snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS), count); + else snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS_FILE), cheats_file()); + } UiTextId problem = m->problem == MOD_EMPTY ? UI_MENU_MODS_EMPTY : m->problem == MOD_PLUGIN ? UI_MENU_MODS_SUBSDK : m->problem == MOD_EXEFS_LATER ? UI_MENU_MODS_EXEFS_LATER - : m->problem == MOD_CHEATS_LATER ? UI_MENU_MODS_CHEATS_LATER : m->problem == MOD_BAD_NAME ? UI_MENU_MODS_BAD_NAME : UI_TEXT_COUNT; int k = snprintf(desc, sizeof desc, menu_text(UI_MENU_MODS_ROW_DESC), m->replaced, m->added); if (k >= 0 && k < (int)sizeof desc) - snprintf(desc + k, sizeof desc - k, "%s%s%s%s%s%s\n\n%s", over[0] ? "\n\n" : "", over, - other[0] ? "\n\n" : "", other, problem != UI_TEXT_COUNT ? "\n\n" : "", + snprintf(desc + k, sizeof desc - k, "%s%s%s%s%s%s%s%s\n\n%s", over[0] ? "\n\n" : "", over, + other[0] ? "\n\n" : "", other, cheat[0] ? "\n\n" : "", cheat, problem != UI_TEXT_COUNT ? "\n\n" : "", problem != UI_TEXT_COUNT ? menu_text(problem) : "", menu_text(UI_MENU_MODS_MOVE_HINT)); const char *note = m->enabled && m->problem != MOD_OK ? menu_text(UI_MENU_MODS_UNUSED) : after; int s = opt_text_row(id, m->name, menu_text(m->enabled ? UI_MENU_ON : UI_MENU_OFF), note, desc, true); diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 02f39259..9e905de7 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -173,7 +173,8 @@ static const char *const text_en[UI_TEXT_COUNT] = { "load code modules, so the whole mod stays off.", [UI_MENU_MODS_EXEFS_LATER] = "This mod patches the game code (exefs). Code patches are not supported yet, so the " "whole mod stays off.", - [UI_MENU_MODS_CHEATS_LATER] = "This mod holds only cheat files. Cheats are not supported yet.", + [UI_MENU_MODS_CHEATS] = "Cheats: %d. Switch them on the Cheats tab.", + [UI_MENU_MODS_CHEATS_FILE] = "Cheats for this game version are read at start from cheats\\%s in this mod.", [UI_MENU_MODS_BAD_NAME] = "The folder name contains |, which the mod list uses between names. Rename the folder.", [UI_MENU_MODS_OTHER_VERSION] = "%u of its files are made for another game version and are left out. Look for a " "version of this mod made for your game version.", @@ -414,6 +415,24 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_OV_FMT_FSR] = "AMD FSR 1, sharpness %d%%", [UI_MENU_OV_SCALE_NONE] = "none (1:1)", [UI_MENU_OV_SCALE_BILINEAR] = "bilinear", [UI_MENU_OV_SCALE_DOWN] = "bilinear (FSR only enlarges)", + [UI_MENU_TAB_CHEATS] = "Cheats", + [UI_MENU_CHEATS_NONE] = "No cheats for this game version. A mod's cheats are an Atmosphere cheat file in its " + "cheats folder, named after the game's build: mods\\\\cheats\\%s. Restart the game to " + "read them. Cheats that change the game's code also need the setup run again on this " + "folder.", + [UI_MENU_CHEATS_MOD] = "%s: %d cheats", + [UI_MENU_CHEAT_CODE_DESC] = "Changes the game's code. Switches at once.", + [UI_MENU_CHEAT_KEY_DESC] = "Changes the game's code while you hold %s. Switches at once.", + [UI_MENU_CHEAT_DATA_DESC] = "Writes the game's memory every frame while it is on.", + [UI_MENU_CHEAT_MASTER] = "always on", + [UI_MENU_CHEAT_MASTER_DESC] = "The file's master code: it is always on.", + [UI_MENU_CHEAT_RESTORE] = "not needed", + [UI_MENU_CHEAT_RESTORE_DESC] = "It only writes the game's own code back. Switching a cheat off already does that.", + [UI_MENU_CHEAT_REBUILD] = "run the setup again", + [UI_MENU_CHEAT_REBUILD_DESC] = "This cheat changes the game's code and is new or edited since the game was built. " + "Run the setup again on this folder to build it (about three minutes).", + [UI_MENU_CHEAT_UNSUPPORTED] = "not supported", + [UI_MENU_CHEAT_UNSUPPORTED_DESC] = "This cheat cannot be used with this version of the game:", }; static const char *const text_ru[UI_TEXT_COUNT] = { @@ -565,7 +584,8 @@ static const char *const text_ru[UI_TEXT_COUNT] = { "модули кода, поэтому мод выключен целиком.", [UI_MENU_MODS_EXEFS_LATER] = "Этот мод меняет код игры (exefs). Патчи кода пока не поддерживаются, поэтому мод " "выключен целиком.", - [UI_MENU_MODS_CHEATS_LATER] = "В этом моде только файлы читов. Читы пока не поддерживаются.", + [UI_MENU_MODS_CHEATS] = "Читов: %d. Они включаются на вкладке «Читы».", + [UI_MENU_MODS_CHEATS_FILE] = "Читы для этой версии игры читаются при запуске из cheats\\%s в этом моде.", [UI_MENU_MODS_BAD_NAME] = "В имени папки есть символ |, которым список модов разделяет имена. Переименуйте папку.", [UI_MENU_MODS_OTHER_VERSION] = "Файлов для другой версии игры: %u, они пропущены. Поищите версию этого мода для " "вашей версии игры.", @@ -811,6 +831,23 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_OV_FMT_FSR] = "AMD FSR 1, резкость %d%%", [UI_MENU_OV_SCALE_NONE] = "нет (1:1)", [UI_MENU_OV_SCALE_BILINEAR] = "билинейное", [UI_MENU_OV_SCALE_DOWN] = "билинейное (FSR только увеличивает)", + [UI_MENU_TAB_CHEATS] = "Читы", + [UI_MENU_CHEATS_NONE] = "Для этой версии игры читов нет. Читы мода — это файл читов Atmosphere в его папке cheats " + "с именем по сборке игры: mods\\<мод>\\cheats\\%s. Перезапустите игру, чтобы они " + "прочитались. Для читов, меняющих код игры, ещё раз запустите установщик для этой папки.", + [UI_MENU_CHEATS_MOD] = "%s — читов: %d", + [UI_MENU_CHEAT_CODE_DESC] = "Меняет код игры. Включается и выключается сразу.", + [UI_MENU_CHEAT_KEY_DESC] = "Меняет код игры, пока вы держите %s. Включается и выключается сразу.", + [UI_MENU_CHEAT_DATA_DESC] = "Пока включён, записывает память игры каждый кадр.", + [UI_MENU_CHEAT_MASTER] = "всегда вкл.", + [UI_MENU_CHEAT_MASTER_DESC] = "Главный код файла: включён всегда.", + [UI_MENU_CHEAT_RESTORE] = "не нужен", + [UI_MENU_CHEAT_RESTORE_DESC] = "Он только возвращает исходный код игры. Выключение чита уже делает это.", + [UI_MENU_CHEAT_REBUILD] = "запустите установщик", + [UI_MENU_CHEAT_REBUILD_DESC] = "Этот чит меняет код игры и появился или изменился после сборки игры. Запустите " + "установщик для этой папки ещё раз, чтобы собрать его (около трёх минут).", + [UI_MENU_CHEAT_UNSUPPORTED] = "не поддерживается", + [UI_MENU_CHEAT_UNSUPPORTED_DESC] = "Этот чит нельзя использовать с этой версией игры:", }; static const char *const text_pt_br[UI_TEXT_COUNT] = { @@ -834,7 +871,8 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { "carrega módulos de código, então o mod inteiro fica desligado.", [UI_MENU_MODS_EXEFS_LATER] = "Este mod altera o código do jogo (exefs). Patches de código ainda não são suportados, " "então o mod inteiro fica desligado.", - [UI_MENU_MODS_CHEATS_LATER] = "Este mod tem só arquivos de cheats. Cheats ainda não são suportados.", + [UI_MENU_MODS_CHEATS] = "Cheats: %d. Ligue-os na aba Cheats.", + [UI_MENU_MODS_CHEATS_FILE] = "Os cheats desta versão do jogo são lidos ao iniciar de cheats\\%s neste mod.", [UI_MENU_MODS_BAD_NAME] = "O nome da pasta contém |, que a lista de mods usa entre os nomes. Renomeie a pasta.", [UI_MENU_MODS_OTHER_VERSION] = "%u dos seus arquivos são de outra versão do jogo e ficam de fora. Procure uma versão " "deste mod feita para a sua versão do jogo.", @@ -1235,6 +1273,25 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_FXAA] = "Antisserrilhado do jogo (FXAA)", [UI_MENU_FXAA_DESC] = "A suavização de bordas FXAA do próprio jogo. Borra um pouco os detalhes finos; com o DLAA " "ligado não é necessária.", + [UI_MENU_TAB_CHEATS] = "Cheats", + [UI_MENU_CHEATS_NONE] = "Nenhum cheat para esta versão do jogo. Os cheats de um mod são um arquivo de cheats do " + "Atmosphere na pasta cheats dele, com o nome da build do jogo: mods\\\\cheats\\%s. " + "Reinicie o jogo para lê-los. Cheats que alteram o código do jogo também precisam que o " + "instalador seja executado de novo nesta pasta.", + [UI_MENU_CHEATS_MOD] = "%s: %d cheats", + [UI_MENU_CHEAT_CODE_DESC] = "Altera o código do jogo. Liga e desliga na hora.", + [UI_MENU_CHEAT_KEY_DESC] = "Altera o código do jogo enquanto você segura %s. Liga e desliga na hora.", + [UI_MENU_CHEAT_DATA_DESC] = "Escreve na memória do jogo a cada quadro enquanto está ligado.", + [UI_MENU_CHEAT_MASTER] = "sempre ligado", + [UI_MENU_CHEAT_MASTER_DESC] = "O código mestre do arquivo: está sempre ligado.", + [UI_MENU_CHEAT_RESTORE] = "desnecessário", + [UI_MENU_CHEAT_RESTORE_DESC] = "Ele só escreve de volta o código original do jogo. Desligar um cheat já faz isso.", + [UI_MENU_CHEAT_REBUILD] = "execute o instalador", + [UI_MENU_CHEAT_REBUILD_DESC] = "Este cheat altera o código do jogo e é novo ou foi editado depois que o jogo foi " + "compilado. Execute o instalador de novo nesta pasta para compilá-lo (cerca de três " + "minutos).", + [UI_MENU_CHEAT_UNSUPPORTED] = "não suportado", + [UI_MENU_CHEAT_UNSUPPORTED_DESC] = "Este cheat não pode ser usado com esta versão do jogo:", }; // Simplified Chinese: this row covers the software keyboard and the whole menu, so the menu and the overlay read Chinese @@ -1264,7 +1321,8 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_MODS_EMPTY] = "此文件夹中没有 romfs、exefs 或 cheats 文件。", [UI_MENU_MODS_SUBSDK] = "此模组带有自己的游戏代码(subsdk 插件或替换的 main)。移植版无法加载代码模块,因此整个模组保持关闭。", [UI_MENU_MODS_EXEFS_LATER] = "此模组修改游戏代码(exefs)。目前还不支持代码补丁,因此整个模组保持关闭。", - [UI_MENU_MODS_CHEATS_LATER] = "此模组只有金手指文件。目前还不支持金手指。", + [UI_MENU_MODS_CHEATS] = "金手指:%d 个。在“金手指”标签页中开关。", + [UI_MENU_MODS_CHEATS_FILE] = "此游戏版本的金手指在启动时从此模组的 cheats\\%s 读取。", [UI_MENU_MODS_BAD_NAME] = "文件夹名称含有 |,模组列表用它分隔名称。请重命名该文件夹。", [UI_MENU_MODS_OTHER_VERSION] = "它有 %u 个文件是为其他游戏版本制作的,已被跳过。请寻找适用于你的游戏版本的此模组。", [UI_MENU_MODS_UNUSED] = "未使用", @@ -1760,6 +1818,21 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_DLSS_PERFORMANCE] = "性能", [UI_MENU_FXAA] = "游戏抗锯齿(FXAA)", [UI_MENU_FXAA_DESC] = "游戏自身的 FXAA 边缘平滑。会让细节略微模糊;开启 DLAA 时不需要。", + [UI_MENU_TAB_CHEATS] = "金手指", + [UI_MENU_CHEATS_NONE] = "此游戏版本没有金手指。模组的金手指是它的 cheats 文件夹中以游戏构建命名的 Atmosphere " + "金手指文件:mods\\<模组>\\cheats\\%s。重启游戏后才会读取。修改游戏代码的金手指还需要对此文件夹重新运行安装程序。", + [UI_MENU_CHEATS_MOD] = "%s:%d 个金手指", + [UI_MENU_CHEAT_CODE_DESC] = "修改游戏代码。立即开关。", + [UI_MENU_CHEAT_KEY_DESC] = "按住 %s 时修改游戏代码。立即开关。", + [UI_MENU_CHEAT_DATA_DESC] = "开启时每帧写入游戏内存。", + [UI_MENU_CHEAT_MASTER] = "始终开启", + [UI_MENU_CHEAT_MASTER_DESC] = "文件的主代码:始终开启。", + [UI_MENU_CHEAT_RESTORE] = "无需使用", + [UI_MENU_CHEAT_RESTORE_DESC] = "它只会写回游戏原本的代码。关闭金手指时已经会这样做。", + [UI_MENU_CHEAT_REBUILD] = "重新运行安装程序", + [UI_MENU_CHEAT_REBUILD_DESC] = "此金手指修改游戏代码,并且是在游戏构建后新增或修改的。对此文件夹重新运行安装程序来构建它(约三分钟)。", + [UI_MENU_CHEAT_UNSUPPORTED] = "不支持", + [UI_MENU_CHEAT_UNSUPPORTED_DESC] = "此金手指不能用于此游戏版本:", }; #define SWKBD_ONLY(name, ...) static const char *const name[UI_TEXT_COUNT] = {SWKBD(__VA_ARGS__)} diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 7c254a6b..706e445c 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -74,9 +74,11 @@ typedef enum { UI_MENU_MODS_ROW_DESC, // printf: files it replaces, files it adds (as of this start) UI_MENU_MODS_OVERRIDDEN, // printf: files a higher mod serves instead, that mod's name UI_MENU_MODS_MOVE_HINT, - UI_MENU_MODS_EMPTY, UI_MENU_MODS_SUBSDK, UI_MENU_MODS_EXEFS_LATER, UI_MENU_MODS_CHEATS_LATER, UI_MENU_MODS_BAD_NAME, + UI_MENU_MODS_EMPTY, UI_MENU_MODS_SUBSDK, UI_MENU_MODS_EXEFS_LATER, UI_MENU_MODS_BAD_NAME, UI_MENU_MODS_OTHER_VERSION, // printf: files made for another game version, left out UI_MENU_MODS_UNUSED, // under the switch of a mod the port cannot use + UI_MENU_MODS_CHEATS, // printf: its cheats as read at start + UI_MENU_MODS_CHEATS_FILE, // printf: .txt, when none were read UI_MENU_MODS_FPS60, UI_MENU_MODS_FPS60_DESC, UI_MENU_MODS_RES, UI_MENU_MODS_RES_DESC, UI_MENU_MODS_QUICKMENU, UI_MENU_MODS_QUICKMENU_DESC, @@ -211,8 +213,8 @@ typedef enum { UI_MENU_OV_SCALE_DOWN, // FSR is selected but the image is larger than the window: FSR only enlarges // the Cheats tab (cheats.c): the file, the kinds of cheat and why one cannot be switched UI_MENU_TAB_CHEATS, - UI_MENU_CHEATS_NONE, // "%s": cheats\.txt - UI_MENU_CHEATS_FILE, // "%s": the file, "%d": its cheats + UI_MENU_CHEATS_NONE, // "%s": .txt + UI_MENU_CHEATS_MOD, // "%s": the mod, "%d": its cheats UI_MENU_CHEAT_CODE_DESC, UI_MENU_CHEAT_KEY_DESC /* "%s": the buttons */, UI_MENU_CHEAT_DATA_DESC, UI_MENU_CHEAT_MASTER, UI_MENU_CHEAT_MASTER_DESC, UI_MENU_CHEAT_RESTORE, UI_MENU_CHEAT_RESTORE_DESC, UI_MENU_CHEAT_REBUILD, UI_MENU_CHEAT_REBUILD_DESC, UI_MENU_CHEAT_UNSUPPORTED, UI_MENU_CHEAT_UNSUPPORTED_DESC, diff --git a/tests/installer_test.py b/tests/installer_test.py index e3ebb588..9ebedaf5 100644 --- a/tests/installer_test.py +++ b/tests/installer_test.py @@ -221,9 +221,10 @@ class LiftKeyTest(unittest.TestCase): def key(self): return steps.Lift().key(self.ctx) - def add_cheats(self, name, text): - (self.dest / 'cheats').mkdir(exist_ok=True) - (self.dest / 'cheats' / name).write_text(text) + def add_cheats(self, name, text, mod='Cheats', where='cheats'): + folder = self.dest / 'mods' / mod / where + folder.mkdir(parents=True, exist_ok=True) + (folder / name).write_text(text) def test_extracting_main_keeps_the_key(self): before = self.key() @@ -237,21 +238,19 @@ class LiftKeyTest(unittest.TestCase): added = self.key() self.assertNotEqual(added, before) self.add_cheats('277178B7DBA1B6D4.txt', '[b]') - self.assertNotEqual(self.key(), added) + edited = self.key() + self.assertNotEqual(edited, added) + self.add_cheats('277178B7DBA1B6D4.txt', '[c]', mod='Other', where='atmosphere/contents/0100F2C0115B6000/cheats') + self.assertNotEqual(self.key(), edited) - def test_installed_bundled_file_keeps_the_key(self): - (self.dest / 'no-tools' / 'data' / 'cheats').mkdir(parents=True) - (self.dest / 'no-tools' / 'data' / 'cheats' / '277178B7DBA1B6D4.txt').write_text('[a]') - before = self.key() - self.add_cheats('277178B7DBA1B6D4.txt', '[a]') - self.assertEqual(self.key(), before) - self.add_cheats('277178B7DBA1B6D4.txt', '[edited by the player]') - self.assertNotEqual(self.key(), before) - - def test_status_file_keeps_the_key(self): + def test_status_and_other_files_keep_the_key(self): self.add_cheats('277178B7DBA1B6D4.txt', '[a]') before = self.key() - self.add_cheats('277178B7DBA1B6D4.status', 'written by lift') + (self.dest / 'build-cache').mkdir() + (self.dest / 'build-cache' / 'cheats.status').write_text('written by lift') + self.add_cheats('readme.md', 'not a cheat file') + (self.dest / 'mods' / 'Cheats' / 'romfs').mkdir() + (self.dest / 'mods' / 'Cheats' / 'romfs' / 'a.txt').write_text('a RomFS file') self.assertEqual(self.key(), before) diff --git a/tools/cheats.py b/tools/cheats.py index eb718a3e..5406fe4d 100644 --- a/tools/cheats.py +++ b/tools/cheats.py @@ -1,18 +1,23 @@ -"""Cheat file to code patch sets: the code cheats of an Atmosphere cheat file become patch sets of the lifted game. +"""Cheat files to code patch sets: the code cheats of the mods' Atmosphere cheat files become patch sets of the lifted +game. Lifted code cannot be written to while the game runs, so a cheat that writes instructions into main's .text is turned into `site` lines (recomp/patches.py) when the game is lifted; the runtime (runtime/cheats.c) switches each cheat's set from the in-game menu. A cheat that only writes data (heap, main's data, pointer chains, button conditions) needs no patch: runtime/cheats.c runs it in its cheat VM. - python tools/cheats.py --exefs --cheats .txt --patches --out --status + python tools/cheats.py --exefs --mods --patches --out --status ---out gets the --patches file followed by one set per convertible cheat (`cheat_`, switch TOTK_CHEAT_, -default off) and its sites. --status gets one line per cheat of the file, in file order, tab separated: +The cheat files are /cheats/.txt in each folder of --mods (or the Atmosphere places of that folder, +as runtime/mods.c finds them; the name's case does not matter), the build id the first 8 bytes of main's. Every mod's +file is built, switched on or off: the runtime decides which run. --out gets the --patches file followed by one set +per convertible cheat (`cheat_`, switch TOTK_CHEAT_, default off) and its sites. --status gets one line +per cheat, mods by name, cheats in file order, tab separated: -name hash: FNV-1a 32 of the UTF-8 name (a repeated name: name + "#2", "#3" ...), 8 upper-case hex digits; content +name hash: FNV-1a 32 of "/" in UTF-8 (a name repeated in one file: name + "#2", "#3" ...), +8 upper-case hex digits, so two mods' cheats of one name are apart; content hash: the same over the cheat's words, so the runtime sees an edited cheat that was not rebuilt. kind: code instruction writes, a patch set key instruction writes while buttons are held (8 mask / writes / 21 else / the original words / 20): a patch @@ -64,8 +69,8 @@ class Cheat: self.sites = {} # {offset: [words]} -def parse(text): - """Cheats in file order; words that are not 8 hex digits are skipped.""" +def parse(text, mod): + """Cheats in file order, keyed under the mod folder name; words that are not 8 hex digits are skipped.""" out = [] for no, raw in enumerate(text.splitlines(), 1): s = raw.strip() @@ -81,7 +86,26 @@ def parse(text): seen = {} for c in out: n = seen[c.name] = seen.get(c.name, 0) + 1 - c.key = fnv((c.name if n == 1 else f'{c.name}#{n}').encode()) + c.key = fnv((f'{mod}/' + (c.name if n == 1 else f'{c.name}#{n}')).encode()) + return out + + +TITLE = '0100F2C0115B6000' + + +def cheat_files(mods, bid): + """[(mod folder name, cheat file)] of the folders of mods, by name: /cheats/.txt or its Atmosphere places + (runtime/mods.c find_root), the file name in any case.""" + out = [] + for mod in sorted((d for d in mods.iterdir() if d.is_dir()), key=lambda d: d.name) if mods.is_dir() else []: + for where in ('cheats', f'atmosphere/contents/{TITLE}/cheats', f'contents/{TITLE}/cheats', f'{TITLE}/cheats'): + folder = mod / where + if folder.is_dir(): + f = next((p for p in sorted(folder.iterdir()) if p.is_file() and p.name.lower() == f'{bid}.txt'.lower()), + None) + if f: + out.append((mod.name, f)) + break return out @@ -311,7 +335,7 @@ def classify(main, c): def main(): ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument('--exefs', type=Path, required=True) - ap.add_argument('--cheats', type=Path, required=True) + ap.add_argument('--mods', type=Path, required=True, help='the mods folder next to totk.exe') ap.add_argument('--patches', type=Path, required=True, help='the game version\'s patch file') ap.add_argument('--out', type=Path, required=True, help='the patch file with the cheats added') ap.add_argument('--status', type=Path, required=True) @@ -319,7 +343,8 @@ def main(): sys.stdout.reconfigure(errors='replace') # cheat names in a console without their characters m = Main(args.exefs / 'main') text = args.patches.read_text() - cheats = parse(args.cheats.read_text(encoding='utf-8-sig', errors='replace')) if args.cheats.is_file() else [] + files = cheat_files(args.mods, build_id(args.exefs / 'main')) + cheats = [c for mod, f in files for c in parse(f.read_text(encoding='utf-8-sig', errors='replace'), mod)] sets, sites, status = [], [], [] for c in cheats: classify(m, c) @@ -334,14 +359,14 @@ def main(): status.append(f'{c.key}\t{content}\t{c.kind}\t{c.buttons:X}\t{note}') print(f'cheats: {c.kind:11} {c.name}' + (f' ({note})' if note else '')) if sets: - text += (f'\n# Cheats of {args.cheats.name} (tools/cheats.py)\n' + '\n'.join(sets) + '\n' - + '\n'.join(sites) + '\n') + text += ('\n# Cheats of the mods folder (tools/cheats.py)\n' + '\n'.join(sets) + '\n' + '\n'.join(sites) + '\n') args.out.write_text(text) + args.status.parent.mkdir(parents=True, exist_ok=True) args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8') kinds = {} for c in cheats: kinds[c.kind] = kinds.get(c.kind, 0) + 1 - print(f'cheats: {len(cheats)} in {args.cheats.name}: ' + print(f'cheats: {len(cheats)} in {len(files)} files ({", ".join(mod for mod, _ in files) or "none"}): ' + ', '.join(f'{n} {k}' for k, n in sorted(kinds.items())) + f'; {len(sites)} sites') diff --git a/tools/data/cheats/277178B7DBA1B6D4.txt b/tools/data/cheats/277178B7DBA1B6D4.txt deleted file mode 100644 index 2e306fd6..00000000 --- a/tools/data/cheats/277178B7DBA1B6D4.txt +++ /dev/null @@ -1,444 +0,0 @@ -# TotK 1.4.3 cheats from MyNXCheats by Skyla Kikari (Arch9SK7) and the people that repository credits. -# https://github.com/Arch9SK7/MyNXCheats, commit 6066c82322d4668dd71ff94354fe9e0653a6a4f1 -# The Legend Of Zelda Tears Of The Kingdom/0100F2C0115B6000/cheats/277178B7DBA1B6D4.txt -# Everything below this comment is that file, unchanged. Readers skip the lines before the first [. - -[The Legend of Zelda: Tears of the Kingdom v720896 TID=0100F2C0115B6000 BID=277178B7DBA1B6D4] - -[Restore Code (Use after unchecking any cheats below)] -040A0000 004407D0 F9400008 -040A0000 0031D398 1F080800 -080A0000 006E0838 BD401D00 9B292908 -040A0000 006E0840 BD000260 -040A0000 0078251C BD004668 -040A0000 00782568 BD004668 -040A0000 0233765C 71000508 -040A0000 004C4D14 1E204100 -040A0000 004CB9BC 1E200C20 -040A0000 00324C14 B9400008 -040A0000 0072AE28 1A9F57E0 -040A0000 0072B124 BD400009 -040A0000 004414FC 1A89C115 -040A0000 00441520 52800095 -040A0000 001AE99C 1E212000 -040A0000 001B5B2C 1E280400 -040A0000 006343D0 1E212000 -040A0000 01B7A460 1E201C20 -040A0000 023BBE00 1E204100 -040A0000 023BCD2C 2D1F8260 -040A0000 00335C40 1E2E1008 -040A0000 00335CA0 BD400008 -040A0000 0047E09C 52A7F008 -040A0000 023F0864 97DD371F -040A0000 00BD3788 1E211C41 -040A0000 023F6448 396B6288 -040A0000 00A77B40 0B0300C3 -040A0000 0250767C 5A980715 -040A0000 021ECA9C 1B09A148 -040A0000 00282E58 B9400901 -040A0000 002829F4 B9400901 -040A0000 01B78CD0 12800001 -040A0000 020B2A1C 12800001 -040A0000 01CCC718 1E201C42 -040A0000 020B3ABC 12800001 -040A0000 020B3B98 54FFFE2C -040A0000 003067F4 BD415E80 -040A0000 01F87E08 370001E0 -040A0000 020F6F10 D10183FF -040A0000 020F6F14 FD0013EA -040A0000 007362D0 D101C3FF -040A0000 007362D4 FD001BEA -040A0000 020FC7A4 39407688 -040A0000 020F6FF0 34000248 -040A0000 00736614 340002C8 -040A0000 020FD158 34FFFBE8 -040A0000 020FEDD4 34FFFBE8 -040A0000 00736CE0 394073A8 -040A0000 020F9F9C 340000E8 -040A0000 00736488 34FFFE4D -040A0000 007364F8 394063E8 -040A0000 020FE2BC 34FFFBA8 -040A0000 020FE2BC 34FFFBA8 -040A0000 020FDC68 34FFFB48 -040A0000 020F8068 34000988 -040A0000 020FCCE4 34FFFA88 -040A0000 00ECCDBC 34FFF7E8 -040A0000 01C0BA70 B9401268 -040A0000 0068C15C BD403E69 -040A0000 0068C15C BD403E69 -040A0000 0068C15C BD403E69 -040A0000 0067FCC4 1E2E1003 -040A0000 01FD39CC 1E2E1001 - -[Link] -20000000 - -[№ 1. Inf. Health] -080A0000 02BB9FF8 176219F6 F9400008 -080A0000 02BB9FF0 B9000808 34000048 -040A0000 02BB9FEC B9401808 -040A0000 004407D0 149DE607 - -[№ 2. Inf. Stamina] -040A0000 0031D398 1E204040 - -[№ 3. Inf. Stamina (Use Only For Master Sword Quest)] -080A0000 006E0838 F2B0000F D2A8B76F -040A0000 006E0840 B900026F - -[№ 4. Inf. Battery] -040A0000 0078251C BD004662 -040A0000 00782568 BD004662 - -[№ 5. Inf. Horse Stamina] -040A0000 0233765C D503201F - -[№ 6. Stealth Mode] -040A0000 004C4D14 1E2703E0 -040A0000 004CB9BC 1E2703E0 - -[№ 7. Perfect Thermometer (No Fire, Heat, Cold)] -040A0000 00324C14 52800068 -040A0000 0072AE28 2A1F03E0 -040A0000 0072B124 BD400809 - -[№ 8. Ignore Gloom Effects] -040A0000 004414FC 1A89C135 -040A0000 00441520 2A1F03F5 - -[Link] -20000001 - -[Combat] -20000000 - -[№ 9. Instant Companion Skills (No CDs)] -040A0000 001AE99C 1E212020 -040A0000 001B5B2C 1E282100 -040A0000 006343D0 1E212020 - -[№10. Faster Weapon Charge] -040A0000 01B7A460 1E211000 - -[№11. Faster Bow Charge] -040A0000 023BBE00 1E209000 - -[№12. Quickfire Bow] -040A0000 023BCD2C 291FA268 - -[№13. Damage Multiplier (2x)] -040A0000 00335C40 1E201008 -040A0000 00335CA0 1E201008 - -[№14. Damage Multiplier (4x)] -040A0000 00335C40 1E221008 -040A0000 00335CA0 1E221008 - -[№15. Damage Multiplier (10x)] -040A0000 00335C40 1E249008 -040A0000 00335CA0 1E249008 - -[№16. Damage Multiplier (30x)] -040A0000 00335C40 1E27D008 -040A0000 00335CA0 1E27D008 - -[Combat] -20000001 - -[Movement] -20000000 - -[№17. Hold (X) Moon Jump] -80000004 -580F0000 03AD99B8 -580F1000 00000070 -580F1000 00000040 -580F1000 000000D0 -580F1000 000000C0 -580F1000 00000198 -580F1000 00000038 -780F0000 000000F4 -640F0000 00000000 41200000 -20000000 - -[№18. Glider Speed (1.5x) (Hold A)] -80000001 -040A0000 02D01D70 3F000000 -21000000 -040A0000 02D01D70 3D088889 -20000000 - -[№19. Glider Speed (2.0x) (Hold A)] -80000001 -040A0000 02D01D70 3F28F5C3 -21000000 -040A0000 02D01D70 3D088889 -20000000 - -[№20. Glider Speed (3.0x) (Hold A)] -80000001 -040A0000 02D01D70 3F7D70A4 -21000000 -040A0000 02D01D70 3D088889 -20000000 - -[№21. Glider Speed (3.8x) (Hold A)] -80000001 -040A0000 02D01D70 3FA08312 -21000000 -040A0000 02D01D70 3D088889 -20000000 - -[№22. Movement Speed (2x)] -80000002 -040A0000 0047E09C 52A80008 -21000000 -040A0000 0047E09C 52A7F008 -20000000 - -[№23. Movement Speed (3x)] -80000002 -040A0000 0047E09C 52A80808 -21000000 -040A0000 0047E09C 52A7F008 -20000000 - -[№24. Movement Speed (10x)] -80000002 -040A0000 0047E09C 52A82408 -21000000 -040A0000 0047E09C 52A7F008 -20000000 - -[№25. Dive Boost] -040A0000 023F0864 1E211000 - -[№26. Jump Higher] -040A0000 00BD3788 1E209001 - -[№27. Default Movement is Running] -040A0000 023F6448 52800028 - -[№28. Default Movement is Walking] -040A0000 023F6448 396B6288 - -[Movement] -20000001 - -[Inventory] -20000000 - -[№29. Items x999] -040A0000 00A77B40 52807CE3 - -[№30. Free Shopping] -040A0000 0250767C 1A9813F5 - -[№31. Inf. Equipment Durability] -040A0000 021ECA9C 1B09A3E8 -080A0000 02BB9FE4 D65F03C0 B9000901 -040A0000 02BB9FE0 B9401901 -040A0000 00282E58 94A4DC62 -040A0000 002829F4 94A4DD7B - -[№32. Inf. Arrow(s)] -040A0000 01B78CD0 2A1F03E1 - -[№33. Inf. Zonai Devices] -040A0000 020B2A1C 2A1F03E1 - -[№34. Inf. Zonai Device Duration (No Blink + Despawn)] -040A0000 01CCC718 1E2703E2 - -[№35. Inf. Food Items] -040A0000 020B3ABC 2A1F03E1 -040A0000 020B3B98 17FFFFF2 - -[№36. Inf. Food Buff Timer] -080A0000 02BB9FD8 D65F03C0 BD015E80 -040A0000 02BB9FD4 BD416280 -040A0000 003067F4 94A2CDF8 - -[№37. Inf. Amiibo Usage] -040A0000 01F87E08 D503201F - -[Inventory] -20000001 - -[Map] -20000000 - -[№38. Show All Shrine and Cave Locations] -040A0000 020F6F10 52800020 -040A0000 020F6F14 D65F03C0 -040A0000 007362D0 52800020 -040A0000 007362D4 D65F03C0 - -[№39. Show All Korok Seed Locations (Must Zoom In)] -040A0000 020FC7A4 1400002E - -[№40. Show all All Shrine And Roots] -040A0000 020F6FF0 D503201F - -[№41. Show all All Skyview Towers] -040A0000 00736614 D503201F - -[№42. Show all Tears of the Dragon] -040A0000 020FD158 D503201F - -[№43. Show all Devil Statue] -040A0000 020FEDD4 D503201F - -[№44. Show all village and Stable] -040A0000 00736CE0 52800028 - -[№45. Show all venue not visited] -040A0000 020F9F9C D503201F - -[№46. Show all caves, Wells And Chasm] -040A0000 00736488 D503201F -040A0000 007364F8 52800028 - -[№47. Show all Great Fairy] -040A0000 020FE2BC D503201F - -[№48. Show all Miskos treasure] -040A0000 020FE2BC D503201F - -[№49. Show all old map] -040A0000 020FDC68 D503201F - -[№50. Show all Five Great Temples] -040A0000 020F8068 D503201F - -[№51. Show all All Zonai Device Dispenser] -040A0000 020FCCE4 D503201F - -[№52. Show all game field and restaurant] -040A0000 00ECCDBC D503201F - -[Map] -20000001 - -[Misc] -20000000 - -[№53. Remove 21 Zonai Device Spawn Limit] -040A0000 01C0BA70 52800028 - -[№54. Time Stop] -040A0000 0068C15C D503201F - -[№55. Time Resume] -040A0000 0068C15C BD403E69 - -[№56. Time RW (ZL+R3Left)] -80100100 -040A0000 0068C15C 1E37D009 -21000000 -040A0000 0068C15C BD403E69 -20000000 - -[№57. Time FF (ZL+R3Right)] -80400100 -040A0000 0068C15C 1E27D009 -21000000 -040A0000 0068C15C BD403E69 -20000000 - -[№58. 2x Longer Days] -040A0000 0068C15C 1E2E1009 - -[№59. 3x Longer Days] -040A0000 0068C15C 1E2C1009 - -[№60. 4x Longer Days] -040A0000 0068C15C 1E2A1009 - -[№61. Add 60 Seconds To Mission Timer (L3+R3)] -040A0000 02AA1034 BD401D00 -80000030 -080A0000 02BB9FCC 17FB9C1A BD001D00 -080A0000 02BB9FC4 1E2A2800 1E2B094A -080A0000 02BB9FBC 1E20100B 1E2A094A -080A0000 02BB9FB4 1E27D00A 340000F5 -080A0000 02BB9FAC B9401115 54000120 -080A0000 02BB9FA4 1E202008 BD401D00 -040A0000 02AA1034 140463DC -20000000 - -[№62. Handheld 480p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 000001E0 00000356 - -[№63. Handheld 540p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 0000021C 000003C0 - -[№64. Handheld 612p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 00000264 00000440 - -[№65. Handheld 648p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 00000288 00000480 - -[№66. Default Handheld 720p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 000002D0 00000500 - -[№67. Docked 720p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 00000360 00000600 - -[№68. Docked 810p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 000003CC 000006C0 - -[№69. Default Docked 1080p] -580F0000 03ACDF90 -580F1000 000000D8 -580F1000 00000578 -780F0000 00000010 -680F01D0 00000438 00000780 - -[Misc] -20000001 - -[Environment] -20000000 - -[№70. Disable Fog] -040A0000 0067FCC4 1E2703E3 - -[№71. ReEnable Fog] -040A0000 0067FCC4 1E2E1003 - -[№72. Instant Bloodmoon] -040A0000 01FD39CC 1E3E1001 - -[Environment] -20000001 - -[This set of cheats is created by All Credited, enjoy!] diff --git a/tools/data/cheats/9B4E43650501A4D4.txt b/tools/data/cheats/9B4E43650501A4D4.txt deleted file mode 100644 index 9fb7f810..00000000 --- a/tools/data/cheats/9B4E43650501A4D4.txt +++ /dev/null @@ -1,496 +0,0 @@ -# TotK 1.2.1 cheats from MyNXCheats by Skyla Kikari (Arch9SK7) and the people that repository credits. -# https://github.com/Arch9SK7/MyNXCheats, commit 6066c82322d4668dd71ff94354fe9e0653a6a4f1 -# The Legend Of Zelda Tears Of The Kingdom/0100F2C0115B6000/cheats/9B4E43650501A4D4.txt -# Everything below this comment is that file, unchanged. Readers skip the lines before the first [. - -[The Legend of Zelda Tears of the Kingdom (US) v393216 TID=0100F2C0115B6000 BID=9B4E43650501A4D4] - -[Restore Code (Use after unchecking any cheats below)] -040A0000 0083E86C 6B09011F -040A0000 0064C008 F9400008 -040A0000 009F1DC4 1E212841 -080A0000 00A5DD98 BD401D00 9B292908 -040A0000 00A5DDA0 BD000260 -040A0000 00B96074 BD004668 -040A0000 00B960EC BD004668 -040A0000 01CADA90 71000508 -040A0000 00695E28 4EA81D00 -040A0000 00699360 1E200D00 -040A0000 009E442C 35FFED88 -040A0000 00B7D13C 1A9F57E0 -040A0000 00B7D208 1A9FD7E0 -040A0000 0064C7A8 52800088 -040A0000 0064C92C 1A89C108 -040A0000 009E33BC 3949CA69 -040A0000 009E6874 B9402668 -040A0000 009F5750 3946D289 -040A0000 00BAA738 1E212000 -040A0000 00DAB18C 1E212000 -040A0000 015D79E0 1E201C20 -040A0000 015D7A0C 1E201C20 -040A0000 01D2F89C 4EA81D00 -040A0000 01D2FE5C 2D1F8260 -040A0000 009FA138 1E2E1008 -040A0000 009FA174 BD400000 -040A0000 01E36238 BD400000 -040A0000 01D57248 52800034 -080A0000 01D6EDEC 396C1AA8 37080128 -040A0000 01D6EE0C 1E20CC20 -040A0000 0065B1C8 1E200D28 -040A0000 0065B1E8 1E200908 -040A0000 0171E90C 1E281C08 -040A0000 01D64AA8 940000C0 -040A0000 0107EA8C 1E281C21 -040A0000 01D6AEF0 396B6288 -040A0000 02416324 0B01014A -040A0000 01E8B2A0 5A980716 -040A0000 01B73A14 1B09A148 -040A0000 00836440 B9400901 -040A0000 00835F58 B9400901 -040A0000 015D66C0 12800001 -040A0000 01A6949C 12800001 -040A0000 0118E5CC 1E211C41 -040A0000 01A6D2C0 12800001 -040A0000 01A6D3D0 54FFFCCC -040A0000 009E3B7C BD415E80 -040A0000 00882A54 F9401508 -040A0000 0162A408 52800021 -040A0000 0194C8EC 36000280 -040A0000 01B0433C 2A2003E8 -040A0000 0204BFC8 12000281 -040A0000 02050788 37000339 -040A0000 012E42C8 6B09011F -040A0000 01A5AF78 54FFF26B -040A0000 01FC757C 360000A0 -040A0000 02122D08 360000E0 -080A0000 00EC206C FD0013EA D10183FF -080A0000 00D23F60 FD001BEA D101C3FF -040A0000 00D25670 39407688 -040A0000 00C6A3CC B9401268 -040A0000 00B3920C BD403E68 -040A0000 00D7D69C BD401D00 -040A0000 0280A5D8 1E2E1001 -040A0000 0062E868 1E210800 - -[--SectionStart:Link--] -20000000 - -[♯ 1. Invincible (Ignore Hits)] -080A0000 02B19FF8 D65F03C0 6B09011F -080A0000 02B19FF0 2A0903E8 34000042 -080A0000 02B19FE8 B940EEC2 35000083 -080A0000 02B19FE0 B9406043 F9403842 -080A0000 02B19FD8 F9400442 F94007E2 -080A0000 02B19FD0 37300121 B94032C1 -040A0000 0083E86C 948B6DD9 - -[♯ 2. Inf. Health] -080A0000 02B19FC8 176CC810 F9400008 -080A0000 02B19FC0 B9000808 34000048 -040A0000 02B19FBC B9401808 -040A0000 0064C008 149337ED - -[♯ 3. Inf. Stamina] -040A0000 009F1DC4 1E204041 - -[♯ 4. Inf. Stamina (Use Only For Master Sword Quest)] -080A0000 00A5DD98 F290000F D2A8B76F -040A0000 00A5DDA0 B900026F - -[♯ 5. Inf. Battery] -040A0000 00B96074 BD004669 -040A0000 00B960EC BD004669 - -[♯ 6. Inf. Horse Stamina] -040A0000 01CADA90 D503201F - -[♯ 7. Stealth Mode] -040A0000 00695E28 1E2703E0 -040A0000 00699360 1E2703E0 - -[♯ 8. Ignore Fall Damage & Reaction] -040A0000 009E442C 17FFFF6C - -[♯ 9. Perfect Goldilocks Thermometer (No Hot or Cold)] -040A0000 00B7D13C 2A1F03E0 -040A0000 00B7D208 2A1F03E0 - -[♯10. Ignore Gloom Effects] -040A0000 0064C7A8 2A1F03E8 -040A0000 0064C92C 1A89C128 - -[♯11. Ignore Paralysis & Slow Effects] -080A0000 02B19FB4 D65F03C0 52800169 -080A0000 02B19FAC 54000041 6B02003F -080A0000 02B19FA4 72AF2C22 528D8A02 -080A0000 02B19F9C B845D021 F9400E81 -040A0000 02B19F98 3949CA69 -040A0000 009E33BC 9484DAF7 - -[♯12. Ignore Cold & Freeze Effects] -080A0000 02B19F90 177B3239 177B323A -080A0000 02B19F88 54000041 6B02003F -080A0000 02B19F80 72AF2C22 528D8A02 -080A0000 02B19F78 B845D021 F9400E61 -040A0000 02B19F74 B9402668 -040A0000 009E6874 1484CDC0 - -[♯13. Ignore Fire & Flame Effects] -080A0000 02B19F6C 177B6DF9 177B6DFA -080A0000 02B19F64 54000041 6B02003F -080A0000 02B19F5C 72AF2C22 528D8A02 -080A0000 02B19F54 B845D021 F9400E61 -040A0000 02B19F50 3946D289 -040A0000 009F5750 14849200 - -[--SectionEnd:Link--] -20000001 - -[--SectionStart:Combat--] -20000000 - -[♯14. Instant Companion Skills (No CDs)] -040A0000 00BAA738 1E212020 -040A0000 00DAB18C 1E212020 - -[♯15. No Stamina Cost For Weapon Charge] -080A0000 02B19F48 17AAF6A6 1E2703E0 -080A0000 02B19F40 54000040 7100041F -040A0000 02B19F3C 1E201C20 -040A0000 015D79E0 14550957 - -[♯16. Faster Weapon Charge] -040A0000 015D7A0C 1E211000 - -[♯17. Faster Bow Charge] -040A0000 01D2F89C 1E209000 - -[♯18. Quickfire Bow] -040A0000 01D2FE5C 291FA268 - -[♯19a Damage Multiplier (2x)] -040A0000 009FA138 1E201008 -040A0000 009FA174 1E201000 - -[♯19b Damage Multiplier (4x) ★] -040A0000 009FA138 1E221008 -040A0000 009FA174 1E221000 - -[♯19c Damage Multiplier (10x)] -040A0000 009FA138 1E249008 -040A0000 009FA174 1E249000 - -[♯19d Damage Multiplier (30x)] -040A0000 009FA138 1E27D008 -040A0000 009FA174 1E27D000 - -[♯20. Master Sword Beam Upgrade] -040A0000 01E36238 1E201000 - -[--SectionEnd:Combat--] -20000001 - -[--SectionStart:Movement--] -20000000 - -[♯21. Spider-Man Mode (No Falling While Climbing)] -040A0000 01D57248 2A1F03F4 - -[♯22. Hold (X) Moon Jump] -580F0000 0471DCB0 -580F1000 000000C8 -580F1000 00000178 -580F1000 00000030 -780F0000 000000FC -80000004 -640F01D0 00000000 41200000 -20000000 - -[#8. Character Speed x3 (Hold B)] -040A0000 03877F34 3F800000 -80000002 -040A0000 03877F34 40400000 -20000000 - -[♯23. Glider Speed (3x) (Hold A)] -040A0000 03811EAC 3D088889 -80000001 -040A0000 03811EAC 3E000000 -20000000 - -[♯24a Glider Speed (1.5x)] -080A0000 01D6EDEC 1E2F1002 D503201F -040A0000 01D6EE0C 1E220820 - -[♯25a Glider Speed (2.0x)] -080A0000 01D6EDEC 1E201002 D503201F -040A0000 01D6EE0C 1E220820 - -[♯26a Glider Speed (3.0x)] -080A0000 01D6EDEC 1E211002 D503201F -040A0000 01D6EE0C 1E220820 - -[♯27. Climbing Speed (2x)] -040A0000 0065B1C8 1E209008 - -[♯28. Swimming Speed (3x)] -040A0000 0065B1E8 1E211008 -040A0000 0171E90C 1E221008 - -[♯29a Movement Speed (1x)] -040A0000 03877F34 3F800000 - -[♯29b Movement Speed (1.5x)] -040A0000 03877F34 3FC00000 - -[♯29c Movement Speed (2x) ★] -040A0000 03877F34 40000000 - -[♯29d Movement Speed (3x)] -040A0000 03877F34 40400000 - -[♯30. Dive Boost] -040A0000 01D64AA8 1E211000 - -[♯31. Jump Higher] -040A0000 0107EA8C 1E209001 - -[#12a Attack Speed (1x)] -040A0000 0062E868 1E2E1000 - -[#12b Attack Speed (1.5x) ★] -040A0000 0062E868 1E2F1000 - -[#12c Attack Speed (2x)] -040A0000 0062E868 1E201000 - -[♯32. Default Movement is Running] -040A0000 01D6AEF0 52800028 - -[♯33. Default Movement is Walking] -040A0000 01D6AEF0 396B6288 - -[walk through gate] -040A0000 0020804C FD400678 -040A0000 0020804C 14A447B7 -040A0000 02B19F28 5C000078 -080A0000 02B19F2C 175BB848 FD000678 -040A0000 02B19F34 3F800000 -040A0000 02B19F38 3F800000 -80000101 -040A0000 02B19F38 C2C80000 -040A0000 02B19F34 C2C80000 -20000000 - -[--SectionEnd:Movement--] -20000001 - -[--SectionStart:Inventory--] -20000000 - -[Items x999] -040A0000 02416324 52807CEA - -[♯34. Free Shopping] -040A0000 01E8B2A0 1A9813F6 - -[♯35. Inf. Equipment Durability (Fire will still break it.)] -040A0000 01B73A14 1B09A3E8 -080A0000 02B19E54 D65F03C0 B9000901 -040A0000 02B19E50 B9401901 -040A0000 00836440 948B8E84 -040A0000 00835F58 948B8FBE - -[♯36. Inf. Arrow(s)] -040A0000 015D66C0 2A1F03E1 - -[♯37. Inf. Zonai Devices] -040A0000 01A6949C 2A1F03E1 - -[♯38. Inf. Zonai Device Duration (No Blink + Despawn)] -040A0000 0118E5CC 1E2703E1 - -[♯39. Inf. Food Items] -040A0000 01A6D2C0 2A1F03E1 -040A0000 01A6D3D0 17FFFFE6 - -[♯40. Inf. Food Buff Timer] -080A0000 02B19F20 D65F03C0 BD015E80 -040A0000 02B19F1C BD416280 -040A0000 009E3B7C 9484D8E8 - -[♯41. Inf. Materials & Zonai Devices (Set To Minimum Qty.500)] -080A0000 02B19F14 1775A2D0 F9401508 -080A0000 02B19F0C 1775A2D5 B8695908 -080A0000 02B19F04 B8295904 5400004C -080A0000 02B19EFC 6B0400BF 52803E84 -080A0000 02B19EF4 B8695905 F9401508 -080A0000 02B19EEC 1A9F82E9 6B17013F -080A0000 02B19EE4 54000161 7100F09F -080A0000 02B19EDC 54000060 7107F89F -040A0000 02B19ED8 B9403104 -040A0000 00882A54 148A5D21 - -[♯42a Item Pickup Multiplier (2x)] -040A0000 0162A408 52800041 - -[♯42b Item Pickup Multiplier (4x)] -040A0000 0162A408 52800081 - -[♯42c Item Pickup Multiplier (8x)] -040A0000 0162A408 52800101 - -[♯43. Inf. Amiibo Usage] -040A0000 0194C8EC 14000014 - -[♯44. Ignore Material Requirements for Upgrades (Horse and Armor)] -040A0000 01B0433C 2A1F03E8 -040A0000 0204BFC8 32000281 -040A0000 02050788 14000019 -040A0000 012E42C8 6B09013F -040A0000 01A5AF78 D503201F -040A0000 01FC757C D503201F -040A0000 02122D08 D503201F - -[--SectionEnd:Inventory--] -20000001 - -[--SectionStart:Map--] -20000000 - -[♯45. Show All Shrine and Cave Locations] -080A0000 00EC206C D65F03C0 52800020 -080A0000 00D23F60 D65F03C0 52800020 - -[♯46. Show All Korok Seed Locations (Must Zoom In)] -040A0000 00D25670 14000019 - -[--SectionEnd:Map--] -20000001 - -[--SectionStart:Misc--] -20000000 - -[♯47. Remove 21 Zonai Device Spawn Limit] -040A0000 00C6A3CC 52800028 - -[♯48. Time Stop (ZL+R3Down)] -80800100 -040A0000 00B3920C D503201F -20000000 - -[♯49. Time Resume (ZL+R3Up)] -80200100 -040A0000 00B3920C 1E212901 -20000000 - -[♯50. Time RW (ZL+R3Left)] -040A0000 00B3920C BD403E68 -80100100 -040A0000 00B3920C 1E37D008 -20000000 - -[♯51. Time FF (ZL+R3Left)] -040A0000 00B3920C BD403E68 -80400100 -040A0000 00B3920C 1E27D008 -20000000 - -[♯52. 2x Longer Days] -040A0000 00B3920C 1E2E1008 - -[♯53. 3x Longer Days] -040A0000 00B3920C 1E2C1008 - -[♯54. 4x Longer Days] -040A0000 00B3920C 1E2A1008 - -[#55. Add 60 Seconds To Mission Timer (L3+R3)] -080A0000 02B19E28 17898E1D BD001D00 -080A0000 02B19E20 1E2A2800 1E2B094A -080A0000 02B19E18 1E20100B 1E2A094A -080A0000 02B19E10 1E27D00A 340000F5 -080A0000 02B19E08 B9401115 54000120 -080A0000 02B19E00 1E202008 BD401D00 -040A0000 00D7D69C BD401D00 -80000030 -040A0000 00D7D69C 147671D9 -20000000 - -[♯56a Handheld 480p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 000001E0 00000356 - -[♯56b Handheld 540p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 0000021C 000003C0 - -[♯56c Handheld 612p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 00000264 00000440 - -[♯56d Handheld 648p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 00000288 00000480 - -[♯56e Default Handheld 720p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 000002D0 00000500 - -[♯56f Docked 720p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 00000360 00000600 - -[♯56g Docked 810p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 000003CC 000006C0 - -[♯56h Default Docked 900p] -580F0000 04716F50 -580F1000 00000090 -780F0000 000000F0 -680F01D0 00000438 00000780 - -[--SectionEnd:Misc--] -20000001 - -[--SectionStart:Environment--] -20000000 - -[Brighten World (ON)] -040A0000 0126C374 1E251001 - -[Brighten World (OFF)] -040A0000 0126C374 1E2E1001 - -[Disable Particles] -040A0000 0080B074 1E2703E0 - -[ReEnable Particles] -040A0000 0080B074 1E2E1000 - -[Disable Fog] -040A0000 009ADB48 1E2703E4 - -[ReEnable Fog] -040A0000 009ADB48 1E2E1004 - -[Instant Bloodmoon] -040A0000 0280A5D8 1E3E1001 - -[--SectionEnd:Environment--] -20000001 \ No newline at end of file diff --git a/totk.ini.example b/totk.ini.example index a04650ca..d889ab24 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -296,8 +296,9 @@ # shared_fonts = [cheats] -# One line per cheat of cheats\.txt next to totk.exe (docs/cheats.md); the Cheats tab of the menu writes -# them. cheat_ = 1 switches a cheat on, the hash being FNV-1a 32 of its name. Default: every cheat off. +# One line per cheat of the mods' cheat files, mods\\cheats\.txt (docs/cheats.md); the Cheats tab of +# the menu writes them. cheat_ = 1 switches a cheat on, the hash being FNV-1a 32 of "/". +# Default: every cheat off. # cheat_0123abcd = 1 [diagnostics]