-
Notifications
You must be signed in to change notification settings - Fork 3
/
silhouette.patch
268 lines (259 loc) · 11.4 KB
/
silhouette.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
diff --git a/actors/mario/geo.inc.c b/actors/mario/geo.inc.c
index 736d31f..66442ea 100644
--- a/actors/mario/geo.inc.c
+++ b/actors/mario/geo.inc.c
@@ -1,5 +1,7 @@
// Normal Mario Geo
+#define LAYER_OPAQUE LAYER_SILHOUETTE // Temporarily set the opaque layer to 8, for the silhouette
+
// 0x170002E0
const GeoLayout mario_geo_face_and_wings[] = {
GEO_ASM(0, geo_mario_head_rotation),
diff --git a/include/sm64.h b/include/sm64.h
index 75de983..aafa6c9 100644
--- a/include/sm64.h
+++ b/include/sm64.h
@@ -55,6 +55,7 @@ int strcmp(char *s, char *t);
#define LAYER_TRANSPARENT 5
#define LAYER_TRANSPARENT_DECAL 6
#define LAYER_TRANSPARENT_INTER 7
+#define LAYER_SILHOUETTE 8
#define INPUT_NONZERO_ANALOG 0x0001
#define INPUT_A_PRESSED 0x0002
diff --git a/silhouette.patch b/silhouette.patch
new file mode 100644
index 0000000..43c39c6
--- /dev/null
+++ b/silhouette.patch
@@ -0,0 +1,120 @@
+diff --git a/actors/mario/geo.inc.c b/actors/mario/geo.inc.c
+index 736d31f..66442ea 100644
+--- a/actors/mario/geo.inc.c
++++ b/actors/mario/geo.inc.c
+@@ -1,5 +1,7 @@
+ // Normal Mario Geo
+
++#define LAYER_OPAQUE LAYER_SILHOUETTE // Temporarily set the opaque layer to 8, for the silhouette
++
+ // 0x170002E0
+ const GeoLayout mario_geo_face_and_wings[] = {
+ GEO_ASM(0, geo_mario_head_rotation),
+diff --git a/include/sm64.h b/include/sm64.h
+index f846c01..936285e 100644
+--- a/include/sm64.h
++++ b/include/sm64.h
+@@ -54,6 +54,7 @@ void *memmove(void *str1, const void *str2, size_t n);
+ #define LAYER_TRANSPARENT 5
+ #define LAYER_TRANSPARENT_DECAL 6
+ #define LAYER_TRANSPARENT_INTER 7
++#define LAYER_SILHOUETTE 8
+
+ #define INPUT_NONZERO_ANALOG 0x0001
+ #define INPUT_A_PRESSED 0x0002
+diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h
+index 3d630d1..dcd36fb 100644
+--- a/src/engine/graph_node.h
++++ b/src/engine/graph_node.h
+@@ -47,7 +47,7 @@
+
+ // The number of master lists. A master list determines the order and render
+ // mode with which display lists are drawn.
+-#define GFX_NUM_MASTER_LISTS 8
++#define GFX_NUM_MASTER_LISTS 9
+
+ // Passed as first argument to a GraphNodeFunc to give information about in
+ // which context it was called and what it is expected to do.
+diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c
+index 63866d6..d959ba2 100644
+--- a/src/game/rendering_graph_node.c
++++ b/src/game/rendering_graph_node.c
+@@ -68,7 +68,7 @@ s16 *gCurAnimData;
+ struct AllocOnlyPool *gDisplayListHeap;
+
+ struct RenderModeContainer {
+- u32 modes[8];
++ u32 modes[GFX_NUM_MASTER_LISTS];
+ };
+
+ /* Rendermode settings for cycle 1 for all 8 layers. */
+@@ -81,6 +81,7 @@ struct RenderModeContainer renderModeTable_1Cycle[2] = { { {
+ G_RM_AA_XLU_SURF,
+ G_RM_AA_XLU_SURF,
+ G_RM_AA_XLU_SURF,
++ G_RM_FOG_SHADE_A,
+ } },
+ { {
+ /* z-buffered */
+@@ -92,6 +93,7 @@ struct RenderModeContainer renderModeTable_1Cycle[2] = { { {
+ G_RM_AA_ZB_XLU_SURF,
+ G_RM_AA_ZB_XLU_DECAL,
+ G_RM_AA_ZB_XLU_INTER,
++ G_RM_FOG_SHADE_A,
+ } } };
+
+ /* Rendermode settings for cycle 2 for all 8 layers. */
+@@ -104,6 +106,7 @@ struct RenderModeContainer renderModeTable_2Cycle[2] = { { {
+ G_RM_AA_XLU_SURF2,
+ G_RM_AA_XLU_SURF2,
+ G_RM_AA_XLU_SURF2,
++ G_RM_NOOP2,
+ } },
+ { {
+ /* z-buffered */
+@@ -115,6 +118,7 @@ struct RenderModeContainer renderModeTable_2Cycle[2] = { { {
+ G_RM_AA_ZB_XLU_SURF2,
+ G_RM_AA_ZB_XLU_DECAL2,
+ G_RM_AA_ZB_XLU_INTER2,
++ G_RM_NOOP2
+ } } };
+
+ struct GraphNodeRoot *gCurGraphNodeRoot = NULL;
+@@ -153,9 +157,35 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
+ }
+
+ for (i = 0; i < GFX_NUM_MASTER_LISTS; i++) {
+- if ((currList = node->listHeads[i]) != NULL) {
+- gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
++ if (i == LAYER_TRANSPARENT) { // If model isn't visible, render silhouette
++ if ((currList = node->listHeads[LAYER_SILHOUETTE]) != NULL) {
++ while (currList != NULL) {
++ gDPSetRenderMode(gDisplayListHead++, modeList->modes[LAYER_SILHOUETTE], mode2List->modes[LAYER_SILHOUETTE]);
++ gDPSetFogColor(gDisplayListHead++, 0, 0, 0, 160);
++ gSPFogPosition(gDisplayListHead++, 1, 2);
++ gSPSetGeometryMode(gDisplayListHead++, G_FOG);
++ gDPSetEnvColor(gDisplayListHead++, 127, 127, 127, 160);
++ gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER);
++ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
++ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
++ gSPDisplayList(gDisplayListHead++, currList->displayList);
++ currList = currList->next;
++ }
++ gSPClearGeometryMode(gDisplayListHead++, G_FOG);
++ gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
++ currList = node->listHeads[LAYER_SILHOUETTE];
++ while (currList != NULL) {
++ gDPSetRenderMode(gDisplayListHead++, modeList->modes[LAYER_OPAQUE], mode2List->modes[LAYER_OPAQUE]);
++ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
++ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
++ gSPDisplayList(gDisplayListHead++, currList->displayList);
++ currList = currList->next;
++ }
++ }
++ }
++ if (i < LAYER_SILHOUETTE && (currList = node->listHeads[i]) != NULL) {
+ while (currList != NULL) {
++ gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
+ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPDisplayList(gDisplayListHead++, currList->displayList);
diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h
index 29f7904..9dc6faf 100644
--- a/src/engine/graph_node.h
+++ b/src/engine/graph_node.h
@@ -47,7 +47,7 @@
// The number of master lists. A master list determines the order and render
// mode with which display lists are drawn.
-#define GFX_NUM_MASTER_LISTS 8
+#define GFX_NUM_MASTER_LISTS 9
// Passed as first argument to a GraphNodeFunc to give information about in
// which context it was called and what it is expected to do.
diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c
index 20d05ae..c41410a 100644
--- a/src/game/rendering_graph_node.c
+++ b/src/game/rendering_graph_node.c
@@ -78,7 +78,7 @@ s16 *gCurrAnimData;
struct AllocOnlyPool *gDisplayListHeap;
struct RenderModeContainer {
- u32 modes[8];
+ u32 modes[GFX_NUM_MASTER_LISTS];
};
/* Rendermode settings for cycle 1 for all 8 layers. */
@@ -91,6 +91,7 @@ struct RenderModeContainer renderModeTable_1Cycle[2] = { { {
G_RM_AA_XLU_SURF,
G_RM_AA_XLU_SURF,
G_RM_AA_XLU_SURF,
+ G_RM_FOG_SHADE_A,
} },
{ {
/* z-buffered */
@@ -102,6 +103,7 @@ struct RenderModeContainer renderModeTable_1Cycle[2] = { { {
G_RM_AA_ZB_XLU_SURF,
G_RM_AA_ZB_XLU_DECAL,
G_RM_AA_ZB_XLU_INTER,
+ G_RM_FOG_SHADE_A,
} } };
/* Rendermode settings for cycle 2 for all 8 layers. */
@@ -114,6 +116,7 @@ struct RenderModeContainer renderModeTable_2Cycle[2] = { { {
G_RM_AA_XLU_SURF2,
G_RM_AA_XLU_SURF2,
G_RM_AA_XLU_SURF2,
+ G_RM_NOOP2,
} },
{ {
/* z-buffered */
@@ -125,6 +128,7 @@ struct RenderModeContainer renderModeTable_2Cycle[2] = { { {
G_RM_AA_ZB_XLU_SURF2,
G_RM_AA_ZB_XLU_DECAL2,
G_RM_AA_ZB_XLU_INTER2,
+ G_RM_NOOP2
} } };
struct GraphNodeRoot *gCurGraphNodeRoot = NULL;
@@ -205,9 +209,57 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
}
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++) {
- if ((currList = node->listHeads[i]) != NULL) {
- gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
+ if (i == LAYER_TRANSPARENT) { // If model isn't visible, render silhouette
+ if ((currList = node->listHeads[LAYER_SILHOUETTE]) != NULL) {
+ while (currList != NULL) {
+ gDPSetRenderMode(gDisplayListHead++, modeList->modes[LAYER_SILHOUETTE], mode2List->modes[LAYER_SILHOUETTE]);
+ gDPSetFogColor(gDisplayListHead++, 0, 0, 0, 160);
+ gSPFogPosition(gDisplayListHead++, 1, 2);
+ gSPSetGeometryMode(gDisplayListHead++, G_FOG);
+ gDPSetEnvColor(gDisplayListHead++, 127, 127, 127, 160);
+ gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER);
+#ifdef HIGH_FPS_PC
+ if ((u32) gMtxTblSize < sizeof(gMtxTbl) / sizeof(gMtxTbl[0])) {
+ gMtxTbl[gMtxTblSize].pos = gDisplayListHead;
+ gMtxTbl[gMtxTblSize].mtx = currList->transform;
+ gMtxTbl[gMtxTblSize++].displayList = currList->displayList;
+ }
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transformInterpolated),
+ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPDisplayList(gDisplayListHead++, currList->displayListInterpolated);
+#else
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
+ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPDisplayList(gDisplayListHead++, currList->displayList);
+#endif
+ currList = currList->next;
+ }
+ gSPClearGeometryMode(gDisplayListHead++, G_FOG);
+ gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
+ currList = node->listHeads[LAYER_SILHOUETTE];
+ while (currList != NULL) {
+ gDPSetRenderMode(gDisplayListHead++, modeList->modes[LAYER_OPAQUE], mode2List->modes[LAYER_OPAQUE]);
+#ifdef HIGH_FPS_PC
+ if ((u32) gMtxTblSize < sizeof(gMtxTbl) / sizeof(gMtxTbl[0])) {
+ gMtxTbl[gMtxTblSize].pos = gDisplayListHead;
+ gMtxTbl[gMtxTblSize].mtx = currList->transform;
+ gMtxTbl[gMtxTblSize++].displayList = currList->displayList;
+ }
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transformInterpolated),
+ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPDisplayList(gDisplayListHead++, currList->displayListInterpolated);
+#else
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
+ G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPDisplayList(gDisplayListHead++, currList->displayList);
+#endif
+ currList = currList->next;
+ }
+ }
+ }
+ if (i < LAYER_SILHOUETTE && (currList = node->listHeads[i]) != NULL) {
while (currList != NULL) {
+ gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
#ifdef HIGH_FPS_PC
if ((u32) gMtxTblSize < sizeof(gMtxTbl) / sizeof(gMtxTbl[0])) {
gMtxTbl[gMtxTblSize].pos = gDisplayListHead;