-
Notifications
You must be signed in to change notification settings - Fork 44
/
PSOUTPUT.C
111 lines (99 loc) · 1.55 KB
/
PSOUTPUT.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "PSOUTPUT.H"
#include "PSXINPUT.H"
#include "SAVEGAME.H"
#include "STYPES.H"
static struct VIBRATION vib[2];
void SetupPadVibration(short num, short acc, short lev, short sus, int dec, int len)//604A4(<), 6101C(<) (F) (*) (D)
{
struct VIBRATION* v = &vib[num];
v->Acc = acc;
v->Lev = lev;
v->Flag = 0;
v->Rate = 0;
v->Vib = 0;
v->Sus = len - sus;
v->Dec = dec;
v->Len = len;
}
void VibratePad()//604EC(<), 61064(<) (F) (*) (D)
{
int i;
struct VIBRATION* v = &vib[0];
if (DualShock == 0 || savegame.VibrateOn == 0)
{
//loc_60510
Motors[0] = 0;
Motors[1] = 0;
return;
}
//loc_6052C
for (i = 0; i < 2; i++, v++)
{
if (v->Len != 0)
{
if (v->Flag == 0)
{
v->Rate += v->Acc;
if (v->Rate >= v->Lev)
{
v->Rate = v->Lev;
v->Flag = 1;
}//loc_605DC
}
else if (v->Flag == 1)
{
//loc_60588
if (v->Len <= v->Sus)
{
v->Flag = 2;
}//loc_605DC
}
else if (v->Flag == 2)
{
//loc_605AC
v->Rate -= v->Dec;
if (v->Rate << 16 < 0)
{
v->Rate = 0;
v->Flag = 3;
}//loc_605DC
}
//loc_605DC
v->Vib += v->Rate;
if (i != 0)
{
if (v->Vib >> 8 != 0)
{
Motors[1] = v->Vib >> 8;
v->Vib &= 0xFF;
}//loc_60650
else
{
//loc_60618
Motors[1] = 0;
}//loc_60650
}
else
{
//loc_60628
if (v->Vib >> 12 != 0)
{
Motors[0] = 1;
v->Vib -= 4096;
}
else
{
//loc_60648
Motors[0] = 0;
}
}
//loc_60650
v->Len--;
}
else
{
//loc_60664
Motors[i] = 0;
}
}
}