]> icculus.org git repositories - btb/d2x.git/blob - 2d/pixel.c
Imported from d1x
[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 #ifdef HAVE_CONFIG_H
20 #include <conf.h>
21 #endif
22
23 #include "u_mem.h"
24
25 #include "gr.h"
26 #include "grdef.h"
27 #include "vesa.h"
28 #include "modex.h"
29 #ifdef OGL
30 #include "ogl_init.h"
31 #endif
32
33
34 #ifndef D1XD3D
35 void gr_upixel( int x, int y )
36 {
37         switch (TYPE)
38         {
39 #ifdef OGL
40                 case BM_OGL:
41                         ogl_upixelc(x,y,COLOR);
42                         return;
43 #endif
44         case BM_LINEAR:
45                 DATA[ ROWSIZE*y+x ] = COLOR;
46                 return;
47 #ifdef __DJGPP__
48         case BM_MODEX:
49                 gr_modex_setplane( (x+XOFFSET) & 3 );
50                 gr_video_memory[(ROWSIZE * (y+YOFFSET)) + ((x+XOFFSET)>>2)] = COLOR;
51                 return;
52         case BM_SVGA:
53                 gr_vesa_pixel( COLOR, (unsigned int)DATA + (unsigned int)ROWSIZE * y + x);
54                 return;
55 #endif
56         }
57 }
58 #endif
59
60 void gr_pixel( int x, int y )
61 {
62         if ((x<0) || (y<0) || (x>=GWIDTH) || (y>=GHEIGHT)) return;
63         gr_upixel (x, y);
64 }
65
66 #ifndef D1XD3D
67 inline void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color )
68 {
69         switch (bm->bm_type)
70         {
71 #ifdef OGL
72                 case BM_OGL:
73                         ogl_upixelc(bm->bm_x+x,bm->bm_y+y,color);
74                         return;
75 #endif
76         case BM_LINEAR:
77                 bm->bm_data[ bm->bm_rowsize*y+x ] = color;
78                 return;
79 #ifdef __DJGPP__
80         case BM_MODEX:
81                 x += bm->bm_x;
82                 y += bm->bm_y;
83                 gr_modex_setplane( x & 3 );
84                 gr_video_memory[(bm->bm_rowsize * y) + (x/4)] = color;
85                 return;
86         case BM_SVGA:
87                 gr_vesa_pixel(color,(unsigned int)bm->bm_data + (unsigned int)bm->bm_rowsize * y + x);
88                 return;
89 #endif
90         }
91 }
92 #endif
93
94 void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color )
95 {
96         if ((x<0) || (y<0) || (x>=bm->bm_w) || (y>=bm->bm_h)) return;
97         gr_bm_upixel (bm, x, y, color);
98 }
99
100