File: effectcopy.c

package info (click to toggle)
xsystem35 2.17.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 8,096 kB
  • sloc: ansic: 38,159; java: 4,085; xml: 249; sh: 134; python: 15; makefile: 12
file content (51 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "config.h"

#include <stdio.h>

#include "portab.h"
#include "system.h"
#include "surface.h"
#include "effect.h"
#include "ags.h"
#include "input.h"
#include "graph.h"
#include "ngraph.h"

void gpx_effect(int no,
		int wx, int wy,
		surface_t *dst, int dx, int dy,
		surface_t *src, int sx, int sy,
		int width, int height,
		int time,
		int *endtype) {
	surface_t *write = nact->ags.dib;
	if (!gr_clip(dst, &dx, &dy, &width, &height, write, &wx, &wy)) return;
	if (!gr_clip(src, &sx, &sy, &width, &height, write, &wx, &wy)) return;

	*endtype = 0;

	enum effect_type type = from_sact_effect(no);
	if (type == EFFECT_INVALID) {
		WARNING("Unimplemented effect %d", no);
		type = EFFECT_CROSSFADE;
	}
	SDL_Rect rect = { wx, wy, width, height };
	struct effect *eff = effect_init(&rect, dst, dx, dy, src, sx, sy, type);
	if (!time)
		time = (no == SACT_EFFECT_CROSSFADE_DOWN || no == SACT_EFFECT_CROSSFADE_UP) ? 1150 : 2700;
	ags_runEffect(time, false, (ags_EffectStepFunc)effect_step, eff);
	effect_finish(eff);

	switch (no) {
	case SACT_EFFECT_FADEOUT:
		gr_fill(write, wx, wy, width, height, 0, 0, 0);
		break;
	case SACT_EFFECT_WHITEOUT:
		gr_fill(write, wx, wy, width, height, 255, 255, 255);
		break;
	default:
		gr_copy(write, wx, wy, src, sx, sy, width, height);
		break;
	}
	ags_updateArea(wx, wy, width, height);
}