Debian Codegraph @

src/gui/render_templates_sai.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 static inline int conc2d(GetResult,SBPP)(PTYPE A, PTYPE B, PTYPE C, PTYPE D) {
20 const bool ac = (A==C);
21 const bool bc = (B==C);
22 const int x1 = ac;
23 const int y1 = (bc & !ac);
24 const bool ad = (A==D);
25 const bool bd = (B==D);
26 const int x2 = ad;
27 const int y2 = (bd & !ad);
28 const int x = x1+x2;
29 const int y = y1+y2;
30 static const int rmap[3][3] = {
31 {0, 0, -1},
32 {0, 0, -1},
33 {1, 1, 0}
34 };
35 return rmap[y][x];
36 }
37
38 inline void conc2d(Super2xSaI,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
39 {
40 //--------------------------------------
41 if (C7 == C5 && C4 != C8) {
42 line1[1] = line0[1] = C7;
43 } else if (C4 == C8 && C7 != C5) {
44 line1[1] = line0[1] = C4;
45 } else if (C4 == C8 && C7 == C5) {
46 register int r = 0;
47 r += conc2d(GetResult,SBPP)(C5,C4,C6,D1);
48 r += conc2d(GetResult,SBPP)(C5,C4,C3,C1);
49 r += conc2d(GetResult,SBPP)(C5,C4,D2,D5);
50 r += conc2d(GetResult,SBPP)(C5,C4,C2,D4);
51
52 if (r > 0)
53 line1[1] = line0[1] = C5;
54 else if (r < 0)
55 line1[1] = line0[1] = C4;
56 else {
57 line1[1] = line0[1] = interp_w2(C4,C5,1U,1U);
58 }
59 } else {
60 if (C5 == C8 && C8 == D1 && C7 != D2 && C8 != D0)
61 line1[1] = interp_w2(C8,C7,3U,1U);
62 else if (C4 == C7 && C7 == D2 && D1 != C8 && C7 != D6)
63 line1[1] = interp_w2(C7,C8,3U,1U);
64 else
65 line1[1] = interp_w2(C7,C8,1U,1U);
66
67 if (C5 == C8 && C5 == C1 && C4 != C2 && C5 != C0)
68 line0[1] = interp_w2(C5,C4,3U,1U);
69 else if (C4 == C7 && C4 == C2 && C1 != C5 && C4 != D3)
70 line0[1] = interp_w2(C4,C5,3U,1U);
71 else
72 line0[1] = interp_w2(C4,C5,1U,1U);
73 }
74
75 if (C4 == C8 && C7 != C5 && C3 == C4 && C4 != D2)
76 line1[0] = interp_w2(C7,C4,1U,1U);
77 else if (C4 == C6 && C5 == C4 && C3 != C7 && C4 != D0)
78 line1[0] = interp_w2(C7,C4,1U,1U);
79 else
80 line1[0] = C7;
81
82 if (C7 == C5 && C4 != C8 && C6 == C7 && C7 != C2)
83 line0[0] = interp_w2(C7,C4,1U,1U);
84 else if (C3 == C7 && C8 == C7 && C6 != C4 && C7 != C0)
85 line0[0] = interp_w2(C7,C4,1U,1U);
86 else
87 line0[0] = C4;
88 }
89
90 inline void conc2d(SuperEagle,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
91 {
92 // --------------------------------------
93 if (C4 != C8) {
94 if (C7 == C5) {
95 line0[1] = line1[0] = C7;
96 if ((C6 == C7) || (C5 == C2)) {
97 line0[0] = interp_w2(C7,C4,3U,1U);
98 } else {
99 line0[0] = interp_w2(C4,C5,1U,1U);
100 }
101
102 if ((C5 == D4) || (C7 == D1)) {
103 line1[1] = interp_w2(C7,C8,3U,1U);
104 } else {
105 line1[1] = interp_w2(C7,C8,1U,1U);
106 }
107 } else {
108 line1[1] = interp_w3(C8,C7,C5,6U,1U,1U);
109 line0[0] = interp_w3(C4,C7,C5,6U,1U,1U);
110
111 line1[0] = interp_w3(C7,C4,C8,6U,1U,1U);
112 line0[1] = interp_w3(C5,C4,C8,6U,1U,1U);
113 }
114 } else {
115 if (C7 != C5) {
116 line1[1] = line0[0] = C4;
117
118 if ((C1 == C4) || (C8 == D5)) {
119 line0[1] = interp_w2(C4,C5,3U,1U);
120 } else {
121 line0[1] = interp_w2(C4,C5,1U,1U);
122 }
123
124 if ((C8 == D2) || (C3 == C4)) {
125 line1[0] = interp_w2(C4,C7,3U,1U);
126 } else {
127 line1[0] = interp_w2(C7,C8,1U,1U);
128 }
129 } else {
130 register int r = 0;
131 r += conc2d(GetResult,SBPP)(C5,C4,C6,D1);
132 r += conc2d(GetResult,SBPP)(C5,C4,C3,C1);
133 r += conc2d(GetResult,SBPP)(C5,C4,D2,D5);
134 r += conc2d(GetResult,SBPP)(C5,C4,C2,D4);
135
136 if (r > 0) {
137 line0[1] = line1[0] = C7;
138 line0[0] = line1[1] = interp_w2(C4,C5,1U,1U);
139 } else if (r < 0) {
140 line1[1] = line0[0] = C4;
141 line0[1] = line1[0] = interp_w2(C4,C5,1U,1U);
142 } else {
143 line1[1] = line0[0] = C4;
144 line0[1] = line1[0] = C7;
145 }
146 }
147 }
148 }
149
150 inline void conc2d(_2xSaI,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
151 {
152 if ((C4 == C8) && (C5 != C7)) {
153 if (((C4 == C1) && (C5 == D5)) ||
154 ((C4 == C7) && (C4 == C2) && (C5 != C1) && (C5 == D3))) {
155 line0[1] = C4;
156 } else {
157 line0[1] = interp_w2(C4,C5,1U,1U);
158 }
159
160 if (((C4 == C3) && (C7 == D2)) ||
161 ((C4 == C5) && (C4 == C6) && (C3 != C7) && (C7 == D0))) {
162 line1[0] = C4;
163 } else {
164 line1[0] = interp_w2(C4,C7,1U,1U);
165 }
166 line1[1] = C4;
167 } else if ((C5 == C7) && (C4 != C8)) {
168 if (((C5 == C2) && (C4 == C6)) ||
169 ((C5 == C1) && (C5 == C8) && (C4 != C2) && (C4 == C0))) {
170 line0[1] = C5;
171 } else {
172 line0[1] = interp_w2(C4,C5,1U,1U);
173 }
174
175 if (((C7 == C6) && (C4 == C2)) ||
176 ((C7 == C3) && (C7 == C8) && (C4 != C6) && (C4 == C0))) {
177 line1[0] = C7;
178 } else {
179 line1[0] = interp_w2(C4,C7,1U,1U);
180 }
181 line1[1] = C5;
182 } else if ((C4 == C8) && (C5 == C7)) {
183 if (C4 == C5) {
184 line0[1] = C4;
185 line1[0] = C4;
186 line1[1] = C4;
187 } else {
188 register int r = 0;
189 r += conc2d(GetResult,SBPP)(C4,C5,C3,C1);
190 r -= conc2d(GetResult,SBPP)(C5,C4,D4,C2);
191 r -= conc2d(GetResult,SBPP)(C5,C4,C6,D1);
192 r += conc2d(GetResult,SBPP)(C4,C5,D5,D2);
193
194 if (r > 0)
195 line1[1] = C4;
196 else if (r < 0)
197 line1[1] = C5;
198 else {
199 line1[1] = interp_w4(C4,C5,C7,C8,1U,1U,1U,1U);
200 }
201
202 line1[0] = interp_w2(C4,C7,1U,1U);
203 line0[1] = interp_w2(C4,C5,1U,1U);
204 }
205 } else {
206 line1[1] = interp_w4(C4,C5,C7,C8,1U,1U,1U,1U);
207
208 if ((C4 == C7) && (C4 == C2)
209 && (C5 != C1) && (C5 == D3)) {
210 line0[1] = C4;
211 } else if ((C5 == C1) && (C5 == C8)
212 && (C4 != C2) && (C4 == C0)) {
213 line0[1] = C5;
214 } else {
215 line0[1] = interp_w2(C4,C5,1U,1U);
216 }
217
218 if ((C4 == C5) && (C4 == C6)
219 && (C3 != C7) && (C7 == D0)) {
220 line1[0] = C4;
221 } else if ((C7 == C3) && (C7 == C8)
222 && (C4 != C6) && (C4 == C0)) {
223 line1[0] = C7;
224 } else {
225 line1[0] = interp_w2(C4,C7,1U,1U);
226 }
227 }
228 line0[0] = C4;
229 }