aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-04-08 01:08:19 +0200
committerArisotura <thetotalworm@gmail.com>2022-04-08 01:08:19 +0200
commit86f725f2f245b8752ff2ea36371fc9bb31da2b3e (patch)
treefaf072e061f0dcb81a08b84a902b836244540e53 /src
parentf6a55354fa96788009bbb04121c31ca172ac5621 (diff)
master brightness has different biases (are you serious, Nintendo)
also add all these biases to the OpenGL compositor
Diffstat (limited to 'src')
-rw-r--r--src/GPU2D_Soft.cpp24
-rw-r--r--src/GPU2D_Soft.h6
-rw-r--r--src/GPU_OpenGL_shaders.h13
3 files changed, 21 insertions, 22 deletions
diff --git a/src/GPU2D_Soft.cpp b/src/GPU2D_Soft.cpp
index 8806273..66095e1 100644
--- a/src/GPU2D_Soft.cpp
+++ b/src/GPU2D_Soft.cpp
@@ -67,24 +67,24 @@ u32 SoftRenderer::ColorBlend5(u32 val1, u32 val2)
return r | g | b | 0xFF000000;
}
-u32 SoftRenderer::ColorBrightnessUp(u32 val, u32 factor)
+u32 SoftRenderer::ColorBrightnessUp(u32 val, u32 factor, u32 bias)
{
u32 rb = val & 0x3F003F;
u32 g = val & 0x003F00;
- rb += (((((0x3F003F - rb) * factor) + 0x080008) >> 4) & 0x3F003F);
- g += (((((0x003F00 - g ) * factor) + 0x000800) >> 4) & 0x003F00);
+ rb += (((((0x3F003F - rb) * factor) + (bias*0x010001)) >> 4) & 0x3F003F);
+ g += (((((0x003F00 - g ) * factor) + (bias*0x000100)) >> 4) & 0x003F00);
return rb | g | 0xFF000000;
}
-u32 SoftRenderer::ColorBrightnessDown(u32 val, u32 factor)
+u32 SoftRenderer::ColorBrightnessDown(u32 val, u32 factor, u32 bias)
{
u32 rb = val & 0x3F003F;
u32 g = val & 0x003F00;
- rb -= ((((rb * factor) + 0x070007) >> 4) & 0x3F003F);
- g -= ((((g * factor) + 0x000700) >> 4) & 0x003F00);
+ rb -= ((((rb * factor) + (bias*0x010001)) >> 4) & 0x3F003F);
+ g -= ((((g * factor) + (bias*0x000100)) >> 4) & 0x003F00);
return rb | g | 0xFF000000;
}
@@ -153,8 +153,8 @@ u32 SoftRenderer::ColorComposite(int i, u32 val1, u32 val2)
{
case 0: return val1;
case 1: return ColorBlend4(val1, val2, eva, evb);
- case 2: return ColorBrightnessUp(val1, CurUnit->EVY);
- case 3: return ColorBrightnessDown(val1, CurUnit->EVY);
+ case 2: return ColorBrightnessUp(val1, CurUnit->EVY, 0x8);
+ case 3: return ColorBrightnessDown(val1, CurUnit->EVY, 0x7);
case 4: return ColorBlend5(val1, val2);
}
@@ -328,7 +328,7 @@ void SoftRenderer::DrawScanline(u32 line, Unit* unit)
for (int i = 0; i < 256; i++)
{
- dst[i] = ColorBrightnessUp(dst[i], factor);
+ dst[i] = ColorBrightnessUp(dst[i], factor, 0x0);
}
}
else if ((masterBrightness >> 14) == 2)
@@ -339,7 +339,7 @@ void SoftRenderer::DrawScanline(u32 line, Unit* unit)
for (int i = 0; i < 256; i++)
{
- dst[i] = ColorBrightnessDown(dst[i], factor);
+ dst[i] = ColorBrightnessDown(dst[i], factor, 0xF);
}
}
}
@@ -445,8 +445,8 @@ void SoftRenderer::DoCapture(u32 line, u32 width)
u32 evy = (val3 >> 8) & 0x1F;
val1 = _3dval;
- if (compmode == 2) val1 = ColorBrightnessUp(val1, evy);
- else if (compmode == 3) val1 = ColorBrightnessDown(val1, evy);
+ if (compmode == 2) val1 = ColorBrightnessUp(val1, evy, 0x8);
+ else if (compmode == 3) val1 = ColorBrightnessDown(val1, evy, 0x7);
}
else
val1 = val2;
diff --git a/src/GPU2D_Soft.h b/src/GPU2D_Soft.h
index b21fa3d..d7a417b 100644
--- a/src/GPU2D_Soft.h
+++ b/src/GPU2D_Soft.h
@@ -49,8 +49,8 @@ private:
u32 ColorBlend4(u32 val1, u32 val2, u32 eva, u32 evb);
u32 ColorBlend5(u32 val1, u32 val2);
- u32 ColorBrightnessUp(u32 val, u32 factor);
- u32 ColorBrightnessDown(u32 val, u32 factor);
+ u32 ColorBrightnessUp(u32 val, u32 factor, u32 bias);
+ u32 ColorBrightnessDown(u32 val, u32 factor, u32 bias);
u32 ColorComposite(int i, u32 val1, u32 val2);
template<u32 bgmode> void DrawScanlineBGMode(u32 line);
@@ -78,4 +78,4 @@ private:
void DoCapture(u32 line, u32 width);
};
-} \ No newline at end of file
+}
diff --git a/src/GPU_OpenGL_shaders.h b/src/GPU_OpenGL_shaders.h
index 1ccbd43..b1460cd 100644
--- a/src/GPU_OpenGL_shaders.h
+++ b/src/GPU_OpenGL_shaders.h
@@ -82,8 +82,7 @@ void main()
eva = (_3dpix.a & 0x1F) + 1;
evb = 32 - eva;
- val1 = ((_3dpix * eva) + (val1 * evb)) >> 5;
- if (eva <= 16) val1 += ivec4(1,1,1,0);
+ val1 = ((_3dpix * eva) + (val1 * evb) + 0x10) >> 5;
val1 = min(val1, 0x3F);
}
else
@@ -103,7 +102,7 @@ void main()
eva = val3.g;
evb = val3.b;
- val1 = ((val1 * eva) + (_3dpix * evb)) >> 4;
+ val1 = ((val1 * eva) + (_3dpix * evb) + 0x8) >> 4;
val1 = min(val1, 0x3F);
}
else
@@ -123,8 +122,8 @@ void main()
evy = val3.g;
val1 = _3dpix;
- if (compmode == 2) val1 += ((ivec4(0x3F,0x3F,0x3F,0) - val1) * evy) >> 4;
- else if (compmode == 3) val1 -= (val1 * evy) >> 4;
+ if (compmode == 2) val1 += (((0x3F - val1) * evy) + 0x8) >> 4;
+ else if (compmode == 3) val1 -= ((val1 * evy) + 0x7) >> 4;
}
else
val1 = val2;
@@ -142,7 +141,7 @@ void main()
int evy = mbright.r & 0x1F;
if (evy > 16) evy = 16;
- pixel += ((ivec4(0x3F,0x3F,0x3F,0) - pixel) * evy) >> 4;
+ pixel += ((0x3F - pixel) * evy) >> 4;
}
else if (brightmode == 2)
{
@@ -150,7 +149,7 @@ void main()
int evy = mbright.r & 0x1F;
if (evy > 16) evy = 16;
- pixel -= (pixel * evy) >> 4;
+ pixel -= ((pixel * evy) + 0xF) >> 4;
}
}