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

  1. /* ch2000.c -- fill screen with 2000 characters        */
  2. /*    This program demonstrates direct memory access   */
  3. /*    of video memory.  It is set up for the MDA.      */
  4. /*    Assign CGAMEM instead of MONMEM to screen for    */
  5. /*    CGA and CGA-compatible modes.                    */
  6. /*    Press a key to fill; press Esc to quit.          */
  7. /* Note: activate Screen Swapping On in Debug menu     */
  8.  
  9. #include <conio.h>
  10. #include "scrn.h"
  11. typedef unsigned short (far * VIDMEM);
  12. #define MONMEM ((VIDMEM) (0xB000L << 16)) /* monochrome */
  13. #define CGAMEM ((VIDMEM) (0xB800L << 16)) /* cga, ega */
  14. #define ESC '\033'
  15. #define CHARS 2000
  16. #define AMASK 0xFF   /* keep attribute in range */
  17. main()
  18. {
  19.      unsigned ch;          /* character to be displayed */
  20.      unsigned attrib = 7;  /* initial attribute         */
  21.      VIDMEM screen;        /* pointer to video RAM      */
  22.      int offset;           /* location on screen        */
  23.  
  24.      screen = MONMEM;      /* monochrome initialization */
  25.      while ((ch = getch()) != ESC)
  26.      {
  27.         for (offset = 0; offset < CHARS; offset++)
  28.           *(screen + offset) = ((attrib++ & AMASK) << 8)                              | ch;
  29.      }
  30. }
  31.