// Создание файлов из 96 б атриб + 96 б конв + 4096..10240б спрайтов
#include <stdio.h>
#include <alloc.h>
#include <string.h>
#include <ctype.h>
#include <process.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <dos.h>
#include <conio.h>
#define X2 9 // к-во ландшафтов по 32 спрайта
#define X5 10 // к-во ландшафтов по 80 спрайтов
#define nn 0xFF // конвертируется сам в себя
#define Xlen 1*1 + 1*3 + X2*2 + X5*5
#define ATstruct struct at_st
ATstruct
{
char s_[16];
char b_[16];
char m_[16];
char t_[16];
char f_[16];
};
ATstruct xat [Xlen] ={
/*XM0................................*/
{
"SSS......SSS.SSS",
"BBB......BBB...B",
"..M.......MMMM.M",
"............DD..",
"3333333333333333"
},
/*XM1................................*/
{
"....SSS.........",
"................",
"................",
"FF..............",
"1111111333333333"
},
{
"...S.S..........",
"................",
"..MMMM..........",
"..DDDD..........",
"3333333333223333"
},
{
"SSSS....SSSS..SS",
"BBBB....BBBB..BB",
"....MMMM.M....MM",
"....DDDD.L......",
"3333222203313331"
},
/*XM2===========================*/
{
"SSSSSS..SSSSSSSS",
"BBBBBB....BBBBBB",
"MMMMM.......MM.M",
"............LL..",
"0000003311113310"
},
{
"SSSSSSSS.SSSSSSS",
"BB.BBBBB.BBBBBBB",
"MM..MMMM..MMMM.M",
"..FF............",
"0000000031000000"
},
/*XM3============================*/
{
"SSSSSSS....SSSS.",
"BBBBB......BBBB.",
"MMMMM.......MM..",
"................",
"0000011331330012"
},
{
"SSSSSSSSSSSSSSSS",
"BBBB.BB....BBBB.",
"M.M...M....M.MM.",
"..../...........",
"0100330333301001"
},
/*XM4---------------------------*/
{
"SSSSSSSSSSSSS.SS",
"BBBBBBBBBBBBB.B.",
"MMMMMMMMMMMMM...",
"................",
"0000000000000000"
},
{
"........SSSSSSSS",
"........BBBBB.BB",
"................",
"................",
"2233332211210100"
},
{
"..S..S.SSSSSS..S",
"..B..B.BBB..B..B",
"MMMMMM...M......",
"DD.DD.....F.....",
"1111113110100000"
},
{
"SS..SSSS.SS.SSSS",
"BB............BB",
"M.............MM",
"L.GGGGGGGGGG/`..",
"3311111111113300"
},
{
"S.S.S.S.S.S.S.SS",
"............B.B.",
"................",
"GGGGGGGGGGGG....",
"1111111111110011"
},
/*XM5---------------------------*/
{
"....SSS.........",
"................",
"................",
"FF..............",
"1111111333333333"
},
{
"...S.S..........",
"................",
"..MMMM..........",
"..DDDD..........",
"3322223333223333"
},
{
"SSSS....SSSS..SS",
"BBBB....BBBB..BB",
"....MMMM.M....MM",
"....DDDD.L......",
"3333222203313331"
},
{
"SSSSSS..SSS.SSSS",
"BBBBB....BB.BBBB",
"MMMMM.......MM.M",
".....F..........",
"0000013312210000"
},
{
"SSSSS..S..SS.SSS",
"BBBBB..B..B..BBB",
"MMM.M...........",
"......F.....F...",
"0000031311111333"
},
/*XM6----------------------------*/
{
"SSS....SSS......",
"BBB....BBB......",
"MMM......MMMMMMM",
".........LDDDDDD",
"0002233223222222"
},
{
"...........SS.SS",
"...........BB...",
"................",
"............../`",
"2233333333322333"
},
{
".SS.SSSSSSSSSSSS",
".B.....BBBBBBBBB",
"...............M",
"................",
"3333333333333330"
},
{
"SSSSSSSSSSSSSSSS",
".B..BBB..B.....B",
".M..............",
"F.GG.........F..",
"1011000110021131"
},
{
"SS.S.SSSSSSSS.SS",
"BB.B.B....B.B.BB",
"................",
".......F........",
"1011112100021233"
},
/*XM7---------------------------*/
{
"SSSSS...SSS.SSSS",
"BBBBB...B.B...B.",
"MMMM..........M.",
"............GGL.",
"1111332211000031"
},
{
"SSSS.SSSSSSS..SS",
"...B.B....BB....",
"..........M.....",
".........F..GGGG",
"3333333331112222"
},
{
".S..SSSSSSS...SS",
".B..............",
"................",
"F...GGGGGGGGGGGG",
"1100000000111111"
},
{
"SSSSSSSS...S..SS",
"BBBBBBBB........",
"MMMMMMMM........",
"DDD..DDD....GGGG",
"2222222211111111"
},
{
"..SS..SSSSSS..SS",
"......BBBBBB..BB",
"........M..M..MM",
"GGGG.........F..",
"1111331313333033"
},
/*XM8---------------------------*/
{
"SSS....SSS......",
"BBB....BBB......",
"MMM......MMMMMMM",
".........LDDDDDD",
"0002233323222222"
},
{
"...........SS.SS",
"...........BB...",
"................",
"............../`",
"2233333333322233"
},
{
".SS.SSSSSSSSSSSS",
"............BBBB",
"..............MM",
"................",
"3333333333332010"
},
{
"SSSSSS....S.SSS.",
"..BBB.....B.BBB.",
"................",
"FF...F..........",
"0011011010112232"
},
{
"SS..........S...",
".B..............",
".M.........MM...",
"...........DD...",
"2122333322222333"
},
/*XM9---------------------------*/
{
"SSSSSSSSSSSSS.SS",
"BBBBBBBBBBBBB.BB",
"MMMM.....M..M...",
"................",
"0000000020000000"
},
{
"........SSSS.SSS",
"........BBBB.BBB",
".............MMM",
"................",
"2233332212221000"
},
{
"SSSSSSSSSSSSSSSS",
"BBBBBBBBB.....BB",
"MMMMMMMMM.......",
"DD.DD..../`.....",
"1111110003333333"
},
{
".SSSSSSSSS......",
".B..B..BBB......",
".M..............",
"..F.............",
"3310011003223333"
},
{
"..SS..SSSSSSSS..",
".....B.BBBBBBBBB",
"........M.......",
"GGGG...F........",
"1111112100000033"
},
/*XM10---------------------------*/
{
"SSS.S...........",
"BBB.B...........",
"MMM.MMMM........",
"....LDDD........",
"1113333333333333"
},
{
"................",
"................",
"................",
"................",
"3323333333333223"
},
{
"..............S.",
"................",
"................",
"................",
"3333333333333111"
},
{
"SSSSSSSSSSSSSSSS",
"BBBBBBBBBBBBBBBB",
"MMMMMMMMMMMMMMMM",
"................",
"3333333333333333"
},
{
"SSSSSSSSSSSSSSSS",
"................",
"................",
"EEEEEEEEEEEEEEEE",
"1010101010101010"
},
/*XM11--------------------------*/
{
"SSSSSSSSSS......",
"BBBBBBBBB.......",
"MMMMMM..........",
"........FF......",
"0000000011022323"
},
{
"........SSSS.SSS",
"........BBBB.BBB",
".............MMM",
"................",
"2233332222211000"
},
{
"SSSSSSSS...SSSS.",
"BBBB..BB...BBB..",
"MMM........MMM..",
"...........DD...",
"3330110011100022"
},
{
"......SSSSSSSSS.",
"........BBBB....",
"MMMMMM..M..M....",
"DD.DD./`.GG.GGGG",
"1111113301100011"
},
{
"SS.SS..........S",
"B..BB..........B",
"....M........MMM",
"..F..........DD.",
"3313122333322223"
},
/*XM12---------------------------*/
{
"..S.SSSSSS.SSS.S",
"................",
"................",
"GF...FEEEEGGGF..",
"1112111111111121"
},
{
"..........S.SSSS",
"..........B..B..",
"......MMMMM.....",
"......DDDDL.F...",
"2233332222331211"
},
{
"..............SS",
"..............BB",
"..............MM",
"................",
"3333333333333300"
},
{
".....SSSSSSS....",
"...........B....",
"................",
"..F....GGGG.....",
"2113333111113333"
},
{
"S...SSSSSSSSSSSS",
"B...BBBB..BBBBBB",
"MMMMMMMM.....MMM",
".DDD.....F......",
"0333111131322333"
},
/*XM13---------------------------*/
{
"....SSSSSS.SSS..",
"......BB.B......",
"................",
"GF......F.GGG...",
"1111111111111111"
},
{
"..........S.SSSS",
"..........B...BB",
"......MMMMM.....",
"......DDDDL.GGGG",
"2233332222331111"
},
{
"..............SS",
"..............BB",
"..............MM",
"................",
"3333333333333300"
},
{
".....SSSS..S....",
"...........B....",
"................",
"..F....GGGG.....",
"2113333111113333"
},
{
"S...SSSSSSSSSSS.",
"B...BBBB..BBBBB.",
"MMMMMMMM.....MMM",
".DDD.....F......",
"0333111131322003"
},
/*XM14===========================*/
{
"SSSSSSS..SSS..SS",
"BBBBBBB....B..BB",
"MMMM.M........M.",
"................",
"0000100333323301"
},
{
"SSSSSS..SS..SSSS",
"BBBBBB......BBBB",
"MMM.MM......MMMM",
"......GGGGGG....",
"0000001111003333"
},
/*XM15===========================*/
{
"SSSSSS.SSSS.....",
"BBBBBB.BBBB.....",
"MMMMM..MM.M.....",
"................",
"0000003000033333"
},
{
".....S.SS..SSSSS",
".....B.BB..B..BB",
".......MM.....MM",
"..........F.....",
"3333321003131233"
},
/*XM16===========================*/
{
"SSSSSSSSSSSSSS.S",
"BBBBBB....BB....",
"MMMMM...........",
"............/`..",
"0000003111333331"
},
{
"SSSSSSSSSSSSS...",
"...BBBBB.BBB.BBB",
"...MMM.M..MM.MMM",
"........F.......",
"3330000000002333"
},
/*XM17===========================*/
{
"SSSSSSS...SSSSSS",
"BBBB..B...BBB..B",
"MMMM...MMM......",
"..../`.DDD......",
"0000332222222222"
},
{
"SSSSSSSSSSSSSSS.",
"BBBBBBBBBBBBBBB.",
".......M..MMMMM.",
"................",
"2223313001000001"
},
/*XM18===========================*/
{
"SSSS.SSSSSSSSSSS",
"BBBB..BB..BBBBBB",
"MMMM............",
"........FF......",
"0000111111111111"
},
{
"SSSSSSSSSSSSSSSS",
"BB..BB.BBB.BBBBB",
".......MMM.MMMM.",
"../`............",
"1133113000100310"
},
/*XM19===========================*/
{
"SSSSSSSSSSSSSSS.",
"BBBBBBBBBBBBBBB.",
"MMMMM.MM..MMMMM.",
"................",
"0000000001000020"
},
{
"................",
"................",
"................",
"................",
"3333333333333333"
},
/*XM20===========================*/
{
"SSSSSSSSSS..SSSS",
"BBBBBBBB.....BBB",
"MMMM.MMM.......M",
"......../.......",
"0000000031111210"
},
{
"SSSSSSSSS.SSSSSS",
".BBBBBBBB.BB.BB.",
"...MMMM......MM.",
"................",
"1210000001012002"
}
}; /*END OF DATA*/
/*-----------------------------------------------------------------*/
char xcnv [Xlen][16] ={
/*xm0*/
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,13,02,nn,nn},
/*xm1*/
{59,59,59,59,62,62,62,nn,nn,nn,nn,nn,nn,nn,nn,nn},
{nn,nn,35,63,37,63,nn,nn,nn,nn,62,62,62,62,62,62},
{nn,nn,nn,nn,53,63,55,63,00,nn,nn,62,nn,nn,nn,62},
/*xm2*/
{65,66,67,nn,65,65,nn,nn,74,75,66,66,nn,nn,66,65},
{65,65,66,67,65,65,65,65,nn,66,65,65,66,66,65,nn},
/*xm3*/
{65,66,67,nn,65,00,00,nn,nn,75,67,nn,82,65,66,78},
{65,82,91,65,nn,nn,91,nn,nn,nn,nn,nn,66,65,65,82},
/*xm4*/
{17,18,19,nn,nn,17,17,17,17,17,17,17,17,30,18,18},
{17,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16},
{49,50,17,52,53,17,19,17,17,17,18,17,17,17,17,16},
{nn,nn,17,17,18,18,18,18,18,18,18,18,nn,nn,17,78},
{18,18,18,18,18,18,18,18,18,18,18,18,17,92,17,94},
/*xm5*/
{90,59,59,59,90,90,62,nn,nn,nn,nn,nn,nn,nn,nn,nn},
{nn,nn,35,63,37,63,nn,nn,nn,nn,62,62,62,62,62,62},
{nn,nn,nn,nn,53,63,55,63,00,nn,nn,62,nn,nn,nn,62},
{65,66,67,nn,65,76,nn,nn,62,62,62,59,nn,65,65,65},
{65,65,65,65,65,nn,87,nn,90,90,62,62,90,nn,nn,nn},
/*xm6*/
{17,18,nn,17,17,17,17,17,17,nn,27,28,16,30,31,16},
{17,17,17,17,17,17,17,17,17,17,17,17,17,17,nn,nn},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn},
{17,nn,17,17,16,16,16,16,16,16,16,17,17,17,nn,16},
{16,18,17,17,17,16,17,17,17,17,17,nn,16,17,nn,nn},
/*xm7*/
{17,18,19,nn,nn,nn,17,17,17,24,16,16,16,16,nn,24},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,18,nn,17,18,18,18,18},
{49,18,16,16,16,16,16,16,16,16,16,16,18,18,18,18},
{65,66,67,nn,nn,68,69,70,17,17,17,17,17,17,17,17},
{18,18,18,18,nn,nn,17,nn,nn,nn,nn,nn,nn,17,nn,nn},
/*xm8*/
{17,18,nn,17,17,17,17,nn,17,nn,27,28,16,30,31,16},
{17,17,17,17,17,17,17,17,17,17,17,17,17,17,nn,nn},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,16,nn,nn},
{17,17,16,16,16,17,16,16,16,16,16,74,17,17,nn,00},
{nn,nn,17,17,17,17,17,17,17,17,17,92,16,nn,nn,nn},
/*xm9*/
{17,18,19,nn,17,17,17,17,18,17,17,17,18,28,17,17},
{46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,nn},
{49,50,46,52,53,46,17,nn,54,nn,nn,nn,nn,nn,nn,nn},
{nn,nn,46,45,45,45,45,45,45,nn,46,46,46,46,46,46},
{17,17,17,17,85,nn,00,17,nn,88,88,88,88,88,88,88},
/*xm10*/
{17,18,nn,nn,nn,22,23,16,nn,nn,nn,nn,nn,nn,nn,nn},
{nn,nn,17,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,17,17,nn},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,17,17,62},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn},
/*xm11*/
{17,18,nn,20,21,nn,20,20,21,21,20,17,17,17,17,17},
{17,17,17,17,17,17,17,17,17,17,17,17,17,46,47,nn},
{nn,nn,nn,16,16,16,16,16,17,17,17,60,61,20,20,17},
{65,66,16,68,69,16,nn,nn,75,75,75,nn,16,16,17,17},
{nn,nn,00,nn,nn,17,17,17,17,17,17,17,17,94,16,nn},
/*xm12*/
{93,75,75,93,75,62,62,62,62,62,93,93,93,62,93,75},
{62,62,62,62,62,62,39,63,41,63,nn,nn,63,62,62,62},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,93,62},
{62,62,75,nn,nn,nn,nn,93,93,93,93,93,nn,nn,nn,nn},
{nn,82,83,63,nn,nn,nn,nn,nn,90,nn,62,62,nn,nn,nn},
/*xm13*/
{93,75,75,93,62,62,62,62,62,62,93,93,93,62,93,75},
{62,62,62,62,62,62,39,63,41,63,nn,nn,62,62,62,62},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,93,62},
{62,62,75,nn,nn,nn,nn,93,93,93,93,93,nn,nn,nn,nn},
{nn,82,83,63,nn,nn,nn,nn,nn,90,nn,62,62,nn,nn,nn},
/*xm14*/
{65,66,67,nn,65,65,65,nn,nn,nn,nn,66,nn,nn,65,65},
{65,65,65,65,65,65,66,66,66,66,65,65,nn,nn,nn,nn},
/*xm15*/
{65,66,67,nn,65,65,nn,65,65,65,66,nn,nn,nn,nn,nn},
{nn,nn,nn,nn,nn,nn,62,nn,66,nn,91,nn,62,62,62,62},
/*xm16*/
{65,66,67,nn,65,65,nn,80,81,82,nn,nn,nn,nn,nn,80},
{nn,nn,nn,65,65,65,66,65,89,66,65,65,66,66,66,66},
/*xm17*/
{65,66,67,nn,nn,nn,62,72,73,63,62,62,75,62,65,65},
{65,65,65,65,65,62,65,65,65,65,65,65,65,65,65,62},
/*xm18*/
{65,66,67,nn,69,70,66,89,89,89,89,89,89,89,89,89},
{89,89,nn,nn,89,89,nn,nn,65,nn,89,65,65,nn,66,65},
/*xm19*/
{65,66,67,nn,65,65,65,65,65,65,65,65,65,65,67,66},
{nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn,nn},
/*xm20*/
{65,66,67,nn,66,65,65,65,nn,86,76,80,77,78,79,66},
{81,82,83,66,65,86,nn,86,86,90,nn,66,86,nn,65,66}
};
char ftyp [21] =
{1,3,2,2,5,5,5,5,5,5,5,5,5,5,2,2,2,2,2,2,2};
/*********************************/
char xa[128];
char xc[128];
char xs[10240];
char GetAt (char s,char b,char m,char t,char f) //Выдача байта параметров
{
char typ=0,fire_typ=0;
if (s!='S' && s!='.') printf("Неверный тип видимости %c%c\n",s,07);
if (b!='B' && b!='.') printf("Неверный тип пробиваемости %c%c\n",b,07);
if (m!='M' && m!='.') printf("Неверный тип проходимости %c%c\n",m,07);
switch ( t )
{
case '.':typ=0;break;
case 'D':typ=1;break;
case '`':typ=2;break;
case '/':typ=3;break;
case 'L':typ=4;break;
case 'G':typ=5;break;
case 'F':typ=6;break;
case 'E':typ=7;break;
default:printf("Неверный тип объекта %c%c\n",t,07);
}
if (f<'0' || f>'3')
{ printf("Неверный тип поражаемости %c%c\n",f,07);}
else fire_typ=f-'0';
return (s=='S'?128:0)+(b=='B'?64:0)+(m=='M'?32:0)+(typ<<2)+fire_typ;
}
void copy_data(char bnk,char len,char pos)
{
int k;
int j;
for (k=bnk;k<bnk+len;k++)
for (j=0;j<16;j++)
{
xc[pos]=xcnv[k][j];
xa[pos]=GetAt(xat[k].s_[j],
xat[k].b_[j],
xat[k].m_[j],
xat[k].t_[j],
xat[k].f_[j]);
pos++;
}
}
int HO,HI;
int main() // ***MAIN***
{
char *z,*b,*m,*name;
char nf;
unsigned i,j,k;
char bnk=1+3; //текущ.блок данных
unsigned blen;
char *Fname=(char*)malloc(80);
printf("\n\t (c)1996 Медноногов В.C.\t\t");
printf("\n\tСоздание файлов аттр+конв+спрайт\n");
printf("\tdata+xmNN.dat --> xmNN.cnv\n\n");
copy_data(0,1,00); //инициализ.спр.истребителя
for(i=2;i<21;i++)
{
sprintf(Fname,"..\\zx_disc\\xm%u.dat",i);
HI=open(Fname,O_RDONLY | O_BINARY);
if(HI==-1) {perror("Fatal! \7");return 1;}
blen=(ftyp[i]==2?4096:10240);
printf(" Длина: %u\n",blen+96+96);
read(HI,xs,blen);
close (HI);
/**/
sprintf(Fname,"..\\zx_disc\\xm%u.CNV",i);
HO=open(Fname,O_BINARY | O_CREAT | O_TRUNC | O_RDWR,S_IWRITE);
if (HO==-1) {perror("Ошибка создания выходного файла\7\n");return 1;}
/**/
if (ftyp[i]==2)
{
copy_data(1,3,16);
copy_data(bnk,2,64);
}
else
copy_data(bnk,5,16);
bnk+=ftyp[i];
write(HO,xa,96);
write(HO,xc,96);
write(HO,xs,blen);
close (HO);
printf("Cоздан файл #%u\n",i);
}
printf("\nO.K.\n");
return 0;
}