/*========================================================[ LPR98.C ]===*/ /* PC9801用プリンタライブラリ */ /* ver 2.0 H4/7/27 by S.F */ /*======================================================================*/ #include #include #include #include #define uchar unsigned char #define uint unsigned int #define ESC 0x1b union unic{ uint w; /* unic 共用体の宣言 */ uchar b[2]; }; typedef union unic UNIC; PRINT_INFO lpf; lp_init() /* プリンタの初期化 */ { lpf.cmmd = 16; bios98print( &lpf ); return( lpf.stus ); } lp_kjin() /* 漢字モードへ */ { lputch(ESC); lputch('K'); } lp_kjout() /* アスキーモードへ */ { lputch(ESC); lputch('H'); } lputch( uchar c ) /* 1文字のプリンタ出力 */ { lpf.cmmd = 17; lpf.chr = c; bios98print( &lpf ); return( lpf.stus ); } lputcrlf() /* CR/LFのプリンタ出力 */ { lputch(13); lputch(10); } lpage() /* ページ送りのプリンタ出力 */ { lputch(12); } lp_putch( uchar c ) /* 1文字のプリンタ出力 */ { switch(c){ case '\n': lputcrlf(); break; default: lputch(c); break; } } lkput( uint sjms ) /* 漢字1文字のプリンタ出力(JIS化を含む) */ { UNIC j; j.w = jmstojis(sjms); lputch(j.b[1]); lputch(j.b[0]); } lputs(char *str) { int i; i=0; while(*str!=NULL){ lputch(*str++); i++; } return(i); } lp_puts( char *str ) /* 文字列のプリンタ出力(漢字対応) */ { UNIC s; int k,n; uchar c; k = 0; n = 0; while(*str!=NULL){ if(k==0){ /* アスキーモード中 */ if(iskanji(*str)){ /* 出力文字が漢字の場合 */ lp_kjin(); /* 漢字モードへ */ k = 1; s.b[1]=*str; str++; s.b[0]=*str; str++; lkput(s.w); /* 漢字出力 */ n += 2; }else{ /* 出力文字がアスキー文字の場合 */ lp_putch(*str); str++; n++; } }else{ /* 漢字モード中 */ if(iskanji(*str)){ /* 出力文字が漢字の場合 */ s.b[1]=*str; str++; s.b[0]=*str; str++; lkput(s.w); /* 漢字出力 */ n += 2; }else{ /* 出力文字がアスキー文字の場合 */ lp_kjout(); /* アスキーモードへ */ k = 0; lp_putch(*str); str++; n++; } } } lp_kjout(); /* アスキーモードへ */ return( n ); } lputsn( char *str, int size ) /* 文字列のプリンタ出力(文字数指定)*/ { lpf.cmmd = 48; lpf.string = str; lpf.size = size; bios98print( & lpf ); return( lpf.stus ); } /*---------------------- e n d --------------------------*/