Triforce v0.8.5

A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-28 10:54:41 -06:00
parent 2df08c751e
commit b527e29adb
203 changed files with 18821 additions and 2051 deletions

View File

@@ -97,6 +97,7 @@ typedef struct {
float vol[MAX_CH][MAX_BUF]; /* to the destination mix */
float ramp_volume, ramp_vol[MAX_CH][MAX_BUF]; /* the volumes the last frame ended with (ramped to the above) */
int snap; /* started or a new destination: no ramp from the old volumes */
int64_t dry_at; /* (Triforce) the mix frame it first played with no buffer left; 0: fed */
uint64_t wb[MAX_WB]; /* queued WaveBuffer*, oldest first (their identity) */
WB wbc[MAX_WB]; /* and their contents when appended */
int nwb, pending_wb; /* (pending: appended, not yet applied by an update) */
@@ -120,6 +121,28 @@ typedef struct {
} Voice;
static uint64_t split_bq_epoch; /* (the last epoch given to a splitter's filter: never 0, a voice's "none yet") */
/* (Triforce, the AMD limits work) Late refills: a playing voice ran out of the game's wave buffers and was given one again
within half a second, so what it played in between was silence: the game's audio thread came late (it needs one of
the virtual cores). Nothing counted this, nor the mix frames dropped because the device was behind, so a stutter left
no line in the log. One line every 10 s that had any (au_late_report). A sound that ends and whose voice is used
again without a stop counts too when it is within the half second: read the count against a quiet stretch's.
au_mix_frame: the mix frame being rendered (5 ms each), from 1. tests/test_audio_late.py */
enum { AUDIO_LATE_MOST = 100 }; /* (mix frames: half a second) */
static int64_t au_mix_frame = 1;
static struct { int64_t gaps, frames, longest; } au_late;
/* the voice's dry mark after a mix frame: 0 while it played a source frame in it or has buffers queued, else the frame
it first played nothing in */
static inline int64_t audio_late_mark(int64_t dry_at, int any, int nwb, int64_t frame) {
if (any || nwb) return 0;
return dry_at ? dry_at : frame;
}
/* a buffer appended at mix frame `frame`: the mix frames a playing voice played dry before it, 0 when it was fed in time
or the gap is longer than a late refill's (a new sound on the voice) */
static inline int64_t audio_late_gap(int playing, int64_t dry_at, int64_t frame) {
if (!playing || !dry_at) return 0;
const int64_t gap = frame - dry_at;
return gap >= 1 && gap <= AUDIO_LATE_MOST ? gap : 0;
}
static CRITICAL_SECTION lock;
static int lock_ready;
static Voice voices[MAX_VOICES];
@@ -778,6 +801,13 @@ static void tv_delay_frame(void) { /* after the voices: each line takes its st
}
}
static void au_late_report(unsigned dropped) { /* (the mixer thread, every 2000 mix frames; see au_late) */
if (au_late.gaps || dropped)
hos_log("audio: in the last 10 s %lld late refills (a playing voice out of the game's buffers, fed again after %lld ms "
"in all, the longest %lld ms), %u mix frames dropped with the device behind",
(long long)au_late.gaps, (long long)au_late.frames * 5, (long long)au_late.longest * 5, dropped);
memset(&au_late, 0, sizeof au_late);
}
static void render_voice(Voice *v) {
/* (a started voice without a destination still plays, as on the DSP: its buffers run out and are released) */
if (v->state != PLAY_STARTED) return;
@@ -814,7 +844,7 @@ static void render_voice(Voice *v) {
}
if (ocarina) hos_pad_speaker_ocarina_seen();
v->ramp_volume = v->volume;
(void)any;
v->dry_at = audio_late_mark(v->dry_at, any, v->nwb, au_mix_frame); /* ((Triforce) late refills: see au_late) */
/* the biquad filters (transposed direct form II, as the DSP's) */
for (int f = 0; f < 2; f++) {
if (!v->bq_on[f]) continue;
@@ -1302,6 +1332,7 @@ static int out_next; /* the next candidate: 0 = HOS_AUDIO_DEVICE, 1 =
static uint64_t out_opened, out_stall_since;
static unsigned out_played, out_peak, out_reported;
static unsigned out_completed; /* ((Triforce) 11-24) blocks the device gave back since it opened: played, not only taken */
static unsigned out_dropped; /* ((Triforce) mix frames dropped with the device behind, since the mixer's last line) */
/* (hookshot) A device gone (a Bluetooth headset off, the audio service restarted: "no driver", "invalid handle" from the
next call) is closed and the default opened again; none opening, the default is tried every second until one does.
Opened as the default, the output follows Windows': its key (au_default_key) looked at every second, a change reopens
@@ -1573,6 +1604,7 @@ static void output_frame(const int16_t *pcm) {
WAVEHDR *h = &hdr[fill_block];
if (fill_frames == 0) {
if (!(h->dwFlags & WHDR_DONE)) { /* the device is behind: this frame is dropped */
out_dropped++; /* ((Triforce) counted: the mixer's "late refills" line) */
const uint64_t now = au_ms();
if (!out_stall_since) out_stall_since = now;
else if (now - out_stall_since > 1500) output_reopen();
@@ -1690,10 +1722,19 @@ static void apply(const Cmd *k) { /* (with the lock held) */
v->yn1 = v->yn2 = 0;
}
if (k->i0 == PLAY_STARTED && v->state != PLAY_STARTED) v->snap = 1;
if (v->state != k->i0) v->dry_at = 0;
v->state = k->i0;
break;
case OP_VOICE_APPEND:
if (v->pending_wb > 0) v->pending_wb--;
{ /* ((Triforce) fed again after running dry: a late refill, see au_late) */
const int64_t gap = audio_late_gap(v->state == PLAY_STARTED, v->dry_at, au_mix_frame);
if (gap) {
au_late.gaps++, au_late.frames += gap;
if (gap > au_late.longest) au_late.longest = gap;
}
v->dry_at = 0;
}
if (v->nwb < MAX_WB) {
v->wbc[v->nwb] = k->wb;
v->wbc[v->nwb].source = k->i0; /* ((Triforce) its class, for the controller speaker: -1 none known) */
@@ -1829,6 +1870,8 @@ static DWORD WINAPI renderer_main(void *p) {
if (ncmds && hos_now_ns() - last_update_ns > 50000000) commit(); /* (no update came: see "parameter updates") */
render_frame(pcm, out_channels);
audio_mono(pcm, FRAME, out_channels, rx_option(HOS_OPT_AUDIO_OUTPUT, 0) == 3); /* ((Triforce) the Audio output row's Mono) */
const int report = ++au_mix_frame % 2000 == 0;
if (report) au_late_report(out_dropped), out_dropped = 0; /* (out_dropped: this thread's alone) */
au_unlock();
/* ((Triforce) the controller speaker's frame (every frame, silence too: the pad's stream runs on), after the Master
volume as the TV's; headphones in the pad's jack that take all the sound, as on the console: the TV silent */