From 14380e22b1907af86794f9bfd2f95c2d5c3baaa9 Mon Sep 17 00:00:00 2001 From: Prakxo Date: Fri, 7 Jun 2024 20:01:51 +0200 Subject: [PATCH] link radio --- config/dol_slices.yml | 3 +++ configure.py | 1 + include/jaudio_NES/kappa.h | 2 +- include/jaudio_NES/radio.h | 8 ++++++- src/static/jaudio_NES/radio.c | 43 +++++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/static/jaudio_NES/radio.c diff --git a/config/dol_slices.yml b/config/dol_slices.yml index 0654df36..0abd3f02 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -48,6 +48,9 @@ jaudio_NES/rhythm.c: .sdata: [0x80217bd0, 0x80217bd8] .sbss: [0x802183a0, 0x802183b0] .sdata2: [0x80218d60, 0x80218d78] +jaudio_NES/radio.c: + .text: [0x800165ec, 0x8001676c] + .sdata2: [0x80218d78, 0x80218d88] jaudio_NES/aictrl.c: .text: [0x80017e80, 0x80018640] .rodata: [0x800aa500, 0x800aa518] diff --git a/configure.py b/configure.py index 8feee686..c050d087 100644 --- a/configure.py +++ b/configure.py @@ -635,6 +635,7 @@ JAUDIO_FUNC_ALIGN_32_TUS = [ JAUDIO_USER_TUS = [ "verysimple.c", "melody.c", + "radio.c", "rhythm.c" ] diff --git a/include/jaudio_NES/kappa.h b/include/jaudio_NES/kappa.h index b38ae147..5f0a4eed 100644 --- a/include/jaudio_NES/kappa.h +++ b/include/jaudio_NES/kappa.h @@ -7,7 +7,7 @@ extern "C" { #endif -extern void Na_GetRadioCounter(void*); +extern void Na_GetKappaCounter(void*); #ifdef __cplusplus } diff --git a/include/jaudio_NES/radio.h b/include/jaudio_NES/radio.h index c2f878ff..05c15392 100644 --- a/include/jaudio_NES/radio.h +++ b/include/jaudio_NES/radio.h @@ -3,11 +3,17 @@ #include "types.h" +typedef struct radio_ { + /* 0x000 */ s8 unk0; + /* 0x004 */ f32 unk4; + /* 0x008 */ u16 tempo; +} radio; + #ifdef __cplusplus extern "C" { #endif -extern void Na_GetKappaCounter(void*); +extern s16 Na_GetRadioCounter(radio* radio); #ifdef __cplusplus } diff --git a/src/static/jaudio_NES/radio.c b/src/static/jaudio_NES/radio.c new file mode 100644 index 00000000..d171c5a4 --- /dev/null +++ b/src/static/jaudio_NES/radio.c @@ -0,0 +1,43 @@ +#include "jaudio_NES/radio.h" +#include "jaudio_NES/game64.h" +#include "jaudio_NES/audiowork.h" + + +s16 Na_GetRadioCounter(radio* radio) { + int unk16; + u16 tempo = 0; + + group* group = nullptr; + int unused = 0; + + + if (AG.groups[sou_now_bgm_handle].flags.enabled != 0 && AG.groups[sou_now_bgm_handle].seq_id == 0xDA) { + group = &(AG.groups)[sou_now_bgm_handle]; + + } else { + return -1; + } + + unk16 = group->unk016; + + (void)unused; + + if (unk16 < 0x2E8) { + radio->unk0 = 0; + } else { + unk16 -= 0x2E8; + radio->unk0 = (s8)(unk16 / 0x300); + unk16 = unk16 - (radio->unk0 * 0x300); + radio->unk0++; + } + if (radio->unk0 == 9) { + radio->unk4 = unk16 / 216.0f; + + } else { + radio->unk4 = unk16 / 768.0f; + } + + radio->tempo = AG.groups[sou_now_bgm_handle].tempo / 48; + tempo = radio->tempo; + return 0; +} \ No newline at end of file