DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
bombeffect.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3
4#include "title/bombeffect.hpp"
5
6#include "camera.hpp"
7#include "mglib.hpp"
8#include "rect.hpp"
9#include "snd.hpp"
10#include "texture.hpp"
11
12void CBombEffect::Draw(CCamera *camera, int dust_only) {
13 sceVu0FVECTOR camera_position;
14 sceVu0FVECTOR direction;
15 sceVu0FVECTOR position;
16 int top_left[4];
17 int bottom_right[4];
18 int top_right[4];
19 int bottom_left[4];
20 sceGsAlpha alpha;
21 sceGsZbuf zbuf;
22 s32 i;
23
24 camera->GetPos(camera_position);
25
26 alpha = mgAlpha;
27 alpha.bits.a = 0;
28 alpha.bits.b = 2;
29 alpha.bits.c = 0;
30 alpha.bits.d = 1;
31 MGSetGsALPHA(&alpha);
32
33 zbuf = mgZBuffer;
34 zbuf.bits.zmsk = 1;
35 MGSetGsZBUF(&zbuf);
36
37 for (i = 0; i < 8; i++) {
38 if (active[i] != 1) {
39 continue;
40 }
41
42 if (counters[i] < 0) {
43 continue;
44 }
45
46 direction[0] = camera_position[0] - positions[i][0];
47 direction[1] = 0.0f;
48 direction[2] = camera_position[2] - positions[i][2];
49 sceVu0Normalize(direction, direction);
50 direction[0] *= 7.0f * i + phases[i];
51 direction[2] *= 7.0f * i + phases[i];
52
53 position[0] = direction[0] + positions[i][0];
54 position[1] = direction[1] + positions[i][1];
55 position[2] = direction[2] + positions[i][2];
56 position[3] = 1.0f;
57
58 if (MGRotTransPers3DSprite(top_left, bottom_right, position, sizes[i], sizes[i] / 2.0f, 0) != 1) {
59 continue;
60 }
61
62 top_right[0] = bottom_right[0];
63 top_right[1] = top_left[1];
64 top_right[2] = top_left[2];
65 top_right[3] = top_left[3];
66 bottom_left[0] = top_left[0];
67 bottom_left[1] = bottom_right[1];
68 bottom_left[2] = bottom_right[2];
69 bottom_left[3] = bottom_right[3];
70
71 if (i < 5) {
72 CRect_i_ rect;
73
74 if (dust_only != 0) {
75 continue;
76 }
77
78 rect.x = 0;
79 rect.y = 0;
80 rect.width = 128;
81 rect.height = 128;
82 set3DSprite(Vif1Packet, TexManager.GetTexture("bakuha1", -1), rect, top_left, top_right, bottom_left, bottom_right, static_cast<u8>(alphas[i]));
83 } else {
84 CRect_i_ rect;
85
86 rect.x = 0;
87 rect.y = 0;
88 rect.width = 128;
89 rect.height = 128;
90 set3DSprite(Vif1Packet, TexManager.GetTexture("sunakemuri", -1), rect, top_left, top_right, bottom_left, bottom_right, static_cast<u8>(alphas[i]));
91 }
92 }
93
94 MGSetGsALPHA(0);
95 MGSetGsZBUF(0);
96}
97
99 s32 i;
100
101 for (i = 0; i < 5; i++) {
102 if (active[i] != 1) {
103 continue;
104 }
105
106 switch (phases[i]) {
107 case BOMB_PHASE_BURST:
108 counters[i]++;
109 sizes[i] += 8.0f;
110 alphas[i] += 4.0f;
111
112 if (counters[i] < 3) {
113 break;
114 }
115
116 counters[i] = 0;
117 phases[i]++;
118 break;
119 case BOMB_PHASE_BLOOM:
120 counters[i]++;
121 sizes[i] += 1.0f;
122 alphas[i] += 8.0f;
123
124 if (counters[i] < 4) {
125 break;
126 }
127
128 counters[i] = 0;
129 phases[i]++;
130 break;
131 case BOMB_PHASE_LINGER:
132 counters[i]++;
133 sizes[i] += 0.3f;
134 alphas[i] -= 3.0f;
135
136 if (counters[i] < 20) {
137 break;
138 }
139
140 counters[i] = 0;
141 phases[i]++;
142 break;
143 case BOMB_PHASE_DISSIPATE:
144 counters[i]++;
145 sizes[i] -= 0.1f;
146 alphas[i] -= 2.0f;
147
148 if (counters[i] < 80) {
149 break;
150 }
151
152 active[i] = 0;
153 break;
154 }
155 }
156
157 for (i = 5; i < 8; i++) {
158 if (active[i] != 1) {
159 continue;
160 }
161
162 switch (phases[i]) {
163 case BOMB_PHASE_BURST:
164 counters[i]++;
165 sizes[i] += 16.0f;
166
167 if (counters[i] < 3) {
168 break;
169 }
170
171 counters[i] = 0;
172 phases[i]++;
173 break;
174 case BOMB_PHASE_BLOOM:
175 counters[i]++;
176 sizes[i] += 8.0f;
177
178 if (counters[i] < 4) {
179 break;
180 }
181
182 counters[i] = 0;
183 phases[i]++;
184 break;
185 case BOMB_PHASE_LINGER:
186 counters[i]++;
187 sizes[i] += 0.3f;
188
189 if (counters[i] < 20) {
190 break;
191 }
192
193 counters[i] = 0;
194 phases[i]++;
195 break;
196 case BOMB_PHASE_DISSIPATE:
197 counters[i]++;
198 sizes[i] -= 0.1f;
199 alphas[i] -= 2.0f;
200
201 if (counters[i] < 80) {
202 break;
203 }
204
205 active[i] = 0;
206 break;
207 }
208 }
209}
void Draw(CCamera *camera, int dust_only)
s32 phases[8]
s32 counters[8]
float sizes[8]
sceVu0FVECTOR positions[8]
float alphas[8]
s32 active[8]
void GetPos(float *pos)
Definition camera.cpp:230
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19