home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / user_int.zip / QPRINTF.CPP < prev    next >
C/C++ Source or Header  |  1995-08-07  |  953b  |  42 lines

  1.  
  2. #include <dos.h>
  3. #include <stdarg.h>
  4. #include <stdio.h>
  5.  
  6. unsigned int _vidseg;
  7.  
  8. void qp_init(void)
  9. {
  10.   const long vidmode = 0x00449lu; // video mode address //
  11.  
  12.   if (*((char far*) vidmode) == 7) // if video mode is 7 //
  13.     _vidseg = 0xb000u; // then monochrome //
  14.   else
  15.     _vidseg = 0xb800u; // else, color //
  16. }
  17.  
  18. void qputch(int col, int row, int attr, char ch)
  19. {
  20.   register int vidofs;
  21.  
  22.   pokeb(_vidseg, vidofs = 160*row+2*col-162, ch); // poke the char //
  23.   pokeb(_vidseg, ++vidofs, attr); // poke the attr //
  24. }
  25.  
  26. void qprintf(int col, int row, int attr, char *str, ...)
  27. {
  28.   register int i, x;
  29.   int vidofs;
  30.   char vstr[90];
  31.   va_list vl;
  32.  
  33.   va_start(vl,str); // get the arguments //
  34.   vsprintf(vstr,str,vl);
  35.   va_end(vl);
  36.   for (i = 0, x = col; vstr[i]; i++, x++)
  37.   {
  38.     pokeb(_vidseg, vidofs = 160*row+2*x-162, vstr[i]); // poke the char //
  39.     pokeb(_vidseg, ++vidofs, attr); // poke the attr //
  40.   }
  41. }
  42.