home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / exc.arj / TEMP / 08-14.C < prev    next >
Text File  |  1995-01-20  |  2KB  |  87 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #ifdef __TURBOC__
  5. #include <alloc.h>
  6. #else
  7. #include <malloc.h>
  8. #endif
  9.  
  10. #define WIDTH  640
  11. #define HEIGHT 400
  12.  
  13. void main(void);
  14.  
  15. void main()
  16. {
  17.    int handle;
  18.    int old_mode;
  19. #ifdef FG32
  20.    char *buffer;
  21. #else
  22.    char huge *buffer;
  23. #endif
  24.  
  25.    /* initialize the video environment */
  26.  
  27.    fg_initpm();
  28.    old_mode = fg_getmode();
  29.    fg_setmode(19);
  30.    fg_vbinit();
  31.  
  32.    /* set up a 640x400 virtual buffer */
  33.  
  34. #ifdef FG32
  35.    buffer = (char *)malloc(WIDTH*HEIGHT);
  36. #elif defined(__TURBOC__)
  37.    buffer = (char huge *)farmalloc((long)WIDTH*(long)HEIGHT);
  38. #else
  39.    buffer = (char huge *)halloc((long)WIDTH*(long)HEIGHT,1);
  40. #endif
  41.    if (buffer == NULL)
  42.    {
  43.       fg_setmode(old_mode);
  44.       fg_reset();
  45.       printf("Could not create the virtual buffer.\n");
  46.       exit(1);
  47.    }
  48.    handle = fg_vbdefine(buffer,WIDTH,HEIGHT);
  49.    fg_vbopen(handle);
  50.  
  51.    /* draw a 320x200 rectangle in each virtual buffer quadrant */
  52.  
  53.    fg_setcolor(9);
  54.    fg_rect(0,319,0,199);
  55.    fg_setcolor(10);
  56.    fg_rect(320,639,0,199);
  57.    fg_setcolor(11);
  58.    fg_rect(0,319,200,399);
  59.    fg_setcolor(12);
  60.    fg_rect(320,639,200,399);
  61.  
  62.    /* paste each rectangle to the 320x200 active video page */
  63.  
  64.    fg_vbpaste(0,319,0,199,0,199);
  65.    fg_waitkey();
  66.    fg_vbpaste(320,639,0,199,0,199);
  67.    fg_waitkey();
  68.    fg_vbpaste(0,319,200,399,0,199);
  69.    fg_waitkey();
  70.    fg_vbpaste(320,639,200,399,0,199);
  71.    fg_waitkey();
  72.  
  73.    /* paste the center 320x200 subset of the virtual buffer */
  74.  
  75.    fg_vbpaste(160,479,100,299,0,199);
  76.    fg_waitkey();
  77.  
  78.    /* close the virtual buffer */
  79.  
  80.    fg_vbclose();
  81.  
  82.    /* restore original video mode and exit */
  83.  
  84.    fg_setmode(old_mode);
  85.    fg_reset();
  86. }
  87.