Skip to content

Commit

Permalink
Remove gre_Blend() and gre_BlendScreen()
Browse files Browse the repository at this point in the history
  • Loading branch information
kichikuou committed Jan 10, 2025
1 parent 51eca5c commit 28e6858
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 136 deletions.
2 changes: 0 additions & 2 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ add_library(modules STATIC
lib/graph_stretch.c
lib/graph_cg.c
lib/gre_blend_useamap.c
lib/gre_blend.c
lib/gre_blend_screen.c
nDEMO/nDEMO.c
nDEMOE/nDEMOE.c
oDEMO/oDEMO.c
Expand Down
3 changes: 2 additions & 1 deletion modules/NIGHTDLL/nt_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "cg.h"
#include "ags.h"
#include "surface.h"
#include "graph.h"
#include "ngraph.h"
#include "night.h"
#include "sprite.h"
Expand Down Expand Up @@ -195,7 +196,7 @@ void nt_gr_screencg(int no, int x, int y) {

sf = sf_loadcg_no(no -1);

gre_BlendScreen(sf0, x, y, sf0, x, y, sf, 0, 0, sf->width, sf->height);
gr_blend_screen(sf0, x, y, sf, 0, 0, sf->width, sf->height);

ags_updateArea(x, y, sf->width, sf->height);

Expand Down
10 changes: 3 additions & 7 deletions modules/NIGHTDLL/sprite_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ags.h"
#include "graphics.h"
#include "surface.h"
#include "graph.h"
#include "ngraph.h"
#include "sprite.h"

Expand Down Expand Up @@ -89,10 +90,7 @@ int nt_sp_draw2(sprite_t *sp, cginfo_t *cg, MyRectangle *r) {
gr_copy(sf0, dx, dy, cg->sf, sx, sy, w, h);
} else if (sp->blendrate > 0) {
// alpha値指定がある場合
gre_Blend(sf0, dx, dy,
sf0, dx, dy,
cg->sf, sx, sy, w, h,
sp->blendrate);
gr_blend(sf0, dx, dy, cg->sf, sx, sy, w, h, sp->blendrate);
}
}

Expand Down Expand Up @@ -132,9 +130,7 @@ int nt_sp_draw_scg(sprite_t *sp, MyRectangle *r) {
dx += r->x;
dy += r->y;

gre_BlendScreen(sf0, dx, dy,
sf0, dx, dy,
cg->sf, sx, sy, w, h);
gr_blend_screen(sf0, dx, dy, cg->sf, sx, sy, w, h);

SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, dx=%d, dy=%d",
sp->no, sx, sy, w, h, dx, dy);
Expand Down
6 changes: 2 additions & 4 deletions modules/SACT/sprite_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "graphics.h"
#include "sact.h"
#include "surface.h"
#include "graph.h"
#include "ngraph.h"
#include "sprite.h"

Expand Down Expand Up @@ -130,10 +131,7 @@ int sp_draw2(sprite_t *sp, cginfo_t *cg) {
gr_copy(sf0, dx, dy, cg->sf, sx, sy, w, h);
} else if (sp->blendrate > 0) {
// alpha値指定がある場合
gre_Blend(sf0, dx, dy,
sf0, dx, dy,
cg->sf, sx, sy, w, h,
sp->blendrate);
gr_blend(sf0, dx, dy, cg->sf, sx, sy, w, h, sp->blendrate);
}
}

Expand Down
29 changes: 28 additions & 1 deletion modules/lib/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,34 @@ void gr_init() {

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;
gre_Blend(dst, dx, dy, dst, dx, dy, src, sx, sy, width, height, lv);

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 = ALPHABLEND16(*yls, *yld, lv);
yls++; yld++;
}
}
break;

case 24:
case 32:
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 = ALPHABLEND24(*yls, *yld, lv);
yls++; yld++;
}
}
break;
}
}

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) {
Expand Down
1 change: 1 addition & 0 deletions modules/lib/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
extern 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);
Expand Down
36 changes: 30 additions & 6 deletions modules/lib/graph_blend_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@
#include "ngraph.h"
#include "ags.h"

int gr_blend_screen(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int w, int h) {

if (src == NULL || dst == NULL) return NG;
if (!gr_clip(src, &sx, &sy, &w, &h, dst, &dx, &dy)) return NG;

return gre_BlendScreen(dst, dx, dy, dst, dx, dy, src, sx, sy, w, 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;
}
}

55 changes: 0 additions & 55 deletions modules/lib/gre_blend.c

This file was deleted.

54 changes: 0 additions & 54 deletions modules/lib/gre_blend_screen.c

This file was deleted.

6 changes: 0 additions & 6 deletions modules/lib/ngraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ extern int gr_draw_amap(surface_t *dst, int dx, int dy, uint8_t *src, int width,
/* in gre_blend_useamap.c */
extern int 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 gre_blend.c */
extern int gre_Blend(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, int lv);

/* in gre_blend_screen.c */
extern int gre_BlendScreen(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);

/* in graph_stretch.c */
extern 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);

Expand Down

0 comments on commit 28e6858

Please sign in to comment.