home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / 2d / pixel.c < prev    next >
Text File  |  1998-06-08  |  3KB  |  123 lines

  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.  * $Source: f:/miner/source/2d/rcs/pixel.c $
  15.  * $Revision: 1.5 $
  16.  * $Author: john $
  17.  * $Date: 1994/11/18 22:50:26 $
  18.  *
  19.  * Graphical routines for setting a pixel.
  20.  *
  21.  * $Log: pixel.c $
  22.  * Revision 1.5  1994/11/18  22:50:26  john
  23.  * Changed shorts to ints in parameters.
  24.  * 
  25.  * Revision 1.4  1993/10/15  16:22:26  john
  26.  * *** empty log message ***
  27.  * 
  28.  * Revision 1.3  1993/09/29  17:31:27  john
  29.  * optimized vesa pixel stuff
  30.  * 
  31.  * Revision 1.2  1993/09/29  16:15:15  john
  32.  * optimized
  33.  * 
  34.  * Revision 1.1  1993/09/08  11:44:09  john
  35.  * Initial revision
  36.  * 
  37.  *
  38.  */
  39.  
  40. #include "mem.h"
  41.  
  42. #include "gr.h"
  43. #include "grdef.h"
  44.  
  45.  
  46. void gr_upixel( int x, int y )
  47. {
  48.     switch (TYPE)
  49.     {
  50.     case BM_LINEAR:
  51.         DATA[ ROWSIZE*y+x ] = COLOR;
  52.         return;
  53.     case BM_MODEX:
  54.         gr_modex_setplane( (x+XOFFSET) & 3 );
  55.         gr_video_memory[(ROWSIZE * (y+YOFFSET)) + ((x+XOFFSET)>>2)] = COLOR;
  56.         return;
  57.     case BM_SVGA:
  58.         gr_vesa_pixel( COLOR, (unsigned int)DATA + (unsigned int)ROWSIZE * y + x);
  59.         return;
  60.     }
  61. }
  62.  
  63. void gr_pixel( int x, int y )
  64. {
  65.     if ((x<0) || (y<0) || (x>=WIDTH) || (y>=HEIGHT)) return;
  66.  
  67.     switch (TYPE)
  68.     {
  69.     case BM_LINEAR:
  70.         DATA[ ROWSIZE*y+x ] = COLOR;
  71.         return;
  72.     case BM_MODEX:
  73.         gr_modex_setplane( (x+XOFFSET) & 3 );
  74.         gr_video_memory[(ROWSIZE * (y+YOFFSET)) + ((x+XOFFSET)>>2)] = COLOR;
  75.         return;
  76.     case BM_SVGA:
  77.         gr_vesa_pixel( COLOR, (unsigned int)DATA + (unsigned int)ROWSIZE * y + x);
  78.         return;
  79.     }
  80. }
  81.  
  82. void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color )
  83. {
  84.     switch (bm->bm_type)
  85.     {
  86.     case BM_LINEAR:
  87.         bm->bm_data[ bm->bm_rowsize*y+x ] = color;
  88.         return;
  89.     case BM_MODEX:
  90.         x += bm->bm_x;
  91.         y += bm->bm_y;
  92.         gr_modex_setplane( x & 3 );
  93.         gr_video_memory[(bm->bm_rowsize * y) + (x/4)] = color;
  94.         return;
  95.     case BM_SVGA:
  96.         gr_vesa_pixel(color,(unsigned int)bm->bm_data + (unsigned int)bm->bm_rowsize * y + x);
  97.         return;
  98.     }
  99. }
  100.  
  101. void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color )
  102. {
  103.     if ((x<0) || (y<0) || (x>=bm->bm_w) || (y>=bm->bm_h)) return;
  104.  
  105.     switch (bm->bm_type)
  106.     {
  107.     case BM_LINEAR:
  108.         bm->bm_data[ bm->bm_rowsize*y+x ] = color;
  109.         return;
  110.     case BM_MODEX:
  111.         x += bm->bm_x;
  112.         y += bm->bm_y;
  113.         gr_modex_setplane( x & 3 );
  114.         gr_video_memory[(bm->bm_rowsize * y) + (x/4)] = color;
  115.         return;
  116.     case BM_SVGA:
  117.         gr_vesa_pixel(color,(unsigned int)bm->bm_data + (unsigned int)bm->bm_rowsize * y + x);
  118.         return;
  119.     }
  120. }
  121.  
  122. 
  123.