Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This function affects subsequent printf()s. You can change the background color of the entire screen, for example to magenta, by coding:

Code Block
        setatr(0x5E);
        printf("\f");

Then all subsequent printf()s will show bright yellow on magenta. The clreol() function also sets the background color for the remainder of the line according to the latest setatr() attribute.

...

This routine defines the handling of printf() when sending an ASCII bel (ctrl+G) character to the operator console. This will probably be a much shorter beep than DOS uses. For example:

Code Block
        belper(200);
        printf("\7");   /* high-pitched beep */
        belper(1000);
        printf("\7");   /* low-pitched beep */
        belper(150);
        printf("\7");   /* very high-pitched beep */
        belper(0);
        printf("\7");   /* silent */

The belper() routine is used in the Major BBS to set the beeps for signup notification (SGNBEL), the page-Sysop warning (SOPBEL), and the emulation screen (EMUBEL).

...

The m commands (display attributes) may be combined using semicolons. For example, esc [1m esc [33m esc [45m has the same effect as esc [1;33;45m Both commands set the display attribute to bright yellow on magenta. The following code displays a message with these attribute settings in the current display window:

Code Block
        printf("\
33
33[1;33;45mWafer yield for the 200MHz P6:  85%");

The individual characters of the above commands may be split across different calls to printf(). There may even be intervening calls to printf() as long as the intervening calls have ansion(0) (ANSI graphics disabled). Also, the display attribute is preserved across calls to setatr() when ansion(0). All of these features enable the emulation of a single user’s channel with ANSI graphics while the Major BBS simultaneously updates various other information on the console. For more on how the Major BBS emulates multiple screens at once, see page 273.

...

The following code example shows some of these video routines in action. The zipred() function makes a red box with an exclamation point zip across the screen from left to right, and then disappear. Note that the image (of the original screen with a red box on it) is constructed in a buffer and then copied to the visible screen, so the red box does not flicker.

Code Block
void
zipred(void)
{
     static char savebf[4000]; /* buffer to save original screen image */
     static char drawbf[4000];     /* buffer to use as a drawing board */
     char *frzseg();               /* frzseg() returns a char pointer! */
     int savx,savy;               /* to save cursor position           */
     int x;

     savx=curcurx();                           /* save cursor position */
     savy=curcury();
     movmem(frzseg(),savebf,4000);              /* save screen image   */
     setatr(0x4F);                     /* bright white on red          */
     for (x=0 ; x < 70 ; x++) {              /* From left to right...  */
          movmem(savebf,drawbf,4000);         /* prepare drawing board */
          setwin(drawbf,x,9,x+10,15,0); /* define an 11 by 7 window    */
          printf("\f");                            /* fill it with red */
          locate(x+5,12);                         /* and in the center */
          printf("!");                                  /* put an "!"  */
          rstwin();                      /* (restore window settings)  */
          movmem(drawbf,frzseg(),4000);   /* make this picture visible */
     }
     movmem(savebf,frzseg(),4000);    /* restore original screen image */
     locate(savx,savy);                     /* restore cursor position */
     setatr(0x07);                                   /* white on black */
     unfrez();
}

To read from the video screen or buffer, you can use scnoff():

...

For example, to find the character and attribute at the lower right corner of a SCNSIZ-byte screen buffer:

Code Block
        lrchar=scnbuf[scnoff(79,24)];
        lrattr=scnbuf[scnoff(79,24)+1];
Writing to Several ANSI Screens at Once

...

For example, you could maintain an array of curatr structures and make one of them active whenever you wrote to one of the screens.

Code Block
        struct curatr ansave[NUMSCNS];
        :
        movmem(&ansave[actscn],&curatr,sizeof(struct curatr));
        printf(ANSI commands to screen);
        movmem(&curatr,&ansave[actscn],sizeof(struct curatr));

The first movmem() puts the curatr structure for the active screen where printf() will use it and update it. The second movmem() saves it away again.

...

int howbig; NOCURS, LILCURS, or BIGCURS

...

Previous: Major BBS v10: 06 The Galacticomm Messaging Engine  |  Contents  |  Next: Major BBS v10: 08 Operator Services