Implement palette shift effect (CD 1001)

Used in Toushin Toshi 2.
This commit is contained in:
kichikuou
2022-07-31 12:44:30 +09:00
parent 652d284628
commit cee18a572e
4 changed files with 24 additions and 9 deletions
+14
View File
@@ -301,6 +301,20 @@ void ags_getPixel(int x, int y, Palette *cell) {
sdl_getPixel(x, y, cell);
}
void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, BYTE sprite) {
if (!ags_check_param(&sx, &sy, &w, &h)) return;
if (!ags_check_param(&dx, &dy, &w, &h)) return;
for (int y = 0; y < h; y++) {
BYTE *src = GETOFFSET_PIXEL(nact->ags.dib, sx, sy + y);
BYTE *dst = GETOFFSET_PIXEL(nact->ags.dib, dx, dy + y);
for (int x = 0; x < w; x++, src++, dst++) {
if (*src != sprite)
*dst = (*src & 0xf0) | (*dst & 0x0f);
}
}
}
void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt) {
if (nact->ags.world_depth != 8) return;
+1
View File
@@ -161,6 +161,7 @@ extern void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, i
extern void ags_wrapColor(int x, int y, int w, int h, int p1, int p2);
extern void ags_getPixel(int x, int y, Palette *cell);
extern void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, BYTE sprite);
extern void ags_changeColorArea(int x, int y, int w, int h, int dst, int src, int cnt);
extern void* ags_saveRegion(int x, int y, int w, int h);
+7 -8
View File
@@ -284,11 +284,6 @@ static int eCopyArea1000(int sx, int sy, int w, int h, int dx, int dy, int opt,
return sys_getInputInfo();
}
static int eCopyArea1001(int sx, int sy, int w, int h, int dx, int dy, int opt, int spCol) {
/* パレットシフト */
return sys_getInputInfo();
}
static int eCopyArea2000(int sx, int sy, int w, int h, int dx, int dy, int opt) {
sdl_fillRectangleRGB(dx, dy, w, h, 0, 0, 0);
ags_copyArea_alphaLevel(sx, sy, w, h, dx, dy, opt);
@@ -401,6 +396,8 @@ static int duration(enum nact_effect effect, int opt, SDL_Rect *rect) {
return opt ? opt : 1000;
case NACT_EFFECT_LINEAR_BLUR:
return opt ? opt : 1700;
case NACT_EFFECT_PALETTE_SHIFT:
return 0;
}
return 1000;
}
@@ -522,9 +519,11 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt
if (nact->ags.world_depth != 8) return;
ret = eCopyArea1000(sx, sy, w, h, dx, dy, opt, spCol);
break;
case 1001:
if (nact->ags.world_depth != 8) return;
ret = eCopyArea1001(sx, sy, w, h, dx, dy, opt, spCol);
case NACT_EFFECT_PALETTE_SHIFT:
if (nact->ags.world_depth != 8 || spCol == -1) return;
ags_copyPaletteShift(sx, sy, w, h, dx, dy, spCol);
ags_updateArea(dx, dy, w, h);
ret = sys_getInputInfo();
break;
case 2000:
if (nact->ags.world_depth == 8) return;
+2 -1
View File
@@ -20,7 +20,7 @@
#ifndef __EFFECT_H__
#define __EFFECT_H__
// Effect types of the CE command.
// Effect types of the CE/CD command.
enum nact_effect {
NACT_EFFECT_WIPE_IN = 7,
NACT_EFFECT_WIPE_OUT = 8,
@@ -64,6 +64,7 @@ enum nact_effect {
NACT_EFFECT_WINDMILL_180 = 51,
NACT_EFFECT_WINDMILL_360 = 52,
NACT_EFFECT_LINEAR_BLUR = 53,
NACT_EFFECT_PALETTE_SHIFT = 1001, // CD command only
};
// Effect types of SCAT.DrawEffect and Gpx.EffectCopy.