]> icculus.org git repositories - btb/d2x.git/blob - 2d/pixel.c
More header unification...
[btb/d2x.git] / 2d / pixel.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13 /*
14  *
15  * Graphical routines for setting a pixel.
16  *
17  */
18
19 #include <conf.h>
20 #include "u_mem.h"
21
22 #include "gr.h"
23 #include "grdef.h"
24 #include "vesa.h"
25 #include "modex.h"
26 #ifdef OGL
27 #include "ogl_init.h"
28 #endif
29
30
31 #ifndef D1XD3D
32 void gr_upixel( int x, int y )
33 {
34         switch (TYPE)
35         {
36 #ifdef OGL
37                 case BM_OGL:
38                         ogl_upixelc(x,y,COLOR);
39                         return;
40 #endif
41         case BM_LINEAR:
42                 DATA[ ROWSIZE*y+x ] = COLOR;
43                 return;
44 #ifdef __ENV_DJGPP__
45         case BM_MODEX:
46                 gr_modex_setplane( (x+XOFFSET) & 3 );
47                 gr_video_memory[(ROWSIZE * (y+YOFFSET)) + ((x+XOFFSET)>>2)] = COLOR;
48                 return;
49         case BM_SVGA:
50                 gr_vesa_pixel( COLOR, (unsigned int)DATA + (unsigned int)ROWSIZE * y + x);
51                 return;
52 #endif
53         }
54 }
55 #endif
56
57 void gr_pixel( int x, int y )
58 {
59         if ((x<0) || (y<0) || (x>=GWIDTH) || (y>=GHEIGHT)) return;
60         gr_upixel (x, y);
61 }
62
63 #ifndef D1XD3D
64 inline void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color )
65 {
66         switch (bm->bm_type)
67         {
68 #ifdef OGL
69                 case BM_OGL:
70                         ogl_upixelc(bm->bm_x+x,bm->bm_y+y,color);
71                         return;
72 #endif
73         case BM_LINEAR:
74                 bm->bm_data[ bm->bm_rowsize*y+x ] = color;
75                 return;
76 #ifdef __ENV_DJGPP__
77         case BM_MODEX:
78                 x += bm->bm_x;
79                 y += bm->bm_y;
80                 gr_modex_setplane( x & 3 );
81                 gr_video_memory[(bm->bm_rowsize * y) + (x/4)] = color;
82                 return;
83         case BM_SVGA:
84                 gr_vesa_pixel(color,(unsigned int)bm->bm_data + (unsigned int)bm->bm_rowsize * y + x);
85                 return;
86 #endif
87         }
88 }
89 #endif
90
91 void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color )
92 {
93         if ((x<0) || (y<0) || (x>=bm->bm_w) || (y>=bm->bm_h)) return;
94         gr_bm_upixel (bm, x, y, color);
95 }
96
97