home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / borland / chap_4 / sync.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-19  |  1.1 KB  |  62 lines

  1.  
  2. // SYNC.C - A demo of the vertical retrace
  3.  
  4. // I N C L U D E S ///////////////////////////////////////////////////////////
  5.  
  6. #include <io.h>
  7. #include <conio.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <dos.h>
  11. #include <bios.h>
  12. #include <fcntl.h>
  13. #include <memory.h>
  14. #include <malloc.h>
  15. #include <math.h>
  16. #include <string.h>
  17.  
  18. #include "black3.h"
  19. #include "black4.h"
  20.  
  21. // M A I N ///////////////////////////////////////////////////////////////////
  22.  
  23. void main(void)
  24. {
  25. int x=0,y=100;  // position of the dot
  26.  
  27. // set the graphics mode to mode 13h
  28.  
  29. Set_Graphics_Mode(GRAPHICS_MODE13);
  30.  
  31. // loop until keyboard is hit
  32.  
  33. while(!kbhit())
  34.      {
  35.  
  36.      // wait for retrace period
  37.  
  38.      Wait_For_Vertical_Retrace();
  39.  
  40.      // at this point the electron gun is retracing, so updates to the
  41.      // video buffer won't be visible
  42.  
  43.      // update our little dot
  44.  
  45.      Write_Pixel(x,y,0);
  46.  
  47.      // move the dot
  48.  
  49.      if (++x>319) // the dot will move at approx. 70 pixels/second
  50.         x=0;
  51.  
  52.      Write_Pixel(x,y,15);
  53.  
  54.      } // end while
  55.  
  56. // reset to text mode
  57.  
  58. Set_Graphics_Mode(TEXT_MODE);
  59.  
  60. } // end main
  61.  
  62.