/* digit.c dgt1.bat = cl /AL digit.c sketmast mmserial vimage maputila graphlib */ #include #include #include "font.h" #include "nomouse.h" #define MAX_TX 18288 #define MAX_PTS 500 #define MAX_X 640 #define MAX_Y 480 int Mouse=0; int VideoType='X'; struct board { int row,col,color; }B_Id; int ScreenXs=640,ScreenYs=480; unsigned char Buffer[12][MAX_X]; struct Color { unsigned char r, g, b; }lut[256],lutm[256],lutc[256],luts[256]; struct Color Vga[16]= { { 0, 0, 0}, { 255, 0, 0}, /* red */ { 255,128, 0}, /* orange */ { 160,160, 0}, /* yellow */ { 0,200, 0}, /* green */ { 0,120, 0}, /* d_green */ { 0, 72, 0}, /* vd_green */ { 0, 0,255}, /* blue */ { 0,200,200}, /* cyan */ { 0,100,100}, /* d_cyan */ { 46, 46, 46}, /* d_grey */ { 128,128,128}, /* m_grey */ { 191,191,191}, /* l_grey */ { 255,255,255}, /* white */ { 130,111, 93}, /* l_buff */ { 96, 28, 14} /* buff */ }; unsigned char B_Buff[50][MAX_X]; void set_lut(); void digit_lines_xy(); double dget_num(); int DisplayOn(){}; int DisplayOff(){}; main(argc,argv) int argc; char *argv[]; { int i,j,k; char ans; int line; init_board(0,argv[1]); for(i=1;i0) plotln(0,ix,iy,ixo,iyo,color); ixo=ix; iyo=iy; i+=1; if(string2[strlen(string2)-1]=='/') { fprintf(fp,"//\n"); i=0; if(fscanf(fpin,"%d",&color)<1) end=1; else fprintf(fp,"%6d",color); } }while(end==0); fclose(fpin); } color=dval=dget_num("Give line value."," Enter 0 to exit", 5,430,350,46,1,1,34); do { if(first==0&&(ret=map_a_point(&ix,&iy,res,&lx,&ly,13))!=1) dval=dget_num("Give line value."," Enter 0 to exit", 5,430,350,46,1,1,34); color=dval; first=0; if(dval>0) { fprintf(fp,"%6.0lf",dval); i=0; while((ret=map_a_point(&ix,&iy,res,&lx,&ly,13))==1) { if(i==0) { lx1=lx; ly1=ly; ix1=ix; iy1=iy; } if(i%4==0) fprintf(fp,"\n"); else fprintf(fp," "); if(iop==1) fprintf(fp,"%5d %5d",lx,ly); if(iop==2) fprintf(fp,"%5d %5d",ly,MAX_TX-lx); if(i++>0) plotln(3,ix,iy,ixo,iyo,color); else plotpt(3,ix,iy,12); ixo=ix;iyo=iy; } if(ret==2) { if(i%4==0) { if(iop==1) fprintf(fp,"\n%5d %5d//\n",lx1,ly1); if(iop==2) fprintf(fp,"\n%5d %5d//\n",ly1,MAX_TX-lx1); } else { if(iop==1) fprintf(fp," %5d %5d//\n",lx1,ly1); if(iop==2) fprintf(fp," %5d %5d//\n",ly1,MAX_TX-lx1); } plotln(3,ix1,iy1,ixo,iyo,color); } else fprintf(fp,"//\n"); } }while(dval>0.0); Video_Off(); fclose(fp); } /*********************************************************************** ** ** ** *** ************************************************************************/ int Video_Off() { SetVideoMode(0,&B_Id); } /************************************************************************** ** ** ** ************************************************************************* */ int Video_On() { int i,ret,row; i=GetVideoBoardID(); if(i==0) VideoType='E'; else if(i==1&&(VideoType=='X'||VideoType=='Y')) VideoType='V'; if(VideoType=='V') { row=SetVideoMode(0x12,&B_Id); if(B_Id.row!=480||row!=480||B_Id.color!=16||B_Id.col!=640) VideoType='E'; } if(VideoType=='E') row=SetVideoMode(0x10,&B_Id); if(VideoType=='X') { SetVideoMode(480,&B_Id); if(B_Id.row==480) set_lut('c'); else { printf("Computer will not support enough colors.\n\n"); exit(0); } } } /******************************************************************** ** ** type g -- grey all lut[] files ** G -- grey only lut[] ** i -- initial header map ** r -- reset lut[] to lutc[] ** p -- positive (0-127) magenta, negative (128-255) green ** ********************************************************************* */ void set_lut(type) char type; { int k,hue,brite,j; int color[3]; double dbrite,dval; float val,minval; for(k=0;k<16;k++) { lutc[k].r=Vga[k].r; lutc[k].g=Vga[k].g; lutc[k].b=Vga[k].b; } WritePalette(lutc); } /******************************************************************** ** ** ** ********************************************************************* */ double dget_num(string1,string2,xc,yc,xs,ys,save,remove,numenu) int xc,yc,xs,ys,save,remove,numenu; char *string1,*string2; { int j,k; int i=yc+1; int ans; int size=2; int txc=xc,tyc=yc+31,txs=7,tys=15; char string[40],ltr[2]; unsigned char buff[640]; double number; ltr[1]='\0'; if(save==1) save_box(3,0,B_Buff,xc,yc,xs,ys); plot_font_h(12,5,i,string1,size,Font); i+=30/size; plot_font_h(12,5,i,string2,size,Font); i+=30/size; k=0; do { ans=getch(); if(ans==0) { if((ans=getch())==59)help(65); if(ans==60)help(65); ans=getch(); } paint_box(0,0,buff,txc,tyc,txs,tys); if((ans>='0'&&ans<='9')||ans=='-'||ans=='.') { string[k]=ans; ltr[0]=ans; plot_font_h(12,txc,i,ltr,size,Font); k+=1; txc+=7; } if(ans==8&&k>0) { string[k]='\0'; k-=1; txc-=7; paint_box(0,0,buff,txc,tyc,txs,tys); } }while(ans!=13); string[k]='\0'; sscanf(string,"%lf",&number); if(remove==1) unsave_box(3,0,B_Buff,xc,yc,xs,ys); return(number); }