diff --git a/src/ags.c b/src/ags.c index 36e75d5..fc32ea0 100644 --- a/src/ags.c +++ b/src/ags.c @@ -384,11 +384,17 @@ agsurface_t *ags_drawStringToSurface(const char *str) { return &result; } -void ags_drawCg(cgdata *cg, int x, int y, int brightness) { +void ags_drawCg(cgdata *cg, int x, int y, int brightness, int sprite_color, bool alpha_blend) { switch (cg->depth) { - case 8: sdl_drawImage8_fromData(cg, x, y); break; - case 16: sdl_drawImage16_fromData(cg, x, y, brightness); break; - case 24: sdl_drawImage24_fromData(cg, x, y, brightness); break; + case 8: + sdl_drawImage8_fromData(cg, x, y, sprite_color); + break; + case 16: + sdl_drawImage16_fromData(cg, x, y, brightness, alpha_blend); + break; + case 24: + sdl_drawImage24_fromData(cg, x, y, brightness); + break; } } diff --git a/src/ags.h b/src/ags.h index e1d0a70..1ddfad3 100644 --- a/src/ags.h +++ b/src/ags.h @@ -170,7 +170,7 @@ extern void ags_copyRegion(void *region, int sx, int sy, int w,int h,int dx,int extern void ags_delRegion(void *region); extern MyRectangle ags_drawString(int x, int y, const char *src, int col); -extern void ags_drawCg(cgdata *cg, int x, int y, int brightness); +extern void ags_drawCg(cgdata *cg, int x, int y, int brightness, int sprite_color, bool alpha_blend); extern void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy); extern void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int col); diff --git a/src/cg.c b/src/cg.c index 99b4ffa..e4f61dc 100644 --- a/src/cg.c +++ b/src/cg.c @@ -65,7 +65,7 @@ static CG_TYPE check_cgformat(BYTE *data); static void set_vspbank(BYTE *pic, int bank, int width, int height); static MyPoint set_display_loc(cgdata *cg); static void clear_display_loc(); -static void display_cg(cgdata *cg, int x, int y); +static void display_cg(cgdata *cg, int x, int y, int sprite_color, bool alpha_blend); static cgdata *loader(int no); @@ -176,8 +176,8 @@ static void clear_display_loc() { * x : display location x * y : display location y */ -static void display_cg(cgdata *cg, int x, int y) { - ags_drawCg(cg, x, y, cg_brightness); +static void display_cg(cgdata *cg, int x, int y, int sprite_color, bool alpha_blend) { + ags_drawCg(cg, x, y, cg_brightness, sprite_color, alpha_blend); ags_updateArea(x, y, cg->width, cg->height); } @@ -340,8 +340,7 @@ void cg_load(int no, int flg) { ags_alpha_setPixel(p.x, p.y, cg->width, cg->height, cg->alpha); } /* draw cg pixel */ - cg->spritecolor = flg; - display_cg(cg, p.x, p.y); + display_cg(cg, p.x, p.y, flg, flg != -1); /* clear display offset */ clear_display_loc(); } @@ -380,7 +379,7 @@ void cg_load_with_alpha(int cgno, int shadowno) { /* draw pixel */ if (cg) { p = set_display_loc(cg); - display_cg(cg, p.x, p.y); + display_cg(cg, p.x, p.y, -1, true); } /* clear display offset */ @@ -436,8 +435,7 @@ int cg_load_with_filename(char *fname_utf8, int x, int y) { /* set display offset */ p = set_display_loc(cg); /* draw cg pixel */ - cg->spritecolor = -1; - display_cg(cg, p.x, p.y); + display_cg(cg, p.x, p.y, -1, false); /* clear display offset */ clear_display_loc(); } diff --git a/src/cg.h b/src/cg.h index 1ce0c54..c10ec33 100644 --- a/src/cg.h +++ b/src/cg.h @@ -59,8 +59,6 @@ typedef struct { int vsp_bank; // palette bank for vsp int pms_bank; // palette bank for pms - - int spritecolor; // sprite color for vsp and pms8 } cgdata; /* diff --git a/src/sdl_core.h b/src/sdl_core.h index 16e937d..395329e 100644 --- a/src/sdl_core.h +++ b/src/sdl_core.h @@ -67,8 +67,8 @@ extern void sdl_copyArea(int sx,int sy, int w, int h, int dx, int dy); extern void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp); extern void sdl_wrapColor(int sx, int sy, int w, int h, BYTE cl, int rate); extern void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror); -extern void sdl_drawImage8_fromData(cgdata *cg, int x, int y); -extern void sdl_drawImage16_fromData(cgdata *cg, int x, int y, int brightness); +extern void sdl_drawImage8_fromData(cgdata *cg, int x, int y, int sprite_color); +extern void sdl_drawImage16_fromData(cgdata *cg, int x, int y, int brightness, bool alpha_blend); extern void sdl_drawImage24_fromData(cgdata *cg, int x, int y, int brightness); extern void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv); extern void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv); diff --git a/src/sdl_draw.c b/src/sdl_draw.c index 7629ecf..97a9714 100644 --- a/src/sdl_draw.c +++ b/src/sdl_draw.c @@ -206,7 +206,7 @@ void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp) { SDL_SetColorKey(sdl_dib, SDL_FALSE, 0); } -void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy) { +void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) { int w = cg->width; int h = cg->height; SDL_Surface *s = SDL_CreateRGBSurfaceWithFormatFrom( @@ -234,9 +234,8 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy) { memcpy(s->format->palette->colors, sdl_col, sizeof(SDL_Color) * 256); } - if (cg->spritecolor != -1) { - SDL_SetColorKey(s, SDL_TRUE, cg->spritecolor); - } + if (sprite_color != -1) + SDL_SetColorKey(s, SDL_TRUE, sprite_color); SDL_Rect r_dst = {dx, dy, w, h}; diff --git a/src/sdl_image.c b/src/sdl_image.c index 7483d73..3046801 100644 --- a/src/sdl_image.c +++ b/src/sdl_image.c @@ -142,12 +142,12 @@ void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, /* * dibに16bitCGの描画 */ -void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int brightness) { +void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int brightness, bool alpha_blend) { int w = cg->width; int h = cg->height; SDL_Surface *s; - if (cg->alpha != NULL && cg->spritecolor != -1) { + if (cg->alpha && alpha_blend) { unsigned short *p_src = (WORD *)cg->pic; DWORD *p_ds, *p_dst; BYTE *a_src = cg->alpha;