PS2SDK
PS2 Homebrew Libraries
ssaccele.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 
13 void _SsSndSetAccele(s16 sep_no, s16 seq_no, int tempo, int v_time)
14 {
15  libsnd2_sequence_struct_t *score_struct;
16  unsigned int m_flags;
17 
18  score_struct = &_ss_score[sep_no][seq_no];
19  m_flags = score_struct->m_flags;
20  if ( (m_flags & 1) != 0 && (m_flags & 2) == 0 )
21  {
22  int m_unk94;
23 
24  m_unk94 = score_struct->m_unk94;
25  if ( tempo != m_unk94 )
26  {
27  score_struct->m_unkA8 = v_time;
28  score_struct->m_unkA4 = v_time;
29  score_struct->m_unkAC = tempo;
30  if (
31  ((tempo - m_unk94 >= 0) && (tempo - m_unk94 < v_time))
32  || ((tempo - m_unk94 < 0) && (m_unk94 - tempo < v_time)) )
33  {
34  int v9;
35  int m_unkA8;
36  int v11;
37  int v13;
38 
39  v9 = score_struct->m_unk94;
40  m_unkA8 = score_struct->m_unkA8;
41  v11 = tempo - v9;
42  v13 = v9 - tempo;
43  if ( v11 < 0 )
44  {
45  if ( v13 == -1 && (unsigned int)m_unkA8 == 0x80000000 )
46  __builtin_trap();
47  score_struct->m_unk4E = m_unkA8 / v13;
48  }
49  else if ( v11 > 0 )
50  {
51  score_struct->m_unk4E = m_unkA8 / v11;
52  }
53  else
54  {
55  __builtin_trap();
56  }
57  }
58  else
59  {
60  int v14;
61  int v15;
62  int v16;
63 
64  v14 = score_struct->m_unk94;
65  v15 = score_struct->m_unkA8;
66  v16 = tempo - v14;
67  if ( tempo - v14 < 0 )
68  v16 = v14 - tempo;
69  if ( v15 == -1 && (unsigned int)v16 == 0x80000000 )
70  __builtin_trap();
71  score_struct->m_unk4E = ~(u16)(v16 / v15);
72  }
73  score_struct->m_flags |= 0x40u;
74  score_struct->m_flags &= ~0x80u;
75  }
76  }
77 }
78 
79 void SsSeqSetAccelerando(s16 seq_no, int tempo, int v_time)
80 {
81  _SsSndSetAccele(seq_no, 0, tempo, v_time);
82 }
83 
84 void SsSepSetAccelerando(s16 seq_no, s16 sep_no, int tempo, int v_time)
85 {
86  _SsSndSetAccele(seq_no, sep_no, tempo, v_time);
87 }
libsnd2_sequence_struct_
Definition: libsnd2_internal.h:47