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

@@ -44,10 +44,13 @@ static int rx_option(int id, int otherwise) {
}
static void ask(int id) { asked[nasked++] = id; }
/* (the game's files: what the test put there) */
static struct { const char *rel; const uint8_t *data; uint64_t size; } rom[16];
static int nrom, rom_reads;
static struct { const char *rel; const uint8_t *data; uint64_t size; } rom[32];
static int nrom, rom_reads, rom_odd;
static uint8_t *hos_fs_rom_file(const char *rel, uint64_t most, uint64_t *size) {
rom_reads++;
/* ((Triforce, 11-25) every file asked for is a .bwav of the sounds' folder itself, the environment's too) */
const size_t len = strlen(rel);
rom_odd += strncmp(rel, "Sound/Resource/Stream/", 22) || strpbrk(rel + 22, "/\\:.") != rel + len - 5 || strcmp(rel + len - 5, ".bwav");
for (int i = 0; i < nrom; i++)
if (!strcmp(rom[i].rel, rel) && rom[i].size && rom[i].size <= most) {
uint8_t *copy = (uint8_t *)malloc((size_t)rom[i].size);
@@ -59,6 +62,17 @@ static uint8_t *hos_fs_rom_file(const char *rel, uint64_t most, uint64_t *size)
}
static int load_requests;
static void load_start(void) { load_requests++; } /* (the test reads the files when it says: load_all) */
/* ((Triforce, 11-25) the environment, as the roles' sounds read it: what the test put there) */
static struct { const char *name, *value; } env[16];
static int nenv, env_reads;
static const char *test_env(const char *name) {
env_reads++;
for (int i = 0; i < nenv; i++)
if (!strcmp(env[i].name, name)) return env[i].value;
return NULL;
}
static void put_env(const char *name, const char *value) { env[nenv].name = name, env[nenv].value = value, nenv++; }
#define MENU_SOUND_ENV(name) test_env(name)
static void (*between)(int at);
#define MENU_SOUND_BETWEEN(at) do { if (between) between(at); } while (0)
@@ -421,7 +435,11 @@ static void decode_refusals(void) {
/* ---- the voices and the mix, on sounds put there as they would be after the files are read ---- */
enum { OPEN = HOS_MENU_SOUND_OPEN, CLOSE = HOS_MENU_SOUND_CLOSE, CURSOR = HOS_MENU_SOUND_CURSOR, DECIDE = HOS_MENU_SOUND_DECIDE,
CANCEL = HOS_MENU_SOUND_CANCEL, TAB_LEFT = HOS_MENU_SOUND_TAB_LEFT, TAB_RIGHT = HOS_MENU_SOUND_TAB_RIGHT, FANFARE = HOS_MENU_SOUND_FANFARE,
SYS_CURSOR = HOS_MENU_SOUND_SYS_CURSOR, SYS_DECIDE = HOS_MENU_SOUND_SYS_DECIDE };
SYS_CURSOR = HOS_MENU_SOUND_SYS_CURSOR, SYS_DECIDE = HOS_MENU_SOUND_SYS_DECIDE,
/* ((Triforce, 11-25) whose sound: the settings' tabs', the Mods screen's, the step back to the pause menu's list) */
S_NAV = HOS_MENU_SOUND_SETTINGS_NAVIGATE, S_SEL = HOS_MENU_SOUND_SETTINGS_SELECT, S_BACK = HOS_MENU_SOUND_SETTINGS_BACK,
M_NAV = HOS_MENU_SOUND_MODS_NAVIGATE, M_SEL = HOS_MENU_SOUND_MODS_SELECT, M_BACK = HOS_MENU_SOUND_MODS_BACK,
P_BACK = HOS_MENU_SOUND_PAUSE_BACK, S_ON = HOS_MENU_SOUND_SETTINGS_ON, S_OFF = HOS_MENU_SOUND_SETTINGS_OFF };
#define BLOCK 240
static float bl[BLOCK], br[BLOCK];
static void install(int id, uint32_t frames, float l, float r) { /* (its samples end where nothing can be read) */
@@ -480,7 +498,8 @@ static void voices_and_mix(void) {
hos_menu_sound_play(TAB_LEFT, t0);
CHECK(active() == 0);
}
{ /* a sound is added to what the block holds, at the gain, left and right; the cursor's tick at 0.6 of it */
{ /* a sound is added to what the block holds, at the gain, left and right; ((Triforce, 11-26) the cursor's tick too,
at the whole level, as the game's own cursor sound (it was at 0.6 of it, under the others)) */
hos_menu_sound_play(OPEN, t0);
CHECK(active() == 1 && voice_with(OPEN) == 0);
block(0.8f, 0.1f, -0.1f);
@@ -489,9 +508,9 @@ static void voices_and_mix(void) {
block(0.0f, 0.1f, -0.1f); /* at gain 0 nothing is added, and the sound goes on */
CHECK(block_is(0, BLOCK, 0.1f, -0.1f) && voice_pos(0) == 2 * BLOCK);
quiet();
hos_menu_sound_play(CURSOR, t0 + 500 * kMs); /* (not within 180 ms of the sound before: see below) */
hos_menu_sound_play(CURSOR, t0 + 500 * kMs); /* (not within 45 ms of the sound before: see below) */
block(0.5f, 0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.5f * 0.5f * 0.6f, 0.5f * 0.5f * 0.6f));
CHECK(block_is(0, BLOCK, 0.5f * 0.5f, 0.5f * 0.5f));
quiet();
}
{ /* a free voice each, while there is one; then the oldest's */
@@ -539,30 +558,42 @@ static void voices_and_mix(void) {
CHECK(active() == 2);
quiet();
}
{ /* the cursor's tick: not within 180 ms of the sound before it, whatever that was; a decision within 50 ms of a
tick takes the tick's voice */
{ /* ((Triforce, 11-26) the cursor's tick: each move's starts with it and the one before rings on beside it, as the game's
own cursor sound (the owner's clip); an ask within NAV_GAP_NS of the sound before is left out (one press asking
twice). A decision within 50 ms of a tick takes the tick's voice; later, a voice of its own, the tick ringing on */
hos_menu_sound_play(CURSOR, t0 + 1000 * kMs);
CHECK(active() == 1 && voice_with(CURSOR) == 0);
block(1.0f, 0.0f, 0.0f);
hos_menu_sound_play(CURSOR, t0 + 1100 * kMs);
hos_menu_sound_play(CURSOR, t0 + 1179 * kMs);
CHECK(active() == 1 && voice_pos(0) == BLOCK);
hos_menu_sound_play(DECIDE, t0 + 1179 * kMs);
CHECK(active() == 1 && voice_with(DECIDE) == 0 && voice_with(CURSOR) < 0 && voice_pos(0) == 0);
hos_menu_sound_play(CURSOR, t0 + 1300 * kMs); /* (121 ms after the decision) */
CHECK(voice_with(CURSOR) < 0);
hos_menu_sound_play(CURSOR, t0 + 1359 * kMs);
CHECK(voice_with(CURSOR) >= 0);
CHECK(active() == 2 && voice_pos(0) == BLOCK && voice_pos(1) == 0);
hos_menu_sound_play(CURSOR, t0 + 1144 * kMs); /* (44 ms on: the same press's) */
CHECK(active() == 2 && voice_pos(1) == 0);
block(1.0f, 0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 1.0f, 1.0f)); /* (both whole, each at the whole level) */
for (int k = 0; k < 4; k++) block(1.0f, 0.0f, 0.0f);
CHECK(active() == 2 && voice_pos(0) == 6 * BLOCK && voice_pos(1) == 5 * BLOCK); /* (neither cut) */
hos_menu_sound_play(DECIDE, t0 + 1149 * kMs); /* (the first tick 1440 frames in, under 50 ms: the same press's voice) */
CHECK(active() == 2 && voice_with(DECIDE) == 0 && voice_pos(0) == 0 && voice_with(CURSOR) == 1);
hos_menu_sound_play(CURSOR, t0 + 1190 * kMs); /* (41 ms after the decision: left out) */
CHECK(active() == 2);
hos_menu_sound_play(CURSOR, t0 + 1194 * kMs);
CHECK(active() == 3 && voice_pos(2) == 0 && voice_with(DECIDE) == 0); /* (beside the decision, which is not cut) */
quiet();
hos_menu_sound_play(CURSOR, t0 + 3000 * kMs);
hos_menu_sound_play(DECIDE, t0 + 3001 * kMs); /* (the same press's: the tick's voice) */
CHECK(active() == 1 && voice_with(DECIDE) == 0 && voice_with(CURSOR) < 0);
quiet();
hos_menu_sound_play(CURSOR, t0 + 4000 * kMs);
for (int k = 0; k < 10; k++) block(1.0f, 0.0f, 0.0f); /* (50 ms on) */
hos_menu_sound_play(DECIDE, t0 + 3050 * kMs);
hos_menu_sound_play(DECIDE, t0 + 4050 * kMs);
CHECK(active() == 2 && voice_with(CURSOR) == 0 && voice_with(DECIDE) == 1);
block(1.0f, 0.0f, 0.0f), block(1.0f, 0.0f, 0.0f);
CHECK(voice_with(CURSOR) == 0 && voice_pos(0) == 12 * BLOCK); /* (the tick rings on under the decision) */
quiet();
}
{ /* ((Triforce, 11-19) the system menu's: the mouse onto Mods or Quit and its click in one tick, or a stick's flick and
A, is their decide alone, as the options' tick and decision; 50 ms on they both play. Its ticks are not thinned
out by the 180 ms gap, as the game's System list does not thin out its own) */
A, is their decide alone, as the options' tick and decision. ((11-26) Its cursor is a navigation sound as the
ticks are: the next move's plays beside it, and so does a decision 50 ms on) */
install(SYS_CURSOR, 30000, 0.5f, 0.5f), install(SYS_DECIDE, 100, 1.0f, -1.0f);
t0 += 10000 * kMs;
hos_menu_sound_play(SYS_CURSOR, t0);
@@ -570,14 +601,71 @@ static void voices_and_mix(void) {
CHECK(active() == 1 && voice_with(SYS_DECIDE) == 0 && voice_with(SYS_CURSOR) < 0 && voice_pos(0) == 0);
quiet();
hos_menu_sound_play(SYS_CURSOR, t0 + 1000 * kMs);
hos_menu_sound_play(SYS_CURSOR, t0 + 1100 * kMs); /* (100 ms on: heard, restarted) */
CHECK(active() == 1 && voice_with(SYS_CURSOR) == 0 && voice_pos(0) == 0);
block(1.0f, 0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.5f, 0.5f));
hos_menu_sound_play(SYS_CURSOR, t0 + 1100 * kMs); /* (100 ms on: heard, the one before ringing on) */
CHECK(active() == 2 && voice_pos(0) == BLOCK && voice_pos(1) == 0);
for (int k = 0; k < 10; k++) block(1.0f, 0.0f, 0.0f);
CHECK(active() == 2 && voice_pos(0) == 11 * BLOCK && voice_pos(1) == 10 * BLOCK);
hos_menu_sound_play(SYS_DECIDE, t0 + 1150 * kMs);
CHECK(active() == 2 && voice_with(SYS_CURSOR) == 0 && voice_with(SYS_DECIDE) == 1);
CHECK(active() == 3 && voice_with(SYS_DECIDE) == 2);
quiet();
sounds[SYS_CURSOR] = sounds[SYS_DECIDE] = (Sound){0};
}
{ /* ((Triforce, 11-26) the settings' tabs' and the Mods screen's own ticks are ticks as the cursor's: at the whole
level, each move's beside the ones before whosever they were, an ask within 45 ms of the sound before left out,
and the decision of the same press takes the tick's voice; a step back after it a voice of its own */
install(S_NAV, 30000, 0.5f, 0.5f), install(M_NAV, 30000, 0.25f, 0.25f);
install(S_SEL, 100, 1.0f, -1.0f), install(P_BACK, 300, 0.25f, 0.25f);
t0 += 10000 * kMs;
hos_menu_sound_play(S_NAV, t0);
block(0.5f, 0.0f, 0.0f);
CHECK(active() == 1 && voice_with(S_NAV) == 0 && block_is(0, BLOCK, 0.5f * 0.5f, 0.5f * 0.5f));
for (int k = 1; k < 20; k++) block(1.0f, 0.0f, 0.0f); /* (100 ms on) */
hos_menu_sound_play(M_NAV, t0 + 100 * kMs);
hos_menu_sound_play(S_NAV, t0 + 140 * kMs); /* (40 ms on: left out) */
CHECK(active() == 2 && voice_with(M_NAV) == 1 && voice_with(S_NAV) == 0 && voice_pos(0) == 20 * BLOCK);
block(1.0f, 0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.5f + 0.25f, 0.5f + 0.25f));
hos_menu_sound_play(S_SEL, t0 + 145 * kMs); /* (the Mods screen's tick 45 ms ago, 240 frames in: its voice) */
CHECK(active() == 2 && voice_with(S_SEL) == 1 && voice_with(M_NAV) < 0 && voice_pos(1) == 0);
hos_menu_sound_play(P_BACK, t0 + 145 * kMs); /* (no tick it could take: a voice of its own) */
CHECK(active() == 3 && voice_with(P_BACK) == 2 && voice_with(S_SEL) == 1 && voice_with(S_NAV) == 0);
block(1.0f, 0.0f, 0.0f);
CHECK(block_is(0, 100, 0.5f + 1.0f + 0.25f, 0.5f - 1.0f + 0.25f));
hos_menu_sound_play(M_NAV, t0 + 300 * kMs); /* (a move after the step back: heard beside it) */
CHECK(voice_with(M_NAV) >= 0 && voice_with(P_BACK) == 2 && voice_with(S_NAV) == 0);
quiet();
}
{ /* ((Triforce, 11-26) a direction held on the settings' tabs with the system menu's cursor's own length, 1.6 s, at
the game's own pace (vk_menu.cpp kNavStepNs: a move each 135 ms): each tick plays whole beside the ones before.
Under them a longer sound that started first (the Mods screen's fanfare, 4 s; the options' opening): with no
voice free the next tick takes the oldest tick's voice, never that sound's, and so does a decision. When the
ticks have played out every voice is free again */
install(FANFARE, 192000, 0.125f, 0.125f), install(S_NAV, 76800, 0.5f, 0.5f), install(S_SEL, 100, 1.0f, -1.0f);
t0 += 10000 * kMs;
hos_menu_sound_play(FANFARE, t0);
int most = 0, started = 0, was_started = (int)started_n;
for (int k = 0; k < 720; k++) { /* (3.6 s of blocks, a move each 27 of them: 135 ms) */
if (k % 27 == 0) hos_menu_sound_play(S_NAV, t0 + 50 * kMs + k * 5 * kMs);
const int now_started = (int)started_n;
started += now_started != was_started, was_started = now_started;
block(1.0f, 0.0f, 0.0f);
if (voice_with(FANFARE) != 0 || voice_pos(0) != (k + 1) * BLOCK) { printf("block %d\n", k); CHECK(!"the fanfare plays on under the ticks"); break; }
if (active() - 1 > most) most = active() - 1;
}
CHECK(started == 27 && most == VOICES - 1 && active() == VOICES); /* (a tick each 135 ms; seven at once, beside the fanfare) */
for (int k = 0; k < 20; k++) block(1.0f, 0.0f, 0.0f); /* (100 ms after the last tick: a decision is not that press's) */
hos_menu_sound_play(S_SEL, t0 + 3800 * kMs);
CHECK(active() == VOICES && voice_with(FANFARE) == 0 && voice_with(S_SEL) > 0);
int ticks = 0;
for (int i = 1; i < VOICES; i++) ticks += atomic_load(&voices[i].sound) == S_NAV;
CHECK(ticks == VOICES - 2); /* (the oldest tick gave its voice) */
for (int k = 0; k < 320; k++) block(1.0f, 0.0f, 0.0f); /* (1.6 s on: the ticks and the fanfare are over) */
CHECK(active() == 0);
quiet();
sounds[FANFARE] = sounds[S_NAV] = sounds[M_NAV] = sounds[S_SEL] = sounds[P_BACK] = (Sound){0};
}
{ /* a restart inside the mix, between its read of the voice's place and of its sound: the tick is 240 samples in when
the decision, 100 samples long, takes its voice. The place is the tick's, the sound the decision's: nothing of
it is mixed in this block (240 is past the decision's end, and its samples end where nothing can be read),
@@ -613,7 +701,7 @@ static void voices_and_mix(void) {
block(1.0f, 0.0f, 0.0f);
restart_with = DECIDE, restart_at = 1, between = restart;
block(1.0f, 0.0f, 0.0f);
CHECK(between == NULL && block_is(0, BLOCK, 0.3f, 0.3f)); /* (the tick's block was already added) */
CHECK(between == NULL && block_is(0, BLOCK, 0.5f, 0.5f)); /* (the tick's block was already added, at the whole level) */
CHECK(active() == 1 && voice_with(DECIDE) == 0 && voice_pos(0) == 0);
block(1.0f, 0.0f, 0.0f);
CHECK(block_is(0, 100, 1.0f, -1.0f) && block_is(100, BLOCK, 0.0f, 0.0f) && active() == 0);
@@ -655,6 +743,8 @@ static void rom_seven(void) {
rom_sound(DECIDE, 1000, 8192, -8192), rom_sound(CANCEL, 500, 2048, 2048), rom_sound(TAB_LEFT, 500, 4096, 0);
rom_sound(TAB_RIGHT, 500, 0, 4096), rom_sound(FANFARE, 1500, 8192, 8192); /* ((Triforce) the Mods screen's install done) */
rom_sound(SYS_CURSOR, 600, 2048, 4096), rom_sound(SYS_DECIDE, 700, 4096, 2048); /* ((Triforce, 11-17) the Mods entry's */
/* ((Triforce, 11-25) the system menu's small decide and its cancel: the roles' own, with its cursor above) */
rom_sound(M_SEL, 800, 1024, 8192), rom_sound(S_BACK, 900, 8192, 1024);
}
static void frame(float l, float r) {
for (int i = 0; i < BLOCK; i++) bl[i] = l, br[i] = r;
@@ -676,8 +766,10 @@ static void loading(void) {
rom_put(files[TAB_RIGHT], huge, sizeof huge); /* (more than a sound's file ever has: not taken) */
CHECK(atomic_load(&loaded) == 0);
load_all();
CHECK(atomic_load(&loaded) == 2 && rom_reads == 10);
CHECK(strstr(logged, "menu sounds: 5 of 10 interface sounds from the game's files"));
/* ((Triforce, 11-25) twelve files for the seventeen sounds: the roles' seven are the system menu's cursor, read for
it already, its small decide and its cancel, read once each) */
CHECK(atomic_load(&loaded) == 2 && rom_reads == 12 && rom_odd == 0);
CHECK(strstr(logged, "menu sounds: 5 of 19 interface sounds from the game's files"));
CHECK(strstr(logged, "SE_Sys_Cancel00.bwav is not a BWAV file the options play") && strstr(logged, "left out"));
CHECK(sounds[OPEN].pcm && sounds[OPEN].frames == 2000 && sounds[OPEN].pcm[0] == 0.25f && sounds[OPEN].pcm[3999] == 0.25f);
CHECK(sounds[DECIDE].pcm && sounds[DECIDE].pcm[1] == -0.25f && sounds[TAB_LEFT].pcm && sounds[TAB_LEFT].pcm[1] == 0.0f);
@@ -713,7 +805,7 @@ static void frames_and_events(void) {
frame(0.0f, 0.0f), frame(0.0f, 0.0f);
CHECK(load_requests == 1);
load_all();
CHECK(strstr(logged, "menu sounds: 10 of 10 interface sounds from the game's files") && rom_reads == 10);
CHECK(strstr(logged, "menu sounds: 19 of 19 interface sounds from the game's files") && rom_reads == 12);
frame(0.0f, 0.0f);
CHECK(load_requests == 1 && block_is(0, BLOCK, 0.0f, 0.0f) && active() == 0);
/* a sound asked for is in the very next block, at the row's level, over what the block holds */
@@ -742,17 +834,17 @@ static void frames_and_events(void) {
row_volume = 50;
frame(0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.0f, 0.0f));
/* the cursor's tick asked for at every step of a held direction: five a second are heard */
/* the cursor's tick asked for at every step of a held direction, each 15 ms: ((Triforce, 11-25) one starts each 45 ms
(one press asking twice is left out), each beside the ones before ((11-26) as the game's) */
now_ns += 1000 * kMs;
int ticks = 0;
const uint64_t ticks_before = started_n;
for (int k = 0; k < 200; k++, now_ns += 5 * kMs) { /* one second of blocks, a tick asked for at every third */
if (k % 3 == 0) ask(CURSOR);
frame(0.0f, 0.0f);
ticks += voice_with(CURSOR) >= 0 && voice_pos(voice_with(CURSOR)) == BLOCK;
CHECK(asked_at == nasked);
if (nasked > 48) nasked = asked_at = 0;
}
CHECK(ticks == 6); /* (at 0, 180, 360, 540, 720 and 900 ms) */
CHECK(started_n - ticks_before == 23); /* (at 0, 45, 90 ... 990 ms) */
now_ns += 1000 * kMs;
for (int k = 0; k < 40; k++) frame(0.0f, 0.0f);
CHECK(active() == 0);
@@ -763,7 +855,147 @@ static void frames_and_events(void) {
CHECK(asked_at == 8);
frame(0.0f, 0.0f);
CHECK(asked_at == 10);
CHECK(volume_reads > 200 && rom_reads == 10); /* (the files were read once) */
CHECK(volume_reads > 200 && rom_reads == 12); /* (the files were read once) */
}
/* ---- (Triforce, 11-25) whose sound: the settings' tabs, the Mods screen and the step back to the pause menu's System list,
a sound each (the owner: "They should be using the title screen's SFX instead of the in-game Menu SFX"), and the
environment's word for each ---- */
static int file_is(int id, const char *name) {
char want[128];
snprintf(want, sizeof want, "Sound/Resource/Stream/%s.bwav", name);
return !strcmp(files[id], want);
}
static void roles_table(void) {
static const char *const names[] = {"HOS_MENU_SOUND_SETTINGS_NAVIGATE", "HOS_MENU_SOUND_SETTINGS_SELECT", "HOS_MENU_SOUND_SETTINGS_BACK",
"HOS_MENU_SOUND_MODS_NAVIGATE", "HOS_MENU_SOUND_MODS_SELECT", "HOS_MENU_SOUND_MODS_BACK",
"HOS_MENU_SOUND_PAUSE_BACK", "HOS_MENU_SOUND_SETTINGS_ON", "HOS_MENU_SOUND_SETTINGS_OFF"};
/* the nine, after the system menu's two and the last of the sounds; each one's variable has its name */
CHECK(ROLES == 9 && S_NAV == SYS_DECIDE + 1 && P_BACK == S_NAV + 6 && S_ON == P_BACK + 1 && S_OFF + 1 == HOS_MENU_SOUND_N);
/* ((Triforce, 11-25) a toggle's On and Off, as the owner chose them: the small decide, the cancel */
CHECK(file_is(S_ON, "SE_Sys_SysMenu_DecideS00") && file_is(S_OFF, "SE_Sys_SysMenu_Cansel00"));
for (int k = 0; k < ROLES; k++) CHECK(roles[k].id == S_NAV + k && !strcmp(roles[k].env, names[k]));
/* their own files: the system menu's (the title screen's) cursor, decide and cancel, as the owner chose them: the
settings' Select the large decide (the title's Continue's), the Mods screen's the small one */
CHECK(file_is(S_NAV, "SE_Sys_SysMenu_Cursor00") && file_is(M_NAV, "SE_Sys_SysMenu_Cursor00"));
CHECK(file_is(S_SEL, "SE_Sys_SysMenu_DecideL00") && file_is(M_SEL, "SE_Sys_SysMenu_DecideS00"));
CHECK(file_is(S_BACK, "SE_Sys_SysMenu_Cansel00") && file_is(M_BACK, "SE_Sys_SysMenu_Cansel00") && file_is(P_BACK, "SE_Sys_SysMenu_Cansel00"));
/* the others as they were */
CHECK(file_is(CURSOR, "SE_Sys_Cursor00") && file_is(DECIDE, "SE_Sys_Do00") && file_is(CANCEL, "SE_Sys_Cancel00"));
CHECK(file_is(SYS_CURSOR, "SE_Sys_SysMenu_Cursor00") && file_is(SYS_DECIDE, "SE_Sys_SysMenu_DecideL00"));
CHECK(file_is(OPEN, "SE_Sys_PlusMenu_Open00") && file_is(CLOSE, "SE_Sys_PlusMenu_Close00") && file_is(FANFARE, "BGM_ItemGet_Medium"));
CHECK(file_is(TAB_LEFT, "SE_Sys_MinusMenu_TabMove_L00") && file_is(TAB_RIGHT, "SE_Sys_MinusMenu_TabMove_R00"));
for (int id = 1; id < SOUNDS; id++) CHECK(files[id] != NULL);
/* the ticks: the cursor's and the two that are a role's; the system menu's own cursor is not thinned out */
for (int id = 0; id <= SOUNDS; id++) CHECK(is_tick(id) == (id == CURSOR || id == S_NAV || id == M_NAV));
/* a sound's name: letters, digits and _, 1 to 64 */
char name[80];
memset(name, 'a', sizeof name);
name[64] = 0;
CHECK(role_name_ok(name) && role_name_ok("SE_Sys_Cursor00") && role_name_ok("SE_Sys_SysMenu_Cansel00") && role_name_ok("_") && role_name_ok("9"));
name[64] = 'a', name[65] = 0;
CHECK(!role_name_ok(name) && !role_name_ok(""));
CHECK(!role_name_ok("SE_Sys_Cursor00.bwav") && !role_name_ok("..") && !role_name_ok(".") && !role_name_ok("../SE_Sys_Cursor00"));
CHECK(!role_name_ok("Stream/SE_Sys_Cursor00") && !role_name_ok("a\\b") && !role_name_ok("C:a") && !role_name_ok("~"));
CHECK(!role_name_ok("SE Sys") && !role_name_ok(" SE") && !role_name_ok("SE-Sys") && !role_name_ok("%s%n") && !role_name_ok("a\n"));
CHECK(!role_name_ok("caf\xc3\xa9") && !role_name_ok("\x7f") && !role_name_ok("a*") && !role_name_ok("a?"));
CHECK(sizeof role_files[0] == strlen("Sound/Resource/Stream/") + 64 + strlen(".bwav") + 1);
}
static int16_t held_more[2][4000];
static void rom_named(const char *rel, uint32_t frames, int l, int r) { /* (one more of the game's files, by its path) */
for (uint32_t i = 0; i < frames; i++) held_more[0][i] = (int16_t)l, held_more[1][i] = (int16_t)r;
const Chan c[2] = {chan(0, 0, 48000, frames, held_more[0]), chan(0, 1, 48000, frames, held_more[1])};
uint64_t size;
const uint8_t *file = bwav(c, 2, &size);
rom_put(rel, file, size);
}
static void roles_set(void) {
rom_seven();
rom_named("Sound/Resource/Stream/SE_Sys_SysMenu_Error00.bwav", 1200, 4096, -4096);
rom_put("Sound/Resource/Stream/Not_A_Sound.bwav", (const uint8_t *)"not a sound at all, whatever its name says", 42);
/* nothing set: the files as roles_table found them, nothing said of a role, the environment asked once for each */
load_all();
CHECK(env_reads == 9 && !strstr(logged, "HOS_MENU_SOUND_") && rom_reads == 12 && rom_odd == 0);
CHECK(strstr(logged, "menu sounds: 19 of 19 interface sounds from the game's files"));
CHECK(file_is(S_NAV, "SE_Sys_SysMenu_Cursor00") && file_is(S_SEL, "SE_Sys_SysMenu_DecideL00") && file_is(P_BACK, "SE_Sys_SysMenu_Cansel00"));
/* (a file is decoded once: the roles that share it share its samples) */
CHECK(sounds[S_NAV].pcm && sounds[S_NAV].pcm == sounds[SYS_CURSOR].pcm && sounds[M_NAV].pcm == sounds[SYS_CURSOR].pcm);
CHECK(sounds[S_SEL].pcm && sounds[S_SEL].pcm == sounds[SYS_DECIDE].pcm && sounds[M_SEL].pcm && sounds[M_SEL].pcm != sounds[S_SEL].pcm);
CHECK(sounds[S_BACK].pcm && sounds[M_BACK].pcm == sounds[S_BACK].pcm && sounds[P_BACK].pcm == sounds[S_BACK].pcm);
/* each sounds as its file, every one whole ((Triforce, 11-26) the ticks too: they were at 0.6) */
row_volume = 100;
ask(S_SEL), ask(P_BACK);
frame(0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.125f + 0.25f, 0.0625f + 0.03125f) && load_requests == 0);
now_ns += 1000 * kMs;
for (int k = 0; k < 4; k++) frame(0.0f, 0.0f);
CHECK(active() == 0);
ask(M_NAV);
frame(0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.0625f, 0.125f));
now_ns += 1000 * kMs;
for (int k = 0; k < 3; k++) frame(0.0f, 0.0f);
CHECK(active() == 0);
/* the environment's word, read when the files are (here: again, as a new run would) */
logged[0] = 0, rom_reads = 0, env_reads = 0;
memset(sounds, 0, sizeof sounds);
put_env("HOS_MENU_SOUND_SETTINGS_NAVIGATE", "SE_Sys_Cursor00"); /* the in-game menu's tick again: the cursor's file */
put_env("HOS_MENU_SOUND_SETTINGS_SELECT", ""); /* empty: as not set */
put_env("HOS_MENU_SOUND_SETTINGS_BACK", "../../../triforce_options"); /* not a name: left out, said */
put_env("HOS_MENU_SOUND_MODS_NAVIGATE", "SE_Sys_SysMenu_Cursor00"); /* its own: nothing to say */
put_env("HOS_MENU_SOUND_MODS_SELECT", "SE_Sys_SysMenu_Error00"); /* another of the game's files */
put_env("HOS_MENU_SOUND_MODS_BACK", "SE_Sys_Typo00"); /* a name the game's files do not have: its own, said */
put_env("HOS_MENU_SOUND_PAUSE_BACK", "Not_A_Sound"); /* a file that is not a sound: its own, said */
put_env("HOS_MENU_SOUND_CURSOR", "SE_Sys_Do00"); /* (not a role: never asked for) */
load_all();
CHECK(env_reads == 9 && rom_odd == 0);
CHECK(file_is(S_NAV, "SE_Sys_Cursor00") && sounds[S_NAV].pcm && sounds[S_NAV].pcm == sounds[CURSOR].pcm);
CHECK(strstr(logged, "menu sounds: HOS_MENU_SOUND_SETTINGS_NAVIGATE: Sound/Resource/Stream/SE_Sys_Cursor00.bwav, the environment's "
"(its own: Sound/Resource/Stream/SE_Sys_SysMenu_Cursor00.bwav)"));
CHECK(file_is(S_SEL, "SE_Sys_SysMenu_DecideL00") && !strstr(logged, "HOS_MENU_SOUND_SETTINGS_SELECT"));
CHECK(file_is(S_BACK, "SE_Sys_SysMenu_Cansel00") && sounds[S_BACK].pcm && !strstr(logged, "triforce_options"));
CHECK(strstr(logged, "menu sounds: HOS_MENU_SOUND_SETTINGS_BACK: its value is not a sound's name"));
CHECK(file_is(M_NAV, "SE_Sys_SysMenu_Cursor00") && sounds[M_NAV].pcm == sounds[SYS_CURSOR].pcm && !strstr(logged, "HOS_MENU_SOUND_MODS_NAVIGATE"));
CHECK(file_is(M_SEL, "SE_Sys_SysMenu_Error00") && sounds[M_SEL].pcm && sounds[M_SEL].pcm != sounds[S_SEL].pcm && sounds[M_SEL].frames == 1200);
CHECK(strstr(logged, "menu sounds: HOS_MENU_SOUND_MODS_SELECT: Sound/Resource/Stream/SE_Sys_SysMenu_Error00.bwav, the environment's"));
CHECK(file_is(M_BACK, "SE_Sys_SysMenu_Cansel00") && sounds[M_BACK].pcm && sounds[M_BACK].pcm == sounds[S_BACK].pcm);
CHECK(strstr(logged, "menu sounds: HOS_MENU_SOUND_MODS_BACK: no sound Sound/Resource/Stream/SE_Sys_Typo00.bwav in the game's files: "
"its own, Sound/Resource/Stream/SE_Sys_SysMenu_Cansel00.bwav"));
CHECK(file_is(P_BACK, "SE_Sys_SysMenu_Cansel00") && sounds[P_BACK].pcm == sounds[S_BACK].pcm);
CHECK(strstr(logged, "Sound/Resource/Stream/Not_A_Sound.bwav is not a BWAV file the options play") &&
strstr(logged, "menu sounds: HOS_MENU_SOUND_PAUSE_BACK: no sound Sound/Resource/Stream/Not_A_Sound.bwav in the game's files"));
CHECK(file_is(CURSOR, "SE_Sys_Cursor00") && file_is(DECIDE, "SE_Sys_Do00") && !strstr(logged, "HOS_MENU_SOUND_CURSOR"));
/* (the ten, the small decide (a toggle's On), the cancel, the error sound, and the two that are not there or not a
sound) */
CHECK(rom_reads == 15 && strstr(logged, "menu sounds: 19 of 19 interface sounds from the game's files"));
/* the settings' tick is the in-game menu's now, still a tick; the Mods screen's decide the error sound */
ask(S_NAV);
frame(0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.5f, 0.5f));
now_ns += 1000 * kMs;
for (int k = 0; k < 20; k++) frame(0.0f, 0.0f);
CHECK(active() == 0);
ask(M_SEL);
frame(0.0f, 0.0f);
CHECK(block_is(0, BLOCK, 0.125f, -0.125f));
}
static void roles_long(void) { /* a value longer than a name may be, and one of 64: a run of its own (the files are read once) */
static char longer[80], longest[80];
memset(longer, 'b', 65), memset(longest, 'c', 64);
rom_seven();
put_env("HOS_MENU_SOUND_MODS_BACK", longer);
put_env("HOS_MENU_SOUND_PAUSE_BACK", longest);
load_all();
CHECK(file_is(M_BACK, "SE_Sys_SysMenu_Cansel00") && strstr(logged, "menu sounds: HOS_MENU_SOUND_MODS_BACK: its value is not a sound's name"));
/* (64: a name, asked for whole, not in the game's files: its own again) */
char want[200];
snprintf(want, sizeof want, "menu sounds: HOS_MENU_SOUND_PAUSE_BACK: Sound/Resource/Stream/%s.bwav, the environment's", longest);
CHECK(strlen(longest) == 64 && strstr(logged, want));
snprintf(want, sizeof want, "menu sounds: HOS_MENU_SOUND_PAUSE_BACK: no sound Sound/Resource/Stream/%s.bwav in the game's files", longest);
CHECK(strstr(logged, want) && file_is(P_BACK, "SE_Sys_SysMenu_Cansel00"));
CHECK(sounds[P_BACK].pcm && sounds[P_BACK].pcm == sounds[S_BACK].pcm && rom_odd == 0 && rom_reads == 13);
CHECK(strstr(logged, "menu sounds: 19 of 19 interface sounds from the game's files"));
}
/* ---- the end of nn_audio.c's render_frame, cut out as it is: the options' sounds, the Master volume, the 16 bits ---- */
@@ -842,6 +1074,8 @@ int main(int argc, char **argv) {
else if (!strcmp(what, "load")) loading();
else if (!strcmp(what, "frames")) frames_and_events();
else if (!strcmp(what, "master")) master_and_clipping();
else if (!strcmp(what, "roles")) roles_table(), roles_set();
else if (!strcmp(what, "roles-long")) roles_long();
else return printf("no such scenario: %s\n", what), 2;
if (fails) return printf("%s: %d checks failed\n", what, fails), 1;
printf("%s: ok\n", what);