home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / graphics / gl.pak / G_CLEAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.3 KB  |  86 lines

  1. #ifndef lint
  2. static char sccsid[] = "@(#) g_clear.c 5.1 89/02/20";
  3. #endif
  4. /*
  5.  *    Copyright (c) David T. Lewis 1987, 1988
  6.  *    All rights reserved.
  7.  *
  8.  *    Permission is granted to use this for any personal noncommercial use.
  9.  *    You may not distribute source or executable code for profit, nor
  10.  *    may you distribute it with a commercial product without the written
  11.  *    consent of the author.  Please send modifications to the author for
  12.  *    inclusion in updates to the program.  Thanks.
  13.  */
  14. /*
  15.  *    Routine to clear video memory (or print buffer memory).  
  16.  *    dtlewis 6-28-87
  17.  *    Sun Mar 13 21:13:59 EST 1988
  18.  */
  19. #include "config.h"
  20. #include "bitmaps.h"
  21. #include "graphics.h"
  22. #include "modes.h"
  23. extern int g_init(), g_finish();
  24. int g_clear()  
  25. {
  26.     extern struct GL_graphics graphics;
  27.     int i, j;
  28.     int istat;
  29. #if MIX_C
  30.     /* No long pointers with this compiler.  Cheat and use BIOS.    */
  31.     g_setmod(graphics.grafmode);
  32.     return(0);
  33. #endif /* MIX_C */
  34.     switch (graphics.grafmode) {
  35.         case CGA_COLOR_MODE:
  36.             for(i=0; i<100; i++)  {
  37.                 for(j=0; j<80; j++)  {
  38.                     (graphics.cgamem)->page1[i][j] = 0x0;
  39.                     (graphics.cgamem)->page2[i][j] = 0x0;
  40.                 }
  41.             }
  42.             break;
  43.         case CGA_HI_RES_MODE:
  44.             for(i=0; i<100; i++)  {
  45.                 for(j=0; j<80; j++)  {
  46.                     (graphics.cgamem)->page1[i][j] = 0x0;
  47.                     (graphics.cgamem)->page2[i][j] = 0x0;
  48.                 }
  49.             }
  50.             break;
  51.         case EGA_COLOR_MODE:
  52.             for (i=0 ; i<350 ; i++) {
  53.                 for (j=0 ; j<80 ; j++) {
  54.                     (graphics.egamem)->mem[i][j] = 0x0;
  55.                 }
  56.             }
  57.             break;
  58.         case HERC_P0_MODE:
  59.         case HERC_P1_MODE:
  60.             for(i=0; i<87; i++)  {
  61.                 for(j=0; j<90; j++)  {
  62.                     (graphics.hercmem)->page1[i][j] = 0x0;
  63.                     (graphics.hercmem)->page2[i][j] = 0x0;
  64.                     (graphics.hercmem)->page3[i][j] = 0x0;
  65.                     (graphics.hercmem)->page4[i][j] = 0x0;
  66.                 }
  67.             }
  68.             break;
  69.         /* For hard copy, there is no point in clearing    */
  70.         /* memory.  We will interpret this call as    */
  71.         /* "done with this page; send it to the printer    */
  72.         /* and get ready for another."            */
  73.         case IBM_PRINTER:
  74.             if ((istat=g_finish()) != 0) return(istat);
  75.             if ((istat=g_init(IBM_PRINTER)) != 0) return(istat);
  76.             break;
  77.         case LJ_PRINTER:
  78.             if ((istat=g_finish()) != 0) return(istat);
  79.             if ((istat=g_init(LJ_PRINTER)) != 0) return(istat);
  80.             break;
  81.         default:
  82.             return(1);
  83.     }
  84.     return(0);
  85. }
  86.