SpaghettiKart
Loading...
Searching...
No Matches
render.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <main.h>
3#include <macros.h>
5
12void render_actor_item_box(Camera* camera, struct ItemBox* item_box) {
13 UNUSED s32 pad[2];
14 Vec3f someVec1;
15 Vec3f someVec2;
16 Vec3s someRot;
17 f32 thing;
18 UNUSED s32 pad2;
19 Mat4 someMatrix1;
20 Mat4 someMatrix2;
21 UNUSED s32 pad3[4];
22 f32 temp_f0;
23 f32 temp_f0_2;
24 f32 temp_f0_3;
25 f32 temp_f12;
26 f32 temp_f2;
27 f32 temp_f2_2;
28 f32 someMultiplier;
29
30 temp_f0 = is_within_render_distance(camera->pos, item_box->pos, camera->rot[1], 0.0f, camera->fieldOfView,
31 4000000.0f);
32 if (CVarGetInteger("gNoCulling", 0) == 1) {
33 temp_f0 = CLAMP(temp_f0, 0.0f, 600000.0f);
34 }
35 if (!(temp_f0 < 0.0f) && !(600000.0f < temp_f0)) {
36 if ((item_box->state == 2) && (temp_f0 < 100000.0f)) {
37 someRot[0] = 0;
38 someRot[1] = item_box->rot[1];
39 someRot[2] = 0;
40 someVec2[0] = item_box->pos[0];
41 someVec2[1] = item_box->resetDistance + 2.0f;
42 someVec2[2] = item_box->pos[2];
43
44 FrameInterpolation_RecordOpenChild("itembox", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
45 mtxf_pos_rotation_xyz(someMatrix1, someVec2, someRot);
46
47 if (!render_set_position(someMatrix1, 0)) {
49 return;
50 }
51
52 gSPDisplayList(gDisplayListHead++, D_0D002EE8);
54 FrameInterpolation_RecordOpenChild("itembox2", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
55
56
57 someRot[1] = item_box->rot[1] * 2;
58 someVec2[1] = item_box->pos[1];
59
60 mtxf_pos_rotation_xyz(someMatrix1, someVec2, someRot);
61
62 if (!render_set_position(someMatrix1, 0)) {
64 return;
65 }
66
67 gSPDisplayList(gDisplayListHead++, itemBoxQuestionMarkModel);
69 }
70 if (item_box->state == 5) {
71 FrameInterpolation_RecordOpenChild("itembox3", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
72 mtxf_pos_rotation_xyz(someMatrix1, item_box->pos, item_box->rot);
73
74 if (!render_set_position(someMatrix1, 0)) {
76 return;
77 }
78
79 gSPDisplayList(gDisplayListHead++, itemBoxQuestionMarkModel);
81 }
82 if (item_box->state != 3) {
83 FrameInterpolation_RecordOpenChild("itembox4", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
84 mtxf_pos_rotation_xyz(someMatrix1, item_box->pos, item_box->rot);
85
86 if (!render_set_position(someMatrix1, 0)) {
88 return;
89 }
90
91 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
92 gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA);
93
94 /*
95 * In the original game, the question mark texture would become corrupted. Thus, this code
96 * makes it disappear to hide the issue. Since the texture no longer becomes corrupted, this
97 * fix can be removed.
98 */
99#ifdef TARGET_N64
100 if ((item_box->rot[1] < 0xAA1) && (item_box->rot[1] > 0)) {
101 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
102 } else if ((item_box->rot[1] >= 0x6AA5) && (item_box->rot[1] < 0x754E)) {
103 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
104 } else if ((item_box->rot[1] >= 0x38E1) && (item_box->rot[1] < 0x438A)) {
105 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
106 } else if ((item_box->rot[1] >= 0xC711) && (item_box->rot[1] < 0xD1BA)) {
107 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
108 } else {
109#endif
110 gDPSetBlendMask(gDisplayListHead++, 0xFF);
111 gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
112#ifdef TARGET_N64
113 }
114#endif
115 gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
116 gSPDisplayList(gDisplayListHead++, D_0D003090);
118 } else {
119 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
120 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
121 gDPSetBlendMask(gDisplayListHead++, 0xFF);
122 thing = item_box->someTimer;
123
124 FrameInterpolation_RecordOpenChild("itembox5", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
125 mtxf_pos_rotation_xyz(someMatrix1, item_box->pos, item_box->rot);
126 if (thing < 10.0f) {
127 someMultiplier = 1.0f;
128 } else {
129 someMultiplier = 1.0f - ((thing - 10.0f) * 0.1f);
130 }
131 mtxf_scale(someMatrix1, someMultiplier);
132 if (item_box->someTimer & 1) {
133 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
134 } else {
135 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_INTER, G_RM_NOOP2);
136 }
137 temp_f2 = 2.0f * thing;
138 someVec1[0] = 0.0f;
139 someVec1[1] = temp_f2;
140 someVec1[2] = thing;
141 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
142
143 if (!render_set_position(someMatrix2, 0)) {
145 return;
146 }
147
148 gSPDisplayList(gDisplayListHead++, D_0D003158);
150 FrameInterpolation_RecordOpenChild("itembox6", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
151
152 temp_f2_2 = 0.8f * thing;
153 temp_f12 = 0.5f * thing;
154 someVec1[0] = temp_f2_2;
155 someVec1[1] = 2.3f * thing;
156 someVec1[2] = temp_f12;
157 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
158
159 if (!render_set_position(someMatrix2, 0)) {
161 return;
162 }
163
164 gSPDisplayList(gDisplayListHead++, D_0D0031B8);
166 FrameInterpolation_RecordOpenChild("itembox7", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
167
168 temp_f0_2 = -0.5f * thing;
169 someVec1[0] = temp_f2_2;
170 someVec1[1] = 1.2f * thing;
171 someVec1[2] = temp_f0_2;
172
173 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
174
175 if (!render_set_position(someMatrix2, 0)) {
177 return;
178 }
179
180 gSPDisplayList(gDisplayListHead++, D_0D003128);
182 FrameInterpolation_RecordOpenChild("itembox8", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
183
184
185 if (!(item_box->someTimer & 1)) {
186 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
187 } else {
188 gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_INTER, G_RM_NOOP2);
189 }
190 someVec1[0] = 0.0f;
191 someVec1[1] = 1.8f * thing;
192 someVec1[2] = -1.0f * thing;
193
194 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
195
196 if (!render_set_position(someMatrix2, 0)) {
198 return;
199 }
200
201 gSPDisplayList(gDisplayListHead++, D_0D0031E8);
203 FrameInterpolation_RecordOpenChild("itembox9", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
204
205 temp_f0_3 = -0.8f * thing;
206 someVec1[0] = temp_f0_3;
207 someVec1[1] = 0.6f * thing;
208 someVec1[2] = temp_f0_2;
209
210 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
211
212 if (!render_set_position(someMatrix2, 0)) {
214 return;
215 }
216
217 gSPDisplayList(gDisplayListHead++, D_0D003188);
219 FrameInterpolation_RecordOpenChild("itembox10", TAG_ITEM_ADDR((((struct Actor*)item_box) - gActorList) << 5) | (camera - cameras));
220
221 someVec1[0] = temp_f0_3;
222 someVec1[1] = temp_f2;
223 someVec1[2] = temp_f12;
224
225 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
226
227 if (!render_set_position(someMatrix2, 0)) {
229 return;
230 }
231
232 gSPDisplayList(gDisplayListHead++, D_0D0030F8);
234
235 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
236 }
237 gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
238 }
239}
void FrameInterpolation_RecordOpenChild(const void *a, uintptr_t b)
Definition FrameInterpolation.cpp:640
void FrameInterpolation_RecordCloseChild(void)
Definition FrameInterpolation.cpp:650
#define TAG_ITEM_ADDR(x)
Definition FrameInterpolation.h:21
void gSPDisplayList(Gfx *pkt, Gfx *dl)
Definition GBIMiddleware.cpp:12
Camera cameras[NUM_CAMERAS]
Definition camera.c:29
struct Actor gActorList[100]
Definition code_800029B0.c:158
f32 Vec3f[3]
Definition common_structs.h:10
s16 Vec3s[3]
Definition common_structs.h:15
f32 Mat4[4][4]
Definition common_structs.h:20
void render_actor_item_box(Camera *camera, struct ItemBox *item_box)
Renders the item box actor.
Definition render.inc.c:12
#define CLAMP(var, min, max)
Definition macros.h:152
#define UNUSED
Definition macros.h:40
Gfx * gDisplayListHead
Definition main.c:129
s32 render_set_position(Mat4 mtx, s32 arg1)
Definition math_util.c:53
f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 minDistance, f32 fov, f32 maxDistance)
Definition math_util.c:1099
void mtxf_pos_rotation_xyz(Mat4 out, Vec3f pos, Vec3s orientation)
Definition math_util.c:449
void add_translate_mat4_vec3f(Mat4 mat, Mat4 dest, Vec3f pos)
Definition math_util.c:191
void mtxf_scale(Mat4 mat, f32 coef)
Definition math_util.c:435
Definition actor_types.h:124
Vec3s rot
Definition actor_types.h:131
Vec3f pos
Definition actor_types.h:133
Definition camera.h:35
Vec3s rot
Definition camera.h:42
f32 fieldOfView
Definition camera.h:43
Vec3f pos
Definition camera.h:36
Definition actor_types.h:348
s16 someTimer
Definition actor_types.h:351
Vec3f pos
Definition actor_types.h:359
s16 state
Definition actor_types.h:352
f32 resetDistance
Definition actor_types.h:353
Vec3s rot
Definition actor_types.h:357