ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aautil.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * aautil.h --- helpers for anti-aliasing routines for Allegro
24  *
25  * This file is gift-ware. This file is given to you freely
26  * as a gift. You may use, modify, redistribute, and generally hack
27  * it about in any way you like, and you do not have to give anyone
28  * anything in return.
29  *
30  * I do not accept any responsibility for any effects, adverse or
31  * otherwise, that this code may have on just about anything that
32  * you can think of. Use it at your own risk.
33  *
34  * Copyright (C) 1998, 1999 Michael Bukin
35  */
36 
37 #ifndef AGS_LIB_AASTR_AAUTIL_H
38 #define AGS_LIB_AASTR_AAUTIL_H
39 
40 #include "ags/lib/allegro.h"
41 
42 namespace AGS3 {
43 
44 /*
45  * Change aa_BITS, and never aa_SIZE or aa_MASK.
46  * 8 or 4 are probably the fastest for i386+.
47  * Recompile the package after changing aa_BITS.
48  */
49 #ifdef aa_BITS
50 #undef aa_BITS
51 #endif
52 #define aa_BITS 8
53 
54 #if ((aa_BITS < 0) || (aa_BITS > 12))
55 #error aa_BITS must be (0 <= aa_BITS <= 12)
56 #endif
57 
58 #define aa_SIZE (1UL << aa_BITS)
59 #define aa_MASK (aa_SIZE - 1)
60 
61 #define aa_MAX_SIZE (1UL << 12)
62 #define aa_MAX_NUM (aa_MAX_SIZE * aa_MAX_SIZE)
63 
64 
65 /* Prepare Bresenham line parameters. */
66 #define aa_PREPARE(inc,dd,i1,i2,_yw,_xw) \
67  { \
68  int xw = (_xw); \
69  int yw = (_yw); \
70  \
71  if ((xw == 0) || ((yw < xw) && (yw > -xw))) { \
72  (inc) = 0; \
73  } \
74  else { \
75  (inc) = yw / xw; \
76  yw %= xw; \
77  } \
78  if (yw < 0) { \
79  (inc) -= 1; \
80  yw += xw; \
81  } \
82  (i2) = ((dd) = ((i1) = 2 * yw) - xw) - xw; \
83  }
84 
85 /* Advance to the next point. */
86 #define aa_ADVANCE(y,inc,dd,i1,i2) \
87  { \
88  if ((dd) >= 0) \
89  (y) += (inc) + 1, (dd) += (i2); \
90  else \
91  (y) += (inc), (dd) += (i1); \
92  }
93 
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
99 /* Prepare offsets for direct access to 24bpp bitmap. */
100 void _aa_prepare_for_24bpp(void);
101 
102 /* Add r,g,b values from source bitmap. */
103 void _aa_add_rgb8(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
104 #ifdef ALLEGRO_COLOR16
105 void _aa_add_rgb15(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
106 void _aa_add_rgb16(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
107 #endif
108 #ifdef ALLEGRO_COLOR24
109 void _aa_add_rgb24(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
110 #endif
111 #ifdef ALLEGRO_COLOR32
112 void _aa_add_rgb32(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
113 #endif
114 
115 /* Put pixel to destination bitmap. */
116 void _aa_put_rgb8(byte *addr, int _x);
117 #ifdef ALLEGRO_COLOR16
118 void _aa_put_rgb15(byte *addr, int _x);
119 void _aa_put_rgb16(byte *addr, int _x);
120 #endif
121 #ifdef ALLEGRO_COLOR24
122 void _aa_put_rgb24(byte *addr, int _x);
123 #endif
124 #ifdef ALLEGRO_COLOR32
125 void _aa_put_rgb32(byte *addr, int _x);
126 #endif
127 
128 /* Add r,g,b and transparency values from source bitmap. */
129 void _aa_masked_add_rgb8(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
130  uint32_t _num);
131 #ifdef ALLEGRO_COLOR16
132 void _aa_masked_add_rgb15(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
133  uint32_t _num);
134 void _aa_masked_add_rgb16(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
135  uint32_t _num);
136 #endif
137 #ifdef ALLEGRO_COLOR24
138 void _aa_masked_add_rgb24(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
139  uint32_t _num);
140 #endif
141 #ifdef ALLEGRO_COLOR32
142 void _aa_masked_add_rgb32(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
143  uint32_t _num);
144 #endif
145 
146 /* Put masked pixel to destination bitmap. */
147 void _aa_masked_put_rgb8(byte *addr, int _x);
148 #ifdef ALLEGRO_COLOR16
149 void _aa_masked_put_rgb15(byte *addr, int _x);
150 void _aa_masked_put_rgb16(byte *addr, int _x);
151 #endif
152 #ifdef ALLEGRO_COLOR24
153 void _aa_masked_put_rgb24(byte *addr, int _x);
154 #endif
155 #ifdef ALLEGRO_COLOR32
156 void _aa_masked_put_rgb32(byte *addr, int _x);
157 #endif
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 } // namespace AGS3
164 
165 #endif
Definition: ags.h:40