annotate dmunscaledblit.h @ 100:f16d102dbbac

Add a function for setting bitmapped font palette.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Oct 2012 20:33:01 +0300
parents 0430f484641b
children 79dac918c81e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * DMLib
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * -- Unscaled sprite / surface blitting function template
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * (C) Copyright 2012 Tecnic Software productions (TNSP)
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 */
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 int DM_BLITFUNC_NAME (SDL_Surface *src,
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 const int x0, const int y0,
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 SDL_Surface *dst
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #ifdef DM_BLITFUNC_ARGS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 DM_BLITFUNC_ARGS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #endif
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 )
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 {
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 int yc;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 DMQValue xr, yr;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 #ifdef DM_BLITFUNC_VARS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 DM_BLITFUNC_VARS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 #endif
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 // Clip coordinates
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 if (dmUnscaledClipCoord(&xr, x0, src->w,
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w)
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 ||
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 dmUnscaledClipCoord(&yr, y0, src->h,
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h))
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 return -1;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 #ifdef DM_BLITFUNC_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 DM_BLITFUNC_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #endif
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 const int srcadd = src->pitch / DM_BLITFUNC_SRC_BYTES;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 const int dstadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES);
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (yr.voffs * src->pitch) / DM_BLITFUNC_SRC_BYTES;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 for (yc = yr.v0; yc < yr.v1; yc++)
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 int xv, xc;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #ifdef DM_BLITFUNC_INNER_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 DM_BLITFUNC_INNER_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 #endif
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 for (xv = xr.voffs, xc = xr.v0; xc < xr.v1; xc++, xv++)
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 {
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 DM_BLITFUNC_INNER
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 }
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 sp += srcadd;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 dp += dstadd;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 }
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 #ifdef DM_BLITFUNC_FINISH
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 DM_BLITFUNC_FINISH
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 #endif
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 return 0;
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 }
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 #undef DM_BLITFUNC_NAME
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 #undef DM_BLITFUNC_ARGS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 #undef DM_BLITFUNC_SRC_BYTES
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 #undef DM_BLITFUNC_DST_BYTES
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 #undef DM_BLITFUNC_SRC_TYPE
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 #undef DM_BLITFUNC_DST_TYPE
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 #undef DM_BLITFUNC_VARS
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 #undef DM_BLITFUNC_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 #undef DM_BLITFUNC_INNER_INIT
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 #undef DM_BLITFUNC_INNER
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 #undef DM_BLITFUNC_FINISH