|
源代码网推荐
#include "dos.h" #include "stdio.h" #include "conio.h" FILE *fp; void OpenLIB(void); void CC256(int, int, int, char *Str); void ErrMsg(); void InitScr(); void RstScr(); void PutPoint(int x, int y, int Color); void Quit(); int main(void) { char *Str = "谢谢您使用本书"; OpenLIB(); InitScr(); CC256(70, 80, 2, Str); getch(); Quit(); return 0; } void InitScr() { union REGS In; In.x.ax = 0x13; /*进入13H模式 */ int86(0x10, &In, &In); } void RstScr() { union REGS In; In.x.ax = 0x03; /* 退出13H模式 */ int86(0x10, &In, &In); } void OpenLIB(void) /* 打开24点阵宋体字库 */ { if ((fp = fopen("c:\\ucdos\\clib24s", "rb")) == NULL) ErrMsg(); } void CC256(int x, int y, int Wid, char *Str) { unsigned Zcode, Bcode; /* 区码, 位码 */ int i, j, k, Rec, Color; long Len; char Buf[72]; while (*Str) /* 直到字串显示完 */ { if ((*Str & 0x80) && (*(Str+1) &0x80)) /* 是汉字 */ { Zcode = (*Str-0xa1) & 0x07f; /* 区码 */ Bcode = (*(Str+1)-0xa1) & 0x07f; /* 位码 */ Rec = Zcode*94+Bcode; /* 记录号 */ Len = Rec*72L; /* 在字库中位置 */ fseek(fp, Len, SEEK_SET); fread (Buf, 1, 72, fp); /* 72字节 */ for (i = 0; i < 24; i++) for (j = 0; j < 3; j++) for (k = 0; k < 8; k++) if (Buf[i*3+j] >> (7-k) & 1) { Color = y+j*8+k-46; PutPoint(x+i, y+j*8+k, Color); } x = x+24+Wid; Str += 2; } } return; } /* 直接写视频缓冲区 */ void PutPoint(int x, int y, int Color) /* 画点函数 */ { char far *p; p = (char far *) (0x0a0000000L); * (x+y*320+p) = Color; } void Quit() { RstScr(); fcloseall(); } void ErrMsg() { printf("Open LIB File Error!"); getch(); Quit(); } 源代码网供稿. |