PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ssrit.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 _SsSndSetRit(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_unkA4 = v_time;
28 score_struct->m_unkAC = tempo;
29 score_struct->m_unkA8 = v_time;
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 __builtin_trap();
55 }
56 else
57 {
58 int v14;
59 int v15;
60 int v16;
61
62 v14 = score_struct->m_unk94;
63 v15 = score_struct->m_unkA8;
64 v16 = tempo - v14;
65 if ( tempo - v14 < 0 )
66 v16 = v14 - tempo;
67 if ( v15 == -1 && (unsigned int)v16 == 0x80000000 )
68 __builtin_trap();
69 score_struct->m_unk4E = ~(u16)(v16 / v15);
70 }
71 score_struct->m_flags |= 0x80u;
72 score_struct->m_flags &= ~0x40u;
73 }
74 }
75}
76
77void SsSeqSetRitardando(s16 sep_no, int tempo, int v_time)
78{
79 _SsSndSetRit(sep_no, 0, tempo, v_time);
80}
81
82void SsSepSetRitardando(s16 sep_no, s16 seq_no, int tempo, int v_time)
83{
84 _SsSndSetRit(sep_no, seq_no, tempo, v_time);
85}