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