home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / PUTCHR.ZIP / PUTCHR.H < prev   
C/C++ Source or Header  |  1994-02-01  |  2KB  |  52 lines

  1. /*
  2.                             Put_Character Routine
  3.  
  4.     This routine will output any character to the screen without having
  5.     to call BIOS routines.  It is handy for those characters which have
  6.     both a symbol and a control feature.  In particular ascii values of
  7.     seven (7) through thirteen (13), inclusively.
  8.  
  9.     To use, put the following line in your source code:
  10.         #include "putchr.h"
  11.  
  12.     and when you are ready to use:
  13.  
  14.         {Set position and text attributes for the character.}
  15.         Put_Character( Char );
  16. */
  17. #if !defined(__CONIO_H)
  18. #include <conio.h>
  19. #endif
  20.  
  21. void
  22. Put_Character( char Character )
  23. {
  24. struct  text_info Current_Window;   //  To get current characteristics.
  25. char    Put_Character[2];           //  The character and its attribute.
  26. int     X, Y;                       //  Screen coordinates.
  27.  
  28. //  Get current display characteristics.
  29.     gettextinfo( &Current_Window );
  30.  
  31. //  Put the character together with the current attributes.
  32.     Put_Character[0] = Character;
  33.     Put_Character[1] = Current_Window.attribute;
  34.  
  35. //  Determine the absolute screen coordinates of the current position.
  36.     X = Current_Window.winleft + Current_Window.curx - 1;
  37.     Y = Current_Window.wintop  + Current_Window.cury - 1;
  38.  
  39. //  Put the character on the screen at the current position with the
  40. //      current attributes.
  41.     puttext( X, Y, X, Y, Put_Character );
  42.  
  43. //  Update the current position.  If not at the edge of the window, then
  44. //      just move right one character.  Otherwise, go to the beginning of
  45. //      the next line.
  46.     if ( Current_Window.curx < Current_Window.winright )
  47.         gotoxy( Current_Window.curx + 1, Current_Window.cury );
  48.     else
  49.         cprintf( "\n\r" );
  50. }
  51.  
  52.