22726e4d |
1 | /****************************************************************************** |
2 | * Arachnoid Graphics Plugin for Mupen64Plus |
3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
4 | * |
5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
6 | * |
7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version 2 |
10 | * of the License, or (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | *****************************************************************************/ |
21 | |
22 | #ifndef COMBINER_STRUCTS_H_ |
23 | #define COMBINER_STRUCTS_H_ |
24 | |
25 | #include "m64p.h" |
26 | #include "OpenGL.h" |
27 | |
28 | // Internal combiner commands |
29 | #define LOAD 0 |
30 | #define SUB 1 |
31 | #define MUL 2 |
32 | #define ADD 3 |
33 | #define INTERPOLATE 4 |
34 | |
35 | // Internal generalized combiner inputs |
36 | |
37 | #define COMBINED 0 |
38 | #define TEXEL0 1 |
39 | #define TEXEL1 2 |
40 | #define PRIMITIVE 3 |
41 | #define SHADE 4 |
42 | #define ENVIRONMENT 5 |
43 | #define CENTER 6 |
44 | #define SCALE 7 |
45 | #define COMBINED_ALPHA 8 |
46 | #define TEXEL0_ALPHA 9 |
47 | #define TEXEL1_ALPHA 10 |
48 | #define PRIMITIVE_ALPHA 11 |
49 | #define SHADE_ALPHA 12 |
50 | #define ENV_ALPHA 13 |
51 | #define LOD_FRACTION 14 |
52 | #define PRIM_LOD_FRAC 15 |
53 | #define NOISE 16 |
54 | #define K4 17 |
55 | #define K5 18 |
56 | #define ONE 19 |
57 | #define ZERO 20 |
58 | |
59 | //* Combiner data |
60 | //! Defines how mux-values are coded. |
61 | //TODO: check this size against GCC when i'm awake |
62 | struct CombineData |
63 | { |
64 | union |
65 | { |
66 | struct |
67 | { |
68 | // muxs1 |
69 | unsigned aA1 : 3; |
70 | unsigned sbA1 : 3; |
71 | unsigned aRGB1 : 3; |
72 | unsigned aA0 : 3; |
73 | unsigned sbA0 : 3; |
74 | unsigned aRGB0 : 3; |
75 | unsigned mA1 : 3; |
76 | unsigned saA1 : 3; |
77 | unsigned sbRGB1 : 4; |
78 | unsigned sbRGB0 : 4; |
79 | |
80 | // muxs0 |
81 | unsigned mRGB1 : 5; |
82 | unsigned saRGB1 : 4; |
83 | unsigned mA0 : 3; |
84 | unsigned saA0 : 3; |
85 | unsigned mRGB0 : 5; |
86 | unsigned saRGB0 : 4; |
87 | }; |
88 | |
89 | struct |
90 | { |
91 | unsigned int muxs1, muxs0; |
92 | }; |
93 | |
94 | unsigned long long mux; |
95 | }; |
96 | }; |
97 | |
98 | //! Combiner operation |
99 | struct CombinerOp |
100 | { |
101 | int op; |
102 | int param1; |
103 | int param2; |
104 | int param3; |
105 | }; |
106 | |
107 | //! Combiner Stage with combiner operations |
108 | struct CombinerStage |
109 | { |
110 | int numOps; |
111 | CombinerOp op[6]; |
112 | }; |
113 | |
114 | //! Combiner with combiner stages |
115 | struct Combiner |
116 | { |
117 | int numStages; |
118 | CombinerStage stage[2]; |
119 | }; |
120 | |
121 | //! Combiner cycle |
122 | struct CombineCycle |
123 | { |
124 | int loadValue; //!< Load |
125 | int addValue; //!< Addition |
126 | int subValue; //!< Subract |
127 | int multValue; //!< Multiplication |
128 | }; |
129 | |
130 | |
131 | //***************************************************************************** |
132 | //! Texture Environment Combiner Argument |
133 | //! Difines a color source and mathimatical operation to be performed |
134 | //***************************************************************************** |
135 | struct TexEnvCombinerArg |
136 | { |
137 | GLenum source; |
138 | GLenum operand; |
139 | }; |
140 | |
141 | //***************************************************************************** |
142 | //! Texture Environment Combiner Stage |
143 | //***************************************************************************** |
144 | struct TexEnvCombinerStage |
145 | { |
146 | unsigned short constant; |
147 | bool used; |
148 | GLenum combine; |
149 | TexEnvCombinerArg arg0, arg1, arg2; |
150 | unsigned short outputTexture; |
151 | }; |
152 | |
153 | //***************************************************************************** |
154 | //* Texture Environment Combiner |
155 | //! Stores information how graphics API should combine colors and set |
156 | //! Texture environment. |
157 | //***************************************************************************** |
158 | struct TexEnvCombiner |
159 | { |
160 | bool usesT0, usesT1, usesNoise; |
161 | |
162 | GLint mode; |
163 | |
164 | unsigned short usedUnits; |
165 | |
166 | struct |
167 | { |
168 | unsigned short color, secondaryColor, alpha; |
169 | } vertex; |
170 | |
171 | TexEnvCombinerStage color[8]; |
172 | TexEnvCombinerStage alpha[8]; |
173 | }; |
174 | |
175 | #endif |