From d8578f1f581f666f8b120dfb33e666262e5816cd Mon Sep 17 00:00:00 2001 From: luigi__ Date: Thu, 8 Oct 2009 19:58:15 +0000 Subject: [PATCH] Re-implement BIOS SoundBias function more correctly. Get rid of SPU_ReadLong. (is the bias feature really used by many games anyway? I don't think so) --- desmume/src/SPU.cpp | 9 --------- desmume/src/SPU.h | 1 - desmume/src/bios.cpp | 12 ++++++------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/desmume/src/SPU.cpp b/desmume/src/SPU.cpp index 5c934bca6..4f0850097 100644 --- a/desmume/src/SPU.cpp +++ b/desmume/src/SPU.cpp @@ -515,15 +515,6 @@ void SPU_struct::KeyOn(int channel) ////////////////////////////////////////////////////////////////////////////// -u32 SPU_ReadLong(u32 addr) -{ - addr &= 0xFFF; - - return T1ReadLong(MMU.ARM7_REG, addr); -} - -////////////////////////////////////////////////////////////////////////////// - void SPU_struct::WriteByte(u32 addr, u8 val) { channel_struct &thischan=channels[(addr >> 4) & 0xF]; diff --git a/desmume/src/SPU.h b/desmume/src/SPU.h index 0adb14520..21d8f38e8 100644 --- a/desmume/src/SPU.h +++ b/desmume/src/SPU.h @@ -139,7 +139,6 @@ void SPU_KeyOn(int channel); void SPU_WriteByte(u32 addr, u8 val); void SPU_WriteWord(u32 addr, u16 val); void SPU_WriteLong(u32 addr, u32 val); -u32 SPU_ReadLong(u32 addr); void SPU_Emulate_core(void); void SPU_Emulate_user(void); diff --git a/desmume/src/bios.cpp b/desmume/src/bios.cpp index 5852f3746..951b6281c 100644 --- a/desmume/src/bios.cpp +++ b/desmume/src/bios.cpp @@ -1049,12 +1049,12 @@ TEMPLATE static u32 isDebugger() TEMPLATE static u32 SoundBias() { - u32 current = SPU_ReadLong(0x4000504); - if (cpu->R[0] > current) - SPU_WriteLong(0x4000504, current + 0x1); - else - SPU_WriteLong(0x4000504, current - 0x1); - return cpu->R[1]; + u32 curBias = _MMU_read32(0x04000504); + u32 newBias = (curBias == 0) ? 0x000:0x200; + u32 delay = (newBias > curBias) ? (newBias-curBias) : (curBias-newBias); + + _MMU_write32(0x04000504, newBias); + return cpu->R[1] * delay; } TEMPLATE static u32 getBootProcs()