11#include "libsnd2_internal.h"
13char SsBlockVoiceAllocation(
void)
15 if ( _snd_ev_flag == 1 )
21char SsUnBlockVoiceAllocation(
void)
29int SsAllocateVoices(u8 voices, u8 priority)
37 unsigned int m_key_stat;
42 for ( v2 = 0; (u8)v2 < (
unsigned int)voices; v2 += 1 )
53 for ( v9 = 0; (u8)v9 < _SsVmMaxVoice; v9 += 1 )
55 if ( ((1 << (u8)v9) & v3) == 0 )
59 voice_struct = &_svm_voice[(u8)v9];
60 if ( !voice_struct->m_unk1d && !voice_struct->m_key_stat )
65 m_priority = voice_struct->m_priority;
66 if ( m_priority >= v5 )
68 if ( m_priority == v5 )
70 m_key_stat = (u16)voice_struct->m_key_stat;
71 if ( m_key_stat >= v4 )
73 if ( m_key_stat != v4 || m_unk02 >= voice_struct->m_unk02 )
75 m_unk02 = (u16)voice_struct->m_unk02;
79 m_unk02 = (u16)voice_struct->m_unk02;
80 v4 = voice_struct->m_key_stat;
87 v5 = voice_struct->m_priority;
88 v4 = voice_struct->m_key_stat;
89 m_unk02 = (u16)voice_struct->m_unk02;
108 for ( v17 = 0; (u8)v17 < _SsVmMaxVoice; v17 += 1 )
112 voice_struct = &_svm_voice[(u8)v17];
113 if ( ((1 << v17) & v3) != 0 )
116 voice_struct->m_unk02 = (u8)v16;
117 voice_struct->m_priority = priority;
118 voice_struct->m_b_auto_vol = 0;
119 voice_struct->m_b_auto_pan = 0;
120 if ( voice_struct->m_unk1d == 2 )
121 SpuSetNoiseVoice(SPU_OFF, 1 << v17);
122 voice_struct->m_unk1d = 1;
126 voice_struct->m_unk02 += voices;