Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
flame.c File Reference

Go to the source code of this file.

Data Structures

struct  FlamePreset
 

Functions

void flame_init (EffectInstance *effect)
 
void flame_update (EffectInstance *effect)
 
void flame_render (EffectInstance *effect)
 
void flame_appendGfx (void *effect)
 
void flame_main (s32 type, f32 arg1, f32 arg2, f32 arg3, f32 arg4, EffectInstance **outEffect)
 

Variables

Gfx D_09000800_3543B0 []
 
Gfx D_090008F8_3544A8 []
 
Gfx D_09000918_3544C8 []
 
Gfx D_090009E0_354590 []
 
FlamePreset FlamePresets []
 
s32 LastFlameRenderFrame = 0
 

Data Structure Documentation

◆ FlamePreset

struct FlamePreset
Data Fields
Color_RGB8 colorScale
s8 keyCenter
Color_RGB8 envColor
s8 primIntensity
u8 sizeScale
Gfx * dlist

Function Documentation

◆ flame_init()

void flame_init ( EffectInstance * effect)

Definition at line 109 of file flame.c.

109 {
110}

Referenced by flame_main().

◆ flame_update()

void flame_update ( EffectInstance * effect)

Definition at line 112 of file flame.c.

112 {
113 FlameFXData* part = effect->data.flame;
114 s32 i;
115
116 for (i = 0; i < effect->numParts; i++, part++) {
117 part->unk_1C += part->unk_20;
118 if (part->unk_1C > 64.0f) {
119 part->unk_1C -= 64.0f;
120 }
121 if (part->unk_1C < 0.0f) {
122 part->unk_1C += 64.0f;
123 }
124
125 part->unk_24 += part->unk_28;
126 if (part->unk_24 > 128.0f) {
127 part->unk_24 -= 128.0f;
128 }
129 if (part->unk_24 < 0.0f) {
130 part->unk_24 += 128.0f;
131 }
132 }
133}
EffectData data
Definition effects.h:2605
struct FlameFXData * flame
Definition effects.h:2496

Referenced by flame_main().

◆ flame_render()

void flame_render ( EffectInstance * effect)

Definition at line 135 of file flame.c.

135 {
136 FlameFXData* data = effect->data.flame;
137 RenderTask renderTask;
138 RenderTask* renderTaskPtr = &renderTask;
139 RenderTask* retTask;
140 s32 outDist;
141 f32 outX;
142 f32 outY;
143 f32 outZ;
144 f32 outW;
145
146 transform_point(gCameras[gCurrentCameraID].mtxPerspective, data->pos.x, data->pos.y, data->pos.z, 1.0f,
147 &outX, &outY, &outZ, &outW);
148
149 outDist = outZ + 5000;
150 if (outDist < 0) {
151 outDist = 0;
152 } else if (outDist > 10000) {
153 outDist = 10000;
154 }
155
156 if (outW < 0.01 && -0.01 < outW) {
157 outDist = 0;
158 }
159
160 renderTaskPtr->appendGfx = flame_appendGfx;
161 renderTaskPtr->dist = -outDist;
162 renderTaskPtr->appendGfxArg = effect;
164
165 queue_render_task(renderTaskPtr);
166}
#define transform_point
#define queue_render_task
Vec3f pos
Definition effects.h:488
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
void flame_appendGfx(void *effect)
Definition flame.c:168
void * appendGfxArg
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by flame_main().

◆ flame_appendGfx()

void flame_appendGfx ( void * effect)

Definition at line 168 of file flame.c.

