;******************************************************************************************************************************************
;HALO 1
[ShaderRegex_Halo1]
shader_model = vs_4_0 vs_5_0 ds_5_0
temps = stereo tmp1

[ShaderRegex_Halo1.Pattern]
mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.xxxx, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.zzzz, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.wwww, r\d+\.xyzw\n
\s*mov o0\.xyzw, (?P<register>r\d+)\.xyzw\n

[ShaderRegex_Halo1.Pattern.Replace]
${0}
\n
// DHR ShaderRegex - Pattern Halo 1:\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
ne ${tmp1}.w, ${register}.w, l(1.0)\n
if_nz ${tmp1}.w\n
add ${tmp1}.x, ${register}.w, -${stereo}.y\n
mad ${register}.x, ${tmp1}.x, ${stereo}.x, ${register}.x\n
endif\n
\n
;
[ShaderRegex_Halo1.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;HALO 2
[ShaderRegex_Halo2]
shader_model = vs_4_0 vs_5_0
temps = stereo tmp1

[ShaderRegex_Halo2.Pattern]
mad r\d+\.xyzw, cb[1234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.xxxx, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[1234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.zzzz, r\d+\.xyzw\n
\s*add r\d+\.xyzw, r\d+\.xyzw, cb[1234]{1}\[\d+\]\.xyzw\n
\s*mov o0\.xyzw, (?P<register>r\d+)\.xyzw\n

[ShaderRegex_Halo2.Pattern.Replace]
${0}
\n
// DHR ShaderRegex - Pattern Halo 2:\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
ne ${tmp1}.w, ${register}.w, l(1.0)\n
if_nz ${tmp1}.w\n
add ${tmp1}.x, ${register}.w, -${stereo}.y\n
mad ${register}.x, ${tmp1}.x, ${stereo}.x, ${register}.x\n
endif\n
\n
;
[ShaderRegex_Halo2.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;HALO 3
[ShaderRegex_Halo3]
shader_model = vs_4_0 vs_5_0
temps = stereo tmp1

[ShaderRegex_Halo3.Pattern]
mad r\d+\.xyzw, cb[012]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.xxxx, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[012]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.zzzz, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[012]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.wwww, r\d+\.xyzw\n
\s*min r\d+\.z, r\d+\.z, cb1\[5\]\.z\n
\s*mov o0\.xyzw, (?P<register>r\d+)\.xyzw\n

[ShaderRegex_Halo3.Pattern.Replace]
${0}
\n
// DHR ShaderRegex - Pattern Halo 2:\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
ne ${tmp1}.w, ${register}.w, l(1.0)\n
if_nz ${tmp1}.w\n
add ${tmp1}.x, ${register}.w, -${stereo}.y\n
mad ${register}.x, ${tmp1}.x, ${stereo}.x, ${register}.x\n
endif\n
\n
;
[ShaderRegex_Halo3.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;HALO 4 - o1
[ShaderRegex_Halo4]
shader_model = vs_4_0 vs_5_0
temps = stereo tmp1

[ShaderRegex_Halo4.Pattern]
mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.xxxx, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.zzzz, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb[01234]{1}\[\d+\]\.xyzw, [vr]{1}\d+\.wwww, r\d+\.xyzw\n
\s*mov o1\.xyzw, (?P<register>r\d+)\.xyzw\n

[ShaderRegex_Halo4.Pattern.Replace]
${0}
\n
// DHR ShaderRegex - Pattern Halo 4:\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
ne ${tmp1}.w, ${register}.w, l(1.0)\n
if_nz ${tmp1}.w\n
add ${tmp1}.x, ${register}.w, -${stereo}.y\n
mad ${register}.x, ${tmp1}.x, ${stereo}.x, ${register}.x\n
endif\n
\n
;
[ShaderRegex_Halo4.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;LIGHT SHAFTS
[ShaderRegex_Light_Shafts]
shader_model = vs_4_0 vs_5_0
temps = stereo tmp1 tmp2

[ShaderRegex_Light_Shafts.Pattern]
(?P<section1>
mad o0\.xyzw, cb2\[20\]\.xyzw, r\d+\.wwww, r\d+\.xyzw\n
)
(?P<section2>
\s*add r\d+\.xy, -v1\.xyxx, cb0\[5\]\.xyxx\n
)

[ShaderRegex_Light_Shafts.Pattern.Replace]
${section1}
;${section2}
\n
// DHR ShaderRegex - Pattern Light Shaft:\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
mov ${tmp1}.xyzw, cb0[5].xyzw\n
mul ${tmp2}.x, ${stereo}.x, l(0.5)\n
add ${tmp1}.x, ${tmp1}.x, ${tmp2}.x\n
add r0.xy, -v1.xyxx, ${tmp1}.xyxx\n
\n
;
[ShaderRegex_Light_Shafts.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;SHADOWS LIGHTS 1
;Pattern for Shadows and Lights 1
[ShaderRegexLights1]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexLights1.Pattern]
mul r\d+\.xyz, r\d+\.yyyy, cb2\[19\]\.xyzx\n
\s*mad r\d+\.xyw, cb2\[18\]\.xyxz, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyxz\n
\s*mad r\d+\.[xyzw]{3}, cb2\[20\]\.[xyzw]{4}, (?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.[xyzw]{4}\n
\s*add r\d+\.[xyzw]{3}, r\d+\.[xyzw]{4}, cb2\[21\]\.[xyzw]{4}\n

[ShaderRegexLights1.Pattern.Replace]
\n
// DHR Unity shadows lights pattern 1\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, ${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, v2.w\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexLights1.InsertDeclarations]
dcl_input_ps linear v2.w
dcl_resource_texture2d (float,float,float,float) t125

;******************************************************************************************************************************************
;SHADOWS LIGHTS 2
;Pattern for Shadows and Lights 2
[ShaderRegexLights2]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexLights2.Pattern]
mul r\d+\.xyz, r\d+\.yyyy, cb1\[19\]\.xyzx\n
\s*mad r\d+\.xyw, cb1\[18\]\.xyxz, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyxz\n
\s*mad r\d+\.xyz, cb1\[20\]\.xyzx, (?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.xywx\n
\s*add r\d+\.xyz, r\d+\.xyzx, cb1\[21\]\.xyzx\n

[ShaderRegexLights2.Pattern.Replace]
\n
// DHR Unity shadows lights pattern 1\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, ${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, v2.w\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexLights2.InsertDeclarations]
dcl_input_ps linear v2.w
dcl_resource_texture2d (float,float,float,float) t125

;**************************************************************
;SHADOWS 1
;Pattern for Shadows
[ShaderRegexShadows1]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexShadows1.Pattern]
mul r\d+\.xyzw, r\d+\.yyyy, cb1\[19\]\.xyzw\n
\s*mad r\d+\.xyzw, cb1\[18\]\.xyzw, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb1\[20\]\.xyzw, -(?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*add r\d+\.xyzw, r\d+\.xyzw, cb1\[21\]\.xyzw\n

[ShaderRegexShadows1.Pattern.Replace]
\n
// DHR Unity shadows pattern 1\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, -${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, v2.w\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexShadows1.InsertDeclarations]
dcl_input_ps linear v2.w
dcl_resource_texture2d (float,float,float,float) t125

;**************************************************************
;SHADOWS 1_1
;Pattern for Shadows
[ShaderRegexShadows1_1]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexShadows1_1.Pattern]
mul r\d+\.xyzw, r\d+\.yyyy, cb0\[19\]\.xyzw\n
\s*mad r\d+\.xyzw, cb0\[18\]\.xyzw, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb0\[20\]\.xyzw, -(?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*add r\d+\.xyzw, r\d+\.xyzw, cb0\[21\]\.xyzw\n

[ShaderRegexShadows1_1.Pattern.Replace]
\n
// DHR Unity shadows pattern 1\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, -${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, v2.w\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexShadows1_1.InsertDeclarations]
dcl_input_ps linear v2.w
dcl_resource_texture2d (float,float,float,float) t125

;**************************************************************
;SHADOWS 2
;Pattern for Shadows
[ShaderRegexShadows2]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexShadows2.Pattern]
mul r\d+\.xyzw, r\d+\.yyyy, cb1\[19\]\.xyzw\n
\s*mad r\d+\.xyzw, cb1\[18\]\.xyzw, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb1\[20\]\.xyzw, (?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*add r\d+\.xyzw, r\d+\.xyzw, cb1\[21\]\.xyzw\n

[ShaderRegexShadows2.Pattern.Replace]
\n
// DHR Unity shadows pattern 1\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, ${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, v2.w\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexShadows2.InsertDeclarations]
dcl_input_ps linear v2.w
dcl_resource_texture2d (float,float,float,float) t125

;**************************************************************
;SHADOWS 3
;Pattern for Shadows
[ShaderRegexShadows3]
shader_model = ps_4_0 ps_5_0
temps = stereo tmp1

[ShaderRegexShadows3.Pattern]
mul r\d+\.xyzw, r\d+\.yyyy, cb2\[19\]\.xyzw\n
\s*mad r\d+\.xyzw, cb2\[18\]\.xyzw, (?P<pos_x>r\d+)\.(?P<swizzle_x>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*mad r\d+\.xyzw, cb2\[20\]\.xyzw, (?P<pos_z>r\d+)\.(?P<swizzle_z>[xyzw])[xyzw]{3}, r\d+\.xyzw\n
\s*add r\d+\.xyzw, r\d+\.xyzw, cb2\[21\]\.xyzw\n

[ShaderRegexShadows3.Pattern.Replace]
\n
// DHR Unity shadows pattern 3\n
ld_indexable(texture2d)(float,float,float,float) ${stereo}.xyzw, l(0, 0, 0, 0), t125.xyzw\n
add ${tmp1}.x, ${pos_z}.${swizzle_z}, -${stereo}.y\n
mul ${tmp1}.x, ${stereo}.x, ${tmp1}.x\n
mul ${tmp1}.x, ${tmp1}.x, cb2[10].x\n
add ${pos_x}.${swizzle_x}, ${pos_x}.${swizzle_x}, -${tmp1}.x\n
\n
${0}

[ShaderRegexShadows3.InsertDeclarations]
dcl_resource_texture2d (float,float,float,float) t125
