From 97b68cc3be71680ab7d4c70470e0b82f4e3010e7 Mon Sep 17 00:00:00 2001 From: cyberwarriorx Date: Wed, 22 Nov 2006 21:24:54 +0000 Subject: [PATCH] -Added support for Master volume --- desmume/src/SPU.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/desmume/src/SPU.c b/desmume/src/SPU.c index d2aeb6a01..160dfa415 100644 --- a/desmume/src/SPU.c +++ b/desmume/src/SPU.c @@ -147,8 +147,6 @@ int SPU_Init(int coreid, int buffersize) ////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - void SPU_Pause(int pause) { if(pause) @@ -1084,6 +1082,7 @@ void (*SPU_ChanUpdate[4][3])(channel_struct *chan) = { void SPU_MixAudio(int length) { channel_struct *chan; + u8 vol; int i; memset(SPU->sndbuf, 0, length*4*2); @@ -1092,6 +1091,8 @@ void SPU_MixAudio(int length) if (!(MMU.ARM7_REG[0x501] & 0x80)) return; + vol = MMU.ARM7_REG[0x500] & 0x7F; + for(chan = &(SPU->chan[0]); chan < &(SPU->chan[16]); chan++) { if (chan->status != CHANSTAT_PLAY) @@ -1112,6 +1113,9 @@ void SPU_MixAudio(int length) // convert from 32-bit->16-bit for (i = 0; i < length*2; i++) { + // Apply Master Volume + SPU->sndbuf[i] = SPU->sndbuf[i] * vol / 127; + if (SPU->sndbuf[i] > 0x7FFF) SPU->outbuf[i] = 0x7FFF; else if (SPU->sndbuf[i] < -0x8000)