DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/gui/render_scalers.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 #ifndef _RENDER_SCALERS_H
00020 #define _RENDER_SCALERS_H
00021 
00022 //#include "render.h"
00023 #include "video.h"
00024 #if RENDER_USE_ADVANCED_SCALERS>0
00025 #define SCALER_MAXWIDTH         1920
00026 #define SCALER_MAXHEIGHT        1440
00027 #else
00028 // reduced to save some memory
00029 #define SCALER_MAXWIDTH         800 
00030 #define SCALER_MAXHEIGHT        600
00031 #endif
00032 
00033 #if RENDER_USE_ADVANCED_SCALERS>1
00034 #define SCALER_COMPLEXWIDTH             800
00035 #define SCALER_COMPLEXHEIGHT    600
00036 #endif
00037 
00038 #define SCALER_BLOCKSIZE        16
00039 
00040 typedef enum {
00041         scalerMode8, scalerMode15, scalerMode16, scalerMode32
00042 } scalerMode_t;
00043 
00044 typedef enum scalerOperation {
00045         scalerOpNormal,
00046 #if RENDER_USE_ADVANCED_SCALERS>2
00047         scalerOpAdvMame,
00048         scalerOpAdvInterp,
00049         scalerOpHQ,
00050         scalerOpSaI,
00051         scalerOpSuperSaI,
00052         scalerOpSuperEagle,
00053 #endif
00054 #if RENDER_USE_ADVANCED_SCALERS>0
00055         scalerOpTV,
00056         scalerOpRGB,
00057         scalerOpScan,
00058         scalerOpGray,
00059 #endif
00060         scalerLast
00061 } scalerOperation_t;
00062 
00063 typedef void (*ScalerLineHandler_t)(const void *src);
00064 typedef void (*ScalerComplexHandler_t)(void);
00065 
00066 extern Bit8u Scaler_Aspect[];
00067 extern Bit8u diff_table[];
00068 extern Bitu Scaler_ChangedLineIndex;
00069 extern Bit16u Scaler_ChangedLines[];
00070 #if RENDER_USE_ADVANCED_SCALERS>1
00071 /* Not entirely happy about those +2's since they make a non power of 2, with muls instead of shift */
00072 typedef Bit8u scalerChangeCache_t [SCALER_COMPLEXHEIGHT][SCALER_COMPLEXWIDTH / SCALER_BLOCKSIZE] ;
00073 typedef union {
00074         Bit32u b32      [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH];
00075         Bit16u b16      [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH];
00076         Bit8u b8        [SCALER_COMPLEXHEIGHT] [SCALER_COMPLEXWIDTH];
00077 } scalerFrameCache_t;
00078 #endif
00079 typedef union {
00080         Bit32u b32      [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH];
00081         Bit16u b16      [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH];
00082         Bit8u b8        [SCALER_MAXHEIGHT] [SCALER_MAXWIDTH];
00083 } scalerSourceCache_t;
00084 extern scalerSourceCache_t scalerSourceCache;
00085 #if RENDER_USE_ADVANCED_SCALERS>1
00086 extern scalerChangeCache_t scalerChangeCache;
00087 #endif
00088 typedef ScalerLineHandler_t ScalerLineBlock_t[5][4];
00089 
00090 typedef struct {
00091         const char *name;
00092         Bitu gfxFlags;
00093         Bitu xscale,yscale;
00094         ScalerComplexHandler_t Linear[4];
00095         ScalerComplexHandler_t Random[4];
00096 } ScalerComplexBlock_t;
00097 
00098 typedef struct {
00099         const char *name;
00100         Bitu gfxFlags;
00101         Bitu xscale,yscale;
00102         ScalerLineBlock_t       Linear;
00103         ScalerLineBlock_t       Random;
00104 } ScalerSimpleBlock_t;
00105 
00106 
00107 #define SCALE_LEFT      0x1
00108 #define SCALE_RIGHT     0x2
00109 #define SCALE_FULL      0x4
00110 
00111 /* Simple scalers */
00112 extern ScalerSimpleBlock_t ScaleNormal1x;
00113 extern ScalerSimpleBlock_t ScaleNormalDw;
00114 extern ScalerSimpleBlock_t ScaleNormalDh;
00115 extern ScalerSimpleBlock_t ScaleNormal2x;
00116 extern ScalerSimpleBlock_t ScaleNormal3x;
00117 extern ScalerSimpleBlock_t ScaleNormal4x;
00118 extern ScalerSimpleBlock_t ScaleNormal5x;
00119 extern ScalerSimpleBlock_t ScaleNormal2xDw;
00120 extern ScalerSimpleBlock_t ScaleNormal2xDh;
00121 #if RENDER_USE_ADVANCED_SCALERS>0
00122 extern ScalerSimpleBlock_t ScaleTV2x;
00123 extern ScalerSimpleBlock_t ScaleTVDh;
00124 extern ScalerSimpleBlock_t ScaleTV3x;
00125 extern ScalerSimpleBlock_t ScaleRGB2x;
00126 extern ScalerSimpleBlock_t ScaleRGB3x;
00127 extern ScalerSimpleBlock_t ScaleScan2x;
00128 extern ScalerSimpleBlock_t ScaleScanDh;
00129 extern ScalerSimpleBlock_t ScaleScan3x;
00130 extern ScalerSimpleBlock_t ScaleGrayNormal;
00131 extern ScalerSimpleBlock_t ScaleGrayDw;
00132 extern ScalerSimpleBlock_t ScaleGrayDh;
00133 extern ScalerSimpleBlock_t ScaleGray2x;
00134 #endif
00135 /* Complex scalers */
00136 #if RENDER_USE_ADVANCED_SCALERS>2
00137 extern ScalerComplexBlock_t ScaleHQ2x;
00138 extern ScalerComplexBlock_t ScaleHQ3x;
00139 extern ScalerComplexBlock_t Scale2xSaI;
00140 extern ScalerComplexBlock_t ScaleSuper2xSaI;
00141 extern ScalerComplexBlock_t ScaleSuperEagle;
00142 extern ScalerComplexBlock_t ScaleAdvMame2x;
00143 extern ScalerComplexBlock_t ScaleAdvMame3x;
00144 extern ScalerComplexBlock_t ScaleAdvInterp2x;
00145 extern ScalerComplexBlock_t ScaleAdvInterp3x;
00146 #endif
00147 #if RENDER_USE_ADVANCED_SCALERS>1
00148 extern ScalerLineBlock_t ScalerCache;
00149 #endif
00150 #endif