#version 420
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_separate_shader_objects : enable

// shader 2f7ecb9f0022d8ca -- Pixel shader for Links Cel Shading World & Menu - Texture format 0x005d
#define mode $mode

layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4ccf000 res 1280x720x1 dim 1 tm: 4 format 0007 compSel: 0 0 0 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 1
layout(location = 0) in vec4 passParameterSem0;
uniform vec2 uf_fragCoordScale;
int clampFI32(int v)
{
if( v == 0x7FFFFFFF )
	return floatBitsToInt(1.0);
else if( v == 0xFFFFFFFF )
	return floatBitsToInt(0.0);
return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0));
}
float mul_nonIEEE(float a, float b){ if( a == 0.0 || b == 0.0 ) return 0.0; return a*b; }
void main()
{
ivec4 R0i = ivec4(0);
ivec4 R127i = ivec4(0);
int backupReg0i, backupReg1i, backupReg2i, backupReg3i, backupReg4i;
ivec4 PV0i = ivec4(0), PV1i = ivec4(0);
int PS0i = 0, PS1i = 0;
ivec4 tempi = ivec4(0);
float tempResultf;
int tempResulti;
ivec4 ARi = ivec4(0);
bool predResult = true;
vec3 cubeMapSTM;
int cubeMapFaceId;

R0i = floatBitsToInt(passParameterSem0); // comes from 3 vertex shaders, one of them handles the lighting that glitches the sky(314b77349f0636db), so lets exclude it

if (passParameterSem0.w == 4.0)
{
	R0i.w = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R0i.xy)).x);

	// 0
	PV0i.x = floatBitsToInt(intBitsToFloat(R0i.w) * intBitsToFloat(0x437f0000));
	R127i.y = int(uint(intBitsToFloat(R0i.z)));
	PS0i = R127i.y;

	// 1
	if ( mode > 1) // if mode is greater than 1 then run our own code
	{
		// very interesting - Replace PS1i(which is integer) with any of these numbers, there are like 4 diff modes that repeat through diff integers, [4,6,7,8,10,11] [-5 -9 -10 -12 -18 -19 -25 -26 -28 -34 -40 -41 -42]
		PS1i = int(mode);
	}
	else
	{
		PS1i = int(uint(intBitsToFloat(PV0i.x))); // orignal code
	}

	// 2
	PV0i.z = R127i.y & PS1i;

	// 3
	PS1i = floatBitsToInt(float(uint(PV0i.z)));

	// 4
	R0i.x = floatBitsToInt(intBitsToFloat(PS1i) * intBitsToFloat(0x3b808081));
}
else
{
	R0i.w = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R0i.xy)).x);

	// 0
	PV0i.x = floatBitsToInt(intBitsToFloat(R0i.w) * intBitsToFloat(0x437f0000));
	R127i.y = int(uint(intBitsToFloat(R0i.z)));
	PS0i = R127i.y;

	// 1
	PS1i = int(uint(intBitsToFloat(PV0i.x))); // orignal code

	// 2
	PV0i.z = R127i.y & PS1i;

	// 3
	PS1i = floatBitsToInt(float(uint(PV0i.z)));

	// 4
	R0i.x = floatBitsToInt(intBitsToFloat(PS1i) * intBitsToFloat(0x3b808081));
}

// export
gl_FragDepth = vec4(intBitsToFloat(R0i.x), 0, 0, 0).x;
}
