//Geometry VS. Haunted Castle.
// ---- Created with 3Dmigoto v0.6.181 on Tue Aug 27 21:42:51 2024

cbuffer _Globals : register(b0)
{
  float4x4 modelViewProj : packoffset(c0);
}



// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main(
  float2 v0 : POSITION0,
  float4 v1 : COLOR0,
  float2 v2 : TEXCOORD0,
  out float4 o0 : SV_Position0,
  out float4 o1 : COLOR0,
  out float2 o2 : TEXCOORD0)
{
  float4 r0;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  float4 iniparams3 = IniParams.Load(int2(3,0));
  float4 iniparams10 = IniParams.Load(int2(10,0));
  
  r0.xy = v0.xy;
  r0.z = 1;
  o0.x = dot(r0.xyz, modelViewProj._m00_m10_m30);
  o0.y = dot(r0.xyz, modelViewProj._m01_m11_m31);
  o0.z = dot(r0.xyz, modelViewProj._m02_m12_m32);
  o0.w = dot(r0.xyz, modelViewProj._m03_m13_m33);
  
  //o0.x+=stereo.x*(o0.w+stereo.y/o0.z);
  
//  if (o0.w==1 && iniparams10.x==1) {
//    //o0.x+=stereo.x*(o0.w)*0.3;
//	//o0.x+=stereo.x*(o0.w-stereo.y*-1*(o0.z-1));
//	//o0.x+=stereo.x*(o0.w-stereo.y*-0.625*(o0.z-1));
//	//o0.x+=stereo.x*(o0.w-stereo.y*-3*(o0.z-0.85));
//	o0.x+=stereo.x*(o0.w+stereo.y-stereo.y*0.5/(o0.z));
//  } else if (o0.w==1 && iniparams10.x==2) {
//    if (iniparams3.w==14) {
//	  o0.x+=stereo.x*o0.w;
//	} else if (iniparams3.w==16) {
//	  o0.x+=stereo.x*(o0.w-stereo.y*-1*(o0.z-0.825));
//	} else if (iniparams3.w==16.1 && v2.y<0.75) {
//	  //o0.x+=stereo.x*(o0.w-stereo.y*-1*(o0.z-0.825));
//	} else if (iniparams3.w==17) {
//	  o0.x+=stereo.x*(o0.w-stereo.y*-2*(o0.z-0.825));
//	} else {
//      o0.x+=stereo.x*(o0.w-stereo.y*-4*(o0.z-0.825));
//	}
//  }
	
	float scaling = iniparams3.w-30.0;
	if (iniparams3.w>=30.0 && iniparams3.w<40.0) {
	  o0.x+=stereo.x*(o0.w-stereo.y*-scaling*(o0.z-0.825));
	}
	
	//Title screen.
	if (iniparams3.w==101) {
	  float tsScaling = 0.3125;
	  float tsSky = v2.x>=(0.0/1024.0) && v2.x<(435.0/1024.0) && v2.y>=(0.0/512.0) && v2.y<(243.0/512.0);
	  float tsClouds = v2.x>=(0.0/1024.0) && v2.x<(429.0/1024.0) && v2.y>=(243.0/512.0) && v2.y<(389.0/512.0);
	  float tsDracula = v2.x>=(757.0/1024.0) && v2.x<(964.0/1024.0) && v2.y>=(343.0/512.0) && v2.y<(503.0/512.0);
	  float tsCastle = v2.x>=(435.0/1024.0) && v2.x<(757.0/1024.0) && v2.y>=(173.0/512.0) && v2.y<(373.0/512.0);
	  float tsRocks = v2.x>=(435.0/1024.0) && v2.x<(869.0/1024.0) && v2.y>=(0.0/512.0) && v2.y<(173.0/512.0);
	  float tsSimon = v2.x>=(757.0/1024.0) && v2.x<(982.0/1024.0) && v2.y>=(173.0/512.0) && v2.y<(344.0/512.0);
	  if (tsSky) {
	    tsScaling = 0.0;
	  }
	  if (tsClouds) {
	    tsScaling = 0.1;
	  }
	  if (tsDracula) {
	    tsScaling = 0.125;
	  }
	  if (tsCastle) {
	    tsScaling = 0.15;
	  }
	  if (tsRocks) {
	    tsScaling = 0.25;
	  }
	  if (tsSimon) {
	    tsScaling = 0.28;
	  }
	  o0.x+=stereo.x*(o0.w-stereo.y*-tsScaling*(o0.z-0.825));
	}
	
	//Stage 6 background.
	if (iniparams3.w==102) {
	  float tsScaling = 0.175;
	  float tsSky1 = v2.x>=(674.0/2048.0) && v2.x<(1109.0/2048.0) && v2.y>=(195.0/1024.0) && v2.y<(444.0/1024.0);
	  float tsSky2 = v2.x>=(1139.0/2048.0) && v2.x<(2007.0/2048.0) && v2.y>=(243.0/1024.0) && v2.y<(485.0/1024.0);
	  float tsFarMountain = v2.x>=(675.0/2048.0) && v2.x<(997.0/2048.0) && v2.y>=(443.0/1024.0) && v2.y<(542.0/1024.0);
	  float tsCloseMountain = v2.x>=(0.0/2048.0) && v2.x<(1139.0/2048.0) && v2.y>=(0.0/1024.0) && v2.y<(195.0/1024.0);
	  //float tsCloserMountain = v2.x>=(0.0/2048.0) && v2.x<(586.0/2048.0) && v2.y>=(385.0/1024.0) && v2.y<(461.0/1024.0);
	  
	  if (tsSky1) {
	    tsScaling = 0.0;
	  }
	  if (tsSky2) {
	    tsScaling = 0.0;
	  }
	  if (tsFarMountain) {
	    tsScaling = 0.1;
	  }
	  if (tsCloseMountain) {
	    tsScaling = 0.15;
	  }
	  //if (tsCloserMountain) {
	  //  tsScaling = 0.2;
	  //}
	  o0.x+=stereo.x*(o0.w-stereo.y*-tsScaling*(o0.z-0.825));
	}
	
	//Stage 6 epilogue.
	if (iniparams3.w==103) {
	  float tsScaling = 0.12;
	  float tsSky1 = v2.x>=(0.0/2048.0) && v2.x<(867.0/2048.0) && v2.y>=(0.0/1024.0) && v2.y<(243.0/1024.0);
	  float tsFarMountain = v2.x>=(867.0/2048.0) && v2.x<(1509.0/2048.0) && v2.y>=(195.0/1024.0) && v2.y<(355.0/1024.0);
	  float tsFarMountain2 = v2.x>=(867.0/2048.0) && v2.x<(1469.0/2048.0) && v2.y>=(485.0/1024.0) && v2.y<(655.0/1024.0);
	  float tsCastle = v2.x>=(0.0/2048.0) && v2.x<(500.0/2048.0) && v2.y>=(459.0/1024.0) && v2.y<(732.0/1024.0);
	  float tsWoman = v2.x>=(1943.0/2048.0) && v2.x<(2049.0/2048.0) && v2.y>=(195.0/1024.0) && v2.y<(1025.0/1024.0);
	  float tsWomanCrown = v2.x>=(1622.0/2048.0) && v2.x<(1634.0/2048.0) && v2.y>=(164.0/1024.0) && v2.y<(183.0/1024.0);
	  float tsSimon1 = v2.x>=(519.0/2048.0) && v2.x<(828.0/2048.0) && v2.y>=(243.0/1024.0) && v2.y<(581.0/1024.0);
	  float tsSimon2 = v2.x>=(1509.0/2048.0) && v2.x<(2049.0/2048.0) && v2.y>=(382.0/1024.0) && v2.y<(551.0/1024.0);
	  float tsSimon3 = v2.x>=(737.0/2048.0) && v2.x<(805.0/2048.0) && v2.y>=(581.0/1024.0) && v2.y<(688.0/1024.0);
	  float tsSimon4 = v2.x>=(333.0/2048.0) && v2.x<(500.0/2048.0) && v2.y>=(459.0/1024.0) && v2.y<(607.0/1024.0);
	  float tsSimon5 = v2.x>=(171.0/2048.0) && v2.x<(234.0/2048.0) && v2.y>=(582.0/1024.0) && v2.y<(732.0/1024.0);
	  if (tsSky1) {
	    tsScaling = 0.0;
	  }
	  if (tsFarMountain) {
	    tsScaling = 0.0625;
	  }
	  if (tsFarMountain2) {
	    tsScaling = 0.1;
	  }
	  if (tsCastle) {
	    tsScaling = 0.112;
	  }
	  if (tsWoman || tsWomanCrown) {
	    tsScaling = 0.28;
	  }
	  if (tsSimon1 || tsSimon2 || tsSimon3 || tsSimon4 || tsSimon5) {
	    tsScaling = 0.29;
	  }
	  o0.x+=stereo.x*(o0.w-stereo.y*-tsScaling*(o0.z-0.825));
	}
	
	//Stage 1 intro.
	if (iniparams3.w==104) {
	  float tsScaling = 0.13;
	  float tsSky1 = v2.x>=(3444.0/4096.0) && v2.x<(3835.0/4096.0) && v2.y>=(2167.0/4096.0) && v2.y<(2349.0/4096.0);
	  float tsSky2 = v2.x>=(2887.0/4096.0) && v2.x<(3667.0/4096.0) && v2.y>=(2630.0/4096.0) && v2.y<(2826.0/4096.0);
	  float tsFarMountain1 = v2.x>=(2887.0/4096.0) && v2.x<(3264.0/4096.0) && v2.y>=(2826.0/4096.0) && v2.y<(2972.0/4096.0);
	  float tsFarMountain2 = v2.x>=(3264.0/4096.0) && v2.x<(3612.0/4096.0) && v2.y>=(2826.0/4096.0) && v2.y<(2939.0/4096.0);
	  float tsMiddleMountain1 = v2.x>=(3444.0/4096.0) && v2.x<(3835.0/4096.0) && v2.y>=(2349.0/4096.0) && v2.y<(2523.0/4096.0);
	  float tsChurch1 = v2.x>=(3667.0/4096.0) && v2.x<(4058.0/4096.0) && v2.y>=(2630.0/4096.0) && v2.y<(2922.0/4096.0);
	  if (tsSky1 || tsSky2) {
	    tsScaling = 0.0;
	  }
	  if (tsFarMountain1) {
	    tsScaling = 0.03;
	  }
	  if (tsFarMountain2) {
	    tsScaling = 0.05;
	  }
	  if (tsMiddleMountain1) {
	    tsScaling = 0.09;
	  }
	  if (tsChurch1) {
	    tsScaling = 0.1;
	  }
	  o0.x+=stereo.x*(o0.w-stereo.y*-tsScaling*(o0.z-0.825));
	}
	
	//Stage 1 sky.
	if (iniparams3.w==105) {
	  float tsScaling = 0.0625;
	  float tsSky1 = v2.x>=(0.0/4096.0) && v2.x<(4097.0/4096.0) && v2.y>=(0.0/4096.0) && v2.y<(243.0/4096.0);
	  if (tsSky1) {
	    tsScaling = 0.0;
	  }
	  o0.x+=stereo.x*(o0.w-stereo.y*-tsScaling*(o0.z-0.825));
	}
	
	//if (iniparams3.w==106) {
	//  o0=0;
	//}
  
  o1.xyzw = v1.xyzw;
  o2.xy = v2.xy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v0.6.181 on Tue Aug 27 21:42:51 2024
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4x4 modelViewProj;            // Offset:    0 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xy          0     NONE   float   xy
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xy          2     NONE   float   xy
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xy          2     NONE   float   xy
//
vs_4_0
dcl_constantbuffer CB0[4], immediateIndexed
dcl_input v0.xy
dcl_input v1.xyzw
dcl_input v2.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 1
mov r0.xy, v0.xyxx
mov r0.z, l(1.000000)
dp3 o0.x, r0.xyzx, cb0[0].xywx
dp3 o0.y, r0.xyzx, cb0[1].xywx
dp3 o0.z, r0.xyzx, cb0[2].xywx
dp3 o0.w, r0.xyzx, cb0[3].xywx
mov o1.xyzw, v1.xyzw
mov o2.xy, v2.xyxx
ret
// Approximately 9 instruction slots used

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
