/* * cTIM v.1.0 TIM image converter for dos by Yannick Suter aka asc/Nowadays * * for more informations about it, read README.txt * * feel free to use it! Let me know, if you found some bugs or did a own * converter. * * no more comments! =) if you have some questions or suggestions for * improvements, please email me: asc@netlink.ch * */ #include #include #include "bmp.h" #include "tim.h" FILE *BMPf,*TIMf; unsigned char infile[100],infile2[100],mode = 3; unsigned char *BMPname; unsigned char *TIMname; // ********************************* BMP stuff BITMAPFILEHEADER bmp_filehead; BITMAPINFOHEADER bmp_infohead; unsigned char bmp_4bitpal[4*16]; unsigned char bmp_8bitpal[4*256]; unsigned char *bmpdata; // ********************************* TIM stuff TIMinf TIMinfo; char find_word(char str1[100],char str2[100]){ int where=0,old=0,next=-1,x=0; char *check; char chh = str2[old]; int len1 = strlen(str1); int len2 = strlen(str2); check = (char *)strchr(str1,chh); if(check == NULL) return(0); do{ old = 0; chh = str2[old]; do {next++;}while((str1[next] != chh) && (next < len1)); if(next == len1) return(0); x = next; do{ x++; old++; chh = str2[old]; if(old == len2) return(1); }while((str1[x] == chh)); }while(next1){ strcpy(&infile,gc[1]); strupr(infile);strcpy(&infile2,&infile); if(find_word(infile,".BMP")) { mode = 0; printf(" : BMP file detected!\n"); strcpy(BMPname,&infile); TIMname = (unsigned char*)(strcat(strrev(strrchr(strrev(infile),'.')),"TIM")); }else if(find_word(infile,".TIM")) { mode = 1; printf(" : TIM file detected!\n"); strcpy(TIMname,&infile); BMPname = (unsigned char*)(strcat(strrev(strrchr(strrev(infile),'.')),"BMP")); } else printf(" : file [%s] is neither a TIM file nor a BMP file\n",infile); if(mode == 0) { read_BMP(BMPname); write_TIM(BMPname,TIMname); } else if(mode == 1) { read_TIM(TIMname); write_BMP(BMPname,TIMname); } }else{ printf(" Syntax: CTIM.EXE file.BMP - will convert the file.BMP into a file.TIM\n"); printf(" CTIM.EXE file.TIM - will convert the file.TIM into a file.BMP\n"); } }