Subversion Repositories NedoOS

Rev

Rev 49 | Rev 267 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  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 MAXDEFB 8
  10.  
  11. #define MASKCOLOR 0x00
  12.  
  13. BYTE filebuf[65536];
  14. char labelbuf[_STRMAX+1];
  15. char formatlabelbuf[_STRMAX+1];
  16. BYTE sizeword[4];
  17. BYTE pic[1024][1024];
  18. BYTE pixrow[1024/8][1024+1024];
  19. #define PIXROWSHIFT 1024
  20. BYTE maskrow[1024/8][1024];
  21. //BYTE pixrowshift[1024/8][1024]; //>>4
  22. BYTE attrrow[1024/8];
  23.  
  24. BYTE ink;
  25. BYTE paper;
  26. BYTE curink;
  27. BYTE curpaper;
  28. BYTE defaultcolor;
  29.  
  30. char sprformat;
  31.  
  32. int hgt;
  33. int wid;
  34. int bpp;
  35.  
  36. int readnum(FILE * fin)
  37. {
  38. char c;
  39. int num;
  40.   num = 0;
  41.   do{
  42.     if (!fread(&c,1,1,fin)) break;
  43.     if ((c<'0')||(c>'9')) break; //т Єюь ўшёых 0x0a
  44.     num = num*10 + (int)(c-'0');
  45.   }while(1);
  46. return num;
  47. }
  48.  
  49. unsigned int readlabel(FILE * fin, char * s)
  50. {
  51. char c;
  52. unsigned int i;
  53. int iscomment;
  54.   do{
  55.     i = 0;
  56.     iscomment = 0;
  57.     do{
  58.       if (!fread(&c,1,1,fin)) break;
  59.       if (c == ';') iscomment = -1;
  60.       if ((c=='=')||(c==',')) {
  61.         if (iscomment) continue; //т ъюььхэЄрї ьюцэю =
  62.         break;
  63.       };
  64.       if (c == 0x0d) continue;
  65.       if (c == 0x0a) {
  66.         if (iscomment) break; //ъюььхэЄ√ ъюэўр■Єё  яю ъюэЎє ёЄЁюъш
  67.         continue;
  68.       };
  69.       if (i==_STRMAX) break;
  70.       s[i] = c;
  71.       i++;
  72.     }while(1);
  73.     s[i] = '\0';
  74.   }while(iscomment);
  75. return i;
  76. }
  77.  
  78. int read4b(FILE * fin)
  79. {
  80.   fread(sizeword, 4, 1, fin);
  81. return sizeword[0] + (sizeword[1]<<8) + (sizeword[2]<<16) + (sizeword[3]<<24);
  82. }
  83.  
  84. BYTE colstat[256];
  85.  
  86. void findinkpaper(int x, int y) //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь
  87. {
  88. //BYTE b;
  89. int i;
  90. int j;
  91. BYTE col1;
  92. BYTE col1stat;
  93. BYTE col2;
  94. BYTE col2stat;
  95. BYTE col3;
  96. BYTE col3stat;
  97. BYTE col4;
  98. BYTE col4stat; //эр ёыєўрщ Єръющ ёЄрЄшёЄшъш: MASKCOLOR, RED, red, anothercolor
  99.   i = 0; do {colstat[i] = 0x00; i++;}while (i!=256);
  100.  
  101.   //col1 = pic[x][y];
  102.   j = y;
  103.   while (j < (y+8)) {
  104. //    b = 0x00;
  105.     i = x;
  106.     while (i < (x+8)) {
  107.       colstat[pic[i][j]]++;
  108.       //b = pic[i][j];
  109.       //if (b!=col1) col2 = b;
  110.       i++;
  111.     };
  112.     j++;
  113.   };
  114.  
  115. //ьрёър MASKCOLOR эх ёўшЄрхЄё  ЎтхЄюь
  116.   col1 = MASKCOLOR; col1stat = 0; //fix 27.12.2018
  117.   col2 = MASKCOLOR; col2stat = 0; //fix 27.12.2018
  118.   col3 = MASKCOLOR; col3stat = 0; //fix 27.12.2018
  119.   col4 = MASKCOLOR; col3stat = 0; //fix 27.12.2018
  120.   i = 0; do { //fix 27.12.2018 (эр ёыєўрщ MASKCOLOR!=0)
  121.     if (colstat[i] > col1stat) {
  122.       col4 = col3;
  123.       col4stat = col3stat;
  124.       col3 = col2;
  125.       col3stat = col2stat;
  126.       col2 = col1;
  127.       col2stat = col1stat;
  128.       col1 = (BYTE)i;
  129.       col1stat = colstat[i];
  130.     }else if (colstat[i] > col2stat) {
  131.       col4 = col3;
  132.       col4stat = col3stat;
  133.       col3 = col2;
  134.       col3stat = col2stat;
  135.       col2 = (BYTE)i;
  136.       col2stat = colstat[i];
  137.     }else if (colstat[i] > col3stat) {
  138.       col4 = col3;
  139.       col4stat = col3stat;
  140.       col3 = (BYTE)i;
  141.       col3stat = colstat[i];
  142.     }else if (colstat[i] > col4stat) {
  143.       col4 = (BYTE)i;
  144.       col4stat = colstat[i];
  145.     };
  146.     i++;
  147.   }while (i!=16); //fix 27.12.2018
  148.  
  149. //MASKCOLOR эхы№ч  ёрь√ь ўрёЄ√ь, ёюЁЄшЁєхь хую т ъюэхЎ
  150.   if (col1==MASKCOLOR) {
  151.     col1 = col2;
  152.     col2 = MASKCOLOR;
  153.   };
  154.   if (col2==MASKCOLOR) {
  155.     col2 = col3;
  156.     col3 = MASKCOLOR;
  157.   };
  158.   if (col3==MASKCOLOR) {
  159.     col3 = col4;
  160.     col4 = MASKCOLOR;
  161.   };
  162.  
  163. //col1 ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  164. //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь, яю¤Єюьє 0x08 яхЁхтюфшЄё  т 0x00 ё фхЇюыЄэющ  ЁъюёЄ№■ (ўЄюс√ эх тыш Є№ эр bright)
  165.   //if ((col1&0x07)==0x00) col1 = (BYTE)(defaultcolor&0x08); //fix 27.12.2018
  166.   //if ((col2&0x07)==0x00) col2 = (BYTE)(defaultcolor&0x08); //fix 27.12.2018
  167. /**  if (col2 == MASKCOLOR) {
  168.     if (col1 == MASKCOLOR) {
  169.       col2 = (BYTE)((col1&0x08) | (defaultcolor&0x07));
  170.     }else {
  171.       col2 = (BYTE)((col1&0x08) | (defaultcolor&0x07));
  172.     };
  173.   };*/ //fix 27.12.2018
  174.   if (((col2&0x07)==(col1&0x07)) /**&& (col2!=0x00)*/) col2 = col3; //same colour with another bright
  175.   ink = col1;
  176.   paper = col2; //Ёхцх
  177.   //paper Ёхцх ш ьюцхЄ с√Є№ MASKCOLOR (эхЄ тЄюЁюую ЎтхЄр, эрфю сЁрЄ№ фхЇюыЄэ√щ)
  178.   //ink ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  179. }
  180.  
  181. void setcurinkpaper(BYTE* pcurink, BYTE* pcurpaper)
  182. //paper Ёхцх ш ьюцхЄ с√Є№ MASKCOLOR (эхЄ тЄюЁюую ЎтхЄр, эрфю сЁрЄ№ фхЇюыЄэ√щ)
  183. //ink ьюцхЄ с√Є№ MASKCOLOR Єюы№ъю фы  чэръюьхёЄр, яюыэюёЄ№■ чрышЄюую MASKCOLOR
  184. //*pcurink, *curpaper шчэрўры№эю ёюфхЁцрЄ рЄЁшсєЄ√ яЁхф√фє∙хую чэръюьхёЄр
  185. //тючтЁр∙рхЄ *pcurink, *curpaper, яЁшў╕ь тьхёЄю 0x08 ёЄртшЄ 0x00 (ўЄюс√ эх тыш ыю эр  ЁъюёЄ№)
  186. {
  187. BYTE t;
  188.   if (sprformat == 's') {
  189.     paper = 0x08;
  190.     ink = 0x0f;
  191.   }; //фы  ёяЁрщЄют Їюэ ў╕Ёэ√щ (р ьрёър 0x00)
  192. //27.02.2019:
  193. //Їюэ фы  чрышЄ√ї чэръюьхёЄ эрўшэр  ё чхы╕эюую ЄхяхЁ№ ў╕Ёэ√щ[шыш эрфю яЁхф√фє∙шщ?]
  194. //Їюэ фы  ў╕Ёэ√ї чэръюьхёЄ схЁ╕Є  ЁъюёЄ№ юЄ defaultcolor, р фы  чрышЄ√ї чэръюьхёЄ ьхэхх чхы╕эюую эх схЁ╕Є
  195. #define MINCOLORWITHBLACKBG 0x04
  196. //fix 27.12.2018:
  197.   if (((ink&0x07)==(*pcurink&0x07)) && (ink!=MASKCOLOR)) { //ink ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє
  198.     *pcurink = ink;
  199.     if (paper==MASKCOLOR) {
  200.       *pcurpaper = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  201.     }else {
  202.       *pcurpaper = paper;
  203.     };
  204.   }else if (((paper&0x07)==(*pcurpaper&0x07)) && (paper!=MASKCOLOR)) { //paper ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє
  205.     *pcurpaper = paper;
  206.     if (ink==MASKCOLOR) {
  207.       *pcurink = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  208.     }else {
  209.       *pcurink = ink;
  210.     };
  211.   }else if (((paper&0x07)==(*pcurink&0x07)) && (paper!=MASKCOLOR)) { //paper ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє ink
  212.     *pcurink = paper;
  213.     if (ink==MASKCOLOR) {
  214.       *pcurpaper = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  215.     }else {
  216.       *pcurpaper = ink;
  217.     };
  218.   }else if (((ink&0x07)==(*pcurpaper&0x07)) && (ink!=MASKCOLOR)) { //ink ёююЄтхЄёЄтєхЄ яЁхф√фє∙хьє paper
  219.     *pcurpaper = ink;
  220.     if (paper==MASKCOLOR) {
  221.       *pcurink = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  222.     }else {
  223.       *pcurink = paper;
  224.     };
  225.   }else if ((ink==MASKCOLOR)&&(paper==MASKCOLOR)) { //юср ЎтхЄр MASKCOLOR
  226.     ink = defaultcolor;
  227.     paper = 0x08;
  228.   }else { //юср ЎтхЄр эх ёююЄтхЄёЄтє■Є яЁхф√фє∙хьє чэръюьхёЄє, эю эх юср MASKCOLOR
  229.     if (ink == MASKCOLOR) ink = ((paper&0x07)<MINCOLORWITHBLACKBG) ? ((paper&0x07)?((defaultcolor&0x07)|(paper&0x08)):defaultcolor) : 0x00;
  230.     if (paper == MASKCOLOR) paper = ((ink&0x07)<MINCOLORWITHBLACKBG) ? ((ink&0x07)?((defaultcolor&0x07)|(ink&0x08)):defaultcolor) : 0x00;
  231.     if (ink > paper) {
  232.       *pcurink = ink;
  233.       *pcurpaper = paper;
  234.     }else {
  235.       *pcurink = paper;
  236.       *pcurpaper = ink;
  237.     };
  238.   };
  239.   if (*pcurpaper==0x08) *pcurpaper = 0x00; //ўЄюс√ эх тыш ыю эр  ЁъюёЄ№ //fix 27.12.2018
  240.   if (*pcurink==0x08) *pcurink = 0x00; //ўЄюс√ эх тыш ыю эр  ЁъюёЄ№ //fix 27.12.2018
  241.   //эр ў╕Ёэюь/ёшэхь Їюэх ink фюыцхэ с√Є№  Ёўх paper'р (юЄфхы№э√щ ёыєўрщ, Є.ъ. юёЄры№э√х, фрцх яєёЄ√х, чэръюьхёЄр ьюуєЄ єўрёЄтютрЄ№ т юЄЁшёютъх ёъЁюыышЁєхь√ї Їюэют ё эхяЁхЁ√тэ√ьш Ўхяюўърьш ink-paper)
  242.   //Єю хёЄ№ эхы№ч  ink=0, р 1 Єюы№ъю т ёыєўрх paper=0
  243.   if (((*pcurink&0x07)<=0x01) && ((*pcurpaper&0x07)>(*pcurink&0x07))) { //ў╕Ёэюх/ёшэхх яєёЄюх чэръюьхёЄю (юЄфхы№э√щ ёыєўрщ, Є.ъ. юёЄры№э√х яєёЄ√х ьюуєЄ єўрёЄтютрЄ№ т юЄЁшёютъх ёъЁюыышЁєхь√ї Їюэют ё эхяЁхЁ√тэ√ьш Ўхяюўърьш ink-paper)
  244.     t = *pcurpaper;
  245.     *pcurpaper = *pcurink;
  246.     *pcurink = t;
  247.   };
  248. }
  249.  
  250. void emitdb(BYTE b, FILE * fout)
  251. {
  252.   fputs("\tdb ", fout);
  253.   fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  254.   fputs("\n", fout);
  255. }
  256.  
  257. void emitnops(BYTE count, FILE * fout)
  258. {
  259.   fputs("\tds ", fout);
  260.   fprintf(fout, "0x%x%x", count>>4, count&0x0f);
  261.   fputs("\n", fout);
  262. }
  263.  
  264. void emitspr(int xchr, int y, int sprwid8, int sprhgt, FILE * fout)
  265. {
  266. BYTE b;
  267. int i;
  268. int j;
  269.   j = y;
  270.   while (1) {
  271.     fputs("\tdb ", fout);
  272.     i = xchr;
  273.     while (1) {
  274.       b = maskrow[i][j];
  275.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  276.       fputs(",", fout);
  277.       b = b^pixrow[i][j];
  278.       fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  279.       i++;
  280.       if (i >= (xchr+sprwid8)) break;
  281.       fputs(",", fout);
  282.     };
  283.     fputs("\n", fout);
  284.     j++;
  285.     if (j >= (y+sprhgt)) break;
  286.   };
  287. }
  288.  
  289. void emitchr_(int xchr, int y, FILE * fout)
  290. {
  291. BYTE b;
  292. int j;
  293.   fputs("\tdb ", fout);
  294.   j = y;
  295.   while (1) {
  296.     b = pixrow[xchr][j];
  297.     fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  298.     j++;
  299.     if (j >= (y+8)) break;
  300.     fputs(",", fout);
  301.   };
  302.   if (sprformat < 'a') { //capital letter format => attr used
  303.     b = attrrow[xchr]; //0x07;
  304.     fputs(",", fout);
  305.     fprintf(fout, "0x%x%x", b>>4, b&0x0f);
  306.   };
  307.   fputs("\n", fout);
  308. }
  309.  
  310. void emitchr(int xchr, int y, FILE * fout)
  311. {
  312.   emitchr_(xchr, y, fout);
  313. }
  314.  
  315. void emitchrshift(int xchr, int y, FILE * fout)
  316. {
  317.   emitchr_(xchr, y+PIXROWSHIFT, fout);
  318. }
  319.  
  320. //ёфтшурхь Ё ф чэръюьхёЄ >>shiftbits, Ёхчєы№ЄрЄ т pixrow[sprx][y+PIXROWSHIFT]
  321. void shiftrow(int sprx, int y, int sprwid, int rowhgt, int pixrowshift, BYTE shiftbits)
  322. {
  323. int j;
  324. int x;
  325. BYTE b;
  326. BYTE b0;
  327. BYTE shiftmask;
  328.   shiftmask = (BYTE)(0xff>>(0x08-shiftbits)); //хёыш shiftbits==0x01, Єю shiftmask==0x01
  329.   j = y;
  330.   while (j < (y+rowhgt)) {
  331.     b = 0x00;
  332.     x = sprx;
  333.     while (x < (sprx+sprwid+8)) {
  334.       b0 = pixrow[x/8][j];
  335.       pixrow[x/8][j+pixrowshift] = (BYTE)((b<<(0x08-shiftbits)) + (b0>>shiftbits));
  336.       b = (BYTE)(b0&shiftmask/**0x0f*/); //хёыш shiftbits==0x01, Єю shiftmask==0x01
  337.       x = x+8;
  338.     };
  339.     j++;
  340.   };
  341. }
  342.  
  343. //data: wid8, hgt8, chrgfx, chrgfx...
  344. void resfile(char * finname, char * fintxtname, char * foutname)
  345. {
  346. FILE* fin;
  347. FILE* fintxt;
  348. FILE* fout;
  349. int i;
  350. int j;
  351. int size;
  352. int y;
  353. int x;
  354.  
  355. BYTE b;
  356. BYTE bmask;
  357. BYTE b0;
  358.  
  359. int sprx;
  360. int spry;
  361. int sprwid;
  362. int sprhgt;
  363. int rowhgt; //8 for tiles, sprhgt for sprites
  364.  
  365.   fin = fopen(finname, "rb");
  366.   if (fin) {
  367.     fread(filebuf, 10, 1, fin); //skip to 10 (header size)
  368.     size = read4b(fin); //10 (header size)
  369.     fread(filebuf, 4, 1, fin); //skip to 18
  370.     wid = read4b(fin); //18
  371.     hgt = read4b(fin); //22
  372.     fread(filebuf, 2, 1, fin); //skip to 28
  373.     fread(&bpp, 1, 1, fin); //28
  374.     fread(filebuf, 1, size-29, fin); //skip to pic
  375.     if ((wid>0)&&(wid<=1024)&&(hgt>0)&&(hgt<=1024)&&((wid&7)==0)&&((hgt&7)==0)) {
  376.       y = hgt;
  377.       while (y>0) {
  378.         y--;
  379.         x = 0;
  380.         while (x<wid) {
  381.           fread(&b, 1, 1, fin);
  382.           if (bpp == 8) {
  383.             pic[x][y] = b;
  384.             x++;
  385.           }else {
  386.             pic[x][y] = (BYTE)((b&0xf0)>>4);
  387.             x++;
  388.             pic[x][y] = (BYTE)(b&0x0f);
  389.             x++;
  390.           };
  391.         };
  392.       };
  393.  
  394.       fintxt = fopen(fintxtname, "rb");
  395.       if (fintxt) {
  396.         fout = fopen(foutname, "wb");
  397.         if (fout) {
  398. /**          if (labelname[0]!='\0') {
  399.             fputs(labelname, fout);
  400.             fputs("\n", fout);
  401.           };*/
  402.           while (1) {
  403.             size = readlabel(fintxt, labelbuf); //fread(filebuf, 1, MAXDEFB, fin);
  404.             if (size == 0) break;
  405.             readlabel(fintxt, formatlabelbuf); //format
  406.             sprformat = *formatlabelbuf;
  407.             sprx = readnum(fintxt);
  408.             spry = readnum(fintxt);
  409.             sprwid = readnum(fintxt);
  410.             sprhgt = readnum(fintxt);
  411.             defaultcolor = (BYTE)readnum(fintxt);
  412.  
  413.             if (sprformat == 'B') {
  414.               fputs(labelbuf, fout);
  415.               fputs("\n", fout);
  416.               emitdb((BYTE)(sprwid>>3), fout);
  417.               emitdb((BYTE)(sprhgt>>3), fout);
  418.               rowhgt = 8;
  419.             }else if (sprformat == 'T') {
  420.               fputs("\tds (-$)&0xff\n", fout);
  421.               fputs(labelbuf, fout);
  422.               fputs("\n", fout);
  423.               rowhgt = 8;
  424.             }else { //'s'
  425.               fputs(labelbuf, fout);
  426.               fputs("\n", fout);
  427.               emitdb((BYTE)(sprwid>>3), fout);
  428.               emitdb((BYTE)(sprhgt), fout);
  429.               rowhgt = sprhgt;
  430.             };
  431.  
  432.             y = spry;
  433.             while (y < (spry+sprhgt)) {
  434.               //яхЁхъюфшЁєхь Ё ф чэръюьхёЄ т√ёюЄющ rowhgt
  435.               curink = 0x0f;
  436.               curpaper = 0x08;
  437.               x = sprx;
  438.               while (x < (sprx+sprwid)) {
  439.                 findinkpaper(x, y);
  440.                 setcurinkpaper(&curink, &curpaper);
  441.               //curink = 0x0f;
  442.               //curpaper = 0x08;
  443.                 j = y;
  444.                 while (j < (y+rowhgt)) {
  445.                   b = 0x00;
  446.                   bmask = 0x00;
  447.                   i = x;
  448.                   while (i < (x+8)) {
  449.                     b = (BYTE)(b<<1);
  450.                     bmask = (BYTE)(bmask<<1);
  451.                     //if (sprformat != 'B') {fprintf(fout, "0x%x%x\n", (pic[i][j])>>4, (pic[i][j])&0x0f);};
  452.                     if (pic[i][j]==curink) b++;
  453.                     if (pic[i][j]!=0x00) bmask++;
  454.                     i++;
  455.                   };
  456.                   pixrow[x/8][j] = b;
  457.                   maskrow[x/8][j] = bmask;
  458.                   pixrow[(x/8)+1][j] = 0x00; //ўЄюс√ ёфтшурЄ№
  459.                   j++;
  460.                 };
  461. //ьрёър 0x00 эх ёўшЄрхЄё  ЎтхЄюь, яю¤Єюьє 0x08 яхЁхтюфшЄё  т 0x00 (ўЄюс√ эх тыш Є№ эр bright)
  462.                 b = 0x00; if (curink!=0x08) b = curink;
  463.                 b0 = 0x00; if (curpaper!=0x08) b0 = curpaper;
  464.                 attrrow[x/8    ] = (BYTE)( (((b|b0)&0x08)<<3)+((curpaper&0x07)<<3)+(curink&0x07) );
  465.                 attrrow[(x/8)+1] = (BYTE)( (((b|b0)&0x08)<<3)+((curpaper&0x07)<<3)+(curink&0x07) ); //ўЄюс√ ёфтшурЄ№
  466.                 x = x+8;
  467.               };
  468.   //            shiftrow(sprx, y, sprwid, rowhgt, PIXROWSHIFT, 0x04); //ёфтшурхь Ё ф чэръюьхёЄ >>4, Ёхчєы№ЄрЄ т pixrow[sprx][y+PIXROWSHIFT]
  469.  
  470.               //т√тюфшь т рёь
  471.               if (sprformat == 'B') { //tiles
  472.                 x = sprx;
  473.                 while (x < (sprx+sprwid)) {
  474.   //                emitchrshift(x/8,y,fout);
  475.                   emitchr(x/8,y,fout);
  476.                   x = x+8;
  477.                 };
  478.   //              emitchrshift(x/8,y,fout);
  479.               }else if (sprformat == 'T') {
  480.                 x = sprx;
  481.                 while (x < (sprx+sprwid)) {
  482.                   emitchr(x/8,y,fout);
  483.                   x = x+8;
  484.                 };
  485.                 emitnops((BYTE)(0x100-((BYTE)(sprwid>>3)*0x09)),fout);
  486.               }else { //sprite
  487.                 emitspr(sprx/8,y,sprwid/8,sprhgt,fout);
  488.               };
  489.               y = y+rowhgt;
  490.             };
  491.  
  492.           };
  493.           fclose(fout);
  494.         }else {printf("can't open %s",foutname);};
  495.         fclose(fintxt);
  496.       }else {printf("can't open %s",fintxtname);};
  497.     };
  498.     fclose(fin);
  499.   }else {printf("can't open %s",finname);};
  500. }
  501.  
  502. int main(int argc,char* argv[])
  503. {
  504. //  int i;
  505.   char *finname;
  506.   char *fintxtname;
  507.   char *foutname;
  508.   finname = "testpic.bmp";
  509.   fintxtname = "testpic.txt";
  510.   foutname = "testpic.asm";
  511.  
  512.   if (argc<4) {
  513.     printf(
  514.       "NedoRes\n"
  515.       "\tnedores.exe file.bmp file.txt file.asm\n"
  516.     );
  517.   }else {
  518.     finname = argv[1];
  519.     fintxtname = argv[2];
  520.     foutname = argv[3];
  521.   };
  522.  
  523.   resfile(finname, fintxtname, foutname);
  524.  
  525.   return 0;
  526. }