home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_12 / 8n12026a < prev    next >
Text File  |  1990-05-04  |  2KB  |  111 lines

  1. /*
  2.     mono.c
  3.  
  4. */
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <mem.h>
  10. #include <stdarg.h>
  11. #include <string.h>
  12. #include <dos.h>
  13.  
  14.  
  15.  
  16. void mprintf(char *format, ...);
  17. void mono(char *message);
  18. static void scroll(void);
  19.  
  20.  
  21. #if 0
  22. void main(void){
  23.     int i;
  24.  
  25.     printf("This is the active screen...");
  26.     for(i=0;i<12;i++){
  27.             getch();
  28.  
  29.         mono("art was here");
  30.         mono("   mono.exe   copyright (C) 1989 Art Shipman & Art_Was_Here");
  31.         mono("one more message line, and");
  32.         mono("another, and");
  33.         mono("Art's going now...");
  34.         printf("and still active\n");
  35.  
  36.         mprintf("%d plus %d equals %d",2,2,5);
  37.         }
  38.     }/*main*/
  39. #endif
  40.  
  41.  
  42.  
  43. void mprintf(char *format, ...){
  44.     va_list    argptr;
  45.     char buf[100];
  46.  
  47.     va_start(argptr, format);
  48.     vsprintf(buf,format,argptr);
  49.     va_end(argptr);
  50.  
  51.     mono(buf);
  52.     }
  53.  
  54.  
  55.  
  56. void mono(char *message){
  57.     static unsigned segment = 0xB000;
  58.     static unsigned offset = 0;
  59.  
  60.     char *blank="  ";
  61.     int i; int j;
  62.     int l=strlen(message);
  63.  
  64.     if (segment==0xB000)    /*clear the screen*/
  65.     {
  66.         for(i=0;i<25;i++)
  67.  
  68.         {    for(j=0; j<160; j++)
  69.             {    pokeb(segment, j++, blank[0] );
  70.                 pokeb(segment, j, 7);
  71.             }
  72.             segment+=10;
  73.         }
  74.         segment=0xB000;
  75.     }
  76.  
  77.  
  78.  
  79.     for(i=0;i<l;i++)        /*display a line*/
  80.     {
  81.         pokeb(segment, offset++, message[i] );
  82.         offset++;
  83.     }
  84.     segment+=10; offset=0;
  85.     if (segment-0xB000 >240)
  86.     {
  87.         scroll();
  88.         segment-=10;
  89.         }
  90. }
  91.  
  92.  
  93. static void scroll(void){
  94.     size_t lin = 80*2;
  95.     unsigned segment = 0xB000;
  96.     int i;
  97.     char *blank="  ";
  98.  
  99.     for(i=1; i<25; i++)
  100.     {
  101.         movedata(segment,160,segment,0, lin );
  102.         segment+=10;
  103.         }
  104.     for(i=0; i<160; i++)
  105.     {    pokeb(segment, i++, blank[0] );
  106.         pokeb(segment, i, 7);
  107.     }
  108.  
  109.  
  110. }
  111.