168 {
169 FlameFXData* data = ((EffectInstance*)effect)->data.flame;
170 Camera* camera = &gCameras[gCurrentCameraID];
171 s32 type = data->type;
172 s32 uls = data->unk_1C * 4.0f;
173 s32 ult = data->unk_24 * 4.0f;
174 FlamePreset* preset;
175 Matrix4f sp18;
176 Matrix4f sp58;
177 Matrix4f sp98;
178
179 gDPPipeSync(gMainGfxPos++);
180 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
181
184 gSPDisplayList(gMainGfxPos++, D_09000918_3544C8);
185 gDPSetTileSize(gMainGfxPos++, 1, uls, ult, uls + 128, ult + 256);
186 gSPDisplayList(gMainGfxPos++, D_090009E0_354590);
187 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr));
188 gDPSetScissorFrac(gMainGfxPos++, G_SC_NON_INTERLACE,
189 camera->viewportStartX * 4.0f,
190 camera->viewportStartY * 4.0f,
191 (camera->viewportStartX + camera->viewportW) * 4.0f,
192 (camera->viewportStartY + camera->viewportH) * 4.0f);
193 }
194
195 preset = &FlamePresets[type];
196
197 gSPDisplayList(gMainGfxPos++, preset->dlist);
198 gDPSetKeyR(gMainGfxPos++, preset->keyCenter, preset->colorScale.r, 0);
199 gDPSetKeyGB(gMainGfxPos++, preset->keyCenter, preset->colorScale.g, 0, preset->keyCenter, preset->colorScale.b, 0);
200 gDPSetPrimColor(gMainGfxPos++, 0, 0, preset->primIntensity, preset->primIntensity, preset->primIntensity, 0);
201 gDPSetEnvColor(gMainGfxPos++, preset->envColor.r, preset->envColor.g, preset->envColor.b, 0);
202
203 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
204 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
205 guMtxCatF(sp58, sp18, sp98);
206 guScaleF(sp58, data->baseScale * data->scaleW, data->baseScale * data->scaleH, data->baseScale);
207 guMtxCatF(sp58, sp98, sp98);
209
211 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
212 gSPDisplayList(gMainGfxPos++, D_090008F8_3544A8);
213 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
214 gDPPipeSync(gMainGfxPos++);
215}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
f32 baseScale
Definition effects.h:489
Gfx D_09000918_3544C8[]
s32 LastFlameRenderFrame
Definition flame.c:54
Gfx * dlist
Definition flame.c:11
Color_RGB8 colorScale
Definition flame.c:6
Gfx D_090008F8_3544A8[]
FlamePreset FlamePresets[]
Definition flame.c:19
Color_RGB8 envColor
Definition flame.c:8
s8 primIntensity
Definition flame.c:9
Gfx D_090009E0_354590[]
Definition flame.c:37
s8 keyCenter
Definition flame.c:7
#define SCREEN_WIDTH
Definition macros.h:105
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
s16 viewportStartX
s16 viewportStartY
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by flame_render().

◆ flame_main()

void flame_main ( s32 type,
f32 arg1,
f32 arg2,
f32 arg3,
f32 arg4,
EffectInstance ** outEffect )

Definition at line 61 of file flame.c.

68 {
70 EffectBlueprint* bpPtr = &bp;
71 EffectInstance* effect;
72 FlameFXData* data;
73 s32 numParts = 1;
74
75 if (type > FX_FLAME_PINK) {
76 type = FX_FLAME_PINK;
77 }
78
79 bpPtr->init = flame_init;
80 bpPtr->update = flame_update;
82 bpPtr->unk_00 = 0;
83 bpPtr->renderUI = NULL;
84 bpPtr->effectID = EFFECT_FLAME;
85
86 effect = create_effect_instance(bpPtr);
87 effect->numParts = numParts;
88 data = effect->data.flame = general_heap_malloc(numParts * sizeof(*data));
89 ASSERT(effect->data.flame != NULL);
90
91 data->type = type;
92 data->unk_18 = 0;
93 data->pos.x = arg1;
94 data->pos.y = arg2;
95 data->pos.z = arg3;
96 data->baseScale = arg4 * FlamePresets[type].sizeScale * 0.01;
97 data->unk_1C = 0;
98 data->unk_24 = 0;
99 data->unk_20 = 0;
100 data->scaleW = 1.0f;
101 data->scaleH = 1.0f;
102 data->unk_28 = 1.0f;
103
104 if (outEffect != NULL) {
105 *outEffect = effect;
106 }
107}
#define general_heap_malloc
#define create_effect_instance
@ FX_FLAME_PINK
Definition effects.h:483
#define ASSERT(condition)
void flame_render(EffectInstance *effect)
Definition flame.c:135
void flame_update(EffectInstance *effect)
Definition flame.c:112
u8 sizeScale
Definition flame.c:10
void flame_init(EffectInstance *effect)
Definition flame.c:109
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2655
void(* init)(EffectInstance *effectInst)
Definition effects.h:2652
void(* update)(EffectInstance *effectInst)
Definition effects.h:2653
void(* renderWorld)(EffectInstance *effectInst)
Definition effects.h:2654

