diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 572de52..2928ab5 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -66,18 +66,11 @@ add_library(modules STATIC lib/surface.c lib/cg.c lib/graph_expandcolor_blend.c - lib/graph_fillrect.c lib/graph_fillrect_amap.c - lib/graph_fillrect_acolor.c - lib/graph_rect.c - lib/graph_copy.c lib/graph_copy_amap.c - lib/graph_copy_bright.c lib/graph_blend_amap.c - lib/graph_blend_screen.c lib/graph_saturadd_amap.c lib/graph_draw_amap.c - lib/graph_stretch.c lib/graph_cg.c lib/gre_blend_useamap.c nDEMO/nDEMO.c diff --git a/modules/ShGraph/ShGraph.c b/modules/ShGraph/ShGraph.c index e11d741..3ba1a12 100644 --- a/modules/ShGraph/ShGraph.c +++ b/modules/ShGraph/ShGraph.c @@ -41,8 +41,6 @@ #define SLOT 40 -static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, int r, int g, int b); - static MyRectangle maprect; /* アニメーション表示領域 */ static MyRectangle mapback; /* 背景セーブ領域 */ static int mapback_p5; /* 背景転送先 X */ @@ -89,6 +87,14 @@ static struct _s2 s2[SLOT]; static int* add_p5[SLOT]; /* どこまでアニメーションのコマが進んだか */ +static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, int r, int g, int b) { + SDL_Surface *sf = nact->ags.dib->sdl_surface; + SDL_SetColorKey(sf, SDL_TRUE, SDL_MapRGB(sf->format, r, g, b)); + SDL_Rect src_rect = { sx, sy, width, height }; + SDL_Rect dst_rect = { dx, dy, width, height }; + SDL_BlitSurface(sf, &src_rect, sf, &dst_rect); + SDL_SetColorKey(sf, SDL_FALSE, 0); +} static void Init() { /* @@ -553,60 +559,6 @@ static void PlayAnimeData() { } } -static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, int r, int g, int b) { - int x, y; - uint8_t *sp, *dp; - agsurface_t *dib; - - if (dx < 0 || dy < 0) return; - - ags_check_param(&sx, &sy, &width, &height); - ags_check_param(&dx, &dy, &width, &height); - - dib = nact->ags.dib; - - sp = GETOFFSET_PIXEL(dib, sx, sy); - dp = GETOFFSET_PIXEL(dib, dx, dy); - - switch(dib->depth) { - case 16: - { - uint16_t pic16 = PIX16(r, g, b); - uint16_t *yls, *yld; - - for (y = 0; y < height; y++) { - yls = (uint16_t *)(sp + y * dib->bytes_per_line); - yld = (uint16_t *)(dp + y * dib->bytes_per_line); - for (x = 0; x < width; x++) { - if (*yls != pic16) { - *yld = *yls; - } - yls++; yld++; - } - } - break; - } - case 24: - case 32: - { - uint32_t pic24 = PIX24(r, g, b); - uint32_t *yls, *yld; - - for (y = 0; y < height; y++) { - yls = (uint32_t *)(sp + y * dib->bytes_per_line); - yld = (uint32_t *)(dp + y * dib->bytes_per_line); - for (x = 0; x < width; x++) { - if (*yls != pic24) { - *yld = *yls; - } - yls++; yld++; - } - } - break; - } - } -} - static const ModuleFunc functions[] = { {"AddAnimeData", AddAnimeData}, {"AddAnimeRemain", AddAnimeRemain}, diff --git a/modules/lib/graph.c b/modules/lib/graph.c index bcb3e45..885a816 100644 --- a/modules/lib/graph.c +++ b/modules/lib/graph.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "portab.h" #include "system.h" @@ -10,6 +11,7 @@ #include "graph.h" #include "ngraph.h" #include "ags.h" +#include "sdl_core.h" /* gr_xxxx はクリッピングあり @@ -69,6 +71,59 @@ bool gr_clip_xywh(surface_t *ss, int *sx, int *sy, int *sw, int *sh) { void gr_init() { } +void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) { + if (!dst->sdl_surface || !src->sdl_surface) return; + if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return; + + SDL_Rect src_rect = {sx, sy, sw, sh}; + SDL_Rect dst_rect = {dx, dy, sw, sh}; + if (dst == src) { + SDL_Rect r; + if (SDL_IntersectRect(&src_rect, &dst_rect, &r)) { + SDL_Surface *view = sdl_createSurfaceView(src->sdl_surface, sx, sy, sw, sh); + SDL_Surface *tmp = SDL_ConvertSurface(view, dst->sdl_surface->format, 0); + src_rect.x = 0; + src_rect.y = 0; + SDL_LowerBlit(tmp, &src_rect, dst->sdl_surface, &dst_rect); + SDL_FreeSurface(tmp); + SDL_FreeSurface(view); + return; + } + } + SDL_LowerBlit(src->sdl_surface, &src_rect, dst->sdl_surface, &dst_rect); +} + +// Copy the specified surface area with brightness lv/255 times +void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) { + SDL_Rect src_rect = {sx, sy, width, height}; + SDL_Rect dst_rect = {dx, dy, width, height}; + SDL_SetSurfaceColorMod(src->sdl_surface, lv, lv, lv); + SDL_BlitSurface(src->sdl_surface, &src_rect, dst->sdl_surface, &dst_rect); + SDL_SetSurfaceColorMod(src->sdl_surface, 255, 255, 255); +} + +void gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) { + SDL_Rect rect = {dx, dy, dw, dh}; + uint32_t color = SDL_MapRGB(dst->sdl_surface->format, r, g, b); + SDL_FillRect(dst->sdl_surface, &rect, color); +} + +void gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) { + SDL_Rect rects[4] = { + {x, y, w, 1}, + {x, y + h - 1, w, 1}, + {x, y, 1, h}, + {x + w - 1, y, 1, h} + }; + uint32_t color = SDL_MapRGB(dst->sdl_surface->format, r, g, b); + SDL_FillRects(dst->sdl_surface, rects, 4, color); +} + +void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh) { + SDL_Rect srcrect = {sx, sy, sw, sh}; + SDL_Rect dstrect = {dx, dy, dw, dh}; + SDL_SoftStretch(src->sdl_surface, &srcrect, dst->sdl_surface, &dstrect); +} void gr_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) { if (!gr_clip(src, &sx, &sy, &width, &height, dst, &dx, &dy)) return; @@ -102,6 +157,14 @@ void gr_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, in } } +void gr_blend_screen(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height) { + SDL_Rect src_rect = { sx, sy, width, height }; + SDL_Rect dst_rect = { dx, dy, width, height }; + SDL_SetSurfaceBlendMode(src->sdl_surface, SDL_BLENDMODE_ADD); + SDL_BlitSurface(src->sdl_surface, &src_rect, dst->sdl_surface, &dst_rect); + SDL_SetSurfaceBlendMode(src->sdl_surface, SDL_BLENDMODE_NONE); +} + void gr_blend_src_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int alpha, int rate) { } @@ -242,4 +305,14 @@ void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int free(col); } +// Fill the rectangle with the specified color (rgb) and blend rate (lv) +void gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b, int lv) { + SDL_Surface *src = SDL_CreateRGBSurfaceWithFormat(0, dw, dh, 32, SDL_PIXELFORMAT_RGBA32); + SDL_FillRect(src, NULL, SDL_MapRGBA(src->format, r, g, b, lv)); + SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND); + SDL_Rect dstrect = {dx, dy, dw, dh}; + SDL_BlitSurface(src, NULL, dst->sdl_surface, &dstrect); + SDL_FreeSurface(src); +} + #include "graph2.c" diff --git a/modules/lib/graph.h b/modules/lib/graph.h index 3a2e0e7..65e879e 100644 --- a/modules/lib/graph.h +++ b/modules/lib/graph.h @@ -4,16 +4,22 @@ #include "config.h" #include "surface.h" -extern void gr_init(); +void gr_init(); -extern void gr_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv); -extern void gr_blend_screen(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height); -extern void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh); -extern void gr_fill_alpha_overborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d); -extern void gr_fill_alpha_underborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d); -extern void gr_copy_alpha_map_sprite(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh, int cl); -extern void gr_blend_alpha_wds_stretch2x2(surface_t *src1, int sx1, int sy1, surface_t *src2, int sx2, int sy2, int sw, int sh, surface_t *dst, int dx, int dy); -extern void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int sx2, int sy2, int sw, int sh, surface_t *dst, int dx, int dy); +void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh); +void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv); +void gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b); +void gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b); +void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh); +void gr_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv); +void gr_blend_screen(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height); +void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh); +void gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b, int lv); +void gr_fill_alpha_overborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d); +void gr_fill_alpha_underborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d); +void gr_copy_alpha_map_sprite(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh, int cl); +void gr_blend_alpha_wds_stretch2x2(surface_t *src1, int sx1, int sy1, surface_t *src2, int sx2, int sy2, int sw, int sh, surface_t *dst, int dx, int dy); +void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int sx2, int sy2, int sw, int sh, surface_t *dst, int dx, int dy); #endif /* __GRAPH_H__ */ diff --git a/modules/lib/graph_blend_screen.c b/modules/lib/graph_blend_screen.c deleted file mode 100644 index ef984d6..0000000 --- a/modules/lib/graph_blend_screen.c +++ /dev/null @@ -1,42 +0,0 @@ -// srcのsurfaceの一部をdstに飽和加算 - -#include - -#include "portab.h" -#include "system.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_blend_screen(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height) { - if (!gr_clip(src, &sx, &sy, &width, &height, dst, &dx, &dy)) return; - - uint8_t *sp = GETOFFSET_PIXEL(src, sx, sy); - uint8_t *dp = GETOFFSET_PIXEL(dst, dx, dy); - - switch(dst->depth) { - case 16: - for (int y = 0; y < height; y++) { - uint16_t *yls = (uint16_t *)(sp + y * src->bytes_per_line); - uint16_t *yld = (uint16_t *)(dp + y * dst->bytes_per_line); - for (int x = 0; x < width; x++) { - *yld = SUTURADD16(*yls, *yld); - yls++; yld++; - } - } - break; - - case 32: - case 24: - for (int y = 0; y < height; y++) { - uint32_t *yls = (uint32_t *)(sp + y * src->bytes_per_line); - uint32_t *yld = (uint32_t *)(dp + y * dst->bytes_per_line); - for (int x = 0; x < width; x++) { - *yld = SUTURADD24(*yls, *yld); - yls++; yld++; - } - } - break; - } -} - diff --git a/modules/lib/graph_copy.c b/modules/lib/graph_copy.c deleted file mode 100644 index 3a5e1c5..0000000 --- a/modules/lib/graph_copy.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * graph_copy.c pixel データのコピー - * - * Copyright (C) 1997-1998 Masaki Chikama (Wren) - * 1998- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ -/* $Id: graph_copy.c,v 1.2 2003/04/25 17:23:55 chikama Exp $ */ - -#include - -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -/** - * 指定の surface の領域を 別の surface の指定位置へコピーする - * pixelデータのみコピー - * - * @param dst: 転送先 surface - * @param dx: 転送先X座標 - * @param dy: 転送先Y座標 - * @param src: 転送元surface - * @param sx: 転送元X座標 - * @param sy: 転送元Y座標 - * @param sw: 転送幅 - * @param sh: 転送高さ - */ -void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) { - uint8_t *sp, *dp; - - if (src == NULL || dst == NULL) return; - if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return; - - sp = GETOFFSET_PIXEL(src, sx, sy); - dp = GETOFFSET_PIXEL(dst, dx, dy); - - if (sp == NULL || dp == NULL) return; - - if (src == dst) { - if (sy <= dy && dy < (sy + sh)) { - sp += (sh -1) * src->bytes_per_line; - dp += (sh -1) * dst->bytes_per_line; - while(sh--) { - memmove(dp, sp, sw * src->bytes_per_pixel); - sp -= src->bytes_per_line; - dp -= dst->bytes_per_line; - } - } else { - while(sh--) { - memmove(dp, sp, sw * src->bytes_per_pixel); - sp += src->bytes_per_line; - dp += dst->bytes_per_line; - } - } - } else { - while(sh--) { - memcpy(dp, sp, sw * src->bytes_per_pixel); - sp += src->bytes_per_line; - dp += dst->bytes_per_line; - } - } -} diff --git a/modules/lib/graph_copy_bright.c b/modules/lib/graph_copy_bright.c deleted file mode 100644 index 1b8edfc..0000000 --- a/modules/lib/graph_copy_bright.c +++ /dev/null @@ -1,55 +0,0 @@ -// 指定のsurface領域を明るさを lv/255 倍してコピー - -#include - -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) { - int x, y; - uint8_t *sp, *dp; - - if (!gr_clip(src, &sx, &sy, &width, &height, dst, &dx, &dy)) return; - - sp = GETOFFSET_PIXEL(src, sx, sy); - dp = GETOFFSET_PIXEL(dst, dx, dy); - - if (sp == NULL || dp == NULL) return; - - switch(dst->depth) { - case 16: - { - uint16_t *yls, *yld; - - for (y = 0; y < height; y++) { - yls = (uint16_t *)(sp + y * src->bytes_per_line); - yld = (uint16_t *)(dp + y * dst->bytes_per_line); - - for (x = 0; x < width; x++) { - *yld = ALPHALEVEL16(*yls, lv); - yls++; yld++; - } - } - } - break; - case 24: - case 32: - { - uint32_t *yls, *yld; - - for (y = 0; y < height; y++) { - yls = (uint32_t *)(sp + y * src->bytes_per_line); - yld = (uint32_t *)(dp + y * dst->bytes_per_line); - - for (x = 0; x < width; x++) { - *yld = ALPHALEVEL24(*yls, lv); - yls++; yld++; - } - } - break; - } - } -} - diff --git a/modules/lib/graph_fillrect.c b/modules/lib/graph_fillrect.c deleted file mode 100644 index 6f1f5d9..0000000 --- a/modules/lib/graph_fillrect.c +++ /dev/null @@ -1,52 +0,0 @@ -// fill rectangle - -#include -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) { - uint8_t *dp, *dp_; - int x, y; - - if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) { - return; - } - - dp = dp_ = GETOFFSET_PIXEL(dst, dx, dy); - - switch(dst->depth) { - case 8: - memset(dp, r, dw); - break; - - case 16: - { - uint16_t pic16 = PIX16(r, g, b); - - for (x = 0; x < dw; x++) { - *((uint16_t *)dp + x) = pic16; - } - - break; - } - case 24: - case 32: - { - uint32_t pic24 = PIX24(r, g, b); - - for (x = 0; x < dw; x++) { - *((uint32_t *)dp + x) = pic24; - } - - break; - } - } - - dp += dst->bytes_per_line; - for (y = 1; y < dh; y++) { - memcpy(dp, dp_, dw * dst->bytes_per_pixel); - dp += dst->bytes_per_line; - } -} diff --git a/modules/lib/graph_fillrect_acolor.c b/modules/lib/graph_fillrect_acolor.c deleted file mode 100644 index 5377492..0000000 --- a/modules/lib/graph_fillrect_acolor.c +++ /dev/null @@ -1,51 +0,0 @@ -// 指定の色(rgb)をブレンド率(lv)を指定して矩形塗りつぶし - -#include "config.h" - -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b, int lv) { - int x, y; - uint8_t *dp; - - if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) { - return; - } - - dp = GETOFFSET_PIXEL(dst, dx, dy); - - switch(dst->depth) { - case 16: - { - uint16_t pic16 = PIX16(r, g, b); - uint16_t *yls; - - for (y = 0; y < dh; y++) { - yls = (uint16_t *)(dp + y * dst->bytes_per_line); - for (x = 0; x < dw; x++) { - *yls = ALPHABLEND16(pic16, *yls, lv); - yls++; - } - } - } - break; - case 24: - case 32: - { - uint32_t pic24 = PIX24(r, g, b); - uint32_t *yls; - - for (y = 0; y < dh; y++) { - yls = (uint32_t *)(dp + y * dst->bytes_per_line); - for (x = 0; x < dw; x++) { - *yls = ALPHABLEND24(pic24, *yls, lv); - yls++; - } - } - break; - } - } -} diff --git a/modules/lib/graph_rect.c b/modules/lib/graph_rect.c deleted file mode 100644 index dcb77f3..0000000 --- a/modules/lib/graph_rect.c +++ /dev/null @@ -1,94 +0,0 @@ -// draw rectangle - -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) { - uint8_t *dp; - int i; - int col = 0; - - if (!gr_clip_xywh(dst, &x, &y, &w, &h)) { - return; - } - - dp = GETOFFSET_PIXEL(dst, x, y); - - switch(dst->depth) { - case 8: - col = r; break; - case 16: - col = PIX16(r, g, b); break; - case 24: - case 32: - col = PIX24(r, g, b); break; - } - - switch(dst->depth) { - case 8: - /* top */ - for (i = 0; i < w; i++) { - *((uint8_t *)dp + i) = col; - } - - /* side */ - h-=2; - for (i = 0; i < h; i++) { - dp += dst->bytes_per_line; - *((uint8_t *)dp) = col; - *((uint8_t *)dp + w - 1) = col; - } - - /* bottom */ - dp += dst->bytes_per_line; - for (i = 0; i < w; i++) { - *((uint8_t *)dp + i) = col; - } - break; - case 16: - /* top */ - for (i = 0; i < w; i++) { - *((uint16_t *)dp + i) = col; - } - - /* side */ - h-=2; - for (i = 0; i < h; i++) { - dp += dst->bytes_per_line; - *((uint16_t *)dp) = col; - *((uint16_t *)dp + w - 1) = col; - } - - /* bottom */ - dp += dst->bytes_per_line; - for (i = 0; i < w; i++) { - *((uint16_t *)dp + i) = col; - } - - break; - case 24: - case 32: - /* top */ - for (i = 0; i < w; i++) { - *((uint32_t *)dp + i) = col; - } - - /* side */ - h-=2; - for (i = 0; i < h; i++) { - dp += dst->bytes_per_line; - *((uint32_t *)dp) = col; - *((uint32_t *)dp + w - 1) = col; - } - - /* bottom */ - dp += dst->bytes_per_line; - for (i = 0; i < w; i++) { - *((uint32_t *)dp + i) = col; - } - - break; - } -} diff --git a/modules/lib/graph_stretch.c b/modules/lib/graph_stretch.c deleted file mode 100644 index df62290..0000000 --- a/modules/lib/graph_stretch.c +++ /dev/null @@ -1,88 +0,0 @@ -// 拡大・縮小 - -#include -#include - -#include "portab.h" -#include "surface.h" -#include "ngraph.h" -#include "ags.h" - -void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh) { - float a1, a2, xd, yd; - int *row, *col; - int x, y; - uint8_t *sp, *dp; - - if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) return; - if (!gr_clip_xywh(src, &sx, &sy, &sw, &sh)) return; - - sp = GETOFFSET_PIXEL(src, sx, sy); - dp = GETOFFSET_PIXEL(dst, dx, dy); - - a1 = (float)sw / (float)dw; - a2 = (float)sh / (float)dh; - - // src width と dst width が同じときに問題があるので+1 - row = calloc(dw+1, sizeof(int)); - // 1おおきくして初期化しないと col[dw-1]とcol[dw]が同じになる - // 可能性がある。 - col = calloc(dh+1, sizeof(int)); - - for (yd = 0.0, y = 0; y < dh; y++) { - col[y] = yd; yd += a2; - } - - for (xd = 0.0, x = 0; x < dw; x++) { - row[x] = xd; xd += a1; - } - - switch(dst->depth) { - case 16: - { - uint16_t *yls, *yld; - uint8_t *_yls, *_yld; - - for (y = 0; y < dh; y++) { - yls = (uint16_t *)(sp + *(y + col) * src->bytes_per_line); - yld = (uint16_t *)(dp + y * dst->bytes_per_line); - for (x = 0; x < dw; x++) { - *(yld + x) = *(yls + *(row + x)); - } - _yld = (uint8_t *)yld; - while (y < dh - 1 && *(col + y) == *(col + y + 1)) { - _yls = _yld; - _yld += dst->bytes_per_line; - memcpy(_yld, _yls, dw * 2); - y++; - } - } - break; - } - case 24: - case 32: - { - uint32_t *yls, *yld; - uint8_t *_yls, *_yld; - - for (y = 0; y < dh; y++) { - yls = (uint32_t *)(sp + *(y + col) * src->bytes_per_line); - yld = (uint32_t *)(dp + y * dst->bytes_per_line); - for (x = 0; x < dw; x++) { - *(yld + x) = *(yls+ *(row + x)); - } - _yld = (uint8_t *)yld; - while (y < dh - 1 && *(col + y) == *(col + y + 1)) { - _yls = _yld; - _yld += dst->bytes_per_line; - memcpy(_yld, _yls, dw * 4); - y++; - } - } - break; - } - } - - free(row); - free(col); -} diff --git a/modules/lib/ngraph.h b/modules/lib/ngraph.h index a81cbaf..fa586dd 100644 --- a/modules/lib/ngraph.h +++ b/modules/lib/ngraph.h @@ -5,6 +5,7 @@ #include "nact.h" #include "ags.h" #include "surface.h" +#include "graph.h" #define sf0 nact->ags.dib @@ -19,25 +20,9 @@ bool gr_clip_xywh(surface_t *ss, int *sx, int *sy, int *sw, int *sh); // 8bppのモノクロをcolでブレンド void gr_expandcolor_blend(surface_t *dst, int dx, int dy, struct SDL_Surface *src, int sx, int sy, int sw, int sh, int r, int g, int b); -/* in graph_fillrect.c */ -void gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b); - /* in graph_fillrect_amap.c */ void gr_fill_alpha_map(surface_t *dst, int dx, int dy, int dw, int dh, int lv); -/* in graph_fillrect_acolor.c */ -void gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b, int lv); - -/* in graph_rect.c */ -// 矩形枠描画 -void gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b); - -/* in graph_copy.c */ -void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh); - -/* in graph_copy_bright.c */ -void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv); - /* in graph_copy_amap.c */ void gr_copy_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh); @@ -58,10 +43,6 @@ void gr_draw_amap(surface_t *dst, int dx, int dy, uint8_t *src, int width, int h /* in gre_blend_useamap.c */ void gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, surface_t *alpha, int ax, int ay, int lv); -/* in graph_stretch.c */ -void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *src, int sx, int sy, int sw, int sh); - - /* in graph_cg.c */ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y); void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y); diff --git a/src/ags.h b/src/ags.h index 1b0d299..ee7d6cb 100644 --- a/src/ags.h +++ b/src/ags.h @@ -260,20 +260,12 @@ void ags_runEffect(int duration_ms, bool cancelable, ags_EffectStepFunc step, vo (((PIXG16((f)) - PIXG16((b))) * (a)) >> 8)+ PIXG16((b)),\ (((PIXB16((f)) - PIXB16((b))) * (a)) >> 8)+ PIXB16((b)))) -#define ALPHALEVEL16(p, lv) PIX16(((PIXR16(p) * (lv)) >> 8),\ - ((PIXG16(p) * (lv)) >> 8),\ - ((PIXB16(p) * (lv)) >> 8)) - #define WHITELEVEL16(p, lv) ALPHABLEND16(0xffff,p,lv) #define ALPHABLEND24(f, b, a) (PIX24((((PIXR24((f)) - PIXR24((b))) * (a)) >> 8) + PIXR24((b)),\ (((PIXG24((f)) - PIXG24((b))) * (a)) >> 8) + PIXG24((b)),\ (((PIXB24((f)) - PIXB24((b))) * (a)) >> 8) + PIXB24((b)))) -#define ALPHALEVEL24(p, lv) (PIX24(((PIXR24(p) * (lv)) >> 8),\ - ((PIXG24(p) * (lv)) >> 8),\ - ((PIXB24(p) * (lv)) >> 8))) - #define WHITELEVEL24(p, lv) ALPHABLEND24(0xffffffff, p, lv) #define SUTURADD16(pa, pb) PIX16(min(255,PIXR16(pa)+PIXR16(pb)), min(255, PIXG16(pa)+PIXG16(pb)), min(255, PIXB16(pa)+PIXB16(pb)));