|
发表于 2011-3-10 19:03:10
|
显示全部楼层
/*
** Casio 9860g 汉字显示
** Last update 2009.10.16
*/
# include "fxlib.h"
# include "dispbios.h"
# include "9860g.h"
WORD font_buf[100] ;
int fontptr ;
int Print_zh(char* input, BYTE x, BYTE y, BYTE type)
{
DWORD fontpos = 0 ;
unsigned char bitmap_ptr[] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
/* 28字节点阵信息 */ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0'} ;
GRAPHDATA font_data ; /* Display structure */
DISPGRAPH font_disp ;
WORD* hanzi = font_buf ;
strcpy(font_buf, input) ; /* Copy input to font buffer */
/* 初始化结构体 */
font_data.width = 14 ; /* GRAPHDATA */
font_data.height = 14 ;
font_disp.x = x ; /* DISPGRAPH */
font_disp.y = y ;
font_dipadKind = IMB_WRITEKIND_OVER ; /* Overwrite (fill) */
switch (type){
case NORMAL:
font_dipadModify = IMB_WRITEMODIFY_NORMAL ; /* Normal */
break ;
case REVERSE: case VERT_REV:
font_dipadModify = IMB_WRITEMODIFY_REVERCE ; /* Revers(c)e */
break ;
case UNDER_LINE: /* 下划线 */
Bdisp_DrawLineVRAM(x-5, y+14, x+47, y+14) ;
font_dipadModify = IMB_WRITEMODIFY_NORMAL ; /* Normal */
default: break ;
}
while (*hanzi>>8 != '\0') {
/* 当前内码位置 = 索引位置 × 字体大小 */
fontpos = GetPosWithMbcs( *hanzi ) * 28 ;
Bfile_ReadFile(fontptr, bitmap_ptr, 28, fontpos) ; /* Read bitmap */
font_data.pBitmap = bitmap_ptr ;
font_disp.GraphData = font_data ;
BdipadGraph_VRAM(&font_disp);
++hanzi ; if (type == VERT_REV || type == VERT) font_disp.y += 14 ;
else font_disp.x += 14 ;
}
Bdisp_PutDisp_DD() ;
return TRUE ;
}
DWORD GetPosWithMbcs(WORD code)
{
BYTE R = (code >> 8) & 0xFF; /* 区码 */
BYTE C = code & 0xFF; /* 位码 */
if ((R >= 0xA1 && R <= 0xFE) && (C >= 0xA1 && C <= 0xFE))
return (R - 0xa1)*94 + (C - 0xa1) ;
else return 0 ;
}
int OpenFont(void)
{
# ifdef RELEASE
FONTCHARACTER fontfile[] = { '\\','\\','f','l','s','0','\\','F','O','N','T','.','b','i','n' ,'\0'} ;
# else
FONTCHARACTER fontfile[] = { '\\','\\','c','r','d','0','\\','f','o','n','t','.','b','i','n' ,'\0'} ;
# endif
fontptr = Bfile_OpenFile(fontfile, _OPENMODE_READ) ;
if (fontptr < 0)
{
locate(1,4) ;
Print((unsigned char*)"Cann't open fontfile.") ;
return FALSE ; /* error */
}
return TRUE ;
}
void CloseFont(void)
{
Bfile_CloseFile( fontptr ) ;
}
Enjoy. |
|