home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap14 / help.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-08  |  2.2 KB  |  66 lines

  1. /*  help.c -- uses paging and direct memory access    */
  2. /*            to display a help screen                */
  3. /*  Program list: help.c, writestr.c, writechr.c,     */
  4. /*                scrfun.c                            */
  5. /*  User include files: scrn.h, color.h               */
  6. /*  Note: activate Screen Swapping On in Debug menu   */
  7.  
  8. #include <stdio.h>
  9. #include <conio.h>
  10. #include "color.h"
  11. #include "scrn.h"
  12. typedef unsigned int (far * VIDMEM);
  13. #define CGAMEM ((VIDMEM) (0xB800L << 16))
  14. #define PAGESIZE 2000
  15. #define PAGEOFFSET  0x800L
  16. #define ESC '\033'
  17. #define ATTR1 (BG_BLUE | YELLOW)
  18. #define ATTR2 (BG_YELLOW | BLUE)
  19. #define ATTR3 (BG_RED | YELLOW | BLINK | INTENSE)
  20. #define CH1  (unsigned short) '\xB1'
  21. char *str1 = "Press ? key for help.";
  22. char *str2 = "Press Enter key to return.";
  23. char *str3 = "Press Esc key to quit.";
  24. char *str4 = "\xB1HELP!\xB1";
  25. void Write_chars(VIDMEM, unsigned short, unsigned
  26.                     short, unsigned short);
  27. void Write_str(VIDMEM, unsigned short, char *);
  28.  
  29. main()
  30. {
  31.     int ch;
  32.     unsigned char page = 0;
  33.     unsigned char mode;
  34.  
  35.     mode = Getvmode();
  36.     if (mode != TEXTC80 && mode != TEXTBW80)
  37.     {
  38.         printf("Only modes 2 and 3 supported. Bye.\n");
  39.         exit(1);
  40.     }
  41.     Setpage (page);
  42.     Write_chars(CGAMEM, '\0', ATTR2, PAGESIZE);
  43.     Write_str(CGAMEM + 2 * COLS, ATTR1, str1);
  44.     Write_str(CGAMEM + 2 * COLS, ATTR1, str1);
  45.     Write_str(CGAMEM + 22 * COLS, ATTR1, str3);
  46.     Write_chars(CGAMEM + PAGEOFFSET, '\0', ATTR1, PAGESIZE);
  47.     Write_str(CGAMEM + PAGEOFFSET + 20 * COLS, ATTR2, str2);
  48.     Write_str(CGAMEM + PAGEOFFSET + 22 * COLS, ATTR1, str3);
  49.     Write_chars(CGAMEM + PAGEOFFSET + 10 * COLS + 36,
  50.                 CH1, ATTR3, 7);
  51.     Write_str(CGAMEM + PAGEOFFSET + 11 * COLS + 36,
  52.               ATTR3, str4);
  53.     Write_chars(CGAMEM + PAGEOFFSET + 12 * COLS + 36,
  54.                 CH1, ATTR3, 7);
  55.  
  56.     while ((ch = getch()) != ESC)
  57.         {
  58.         if (ch == '?' && page == 0)
  59.             Setpage (page = 1);
  60.         else if (ch == '\r' && page == 1)
  61.             Setpage(page = 0);
  62.         }
  63.     Write_chars(CGAMEM, '\0', NORMAL, PAGESIZE);
  64.     Write_chars(CGAMEM + PAGEOFFSET, '\0', NORMAL, PAGESIZE);
  65. }
  66.