From e2ed1930c3e974c4ab556c0c672f75504adb118d Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 23 Aug 2023 16:44:14 +0200 Subject: [PATCH] add d3d9 lanczos2 shader --- inc/d3d9shader.h | 1241 ++++++++++++++++++++++++++++++++++++++------- inc/dd.h | 1 + src/config.c | 2 +- src/render_d3d9.c | 40 +- 4 files changed, 1094 insertions(+), 190 deletions(-) diff --git a/inc/d3d9shader.h b/inc/d3d9shader.h index 31002fa..130d33f 100644 --- a/inc/d3d9shader.h +++ b/inc/d3d9shader.h @@ -2,36 +2,6 @@ #define D3D9SHADER_H #if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 10.1 -// -// Parameters: -// -// sampler2D PaletteTex; -// sampler2D SurfaceTex; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// SurfaceTex s0 1 -// PaletteTex s1 1 -// - - ps_2_0 - def c0, 0.99609375, 0.001953125, 0, 0 - dcl t0.xy - dcl_2d s0 - dcl_2d s1 - texld r0, t0, s0 - mad r0.x, r0.x, c0.x, c0.y - mov r0.y, c0.z - texld r0, r0, s1 - mov oC0, r0 - -// approximately 5 instruction slots used (2 texture, 3 arithmetic) - // fxc.exe /Tps_2_0 shader.hlsl /Fhshader.h /* uniform sampler2D SurfaceTex; @@ -107,69 +77,6 @@ const BYTE D3D9_PALETTE_SHADER[] = /* bilinear upscaling */ #if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 10.1 -// -// Parameters: -// -// sampler2D PaletteTex; -// sampler2D SurfaceTex; -// float4 TextureSize; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// TextureSize c0 1 -// SurfaceTex s0 1 -// PaletteTex s1 1 -// - - ps_2_0 - def c1, -0.5, 0.5, 1.5, 0 - def c2, 0.99609375, 0.001953125, 0, 0 - dcl t0.xy - dcl_2d s0 - dcl_2d s1 - mov r0.w, c1.x - mad r0.xy, t0, c0, r0.w - frc r0.zw, r0.wzyx - add r0.xy, -r0.wzyx, r0 - add r0.zw, r0.wzyx, c1.z - add r0.xy, r0, c1.y - rcp r1.x, c0.x - rcp r1.y, c0.y - mul r2.xy, r0.wzyx, r1 - mul r1.xy, r0, r1 - mad r0.xy, t0, c0, -r0 - mov r3.x, r2.x - mov r3.y, r1.y - mov r4.x, r1.x - mov r4.y, r2.y - texld r3, r3, s0 - texld r1, r1, s0 - texld r2, r2, s0 - texld r4, r4, s0 - mad r3.x, r3.x, c2.x, c2.y - mov r3.y, c1.w - mad r1.x, r1.x, c2.x, c2.y - mov r1.y, c1.w - mad r2.x, r2.x, c2.x, c2.y - mad r4.x, r4.x, c2.x, c2.y - mov r4.y, c1.w - mov r2.y, c1.w - texld r3, r3, s1 - texld r1, r1, s1 - texld r4, r4, s1 - texld r2, r2, s1 - lrp r5, r0.x, r3, r1 - lrp r1, r0.x, r2, r4 - lrp r2, r0.y, r1, r5 - mov oC0, r2 - -// approximately 35 instruction slots used (8 texture, 27 arithmetic) - // fxc.exe /Tps_2_0 shader.hlsl /Fhshader.h /* uniform sampler2D SurfaceTex; @@ -365,91 +272,15 @@ const BYTE D3D9_PALETTE_SHADER_BILINEAR[] = /* catmull rom upscaling */ #if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 10.1 -// -// Parameters: -// -// sampler2D SurfaceTex; -// float4 TextureSize; -// -// -// Registers: -// -// Name Reg Size -// ------------ ----- ---- -// TextureSize c0 1 -// SurfaceTex s0 1 -// - - ps_2_0 - def c1, -0.5, 0.5, 1, 2.5 - def c2, 1.5, -2.5, 2, 0 - dcl t0.xy - dcl_2d s0 - mov r0.w, c1.x - mad r0.xy, t0, c0, r0.w - frc r0.zw, r0.wzyx - add r0.xy, -r0.wzyx, r0 - add r0.zw, r0.wzyx, c1.x - rcp r1.x, c0.x - rcp r1.y, c0.y - mul r2.xy, r0.wzyx, r1 - mov r3.x, r2.x - add r0.zw, r0.wzyx, c1.y - add r0.xy, r0, c1.w - mul r0.xy, r1, r0 - mad r1.zw, t0.wzyx, c0.wzyx, -r0 - mad r2.zw, r1, -c2.x, c2.z - mad r2.zw, r1, r2, c1.y - mul r3.zw, r1, r2 - mad r4.xy, r1.wzyx, c2.x, c2.y - mul r4.zw, r1, r1 - mad r4.xy, r4.wzyx, r4, c1.z - mad r2.zw, r1, r2, r4.wzyx - rcp r4.x, r2.w - rcp r4.y, r2.z - mad r0.zw, r3, r4.wzyx, r0 - mul r1.xy, r1, r0.wzyx - mov r3.y, r1.y - mov r4.y, r3.y - mov r2.x, r1.x - mov r5.x, r2.x - mov r4.x, r0.x - mov r5.y, r0.y - texld r0, r3, s0 - texld r3, r1, s0 - texld r6, r2, s0 - texld r5, r5, s0 - texld r7, r4, s0 - mad r1.xy, r1.wzyx, -c1.y, c1.z - mad r1.xy, r1.wzyx, r1, c1.x - mul r1.xy, r1, r1.wzyx - mad r1.zw, r1, c1.y, c1.x - mul r1.zw, r1, r4 - mul r0.w, r2.z, r1.x - mul r0.xyz, r0.w, r0 - mad r0.w, r2.w, r1.y, r0.w - mul r3.w, r1.y, r2.w - mad r0.w, r2.w, r2.z, r0.w - mad r0.w, r1.w, r2.z, r0.w - mad r0.w, r2.w, r1.z, r0.w - rcp r0.w, r0.w - mad r0.xyz, r6, r3.w, r0 - mul r3.w, r2.z, r2.w - mad r0.xyz, r3, r3.w, r0 - mul r5.w, r2.z, r1.w - mul r7.w, r1.z, r2.w - mad r0.xyz, r7, r5.w, r0 - mad r0.xyz, r5, r7.w, r0 - mul r0.xyz, r0.w, r0 - mov r0.w, c1.z - mov oC0, r0 - -// approximately 58 instruction slots used (5 texture, 53 arithmetic) - // fxc.exe /Tps_2_0 shader.hlsl /Fhshader.h /* +// The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae +// Ported from code: https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1 +// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16. +// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details + +// Modified to use 5 texture fetches + uniform sampler2D SurfaceTex; float4 TextureSize : register(c0); @@ -458,13 +289,6 @@ float4 TextureSize : register(c0); float4 catmull_rom(float2 coord) { - // The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae - - // Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16. - // See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details - - // Modified to use 5 texture fetches - float2 samplePos = coord * SourceSize.xy; float2 texPos1 = floor(samplePos - 0.5f) + 0.5f; @@ -716,5 +540,1056 @@ const BYTE D3D9_CATMULL_ROM_SHADER[] = }; +/* lanczos2 upscaling */ + +#if 0 +// fxc.exe /Tps_3_0 shader.hlsl /Fhshader.h +/* +// The following code is licensed under the MIT license: +// Hyllian's jinc windowed-jinc 2-lobe sharper with anti-ringing Shader +// Copyright (C) 2011-2016 Hyllian/Jararaca - sergiogdb@gmail.com +// Ported from: https://github.com/libretro/glsl-shaders/blob/09e2942efbab2f51b60ff0b93b7761b0b0570910/windowed/shaders/lanczos2-sharp.glsl + +uniform sampler2D SurfaceTex; + +float4 TextureSize : register(c0); + +#define JINC2_WINDOW_SINC 0.5 +#define JINC2_SINC 1.0 +#define JINC2_AR_STRENGTH 0.8 + +static const float pi = 3.1415926535897932384626433832795; +static const float wa = JINC2_WINDOW_SINC*pi; +static const float wb = JINC2_SINC*pi; + +// Calculates the distance between two points +float d(float2 pt1, float2 pt2) +{ + float2 v = pt2 - pt1; + return sqrt(dot(v,v)); +} + +float3 min4(float3 a, float3 b, float3 c, float3 d) +{ + return min(a, min(b, min(c, d))); +} + +float3 max4(float3 a, float3 b, float3 c, float3 d) +{ + return max(a, max(b, max(c, d))); +} + +float4 resampler(float4 x) +{ + float4 res; + + res.x = (x.x==0.0) ? wa*wb : sin(x.x*wa)*sin(x.x*wb)/(x.x*x.x); + res.y = (x.y==0.0) ? wa*wb : sin(x.y*wa)*sin(x.y*wb)/(x.y*x.y); + res.z = (x.z==0.0) ? wa*wb : sin(x.z*wa)*sin(x.z*wb)/(x.z*x.z); + res.w = (x.w==0.0) ? wa*wb : sin(x.w*wa)*sin(x.w*wb)/(x.w*x.w); + + return res; +} + +float4 lanczos2(float2 coord) +{ + float3 color; + float4 weights[4]; + + float2 dx = float2(1.0, 0.0); + float2 dy = float2(0.0, 1.0); + + float2 pc = coord*TextureSize.xy; + + float2 tc = (floor(pc-float2(0.5,0.5))+float2(0.5,0.5)); + + weights[0] = resampler(float4(d(pc, tc -dx -dy), d(pc, tc -dy), d(pc, tc +dx -dy), d(pc, tc+2.0*dx -dy))); + weights[1] = resampler(float4(d(pc, tc -dx ), d(pc, tc ), d(pc, tc +dx ), d(pc, tc+2.0*dx ))); + weights[2] = resampler(float4(d(pc, tc -dx +dy), d(pc, tc +dy), d(pc, tc +dx +dy), d(pc, tc+2.0*dx +dy))); + weights[3] = resampler(float4(d(pc, tc -dx+2.0*dy), d(pc, tc +2.0*dy), d(pc, tc +dx+2.0*dy), d(pc, tc+2.0*dx+2.0*dy))); + + dx = dx/TextureSize.xy; + dy = dy/TextureSize.xy; + tc = tc/TextureSize.xy; + + float3 c00 = tex2D(SurfaceTex, tc -dx -dy).xyz; + float3 c10 = tex2D(SurfaceTex, tc -dy).xyz; + float3 c20 = tex2D(SurfaceTex, tc +dx -dy).xyz; + float3 c30 = tex2D(SurfaceTex, tc+2.0*dx -dy).xyz; + float3 c01 = tex2D(SurfaceTex, tc -dx ).xyz; + float3 c11 = tex2D(SurfaceTex, tc ).xyz; + float3 c21 = tex2D(SurfaceTex, tc +dx ).xyz; + float3 c31 = tex2D(SurfaceTex, tc+2.0*dx ).xyz; + float3 c02 = tex2D(SurfaceTex, tc -dx +dy).xyz; + float3 c12 = tex2D(SurfaceTex, tc +dy).xyz; + float3 c22 = tex2D(SurfaceTex, tc +dx +dy).xyz; + float3 c32 = tex2D(SurfaceTex, tc+2.0*dx +dy).xyz; + float3 c03 = tex2D(SurfaceTex, tc -dx+2.0*dy).xyz; + float3 c13 = tex2D(SurfaceTex, tc +2.0*dy).xyz; + float3 c23 = tex2D(SurfaceTex, tc +dx+2.0*dy).xyz; + float3 c33 = tex2D(SurfaceTex, tc+2.0*dx+2.0*dy).xyz; + + color = tex2D(SurfaceTex, coord).xyz; + + // Get min/max samples + float3 min_sample = min4(c11, c21, c12, c22); + float3 max_sample = max4(c11, c21, c12, c22); + + color = float3(dot(weights[0], float4(c00.x, c10.x, c20.x, c30.x)), dot(weights[0], float4(c00.y, c10.y, c20.y, c30.y)), dot(weights[0], float4(c00.z, c10.z, c20.z, c30.z))); + color+= float3(dot(weights[1], float4(c01.x, c11.x, c21.x, c31.x)), dot(weights[1], float4(c01.y, c11.y, c21.y, c31.y)), dot(weights[1], float4(c01.z, c11.z, c21.z, c31.z))); + color+= float3(dot(weights[2], float4(c02.x, c12.x, c22.x, c32.x)), dot(weights[2], float4(c02.y, c12.y, c22.y, c32.y)), dot(weights[2], float4(c02.z, c12.z, c22.z, c32.z))); + color+= float3(dot(weights[3], float4(c03.x, c13.x, c23.x, c33.x)), dot(weights[3], float4(c03.y, c13.y, c23.y, c33.y)), dot(weights[3], float4(c03.z, c13.z, c23.z, c33.z))); + color = color/(dot(weights[0], float4(1,1,1,1)) + dot(weights[1], float4(1,1,1,1)) + dot(weights[2], float4(1,1,1,1)) + dot(weights[3], float4(1,1,1,1))); + + // Anti-ringing + float3 aux = color; + color = clamp(color, min_sample, max_sample); + color = lerp(aux, color, JINC2_AR_STRENGTH); + + // final sum and weight normalization + return float4(color, 1.0); +} + +float4 main(float2 texCoords : TEXCOORD) : COLOR +{ + return lanczos2(texCoords); +} + +*/ +#endif + +const BYTE D3D9_LANCZOS2_SHADER[] = + { + 0, 3, 255, 255, 254, 255, + 44, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 131, 0, + 0, 0, 0, 3, 255, 255, + 2, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 124, 0, 0, 0, 68, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 96, 0, 0, 0, 2, 0, + 0, 0, 1, 0, 2, 0, + 108, 0, 0, 0, 0, 0, + 0, 0, 83, 117, 114, 102, + 97, 99, 101, 84, 101, 120, + 0, 171, 4, 0, 12, 0, + 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 84, 101, 120, 116, 117, 114, + 101, 83, 105, 122, 101, 0, + 1, 0, 3, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 112, 115, + 95, 51, 95, 48, 0, 77, + 105, 99, 114, 111, 115, 111, + 102, 116, 32, 40, 82, 41, + 32, 72, 76, 83, 76, 32, + 83, 104, 97, 100, 101, 114, + 32, 67, 111, 109, 112, 105, + 108, 101, 114, 32, 49, 48, + 46, 49, 0, 171, 81, 0, + 0, 5, 1, 0, 15, 160, + 230, 233, 157, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 64, 81, 0, + 0, 5, 2, 0, 15, 160, + 0, 0, 128, 62, 0, 0, + 0, 63, 219, 15, 201, 64, + 219, 15, 73, 192, 81, 0, + 0, 5, 3, 0, 15, 160, + 0, 0, 0, 191, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 192, 63, 81, 0, + 0, 5, 4, 0, 15, 160, + 0, 0, 32, 64, 0, 0, + 0, 191, 0, 0, 192, 63, + 0, 0, 0, 63, 81, 0, + 0, 5, 5, 0, 15, 160, + 205, 204, 76, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 3, 144, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 1, 0, + 0, 2, 0, 0, 1, 128, + 3, 0, 0, 160, 4, 0, + 0, 4, 0, 0, 3, 128, + 0, 0, 228, 144, 0, 0, + 228, 160, 0, 0, 0, 128, + 19, 0, 0, 2, 0, 0, + 12, 128, 0, 0, 68, 128, + 2, 0, 0, 3, 0, 0, + 3, 128, 0, 0, 238, 129, + 0, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 12, 128, + 0, 0, 68, 128, 3, 0, + 0, 160, 4, 0, 0, 4, + 0, 0, 12, 128, 0, 0, + 68, 144, 0, 0, 68, 161, + 0, 0, 228, 128, 90, 0, + 0, 4, 0, 0, 4, 128, + 0, 0, 238, 128, 0, 0, + 238, 128, 3, 0, 170, 160, + 7, 0, 0, 2, 0, 0, + 4, 128, 0, 0, 170, 128, + 6, 0, 0, 2, 0, 0, + 4, 128, 0, 0, 170, 128, + 4, 0, 0, 4, 1, 0, + 3, 128, 0, 0, 170, 128, + 2, 0, 228, 160, 2, 0, + 85, 160, 19, 0, 0, 2, + 1, 0, 3, 128, 1, 0, + 228, 128, 4, 0, 0, 4, + 1, 0, 3, 128, 1, 0, + 228, 128, 2, 0, 170, 160, + 2, 0, 255, 160, 37, 0, + 0, 2, 2, 0, 2, 128, + 1, 0, 0, 128, 37, 0, + 0, 2, 3, 0, 2, 128, + 1, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 8, 128, + 2, 0, 85, 128, 3, 0, + 85, 128, 5, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 170, 128, 0, 0, 170, 128, + 6, 0, 0, 2, 1, 0, + 1, 128, 1, 0, 0, 128, + 5, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 255, 128, + 1, 0, 0, 128, 88, 0, + 0, 4, 1, 0, 1, 128, + 0, 0, 170, 129, 1, 0, + 0, 160, 0, 0, 255, 128, + 4, 0, 0, 4, 0, 0, + 12, 128, 0, 0, 68, 144, + 0, 0, 68, 161, 0, 0, + 68, 128, 2, 0, 0, 3, + 2, 0, 15, 128, 0, 0, + 68, 128, 3, 0, 84, 160, + 2, 0, 0, 3, 3, 0, + 15, 128, 0, 0, 238, 128, + 3, 0, 49, 160, 90, 0, + 0, 4, 0, 0, 1, 128, + 3, 0, 228, 128, 3, 0, + 228, 128, 3, 0, 170, 160, + 90, 0, 0, 4, 0, 0, + 2, 128, 3, 0, 238, 128, + 3, 0, 238, 128, 3, 0, + 170, 160, 7, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 7, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 6, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 4, 0, 0, 4, + 3, 0, 3, 128, 0, 0, + 0, 128, 2, 0, 228, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 3, 0, 3, 128, + 3, 0, 228, 128, 4, 0, + 0, 4, 3, 0, 3, 128, + 3, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 4, 0, + 2, 128, 3, 0, 0, 128, + 37, 0, 0, 2, 5, 0, + 2, 128, 3, 0, 85, 128, + 5, 0, 0, 3, 3, 0, + 1, 128, 4, 0, 85, 128, + 5, 0, 85, 128, 5, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 0, 128, 0, 0, + 0, 128, 6, 0, 0, 2, + 3, 0, 2, 128, 3, 0, + 85, 128, 5, 0, 0, 3, + 3, 0, 1, 128, 3, 0, + 85, 128, 3, 0, 0, 128, + 88, 0, 0, 4, 1, 0, + 2, 128, 0, 0, 0, 129, + 1, 0, 0, 160, 3, 0, + 0, 128, 4, 0, 0, 4, + 3, 0, 3, 128, 0, 0, + 85, 128, 2, 0, 228, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 3, 0, 3, 128, + 3, 0, 228, 128, 4, 0, + 0, 4, 3, 0, 3, 128, + 3, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 4, 0, + 2, 128, 3, 0, 0, 128, + 37, 0, 0, 2, 5, 0, + 2, 128, 3, 0, 85, 128, + 5, 0, 0, 3, 0, 0, + 1, 128, 4, 0, 85, 128, + 5, 0, 85, 128, 5, 0, + 0, 3, 3, 0, 1, 128, + 0, 0, 85, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 3, 0, 1, 128, 3, 0, + 0, 128, 5, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 3, 0, 0, 128, + 88, 0, 0, 4, 1, 0, + 4, 128, 0, 0, 85, 129, + 1, 0, 0, 160, 0, 0, + 0, 128, 2, 0, 0, 3, + 3, 0, 15, 128, 0, 0, + 238, 128, 4, 0, 228, 160, + 90, 0, 0, 4, 0, 0, + 1, 128, 3, 0, 228, 128, + 3, 0, 228, 128, 3, 0, + 170, 160, 90, 0, 0, 4, + 0, 0, 2, 128, 3, 0, + 238, 128, 3, 0, 238, 128, + 3, 0, 170, 160, 7, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 6, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 7, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 6, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 4, 0, + 0, 4, 3, 0, 3, 128, + 0, 0, 0, 128, 2, 0, + 228, 160, 2, 0, 85, 160, + 19, 0, 0, 2, 3, 0, + 3, 128, 3, 0, 228, 128, + 4, 0, 0, 4, 3, 0, + 3, 128, 3, 0, 228, 128, + 2, 0, 170, 160, 2, 0, + 255, 160, 37, 0, 0, 2, + 4, 0, 2, 128, 3, 0, + 0, 128, 37, 0, 0, 2, + 5, 0, 2, 128, 3, 0, + 85, 128, 5, 0, 0, 3, + 3, 0, 1, 128, 4, 0, + 85, 128, 5, 0, 85, 128, + 5, 0, 0, 3, 3, 0, + 2, 128, 0, 0, 0, 128, + 0, 0, 0, 128, 6, 0, + 0, 2, 3, 0, 2, 128, + 3, 0, 85, 128, 5, 0, + 0, 3, 3, 0, 1, 128, + 3, 0, 85, 128, 3, 0, + 0, 128, 88, 0, 0, 4, + 1, 0, 8, 128, 0, 0, + 0, 129, 1, 0, 0, 160, + 3, 0, 0, 128, 1, 0, + 0, 2, 3, 0, 2, 128, + 3, 0, 170, 160, 6, 0, + 0, 2, 4, 0, 1, 128, + 0, 0, 0, 160, 1, 0, + 0, 2, 3, 0, 1, 128, + 4, 0, 0, 128, 6, 0, + 0, 2, 4, 0, 2, 128, + 0, 0, 85, 160, 4, 0, + 0, 4, 3, 0, 12, 128, + 2, 0, 228, 128, 4, 0, + 68, 128, 3, 0, 68, 129, + 4, 0, 0, 4, 3, 0, + 3, 128, 2, 0, 238, 128, + 4, 0, 228, 128, 3, 0, + 228, 128, 4, 0, 0, 4, + 4, 0, 12, 128, 4, 0, + 68, 128, 1, 0, 148, 161, + 3, 0, 228, 128, 66, 0, + 0, 3, 5, 0, 15, 128, + 4, 0, 238, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 6, 0, 1, 128, 5, 0, + 0, 128, 4, 0, 0, 4, + 4, 0, 12, 128, 4, 0, + 68, 128, 1, 0, 148, 161, + 3, 0, 68, 128, 66, 0, + 0, 3, 7, 0, 15, 128, + 4, 0, 238, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 6, 0, 4, 128, 7, 0, + 0, 128, 5, 0, 0, 3, + 4, 0, 12, 128, 2, 0, + 228, 128, 4, 0, 68, 128, + 4, 0, 0, 4, 5, 0, + 9, 128, 4, 0, 100, 128, + 1, 0, 103, 160, 4, 0, + 230, 128, 66, 0, 0, 3, + 8, 0, 15, 128, 4, 0, + 238, 128, 0, 8, 228, 160, + 4, 0, 0, 4, 4, 0, + 12, 128, 4, 0, 68, 128, + 1, 0, 148, 161, 5, 0, + 196, 128, 66, 0, 0, 3, + 9, 0, 15, 128, 4, 0, + 238, 128, 0, 8, 228, 160, + 1, 0, 0, 2, 6, 0, + 8, 128, 9, 0, 0, 128, + 5, 0, 0, 3, 4, 0, + 12, 128, 4, 0, 68, 128, + 1, 0, 148, 160, 4, 0, + 0, 4, 9, 0, 9, 128, + 2, 0, 230, 128, 4, 0, + 100, 128, 4, 0, 230, 129, + 4, 0, 0, 4, 4, 0, + 12, 128, 2, 0, 228, 128, + 4, 0, 68, 128, 4, 0, + 228, 128, 66, 0, 0, 3, + 10, 0, 15, 128, 4, 0, + 238, 128, 0, 8, 228, 160, + 66, 0, 0, 3, 11, 0, + 15, 128, 9, 0, 236, 128, + 0, 8, 228, 160, 1, 0, + 0, 2, 6, 0, 2, 128, + 11, 0, 0, 128, 9, 0, + 0, 3, 6, 0, 1, 128, + 1, 0, 228, 128, 6, 0, + 228, 128, 1, 0, 0, 2, + 12, 0, 1, 128, 5, 0, + 85, 128, 1, 0, 0, 2, + 7, 0, 1, 128, 5, 0, + 170, 128, 1, 0, 0, 2, + 12, 0, 4, 128, 7, 0, + 85, 128, 1, 0, 0, 2, + 12, 0, 2, 128, 11, 0, + 85, 128, 1, 0, 0, 2, + 7, 0, 2, 128, 11, 0, + 170, 128, 1, 0, 0, 2, + 12, 0, 8, 128, 9, 0, + 85, 128, 1, 0, 0, 2, + 7, 0, 8, 128, 9, 0, + 170, 128, 9, 0, 0, 3, + 6, 0, 4, 128, 1, 0, + 228, 128, 7, 0, 228, 128, + 9, 0, 0, 3, 6, 0, + 2, 128, 1, 0, 228, 128, + 12, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 128, 1, 0, + 170, 160, 4, 0, 0, 4, + 1, 0, 15, 128, 0, 0, + 68, 144, 0, 0, 68, 161, + 2, 0, 228, 128, 90, 0, + 0, 4, 1, 0, 1, 128, + 1, 0, 228, 128, 1, 0, + 228, 128, 3, 0, 170, 160, + 90, 0, 0, 4, 1, 0, + 2, 128, 1, 0, 238, 128, + 1, 0, 238, 128, 3, 0, + 170, 160, 7, 0, 0, 2, + 1, 0, 2, 128, 1, 0, + 85, 128, 6, 0, 0, 2, + 1, 0, 2, 128, 1, 0, + 85, 128, 7, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 0, 128, 6, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 0, 128, 4, 0, 0, 4, + 1, 0, 12, 128, 1, 0, + 0, 128, 2, 0, 68, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 1, 0, 12, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 12, 128, + 1, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 7, 0, + 2, 128, 1, 0, 170, 128, + 37, 0, 0, 2, 9, 0, + 2, 128, 1, 0, 255, 128, + 5, 0, 0, 3, 1, 0, + 4, 128, 7, 0, 85, 128, + 9, 0, 85, 128, 5, 0, + 0, 3, 1, 0, 8, 128, + 1, 0, 0, 128, 1, 0, + 0, 128, 6, 0, 0, 2, + 1, 0, 8, 128, 1, 0, + 255, 128, 5, 0, 0, 3, + 1, 0, 4, 128, 1, 0, + 255, 128, 1, 0, 170, 128, + 88, 0, 0, 4, 7, 0, + 1, 128, 1, 0, 0, 129, + 1, 0, 0, 160, 1, 0, + 170, 128, 4, 0, 0, 4, + 1, 0, 5, 128, 1, 0, + 85, 128, 2, 0, 212, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 1, 0, 5, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 5, 128, + 1, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 9, 0, + 2, 128, 1, 0, 0, 128, + 37, 0, 0, 2, 11, 0, + 2, 128, 1, 0, 170, 128, + 5, 0, 0, 3, 1, 0, + 1, 128, 9, 0, 85, 128, + 11, 0, 85, 128, 5, 0, + 0, 3, 1, 0, 4, 128, + 1, 0, 85, 128, 1, 0, + 85, 128, 6, 0, 0, 2, + 1, 0, 4, 128, 1, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 170, 128, 1, 0, 0, 128, + 88, 0, 0, 4, 7, 0, + 2, 128, 1, 0, 85, 129, + 1, 0, 0, 160, 1, 0, + 0, 128, 4, 0, 0, 4, + 1, 0, 3, 128, 0, 0, + 85, 128, 2, 0, 228, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 1, 0, 3, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 3, 128, + 1, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 9, 0, + 2, 128, 1, 0, 0, 128, + 37, 0, 0, 2, 11, 0, + 2, 128, 1, 0, 85, 128, + 5, 0, 0, 3, 1, 0, + 1, 128, 9, 0, 85, 128, + 11, 0, 85, 128, 5, 0, + 0, 3, 1, 0, 2, 128, + 0, 0, 85, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 1, 0, 2, 128, 1, 0, + 85, 128, 5, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 85, 128, 1, 0, 0, 128, + 88, 0, 0, 4, 7, 0, + 4, 128, 0, 0, 85, 129, + 1, 0, 0, 160, 1, 0, + 0, 128, 2, 0, 0, 3, + 1, 0, 15, 128, 0, 0, + 238, 128, 4, 0, 156, 160, + 90, 0, 0, 4, 0, 0, + 2, 128, 1, 0, 228, 128, + 1, 0, 228, 128, 3, 0, + 170, 160, 90, 0, 0, 4, + 1, 0, 1, 128, 1, 0, + 238, 128, 1, 0, 238, 128, + 3, 0, 170, 160, 7, 0, + 0, 2, 1, 0, 1, 128, + 1, 0, 0, 128, 6, 0, + 0, 2, 1, 0, 1, 128, + 1, 0, 0, 128, 7, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 6, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 4, 0, + 0, 4, 1, 0, 6, 128, + 0, 0, 85, 128, 2, 0, + 208, 160, 2, 0, 85, 160, + 19, 0, 0, 2, 1, 0, + 6, 128, 1, 0, 228, 128, + 4, 0, 0, 4, 1, 0, + 6, 128, 1, 0, 228, 128, + 2, 0, 170, 160, 2, 0, + 255, 160, 37, 0, 0, 2, + 9, 0, 2, 128, 1, 0, + 85, 128, 37, 0, 0, 2, + 11, 0, 2, 128, 1, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 2, 128, 9, 0, + 85, 128, 11, 0, 85, 128, + 5, 0, 0, 3, 1, 0, + 4, 128, 0, 0, 85, 128, + 0, 0, 85, 128, 6, 0, + 0, 2, 1, 0, 4, 128, + 1, 0, 170, 128, 5, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 170, 128, 1, 0, + 85, 128, 88, 0, 0, 4, + 7, 0, 8, 128, 0, 0, + 85, 129, 1, 0, 0, 160, + 1, 0, 85, 128, 66, 0, + 0, 3, 9, 0, 15, 128, + 3, 0, 238, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 11, 0, 1, 128, 9, 0, + 0, 128, 66, 0, 0, 3, + 12, 0, 15, 128, 3, 0, + 228, 128, 0, 8, 228, 160, + 1, 0, 0, 2, 11, 0, + 4, 128, 12, 0, 0, 128, + 66, 0, 0, 3, 13, 0, + 15, 128, 5, 0, 236, 128, + 0, 8, 228, 160, 1, 0, + 0, 2, 11, 0, 8, 128, + 13, 0, 0, 128, 1, 0, + 0, 2, 11, 0, 2, 128, + 8, 0, 0, 128, 9, 0, + 0, 3, 11, 0, 1, 128, + 7, 0, 228, 128, 11, 0, + 228, 128, 1, 0, 0, 2, + 14, 0, 1, 128, 9, 0, + 85, 128, 1, 0, 0, 2, + 9, 0, 1, 128, 9, 0, + 170, 128, 1, 0, 0, 2, + 14, 0, 8, 128, 13, 0, + 85, 128, 1, 0, 0, 2, + 9, 0, 8, 128, 13, 0, + 170, 128, 1, 0, 0, 2, + 14, 0, 4, 128, 12, 0, + 85, 128, 1, 0, 0, 2, + 14, 0, 2, 128, 8, 0, + 85, 128, 9, 0, 0, 3, + 11, 0, 2, 128, 7, 0, + 228, 128, 14, 0, 228, 128, + 1, 0, 0, 2, 9, 0, + 4, 128, 12, 0, 170, 128, + 1, 0, 0, 2, 9, 0, + 2, 128, 8, 0, 170, 128, + 9, 0, 0, 3, 11, 0, + 4, 128, 7, 0, 228, 128, + 9, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 2, 128, + 7, 0, 228, 128, 1, 0, + 170, 160, 2, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 85, 128, 0, 0, 0, 128, + 2, 0, 0, 3, 1, 0, + 14, 128, 6, 0, 144, 128, + 11, 0, 144, 128, 4, 0, + 0, 4, 2, 0, 3, 128, + 1, 0, 0, 128, 2, 0, + 228, 160, 2, 0, 85, 160, + 19, 0, 0, 2, 2, 0, + 3, 128, 2, 0, 228, 128, + 4, 0, 0, 4, 2, 0, + 3, 128, 2, 0, 228, 128, + 2, 0, 170, 160, 2, 0, + 255, 160, 37, 0, 0, 2, + 6, 0, 2, 128, 2, 0, + 0, 128, 37, 0, 0, 2, + 7, 0, 2, 128, 2, 0, + 85, 128, 5, 0, 0, 3, + 0, 0, 2, 128, 6, 0, + 85, 128, 7, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 1, 128, 1, 0, 0, 128, + 1, 0, 0, 128, 6, 0, + 0, 2, 2, 0, 1, 128, + 2, 0, 0, 128, 5, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 85, 128, 2, 0, + 0, 128, 88, 0, 0, 4, + 6, 0, 1, 128, 1, 0, + 0, 129, 1, 0, 0, 160, + 0, 0, 85, 128, 2, 0, + 0, 3, 7, 0, 15, 128, + 0, 0, 238, 128, 3, 0, + 253, 160, 90, 0, 0, 4, + 0, 0, 2, 128, 7, 0, + 228, 128, 7, 0, 228, 128, + 3, 0, 170, 160, 90, 0, + 0, 4, 1, 0, 1, 128, + 7, 0, 238, 128, 7, 0, + 238, 128, 3, 0, 170, 160, + 7, 0, 0, 2, 1, 0, + 1, 128, 1, 0, 0, 128, + 6, 0, 0, 2, 1, 0, + 1, 128, 1, 0, 0, 128, + 7, 0, 0, 2, 0, 0, + 2, 128, 0, 0, 85, 128, + 6, 0, 0, 2, 0, 0, + 2, 128, 0, 0, 85, 128, + 4, 0, 0, 4, 2, 0, + 3, 128, 0, 0, 85, 128, + 2, 0, 228, 160, 2, 0, + 85, 160, 19, 0, 0, 2, + 2, 0, 3, 128, 2, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 2, 0, + 228, 128, 2, 0, 170, 160, + 2, 0, 255, 160, 37, 0, + 0, 2, 7, 0, 2, 128, + 2, 0, 0, 128, 37, 0, + 0, 2, 9, 0, 2, 128, + 2, 0, 85, 128, 5, 0, + 0, 3, 2, 0, 1, 128, + 7, 0, 85, 128, 9, 0, + 85, 128, 5, 0, 0, 3, + 2, 0, 2, 128, 0, 0, + 85, 128, 0, 0, 85, 128, + 6, 0, 0, 2, 2, 0, + 2, 128, 2, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 1, 128, 2, 0, 85, 128, + 2, 0, 0, 128, 88, 0, + 0, 4, 6, 0, 2, 128, + 0, 0, 85, 129, 1, 0, + 0, 160, 2, 0, 0, 128, + 4, 0, 0, 4, 2, 0, + 3, 128, 1, 0, 0, 128, + 2, 0, 228, 160, 2, 0, + 85, 160, 19, 0, 0, 2, + 2, 0, 3, 128, 2, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 2, 0, + 228, 128, 2, 0, 170, 160, + 2, 0, 255, 160, 37, 0, + 0, 2, 7, 0, 2, 128, + 2, 0, 0, 128, 37, 0, + 0, 2, 9, 0, 2, 128, + 2, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 2, 128, + 7, 0, 85, 128, 9, 0, + 85, 128, 5, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 0, 128, 1, 0, 0, 128, + 6, 0, 0, 2, 2, 0, + 1, 128, 2, 0, 0, 128, + 5, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 85, 128, + 2, 0, 0, 128, 88, 0, + 0, 4, 6, 0, 4, 128, + 1, 0, 0, 129, 1, 0, + 0, 160, 0, 0, 85, 128, + 2, 0, 0, 3, 7, 0, + 15, 128, 0, 0, 238, 128, + 4, 0, 24, 160, 90, 0, + 0, 4, 0, 0, 2, 128, + 7, 0, 228, 128, 7, 0, + 228, 128, 3, 0, 170, 160, + 90, 0, 0, 4, 1, 0, + 1, 128, 7, 0, 238, 128, + 7, 0, 238, 128, 3, 0, + 170, 160, 7, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 0, 128, 6, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 0, 128, 7, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 0, 0, + 85, 128, 2, 0, 228, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 2, 0, 3, 128, + 2, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 3, 128, + 2, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 7, 0, + 2, 128, 2, 0, 0, 128, + 37, 0, 0, 2, 9, 0, + 2, 128, 2, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 1, 128, 7, 0, 85, 128, + 9, 0, 85, 128, 5, 0, + 0, 3, 2, 0, 2, 128, + 0, 0, 85, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 2, 0, 2, 128, 2, 0, + 85, 128, 5, 0, 0, 3, + 2, 0, 1, 128, 2, 0, + 85, 128, 2, 0, 0, 128, + 88, 0, 0, 4, 6, 0, + 8, 128, 0, 0, 85, 129, + 1, 0, 0, 160, 2, 0, + 0, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 4, 0, + 228, 128, 1, 0, 233, 160, + 3, 0, 238, 128, 4, 0, + 0, 4, 3, 0, 12, 128, + 4, 0, 68, 128, 1, 0, + 212, 160, 3, 0, 228, 128, + 66, 0, 0, 3, 7, 0, + 15, 128, 3, 0, 238, 128, + 0, 8, 228, 160, 66, 0, + 0, 3, 9, 0, 15, 128, + 2, 0, 228, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 11, 0, 1, 128, 9, 0, + 0, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 4, 0, + 228, 128, 1, 0, 233, 160, + 5, 0, 236, 128, 4, 0, + 0, 4, 3, 0, 12, 128, + 4, 0, 68, 128, 1, 0, + 212, 160, 5, 0, 196, 128, + 66, 0, 0, 3, 5, 0, + 15, 128, 3, 0, 238, 128, + 0, 8, 228, 160, 66, 0, + 0, 3, 13, 0, 15, 128, + 2, 0, 228, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 11, 0, 8, 128, 13, 0, + 0, 128, 4, 0, 0, 4, + 2, 0, 3, 128, 4, 0, + 228, 128, 1, 0, 233, 160, + 3, 0, 228, 128, 4, 0, + 0, 4, 3, 0, 3, 128, + 4, 0, 228, 128, 1, 0, + 237, 160, 3, 0, 228, 128, + 66, 0, 0, 3, 3, 0, + 15, 128, 3, 0, 228, 128, + 0, 8, 228, 160, 66, 0, + 0, 3, 14, 0, 15, 128, + 2, 0, 228, 128, 0, 8, + 228, 160, 1, 0, 0, 2, + 11, 0, 4, 128, 14, 0, + 0, 128, 1, 0, 0, 2, + 11, 0, 2, 128, 10, 0, + 0, 128, 9, 0, 0, 3, + 11, 0, 1, 128, 6, 0, + 228, 128, 11, 0, 228, 128, + 1, 0, 0, 2, 15, 0, + 1, 128, 9, 0, 85, 128, + 1, 0, 0, 2, 9, 0, + 1, 128, 9, 0, 170, 128, + 1, 0, 0, 2, 15, 0, + 8, 128, 13, 0, 85, 128, + 1, 0, 0, 2, 9, 0, + 8, 128, 13, 0, 170, 128, + 1, 0, 0, 2, 15, 0, + 4, 128, 14, 0, 85, 128, + 1, 0, 0, 2, 15, 0, + 2, 128, 10, 0, 85, 128, + 9, 0, 0, 3, 11, 0, + 2, 128, 6, 0, 228, 128, + 15, 0, 228, 128, 1, 0, + 0, 2, 9, 0, 4, 128, + 14, 0, 170, 128, 1, 0, + 0, 2, 9, 0, 2, 128, + 10, 0, 170, 128, 9, 0, + 0, 3, 11, 0, 4, 128, + 6, 0, 228, 128, 9, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 6, 0, + 228, 128, 1, 0, 170, 160, + 2, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 85, 128, + 0, 0, 0, 128, 2, 0, + 0, 3, 1, 0, 14, 128, + 1, 0, 228, 128, 11, 0, + 144, 128, 5, 0, 0, 3, + 2, 0, 3, 128, 4, 0, + 228, 128, 1, 0, 237, 160, + 4, 0, 0, 4, 2, 0, + 3, 128, 2, 0, 238, 128, + 4, 0, 228, 128, 2, 0, + 228, 128, 66, 0, 0, 3, + 2, 0, 15, 128, 2, 0, + 228, 128, 0, 8, 228, 160, + 1, 0, 0, 2, 4, 0, + 2, 128, 2, 0, 0, 128, + 4, 0, 0, 4, 2, 0, + 9, 128, 1, 0, 0, 128, + 2, 0, 100, 160, 2, 0, + 85, 160, 19, 0, 0, 2, + 2, 0, 9, 128, 2, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 9, 128, 2, 0, + 228, 128, 2, 0, 170, 160, + 2, 0, 255, 160, 37, 0, + 0, 2, 6, 0, 2, 128, + 2, 0, 0, 128, 37, 0, + 0, 2, 9, 0, 2, 128, + 2, 0, 255, 128, 5, 0, + 0, 3, 0, 0, 2, 128, + 6, 0, 85, 128, 9, 0, + 85, 128, 5, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 0, 128, 1, 0, 0, 128, + 6, 0, 0, 2, 2, 0, + 1, 128, 2, 0, 0, 128, + 5, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 85, 128, + 2, 0, 0, 128, 88, 0, + 0, 4, 6, 0, 1, 128, + 1, 0, 0, 129, 1, 0, + 0, 160, 0, 0, 85, 128, + 2, 0, 0, 3, 2, 0, + 9, 128, 0, 0, 230, 128, + 4, 0, 0, 160, 2, 0, + 0, 3, 9, 0, 15, 128, + 0, 0, 238, 128, 4, 0, + 35, 160, 90, 0, 0, 4, + 0, 0, 2, 128, 2, 0, + 236, 128, 2, 0, 236, 128, + 3, 0, 170, 160, 7, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 6, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 4, 0, + 0, 4, 0, 0, 12, 128, + 0, 0, 85, 128, 2, 0, + 68, 160, 2, 0, 85, 160, + 19, 0, 0, 2, 0, 0, + 12, 128, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 12, 128, 0, 0, 228, 128, + 2, 0, 170, 160, 2, 0, + 255, 160, 37, 0, 0, 2, + 11, 0, 2, 128, 0, 0, + 170, 128, 37, 0, 0, 2, + 13, 0, 2, 128, 0, 0, + 255, 128, 5, 0, 0, 3, + 0, 0, 4, 128, 11, 0, + 85, 128, 13, 0, 85, 128, + 5, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 85, 128, + 0, 0, 85, 128, 6, 0, + 0, 2, 0, 0, 8, 128, + 0, 0, 255, 128, 5, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 255, 128, 0, 0, + 170, 128, 88, 0, 0, 4, + 6, 0, 8, 128, 0, 0, + 85, 129, 1, 0, 0, 160, + 0, 0, 170, 128, 90, 0, + 0, 4, 0, 0, 2, 128, + 9, 0, 228, 128, 9, 0, + 228, 128, 3, 0, 170, 160, + 90, 0, 0, 4, 0, 0, + 4, 128, 9, 0, 238, 128, + 9, 0, 238, 128, 3, 0, + 170, 160, 7, 0, 0, 2, + 0, 0, 4, 128, 0, 0, + 170, 128, 6, 0, 0, 2, + 0, 0, 4, 128, 0, 0, + 170, 128, 7, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 4, 0, 0, 4, + 2, 0, 9, 128, 0, 0, + 85, 128, 2, 0, 100, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 2, 0, 9, 128, + 2, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 9, 128, + 2, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 9, 0, + 2, 128, 2, 0, 0, 128, + 37, 0, 0, 2, 11, 0, + 2, 128, 2, 0, 255, 128, + 5, 0, 0, 3, 0, 0, + 8, 128, 9, 0, 85, 128, + 11, 0, 85, 128, 5, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 85, 128, 0, 0, + 85, 128, 6, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 0, 128, 5, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 255, 128, 1, 0, 0, 128, + 88, 0, 0, 4, 6, 0, + 2, 128, 0, 0, 85, 129, + 1, 0, 0, 160, 0, 0, + 255, 128, 4, 0, 0, 4, + 0, 0, 10, 128, 0, 0, + 170, 128, 2, 0, 96, 160, + 2, 0, 85, 160, 19, 0, + 0, 2, 0, 0, 10, 128, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 10, 128, + 0, 0, 228, 128, 2, 0, + 170, 160, 2, 0, 255, 160, + 37, 0, 0, 2, 9, 0, + 2, 128, 0, 0, 85, 128, + 37, 0, 0, 2, 11, 0, + 2, 128, 0, 0, 255, 128, + 5, 0, 0, 3, 0, 0, + 2, 128, 9, 0, 85, 128, + 11, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 8, 128, + 0, 0, 170, 128, 0, 0, + 170, 128, 6, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 128, 5, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 255, 128, 0, 0, 85, 128, + 88, 0, 0, 4, 6, 0, + 4, 128, 0, 0, 170, 129, + 1, 0, 0, 160, 0, 0, + 85, 128, 1, 0, 0, 2, + 4, 0, 1, 128, 7, 0, + 0, 128, 1, 0, 0, 2, + 4, 0, 4, 128, 3, 0, + 0, 128, 1, 0, 0, 2, + 4, 0, 8, 128, 5, 0, + 0, 128, 9, 0, 0, 3, + 4, 0, 1, 128, 6, 0, + 228, 128, 4, 0, 228, 128, + 1, 0, 0, 2, 9, 0, + 1, 128, 7, 0, 85, 128, + 1, 0, 0, 2, 3, 0, + 1, 128, 7, 0, 170, 128, + 1, 0, 0, 2, 9, 0, + 4, 128, 3, 0, 85, 128, + 1, 0, 0, 2, 9, 0, + 8, 128, 5, 0, 85, 128, + 1, 0, 0, 2, 3, 0, + 8, 128, 5, 0, 170, 128, + 1, 0, 0, 2, 9, 0, + 2, 128, 2, 0, 85, 128, + 1, 0, 0, 2, 3, 0, + 2, 128, 2, 0, 170, 128, + 9, 0, 0, 3, 4, 0, + 4, 128, 6, 0, 228, 128, + 3, 0, 228, 128, 9, 0, + 0, 3, 4, 0, 2, 128, + 6, 0, 228, 128, 9, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 6, 0, + 228, 128, 1, 0, 170, 160, + 2, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 85, 128, + 0, 0, 0, 128, 6, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 2, 0, + 0, 3, 0, 0, 14, 128, + 1, 0, 228, 128, 4, 0, + 144, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 0, 0, + 0, 128, 0, 0, 249, 128, + 10, 0, 0, 3, 2, 0, + 7, 128, 14, 0, 228, 128, + 10, 0, 228, 128, 11, 0, + 0, 3, 3, 0, 7, 128, + 10, 0, 228, 128, 14, 0, + 228, 128, 11, 0, 0, 3, + 4, 0, 7, 128, 12, 0, + 228, 128, 3, 0, 228, 128, + 10, 0, 0, 3, 3, 0, + 7, 128, 2, 0, 228, 128, + 12, 0, 228, 128, 10, 0, + 0, 3, 2, 0, 7, 128, + 3, 0, 228, 128, 8, 0, + 228, 128, 11, 0, 0, 3, + 3, 0, 7, 128, 8, 0, + 228, 128, 4, 0, 228, 128, + 11, 0, 0, 3, 4, 0, + 7, 128, 1, 0, 228, 128, + 2, 0, 228, 128, 10, 0, + 0, 3, 2, 0, 7, 128, + 3, 0, 228, 128, 4, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 249, 128, 0, 0, 0, 129, + 2, 0, 228, 128, 4, 0, + 0, 4, 0, 8, 7, 128, + 0, 0, 228, 128, 5, 0, + 0, 160, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 8, 128, 1, 0, 170, 160, + 255, 255, 0, 0 + }; + + + #endif diff --git a/inc/dd.h b/inc/dd.h index bfddd0a..e8a96aa 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -39,6 +39,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute #define FILTER_NEAREST 0 #define FILTER_LINEAR 1 #define FILTER_CUBIC 2 +#define FILTER_LANCZOS 3 #define SDM_MODE_SET_BY_GAME 0x00000001l #define SDM_LEAVE_WINDOWED 0x00000002l diff --git a/src/config.c b/src/config.c index 0215716..7e185c9 100644 --- a/src/config.c +++ b/src/config.c @@ -298,7 +298,7 @@ static void cfg_create_ini() "resizable=true\n" "\n" "; Upscaling filter for the direct3d9* renderers\n" - "; Possible values: 0 = nearest-neighbor, 1 = bilinear, 2 = bicubic (16/32bit color depth games only)\n" + "; Possible values: 0 = nearest-neighbor, 1 = bilinear, 2 = bicubic, 3 = lanczos (bicubic/lanczos only support 16/32bit color depth games)\n" "d3d9_filter=2\n" "\n" "; Enable upscale hack for high resolution patches (Supports C&C1, Red Alert 1 and KKND Xtreme)\n" diff --git a/src/render_d3d9.c b/src/render_d3d9.c index 29c0c26..8e8ebcd 100644 --- a/src/render_d3d9.c +++ b/src/render_d3d9.c @@ -318,10 +318,27 @@ static BOOL d3d9_create_resources() } else { - IDirect3DDevice9_CreatePixelShader( - g_d3d9.device, - (DWORD*)D3D9_CATMULL_ROM_SHADER, - &g_d3d9.pixel_shader_upscale); + if (g_ddraw->d3d9_filter == FILTER_LANCZOS) + { + BOOL error = FAILED( + IDirect3DDevice9_CreatePixelShader( + g_d3d9.device, + (DWORD*)D3D9_LANCZOS2_SHADER, + &g_d3d9.pixel_shader_upscale)); + + if (error || !g_d3d9.pixel_shader_upscale) + { + g_ddraw->d3d9_filter = FILTER_CUBIC; + } + } + + if (g_ddraw->d3d9_filter == FILTER_CUBIC) + { + IDirect3DDevice9_CreatePixelShader( + g_d3d9.device, + (DWORD*)D3D9_CATMULL_ROM_SHADER, + &g_d3d9.pixel_shader_upscale); + } } return g_d3d9.vertex_buf && (g_d3d9.pixel_shader || g_ddraw->bpp == 16 || g_ddraw->bpp == 32) && !err; @@ -359,11 +376,22 @@ static BOOL d3d9_set_states() { if (g_ddraw->d3d9_filter) { - if (SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)) && + if (g_ddraw->d3d9_filter == FILTER_LANCZOS && + g_d3d9.pixel_shader_upscale && + (g_ddraw->render.viewport.width != g_ddraw->width || + g_ddraw->render.viewport.height != g_ddraw->height) && + SUCCEEDED(IDirect3DDevice9_SetPixelShader(g_d3d9.device, g_d3d9.pixel_shader_upscale))) + { + float texture_size[4] = { (float)g_d3d9.tex_width, (float)g_d3d9.tex_height, 0, 0 }; + err = err || FAILED(IDirect3DDevice9_SetPixelShaderConstantF(g_d3d9.device, 0, texture_size, 1)); + } + else if ( + SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)) && SUCCEEDED(IDirect3DDevice9_SetSamplerState(g_d3d9.device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR)) && g_ddraw->d3d9_filter == FILTER_CUBIC && g_d3d9.pixel_shader_upscale && - (g_ddraw->render.viewport.width != g_ddraw->width || g_ddraw->render.viewport.height != g_ddraw->height) && + (g_ddraw->render.viewport.width != g_ddraw->width || + g_ddraw->render.viewport.height != g_ddraw->height) && SUCCEEDED(IDirect3DDevice9_SetPixelShader(g_d3d9.device, g_d3d9.pixel_shader_upscale))) { float texture_size[4] = { (float)g_d3d9.tex_width, (float)g_d3d9.tex_height, 0, 0 };