/*
 *  romfont.c -- 98のフォントROMから文字フォントを得る
 *
 *  revision history:
 *	0.0: Mar. 14, 1993 by Dai Ishijima
 *	0.1: Oct. 23, 1994
 */

#include <dos.h>

#define FONTSIZE 32
#define FBUFSIZ (FONTSIZE + 2)
#define CRTBIOS 0x18
#define GETFONT 0x14
#define CGACCESS 0x1b


unsigned char *font(int code)
{
    static unsigned char fontbuf[FBUFSIZ];
    union REGS regs;

#ifndef NOFLASH
    regs.h.ah = CGACCESS;
    regs.h.al = 1;
    int86(CRTBIOS, &regs, &regs);
#endif
    if (code < 0x100) {		/* 8x16 ank font */
	code |= 0x8000;
    }
    regs.h.ah = GETFONT;
    regs.x.bx = FP_SEG((void far *)fontbuf);
    regs.x.cx = FP_OFF((void far *)fontbuf);
    regs.x.dx = code;
    int86(CRTBIOS, &regs, &regs);
#ifndef NOFLASH
    regs.h.ah = CGACCESS;
    regs.h.al = 0;
    int86(CRTBIOS, &regs, &regs);
#endif
    return(&fontbuf[2]);
}        
