mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 13:45:57 +00:00
Mod plugins that hook the middle of game functions, swap pointers in the game's data, use the SD card or switch their hooks during play build in, and may call what the game itself calls; Zonai Fieldworks starts (#1388)
Zonai Fieldworks was refused at several steps; each is now handled: 1. The start-up asked GetInfo 6, 7, 16 and 17 and SetHeapSize; runtime/plugin_init.c serves them. 2. Its start-up calls main where the lift has no function start. The tool names those addresses (--entries-out) and the installer lifts again with them as `entry` lines, up to four rounds (installer/steps.py PLUGIN_ENTRY_ROUNDS). 3. Branch hooks into the middle of game functions (far-jump veneers) and pointer swaps in main's data are accepted hook kinds; the veneer targets seed the plugin's lift, and an Orig trampoline counts as a seed. 4. Code the start-up writes into the plugin's own .text (hook pads it switches to during play) is found by comparing the image before and after the init, and seeds the lift (init_code). Without it the game stopped with "no function at guest pc" when a feature switched on. 5. recomp/gen.py: a branch-out alternative on a flag-writing site leaves with the flags from before the site; an inline hook may sit on a blr. 6. nn::fs::MountSdCard mounts <profile>/sdcard (runtime/fs_host.c), and nn::settings language codes are answered (runtime/ov_system.c). The import check now also allows what the game's main imports (--exefs, game_imports): the game runs on those paths, so the runtime serves them. Left out: nn::ro, the C runtime start, the thread-local allocator hook and the shader compiler. Break in code the hooks reach is allowed (an abort ends the game with the reason, as on the Switch), and RenameFile, DeleteDirectoryRecursively, Commit and Unmount join the SD card calls. Checked: Zonai Fieldworks, The Second Quest, Challenge Mode and Material Columns on 1.4.3, Full Inventory Expansion, Quick Weapon Durability and Magic of the Kingdom on 1.2.1 accepted; UltraCam's init still crashes its service run. Plain lift unchanged; probes 4/4 on both versions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
942b6b7b2b
commit
3fe8d7a1d9
9 files changed
+552
-136
No files matched your search
+15
-1
@@ -11,6 +11,8 @@
|
||||
// <profile>/save-backup/<time>/ the three committed saves before the current one
|
||||
// <profile>/temp/ emptied at start
|
||||
// <profile>/cache/<index>/ cache storage
|
||||
// <profile>/sdcard/ the SD card a mod plugin mounts (MountSdCard, under any mount name: Zonai
|
||||
// Fieldworks keeps its settings and logs there); the game never mounts it
|
||||
//
|
||||
// The save mount is journaled as on Horizon: changes go to a working copy and become the committed save atomically at
|
||||
// Commit; a crash or an Unmount before Commit leaves the previous committed save. Commit returns at once and the copy
|
||||
@@ -33,7 +35,8 @@
|
||||
#define NMOUNTS 16
|
||||
#define PATH_CAP 1100
|
||||
|
||||
enum { M_FREE, M_SAVE, M_TEMP, M_CACHE, M_SAVE_RO }; // M_SAVE: the working copy; M_SAVE_RO: the committed save
|
||||
// M_SAVE: the working copy; M_SAVE_RO: the committed save; M_SDCARD: <profile>/sdcard
|
||||
enum { M_FREE, M_SAVE, M_TEMP, M_CACHE, M_SAVE_RO, M_SDCARD };
|
||||
|
||||
typedef struct { int kind; char name[32]; char root[1024]; } Mount;
|
||||
typedef struct { PlatFile *h; int mode, save; } File; // h NULL = free; save: on a save-data mount
|
||||
@@ -800,6 +803,14 @@ static uint32_t mount_temp(const char *name) {
|
||||
return mount_add(name, M_TEMP, p);
|
||||
}
|
||||
|
||||
static uint32_t mount_sdcard(const char *name) {
|
||||
ready();
|
||||
char p[PATH_CAP];
|
||||
snprintf(p, sizeof p, "%s/sdcard", profile);
|
||||
make_dirs(p);
|
||||
return mount_add(name, M_SDCARD, p);
|
||||
}
|
||||
|
||||
static void cache_dir(int index, char *out, size_t cap) { snprintf(out, cap, "%s/cache/%d", profile, index); }
|
||||
|
||||
static uint32_t create_cache(int index, int64_t size, int64_t journal) {
|
||||
@@ -1210,6 +1221,7 @@ static void ov_mount_save(Cpu *c) { ret_x(c, mount_save(arg_p(c, 0), arg_p(c, 1)
|
||||
static void ov_mount_save_ro(Cpu *c) { ret_x(c, mount_save_ro(arg_p(c, 0), arg_x(c, 1), arg_p(c, 2))); }
|
||||
static void ov_save_exists(Cpu *c) { ret_x(c, save_exists(arg_x(c, 0), arg_p(c, 1))); }
|
||||
static void ov_mount_temp(Cpu *c) { ret_x(c, mount_temp(arg_p(c, 0))); }
|
||||
static void ov_mount_sdcard(Cpu *c) { ret_x(c, mount_sdcard(arg_p(c, 0))); }
|
||||
static void ov_unmount(Cpu *c) { unmount(arg_p(c, 0)); }
|
||||
static void ov_commit(Cpu *c) { ret_x(c, commit(arg_p(c, 0))); }
|
||||
static void ov_create_cache(Cpu *c) { ret_x(c, create_cache(I32(0), I64(1), I64(2))); }
|
||||
@@ -1245,6 +1257,7 @@ static void ov_set_priority(Cpu *c) { (void)c; }
|
||||
#define S_MOUNT_SAVE_RO "_ZN2nn2fs21MountSaveDataReadOnlyEPKcNS_13ApplicationIdERKNS_7account3UidE"
|
||||
#define S_SAVE_EXISTS "_ZN2nn2fs18IsSaveDataExistingENS_13ApplicationIdERKNS_7account3UidE"
|
||||
#define S_MOUNT_TEMP "_ZN2nn2fs21MountTemporaryStorageEPKc"
|
||||
#define S_MOUNT_SDCARD "_ZN2nn2fs11MountSdCardEPKc"
|
||||
#define S_UNMOUNT "_ZN2nn2fs7UnmountEPKc"
|
||||
#define S_COMMIT "_ZN2nn2fs6CommitEPKc"
|
||||
#define S_CREATE_CACHE "_ZN2nn2fs18CreateCacheStorageEill"
|
||||
@@ -1281,6 +1294,7 @@ HOST_OVERRIDE(S_MOUNT_SAVE, ov_mount_save);
|
||||
HOST_OVERRIDE(S_MOUNT_SAVE_RO, ov_mount_save_ro);
|
||||
HOST_OVERRIDE(S_SAVE_EXISTS, ov_save_exists);
|
||||
HOST_OVERRIDE(S_MOUNT_TEMP, ov_mount_temp);
|
||||
HOST_OVERRIDE(S_MOUNT_SDCARD, ov_mount_sdcard);
|
||||
HOST_OVERRIDE(S_UNMOUNT, ov_unmount);
|
||||
HOST_OVERRIDE(S_COMMIT, ov_commit);
|
||||
HOST_OVERRIDE(S_CREATE_CACHE, ov_create_cache);
|
||||
|
||||
Reference in new issue
Block a user