8#include "runeffect.hpp"
12CFireOmni::CFireOmni() {
27void CFireOmni::FireStep() {
40 flicker_seed = (int) (60000.0f * (
float) rand() / 2.1474836e9f);
43void CFireOmni::FireCreate() {
44 CTexture *texture = TexManager.GetTexture(
"d01e02", -1);
46 if (texture == NULL) {
50 if (texture->
bpp == 1) {
52 int column = cell % 4;
55 blendTextuer(Vif1Packet, blend.TBP0, blend.TBW, blend.PSM, TexManager.GetTexture(
"d01e03", -1),
CRect_i_(0, 0, 128, 128),
CRect_i_(0, (
int)
flame_phase, 128, 64), TexManager.GetTexture(
"d01e02", -1),
CRect_i_(0, 0, 128, 128),
CRect_i_(column * 64, row * 64, 64, 64));
58 blendTextuer(Vif1Packet, blend.TBP0, blend.TBW, blend.PSM, TexManager.GetTexture(
"d01e03", -1),
CRect_i_(0, 0, 128, 128),
CRect_i_(0, (
int)
flame_phase, 128, 64), TexManager.GetTexture(
"d01e02", -1),
CRect_i_(0, 0, 128, 128),
CRect_i_(0, (
int)
cell_phase * 64, 64, 64));
63 this->
core = core_texture;
64 this->
glow = glow_texture;
68void CFireOmni::DrawFire(
int unused0,
int unused1,
CCamera *camera,
float *colour,
float scale,
int layers,
float camera_offset) {
69 sceVu0FVECTOR camera_direction;
70 sceVu0FVECTOR camera_ref;
72 int near_bottom_right[4];
84 core = TexManager.GetTexture(
"lightling", -1);
88 glow = TexManager.GetTexture(
"blender", -1);
92 camera->
GetPos(camera_direction);
93 camera->
GetRef(camera_ref);
94 sceVu0SubVector(camera_direction, camera_direction, camera_ref);
95 sceVu0Normalize(camera_direction, camera_direction);
96 sceVu0ScaleVector(camera_direction, camera_direction, camera_offset);
97 spRGBA white = {0x80, 0x80, 0x80, 0x80};
100 sceVif1PkCnt(Vif1Packet, 0);
101 sceVif1PkOpenDirectCode(Vif1Packet, 0);
102 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
103 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEX1_1, 0x61);
107 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEST_1, *(u_long *) &test);
109 zbuffer.bits.zmsk = 1;
110 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ZBUF_1, *(u_long *) &zbuffer);
116 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ALPHA_1, *(u_long *) &alpha);
117 sceVif1PkCloseGifTag(Vif1Packet);
118 sceVif1PkCloseDirectCode(Vif1Packet);
121 world[1] =
pos[1] + 4.6f;
125 if (MGRotTransPers3DSprite(top_left, bottom_right, world, 18.0f * scale, 9.0f * scale, 1) == 1) {
126 set3DSpriteFog(Vif1Packet,
core,
CRect_i_(0, 0, 64, 64), top_left, bottom_right, &white);
127 set3DSpriteFog(Vif1Packet,
glow,
CRect_i_(2, 2, 124, 124), top_left, bottom_right, &white);
132 sceVif1PkCnt(Vif1Packet, 0);
133 sceVif1PkOpenDirectCode(Vif1Packet, 0);
134 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
135 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEX1_1, 0x61);
139 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEST_1, *(u_long *) &test);
141 zbuffer.bits.zmsk = 1;
142 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ZBUF_1, *(u_long *) &zbuffer);
148 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ALPHA_1, *(u_long *) &alpha);
149 sceVif1PkCloseGifTag(Vif1Packet);
150 sceVif1PkCloseDirectCode(Vif1Packet);
161 world[1] =
pos[1] + 4.6f;
165 if (MGRotTransPers3DSprite(top_left, bottom_right, world, 45.0f *
flicker_width * scale, 45.0f *
flicker_height * scale / 2.0f, 1) == 1) {
166 top_right[0] = bottom_right[0];
167 top_right[1] = top_left[1];
168 top_right[2] = top_left[2];
169 top_right[3] = top_left[3];
170 bottom_left[0] = top_left[0];
171 bottom_left[1] = bottom_right[1];
172 bottom_left[2] = bottom_right[2];
173 bottom_left[3] = bottom_right[3];
174 world[0] += camera_direction[0];
175 world[1] += camera_direction[1];
176 world[2] += camera_direction[2];
178 if (MGRotTransPers3DSprite(near_top_left, near_bottom_right, world, 45.0f * scale +
flicker_width, (45.0f * scale +
flicker_height) / 2.0f, 0) == 1) {
179 top_right[2] = top_left[2] = bottom_left[2] = bottom_right[2] = near_top_left[2];
182 set3DSpriteFog(Vif1Packet,
core,
CRect_i_(0, 0, 64, 64), top_left, top_right, bottom_left, bottom_right, 0x80);
186 sceVif1PkCnt(Vif1Packet, 0);
187 sceVif1PkOpenDirectCode(Vif1Packet, 0);
188 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
189 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEX1_1, 0x61);
190 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEST_1, *(u_long *) &mgPixelTest);
191 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ZBUF_1, *(u_long *) &mgZBuffer);
192 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_ALPHA_1, *(u_long *) &mgAlpha);
193 sceVif1PkCloseGifTag(Vif1Packet);
194 sceVif1PkCloseDirectCode(Vif1Packet);
198 float phase = this->
raster_phase + ((2.0f * (float) rand()) / 2.1474836e9f);
201 if (!(phase < 8.0f)) {
212 world[1] =
pos[1] + 3.0f;
216 if (MGRotTransPers3DSprite(top_left, bottom_right, world, 15.0f, 16.0f, 0) != 1) {
220 int x = (top_left[0] - 0x6C00) >> 4;
221 int y = (top_left[1] - GS_Y_OFFSET) >> 3;
222 int width = (bottom_right[0] - top_left[0]) >> 4;
223 int height = (bottom_right[1] - top_left[1]) >> 4;
226 if (x + width > 639 && x < 640) {
230 if (x < 0 && x + width > 0) {
241 blendTextuerTest(Vif1Packet, blend.TBP0, blend.TBW, blend.PSM,
CRect_i_(x, y >> 1, width, height), TexManager.GetTexture(
"alpha01", -1),
CRect_i_(0, 0, width, height),
CRect_i_(0, 0, 64, 64), top_left[2] >> 4,
raster_phase);
242 set2DSprite(Vif1Packet, TexManager.GetTexture(
"blender", -1),
CRect_i_(x, y, width, height * 2),
CRect_i_(1, 1, width - 2, height - 2));
void SetTexture(CTexture *core_texture, CTexture *glow_texture)