[comp.os.msdos.programmer] blitting text to a hercules

tr@samadams.princeton.edu (Tom Reingold) (06/07/91)

Is there something I need to know about blitting characters onto the
screen with a Hercules board?  The following function works just fine
on regular color and monochrome boards.  Do I have to access some
register or something before I do direct access to video RAM?  The
Hercules BIOS says it's a monochrome board.  I assume that the RAM
addresses for monochrome are coorect.

Thanks.

/* display a character at row, col with attribute and repetition */
/* uses video RAM */
void disp_char(int row, int col, char val, char attribute, int times)
{    
    static char far *v_off = (char far *) 0;
    char far *p;
    
    if (v_off == (char far *) 0) {
	if (video_type() == COLOR)
	    v_off = (char far *) 0xb8000000;
	else
	    v_off = (char far *) 0xb0000000;
    }
    p = v_off + (((row * 80) + col) << 1);
    while (times--) {
	*p++ = val;
	*p++ = attribute;
    }
}
--
        Tom Reingold
        tr@samadams.princeton.edu  OR  ...!princeton!samadams!tr
        "Warning: Do not drive with Auto-Shade in place.  Remove
        from windshield before starting ignition."