DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
src/gui/render_templates_sai.h
00001 /*
00002  *  Copyright (C) 2002-2013  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 static inline int conc2d(GetResult,SBPP)(PTYPE A, PTYPE B, PTYPE C, PTYPE D) {
00020         const bool ac = (A==C);
00021         const bool bc = (B==C);
00022         const int x1 = ac;
00023         const int y1 = (bc & !ac);
00024         const bool ad = (A==D);
00025         const bool bd = (B==D);
00026         const int x2 = ad;
00027         const int y2 = (bd & !ad);
00028         const int x = x1+x2;
00029         const int y = y1+y2;
00030         static const int rmap[3][3] = {
00031                 {0, 0, -1},
00032                 {0, 0, -1},
00033                 {1, 1,  0}
00034         };
00035         return rmap[y][x];
00036 }
00037 
00038 inline void conc2d(Super2xSaI,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
00039 {
00040 # if !defined(_MSC_VER) /* Microsoft C++ thinks this is a failed attempt at a function call---it's not */
00041         (void)conc2d(Super2xSaI,SBPP);
00042 # endif
00043 
00044         //--------------------------------------
00045         if (C7 == C5 && C4 != C8) {
00046                 line1[1] = line0[1] = C7;
00047         } else if (C4 == C8 && C7 != C5) {
00048                 line1[1] = line0[1] = C4;
00049         } else if (C4 == C8 && C7 == C5) {
00050                 int r = 0;
00051                 r += conc2d(GetResult,SBPP)(C5,C4,C6,D1);
00052                 r += conc2d(GetResult,SBPP)(C5,C4,C3,C1);
00053                 r += conc2d(GetResult,SBPP)(C5,C4,D2,D5);
00054                 r += conc2d(GetResult,SBPP)(C5,C4,C2,D4);
00055 
00056                 if (r > 0)
00057                         line1[1] = line0[1] = C5;
00058                 else if (r < 0)
00059                         line1[1] = line0[1] = C4;
00060                 else {
00061                         line1[1] = line0[1] = interp_w2(C4,C5,1U,1U);
00062                 }
00063         } else {
00064                 if (C5 == C8 && C8 == D1 && C7 != D2 && C8 != D0)
00065                         line1[1] = interp_w2(C8,C7,3U,1U);
00066                 else if (C4 == C7 && C7 == D2 && D1 != C8 && C7 != D6)
00067                         line1[1] = interp_w2(C7,C8,3U,1U);
00068                 else
00069                         line1[1] = interp_w2(C7,C8,1U,1U);
00070 
00071                 if (C5 == C8 && C5 == C1 && C4 != C2 && C5 != C0)
00072                         line0[1] = interp_w2(C5,C4,3U,1U);
00073                 else if (C4 == C7 && C4 == C2 && C1 != C5 && C4 != D3)
00074                         line0[1] = interp_w2(C4,C5,3U,1U);
00075                 else
00076                         line0[1] = interp_w2(C4,C5,1U,1U);
00077         }
00078 
00079         if (C4 == C8 && C7 != C5 && C3 == C4 && C4 != D2)
00080                 line1[0] = interp_w2(C7,C4,1U,1U);
00081         else if (C4 == C6 && C5 == C4 && C3 != C7 && C4 != D0)
00082                 line1[0] = interp_w2(C7,C4,1U,1U);
00083         else
00084                 line1[0] = C7;
00085 
00086         if (C7 == C5 && C4 != C8 && C6 == C7 && C7 != C2)
00087                 line0[0] = interp_w2(C7,C4,1U,1U);
00088         else if (C3 == C7 && C8 == C7 && C6 != C4 && C7 != C0)
00089                 line0[0] = interp_w2(C7,C4,1U,1U);
00090         else
00091                 line0[0] = C4;
00092 }
00093 
00094 inline void conc2d(SuperEagle,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
00095 {
00096         // --------------------------------------
00097         if (C4 != C8) {
00098                 if (C7 == C5) {
00099                         line0[1] = line1[0] = C7;
00100                         if ((C6 == C7) || (C5 == C2)) {
00101                                 line0[0] = interp_w2(C7,C4,3U,1U);
00102                         } else {
00103                                 line0[0] = interp_w2(C4,C5,1U,1U);
00104                         }
00105 
00106                         if ((C5 == D4) || (C7 == D1)) {
00107                                 line1[1] = interp_w2(C7,C8,3U,1U);
00108                         } else {
00109                                 line1[1] = interp_w2(C7,C8,1U,1U);
00110                         }
00111                 } else {
00112                         line1[1] = interp_w3(C8,C7,C5,6U,1U,1U);
00113                         line0[0] = interp_w3(C4,C7,C5,6U,1U,1U);
00114 
00115                         line1[0] = interp_w3(C7,C4,C8,6U,1U,1U);
00116                         line0[1] = interp_w3(C5,C4,C8,6U,1U,1U);
00117                 }
00118         } else {
00119                 if (C7 != C5) {
00120                         line1[1] = line0[0] = C4;
00121 
00122                         if ((C1 == C4) || (C8 == D5)) {
00123                                 line0[1] = interp_w2(C4,C5,3U,1U);
00124                         } else {
00125                                 line0[1] = interp_w2(C4,C5,1U,1U);
00126                         }
00127 
00128                         if ((C8 == D2) || (C3 == C4)) {
00129                                 line1[0] = interp_w2(C4,C7,3U,1U);
00130                         } else {
00131                                 line1[0] = interp_w2(C7,C8,1U,1U);
00132                         }
00133                 } else {
00134                         int r = 0;
00135                         r += conc2d(GetResult,SBPP)(C5,C4,C6,D1);
00136                         r += conc2d(GetResult,SBPP)(C5,C4,C3,C1);
00137                         r += conc2d(GetResult,SBPP)(C5,C4,D2,D5);
00138                         r += conc2d(GetResult,SBPP)(C5,C4,C2,D4);
00139 
00140                         if (r > 0) {
00141                                 line0[1] = line1[0] = C7;
00142                                 line0[0] = line1[1] = interp_w2(C4,C5,1U,1U);
00143                         } else if (r < 0) {
00144                                 line1[1] = line0[0] = C4;
00145                                 line0[1] = line1[0] = interp_w2(C4,C5,1U,1U);
00146                         } else {
00147                                 line1[1] = line0[0] = C4;
00148                                 line0[1] = line1[0] = C7;
00149                         }
00150                 }
00151         }
00152 }
00153 
00154 inline void conc2d(_2xSaI,SBPP)(PTYPE * line0, PTYPE * line1, const PTYPE * fc)
00155 {
00156         if ((C4 == C8) && (C5 != C7)) {
00157                 if (((C4 == C1) && (C5 == D5)) ||
00158                         ((C4 == C7) && (C4 == C2) && (C5 != C1) && (C5 == D3))) {
00159                                 line0[1] = C4;
00160                 } else {
00161                         line0[1] = interp_w2(C4,C5,1U,1U);
00162                 }
00163 
00164                 if (((C4 == C3) && (C7 == D2)) ||
00165                         ((C4 == C5) && (C4 == C6) && (C3 != C7)  && (C7 == D0))) {
00166                                 line1[0] = C4;
00167                 } else {
00168                         line1[0] = interp_w2(C4,C7,1U,1U);
00169                 }
00170                 line1[1] = C4;
00171         } else if ((C5 == C7) && (C4 != C8)) {
00172                 if (((C5 == C2) && (C4 == C6)) ||
00173                         ((C5 == C1) && (C5 == C8) && (C4 != C2) && (C4 == C0))) {
00174                                 line0[1] = C5;
00175                 } else {
00176                         line0[1] = interp_w2(C4,C5,1U,1U);
00177                 }
00178 
00179                 if (((C7 == C6) && (C4 == C2)) ||
00180                         ((C7 == C3) && (C7 == C8) && (C4 != C6) && (C4 == C0))) {
00181                                 line1[0] = C7;
00182                 } else {
00183                         line1[0] = interp_w2(C4,C7,1U,1U);
00184                 }
00185                 line1[1] = C5;
00186         } else if ((C4 == C8) && (C5 == C7)) {
00187                 if (C4 == C5) {
00188                         line0[1] = C4;
00189                         line1[0] = C4;
00190                         line1[1] = C4;
00191                 } else {
00192                         int r = 0;
00193                         r += conc2d(GetResult,SBPP)(C4,C5,C3,C1);
00194                         r -= conc2d(GetResult,SBPP)(C5,C4,D4,C2);
00195                         r -= conc2d(GetResult,SBPP)(C5,C4,C6,D1);
00196                         r += conc2d(GetResult,SBPP)(C4,C5,D5,D2);
00197 
00198                         if (r > 0)
00199                                 line1[1] = C4;
00200                         else if (r < 0)
00201                                 line1[1] = C5;
00202                         else {
00203                                 line1[1] = interp_w4(C4,C5,C7,C8,1U,1U,1U,1U);
00204                         }
00205 
00206                         line1[0] = interp_w2(C4,C7,1U,1U);
00207                         line0[1] = interp_w2(C4,C5,1U,1U);
00208                 }
00209         } else {
00210                 line1[1] = interp_w4(C4,C5,C7,C8,1U,1U,1U,1U);
00211 
00212                 if ((C4 == C7) && (C4 == C2)
00213                         && (C5 != C1) && (C5 == D3)) {
00214                                 line0[1] = C4;
00215                 } else if ((C5 == C1) && (C5 == C8)
00216                         && (C4 != C2) && (C4 == C0)) {
00217                                 line0[1] = C5;
00218                 } else {
00219                         line0[1] = interp_w2(C4,C5,1U,1U);
00220                 }
00221 
00222                 if ((C4 == C5) && (C4 == C6)
00223                         && (C3 != C7) && (C7 == D0)) {
00224                                 line1[0] = C4;
00225                 } else if ((C7 == C3) && (C7 == C8)
00226                         && (C4 != C6) && (C4 == C0)) {
00227                                 line1[0] = C7;
00228                 } else {
00229                         line1[0] = interp_w2(C4,C7,1U,1U);
00230                 }
00231         }
00232         line0[0] = C4;
00233 }