PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
cres.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include "libsnd2_internal.h"
12
13void _SsSndCrescendo(s16 sep_no, s16 seq_no)
14{
15 libsnd2_sequence_struct_t *score_struct;
16
17 score_struct = &_ss_score[sep_no][seq_no];
18 score_struct->m_unkA0 += 1;
19 if ( score_struct->m_unk9C >= score_struct->m_unkA0 )
20 {
21 int mulfield_tmp;
22 int new_field_4a;
23 int vol_inc_by;
24
25 mulfield_tmp = score_struct->m_unk48 * score_struct->m_unkA0;
26 new_field_4a = mulfield_tmp / score_struct->m_unk9C;
27 if ( score_struct->m_unk9C == -1 && (unsigned int)mulfield_tmp == 0x80000000 )
28 __builtin_trap();
29 vol_inc_by = new_field_4a - score_struct->m_unk4A;
30 if ( new_field_4a != score_struct->m_unk4A )
31 {
32 int voll_clamped;
33 int volr_clamped;
34 s16 seq_left_vol;
35 s16 seq_right_vol;
36
37 score_struct->m_unk4A = new_field_4a;
38 _SsVmGetSeqVol(sep_no | (seq_no << 8), &seq_left_vol, &seq_right_vol);
39 voll_clamped = (u16)seq_left_vol + vol_inc_by;
40 if ( voll_clamped >= 128 )
41 voll_clamped = 127;
42 if ( voll_clamped < 0 )
43 voll_clamped = 0;
44 volr_clamped = (u16)seq_right_vol + vol_inc_by;
45 if ( volr_clamped >= 128 )
46 volr_clamped = 127;
47 if ( volr_clamped < 0 )
48 volr_clamped = 0;
49 _SsVmSetSeqVol(sep_no | (seq_no << 8), voll_clamped, volr_clamped);
50 if ( (voll_clamped == 127 && volr_clamped == 127) || (voll_clamped == 0 && volr_clamped == 0) )
51 {
52 score_struct->m_flags &= ~0x10u;
53 }
54 }
55 }
56 else
57 {
58 score_struct->m_flags &= ~0x10u;
59 }
60 _SsVmGetSeqVol(sep_no | (seq_no << 8), &score_struct->m_unk5C, &score_struct->m_unk5E);
61}