aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-06-28 09:19:38 +0200
committerStapleButter <thetotalworm@gmail.com>2017-06-28 09:19:38 +0200
commit5f6e8cc30bf541a71031c4f64c165a4dc4d8ea92 (patch)
treeefeb41e26d892dafd9cb2a148d64d4d67b085b4f
parentf113f2f26e4f018347b2621457ec94a778a9bff2 (diff)
fix toon highlight mode. GBAtek is wrong.
-rw-r--r--src/GPU3D_Soft.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp
index 8bc0662..482a28d 100644
--- a/src/GPU3D_Soft.cpp
+++ b/src/GPU3D_Soft.cpp
@@ -709,11 +709,26 @@ u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t)
if (blendmode == 2)
{
- u16 tooncolor = RenderToonTable[vr >> 1];
+ if (RenderDispCnt & (1<<1))
+ {
+ // highlight mode: color is calculated normally
+ // except all vertex color components are set
+ // to the red component
+ // the toon color is added to the final color
- vr = (tooncolor << 1) & 0x3E; if (vr) vr++;
- vg = (tooncolor >> 4) & 0x3E; if (vg) vg++;
- vb = (tooncolor >> 9) & 0x3E; if (vb) vb++;
+ vg = vr;
+ vb = vr;
+ }
+ else
+ {
+ // toon mode: vertex color is replaced by toon color
+
+ u16 tooncolor = RenderToonTable[vr >> 1];
+
+ vr = (tooncolor << 1) & 0x3E; if (vr) vr++;
+ vg = (tooncolor >> 4) & 0x3E; if (vg) vg++;
+ vb = (tooncolor >> 9) & 0x3E; if (vb) vb++;
+ }
}
if ((RenderDispCnt & (1<<0)) && (((polygon->TexParam >> 26) & 0x7) != 0))
@@ -771,6 +786,12 @@ u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t)
if ((blendmode == 2) && (RenderDispCnt & (1<<1)))
{
+ u16 tooncolor = RenderToonTable[vr >> 1];
+
+ vr = (tooncolor << 1) & 0x3E; if (vr) vr++;
+ vg = (tooncolor >> 4) & 0x3E; if (vg) vg++;
+ vb = (tooncolor >> 9) & 0x3E; if (vb) vb++;
+
r += vr;
g += vg;
b += vb;