mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-26 19:18:49 -04:00
Triforce v0.8.3
Fixes from the 0.8 reports: a mod's code patches go in together or not at all and a mod whose code is refused is off whole; nn::crypto random bytes from the host (a crash at start); shader preparation on three quarters of the CPU threads; Evil HD ornaments and shoot leaves kept to 75 m and 70 m (flicker); the RADV lighting flicker fix; 3D BC images through block attachments on AMD RDNA 1/2 Windows (rainbow lights).
This commit is contained in:
@@ -44,6 +44,19 @@
|
||||
enum { EVIL_HD_FOLIAGE_COUNT = 8 };
|
||||
#define EVIL_HD_FOLIAGE_DEFAULTS 0x83f0fd38ULL /* (main+0x3eefd38: the eight defaults, in this order) */
|
||||
static const float evil_hd_foliage_game[EVIL_HD_FOLIAGE_COUNT] = {40.0f, 60.0f, 35.0f, 30.0f, 40.0f, 135.0f, 10.0f, 45.0f};
|
||||
/* ((Triforce, 11-25, a player's report with the measurements: "Evil HD 4x: Kokiri Forest bushes and Lost Woods tree leaves
|
||||
flicker") The most two of them go to: the ornaments (Kokiri Forest's cuttable bushes and flowers) flickered at 140 m (4x)
|
||||
and 105 m (3x) and were steady at 70 and 75 m; the low trees' shoot leaves (the Lost Woods' leaves overhead) flickered at
|
||||
120 m and were steady at 30 and 70 m. The game's own areas set them no farther than 75 m (Hyrule Castle's ornaments) and
|
||||
70 m (Zora's Domain's shoot leaves): the foliage system seems to have room for about that many of them. The other six
|
||||
showed no flicker at 4x and keep the whole factor. 0: no bound */
|
||||
static const float evil_hd_foliage_most[EVIL_HD_FOLIAGE_COUNT] = {0.0f, 0.0f, 75.0f, 70.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
/* One distance at a factor: the game's times it, kept to its most */
|
||||
static inline float evil_hd_foliage_one(int i, float factor) {
|
||||
const float v = factor == 1.0f ? evil_hd_foliage_game[i] : evil_hd_foliage_game[i] * factor;
|
||||
return evil_hd_foliage_most[i] > 0.0f && v > evil_hd_foliage_most[i] && evil_hd_foliage_game[i] <= evil_hd_foliage_most[i]
|
||||
? evil_hd_foliage_most[i] : v;
|
||||
}
|
||||
|
||||
/* Whether Evil HD is on: the row's value, or HOS_EVIL_HD's when it is set to 0 or 1 (anything else: the row's) */
|
||||
static inline int evil_hd_on(int row, const char *asked) {
|
||||
@@ -76,9 +89,9 @@ static inline float evil_hd_factor(int row, const char *mode, const char *dist)
|
||||
return evil_hd_on(row, mode) ? evil_hd_dist_factor(dist) : 1.0f;
|
||||
}
|
||||
|
||||
/* The game's eight foliage defaults, each times the factor, into out (the factor 1: the game's own exactly) */
|
||||
/* The game's eight foliage defaults, each times the factor (kept to evil_hd_foliage_most), into out (the factor 1: the game's own exactly) */
|
||||
static inline void evil_hd_foliage(float factor, float out[EVIL_HD_FOLIAGE_COUNT]) {
|
||||
for (int i = 0; i < EVIL_HD_FOLIAGE_COUNT; i++) out[i] = factor == 1.0f ? evil_hd_foliage_game[i] : evil_hd_foliage_game[i] * factor;
|
||||
for (int i = 0; i < EVIL_HD_FOLIAGE_COUNT; i++) out[i] = evil_hd_foliage_one(i, factor);
|
||||
}
|
||||
|
||||
/* Whether the eight floats at the defaults' place are a version of them this rule knows: the game's own, or the game's
|
||||
@@ -87,7 +100,7 @@ static inline int evil_hd_foliage_known(const float have[EVIL_HD_FOLIAGE_COUNT])
|
||||
const float f = have[0] / evil_hd_foliage_game[0];
|
||||
if (!(f >= 1.0f && f <= EVIL_HD_DIST_MOST)) return 0;
|
||||
for (int i = 0; i < EVIL_HD_FOLIAGE_COUNT; i++) {
|
||||
const float want = evil_hd_foliage_game[i] * f, d = have[i] - want;
|
||||
const float want = evil_hd_foliage_one(i, f), d = have[i] - want;
|
||||
if (d > want * 1e-4f || d < -want * 1e-4f) return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
24
host/mods.c
24
host/mods.c
@@ -204,8 +204,9 @@ static void code_record_load(void) {
|
||||
if (built) nbuilt = mod_code_parse(text, built, BUILT_MOST);
|
||||
free(text);
|
||||
}
|
||||
/* (returns how many of this mod's patches wait for a build: new since it, or changed) */
|
||||
static int code_patches(const Mod *mod) {
|
||||
/* (returns how many of this mod's patches wait for a build: new since it, or changed; *refused: how many the build refused) */
|
||||
static int code_patches(const Mod *mod, int *refused) {
|
||||
*refused = 0;
|
||||
char pat[MAX_PATH];
|
||||
snprintf(pat, sizeof pat, "%s\\exefs\\*", mod->path);
|
||||
WIN32_FIND_DATAA fd;
|
||||
@@ -227,6 +228,8 @@ static int code_patches(const Mod *mod) {
|
||||
else if (state == MOD_CODE_CHANGED) hos_log("mods: %s changed since the game was built: the game has it as it was then", rel);
|
||||
else hos_log("mods: %s is not built into the game", rel);
|
||||
waits += state == MOD_CODE_CHANGED || state == MOD_CODE_WAITS;
|
||||
/* (one for another build of the game holds nothing back: mods carry a patch per game version, nx2/code_mods.py OtherBuild) */
|
||||
*refused += state == MOD_CODE_REFUSED && strncmp(why, "it is for build ", 16) != 0;
|
||||
} while (FindNextFileA(f, &fd));
|
||||
FindClose(f);
|
||||
code_waits += waits;
|
||||
@@ -289,13 +292,20 @@ static void mods_scan(void) {
|
||||
files waiting too: the game crashed at its start with a mod's new files over its old code (Classic Item Slots
|
||||
put in by the Mods menu, #bug-tracker "Crashing on startup"; a build put them in step). They come with the code,
|
||||
at the next build. HOS_MODS_SPLIT=1: the files now anyway, as before) */
|
||||
const int waits = code_patches(&mods[i]);
|
||||
/* ((Triforce, 11-25) and a mod whose code the build refused (a code cave, another build) is off whole: its RomFS
|
||||
files were made for its code. A player's "More Tunics" had its two code-cave patches refused and its 172 files
|
||||
(new tunics in the actor and game data tables) loaded over the game's own code; crashes at every loading screen) */
|
||||
int refused = 0;
|
||||
const int waits = code_patches(&mods[i], &refused);
|
||||
static int split = -1;
|
||||
if (split < 0) split = getenv("HOS_MODS_SPLIT") && atoi(getenv("HOS_MODS_SPLIT")) == 1;
|
||||
const int hold = waits > 0 && !split;
|
||||
const int files = hold ? 0 : index_romfs(dir, "", 0);
|
||||
cheat_files(&mods[i]); /* (and its cheat file) */
|
||||
if (hold)
|
||||
const int hold = waits > 0 && !split, off = refused > 0 && !split;
|
||||
const int files = hold || off ? 0 : index_romfs(dir, "", 0);
|
||||
if (!off) cheat_files(&mods[i]); /* (and its cheat file) */
|
||||
if (off)
|
||||
hos_log("mods: %s is off: %d of its code patch(es) could not be built in, and its RomFS files and cheats go with its code "
|
||||
"(HOS_MODS_SPLIT=1: its files anyway)", mods[i].name, refused);
|
||||
else if (hold)
|
||||
hos_log("mods: %s: its RomFS files wait for the build too, with its code (%d patch(es) not built in yet)", mods[i].name, waits);
|
||||
else
|
||||
hos_log("mods: %s: %d RomFS files", mods[i].name, files);
|
||||
|
||||
@@ -465,6 +465,40 @@ HLE(_ZN2nn5prepo10PlayReport4SaveERKNS_7account3UidE) { RET(0); }
|
||||
/* (hookshot) PlayReport::Send(Uid const&), SDK 22's: kept nowhere, as Save. Left to the SDK it opened the prepo
|
||||
service through sm: and aborted on the empty reply (OoT's PlayReporter thread, ~5 minutes into a game). */
|
||||
HLE(_ZN2nn5prepo10PlayReport4SendERKNS_7account3UidE) { RET(0); }
|
||||
|
||||
/* ((Triforce, 11-25) nn::crypto::GenerateCryptographicallyRandomBytes(void* out, size_t size): the host's own secure random
|
||||
bytes. Left to the SDK it opened the csrng service through sm:, got the empty reply and aborted (svcBreak in
|
||||
nn::diag::detail::Abort): a player's game stopped ~6 s after every start, on OoT's Porter thread (main 0x82507050, the
|
||||
npln online code), on an RX 6800 PC; never seen here, so its call is on a path our runs do not take. */
|
||||
#ifdef _WIN32
|
||||
#include <ntsecapi.h> /* (RtlGenRandom, as host/hos_report_run.c) */
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
HLE(_ZN2nn6crypto36GenerateCryptographicallyRandomBytesEPvm) {
|
||||
const uint64_t out = ARG(0), size = ARG(1);
|
||||
if (!out || !size || !hos_guest_range(out, size)) return;
|
||||
uint8_t *p = (uint8_t *)GP(out);
|
||||
uint64_t done = 0;
|
||||
while (done < size) {
|
||||
const uint64_t n = size - done < 0x10000 ? size - done : 0x10000;
|
||||
#ifdef _WIN32
|
||||
if (!RtlGenRandom(p + done, (ULONG)n)) break;
|
||||
done += n;
|
||||
#else
|
||||
const ssize_t got = getrandom(p + done, (size_t)n, 0);
|
||||
if (got < 0 && errno == EINTR) continue;
|
||||
if (got <= 0) break;
|
||||
done += (uint64_t)got;
|
||||
#endif
|
||||
}
|
||||
if (done < size) { /* (no host randomness: never seen; the bytes still differ from run to run) */
|
||||
uint64_t x = (uint64_t)hos_now_ns() ^ (out << 17) ^ 0x9E3779B97F4A7C15ULL;
|
||||
for (; done < size; done++) { x ^= x << 13; x ^= x >> 7; x ^= x << 17; p[done] = (uint8_t)x; }
|
||||
hos_log("crypto: the host gave no random bytes: %llu made from the clock", (unsigned long long)size);
|
||||
}
|
||||
}
|
||||
/* (hookshot) prepo::AsyncContext: the report "sent" at once. GetCompletionEvent(SystemEvent* out) gives an event
|
||||
already signaled (the SDK's own aborted on the context the empty IPC reply left), GetResult success. */
|
||||
void hos_system_event_init(uint64_t key, int autoclear); /* nn_os_sync.c */
|
||||
|
||||
Reference in New Issue
Block a user