home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / writef.lzh / WRITEF.C next >
Encoding:
C/C++ Source or Header  |  1987-07-23  |  1.4 KB  |  61 lines

  1. /*  No need to assemble external code.  writef will give you extremely
  2.     fast screen writes, in any color with any background.  It consists
  3.     of only one small procedure (14 lines) written entirely in Turbo C.
  4.  
  5.     example:
  6.  
  7.      writef(5,4,0x17,"This demonstrates the speed fo writef");
  8.  
  9.             The above line will write the enclosed text on
  10.           line 4, column 5 with a background color of 1 (blue)
  11.           and a forground color of 7 (gray).  Using numbers greater
  12.           than 7 for background will create blinking characters.
  13.  
  14.  
  15.     This routine was developed by:
  16.                 
  17.                        Gemini Systems
  18.                        Tom Hunter
  19.                        P.O. Box 7086
  20.                        Bloomfield Hills, Mi 48302
  21.  
  22.  
  23.  
  24.  
  25. */
  26.  
  27. #include <stdio.h>
  28.  
  29. int  i;
  30.  
  31. void writef(int x, int y, int attr, char line[80])
  32. {
  33.   const long vmode   = 0x00449lu;  /* video mode byte */
  34.   int   i, j, scrseg, scrofs;
  35.  
  36.   if (7 == *((char far*) vmode))
  37.     scrseg = 0xb000u;
  38.   else
  39.     scrseg = 0xb800u;
  40.   j = strlen(line);
  41.   for (i = 0; i < j; i++)
  42.   {
  43.     scrofs = (((y * 160) - 160) + (x * 2)) - 2;
  44.     pokeb(scrseg, scrofs, line[i]);
  45.     pokeb(scrseg, scrofs+1, attr);
  46.     x++;
  47.   }
  48.   return;
  49. }
  50.  
  51. main()
  52. {
  53.  
  54.    for (i = 1; i < 20; i++)
  55.      writef(5,i,0x4e,"This demonstrates the speed fo writef, by Gemini Systems.");
  56.    exit(0);
  57.  
  58. }
  59.  
  60.  
  61.