home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / IYONIX / MANICMINER / SOURCE.ZIP / manicminer-1.6.3 / gfxlibs / svgalib / c / gfx next >
Encoding:
Text File  |  2000-12-01  |  2.0 KB  |  108 lines

  1. #include "../../manic.h"
  2. #include "common.h"
  3. #include "../gfx.h"
  4. #include <unistd.h>
  5.  
  6. #define DELAY 17500
  7.  
  8. void
  9. mm_gfx_putpixel2 (uint_fast16_t x, uint_fast16_t y, uint_fast8_t data)
  10. {
  11.   gl_setpixel (x, y, data);
  12. }
  13.  
  14. void
  15. mm_gfx_putpixel (uint_fast16_t x, uint_fast16_t y, uint_fast8_t data)
  16. {
  17.   gl_setpixel (x + xoffset, y + yoffset, data);
  18. }
  19.  
  20. uint_fast8_t
  21. mm_gfx_getpixel (uint_fast16_t x, uint_fast16_t y)
  22. {
  23.   return (gl_getpixel (x + xoffset, y + yoffset));
  24. }
  25.  
  26. uint_fast8_t
  27. mm_gfx_getpixel2 (uint_fast16_t x, uint_fast16_t y)
  28. {
  29.   return (gl_getpixel (x, y));
  30. }
  31.  
  32. void
  33. mm_gfx_cls (uint_fast8_t col)
  34. {
  35.   gl_clearscreen (col);
  36. }
  37.  
  38. void
  39. mm_gfx_flush (void)
  40. {
  41.   mm_gfx_waitvr ();
  42.   gl_copyscreen (&physicalscreen);
  43. }
  44.  
  45. void
  46. mm_gfx_waitvr (void)
  47. {
  48. #ifdef WAITVR
  49.   vga_waitretrace ();
  50.   if (vert_frequency == 120)
  51.     vga_waitretrace ();
  52. #else
  53.   struct timeval tv2;
  54.   int l;
  55.  
  56.   gettimeofday (&tv2, NULL);
  57.   frame_num++;
  58.   l = (tv2.tv_sec - tv.tv_sec) * 1000000 +
  59.     tv2.tv_usec - tv.tv_usec - frame_num * DELAY;
  60.   if (l > 0)
  61.     frame_num += l / DELAY;
  62.   else if (l > -DELAY)
  63.     usleep (-l);
  64. #endif
  65. }
  66.  
  67. void
  68. mm_gfx_fillbox (uint_fast16_t xpos, uint_fast16_t ypos,
  69.         uint_fast16_t width, uint_fast16_t height, uint_fast8_t col)
  70. {
  71.   uint_fast16_t x, y;
  72.   uint_fast16_t origx = xpos;
  73.  
  74.   for (y = 0; y < height; y++, ypos++) {
  75.     for (x = 0; x < width; x++)
  76.       gl_setpixel (xpos++ + xoffset, ypos + yoffset, col);
  77.     xpos = origx;
  78.   }
  79. }
  80.  
  81. void
  82. mm_gfx_fillbox2 (uint_fast16_t xpos, uint_fast16_t ypos,
  83.          uint_fast16_t width, uint_fast16_t height, uint_fast8_t col)
  84. {
  85.   uint_fast16_t x, y;
  86.   uint_fast16_t origx = xpos;
  87.  
  88.   for (y = 0; y < height; y++, ypos++) {
  89.     for (x = 0; x < width; x++, xpos++)
  90.       gl_setpixel (xpos, ypos, col);
  91.     xpos = origx;
  92.   }
  93. }
  94.  
  95. void
  96. mm_gfx_palset (uint_least8_t * palette)
  97. {
  98.   int_fast16_t i;
  99.   int_least8_t svgapal[256][3];
  100.  
  101.   for (i = 0; i < 256; i++) {
  102.     svgapal[i][0] = palette[(i * 3)];
  103.     svgapal[i][1] = palette[(i * 3) + 1];
  104.     svgapal[i][2] = palette[(i * 3) + 2];
  105.   }
  106.   gl_setpalette (&svgapal);
  107. }
  108.