Skip to content

Commit

Permalink
Enable color correction on Android. Tweak color washing.
Browse files Browse the repository at this point in the history
  • Loading branch information
veikkos committed Mar 12, 2019
1 parent b98964b commit 895f129
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion android/ChesterApp/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.1)

file(GLOB ChesterSrcs ../../../src/lib/*.c)

add_definitions(-DEXPERIMENTAL_CGB -DRGBA8888)
add_definitions(-DEXPERIMENTAL_CGB -DCOLOR_CORRECTION -DRGBA8888)

add_library(native-lib
SHARED
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chester.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool init(chester *chester, const char* rom, const char* save_path, const char*
{
char* base_name_cpy = strdup(rom);
#ifdef WIN32
char base_name[64];
char base_name[128];
_splitpath(base_name_cpy, NULL, NULL, base_name, NULL);
#else
char* base_name = basename(base_name_cpy);
Expand Down
24 changes: 20 additions & 4 deletions src/lib/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,33 @@ static inline void wash_color_if(uint8_t *c, const uint8_t largest, const double
static inline void wash_colors(uint8_t *r, uint8_t *g, uint8_t *b, const double change)
{
uint8_t largest;
uint8_t *second_largest;

if (*r >= *g && *r >= *b)
largest = *r;
{
largest = *r;
second_largest = *g > *b ? g : b;
}
else if (*g >= *r && *g >= *b)
largest = *g;
{
largest = *g;
second_largest = *r > *b ? r : b;
}
else
largest = *b;
{
largest = *b;
second_largest = *r > *g ? r : g;
}

wash_color_if(r, largest, change);
wash_color_if(g, largest, change);
wash_color_if(b, largest, change);

const double half_change = change / 2;

wash_color_if(r, *second_largest, half_change);
wash_color_if(g, *second_largest, half_change);
wash_color_if(b, *second_largest, half_change);
}
#endif

Expand Down Expand Up @@ -109,7 +125,7 @@ static inline const uint8_t *get_color(const unsigned int raw_color,
colors[b_index] = convert_color((p_colors >> 10) & 0x1F);

#ifdef COLOR_CORRECTION
wash_colors(&colors[r_index], &colors[g_index], &colors[b_index], 0.25);
wash_colors(&colors[r_index], &colors[g_index], &colors[b_index], 0.15);
change_saturation(&colors[r_index], &colors[g_index], &colors[b_index], 0.85);
#endif

Expand Down

0 comments on commit 895f129

Please sign in to comment.