Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/pc/gfx/gfx_cc.c
7861 views
1
#include "gfx_cc.h"
2
3
void gfx_cc_get_features(uint32_t shader_id, struct CCFeatures *cc_features) {
4
for (int i = 0; i < 4; i++) {
5
cc_features->c[0][i] = (shader_id >> (i * 3)) & 7;
6
cc_features->c[1][i] = (shader_id >> (12 + i * 3)) & 7;
7
}
8
9
cc_features->opt_alpha = (shader_id & SHADER_OPT_ALPHA) != 0;
10
cc_features->opt_fog = (shader_id & SHADER_OPT_FOG) != 0;
11
cc_features->opt_texture_edge = (shader_id & SHADER_OPT_TEXTURE_EDGE) != 0;
12
cc_features->opt_noise = (shader_id & SHADER_OPT_NOISE) != 0;
13
14
cc_features->used_textures[0] = false;
15
cc_features->used_textures[1] = false;
16
cc_features->num_inputs = 0;
17
18
for (int i = 0; i < 2; i++) {
19
for (int j = 0; j < 4; j++) {
20
if (cc_features->c[i][j] >= SHADER_INPUT_1 && cc_features->c[i][j] <= SHADER_INPUT_4) {
21
if (cc_features->c[i][j] > cc_features->num_inputs) {
22
cc_features->num_inputs = cc_features->c[i][j];
23
}
24
}
25
if (cc_features->c[i][j] == SHADER_TEXEL0 || cc_features->c[i][j] == SHADER_TEXEL0A) {
26
cc_features->used_textures[0] = true;
27
}
28
if (cc_features->c[i][j] == SHADER_TEXEL1) {
29
cc_features->used_textures[1] = true;
30
}
31
}
32
}
33
34
cc_features->do_single[0] = cc_features->c[0][2] == 0;
35
cc_features->do_single[1] = cc_features->c[1][2] == 0;
36
cc_features->do_multiply[0] = cc_features->c[0][1] == 0 && cc_features->c[0][3] == 0;
37
cc_features->do_multiply[1] = cc_features->c[1][1] == 0 && cc_features->c[1][3] == 0;
38
cc_features->do_mix[0] = cc_features->c[0][1] == cc_features->c[0][3];
39
cc_features->do_mix[1] = cc_features->c[1][1] == cc_features->c[1][3];
40
cc_features->color_alpha_same = (shader_id & 0xfff) == ((shader_id >> 12) & 0xfff);
41
}
42
43