]> icculus.org git repositories - btb/d2x.git/blob - include/grdef.h
added gr_rle_expand_scanline_generic_masked from d2src
[btb/d2x.git] / include / grdef.h
1 /* $Id: grdef.h,v 1.5 2002-09-04 22:21:25 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Internal definitions for graphics lib.
18  *
19  * Old Log:
20  * Revision 1.5  1995/09/14  15:36:33  allender
21  * added stuff for 68k version
22  *
23  * Revision 1.4  1995/07/05  16:10:57  allender
24  * gr_linear_movsd prototype changes
25  *
26  * Revision 1.3  1995/04/19  14:39:28  allender
27  * changed function prototype
28  *
29  * Revision 1.2  1995/04/18  09:49:53  allender
30  * *** empty log message ***
31  *
32  * Revision 1.1  1995/03/09  09:04:56  allender
33  * Initial revision
34  *
35  *
36  * --- PC RCS information ---
37  * Revision 1.8  1994/05/06  12:50:09  john
38  * Added supertransparency; neatend things up; took out warnings.
39  *
40  * Revision 1.7  1994/01/25  11:40:29  john
41  * Added gr_check_mode function.
42  *
43  * Revision 1.6  1993/10/15  16:22:53  john
44  * y
45  *
46  * Revision 1.5  1993/09/29  17:31:00  john
47  * added gr_vesa_pixel
48  *
49  * Revision 1.4  1993/09/29  16:14:43  john
50  * added global canvas descriptors.
51  *
52  * Revision 1.3  1993/09/08  17:38:02  john
53  * Looking for errors
54  *
55  * Revision 1.2  1993/09/08  15:54:29  john
56  * *** empty log message ***
57  *
58  * Revision 1.1  1993/09/08  11:37:57  john
59  * Initial revision
60  *
61  */
62
63 void gr_init_bitmap_alloc( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline);
64 void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, int x, int y, int w, int h );
65 void gr_init_bitmap( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline, unsigned char * data );
66
67 extern void gr_set_buffer(int w, int h, int r, int (*buffer_func)());
68
69 extern void gr_pal_setblock( int start, int n, unsigned char * palette );
70 extern void gr_pal_getblock( int start, int n, unsigned char * palette );
71 extern void gr_pal_setone( int index, unsigned char red, unsigned char green, unsigned char blue );
72
73 void gr_linear_movsb( ubyte * source, ubyte * dest, int nbytes);
74 void gr_linear_movsw( ubyte * source, ubyte * dest, int nbytes);
75 void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes);
76
77 extern unsigned int gr_var_color;
78 extern unsigned int gr_var_bwidth;
79 extern unsigned char * gr_var_bitmap;
80
81 static void gr_linear_movsd( ubyte * source, ubyte * dest, int nbytes);
82
83 #ifndef NO_ASM
84 // This code aligns edi so that the destination is aligned to a dword boundry before rep movsd
85
86 #ifdef __WATCOMC__
87
88 #pragma aux gr_linear_movsd parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \
89 " cld "                                 \
90 " mov           ebx, ecx        "       \
91 " mov           eax, edi"       \
92 " and           eax, 011b"      \
93 " jz            d_aligned"      \
94 " mov           ecx, 4"         \
95 " sub           ecx, eax"       \
96 " sub           ebx, ecx"       \
97 " rep           movsb"          \
98 " d_aligned: "                  \
99 " mov           ecx, ebx"       \
100 " shr           ecx, 2"         \
101 " rep   movsd"          \
102 " mov           ecx, ebx"       \
103 " and   ecx, 11b"       \
104 " rep   movsb";
105
106 #elif defined __GNUC__
107
108 static inline void gr_linear_movsd(ubyte *src, ubyte *dest, int num_pixels) {
109         int dummy[3];
110  __asm__ __volatile__ (
111 " cld;"
112 " movl      %%ecx, %%ebx;"
113 " movl      %%edi, %%eax;"
114 " andl      $3, %%eax;"
115 " jz        0f;"
116 " movl      $4, %%ecx;"
117 " subl      %%eax,%%ecx;"
118 " subl      %%ecx,%%ebx;"
119 " rep;      movsb;"
120 "0: ;"
121 " movl      %%ebx, %%ecx;"
122 " shrl      $2, %%ecx;"
123 " rep;      movsl;"
124 " movl      %%ebx, %%ecx;"
125 " andl      $3, %%ecx;"
126 " rep;      movsb"
127  : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2])
128  : "0" (src), "1" (dest), "2" (num_pixels)
129  :      "%eax", "%ebx");
130 }
131
132 #elif defined _MSC_VER
133
134 __inline void gr_linear_movsd(ubyte *src, ubyte *dest, int num_pixels)
135 {
136  __asm {
137    mov esi, [src]
138    mov edi, [dest]
139    mov ecx, [num_pixels]
140    cld
141    mov ebx, ecx
142    mov eax, edi
143    and eax, 011b
144    jz d_aligned
145    mov ecx, 4
146    sub ecx, eax
147    sub ebx, ecx
148    rep movsb
149 d_aligned:
150    mov ecx, ebx
151    shr ecx, 2
152    rep movsd
153    mov ecx, ebx
154    and ecx, 11b
155    rep movsb
156  }
157 }
158
159 #endif
160
161 #endif          // ifdef NO_ASM
162
163 void gr_linear_line( int x0, int y0, int x1, int y1);
164
165 extern unsigned int Table8to32[256];
166
167 #ifdef __MSDOS__
168 extern unsigned char * gr_video_memory;
169 #endif
170
171
172 #define MINX    0
173 #define MINY    0
174 #define MAXX    (GWIDTH-1)
175 #define MAXY    (GHEIGHT-1)
176 #define TYPE    grd_curcanv->cv_bitmap.bm_type
177 #define DATA    grd_curcanv->cv_bitmap.bm_data
178 #define XOFFSET grd_curcanv->cv_bitmap.bm_x
179 #define YOFFSET grd_curcanv->cv_bitmap.bm_y
180 #define ROWSIZE grd_curcanv->cv_bitmap.bm_rowsize
181 #define COLOR   grd_curcanv->cv_color
182
183 void order( int *x1, int *x2 );