home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / Source / BONUS / MONO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-29  |  4.2 KB  |  108 lines

  1.  
  2. // MONO.H - HEADER FOR MONOCHROME PRINTING ENGINE ///////////////////////////////
  3.  
  4. #ifndef MONOCHROME_H                    // watch out for multiple inclusions
  5. #define MONOCHROME_H
  6.  
  7. // colors and styles for printing
  8.  
  9. #define MONO_BLACK                0        
  10. #define MONO_DARK                 7
  11. #define MONO_DARK_UNDERLINE       1
  12. #define MONO_BRIGHT               15
  13. #define MONO_BRIGHT_UNDERLINE     9
  14. #define MONO_BYTES_PER_LINE       160
  15.  
  16. // dimensions of monchrome display
  17.  
  18. #define MONO_ROWS                 25    
  19. #define MONO_COLUMNS              80
  20.  
  21. // watch variable defines
  22.  
  23. #define MONO_MAX_WATCHES          64      // maximum number of watches
  24.  
  25. #define MONO_WATCH_CHAR           0       // types of watches, needed to compute RTTI
  26. #define MONO_WATCH_UCHAR          1
  27. #define MONO_WATCH_SHORT          2
  28. #define MONO_WATCH_USHORT         3
  29. #define MONO_WATCH_INT            4
  30. #define MONO_WATCH_UINT           5
  31. #define MONO_WATCH_STRING         6
  32. #define MONO_WATCH_STRING_HEX     7
  33. #define MONO_WATCH_FLOAT          8
  34. #define MONO_WATCH_PTR            9
  35.  
  36. // TYPES //////////////////////////////////////////////////////////////////////
  37.  
  38. // some convienient types
  39.  
  40. typedef unsigned short USHORT;
  41. typedef unsigned char  UCHAR;
  42.  
  43. // this structure is used to hold the parameters for a "watch" variable
  44.  
  45. typedef struct mono_watch_tag
  46. {
  47. char name[32];        // the name of the variable
  48. void *data;             // pointer to the data to watch
  49. int type;               // type of data being watched
  50. int x,y;                // position to display watch
  51. int field_width;        // the width you want cleared in watch display
  52.                         // this is so you don't get garbage
  53.  
  54. } mono_watch, *_monowatch_ptr;
  55.  
  56. // CLASSES ////////////////////////////////////////////////////////////////////
  57.  
  58. class MONOPRINT          // monochrome display class
  59. {
  60.  
  61. public:
  62.  
  63.         MONOPRINT(void);                        // constructor
  64.         ~MONOPRINT() {}                         // destructor does nothing for now
  65.  
  66.         void print(char *string);               // prints a string at the current cursor location
  67.                                                                              // and style, similar to printf supports scrolling etc.
  68.  
  69.         void draw(char *string,                 // "draws" a string anywhere with sent style
  70.                  int x,                         // no scrolling or logic
  71.                  int y,
  72.                  int style);
  73.  
  74.     void set_cursor(int x, int y);        // positions the cursor in the 80x25 matrix
  75.     void get_cursor(int &x, int &y);    // retrieves the position of the cursor
  76.     void set_style(int new_style);        // sets the style of output
  77.         void enable();                          // enables output
  78.         void disable();                         // disables output
  79.         void scroll(int num_lines);             // scrolls the display from the bottom
  80.     void clear();                        // this function clears the display    
  81.  
  82. // methods for debugging watch display
  83.  
  84.         void delete_watches(void);               // deletes all watches
  85.     
  86.         int add_watch(char *name,                // ascii name of variable, up to 15 chars
  87.                                 void *addr,      // address of variable to watch
  88.                                 int type,        // type of variable
  89.                                 int x,           // position of variable
  90.                 int y,
  91.                                 int field_width); // size of output field
  92.  
  93.         void update_watches(void);                // simply displays all the watches
  94.  
  95. private:
  96.  
  97.         int cx,cy;                                // position of printing cursor on 80x25 matrix
  98.         int style;                                // style of output, dark, bright, underlined, etc.
  99.         int output_enable;                        // used to "gate" output to monitor
  100.         USHORT *mono_video;                       // pointer to the monochrome video buffer
  101.     
  102.         int num_watches;                          // number of active watches
  103.         mono_watch watch[MONO_MAX_WATCHES];       // pre-allocate the watch structures to keep
  104.                                         // code simple, IRL use a linked list
  105. };
  106.  
  107. #endif
  108.