Variable Documentation

◆ D_09000800_3543B0

Gfx D_09000800_3543B0[]
extern

Definition at line 13 of file flame.c.

13 {
14 gsDPPipeSync(),
15 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
16 gsDPSetCycleType(G_CYC_2CYCLE),
17 gsDPSetTexturePersp(G_TP_PERSP),
18 gsDPSetTextureDetail(G_TD_CLAMP),
19 gsDPSetTextureLOD(G_TL_TILE),
20 gsDPSetTextureFilter(G_TF_BILERP),
21 gsDPSetTextureConvert(G_TC_FILT),
22 gsDPSetColorDither(G_CD_MAGICSQ),
23 gsDPSetAlphaDither(G_AD_PATTERN),
24 gsDPSetTextureLUT(G_TT_NONE),
25 gsDPSetRenderMode(G_RM_PASS, G_RM_ZB_CLD_SURF2),
26 gsDPLoadTextureTile(OS_K0_TO_PHYSICAL(&D_800B32E0), G_IM_FMT_I, G_IM_SIZ_8b, 32, 0, 0, 0, 31, 63, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
27 gsDPSetCombineMode(PM_CC_34, PM_CC_35),
28 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
29 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
30 gsSPEndDisplayList(),
31};
unsigned char D_800B32E0[]
#define PM_CC_34
Definition macros.h:389
#define PM_CC_35
Definition macros.h:390

◆ D_090008F8_3544A8

Gfx D_090008F8_3544A8[]
extern

Referenced by flame_appendGfx().

◆ D_09000918_3544C8

Gfx D_09000918_3544C8[]
extern

Referenced by flame_appendGfx().

◆ D_090009E0_354590

Gfx D_090009E0_354590[]
extern

Definition at line 37 of file flame.c.

37 {
38 gsDPSetColorImage(G_IM_FMT_I, G_IM_SIZ_8b, 32, OS_K0_TO_PHYSICAL(&D_800B3AE0)),
39 gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, 32, 64),
40 gsDPSetTexturePersp(G_TP_NONE),
41 gsDPSetTextureFilter(G_TF_BILERP),
42 gsDPSetRenderMode(G_RM_PASS, G_RM_CLD_SURF2),
43 gsDPSetCombineMode(PM_CC_CONST_ALPHA_1, PM_CC_CONST_ALPHA_1),
44 gsSPTextureRectangle(0, 0, 0x0080, 0x0100, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400),
45 gsDPPipeSync(),
46 gsDPSetCombineMode(PM_CC_36, PM_CC_37),
47 gsSPTextureRectangle(0, 0, 0x0080, 0x0100, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400),
48 gsDPPipeSync(),
49 gsDPLoadTextureTile(OS_K0_TO_PHYSICAL(&D_800B3AE0), G_IM_FMT_I, G_IM_SIZ_8b, 32, 0, 0, 0, 31, 63, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
50 gsDPSetColorImage(G_IM_FMT_I, G_IM_SIZ_8b, 32, OS_K0_TO_PHYSICAL(&D_800B32E0)),
51 gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
52 gsDPSetTextureFilter(G_TF_POINT),
53 gsDPSetCombineMode(PM_CC_38, PM_CC_39),
54 gsDPSetConvert(0, 0, 0, 0, 92, 0),
55 gsDPSetPrimColor(0, 0, 0x00, 0x00, 0x00, 0x78),
56 gsDPSetEnvColor(0x00, 0x00, 0x00, 0xA4),
57 gsDPLoadMultiTile(OS_K0_TO_PHYSICAL(&D_800B32E0), 0x0100, 1, G_IM_FMT_I, G_IM_SIZ_8b, 32, 0, 0, 0, 31, 63, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
58 gsDPSetTileSize(1, 0x0004, 0, 0x007C, 0x00FC),
59 gsSPTextureRectangle(0, 0, 0x0080, 0x0100, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400),
60 gsDPPipeSync(),
61 gsDPLoadMultiTile(OS_K0_TO_PHYSICAL(&D_800B32E0), 0x0100, 1, G_IM_FMT_I, G_IM_SIZ_8b, 32, 0, 0, 0, 31, 63, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
62 gsDPSetTileSize(1, 0x007C, 0, 0x007C, 0x00FC),
63 gsSPTextureRectangle(0, 0, 0x0080, 0x0100, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400),
64 gsDPPipeSync(),
65 gsDPLoadMultiTile(OS_K0_TO_PHYSICAL(&D_800B32E0), 0x0100, 1, G_IM_FMT_I, G_IM_SIZ_8b, 32, 0, 0, 0, 31, 63, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD),
66 gsDPSetTileSize(1, 0, 0x0004, 0x007C, 0x00FC),
67 gsSPTextureRectangle(0, 0, 0x0080, 0x0100, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400),
68 gsDPPipeSync(),
69 gsSPEndDisplayList(),
70};
unsigned char D_800B3AE0[]
#define PM_CC_37
Definition macros.h:393
#define PM_CC_CONST_ALPHA_1
Definition macros.h:509
#define PM_CC_39
Definition macros.h:396
#define PM_CC_38
Definition macros.h:395
#define PM_CC_36
Definition macros.h:392

Referenced by flame_appendGfx().

◆ FlamePresets

FlamePreset FlamePresets[]

Definition at line 19 of file flame.c.

19 {
21 .colorScale = { 255, 109, 255 },
22 .keyCenter = 92,
23 .envColor = { 102, 191, 255 },
24 .primIntensity = 75,
25 .sizeScale = 50,
26 .dlist = D_09000800_3543B0,
27 },
28 [FX_FLAME_RED] {
29 .colorScale = { 255, 255, 255 },
30 .keyCenter = 0,
31 .envColor = { 255, 32, 0 },
32 .primIntensity = 75,
33 .sizeScale = 100,
34 .dlist = D_09000800_3543B0,
35 },
37 .colorScale = { 255, 0, 255 },
38 .keyCenter = 92,
39 .envColor = { 107, 168, 255 },
40 .primIntensity = 75,
41 .sizeScale = 10,
42 .dlist = D_09000800_3543B0,
43 },
45 .colorScale = { 255, 255, 255 },
46 .keyCenter = 244,
47 .envColor = { 247, 175, 175 },
48 .primIntensity = 22,
49 .sizeScale = 30,
50 .dlist = D_09000800_3543B0,
51 },
52};
@ FX_FLAME_RED
Definition effects.h:481
@ FX_FLAME_SMALL_BLUE
Definition effects.h:482
@ FX_FLAME_BLUE
Definition effects.h:480
Gfx D_09000800_3543B0[]
Definition flame.c:13

Referenced by flame_appendGfx(), and flame_main().

◆ LastFlameRenderFrame

s32 LastFlameRenderFrame = 0

Definition at line 54 of file flame.c.

Referenced by flame_appendGfx().