diff --git a/modules/ShGraph/ShGraph.c b/modules/ShGraph/ShGraph.c index cbd1a69..0556d5a 100644 --- a/modules/ShGraph/ShGraph.c +++ b/modules/ShGraph/ShGraph.c @@ -37,6 +37,7 @@ #include "ags.h" #include "music.h" #include "sdl_core.h" +#include "hacks.h" #define SLOT 40 @@ -182,6 +183,9 @@ static void ChangeNotColor() { break; } } + // The CX command after ChangeNotColor (in FIGHT.ADV) must use a precise + // calculation. + daiakuji_cx_hack = true; } /* diff --git a/src/cmdc.c b/src/cmdc.c index 15917f1..6783dfc 100644 --- a/src/cmdc.c +++ b/src/cmdc.c @@ -27,6 +27,7 @@ #include "xsystem35.h" #include "scenario.h" #include "ags.h" +#include "hacks.h" void commandCC() { int src_x = getCaliValue(); @@ -69,7 +70,16 @@ void commandCX() { switch(mode) { case 0: - ags_copyArea_shadow(src_x, src_y, width, height, dst_x, dst_y); + // In Daiakuji, the image after the blending is used as a source image + // for sprite copy (CX 1). SDL's SIMD blending implementation has some + // error (blending #ff00ff and #ff00ff results in #fd00fd), so the + // resulting color may not match the colorkey of CX 1. To workaround + // this, specify a small alpha mod so that SDL will use a "slow path" + // that does accurate calculation. + if (daiakuji_cx_hack) + ags_copyArea_shadow_withrate(src_x, src_y, width, height, dst_x, dst_y, 254); + else + ags_copyArea_shadow(src_x, src_y, width, height, dst_x, dst_y); ags_updateArea(dst_x, dst_y, width, height); break; case 1: @@ -94,6 +104,7 @@ void commandCX() { DEBUG_COMMAND_YET("CX %d,%d,%d,%d,%d,%d,%d,%d:", mode, src_x, src_y, width, height, dst_x, dst_y, col); break; } + daiakuji_cx_hack = false; DEBUG_COMMAND("CX %d,%d,%d,%d,%d,%d,%d,%d:", mode, src_x, src_y, width, height, dst_x, dst_y, col); } diff --git a/src/hacks.c b/src/hacks.c index 202d6c6..acd772f 100644 --- a/src/hacks.c +++ b/src/hacks.c @@ -33,6 +33,8 @@ /* defined by cmdy.c */ extern boolean Y3waitFlags; +bool daiakuji_cx_hack; + void enable_hack_by_gameid(const char *gameid) { if (!strcmp(gameid, "toushin2")) nact->game = GAME_TT2; diff --git a/src/hacks.h b/src/hacks.h index 0e14bfe..1a698c1 100644 --- a/src/hacks.h +++ b/src/hacks.h @@ -20,6 +20,8 @@ #ifndef __HACKS_H_ #define __HACKS_H_ +#include + enum gameId { GAME_UNKNOWN = 0, GAME_TT2, @@ -31,4 +33,6 @@ enum gameId { void enable_hack_by_gameid(const char *gameid); void enable_hack_by_title(const char *game_title_utf8); +extern bool daiakuji_cx_hack; + #endif // __HACKS_H_