From 951bf4f99ec0d8adaf93994f5a9ddf16f99e7f37 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sat, 17 May 2025 18:45:30 -0400 Subject: [PATCH] hardcoded but justified --- soh/soh/stubs.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/soh/soh/stubs.c b/soh/soh/stubs.c index ddd235a96..45ad375b8 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -145,17 +145,47 @@ void Audio_osWritebackDCache(void* mem, s32 size) { } s32 osAiSetFrequency(u32 freq) { - // from libultra - // #define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ - // s32 osViClock = VI_NTSC_CLOCK; - f32 dacRateF = ((f32)48681812 / freq) + 0.5f; - u32 dacRate = dacRateF; + // this is based off the math from the original method + /* + + s32 osAiSetFrequency(u32 frequency) { + u8 bitrate; + f32 dacRateF = ((f32)osViClock / frequency) + 0.5f; + u32 dacRate = dacRateF; - if (dacRate < 132) { - return -1; + if (dacRate < 132) { + return -1; + } + + bitrate = (dacRate / 66); + if (bitrate > 16) { + bitrate = 16; + } + + HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; + HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; + return osViClock / (s32)dacRate; } - return 48681812 / (s32)dacRate; + */ + + // bitrate is unused + + // osViClock comes from + // #define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ + // s32 osViClock = VI_NTSC_CLOCK; + + // frequency was originally 32000 + + // given all of that, dacRate is + // (u32)(((f32)48681812 / 32000) + 0.5f) + // which evaluates to 1521 (which is > 132) + + // this leaves us with a final calculation of + // 48681812 / 1521 + // which evaluates to 32006 + + return 32006; } void osInvalDCache(void* vaddr, s32 nbytes) {