

/* works with Microsoft C V6.0, PC with EGA */

#include <stdio.h>
#include <dos.h>

void cchar(int chr, int color, int background, int blink, int page);

#define BLACK   O
#define BLUE    1
#define GREEN   2
/* etc. */

void main()
{
    printf("%c", 65);                 /* prints 'A' */
    printf("%c", l);                  /* prints smiley face */

    printf("%c", 7);                  /* rings bell */
    putchar(7);                       /* rings bell */

/* above functions call DOS (probably via INT 21H), which
** executes some control codes with their traditional meaning.
*/

/* now bypass DOS and use ROM-BIOS *   /
cchar(7, GREEN, BLACK, 1, 0);          /* blinking green diamond */
}


/* color character at present cursor location */
void cchar( int chr, int color, int background, int blink, int page)
{
union REGS regs;

    regs.h.ah = 9;                    /* write character function */
    regs.h.al = chr;                  /* character code */
                                      /* attribute */
    regs.h.bl = (blink ? Ox80 : 0) | ((background & 7) << 4) | (color & 0x0f);
    regs.h.bh = page;                 /* display page */
    regs.x.cx = l;                    /* repetition count */
    int86(0xlO, &regs, &regs);        /* call BIOS video function */
}

