?login_element?

Subversion Repositories NedoOS

Rev

Rev 1713 | Rev 1890 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. //#include <mem.h>
  4. #include <string.h>
  5.  
  6. #define _STRMAX 79
  7.  
  8. #define BYTE unsigned char
  9. #define UINT unsigned int
  10. #define MAXDEFB 8
  11.  
  12. #define MASKCOLOR 0x00
  13.  
  14. BYTE filebuf[65536];
  15. char labelbuf[_STRMAX+1];
  16. char formatlabelbuf[_STRMAX+1];
  17. char commentlabelbuf[_STRMAX+1];
  18. BYTE sizeword[4];
  19. BYTE pic[1024][1024];
  20. BYTE pixrow[1024/8+1][1024+1024];
  21. #define PIXROWSHIFT 1024
  22. BYTE maskrow[1024/8+1][1024];
  23. //BYTE pixrowshift[1024/8][1024]; //>>4
  24. BYTE attrrow[1024/8+1];
  25. BYTE pal[64];
  26.  
  27. #define CONVORDERSZ 1024
  28.  
  29. int convorderx[CONVORDERSZ]; //фы  ърцфюую эюьхЁр Єрщыр ъююЁфшэрЄ√
  30. int convordery[CONVORDERSZ]; //фы  ърцфюую эюьхЁр Єрщыр ъююЁфшэрЄ√
  31.  
  32. int sprcount;
  33. int vertsprcount;
  34.  
  35. BYTE numok;
  36.  
  37. BYTE ink;
  38. BYTE paper;
  39. BYTE curink;
  40. BYTE curpaper;
  41. BYTE defaultcolor;
  42.  
  43. char sprformat;
  44.  
  45. int hgt;
  46. int wid;
  47. int bpp;
  48.  
  49. void skiplf(FILE * fin)
  50. { //тючьюцэю, 0x0d єцх яЁюўшЄрэ, ЄхяхЁ№ яЁюяєёърхь 0x0a
  51. char c;
  52.   do{
  53.     if (!fread(&c,1,1,fin)) break;
  54.   }while (c!=0x0a);
  55. }
  56.  
  57. void readcomment(FILE * fin, char * s)
  58. { //тючьюцэю, 0x0d єцх яЁюўшЄрэ, ЄхяхЁ№ яЁюяєёърхь 0x0a
  59. char c;
  60. unsigned int i;
  61.   i = 0;
  62.   do{
  63.     if (!fread(&c,1,1,fin)) break;
  64.     if (i==_STRMAX) break;
  65.     s[i] = c;
  66.     i++;
  67.   }while (c!=0x0a);
  68.   s[i] = '\0';
  69. }
  70.  
  71. int readnum(FILE * fin)
  72. {
  73. char c;
  74. int num;
  75. int sign=1;
  76.   num = 0;
  77.   do{
  78.     if (!fread(&c,1,1,fin)) break;
  79.     if (c==' ') goto skip;
  80.     //if (c == 0x0d) goto skip;
  81.     //if (c == 0x0a) break;
  82.     if (c=='-') {sign = -1; goto skip;};
  83.     if ((c<'0')||(c>'9')) break; //т Єюь ўшёых 0x0a
  84.     num = num*10 + (int)(c-'0');
  85.     numok = 0xff;
  86. skip:
  87.         ;
  88.   }while(1);
  89.   num = num*sign;
  90. return num;
  91. }
  92.  
  93. unsigned int readlabel(FILE * fin, char * s)
  94. {
  95. char c;
  96. unsigned int i;
  97. int iscomment;
  98.   sprcount = 0;
  99.   vertsprcount = 0;
  100.   do{
  101.     i = 0;
  102.     iscomment = 0;
  103.     do{
  104.       if (!fread(&c,1,1,fin)) break;
  105.       if (c == ';') iscomment = -1;
  106.       if (c=='$') { //фры№°х ўшёыю ёяЁрщЄют тхЁЄшъры№эю
  107.         if (iscomment) continue; //т ъюььхэЄрї ьюцэю $
  108.         while (1) {
  109.           if (!fread(&c,1,1,fin)) return 0;
  110.           if ((c < '0') || (c > '9')) break;
  111.           vertsprcount = vertsprcount*10;
  112.           vertsprcount = vertsprcount + (int)(c-'0');
  113.         };
  114.       };
  115.       if (c=='#') { //фры№°х ўшёыю ёяЁрщЄют
  116.         if (iscomment) continue; //т ъюььхэЄрї ьюцэю #
  117.         while (1) {
  118.           if (!fread(&c,1,1,fin)) return 0;
  119.           if ((c < '0') || (c > '9')) break;
  120.           sprcount = sprcount*10;
  121.           sprcount = sprcount + (int)(c-'0');
  122.         };
  123.       };
  124.       if ((c=='=')||(c==',')) {
  125.         if (iscomment) continue; //т ъюььхэЄрї ьюцэю =
  126.         break;
  127.       };
  128.       if (c == 0x0d) continue;
  129.       if (c == 0x0a) {
  130.         if (iscomment) break; //ъюььхэЄ√ ъюэўр■Єё  яю ъюэЎє ёЄЁюъш
  131.         continue;
  132.       };
  133.       if (i==_STRMAX) break;
  134.       s[i] = c;
  135.       i++;
  136.     }while(1);
  137.     s[i] = '\0';
  138.   }while(iscomment);
  139. return i;
  140. }
  141.  
  142. int read4b(FILE * fin)
  143. {
  144.   fread(sizeword, 4, 1, fin);
  145. return sizeword[0] + (sizeword[1]<<8) + (sizeword[2]<<16) + (sizeword[3]<<24);
  146. }
  147.  
  148. BYTE colstat[256];
  149.  
  150. char numbuf[256];
  151.  
  152. UINT maxsprcount;
  153. UINT cursprcount;
  154. UINT maxvertsprcount;
  155. UINT curvertsprcount;
  156.  
  157. void putlabel(char * labelbuf, FILE * fout)
  158. {
  159. UINT num;
  160. UINT i;
  161.         fputs(labelbuf, fout);
  162.         if (maxvertsprcount != 0) {
  163.           fputc('_', fout);
  164.           fputc('_', fout);
  165.           num = curvertsprcount;
  166.  
  167.           i = 0;
  168.           do {
  169.             numbuf[i] = (char)((UINT)'0' + (num - (num/10)*10));
  170.             num = num/10;
  171.             i++;
  172.           } while (num != 0);
  173.  
  174.           do {
  175.             i--;
  176.             fputc(numbuf[i], fout);
  177.           } while (i != 0);
  178.         };
  179.         if (maxsprcount != 0) {
  180.           fputc('_', fout);
  181.           num = cursprcount;
  182.  
  183.           i = 0;
  184.           do {
  185.             numbuf[i] = (char)((UINT)'0' + (num - (num/10)*10));
  186.             num = num/10;
  187.             i++;
  188.           } while (num != 0);
  189.  
  190.           do {
  191.             i--;
  192.             fputc(numbuf[i], fout);
  193.           } while (i != 0);
  194.         };
  195. return;
  196. }
  197.  
  198. void findinkpaper(int x, int y) //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь
  199. {
  200. //BYTE b;
  201. int i;
  202. int j;
  203. BYTE col1;
  204. BYTE col1stat;
  205. BYTE col2;
  206. BYTE col2stat;
  207. BYTE col3;
  208. BYTE col3stat;
  209. BYTE col4;
  210. BYTE col4stat; //эр ёыєўрщ Єръющ ёЄрЄшёЄшъш: MASKCOLOR, RED, red, anothercolor
  211.   i = 0; do {colstat[i] = 0x00; i++;}while (i!=256);
  212.  
  213.   //col1 = pic[x][y];
  214.   j = y;
  215.   while (j < (y+8)) {
  216. //    b = 0x00;
  217.     i = x;
  218.     while (i < (x+8)) {
  219.       colstat[pic[i][j]]++;
  220.       //b = pic[i][j];
  221.       //if (b!=col1) col2 = b;
  222.       i++;
  223.     };
  224.     j++;
  225.   };
  226.  
  227. //ьрёър MASKCOLOR эх ёўшЄрхЄё  ЎтхЄюь
  228.   col1 = MASKCOLOR; col1stat = 0; //fix 27.12.2018
  229.   col2 = MASKCOLOR; col2stat = 0; //fix 27.12.2018
  230.   col3 = MASKCOLOR; col3stat = 0; //fix 27.12.2018
  231.   col4 = MASKCOLOR; col3stat = 0; //fix 27.12.2018
  232.   i = 0; do { //fix 27.12.2018 (эр ёыєўрщ MASKCOLOR!=0)
  233.     if (colstat[i] > col1stat) {
  234.       col4 = col3;
  235.       col4stat = col3stat;
  236.       col3 = col2;
  237.       col3stat = col2stat;
  238.       col2 = col1;
  239.       col2stat = col1stat;
  240.       col1 = (BYTE)i;
  241.       col1stat = colstat[i];
  242.     }else if (colstat[i] > col2stat) {
  243.       col4 = col3;
  244.       col4stat = col3stat;
  245.       col3 = col2;
  246.       col3stat = col2stat;
  247.       col2 = (BYTE)i;
  248.       col2stat = colstat[i];
  249.     }else if (colstat[i] > col3stat) {
  250.       col4 = col3;
  251.       col4stat = col3stat;
  252.       col3 = (BYTE)i;
  253.       col3stat = colstat[i];
  254.     }else if (colstat[i] > col4stat) {
  255.       col4 = (BYTE)i;
  256.       col4stat = colstat[i];
  257.     };
  258.     i++;
  259.   }while (i!=16); //fix 27.12.2018
  260.  
  261. //MASKCOLOR эхы№ч  ёрь√ь ўрёЄ√ь, ёюЁЄшЁєхь хую т ъюэхЎ
  262.   if (col1==MASKCOLOR) {
  263.     col1 = col2;
  264.     col2 = MASKCOLOR;
  265.   };
  266.   if (col2==MASKCOLOR) {
  267.     col2 = col3;
  268.     col3 = MASKCOLOR;
  269.   };
  270.   if (col3==MASKCOLOR) {
  271.     col3 = col4;
  272.     col4 = MASKCOLOR;
  273.   };
  274.  
  275. //col1 ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  276. //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь, яю¤Єюьє 0x08 яхЁхтюфшЄё  т 0x00 ё фхЇюыЄэющ  ЁъюёЄ№■ (ўЄюс√ эх тыш Є№ эр bright)
  277.   //if ((col1&0x07)==0x00) col1 = (BYTE)(defaultcolor&0x08); //fix 27.12.2018
  278.   //if ((col2&0x07)==0x00) col2 = (BYTE)(defaultcolor&0x08); //fix 27.12.2018
  279. /**  if (col2 == MASKCOLOR) {
  280.     if (col1 == MASKCOLOR) {
  281.       col2 = (BYTE)((col1&0x08) | (defaultcolor&0x07));
  282.     }else {
  283.       col2 = (BYTE)((col1&0x08) | (defaultcolor&0x07));
  284.     };
  285.   };*/ //fix 27.12.2018
  286.   if (((col2&0x07)==(col1&0x07)) /**&& (col2!=0x00)*/) col2 = col3; //same colour with another bright
  287.   ink = col1;
  288.   paper = col2; //Ёхцх
  289.   //paper Ёхцх ш ьюцхЄ с√Є№ MASKCOLOR (эхЄ тЄюЁюую ЎтхЄр, эрфю сЁрЄ№ фхЇюыЄэ√щ)
  290.   //ink ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  291. }
  292.  
  293. void setcurinkpaper(BYTE* pcurink, BYTE* pcurpaper)
  294. //paper Ёхцх ш ьюцхЄ с√Є№ MASKCOLOR (эхЄ тЄюЁюую ЎтхЄр, эрфю сЁрЄ№ фхЇюыЄэ√щ)
  295. //ink ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  296. //*pcurink, *curpaper шчэрўры№эю ёюфхЁцрЄ рЄЁшсєЄ√ яЁхф√фє∙хую чэръюьхёЄр
  297. //тючтЁр∙рхЄ *pcurink, *curpaper, яЁшў╕ь тьхёЄю 0x08 ёЄртшЄ 0x00 (ўЄюс√ эх тыш ыю эр  ЁъюёЄ№)
  298. {
  299. BYTE t;
  300.   if ((sprformat == 's')||(sprformat == 'y')||(sprformat == 'Z')||(sprformat == 'z')||(sprformat == 'W')||(sprformat == 'w')) {
  301.     paper = 0x08;
  302.     ink = 0x0f;
  303.   }; //фы  ёяЁрщЄют Їюэ ў╕Ёэ√щ (р ьрёър 0x00)
  304.  
  305. //27.02.2019:
  306. //Їюэ фы  чрышЄ√ї чэръюьхёЄ эрўшэр  ё чхы╕эюую ЄхяхЁ№ ў╕Ёэ√щ[шыш эрфю яЁхф√фє∙шщ?]
  307. //Їюэ фы  ў╕Ёэ√ї чэръюьхёЄ схЁ╕Є  ЁъюёЄ№ юЄ defaultcolor, р фы  чрышЄ√ї чэръюьхёЄ ьхэхх чхы╕эюую эх схЁ╕Є
  308. #define MINCOLORWITHBLACKBG 0x04
  309. //fix 27.12.2018:
  310.   if (((ink&0x07)==(*pcurink&0x07)) && (ink!=MASKCOLOR)) { //ink ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє
  311.     *pcurink = ink;
  312.     if (paper==MASKCOLOR) {
  313.       *pcurpaper = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  314.     }else {
  315.       *pcurpaper = paper;
  316.     };
  317.   }else if (((paper&0x07)==(*pcurpaper&0x07)) && (paper!=MASKCOLOR)) { //paper ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє
  318.     *pcurpaper = paper;
  319.     if (ink==MASKCOLOR) {
  320.       *pcurink = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  321.     }else {
  322.       *pcurink = ink;
  323.     };
  324.   }else if (((paper&0x07)==(*pcurink&0x07)) && (paper!=MASKCOLOR)) { //paper ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє ink
  325.     *pcurink = paper;
  326.     if (ink==MASKCOLOR) {
  327.       *pcurpaper = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  328.     }else {
  329.       *pcurpaper = ink;
  330.     };
  331.   }else if (((ink&0x07)==(*pcurpaper&0x07)) && (ink!=MASKCOLOR)) { //ink ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє paper
  332.     *pcurpaper = ink;
  333.     if (paper==MASKCOLOR) {
  334.       *pcurink = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  335.     }else {
  336.       *pcurink = paper;
  337.     };
  338.   }else if ((ink==MASKCOLOR)&&(paper==MASKCOLOR)) { //юср ЎтхЄр MASKCOLOR
  339.     ink = defaultcolor;
  340.     paper = 0x08;
  341.   }else { //юср ЎтхЄр эх ёююЄтхЄёЄтє■Є яЁхф√фє∙хьє чэръюьхёЄє, эю эх юср MASKCOLOR
  342.     if (ink == MASKCOLOR) ink = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  343.     if (paper == MASKCOLOR) paper = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  344.     if (ink > paper) {
  345.       *pcurink = ink;
  346.       *pcurpaper = paper;
  347.     }else {
  348.       *pcurink = paper;
  349.       *pcurpaper = ink;
  350.     };
  351.   };
  352.  
  353.     //*pcurink = ink;
  354.     //*pcurpaper = paper;
  355.  
  356.   if (*pcurpaper==0x08) *pcurpaper = 0x00; //ўЄюс√ эх тыш ыю эр  ЁъюёЄ№ //fix 27.12.2018
  357.   if (*pcurink==0x08) *pcurink = 0x00; //ўЄюс√ эх тыш ыю эр  ЁъюёЄ№ //fix 27.12.2018
  358.   //эр ў╕Ёэюь/ёшэхь Їюэх ink фюыцхэ с√Є№  Ёўх paper'р (юЄфхы№э√щ ёыєўрщ, Є.ъ. юёЄры№э√х, фрцх яєёЄ√х, чэръюьхёЄр ьюуєЄ єўрёЄтютрЄ№ т юЄЁшёютъх ёъЁюыышЁєхь√ї Їюэют ё эхяЁхЁ√тэ√ьш Ўхяюўърьш ink-paper)
  359.   //Єю хёЄ№ эхы№ч  ink=0, р 1 Єюы№ъю т ёыєўрх paper=0
  360.   if (((*pcurink&0x07)<=0x01) && ((*pcurpaper&0x07)>(*pcurink&0x07))) { //ў╕Ёэюх/ёшэхх яєёЄюх чэръюьхёЄю (юЄфхы№э√щ ёыєўрщ, Є.ъ. юёЄры№э√х яєёЄ√х ьюуєЄ єўрёЄтютрЄ№ т юЄЁшёютъх ёъЁюыышЁєхь√ї Їюэют ё эхяЁхЁ√тэ√ьш Ўхяюўърьш ink-paper)
  361.     t = *pcurpaper;
  362.     *pcurpaper = *pcurink;
  363.     *pcurink = t;
  364.   };
  365. }
  366.  
  367. void emitdb(BYTE b, FILE * fout)
  368. {
  369.   fputs("\tdb ", fout);
  370.   fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  371.   fputs("\n", fout);
  372. }
  373.  
  374. void emitdw(UINT u, FILE * fout)
  375. {
  376.   fputs("\tdw ", fout);
  377.   fprintf(fout, "0x%x%x%x%x", (u>>12)&0x0f, (u>>8)&0x0f, (u>>4)&0x0f, u&0x0f);
  378.   fputs("\n", fout);
  379. }
  380.  
  381. void emitnops(BYTE count, FILE * fout)
  382. {
  383.   fputs("\tds ", fout);
  384.   fprintf(fout, "0x%x%x", count>>4, count&0x0f);
  385.   fputs("\n", fout);
  386. }
  387.  
  388. void emitspr(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  389. {
  390. BYTE b;
  391. int i;
  392. int j;
  393.   j = y;
  394.   while (1) {
  395.     fputs("\tdb ", fout);
  396.     i = xchr;
  397.     while (1) {
  398.       b = maskrow[i][j];
  399.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  400.       fputs(",", fout);
  401.       b = b^pixrow[i][j];
  402.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  403.       i++;
  404.       if (i >= (xchr+sprwid8)) break;
  405.       fputs(",", fout);
  406.     };
  407.     fputs("\n", fout);
  408.     j++;
  409.     if (j >= (y+sprhgt)) break;
  410.   };
  411. }
  412.  
  413. void emitspry(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  414. {
  415. BYTE b;
  416. int i;
  417. int j;
  418.   i = xchr;
  419.   while (1) {
  420.     fputs("\tdb ", fout);
  421.     j = y;
  422.     while (1) {
  423.       b = ~maskrow[i][j];
  424.       b = b^pixrow[i][j];
  425.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  426.       fputs(",", fout);
  427.       //b = maskrow[i][j];
  428.       b = pixrow[i][j];
  429.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  430.       j++;
  431.       if (j >= (y+sprhgt)) break;
  432.       fputs(",", fout);
  433.     };
  434.     fputs("\n", fout);
  435.     i++;
  436.     if (i >= (xchr+sprwid8)) break;
  437.   };
  438. }
  439.  
  440. void emitsprw(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  441. { //antipixelsline, antimaskline
  442. BYTE b;
  443. int i;
  444. int j;
  445.   j = y;
  446.   while (1) {
  447.     fputs("\tdb ", fout);
  448.     i = xchr;
  449.     while (1) {
  450.       b = ~maskrow[i][j];
  451.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  452.       i++;
  453.       if (i == xchr+sprwid8) break;
  454.       fputs(",", fout);
  455.     };
  456.     fputs("\n", fout);
  457.     fputs("\tdb ", fout);
  458.     i = xchr;
  459.     while (1) {
  460.       b = ~maskrow[i][j];
  461.       b ^= pixrow[i][j];
  462.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  463.       i++;
  464.       if (i == xchr+sprwid8) break;
  465.       fputs(",", fout);
  466.     };
  467.     fputs("\n", fout);
  468.     j++;
  469.     if (j >= (y+sprhgt)) break;
  470.   };
  471. }
  472.  
  473. void emitsprwback(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  474. { //antipixelsw, antimaskw
  475. BYTE b;
  476. int i;
  477. int j;
  478.   j = y;
  479.   while (1) {
  480.     fputs("\tdb ", fout);
  481.     i = xchr+sprwid8;
  482.     while (1) {
  483.       i--;
  484.       b = ~maskrow[i][j];
  485.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  486.       if (i == xchr) break;
  487.       fputs(",", fout);
  488.     };
  489.     fputs("\n", fout);
  490.     fputs("\tdb ", fout);
  491.     i = xchr+sprwid8;
  492.     while (1) {
  493.       i--;
  494.       b = ~maskrow[i][j];
  495.       b ^= pixrow[i][j];
  496.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  497.       if (i == xchr) break;
  498.       fputs(",", fout);
  499.     };
  500.     fputs("\n", fout);
  501.     j++;
  502.     if (j >= (y+sprhgt)) break;
  503.   };
  504. }
  505.  
  506. void emitsprwnomask(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  507. { //antipixelsw
  508. BYTE b;
  509. int i;
  510. int j;
  511.   j = y;
  512.   while (1) {
  513.     fputs("\tdb ", fout);
  514.     i = xchr;
  515.     while (1) {
  516.       b = ~maskrow[i][j];
  517.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  518.       i++;
  519.       if (i == xchr+sprwid8) break;
  520.       fputs(",", fout);
  521.     };
  522.     fputs("\n", fout);
  523.     j++;
  524.     if (j >= (y+sprhgt)) break;
  525.   };
  526. }
  527.  
  528. void emitsprwnomaskback(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  529. { //antipixelsw
  530. BYTE b;
  531. int i;
  532. int j;
  533.   j = y;
  534.   while (1) {
  535.     fputs("\tdb ", fout);
  536.     i = xchr+sprwid8;
  537.     while (1) {
  538.       i--;
  539.       b = ~maskrow[i][j];
  540.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  541.       if (i == xchr) break;
  542.       fputs(",", fout);
  543.     };
  544.     fputs("\n", fout);
  545.     j++;
  546.     if (j >= (y+sprhgt)) break;
  547.   };
  548. }
  549.  
  550. void emitimgW(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  551. { //by columns
  552. BYTE b;
  553. int i;
  554. int j;
  555.   i = xchr;
  556.   while (1) {
  557.     fputs("\tdb ", fout);
  558.     j = y;
  559.     while (1) {
  560.       b = maskrow[i][j];
  561.                   //fprintf(fout, "0x%x%x ", i>>4, i&0x0f);
  562.                   //fprintf(fout, "0x%x%x ", j>>4, j&0x0f);
  563.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  564.       j++;
  565.       if (j >= (y+sprhgt)) break;
  566.       fputs(",", fout);
  567.     };
  568.     fputs("\n", fout);
  569.     i++;
  570.     if (i == (xchr+sprwid8)) break;
  571.   };
  572. }
  573.  
  574. void emitchr_(int xchr, int y, FILE * fout)
  575. {
  576. BYTE b;
  577. int j;
  578.   fputs("\tdb ", fout);
  579.   j = y;
  580.   while (1) {
  581.     b = pixrow[xchr][j];
  582.     fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  583.     j++;
  584.     if (j >= (y+8)) break;
  585.     fputs(",", fout);
  586.   };
  587.   if (sprformat < 'a') { //capital letter format => attr used
  588.     b = attrrow[xchr]; //0x07;
  589.     fputs(",", fout);
  590.     fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  591.   };
  592.   fputs("\n", fout);
  593. }
  594.  
  595. void emitchr(int xchr, int y, FILE * fout)
  596. {
  597.   emitchr_(xchr, y, fout);
  598. }
  599.  
  600. void emitchrshift(int xchr, int y, FILE * fout)
  601. {
  602.   emitchr_(xchr, y+PIXROWSHIFT, fout);
  603. }
  604.  
  605. //ёфтшурхь Ё ф чэръюьхёЄ >>shiftbits, Ёхчєы№ЄрЄ т pixrow[sprx][y+PIXROWSHIFT]
  606. void shiftrow(int sprx, int y, int sprwid, int rowhgt, int pixrowshift, BYTE shiftbits)
  607. {
  608. int j;
  609. int x;
  610. BYTE b;
  611. BYTE b0;
  612. BYTE shiftmask;
  613.   shiftmask = (BYTE)(0xff>>(0x08-shiftbits)); //хёыш shiftbits==0x01, Єю shiftmask==0x01
  614.   j = y;
  615.   while (j < (y+rowhgt)) {
  616.     b = 0x00;
  617.     x = sprx;
  618.     while (x < (sprx+sprwid+8)) {
  619.       b0 = pixrow[x/8][j];
  620.       pixrow[x/8][j+pixrowshift] = (BYTE)((b<<(0x08-shiftbits)) + (b0>>shiftbits));
  621.       b = (BYTE)(b0&shiftmask/**0x0f*/); //хёыш shiftbits==0x01, Єю shiftmask==0x01
  622.       x = x+8;
  623.     };
  624.     j++;
  625.   };
  626. }
  627.  
  628. //data: wid8, hgt8, chrgfx, chrgfx...
  629. void resfile(char * finname, char * fintxtname, char * foutname)
  630. {
  631. FILE* fin;
  632. FILE* fintxt;
  633. FILE* fout;
  634. int i;
  635. int j;
  636. int size;
  637. int y;
  638. int x;
  639. int n;
  640. int tiles;
  641.  
  642. BYTE b;
  643. BYTE bmask;
  644. BYTE b0;
  645.  
  646. int sprx;
  647. int startsprx;
  648. int spry;
  649. int sprwid;
  650. int sprhgt;
  651. int rowhgt; //8 for tiles, sprhgt for sprites
  652.  
  653. UINT color;
  654.  
  655.   fin = fopen(finname, "rb");
  656.   if (fin) {
  657.     fread(filebuf, 10, 1, fin); //skip to 10 (header size)
  658.     size = read4b(fin); //10 (header size)
  659.     fread(filebuf, 4, 1, fin); //skip to 18
  660.     wid = read4b(fin); //18
  661.     hgt = read4b(fin); //22
  662.     fread(filebuf, 2, 1, fin); //skip to 28
  663.     fread(&bpp, 1, 1, fin); //28
  664.     fread(filebuf, 1, 54-29, fin); //skip to pal
  665.     fread(pal, 1, 64, fin); //ярышЄЁр (B, G, R, 0)
  666.     if (size > (54+64)) {fread(filebuf, 1, size-(54+64), fin);}; //skip to pic
  667.     if ((wid>0)&&(wid<=1024)&&(hgt>0)&&(hgt<=1024)&&((wid&7)==0)&&((hgt&7)==0)) {
  668.       y = hgt;
  669.       while (y>0) {
  670.         y--;
  671.         x = 0;
  672.         while (x<wid) {
  673.           fread(&b, 1, 1, fin);
  674.           if (bpp == 8) {
  675.             pic[x][y] = b;
  676.             x++;
  677.           }else {
  678.             pic[x][y] = (BYTE)((b&0xf0)>>4);
  679.             x++;
  680.             pic[x][y] = (BYTE)(b&0x0f);
  681.             x++;
  682.           };
  683.         };
  684.       };
  685.  
  686.       fintxt = fopen(fintxtname, "rb");
  687.       if (fintxt) {
  688.         fout = fopen(foutname, "wb");
  689.         if (fout) {
  690. /**          if (labelname[0]!='\0') {
  691.             fputs(labelname, fout);
  692.             fputs("\n", fout);
  693.           };*/
  694.           while (1) {
  695.             size = readlabel(fintxt, labelbuf); //fread(filebuf, 1, MAXDEFB, fin);
  696.            maxvertsprcount = vertsprcount;
  697.            maxsprcount = sprcount;
  698.             if (size == 0) break;
  699.             readlabel(fintxt, formatlabelbuf); //format
  700.             sprformat = *formatlabelbuf;
  701.             startsprx = readnum(fintxt);
  702.             spry = readnum(fintxt);
  703.             sprwid = readnum(fintxt);
  704.             sprhgt = readnum(fintxt);
  705.             numok = 0x00;
  706.             tiles = readnum(fintxt); //юЄёєЄёЄтєхЄ т x
  707.             defaultcolor = (BYTE)tiles; //фы  тёхї, ъЁюьх L
  708.             *commentlabelbuf = '\0';
  709.             if ((numok != 0x00) && (sprformat != 'L')) readcomment(fintxt, commentlabelbuf);
  710.            curvertsprcount = 0;
  711.            do { //vertsprcount
  712.            cursprcount = 0;
  713.            sprx = startsprx;
  714.            do { //sprcount
  715.             if ((sprformat == 'B')||(sprformat == 'b')) {
  716.               putlabel(labelbuf, fout);
  717.               fputs("\n", fout);
  718.               //emitdb((BYTE)(sprwid>>3), fout);
  719.               //emitdb((BYTE)(sprhgt>>3), fout);
  720.               rowhgt = 8;
  721.             }else if (sprformat == 'T') { //эрсюЁ Єрщыют
  722.               fputs("\tds (-$)&0xff\n", fout);
  723.               putlabel(labelbuf, fout);
  724.               fputs("\n", fout);
  725.               rowhgt = 8;
  726.             }else if (sprformat == 'x') { //ёяЁрщЄ 16c
  727.               fputs("\n", fout);
  728.               putlabel(labelbuf, fout);
  729.               fputs("=$+4\n", fout);
  730.               fputs("\n", fout);
  731.               emitdb((BYTE)(sprwid>>1), fout);
  732.               emitdb((BYTE)(sprhgt), fout);
  733.               rowhgt = sprhgt;
  734.             }else if ((sprformat == 'i')||(sprformat == 'I')) { //ърЁЄшэър 16c яю ёЄюысЎрь
  735.               fputs("\n", fout);
  736.               putlabel(labelbuf, fout);
  737.               fputs("\n", fout);
  738.               rowhgt = sprhgt;
  739.             }else if (sprformat == 'L') { //LAND ъръ т ╫┬, фры№°х ёыхфєхЄ ЄрсышЎр - эюьхЁ Єрщыр фы  ърцфющ ъыхЄъш
  740.               fputs("\n", fout);
  741.               putlabel(labelbuf, fout);
  742.               fputs("\n", fout);
  743.               rowhgt = sprhgt;
  744.             }else if (sprformat == 'P') { //DDp palette
  745.               fputs("\n", fout);
  746.               putlabel(labelbuf, fout);
  747.               fputs("\n", fout);
  748.               i = 0;
  749.               while (i < 64) { //DDp palette: %grbG11RB(low),%grbG11RB(high), шэтхЁёэ√х //color = highlow
  750.                 color = 0; //pal = ярышЄЁр (B, G, R, 0)
  751.                 if (pal[i]&0x80) color = color | 0x0100;
  752.                 if (pal[i]&0x40) color = color | 0x2000;
  753.                 if (pal[i]&0x20) color = color | 0x0001;
  754.                 if (pal[i]&0x10) color = color | 0x0020;
  755.                 i++;
  756.                 if (pal[i]&0x80) color = color | 0x1000;
  757.                 if (pal[i]&0x40) color = color | 0x8000;
  758.                 if (pal[i]&0x20) color = color | 0x0010;
  759.                 if (pal[i]&0x10) color = color | 0x0080;
  760.                 i++;
  761.                 if (pal[i]&0x80) color = color | 0x0200;
  762.                 if (pal[i]&0x40) color = color | 0x4000;
  763.                 if (pal[i]&0x20) color = color | 0x0002;
  764.                 if (pal[i]&0x10) color = color | 0x0040;
  765.                 i++;
  766.                 emitdw(~color, fout);
  767.                 i++;
  768.               };
  769.               fputs("\n", fout);
  770.               rowhgt = sprhgt;
  771.             }else if ((sprformat == 'w')||(sprformat == 'W')||(sprformat == 'z')||(sprformat == 'Z')||(sprformat == 'y')) {
  772.               putlabel(labelbuf, fout);
  773.               fputs("\n", fout);
  774.               rowhgt = sprhgt;
  775.             }else if (sprformat == 'c') {
  776.               putlabel(labelbuf, fout);
  777.               fputs("\n", fout);
  778.               rowhgt = sprhgt;
  779.             }else { //'s'
  780.               putlabel(labelbuf, fout);
  781.               fputs("\n", fout);
  782.               emitdb((BYTE)(sprwid>>3), fout);
  783.               emitdb((BYTE)(sprhgt), fout);
  784.               rowhgt = sprhgt;
  785.             };
  786.  
  787. //copy comment as code line
  788.               fputs(commentlabelbuf, fout);
  789.               //fputs("\n", fout);
  790.  
  791.             y = spry;
  792.             while (y < (spry+sprhgt)) {
  793.               //яхЁхъюфшЁєхь Ё ф чэръюьхёЄ т√ёюЄющ rowhgt
  794.               curink = 0x0f;
  795.               curpaper = 0x08;
  796.               x = 0;//sprx;
  797.               while (x < (sprx+sprwid)) {
  798.                 findinkpaper(x, y);
  799.                 setcurinkpaper(&curink, &curpaper);
  800.               //curink = 0x0f;
  801.               //curpaper = 0x08;
  802. //  if (sprformat == 'c') {
  803. //    curpaper = 0;
  804. //    curink = 1;
  805. //  };
  806.                 j = y;
  807.                 while (j < (y+rowhgt)) {
  808.                   b = 0x00;
  809.                   bmask = 0x00;
  810.                   i = x;
  811.                   while (i < (x+8)) {
  812.                     b = (BYTE)(b<<1);
  813.                     bmask = (BYTE)(bmask<<1);
  814.                     //if (sprformat != 'B') {fprintf(fout, "0x%x%x\n", (pic[i][j])>>4, (pic[i][j])&0x0f);};
  815.                     if (pic[i][j]==curink) b++;
  816.                     if (pic[i][j]!=0x00) bmask++;
  817.                     i++;
  818.                   };
  819.                   pixrow[x/8][j] = b;
  820.                   maskrow[x/8][j] = bmask;
  821.                   //fprintf(fout, "0x%x%x ", x>>4, x&0x0f);
  822.                   //fprintf(fout, "0x%x%x ", j>>4, j&0x0f);
  823.                   //fprintf(fout, "0x%x%x ", b>>4, b&0x0f);
  824.                   //fprintf(fout, "0x%x%x\n", bmask>>4, bmask&0x0f);
  825.                   pixrow[(x/8)+1][j] = 0x00; //ўЄюс√ ёфтшурЄ№
  826.                   j++;
  827.                 };
  828. //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь, яю¤Єюьє 0x08 яхЁхтюфшЄё  т 0x00 (ўЄюс√ эх тыш Є№ эр bright)
  829.                 b = 0x00; if (curink!=0x08) b = curink;
  830.                 b0 = 0x00; if (curpaper!=0x08) b0 = curpaper;
  831.                 attrrow[x/8    ] = (BYTE)( (((b|b0)&0x08)<<3)+((curpaper&0x07)<<3)+(curink&0x07) );
  832.                 attrrow[(x/8)+1] = (BYTE)( (((b|b0)&0x08)<<3)+((curpaper&0x07)<<3)+(curink&0x07) ); //ўЄюс√ ёфтшурЄ№
  833.                 x = x+8;
  834.               };
  835.   //            shiftrow(sprx, y, sprwid, rowhgt, PIXROWSHIFT, 0x04); //ёфтшурхь Ё ф чэръюьхёЄ >>4, Ёхчєы№ЄрЄ т pixrow[sprx][y+PIXROWSHIFT]
  836.  
  837.               //т√тюфшь т рёь
  838.               if ((sprformat == 'B')||(sprformat == 'b')) { //tiles or bw tiles
  839.                 x = sprx;
  840.                 while (x < (sprx+sprwid)) {
  841.   //                emitchrshift(x/8,y,fout);
  842.                   emitchr(x/8,y,fout); //checks for capital letter in sprformat
  843.                   x = x+8;
  844.                 };
  845.   //              emitchrshift(x/8,y,fout);
  846.               }else if (sprformat == 'T') {
  847.                 x = sprx;
  848.                 while (x < (sprx+sprwid)) {
  849.                   emitchr(x/8,y,fout);
  850.                   x = x+8;
  851.                 };
  852.                 emitnops((BYTE)(0x100-((BYTE)(sprwid>>3)*0x09)),fout);
  853.               }else if (sprformat == 's') { //sprite
  854.                 emitspr(sprx/8,y,sprwid/8,sprhgt,fout);
  855.               }else if (sprformat == 'y') { //spritey
  856.                 emitspry(sprx/8,y,sprwid/8,sprhgt,fout);
  857.               }else if (sprformat == 'w') { //sprite antipixels16, antimask16 right to left
  858.                 emitsprwback(sprx/8,y,sprwid/8,sprhgt,fout);
  859.               }else if (sprformat == 'W') { //sprite antipixels16, antimask16
  860.                 emitsprw(sprx/8,y,sprwid/8,sprhgt,fout);
  861.               }else if (sprformat == 'z') { //unmasked sprite right to left
  862.                 emitsprwnomaskback(sprx/8,y,sprwid/8,sprhgt,fout);
  863.               }else if (sprformat == 'Z') { //unmasked sprite
  864.                 emitsprwnomask(sprx/8,y,sprwid/8,sprhgt,fout);
  865.               }else if (sprformat == 'c') { //b/w image by columns
  866.                 emitimgW(sprx/8,y,sprwid/8,sprhgt,fout);
  867.                 //emitimgW(0,0,128,128,fout);
  868.               };
  869.               y = y+rowhgt;
  870.             }; //while y
  871.  
  872.             if (sprformat == 'x') {
  873.               x = sprx;
  874.               while (x < (sprx+sprwid)) {
  875.                 y = spry;
  876.                 while (y < (spry+sprhgt)) {
  877.                   b = pic[x][y]; //L
  878.                   b0 = pic[x+1][y]; //R
  879.                   bmask = 0; //0x47(L) ш 0xb8(R) т Єхї ьхёЄрї, уфх ЎтхЄ=16:
  880.                   if (b == 16) {bmask = bmask + 0x47; b = 0x00;};
  881.                   if (b0 == 16) {bmask = bmask + 0xb8; b0 = 0x00;};
  882.                   b = ((b&0x08)<<3) + (b&0x07) + ((b0&0x08)<<4) + ((b0&0x07)<<3);
  883.                   fputs("\tdb ", fout);
  884.                   fprintf(fout, "0x%x%x", bmask>>4, bmask&0x0f);
  885.                   fprintf(fout, ",0x%x%x", b>>4, b&0x0f);
  886.                   fputs("\n", fout);
  887.                   y = y+1;
  888.                 };
  889.                 x = x+2;
  890.                 if (x < (sprx+sprwid)) {
  891.                   emitdw(0x4000-((sprhgt-1)*40), fout);
  892.                 }else {
  893.                   emitdw(0xffff, fout);
  894.                 };
  895.                 fputs("\n", fout);
  896.               };
  897.               fputs("\tdw prsprqwid\n", fout);
  898.             };
  899.  
  900.             if (sprformat == 'i') {
  901.               x = sprx;
  902.               while (x < (sprx+sprwid)) {
  903.                 y = spry;
  904.                 while (y < (spry+sprhgt)) {
  905.                   b = pic[x][y]; //L
  906.                   b0 = pic[x+1][y]; //R
  907.                   b = ((b&0x08)<<3) + (b&0x07) + ((b0&0x08)<<4) + ((b0&0x07)<<3);
  908.                   fprintf(fout, "\tdb 0x%x%x", b>>4, b&0x0f);
  909.                   fputs("\n", fout);
  910.                   y = y+1;
  911.                 };
  912.                 x = x+2;
  913.                 fputs("\n", fout);
  914.               };
  915.             };
  916.  
  917.             if (sprformat == 'I') {
  918.               x = sprx;
  919.               while (x < (sprx+sprwid)) {
  920.                 BYTE mode = 255;
  921.                 BYTE newmode = 0;
  922.                 BYTE transp;
  923.                 int count = 0;
  924.                 int xi;
  925.                 int yi;
  926.                 int sumhgt = 0;
  927.                 y = spry;
  928.                 while (1) { //y
  929.                   //fprintf(fout, "\ty=%d\n", y);
  930.  
  931.                   if (y != (spry+sprhgt)) {
  932.                   //яюёўшЄрЄ№ ўшёыю яЁючЁрўэ√ї яшъёхыхщ
  933.                     transp = 0;
  934.                     xi = x;
  935.                     while (xi < (x+8)) {
  936.                       if (pic[xi][y] == 16) transp = transp+1;
  937.                       xi = xi+1;
  938.                     }
  939.                     if (transp == 0) { newmode = 1; //ld zone
  940.                     }else if (transp == 8) { newmode = 0; //empty zone
  941.                     }else { newmode = 2; //and:or zone
  942.                     }
  943.                     if (mode == 255) { mode = newmode; };
  944.                   };
  945.  
  946.                   if (((newmode != mode)||(y == (spry+sprhgt)))&&(count != 0)) {
  947.                     //fprintf(fout, "\ty=%d, transp=%d, count=%d, mode=%d, newmode=%d\n", y, transp, count, mode, newmode);
  948.                     fprintf(fout, "\tdb %d,%d\n", mode, count);
  949.                     sumhgt = sumhgt + count;
  950.                     yi = y-count;
  951.                     while (yi != y) {
  952.                       xi = x;
  953.                       if (mode == 1) { //ld zone
  954.                         fprintf(fout, "\tdb ");
  955.                         while (1) {
  956.                           b = pic[xi][yi]; //L
  957.                           b0 = pic[xi+1][yi]; //R
  958.                           b = ((b&0x08)<<3) + (b&0x07) + ((b0&0x08)<<4) + ((b0&0x07)<<3);
  959.                           fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  960.                           xi = xi+2;
  961.                           if (xi == (x+8)) break;
  962.                           fputs(",", fout);
  963.                         }
  964.                         fputs("\n", fout);
  965.                       //}else if (mode == 0) { //empty zone
  966.                       }else if (mode == 2) { //and:or zone
  967.                         fprintf(fout, "\tdb ");
  968.                         while (1) {
  969.                           b = pic[xi][yi]; //L
  970.                           b0 = pic[xi+1][yi]; //R
  971.                           bmask = 0; //0x47(L) ш 0xb8(R) т Єхї ьхёЄрї, уфх ЎтхЄ=16:
  972.                           if (b == 16) {bmask = bmask + 0x47; b = 0x00;};
  973.                           if (b0 == 16) {bmask = bmask + 0xb8; b0 = 0x00;};
  974.                           b = ((b&0x08)<<3) + (b&0x07) + ((b0&0x08)<<4) + ((b0&0x07)<<3);
  975.                           fprintf(fout, "0x%x%x", bmask>>4, bmask&0x0f);
  976.                           fprintf(fout, ",0x%x%x", b>>4, b&0x0f);
  977.                           xi = xi+2;
  978.                           if (xi == (x+8)) break;
  979.                           fputs(",", fout);
  980.                         };
  981.                         fputs("\n", fout);
  982.                       };
  983.                       yi = yi+1;
  984.                     };
  985.                     mode = newmode;
  986.                     count = 0;
  987.                   };
  988.                   count = count+1;
  989.  
  990.                   if (y >= (spry+sprhgt)) break;
  991.  
  992.                   y = y+1;
  993.                 };
  994.                 x = x+8;
  995.                 //fprintf(fout, "\tsumhgt=%d\n", sumhgt);
  996.                 fputs("\n", fout);
  997.               };
  998.             };
  999.  
  1000.             if (sprformat == 'L') { //фрыхх ЄхъёЄ Єшяр (-1=яЁюяєёъ):
  1001. //   -1, -1, -1,114,116,119,121,124,126,-1,-1,-1,-1,-1,-1,-1,
  1002. //  113,118,123,115,117,120,122,125,127,-1,-1,-1,-1,-1,-1,-1
  1003. //фы  ърцфющ  ўхщъш ърЁЄшэъш єърчрэ эюьхЁ Єрщыр
  1004. //р эрь эрфю чряюыэшЄ№ ьрёёшт√ convorderx,y - ъююЁфшэрЄ√ фы  ърцфюую эюьхЁр Єрщыр
  1005. //тёх фюыцэ√ с√Є№ т юфэющ ърЁЄшэъх, шэрўх эх яюыєўшЄё  (яхЁхьх°рэ√ эюьхЁр Єрщыют юс∙шх фы  тёхї ыюърЎшщ ш фы  ъюэъЁхЄэющ)
  1006.               n = 0;
  1007.               while (n < CONVORDERSZ) {
  1008.                 convorderx[n] = 0;
  1009.                 convordery[n] = 0;
  1010.                 n = n+1;
  1011.               };
  1012.  
  1013.                 skiplf(fintxt);
  1014.               //tiles = 0;
  1015.  
  1016.               y = spry;
  1017.               while (y < (spry+sprhgt)) {
  1018.                 x = sprx;
  1019.                 while (x < (sprx+sprwid)) {
  1020.                   n = readnum(fintxt);
  1021.                   if (n != -1) {
  1022.                     convorderx[n] = x;
  1023.                     convordery[n] = y;
  1024.                   };
  1025.                   //fprintf(fout, "\tdb %d\n", n);
  1026.                   //tiles = tiles + 1;
  1027.                   x = x+16;
  1028.                 };
  1029.                 skiplf(fintxt);
  1030.                 //fputs("\n", fout);
  1031.                 y = y+16;
  1032.               };
  1033.  
  1034.               n = 0;
  1035.               while (n < tiles) {
  1036.                 x = convorderx[n];
  1037.                 while (x < (convorderx[n]+16)) {
  1038.                   fputs(" db ", fout);
  1039.                   y = convordery[n];
  1040.                   while (1) {
  1041.                     b = pic[x][y]; //L
  1042.                     b0 = pic[x+1][y]; //R
  1043.                     b = ((b&0x08)<<3) + (b&0x07) + ((b0&0x08)<<4) + ((b0&0x07)<<3);
  1044.                     fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  1045.                     y = y+1;
  1046.                     if (y == (convordery[n]+16)) break;
  1047.                     fputs(",", fout);
  1048.                   };
  1049.                   fputs("\n", fout);
  1050.                   x = x+2;
  1051.                 };
  1052.                 n = n+1;
  1053.               };
  1054.  
  1055.             };
  1056.             sprx = sprx + sprwid;
  1057.             cursprcount++;
  1058.            } while (cursprcount<maxsprcount); //while (sprcount)
  1059.             spry = spry + sprhgt;
  1060.             curvertsprcount++;
  1061.            } while (curvertsprcount<maxvertsprcount); //while (vertsprcount)
  1062.           }; //while (1)
  1063.           fclose(fout);
  1064.         }else {printf("can't open %s",foutname);};
  1065.         fclose(fintxt);
  1066.       }else {printf("can't open %s",fintxtname);};
  1067.     };
  1068.     fclose(fin);
  1069.   }else {printf("can't open %s",finname);};
  1070. }
  1071.  
  1072. int main(int argc,char* argv[])
  1073. {
  1074. //  int i;
  1075.   char *finname;
  1076.   char *fintxtname;
  1077.   char *foutname;
  1078.   finname = "testpic.bmp";
  1079.   fintxtname = "testpic.txt";
  1080.   foutname = "testpic.asm";
  1081.  
  1082.   if (argc<4) {
  1083.     printf(
  1084.       "NedoRes\n"
  1085.       "\tnedores.exe file.bmp file.dat(=txt) file.ast(=asm)\n"
  1086.       "4bpp or 8bpp\n"
  1087.     );
  1088.   }else {
  1089.     finname = argv[1];
  1090.     fintxtname = argv[2];
  1091.     foutname = argv[3];
  1092.   };
  1093.  
  1094.   resfile(finname, fintxtname, foutname);
  1095.  
  1096.   return 0;
  1097. }