11#include "libsnd2_internal.h"
13void _SsSeqPlay(s16 sep_no, s16 seq_no)
20 score_struct = &_ss_score[sep_no][seq_no];
21 m_unk54 = score_struct->m_unk54;
22 m_delta_value = score_struct->m_delta_value;
23 diff1 = m_delta_value - m_unk54;
30 v11 = score_struct->m_delta_value;
31 if ( m_unk54 < m_delta_value )
39 _SsGetSeqData(sep_no, seq_no);
40 v14 = score_struct->m_delta_value;
42 v15 = score_struct->m_unk54;
45 }
while ( v11 < v15 );
46 score_struct->m_delta_value = v10;
50 if ( score_struct->m_unk52 > 0 )
52 score_struct->m_unk52 -= 1;
55 if ( score_struct->m_unk52 )
57 score_struct->m_delta_value = diff1;
60 score_struct->m_unk52 = score_struct->m_unk54;
61 score_struct->m_delta_value -= 1;
65void _SsSeqGetEof(s16 sep_no, s16 seq_no)
71 score_struct = &_ss_score[sep_no][seq_no];
72 m_l_count = score_struct->m_l_count;
73 score_struct->m_unk21 += 1;
74 if ( m_l_count != SSPLAY_INFINITY )
76 if ( score_struct->m_unk21 >= m_l_count )
78 score_struct->m_flags &= ~1u;
79 score_struct->m_flags &= ~8u;
80 score_struct->m_flags &= ~2u;
81 score_struct->m_flags |= 0x200u;
82 score_struct->m_flags |= 4u;
83 score_struct->m_play_mode = SSPLAY_PAUSE;
84 if ( (score_struct->m_flags & 0x400) != 0 )
85 score_struct->m_unk08 = score_struct->m_unk0C;
87 score_struct->m_unk08 = score_struct->m_unk04;
88 if ( score_struct->m_next_sep != -1 )
90 score_struct->m_play_mode = SSPLAY_PAUSE;
91 _SsSndNextSep(score_struct->m_next_sep, score_struct->m_next_seq);
92 _SsVmSeqKeyOff(sep_no | (seq_no << 8));
94 _SsVmSeqKeyOff(sep_no | (seq_no << 8));
95 score_struct->m_delta_value = score_struct->m_unk54;
99 score_struct->m_unk88 = 0;
100 score_struct->m_unk1C = 0;
101 score_struct->m_delta_value = 0;
102 if ( (score_struct->m_flags & 0x400) != 0 )
103 m_unk04 = score_struct->m_unk0C;
105 m_unk04 = score_struct->m_unk04;
106 score_struct->m_seq_ptr = m_unk04;
107 score_struct->m_unk08 = m_unk04;
112 score_struct->m_unk88 = 0;
113 score_struct->m_unk1C = 0;
114 score_struct->m_delta_value = 0;
115 if ( (score_struct->m_flags & 0x400) != 0 )
116 score_struct->m_seq_ptr = score_struct->m_unk0C;
118 score_struct->m_seq_ptr = score_struct->m_unk04;
122int _SsGetSeqData(s16 sep_no, s16 seq_no)
129 score_struct = &_ss_score[sep_no][seq_no];
130 midi_byte = *(score_struct->m_seq_ptr);
131 score_struct->m_seq_ptr += 1;
132 if ( (score_struct->m_flags & 0x401) == 0x401 )
134 if ( score_struct->m_seq_ptr == score_struct->m_unk10 + 1 )
136 _SsSeqGetEof(sep_no, seq_no);
140 if ( (midi_byte & 0x80) != 0 )
142 score_struct->m_channel_idx = midi_byte & 0xF;
143 switch ( midi_byte & 0xF0 )
149 score_struct->m_running_status = 0x90;
150 midi_byte_next_1 = *(score_struct->m_seq_ptr);
151 score_struct->m_seq_ptr += 1;
152 midi_byte_1 = *(score_struct->m_seq_ptr);
153 score_struct->m_seq_ptr += 1;
154 score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no);
155 SsFCALL.noteon(sep_no, seq_no, midi_byte_next_1, midi_byte_1);
159 score_struct->m_running_status = 0xB0;
160 score_struct->m_seq_ptr += 1;
161 SsFCALL.control[CC_NUMBER](sep_no, seq_no, midi_byte);
164 score_struct->m_running_status = 0xC0;
165 score_struct->m_seq_ptr += 1;
166 SsFCALL.programchange(sep_no, seq_no, midi_byte);
169 score_struct->m_running_status = 0xE0;
170 score_struct->m_seq_ptr += 1;
171 SsFCALL.pitchbend(sep_no, seq_no);
174 score_struct->m_running_status = -1;
175 midi_byte_2 = *(score_struct->m_seq_ptr);
176 score_struct->m_seq_ptr += 1;
177 if ( midi_byte_2 == 0x2F )
179 _SsSeqGetEof(sep_no, seq_no);
182 SsFCALL.metaevent(sep_no, seq_no, midi_byte);
190 switch ( score_struct->m_running_status )
196 midi_byte_3 = *(score_struct->m_seq_ptr);
197 score_struct->m_seq_ptr += 1;
198 score_struct->m_delta_value = _SsReadDeltaValue(sep_no, seq_no);
199 SsFCALL.noteon(sep_no, seq_no, midi_byte, midi_byte_3);
203 SsFCALL.control[CC_NUMBER](sep_no, seq_no, midi_byte);
206 SsFCALL.programchange(sep_no, seq_no, midi_byte);
209 SsFCALL.pitchbend(sep_no, seq_no);
212 if ( midi_byte == 0x2F )
214 _SsSeqGetEof(sep_no, seq_no);
217 SsFCALL.metaevent(sep_no, seq_no, midi_byte);