home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / r_la4_01 / attrfill.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-25  |  1.6 KB  |  56 lines

  1. /* ATTRFILL.C - From page 358 of "Microsoft C Programming for   */
  2. /* the IBM" by Robert Lafore. This progam uses direct memory    */
  3. /* access to change the screen attributes. Enter 'x' to quit.   */
  4. /****************************************************************/
  5.  
  6. #define ROMAX 25
  7. #define COMAX 80
  8. #define TRUE 1
  9.  
  10. main()
  11. {
  12. char ch, attr;
  13.  
  14.    printf("\nType 'n' for normal,\n");
  15.    printf("     'u' for underlined,\n");
  16.    printf("     'i' for intensified,\n");
  17.    printf("     'b' for blinking,\n");
  18.    printf("     'r' for reverse video,\n\n");
  19.    while((ch = getch()) != 'x') {
  20.       switch(ch) {
  21.          case 'n':
  22.             attr = 0x07;            /*set to normal*/
  23.             break;                  /*0000 0111*/
  24.          case 'u':
  25.             attr = attr & 0x88;     /*set to underline*/
  26.             attr = attr | 0x01;     /* x000 x001 */
  27.             break;
  28.          case 'i':
  29.             attr = attr ^ 0x08;     /*toggle intensified*/
  30.             break;                  /* xxxx Txxx */
  31.          case 'b':
  32.             attr = attr ^ 0x80;     /*toggle blinking*/
  33.             break;                  /* 1xxx xxx */
  34.          case 'r':
  35.             attr = attr & 0x88;     /*set to reverse video*/
  36.             attr = attr | 0x70;     /* x111 x000 */
  37.             break;
  38.       }
  39.       fill(ch, attr);
  40.    }
  41. }
  42.  
  43. /* fill() */      /*fills screen with char 'ch', attribute 'attr' */
  44. fill(ch, attr)
  45. char ch, attr;
  46. {
  47. int far *farptr;
  48. int col, row;
  49.  
  50.    farptr = (int far *) 0xB0000000;
  51.    for(row = 0; row < ROMAX; row++)
  52.       for(col = 0; col < COMAX; col++)
  53.          *(farptr + row*COMAX + col) = ch | attr << 8;
  54. }
  55.  
  56.