ps_2_0
// apply brightness and contrast
// inputs:
//   tex0
//   c0.x is linear brightness
//   c0.y is other brightness
dcl t0
dcl_2d s0
def c1,1,-1,0,0
texld r0,t0,s0
mul r0,r0,c0.x
sub r1,c1.x,r0
mov r2,c1.x
sub r2.x,r2.x,c0.y
mul r1,r1,r2.x
mad r1,r1,c1.y,c1.x  // b1 = (1-(1-c)*(1-b))
add r2.y,r2.y,c0.y
mul r2,r0,r2.y
cmp r0,c0.x,r1,r2    // b2 = c*(1+b);
mov oC0,r0
