BOX.C 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/box.c $
  15. * $Revision: 1.3 $
  16. * $Author: john $
  17. * $Date: 1994/11/18 22:50:19 $
  18. *
  19. * Graphical routines for drawing boxes.
  20. *
  21. * $Log: box.c $
  22. * Revision 1.3 1994/11/18 22:50:19 john
  23. * Changed shorts to ints in parameters.
  24. *
  25. * Revision 1.2 1993/10/15 16:23:31 john
  26. * y
  27. *
  28. * Revision 1.1 1993/09/08 11:43:11 john
  29. * Initial revision
  30. *
  31. *
  32. */
  33. #include "mem.h"
  34. #include "gr.h"
  35. #include "grdef.h"
  36. void gr_ubox0(int left,int top,int right,int bot)
  37. {
  38. int i, d;
  39. unsigned char * ptr1;
  40. unsigned char * ptr2;
  41. ptr1 = DATA + ROWSIZE *top+left;
  42. ptr2 = ptr1;
  43. d = right - left;
  44. for (i=top; i<=bot; i++ )
  45. {
  46. ptr2[0] = COLOR;
  47. ptr2[d] = COLOR;
  48. ptr2 += ROWSIZE;
  49. }
  50. ptr2 = ptr1;
  51. d = (bot - top)*ROWSIZE;
  52. for (i=1; i<(right-left); i++ )
  53. {
  54. ptr2[i+0] = COLOR;
  55. ptr2[i+d] = COLOR;
  56. }
  57. }
  58. void gr_box0(int left,int top,int right,int bot)
  59. {
  60. if (top > MAXY ) return;
  61. if (bot < MINY ) return;
  62. if (left > MAXX ) return;
  63. if (right < MINX ) return;
  64. if (top < MINY) top = MINY;
  65. if (bot > MAXY ) bot = MAXY;
  66. if (left < MINX) left = MINX;
  67. if (right > MAXX ) right = MAXX;
  68. gr_ubox0(left,top,right,bot);
  69. }
  70. void gr_ubox12(int left,int top,int right,int bot)
  71. {
  72. int i;
  73. for (i=top; i<=bot; i++ )
  74. {
  75. gr_upixel( left, i );
  76. gr_upixel( right, i );
  77. }
  78. gr_uscanline( left, right, top );
  79. gr_uscanline( left, right, bot );
  80. }
  81. void gr_box12(int left,int top,int right,int bot)
  82. {
  83. if (top > MAXY ) return;
  84. if (bot < MINY ) return;
  85. if (left > MAXX ) return;
  86. if (right < MINX ) return;
  87. if (top < MINY) top = MINY;
  88. if (bot > MAXY ) bot = MAXY;
  89. if (left < MINX) left = MINX;
  90. if (right > MAXX ) right = MAXX;
  91. gr_ubox12(left, top, right, bot );
  92. }
  93. void gr_ubox(int left,int top,int right,int bot)
  94. {
  95. if (TYPE==BM_LINEAR)
  96. gr_ubox0( left, top, right, bot );
  97. else if ( TYPE == BM_MODEX )
  98. gr_ubox12( left, top, right, bot );
  99. else
  100. gr_ubox12( left, top, right, bot );
  101. }
  102. void gr_box(int left,int top,int right,int bot)
  103. {
  104. if (TYPE==BM_LINEAR)
  105. gr_box0( left, top, right, bot );
  106. else if ( TYPE == BM_MODEX )
  107. gr_box12( left, top, right, bot );
  108. else
  109. gr_ubox12( left, top, right, bot );
  110. }
  111.