1#include "effectmacro.hpp"
8#include "effectgroup.hpp"
14sceVu0FVECTOR wind_dir = {0.0f, 0.0f, 0.0f, 0.0f};
20void EffectMacroStep(
float *wind) {
21 sceVu0CopyVector(wind_dir, wind);
23 smoke_tex = TexManager.GetTexture(
"smoke", -1);
24 sibuki_tex = TexManager.GetTexture(
"shibuki", -1);
25 hamon_tex = TexManager.GetTexture(
"hamon", -1);
28void EffectSmoke(
CEffectGroup *group,
float *position,
float size,
int period) {
32 if (effect_count % period != 0) {
38 sceVu0CopyVector(effect.
position, position);
41 if (rand() % 2 != 0) {
53 effect.
velocity[1] += 0.2f + 0.2f * (float) rand() / 2.1474836e9f;
56 effect.
scale[0] = size;
57 effect.
scale[1] = size;
79 group->EnterEffect(&effect);
82void EffectWaterSpray(
CEffectGroup *group,
float *position,
float *extent,
int period,
int phase) {
85 if ((effect_count + phase) % period != 0) {
91 sceVu0CopyVector(effect.
position, position);
96 float spread_x = 0.2f * extent[0];
97 float spread_z = 0.2f * extent[2];
98 float rise = 0.1f * extent[1] * (1.0f + (float) rand() / 2.1474836e9f);
99 float width_grown = rise + 0.5f * (extent[0] + extent[2]);
100 float height_grown = extent[1] + rise;
102 effect.
velocity[0] = spread_x * (float) rand() / 2.1474836e9f - 0.5f * spread_x;
103 effect.
velocity[2] = (spread_x * (float) rand() / 2.1474836e9f - 0.5f * spread_z) - 0.5f;
104 effect.
velocity[1] = 1.0f + 0.5f * (float) rand() / 2.1474836e9f;
108 effect.
scale[0] = 0.2f * width_grown;
109 effect.
scale[1] = 0.2f * height_grown;
113 effect.
width = 10.0f;
115 group->EnterEffect(&effect);
118void EffectHamon(
CEffectGroup *group,
float *position,
float size) {
123 sceVu0CopyVector(effect.
position, position);
133 effect.
scale[0] = 0.0f;
134 effect.
scale[1] = 0.0f;
135 effect.
scale[2] = 0.0f;
140 group->EnterEffect(&effect);
143void DepthOfField(
float *focus,
int level,
int alpha,
int blur) {
144 static float rd[21][15];
154 MGGetFBuffTex(&frame);
155 image = *(
sceGsTex0 *) &TexManager.GetTexture(
"frame_image", -1)->
tex0;
156 frame.PSM = SCE_GS_PSMCT24;
157 MGStretchMoveImage(&frame,
CRect_i_(0, 0, 0x2800, (SCREEN_HALF_HEIGHT << 4)), &image,
CRect_i_(0, 0, 0x1400, (SCREEN_HALF_HEIGHT << 4)));
158 MGStretchMoveImage(&image,
CRect_i_(0, 0, 0x1400, (SCREEN_HALF_HEIGHT << 4)), &image,
CRect_i_(0x1400, 0, 0xA00, (SCREEN_HALF_HEIGHT << 4)));
160 sceVu0FVECTOR depth_point[4] = {
161 {0.0f, 0.0f, focus[0], 1.0f},
162 {0.0f, 0.0f, focus[0] + 30.0f, 1.0f},
163 {0.0f, 0.0f, focus[1], 1.0f},
164 {0.0f, 0.0f, focus[1] + 20.0f, 1.0f},
168 for (i = 0; i < 4; i++) {
169 sceVu0ApplyMatrix(depth_point[i], mgRenderInfo.
screen, depth_point[i]);
170 depth_point[i][2] /= depth_point[i][3];
171 screen[i][2] = (int) depth_point[i][2];
174 sceVif1PkCnt(Vif1Packet, 0);
175 sceVif1PkOpenDirectCode(Vif1Packet, 0);
176 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
177 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
178 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEX1_1, 0x61);
179 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEX0_1, *(u_long *) &image);
186 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEST_1, *(u_long *) &test);
188 zbuffer.bits.zmsk = 1;
189 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ZBUF_1, *(u_long *) &zbuffer);
190 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_RGBAQ, SCE_GS_SET_RGBAQ(0x80, 0x80, 0x80, 0x80, 0));
191 sceVif1PkCloseGifTag(Vif1Packet);
192 sceVif1PkCloseDirectCode(Vif1Packet);
194 for (phase = 0; phase < 1; phase++) {
195 sceVif1PkCnt(Vif1Packet, 0);
196 sceVif1PkOpenDirectCode(Vif1Packet, 0);
197 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
199 for (k = 0; k < 8; k++) {
200 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_PRIM, 0x15C);
202 for (j = 0; j < 41; j++) {
203 int x = (j << 8) + 0x6C00;
205 int y = v + GS_Y_OFFSET;
207 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_RGBAQ, SCE_GS_SET_RGBAQ(0x80, 0x80, 0x80, alpha, 0));
208 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v));
209 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x, y, screen[(j + phase) % 2][2], 0));
210 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v + 0x200));
211 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x, y + 0x200, screen[(j + phase) % 2][2], 0));
215 sceVif1PkCloseGifTag(Vif1Packet);
216 sceVif1PkCloseDirectCode(Vif1Packet);
219 sceVif1PkCnt(Vif1Packet, 0);
220 sceVif1PkOpenDirectCode(Vif1Packet, 0);
221 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
225 for (i = 0; i < 21; i++) {
226 for (j = 0; j < 15; j++) {
228 rd[i][j] += 0.2f * ((float) blur * ((
float) rand() / 2147483648.0f - 0.5f));
230 if (rd[i][j] < 0.0f) {
234 if (rd[i][j] > (
float) blur) {
235 rd[i][j] = (float) blur;
249 for (j = 0; j < 15; j++) {
251 for (j = 0; j < 14; j++) {
253 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_PRIM, 0x15C);
254 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_RGBAQ, SCE_GS_SET_RGBAQ(0x80, 0x80, 0x80, alpha, 0));
256 for (i = 0; i < 21; i++) {
257 int x = (i << 9) + 0x6C00;
259 int y = v + GS_Y_OFFSET;
260 int y_bottom = y + 0x100;
261 int u = (i << 7) + 0x1400;
262 int v_bottom = v + 0x100;
265 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v));
266 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x - (
int) rd[i][j], y, screen[2 + i % 2][2], 0));
267 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v_bottom));
268 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x - (
int) rd[i][j + 1], y_bottom, screen[2 + i % 2][2], 0));
270 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v));
271 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x, y, screen[2 + i % 2][2], 0));
272 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_UV, SCE_GS_SET_UV(u, v_bottom));
273 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x, y_bottom, screen[2 + i % 2][2], 0));
279 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
280 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEST_1, *(u_long *) &mgPixelTest);
281 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ZBUF_1, *(u_long *) &mgZBuffer);
282 sceVif1PkCloseGifTag(Vif1Packet);
283 sceVif1PkCloseDirectCode(Vif1Packet);
int position_oscillation_flags
float position_oscillation_rate[4]
float position_oscillation_scale[4]