DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/gui/render_simple.h
00001 /*
00002  *  Copyright (C) 2002-2015  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 
00020 #if defined (SCALERLINEAR)
00021 static inline void conc4d(SCALERNAME,SBPP,DBPP,L)(const void *s) {
00022 # if !defined(_MSC_VER) /* Microsoft C++ thinks this is a failed attempt at a function call---it's not */
00023         (void)conc4d(SCALERNAME,SBPP,DBPP,L);
00024 # endif
00025 #else
00026 static inline void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) {
00027 # if !defined(_MSC_VER) /* Microsoft C++ thinks this is a failed attempt at a function call---it's not */
00028         (void)conc4d(SCALERNAME,SBPP,DBPP,R);
00029 # endif
00030 #endif
00031 
00032 #ifdef RENDER_NULL_INPUT
00033         if (!s) {
00034                 render.scale.cacheRead += render.scale.cachePitch;
00035 #if defined(SCALERLINEAR) 
00036                 Bitu skipLines = SCALERHEIGHT;
00037 #else
00038                 Bitu skipLines = Scaler_Aspect[ render.scale.outLine++ ];
00039 #endif
00040                 ScalerAddLines( 0, skipLines );
00041                 return;
00042         }
00043 #endif
00044         /* Clear the complete line marker */
00045         Bitu hadChange = 0;
00046         const SRCTYPE *src = (SRCTYPE*)s;
00047         SRCTYPE *cache = (SRCTYPE*)(render.scale.cacheRead);
00048         render.scale.cacheRead += render.scale.cachePitch;
00049         PTYPE * line0=(PTYPE *)(render.scale.outWrite);
00050 #if (SBPP == 9)
00051         for (Bits x=(Bits)render.src.width;x>0;) {
00052                 if (*(Bit32u const*)src == *(Bit32u*)cache && !(
00053                         render.pal.modified[src[0]] | 
00054                         render.pal.modified[src[1]] | 
00055                         render.pal.modified[src[2]] | 
00056                         render.pal.modified[src[3]] )) {
00057                         x-=4;
00058                         src+=4;
00059                         cache+=4;
00060                         line0+=4*SCALERWIDTH;
00061 #else 
00062         for (Bits x=(Bits)render.src.width;x>0;) {
00063                 if (*(Bitu const*)src == *(Bitu*)cache) {
00064                         x-=(Bits)(sizeof(Bitu)/sizeof(SRCTYPE));
00065                         src+=(Bits)(sizeof(Bitu)/sizeof(SRCTYPE));
00066                         cache+=(Bits)(sizeof(Bitu)/sizeof(SRCTYPE));
00067                         line0+=(Bits)(sizeof(Bitu)/sizeof(SRCTYPE))*SCALERWIDTH;
00068 #endif
00069                 } else {
00070 #if defined(SCALERLINEAR)
00071 #if (SCALERHEIGHT > 1) 
00072                         PTYPE *line1 = WC[0];
00073 #endif
00074 #if (SCALERHEIGHT > 2) 
00075                         PTYPE *line2 = WC[1];
00076 #endif
00077 #if (SCALERHEIGHT > 3) 
00078                         PTYPE *line3 = WC[2];
00079 #endif
00080 #if (SCALERHEIGHT > 4) 
00081                         PTYPE *line4 = WC[3];
00082 #endif
00083 #if (SCALERHEIGHT > 5) 
00084                         PTYPE *line5 = WC[4];
00085 #endif
00086 #else
00087 #if (SCALERHEIGHT > 1) 
00088                 PTYPE *line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch);
00089 #endif
00090 #if (SCALERHEIGHT > 2) 
00091                 PTYPE *line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
00092 #endif
00093 #if (SCALERHEIGHT > 3) 
00094                 PTYPE *line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
00095 #endif
00096 #if (SCALERHEIGHT > 4) 
00097                 PTYPE *line4 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 4);
00098 #endif
00099 #if (SCALERHEIGHT > 5) 
00100                 PTYPE *line5 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 5);
00101 #endif
00102 #endif //defined(SCALERLINEAR)
00103                         hadChange = 1;
00104                         for (Bitu i = x > 32 ? 32 : (Bitu)x;i>0;i--,x--) {
00105                                 const SRCTYPE S = *src;
00106                                 *cache = S;
00107                                 src++;cache++;
00108                                 const PTYPE P = PMAKE(S);
00109                                 SCALERFUNC;
00110                                 line0 += SCALERWIDTH;
00111 #if (SCALERHEIGHT > 1) 
00112                                 line1 += SCALERWIDTH;
00113 #endif
00114 #if (SCALERHEIGHT > 2) 
00115                                 line2 += SCALERWIDTH;
00116 #endif
00117 #if (SCALERHEIGHT > 3) 
00118                                 line3 += SCALERWIDTH;
00119 #endif
00120 #if (SCALERHEIGHT > 4) 
00121                                 line4 += SCALERWIDTH;
00122 #endif
00123 #if (SCALERHEIGHT > 5) 
00124                                 line5 += SCALERWIDTH;
00125 #endif
00126                         }
00127 #if defined(SCALERLINEAR)
00128 #if (SCALERHEIGHT > 1)
00129                         Bitu copyLen = (Bitu)((Bit8u*)line1 - (Bit8u*)WC[0]);
00130                         BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch  ,WC[0], copyLen );
00131 #endif
00132 #if (SCALERHEIGHT > 2) 
00133                         BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*2,WC[1], copyLen );
00134 #endif
00135 #if (SCALERHEIGHT > 3) 
00136                         BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*3,WC[2], copyLen );
00137 #endif
00138 #if (SCALERHEIGHT > 4) 
00139                         BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*4,WC[3], copyLen );
00140 #endif
00141 #if (SCALERHEIGHT > 5) 
00142                         BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*5,WC[4], copyLen );
00143 #endif
00144 #endif //defined(SCALERLINEAR)
00145                 }
00146         }
00147 #if defined(SCALERLINEAR) 
00148         Bitu scaleLines = SCALERHEIGHT;
00149 #else
00150         Bitu scaleLines = Scaler_Aspect[ render.scale.outLine++ ];
00151         if ( scaleLines - SCALERHEIGHT && hadChange ) {
00152                 BituMove( render.scale.outWrite + render.scale.outPitch * SCALERHEIGHT,
00153                         render.scale.outWrite + render.scale.outPitch * (SCALERHEIGHT-1),
00154                         render.src.width * SCALERWIDTH * PSIZE);
00155         }
00156 #endif
00157         ScalerAddLines( hadChange, scaleLines );
00158 }
00159 
00160 #if !defined(SCALERLINEAR) 
00161 #define SCALERLINEAR 1
00162 #include "render_simple.h"
00163 #undef SCALERLINEAR
00164 #endif