DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/gui/render_templates.h
00001 /*
00002  *  Copyright (C) 2002-2020  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 along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "config.h"
00020 #include "SDL_endian.h"
00021 
00022 #if DBPP == 8
00023 #define PSIZE 1
00024 #define PTYPE Bit8u
00025 #define WC scalerWriteCache.b8
00026 //#define FC scalerFrameCache.b8
00027 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b8
00028 #define redMask         0
00029 #define greenMask       0
00030 #define blueMask        0
00031 #define redBits         0
00032 #define greenBits       0
00033 #define blueBits        0
00034 #define redShift        0
00035 #define greenShift      0
00036 #define blueShift       0
00037 #elif DBPP == 15 || DBPP == 16
00038 #define PSIZE 2
00039 #define PTYPE Bit16u
00040 #define WC scalerWriteCache.b16
00041 //#define FC scalerFrameCache.b16
00042 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b16
00043 #if DBPP == 15
00044 #define redMask         0x7C00
00045 #define greenMask       0x03E0
00046 #define blueMask        0x001F
00047 #define redBits         5
00048 #define greenBits       5
00049 #define blueBits        5
00050 #define redShift        10
00051 #define greenShift      5
00052 #define blueShift       0
00053 #elif DBPP == 16
00054 #define redMask         0xF800
00055 #define greenMask       0x07E0
00056 #define blueMask        0x001F
00057 #define redBits         5
00058 #define greenBits       6
00059 #define blueBits        5
00060 #define redShift        11
00061 #define greenShift      5
00062 #define blueShift       0
00063 #endif
00064 #elif DBPP == 32
00065 #define PSIZE 4
00066 #define PTYPE Bit32u
00067 #define WC scalerWriteCache.b32
00068 //#define FC scalerFrameCache.b32
00069 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b32
00070 # if !defined(C_SDL2) && defined(MACOSX) /* SDL1 builds are subject to Mac OS X strange BGRA (alpha in low byte) order */
00071 #  define redMask       0x0000ff00
00072 #  define greenMask     0x00ff0000
00073 #  define blueMask      0xff000000
00074 #  define redBits       8
00075 #  define greenBits     8
00076 #  define blueBits      8
00077 #  define redShift      8
00078 #  define greenShift    16
00079 #  define blueShift     24
00080 # else
00081 #  define redMask       0xff0000
00082 #  define greenMask     0x00ff00
00083 #  define blueMask      0x0000ff
00084 #  define redBits       8
00085 #  define greenBits     8
00086 #  define blueBits      8
00087 #  define redShift      16
00088 #  define greenShift    8
00089 #  define blueShift     0
00090 # endif
00091 #endif
00092 
00093 #define redblueMask (redMask | blueMask)
00094 
00095 
00096 #if SBPP == 8 || SBPP == 9
00097 #define SC scalerSourceCache.b8
00098 #if DBPP == 8
00099 #define PMAKE(_VAL) (_VAL)
00100 #elif DBPP == 15
00101 #define PMAKE(_VAL) render.pal.lut.b16[_VAL]
00102 #elif DBPP == 16
00103 #define PMAKE(_VAL) render.pal.lut.b16[_VAL]
00104 #elif DBPP == 32
00105 #define PMAKE(_VAL) render.pal.lut.b32[_VAL]
00106 #endif
00107 #define SRCTYPE Bit8u
00108 #endif
00109 
00110 #if SBPP == 15
00111 #define SC scalerSourceCache.b16
00112 #if DBPP == 15
00113 #define PMAKE(_VAL) (_VAL)
00114 #elif DBPP == 16
00115 #define PMAKE(_VAL) (((_VAL) & 31) | ((_VAL) & ~31) << 1)
00116 #elif DBPP == 32
00117 # if SDL_BYTEORDER == SDL_LIL_ENDIAN && defined(MACOSX) /* Mac OS X Intel builds use a weird RGBA order (alpha in the low 8 bits) */
00118 #  define PMAKE(_VAL)  (((_VAL&(31u<<10u))<<1u)|((_VAL&(31u<<5u))<<14u)|((_VAL&31u)<<27u))
00119 # else
00120 #  define PMAKE(_VAL)  (((_VAL&(31u<<10u))<<9u)|((_VAL&(31u<<5u))<<6u)|((_VAL&31u)<<3u))
00121 # endif
00122 #endif
00123 #define SRCTYPE Bit16u
00124 #endif
00125 
00126 #if SBPP == 16
00127 #define SC scalerSourceCache.b16
00128 #if DBPP == 15
00129 #define PMAKE(_VAL) (((_VAL&~31u)>>1u)|(_VAL&31u))
00130 #elif DBPP == 16
00131 #define PMAKE(_VAL) (_VAL)
00132 #elif DBPP == 32
00133 # if SDL_BYTEORDER == SDL_LIL_ENDIAN && defined(MACOSX) /* Mac OS X Intel builds use a weird RGBA order (alpha in the low 8 bits) */
00134 #  define PMAKE(_VAL)  (((_VAL&(31u<<11u))<<0u)|((_VAL&(63u<<5u))<<13u)|((_VAL&31u)<<27u))
00135 # else
00136 #  define PMAKE(_VAL)  (((_VAL&(31u<<11u))<<8u)|((_VAL&(63u<<5u))<<5u)|((_VAL&31u)<<3u))
00137 # endif
00138 #endif
00139 #define SRCTYPE Bit16u
00140 #endif
00141 
00142 #if SBPP == 32
00143 #define SC scalerSourceCache.b32
00144 #if DBPP == 15
00145 #define PMAKE(_VAL) (PTYPE)(((_VAL&(31u<<19u))>>9u)|((_VAL&(31u<<11u))>>6u)|((_VAL&(31u<<3u))>>3u))
00146 #elif DBPP == 16
00147 #define PMAKE(_VAL) (PTYPE)(((_VAL&(31u<<19u))>>8u)|((_VAL&(63u<<10u))>>5u)|((_VAL&(31u<<3u))>>3u))
00148 #elif DBPP == 32
00149 #define PMAKE(_VAL) (_VAL)
00150 #endif
00151 #define SRCTYPE Bit32u
00152 #endif
00153 
00154 //  C0 C1 C2 D3
00155 //  C3 C4 C5 D4
00156 //  C6 C7 C8 D5
00157 //  D0 D1 D2 D6
00158 
00159 #define C0 fc[-1 - SCALER_COMPLEXWIDTH]
00160 #define C1 fc[+0 - SCALER_COMPLEXWIDTH]
00161 #define C2 fc[+1 - SCALER_COMPLEXWIDTH]
00162 #define C3 fc[-1 ]
00163 #define C4 fc[+0 ]
00164 #define C5 fc[+1 ]
00165 #define C6 fc[-1 + SCALER_COMPLEXWIDTH]
00166 #define C7 fc[+0 + SCALER_COMPLEXWIDTH]
00167 #define C8 fc[+1 + SCALER_COMPLEXWIDTH]
00168 
00169 #define D0 fc[-1 + 2*SCALER_COMPLEXWIDTH]
00170 #define D1 fc[+0 + 2*SCALER_COMPLEXWIDTH]
00171 #define D2 fc[+1 + 2*SCALER_COMPLEXWIDTH]
00172 #define D3 fc[+2 - SCALER_COMPLEXWIDTH]
00173 #define D4 fc[+2]
00174 #define D5 fc[+2 + SCALER_COMPLEXWIDTH]
00175 #define D6 fc[+2 + 2*SCALER_COMPLEXWIDTH]
00176 
00177 
00178 #if RENDER_USE_ADVANCED_SCALERS>1
00179 static inline void conc3d(Cache,SBPP,DBPP) (const void * s) {
00180 # if !defined(_MSC_VER) /* Microsoft C++ thinks this is a failed attempt at a function call---it's not */
00181         (void)conc3d(Cache,SBPP,DBPP);
00182 # endif
00183 #ifdef RENDER_NULL_INPUT
00184         if (!s) {
00185                 render.scale.cacheRead += render.scale.cachePitch;
00186                 render.scale.inLine++;
00187                 render.scale.complexHandler();
00188                 return;
00189         }
00190 #endif
00191         const SRCTYPE * src = (SRCTYPE*)s;
00192         PTYPE *fc= &FC[render.scale.inLine+1][1];
00193         SRCTYPE *sc = (SRCTYPE*)(render.scale.cacheRead);
00194         render.scale.cacheRead += render.scale.cachePitch;
00195         Bitu b;
00196         bool hadChange = false;
00197         /* This should also copy the surrounding pixels but it looks nice enough without */
00198         for (b=0;b<render.scale.blocks;b++) {
00199 #if (SBPP == 9)
00200                 for (Bitu x=0;x<SCALER_BLOCKSIZE;x++) {
00201                         PTYPE pixel = PMAKE(src[x]);
00202                         if (pixel != fc[x]) {
00203 #else 
00204                 for (Bitu x=0;x<SCALER_BLOCKSIZE;x+=sizeof(Bitu)/sizeof(SRCTYPE)) {
00205                         if (*(Bitu const*)&src[x] != *(Bitu*)&sc[x]) {
00206 #endif
00207                                 do {
00208                                         fc[x] = PMAKE(src[x]);
00209                                         sc[x] = src[x];
00210                                         x++;
00211                                 } while (x<SCALER_BLOCKSIZE);
00212                                 hadChange = true;
00213                                 /* Change the surrounding blocks */
00214                                 CC[render.scale.inLine+0][1+b-1] |= SCALE_RIGHT;
00215                                 CC[render.scale.inLine+0][1+b+0] |= SCALE_FULL;
00216                                 CC[render.scale.inLine+0][1+b+1] |= SCALE_LEFT;
00217                                 CC[render.scale.inLine+1][1+b-1] |= SCALE_RIGHT;
00218                                 CC[render.scale.inLine+1][1+b+0] |= SCALE_FULL;
00219                                 CC[render.scale.inLine+1][1+b+1] |= SCALE_LEFT;
00220                                 CC[render.scale.inLine+2][1+b-1] |= SCALE_RIGHT;
00221                                 CC[render.scale.inLine+2][1+b+0] |= SCALE_FULL;
00222                                 CC[render.scale.inLine+2][1+b+1] |= SCALE_LEFT;
00223                                 continue;
00224                         }
00225                 }
00226                 fc += SCALER_BLOCKSIZE;
00227                 sc += SCALER_BLOCKSIZE;
00228                 src += SCALER_BLOCKSIZE;
00229         }
00230         if (hadChange) {
00231                 CC[render.scale.inLine+0][0] = 1;
00232                 CC[render.scale.inLine+1][0] = 1;
00233                 CC[render.scale.inLine+2][0] = 1;
00234         }
00235         render.scale.inLine++;
00236         render.scale.complexHandler();
00237 }
00238 #endif
00239 
00240 
00241 /* Simple scalers */
00242 #define SCALERNAME              Normal1x
00243 #define SCALERWIDTH             1
00244 #define SCALERHEIGHT    1
00245 #define SCALERFUNC                                                              \
00246         line0[0] = P;
00247 #include "render_simple.h"
00248 #undef SCALERNAME
00249 #undef SCALERWIDTH
00250 #undef SCALERHEIGHT
00251 #undef SCALERFUNC
00252 
00253 #define SCALERNAME              Normal2x
00254 #define SCALERWIDTH             2
00255 #define SCALERHEIGHT    2
00256 #define SCALERFUNC                                                              \
00257         line0[0] = P;                                                           \
00258         line0[1] = P;                                                           \
00259         line1[0] = P;                                                           \
00260         line1[1] = P;
00261 #include "render_simple.h"
00262 #undef SCALERNAME
00263 #undef SCALERWIDTH
00264 #undef SCALERHEIGHT
00265 #undef SCALERFUNC
00266 
00267 #define SCALERNAME              Normal3x
00268 #define SCALERWIDTH             3
00269 #define SCALERHEIGHT    3
00270 #define SCALERFUNC                                                              \
00271         line0[0] = P;                                                           \
00272         line0[1] = P;                                                           \
00273         line0[2] = P;                                                           \
00274         line1[0] = P;                                                           \
00275         line1[1] = P;                                                           \
00276         line1[2] = P;                                                           \
00277         line2[0] = P;                                                           \
00278         line2[1] = P;                                                           \
00279         line2[2] = P;
00280 #include "render_simple.h"
00281 #undef SCALERNAME
00282 #undef SCALERWIDTH
00283 #undef SCALERHEIGHT
00284 #undef SCALERFUNC
00285 
00286 #define SCALERNAME              Normal4x
00287 #define SCALERWIDTH             4
00288 #define SCALERHEIGHT    4
00289 #define SCALERFUNC                                                         \
00290         line0[0] = P;                                                           \
00291         line0[1] = P;                                                           \
00292         line0[2] = P;                                                           \
00293         line0[3] = P;                                                           \
00294         line1[0] = P;                                                           \
00295         line1[1] = P;                                                           \
00296         line1[2] = P;                                                           \
00297         line1[3] = P;                                                           \
00298         line2[0] = P;                                                           \
00299         line2[1] = P;                                                           \
00300         line2[2] = P;                                                           \
00301         line2[3] = P;                                                           \
00302         line3[0] = P;                                                           \
00303         line3[1] = P;                                                           \
00304         line3[2] = P;                                                           \
00305         line3[3] = P; 
00306 #include "render_simple.h"
00307 #undef SCALERNAME
00308 #undef SCALERWIDTH
00309 #undef SCALERHEIGHT
00310 #undef SCALERFUNC
00311 
00312 #define SCALERNAME              Normal5x
00313 #define SCALERWIDTH             5
00314 #define SCALERHEIGHT    5
00315 #define SCALERFUNC                                                         \
00316         line0[0] = P;                                                           \
00317         line0[1] = P;                                                           \
00318         line0[2] = P;                                                           \
00319         line0[3] = P;                                                           \
00320         line0[4] = P;                                                           \
00321         line1[0] = P;                                                           \
00322         line1[1] = P;                                                           \
00323         line1[2] = P;                                                           \
00324         line1[3] = P;                                                           \
00325         line1[4] = P;                                                           \
00326         line2[0] = P;                                                           \
00327         line2[1] = P;                                                           \
00328         line2[2] = P;                                                           \
00329         line2[3] = P;                                                           \
00330         line2[4] = P;                                                           \
00331         line3[0] = P;                                                           \
00332         line3[1] = P;                                                           \
00333         line3[2] = P;                                                           \
00334         line3[3] = P;                                                            \
00335         line3[4] = P;                                                           \
00336         line4[0] = P;                                                           \
00337         line4[1] = P;                                                           \
00338         line4[2] = P;                                                           \
00339         line4[3] = P;                                                            \
00340         line4[4] = P;                                                           
00341 #include "render_simple.h"
00342 #undef SCALERNAME
00343 #undef SCALERWIDTH
00344 #undef SCALERHEIGHT
00345 #undef SCALERFUNC
00346 /*
00347 #define SCALERNAME              Normal6x
00348 #define SCALERWIDTH             6
00349 #define SCALERHEIGHT    6
00350 #define SCALERFUNC                                                         \
00351         line0[0] = P;                                                           \
00352         line0[1] = P;                                                           \
00353         line0[2] = P;                                                           \
00354         line0[3] = P;                                                           \
00355         line0[4] = P;                                                           \
00356         line0[5] = P;                                                           \
00357         line1[0] = P;                                                           \
00358         line1[1] = P;                                                           \
00359         line1[2] = P;                                                           \
00360         line1[3] = P;                                                           \
00361         line1[4] = P;                                                           \
00362         line1[5] = P;                                                           \
00363         line2[0] = P;                                                           \
00364         line2[1] = P;                                                           \
00365         line2[2] = P;                                                           \
00366         line2[3] = P;                                                           \
00367         line2[4] = P;                                                           \
00368         line2[5] = P;                                                           \
00369         line3[0] = P;                                                           \
00370         line3[1] = P;                                                           \
00371         line3[2] = P;                                                           \
00372         line3[3] = P;                                                            \
00373         line3[4] = P;                                                           \
00374         line3[5] = P;                                                           \
00375         line4[0] = P;                                                           \
00376         line4[1] = P;                                                           \
00377         line4[2] = P;                                                           \
00378         line4[3] = P;                                                            \
00379         line4[4] = P;                                                           \
00380         line4[5] = P;                                                           \
00381         line5[0] = P;                                                           \
00382         line5[1] = P;                                                           \
00383         line5[2] = P;                                                           \
00384         line5[3] = P;                                                            \
00385         line5[4] = P;                                                           \
00386         line5[5] = P;                                                           
00387 #include "render_simple.h"
00388 #undef SCALERNAME
00389 #undef SCALERWIDTH
00390 #undef SCALERHEIGHT
00391 #undef SCALERFUNC
00392 */
00393 #define SCALERNAME              NormalDw
00394 #define SCALERWIDTH             2
00395 #define SCALERHEIGHT    1
00396 #define SCALERFUNC                                                              \
00397         line0[0] = P;                                                           \
00398         line0[1] = P;
00399 #include "render_simple.h"
00400 #undef SCALERNAME
00401 #undef SCALERWIDTH
00402 #undef SCALERHEIGHT
00403 #undef SCALERFUNC
00404 
00405 #define SCALERNAME              NormalDh
00406 #define SCALERWIDTH             1
00407 #define SCALERHEIGHT    2
00408 #define SCALERFUNC                                                              \
00409         line0[0] = P;                                                           \
00410         line1[0] = P;
00411 #include "render_simple.h"
00412 #undef SCALERNAME
00413 #undef SCALERWIDTH
00414 #undef SCALERHEIGHT
00415 #undef SCALERFUNC
00416 
00417 #define SCALERNAME              Normal2xDw
00418 #define SCALERWIDTH             4
00419 #define SCALERHEIGHT    2
00420 #define SCALERFUNC                              \
00421     line0[0] = P;                               \
00422     line0[1] = P;                               \
00423     line0[2] = P;                               \
00424     line0[3] = P;                               \
00425     line1[0] = P;                               \
00426     line1[1] = P;                               \
00427     line1[2] = P;                               \
00428     line1[3] = P;
00429 #include "render_simple.h"
00430 #undef SCALERNAME
00431 #undef SCALERWIDTH
00432 #undef SCALERHEIGHT
00433 #undef SCALERFUNC
00434 
00435 #define SCALERNAME      Normal2xDh
00436 #define SCALERWIDTH     2
00437 #define SCALERHEIGHT    4
00438 #define SCALERFUNC                              \
00439     line0[0] = P;                               \
00440     line0[1] = P;                               \
00441     line1[0] = P;                               \
00442     line1[1] = P;                               \
00443     line2[0] = P;                               \
00444     line2[1] = P;                               \
00445     line3[0] = P;                               \
00446     line3[1] = P;
00447 #include "render_simple.h"
00448 #undef SCALERNAME
00449 #undef SCALERWIDTH
00450 #undef SCALERHEIGHT
00451 #undef SCALERFUNC
00452 
00453 #if (DBPP > 8)
00454 
00455 #if RENDER_USE_ADVANCED_SCALERS>0
00456 
00457 #define SCALERNAME              TV2x
00458 #define SCALERWIDTH             2
00459 #define SCALERHEIGHT    2
00460 #define SCALERFUNC                                                                      \
00461 {                                                                                                       \
00462         PTYPE halfpixel=((P & redblueMask) >> 1) & redblueMask; \
00463         halfpixel|=((P & greenMask) >> 1) & greenMask;                  \
00464         line0[0]=P;                                                     \
00465         line0[1]=P;                                                     \
00466         line1[0]=halfpixel;                                             \
00467         line1[1]=halfpixel;                                             \
00468 }
00469 #include "render_simple.h"
00470 #undef SCALERNAME
00471 #undef SCALERWIDTH
00472 #undef SCALERHEIGHT
00473 #undef SCALERFUNC
00474 
00475 #define SCALERNAME              TVDh
00476 #define SCALERWIDTH             1
00477 #define SCALERHEIGHT    2
00478 #define SCALERFUNC                                                                      \
00479 {                                                                                                       \
00480         PTYPE halfpixel=((P & redblueMask) >> 1) & redblueMask; \
00481         halfpixel|=((P & greenMask) >> 1) & greenMask;                  \
00482         line0[0]=P;                                                     \
00483         line1[0]=halfpixel;                                             \
00484 }
00485 #include "render_simple.h"
00486 #undef SCALERNAME
00487 #undef SCALERWIDTH
00488 #undef SCALERHEIGHT
00489 #undef SCALERFUNC
00490 
00491 #define SCALERNAME              TV3x
00492 #define SCALERWIDTH             3
00493 #define SCALERHEIGHT    3
00494 #if !defined(C_SDL2) && defined(MACOSX) /* SDL1 builds are subject to Mac OS X strange BGRA (alpha in low byte) order */
00495 #define SCALERFUNC                                                      \
00496 {                                                                                       \
00497         PTYPE halfpixel=(((uint64_t)(P & redblueMask) * (uint64_t)5) >> (uint64_t)3) & redblueMask;     \
00498         halfpixel|=(((uint64_t)(P & greenMask) * (uint64_t)5) >> (uint64_t)3) & greenMask;                      \
00499         line0[0]=P;                                                             \
00500         line0[1]=P;                                                             \
00501         line0[2]=P;                                                             \
00502         line1[0]=halfpixel;                                             \
00503         line1[1]=halfpixel;                                             \
00504         line1[2]=halfpixel;                                             \
00505         halfpixel=(((uint64_t)(P & redblueMask) * (uint64_t)5) >> (uint64_t)4) & redblueMask;   \
00506         halfpixel|=(((uint64_t)(P & greenMask) * (uint64_t)5) >> (uint64_t)4) & greenMask;                      \
00507         line2[0]=halfpixel;                                             \
00508         line2[1]=halfpixel;                                             \
00509         line2[2]=halfpixel;                                             \
00510 }
00511 #else
00512 #define SCALERFUNC                                                      \
00513 {                                                                                       \
00514         PTYPE halfpixel=(((P & redblueMask) * 5) >> 3) & redblueMask;   \
00515         halfpixel|=(((P & greenMask) * 5) >> 3) & greenMask;                    \
00516         line0[0]=P;                                                             \
00517         line0[1]=P;                                                             \
00518         line0[2]=P;                                                             \
00519         line1[0]=halfpixel;                                             \
00520         line1[1]=halfpixel;                                             \
00521         line1[2]=halfpixel;                                             \
00522         halfpixel=(((P & redblueMask) * 5) >> 4) & redblueMask; \
00523         halfpixel|=(((P & greenMask) * 5) >> 4) & greenMask;                    \
00524         line2[0]=halfpixel;                                             \
00525         line2[1]=halfpixel;                                             \
00526         line2[2]=halfpixel;                                             \
00527 }
00528 #endif
00529 #include "render_simple.h"
00530 #undef SCALERNAME
00531 #undef SCALERWIDTH
00532 #undef SCALERHEIGHT
00533 #undef SCALERFUNC
00534 
00535 #define SCALERNAME              RGB2x
00536 #define SCALERWIDTH             2
00537 #define SCALERHEIGHT    2
00538 #define SCALERFUNC                                              \
00539         line0[0]=P & redMask;                           \
00540         line0[1]=P & greenMask;                 \
00541         line1[0]=P & blueMask;                          \
00542         line1[1]=P;
00543 #include "render_simple.h"
00544 #undef SCALERNAME
00545 #undef SCALERWIDTH
00546 #undef SCALERHEIGHT
00547 #undef SCALERFUNC
00548 
00549 #define SCALERNAME              RGB3x
00550 #define SCALERWIDTH             3
00551 #define SCALERHEIGHT    3
00552 #define SCALERFUNC                                              \
00553         line0[0]=P;                                                     \
00554         line0[1]=P & greenMask;                         \
00555         line0[2]=P & blueMask;                          \
00556         line1[0]=P & greenMask;                         \
00557         line1[1]=P & redMask;                                           \
00558         line1[2]=P;                             \
00559         line2[0]=P;                             \
00560         line2[1]=P & blueMask;                          \
00561         line2[2]=P & redMask;
00562 #include "render_simple.h"
00563 #undef SCALERNAME
00564 #undef SCALERWIDTH
00565 #undef SCALERHEIGHT
00566 #undef SCALERFUNC
00567 
00568 #define SCALERNAME              Scan2x
00569 #define SCALERWIDTH             2
00570 #define SCALERHEIGHT    2
00571 #define SCALERFUNC                                              \
00572         line0[0]=P;                                                     \
00573         line0[1]=P;                                                     \
00574         line1[0]=0;                                                     \
00575         line1[1]=0;
00576 #include "render_simple.h"
00577 #undef SCALERNAME
00578 #undef SCALERWIDTH
00579 #undef SCALERHEIGHT
00580 #undef SCALERFUNC
00581 
00582 #define SCALERNAME              ScanDh
00583 #define SCALERWIDTH             1
00584 #define SCALERHEIGHT    2
00585 #define SCALERFUNC                                                              \
00586         line0[0] = P;                                                           \
00587         line1[0] = 0;
00588 #include "render_simple.h"
00589 #undef SCALERNAME
00590 #undef SCALERWIDTH
00591 #undef SCALERHEIGHT
00592 #undef SCALERFUNC
00593 
00594 #define SCALERNAME              Scan3x
00595 #define SCALERWIDTH             3
00596 #define SCALERHEIGHT    3
00597 #define SCALERFUNC                      \
00598         line0[0]=P;                             \
00599         line0[1]=P;                             \
00600         line0[2]=P;                             \
00601         line1[0]=P;                             \
00602         line1[1]=P;                             \
00603         line1[2]=P;                             \
00604         line2[0]=0;                             \
00605         line2[1]=0;                             \
00606         line2[2]=0;
00607 #include "render_simple.h"
00608 #undef SCALERNAME
00609 #undef SCALERWIDTH
00610 #undef SCALERHEIGHT
00611 #undef SCALERFUNC
00612 
00613 /* Grayscale scalers */
00614 #define SCALERNAME              GrayNormal
00615 #define SCALERWIDTH             1
00616 #define SCALERHEIGHT    1
00617 #define SCALERFUNC                                                              \
00618         PTYPE _red=(P&redMask)>>redShift,_green=(P&greenMask)>>greenShift,_blue=(P&blueMask)>>blueShift;        \
00619   double _gray=0.2125*(double)_red+0.7154*(double)_green+0.0721*(double)_blue; \
00620   PTYPE _value = _gray>255?0xff:(uint8_t)(_gray);  \
00621         line0[0] = ((_value<<redShift)|(_value<<greenShift)|(_value)<<blueShift);
00622 #include "render_simple.h"
00623 #undef SCALERNAME
00624 #undef SCALERWIDTH
00625 #undef SCALERHEIGHT
00626 #undef SCALERFUNC
00627 
00628 #define SCALERNAME              GrayDw
00629 #define SCALERWIDTH             2
00630 #define SCALERHEIGHT    1
00631 #define SCALERFUNC                                                              \
00632         PTYPE _red=(P&redMask)>>redShift,_green=(P&greenMask)>>greenShift,_blue=(P&blueMask)>>blueShift;        \
00633   double _gray=0.2125*(double)_red+0.7154*(double)_green+0.0721*(double)_blue; \
00634   PTYPE _value = _gray>255?0xff:(uint8_t)(_gray);  \
00635         line0[0]=line0[1] = ((_value<<redShift)|(_value<<greenShift)|(_value)<<blueShift);
00636 #include "render_simple.h"
00637 #undef SCALERNAME
00638 #undef SCALERWIDTH
00639 #undef SCALERHEIGHT
00640 #undef SCALERFUNC
00641 
00642 #define SCALERNAME              GrayDh
00643 #define SCALERWIDTH             1
00644 #define SCALERHEIGHT    2
00645 #define SCALERFUNC                                                              \
00646         PTYPE _red=(P&redMask)>>redShift,_green=(P&greenMask)>>greenShift,_blue=(P&blueMask)>>blueShift;        \
00647   double _gray=0.2125*(double)_red+0.7154*(double)_green+0.0721*(double)_blue; \
00648   PTYPE _value = _gray>255?0xff:(uint8_t)(_gray);  \
00649         line0[0]=line1[0] = ((_value<<redShift)|(_value<<greenShift)|(_value)<<blueShift);
00650 #include "render_simple.h"
00651 #undef SCALERNAME
00652 #undef SCALERWIDTH
00653 #undef SCALERHEIGHT
00654 #undef SCALERFUNC
00655 
00656 #define SCALERNAME              Gray2x
00657 #define SCALERWIDTH             2
00658 #define SCALERHEIGHT    2
00659 #define SCALERFUNC                                                              \
00660         PTYPE _red=(P&redMask)>>redShift,_green=(P&greenMask)>>greenShift,_blue=(P&blueMask)>>blueShift;        \
00661   double _gray=0.2125*(double)_red+0.7154*(double)_green+0.0721*(double)_blue; \
00662   PTYPE _value = _gray>255?0xff:(uint8_t)(_gray);  \
00663         line0[0]=line1[0]=line0[1]=line1[1] = ((_value<<redShift)|(_value<<greenShift)|(_value)<<blueShift);
00664 #include "render_simple.h"
00665 #undef SCALERNAME
00666 #undef SCALERWIDTH
00667 #undef SCALERHEIGHT
00668 #undef SCALERFUNC
00669 
00670 #endif          //#if RENDER_USE_ADVANCED_SCALERS>0
00671 
00672 #endif          //#if (DBPP > 8)
00673 
00674 /* Complex scalers */
00675 
00676 #if RENDER_USE_ADVANCED_SCALERS>2
00677 
00678 #if (SBPP == DBPP) 
00679 
00680 
00681 #if (DBPP > 8)
00682 
00683 #include "render_templates_hq.h"
00684 
00685 #define SCALERNAME              HQ2x
00686 #define SCALERWIDTH             2
00687 #define SCALERHEIGHT    2
00688 #include "render_templates_hq2x.h"
00689 #define SCALERFUNC              conc2d(Hq2x,SBPP)(line0, line1, fc)
00690 #include "render_loops.h"
00691 #undef SCALERNAME
00692 #undef SCALERWIDTH
00693 #undef SCALERHEIGHT
00694 #undef SCALERFUNC
00695 
00696 #define SCALERNAME              HQ3x
00697 #define SCALERWIDTH             3
00698 #define SCALERHEIGHT    3
00699 #include "render_templates_hq3x.h"
00700 #define SCALERFUNC              conc2d(Hq3x,SBPP)(line0, line1, line2, fc)
00701 #include "render_loops.h"
00702 #undef SCALERNAME
00703 #undef SCALERWIDTH
00704 #undef SCALERHEIGHT
00705 #undef SCALERFUNC
00706 
00707 #include "render_templates_sai.h"
00708 
00709 #define SCALERNAME              Super2xSaI
00710 #define SCALERWIDTH             2
00711 #define SCALERHEIGHT    2
00712 #define SCALERFUNC              conc2d(Super2xSaI,SBPP)(line0, line1, fc)
00713 #include "render_loops.h"
00714 #undef SCALERNAME
00715 #undef SCALERWIDTH
00716 #undef SCALERHEIGHT
00717 #undef SCALERFUNC
00718 
00719 #define SCALERNAME              SuperEagle
00720 #define SCALERWIDTH             2
00721 #define SCALERHEIGHT    2
00722 #define SCALERFUNC              conc2d(SuperEagle,SBPP)(line0, line1, fc)
00723 #include "render_loops.h"
00724 #undef SCALERNAME
00725 #undef SCALERWIDTH
00726 #undef SCALERHEIGHT
00727 #undef SCALERFUNC
00728 
00729 #define SCALERNAME              _2xSaI
00730 #define SCALERWIDTH             2
00731 #define SCALERHEIGHT    2
00732 #define SCALERFUNC              conc2d(_2xSaI,SBPP)(line0, line1, fc)
00733 #include "render_loops.h"
00734 #undef SCALERNAME
00735 #undef SCALERWIDTH
00736 #undef SCALERHEIGHT
00737 #undef SCALERFUNC
00738 
00739 #define SCALERNAME              AdvInterp2x
00740 #define SCALERWIDTH             2
00741 #define SCALERHEIGHT    2
00742 #define SCALERFUNC                                                                                              \
00743         if (C1 != C7 && C3 != C5) {                                                                     \
00744                 line0[0] = C3 == C1 ? interp_w2(C3,C4,5U,3U) : C4;              \
00745                 line0[1] = C1 == C5 ? interp_w2(C5,C4,5U,3U) : C4;              \
00746                 line1[0] = C3 == C7 ? interp_w2(C3,C4,5U,3U) : C4;              \
00747                 line1[1] = C7 == C5 ? interp_w2(C5,C4,5U,3U) : C4;              \
00748         } else {                                                                                                        \
00749                 line0[0] = line0[1] = C4;                                                               \
00750                 line1[0] = line1[1] = C4;                                                               \
00751         }
00752 #include "render_loops.h"
00753 #undef SCALERNAME
00754 #undef SCALERWIDTH
00755 #undef SCALERHEIGHT
00756 #undef SCALERFUNC
00757 
00758 //TODO, come up with something better for this one
00759 #define SCALERNAME              AdvInterp3x
00760 #define SCALERWIDTH             3
00761 #define SCALERHEIGHT    3
00762 #define SCALERFUNC                                                                                              \
00763         if ((C1 != C7) && (C3 != C5)) {                                                                                                 \
00764                 line0[0] = C3 == C1 ?  interp_w2(C3,C4,5U,3U) : C4;                                                                                             \
00765                 line0[1] = (C3 == C1 && C4 != C2) || (C5 == C1 && C4 != C0) ? C1 : C4;          \
00766                 line0[2] = C5 == C1 ?  interp_w2(C5,C4,5U,3U) : C4;                                                                                             \
00767                 line1[0] = (C3 == C1 && C4 != C6) || (C3 == C7 && C4 != C0) ? C3 : C4;          \
00768                 line1[1] = C4;                                                                                                                          \
00769                 line1[2] = (C5 == C1 && C4 != C8) || (C5 == C7 && C4 != C2) ? C5 : C4;          \
00770                 line2[0] = C3 == C7 ?  interp_w2(C3,C4,5U,3U) : C4;                                                                                             \
00771                 line2[1] = (C3 == C7 && C4 != C8) || (C5 == C7 && C4 != C6) ? C7 : C4;          \
00772                 line2[2] = C5 == C7 ?  interp_w2(C5,C4,5U,3U) : C4;                                                                                             \
00773         } else {                                                                                                                                                \
00774                 line0[0] = line0[1] = line0[2] = C4;                                                                            \
00775                 line1[0] = line1[1] = line1[2] = C4;                                                                            \
00776                 line2[0] = line2[1] = line2[2] = C4;                                                                            \
00777         }
00778 #include "render_loops.h"
00779 #undef SCALERNAME
00780 #undef SCALERWIDTH
00781 #undef SCALERHEIGHT
00782 #undef SCALERFUNC
00783 
00784 #endif // #if (DBPP > 8)
00785 
00786 #define SCALERNAME              AdvMame2x
00787 #define SCALERWIDTH             2
00788 #define SCALERHEIGHT    2
00789 #define SCALERFUNC                                                                                              \
00790         if (C1 != C7 && C3 != C5) {                                                                     \
00791                 line0[0] = C3 == C1 ? C3 : C4;                                                  \
00792                 line0[1] = C1 == C5 ? C5 : C4;                                                  \
00793                 line1[0] = C3 == C7 ? C3 : C4;                                                  \
00794                 line1[1] = C7 == C5 ? C5 : C4;                                                  \
00795         } else {                                                                                                        \
00796                 line0[0] = line0[1] = C4;                                                               \
00797                 line1[0] = line1[1] = C4;                                                               \
00798         }
00799 #include "render_loops.h"
00800 #undef SCALERNAME
00801 #undef SCALERWIDTH
00802 #undef SCALERHEIGHT
00803 #undef SCALERFUNC
00804 
00805 #define SCALERNAME              AdvMame3x
00806 #define SCALERWIDTH             3
00807 #define SCALERHEIGHT    3
00808 #define SCALERFUNC                                                                                                                                      \
00809         if ((C1 != C7) && (C3 != C5)) {                                                                                                 \
00810                 line0[0] = C3 == C1 ?  C3 : C4;                                                                                         \
00811                 line0[1] = (C3 == C1 && C4 != C2) || (C5 == C1 && C4 != C0) ? C1 : C4;          \
00812                 line0[2] = C5 == C1 ?  C5 : C4;                                                                                         \
00813                 line1[0] = (C3 == C1 && C4 != C6) || (C3 == C7 && C4 != C0) ? C3 : C4;          \
00814                 line1[1] = C4;                                                                                                                          \
00815                 line1[2] = (C5 == C1 && C4 != C8) || (C5 == C7 && C4 != C2) ? C5 : C4;          \
00816                 line2[0] = C3 == C7 ?  C3 : C4;                                                                                         \
00817                 line2[1] = (C3 == C7 && C4 != C8) || (C5 == C7 && C4 != C6) ? C7 : C4;          \
00818                 line2[2] = C5 == C7 ?  C5 : C4;                                                                                         \
00819         } else {                                                                                                                                                \
00820                 line0[0] = line0[1] = line0[2] = C4;                                                                            \
00821                 line1[0] = line1[1] = line1[2] = C4;                                                                            \
00822                 line2[0] = line2[1] = line2[2] = C4;                                                                            \
00823         }
00824 
00825 #include "render_loops.h"
00826 #undef SCALERNAME
00827 #undef SCALERWIDTH
00828 #undef SCALERHEIGHT
00829 #undef SCALERFUNC
00830 
00831 
00832 #endif // (SBPP == DBPP) && !defined (CACHEWITHPAL)
00833 
00834 #endif // #if RENDER_USE_ADVANCED_SCALERS>2
00835 
00836 #undef PSIZE
00837 #undef PTYPE
00838 #undef PMAKE
00839 #undef WC
00840 #undef LC
00841 #undef FC
00842 #undef SC
00843 #undef redMask
00844 #undef greenMask
00845 #undef blueMask
00846 #undef redblueMask
00847 #undef redBits
00848 #undef greenBits
00849 #undef blueBits
00850 #undef redShift
00851 #undef greenShift
00852 #undef blueShift
00853 #undef SRCTYPE