PS2SDK
PS2 Homebrew Libraries
ssp.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 int SsSeqSkip(s16 sep_no, s16 seq_no, char unit, s16 count)
14 {
15  int m_unk54;
16  int v5;
17  libsnd2_sequence_struct_t *score_struct;
18  void (*noteon)(s16, s16, u8, u8);
19  u8 *m_unk04;
20  int m_unk84;
21  u8 *v19;
22 
23  m_unk54 = 0;
24  v5 = 0;
25  score_struct = &_ss_score[sep_no][seq_no];
26  if ( count < 0 )
27  return -1;
28  if ( !count )
29  return 0;
30  noteon = SsFCALL.noteon;
31  m_unk04 = score_struct->m_unk04;
32  _snd_ev_flag = 1;
33  score_struct->m_seq_ptr = m_unk04;
34  SsFCALL.noteon = dmy_nothing1;
35  switch ( unit )
36  {
37  case SSSKIP_TICK:
38  m_unk54 = score_struct->m_unk54 * count;
39  break;
40  case SSSKIP_NOTE4:
41  m_unk54 = count * 10 * score_struct->m_resolution_of_quarter_note;
42  break;
43  case SSSKIP_NOTE8:
44  m_unk54 = count * 5 * score_struct->m_resolution_of_quarter_note;
45  break;
46  case SSSKIP_BAR:
47  {
48  int m_rhythm_d;
49 
50  m_rhythm_d = score_struct->m_rhythm_d;
51  if ( m_rhythm_d == 2 )
52  {
53  m_unk54 = score_struct->m_rhythm_n * count * 10 * score_struct->m_resolution_of_quarter_note;
54  }
55  else
56  {
57  int v15;
58 
59  v15 = count * 10 * score_struct->m_resolution_of_quarter_note;
60  if ( (1 << m_rhythm_d) == 0 )
61  __builtin_trap();
62  if ( 1 << m_rhythm_d == -1 && (unsigned int)v15 == 0x80000000 )
63  __builtin_trap();
64  m_unk54 = v15 / (1 << m_rhythm_d) * score_struct->m_rhythm_n;
65  }
66  break;
67  }
68  default:
69  break;
70  }
71  do
72  {
73  do
74  {
75  if ( _SsGetSeqData(sep_no, seq_no) == 1 )
76  {
77  m_unk54 = score_struct->m_unk54;
78  m_unk84 = score_struct->m_unk84;
79  v19 = score_struct->m_unk04;
80  v5 = -1;
81  score_struct->m_unk10 = 0;
82  score_struct->m_delta_value = m_unk84;
83  score_struct->m_seq_ptr = v19;
84  score_struct->m_unk0C = v19;
85  break;
86  }
87  } while ( !score_struct->m_delta_value );
88  m_unk54 -= score_struct->m_delta_value;
89  } while ( score_struct->m_unk54 < m_unk54 );
90  SsFCALL.noteon = noteon;
91  _snd_ev_flag = 0;
92  return v5;
93 }
libsnd2_sequence_struct_
Definition: libsnd2_internal.h:47
count
u32 count
start sector of fragmented bd/file
Definition: usbhdfsd-common.h:3