@@ -133,9 +133,11 @@ static void SPUUploadInstruments(uint32_t SpuAddr, const uint8_t* data, uint32_t
133
133
134
134
static void SPUUnMute () { SPU_CTRL = 0xc000 ; }
135
135
136
- static void SPUSetVoiceVolume (int voiceID , uint16_t left , uint16_t right ) {
137
- SPU_VOICES [voiceID ].volumeLeft = left >> 2 ;
138
- SPU_VOICES [voiceID ].volumeRight = right >> 2 ;
136
+ static uint32_t s_masterVolume = 16384 ;
137
+
138
+ static void SPUSetVoiceVolume (int voiceID , uint32_t left , uint32_t right ) {
139
+ SPU_VOICES [voiceID ].volumeLeft = (left * s_masterVolume ) >> 16 ;
140
+ SPU_VOICES [voiceID ].volumeRight = (right * s_masterVolume ) >> 16 ;
139
141
}
140
142
141
143
static void SPUSetStartAddress (int voiceID , uint32_t spuAddr ) { SPU_VOICES [voiceID ].sampleStartAddr = spuAddr >> 3 ; }
@@ -804,3 +806,18 @@ void MOD_PlayNote(unsigned channel, unsigned sampleID, unsigned note, int16_t vo
804
806
int32_t newPeriod = channelData -> period = MOD_PeriodTable [note ];
805
807
SETVOICESAMPLERATE (channel , newPeriod );
806
808
}
809
+
810
+ void MOD_PlaySoundEffect (unsigned channel , unsigned sampleID , unsigned note , int16_t volume ) {
811
+ uint32_t s_prevVolume = s_masterVolume ;
812
+ s_masterVolume = 16384 ;
813
+ MOD_PlayNote ( channel , sampleID , note , volume );
814
+ s_masterVolume = s_prevVolume ;
815
+ }
816
+
817
+ void MOD_SetMusicVolume (uint32_t musicVolume ) {
818
+ s_masterVolume = musicVolume ;
819
+ const unsigned channels = MOD_Channels ;
820
+ for (unsigned channel = 0 ; channel < MOD_Channels ; channel ++ ) {
821
+ SETVOICEVOLUME (channel , s_channelData [channel ].volume );
822
+ }
823
+ }
0 commit comments