Skip to content

Commit

Permalink
ws: First pass at "mono" model color emulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka authored and LukeUsher committed Feb 16, 2025
1 parent c9285b5 commit 58af8cb
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ares/ws/ppu/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ auto PPU::color(n32 color) -> n64 {
u64 B = image::normalize(b, 4, 16);

if(colorEmulation->value()) {
R = (r * 26 + g * 4 + b * 2);
G = ( g * 24 + b * 8);
B = (r * 6 + g * 4 + b * 22);
R = image::normalize(min(480, R), 9, 16);
G = image::normalize(min(480, G), 9, 16);
B = image::normalize(min(480, B), 9, 16);
if(SoC::ASWAN()) {
auto gammaAdjustBetween = [=](u32 c, u32 min, u32 max) { return min + (u32) (pow(c / 15.0, 1 / 2.2) * (max - min)); };
// The WS's display has similar characteristics to the GBP.
R = gammaAdjustBetween(r, 0x2b2b, 0xe0e0);
G = gammaAdjustBetween(g, 0x2b2b, 0xdbdb);
B = gammaAdjustBetween(b, 0x2626, 0xcdcd);
return R << 32 | G << 16 | B << 0;
} else {
// The SC's display has similar characteristics to the GBC.
R = (r * 26 + g * 4 + b * 2);
G = ( g * 24 + b * 8);
B = (r * 6 + g * 4 + b * 22);
R = image::normalize(min(480, R), 9, 16);
G = image::normalize(min(480, G), 9, 16);
B = image::normalize(min(480, B), 9, 16);
}
}

return R << 32 | G << 16 | B << 0;
Expand Down

0 comments on commit 58af8cb

Please sign in to comment.