11#include "libsnd2_internal.h"
13s16 _SsInitSoundSeq(s16 seq_no, s16 vab_id, u8 *addr)
29 score_struct = &_ss_score[seq_no][0];
30 score_struct->m_vab_id = vab_id;
31 score_struct->m_resolution_of_quarter_note = 0;
32 score_struct->m_unk18 = 0;
33 score_struct->m_unk19 = 0;
34 score_struct->m_unk1E = 0;
35 score_struct->m_fn_idx = 0;
36 score_struct->m_unk1B = 0;
37 score_struct->m_unk1F = 0;
38 score_struct->m_channel_idx = 0;
39 score_struct->m_unk84 = 0;
40 score_struct->m_unk88 = 0;
41 score_struct->m_tempo = 0;
42 score_struct->m_unk56 = 0;
43 score_struct->m_l_count = 1;
44 score_struct->m_unk21 = 0;
45 score_struct->m_play_mode = SSPLAY_PAUSE;
46 score_struct->m_delta_value = 0;
47 score_struct->m_unk1C = 0;
48 score_struct->m_unk1D = 0;
49 score_struct->m_unk15 = 0;
50 score_struct->m_running_status = 0;
51 score_struct->m_channel_mute = 0;
52 score_struct->m_rhythm_n = 0;
53 score_struct->m_rhythm_d = 0;
54 for ( v4 = 0; v4 < 16; v4 += 1 )
56 score_struct->m_programs[v4] = v4;
57 score_struct->m_panpot[v4] = 64;
58 score_struct->m_vol[v4] = 127;
60 score_struct->m_unk52 = 1;
61 score_struct->m_seq_ptr = addr;
63 score_struct->m_seq_ptr += 7;
64 if ( v8 != 83 && v8 != 112 )
66 printf(
"This is an old SEQ Data Format.\n");
69 v9 = *(score_struct->m_seq_ptr);
70 score_struct->m_seq_ptr += 1;
73 printf(
"This is not SEQ Data.\n");
76 v11 = *(score_struct->m_seq_ptr);
77 score_struct->m_seq_ptr += 1;
78 v12 = *(score_struct->m_seq_ptr);
79 score_struct->m_seq_ptr += 1;
80 score_struct->m_resolution_of_quarter_note = v12 | (v11 << 8);
81 v13 = *(score_struct->m_seq_ptr);
82 score_struct->m_seq_ptr += 1;
83 v14 = *(score_struct->m_seq_ptr);
84 score_struct->m_seq_ptr += 1;
85 tempo = 60000000 / ((v13 << 16) | (v14 << 8) | *(score_struct->m_seq_ptr));
86 score_struct->m_seq_ptr += 1;
87 score_struct->m_tempo = tempo;
88 score_struct->m_unk94 = score_struct->m_tempo;
89 score_struct->m_rhythm_n = *(score_struct->m_seq_ptr);
90 score_struct->m_seq_ptr += 1;
91 score_struct->m_rhythm_d = *(score_struct->m_seq_ptr);
92 score_struct->m_seq_ptr += 1;
93 delta_value = _SsReadDeltaValue(seq_no, 0);
94 v20 = score_struct->m_resolution_of_quarter_note * score_struct->m_tempo;
95 score_struct->m_unk84 = delta_value;
96 score_struct->m_delta_value = delta_value;
97 score_struct->m_unk10 = 0;
98 score_struct->m_unk08 = score_struct->m_seq_ptr;
99 score_struct->m_unk04 = score_struct->m_seq_ptr;
100 score_struct->m_unk0C = score_struct->m_seq_ptr;
103 if ( 10 * v20 < (
unsigned int)(60 * tmp1) )
109 v25 = 600 * tmp1 / v20;
110 score_struct->m_unk52 = v25;
111 score_struct->m_unk54 = v25;
118 v27 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo / tmp2;
119 v28 = 10 * score_struct->m_resolution_of_quarter_note * score_struct->m_tempo % tmp2;
120 score_struct->m_unk52 = -1;
121 score_struct->m_unk54 = v27;
122 if ( (
unsigned int)(30 * tmp1) < v28 )
124 score_struct->m_unk54 = v27 + 1;
127 score_struct->m_unk56 = score_struct->m_unk54;