From 5053485aaca69c052810867e836d9be08df06910 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Fri, 30 May 2025 09:38:48 -0400 Subject: [PATCH] Fix emusound/Sound_Read & usage in ks_nes_core --- src/static/Famicom/ks_nes_core.cpp | 2 -- src/static/jaudio_NES/game/emusound.c | 25 ++++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/static/Famicom/ks_nes_core.cpp b/src/static/Famicom/ks_nes_core.cpp index e7c4df3a..0d7db515 100644 --- a/src/static/Famicom/ks_nes_core.cpp +++ b/src/static/Famicom/ks_nes_core.cpp @@ -8,8 +8,6 @@ #include "_mem.h" #include "dolphin/os.h" -extern "C" u8 Sound_Read(u16 reg_addr); - // TODO: verify function signatures. // TODO: replace hard-coded function pointers with function names. diff --git a/src/static/jaudio_NES/game/emusound.c b/src/static/jaudio_NES/game/emusound.c index 37a481bf..0b57181d 100644 --- a/src/static/jaudio_NES/game/emusound.c +++ b/src/static/jaudio_NES/game/emusound.c @@ -1846,23 +1846,25 @@ void EmuSound_Exit() { exitflag = TRUE; } -u8 Sound_Read(u16 param_1, u32 param_2, u32 param_3, u32 param_4, u32 param_5) { - u8 a, b, c, d, e; - if (param_1 == 0x5015) { +u8 Sound_Read(u16 reg_addr) { + if (reg_addr == 0x5015) { + u8 x, y, z; if (!DUMMY_ACTIVE[6]) { - param_3 = SoundX._00; + x = SoundX._00; } if (!DUMMY_ACTIVE[7]) { - param_4 = SoundY._00; + y = SoundY._00; } if (!DUMMY_ACTIVE[8]) { - param_5 = SoundZ._00; + z = SoundZ._00; } - return (u8)param_5 << 2 | (u8)param_4 << 1 | (param_3); - } else if (param_1 == 0x4015) { - a = SoundA._00; + return z << 2 | y << 1 | (x); + } else if (reg_addr == 0x4015) { + u8 a, b, c, d, e; if (DUMMY_ACTIVE[0]) { a = DUMMY_ACTIVE[0] - 1; + } else { + a = SoundA._00; } if (DUMMY_ACTIVE[1]) { @@ -1883,13 +1885,14 @@ u8 Sound_Read(u16 param_1, u32 param_2, u32 param_3, u32 param_4, u32 param_5) { d = SoundD._00; } - e = SoundE._00; if (DUMMY_ACTIVE[4]) { e = DUMMY_ACTIVE[4] - 1; + } else { + e = SoundE._00; } return SoundE._20 << 7 | e << 4 | d << 3 | c << 2 | b << 1 | a; } else { - switch (param_1 & 0xff) { + switch (reg_addr & 0xff) { case 0x90: return SoundF._2D; case 0x92: