/* From YE@LEPTON.NPL.WASHINGTON.EDU Wed Aug 25 20:12:10 1993 Return-Path: Date: Wed, 25 Aug 1993 18:11:26 -0700 (PDT) From: YE@LEPTON.NPL.WASHINGTON.EDU Subject: chinese viewer for microVAX To: ftp-admin@ifcss.org X-Vmsmail-To: SMTP%"ftp-admin@ifcss.org" */ /* This program is a chinese viewer running on MicroVax (Vax station 3100) * under VMS V5.5-2 operating system. * * To view a binary GB file using this program, one needs to have a * transformed cclib.16 font file in which every byte has a reversed bit * order as regarding to that in cclib.16. (A crude source code is attached * for this purpose.) * * Once the font file is installed, one can proceed to compile and link the * source code. Finally, before running the code, one should define a symbol * such as * * CHV :==$DISK:[ directory_name ]MicroVAX_CHVIEW * * Now, a simple command " CHV < GB file > " will be sufficient. * * It is hoped by the author that a lack of documentation in the code can be * partially compensated by its simplicity. * */ /********************beginning of the source code******************/ /* * MicroVAX_CHVIEW.c -- a chinese viewer program */ #include #include #include stdio #include ssdef #include descrip #define XMIN 10 #define XMAX 800 #define YMIN 20 #define YMAX 750 #define FONT_HEIGHT 16 #define FONT_WIDTH 16 #define FONT_SIZE 32 #define FONT_FILE "TCCLIB.16" #define DICTIONARY_FONT 4412 #define MAX_PAGE 100 unsigned long int VD_ID, WD_ID; void ginit(); main(argc, argv) int argc; char *argv[]; { unsigned long int ATB = 0; unsigned long int bit_per_pix = 1; unsigned long int x1, y1, x2, y2; unsigned char array[DICTIONARY_FONT][FONT_SIZE]; unsigned char temp_array[FONT_SIZE]; unsigned long int array_width = 16; unsigned long int array_height = 16; unsigned long int page_mark[MAX_PAGE]; int byte_in_file = 0; int page_no = 0; FILE *cclib_file, *gb_file; int byte; int j = 0; char ans; int ch1, ch2; long addr; if(argc!=2) { printf("usage: chview \n"); exit(); } if( (cclib_file=fopen(FONT_FILE,"r")) ==NULL) { printf("Can not open font file %s", FONT_FILE); exit(); } if( (gb_file=fopen(argv[1],"r")) ==NULL) { printf("Can not open GB file %s", argv[1]); exit(); } printf(" loading font ....... \n"); byte=fread(array, FONT_SIZE*DICTIONARY_FONT, 1, cclib_file); ginit(); while(ans!='q') { for (y1 = YMAX; y1>YMIN; y1-=FONT_HEIGHT ) for (x1 = XMIN; x1=0xA1 ) { ch2 = fgetc(gb_file); byte_in_file++; addr = (ch1-0xA1)*94+ch2-0xA1; if(addr>1410) addr=addr-94*8; } else { addr = ch1+155; if (ch1==13 ) {addr=0; x1=XMAX ;} if (ch1==26 || ch1=='\n') {addr=0;} if (ch1=='\t'||ch1==' ') {addr=0;} } if ( addr ) { if ( addr < DICTIONARY_FONT) { uisdc$image( &WD_ID, &ATB, &x1, &y1, &x2, &y2, &array_width, &array_height, &bit_per_pix, array[addr] ); } else { fseek(cclib_file, addr*FONT_SIZE, 0); byte=fread(temp_array, FONT_SIZE, 1, cclib_file); uisdc$image( &WD_ID, &ATB, &x1, &y1, &x2, &y2, &array_width, &array_height, &bit_per_pix, temp_array ); } } } page_mark[++page_no]=byte_in_file; printf("return: continue, p: previous page, q: quit %c>",7); ans=getc(stdin); if(ans=='p' && page_no!=1){ page_no=page_no-2; byte_in_file=page_mark[page_no]; fseek(gb_file, byte_in_file,0); } if(ans!='\n'&& ans!='q') ans=getc(stdin); uisdc$erase(&WD_ID); } } void ginit() { float x1,y1,x2,y2,width,height; struct dsc$descriptor_s screen_desc; char *screen = "sys$workstation"; x1=0.0, y1=0.0, x2=30.0, y2=26.0, width=30.0, height=26.0; VD_ID=uis$create_display( &x1,&y1,&x2,&y2,&width,&height); screen_desc.dsc$w_length = strlen(screen); screen_desc.dsc$a_pointer = screen; screen_desc.dsc$b_class = DSC$K_CLASS_S; screen_desc.dsc$b_dtype = DSC$K_DTYPE_T; WD_ID=uis$create_window( &VD_ID, &screen_desc ); uis$disable_display_list( &VD_ID); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ATTACHMENT: simple code to generate transformed font file * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * FONT_TRAN.c : a crude program that reverses bit order in a file */ #include stdio main() { unsigned char array[32], temp; unsigned long int array_width = 16; unsigned long int array_height = 16; int CHsize=32; FILE *cclib_file_old, *cclib_file_new; int byte, i, m, byte_out; char ans; cclib_file_old = fopen("cclib.16","r"); cclib_file_new = fopen("tcclib.16","w"); m=0; while( (byte=fread(array, CHsize, 1, cclib_file_old))!=0 ) { m++; for(i=0; i