?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #include <stdio.h>
  2. #include <alloc.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <process.h>
  6. #include <io.h>
  7. #include <fcntl.h>
  8. #include <sys\stat.h>
  9. #include <dos.h>
  10. #include <conio.h>
  11. #define b16len 16384
  12. //cоздание образов диска 1 и 2 файла
  13. int HO,HI;
  14. FILE * HASM;
  15. char *fn[]={
  16.   "m2","m3","m4","m5","m10","m7","m8","m9",
  17.   "m6","m11","m12","m13","m14","m15","m16",
  18.   "m17","m18","m19","m20",
  19.  
  20.   "l2","end","l3","l4","l5a","l5b","l5c","l5d",
  21.   "l6a","l6b","l6c","l6d","X2","l7",
  22.   "l8a","l8b","l8c","l8d","l9","X3",
  23.   "l10a","l10b","l10c","l10d","l11",
  24.   "l12","l13","l14","l15","l19",
  25.   "l17","l18","l16","l20",
  26.  
  27.   "up1","up2","up3","up4","up5","up6","up7",
  28.   "up8","up9","up10","up11","up12","up13","up14",
  29.   "up15","up16","up17","up18","up19","up20",
  30.  
  31.   "0"};
  32.  
  33. int fnum=0 ;
  34. unsigned blen;
  35.  
  36. char *fn1[]={
  37. "DANGEROU.LPC",
  38. //;-----------------
  39. "XBINSTR.LP0","XBINSTR.LP1",
  40. //;-----------------
  41. "XCOM3.PG7",
  42. "XCOM3.PG0","XCOM3.PG1","XCOM3.PG3","XCOM3.PG4",
  43. "XCOM3.PG5","XCOM3.PG2",
  44.   "?","?","?",
  45. //;-----------------
  46. "XDEMO0.LPC","XDEMO1.LPC","XDEMO2.LPC","XDEMOS6.LPC",
  47. "XDEMOS7.LPC","XDEMOTXT.LPC","XBEGIN.LPC",
  48. //;-----------------
  49. "0"};
  50.  
  51. int disk2() // ***MAIN***
  52. {
  53.  char *z,*b,*m,*name;
  54.  unsigned i,j,k;
  55.  char *Fname=(char*)malloc(80);
  56.  for (;fn[fnum][0]!='0';fnum++);
  57.  strcpy(Fname,"d:\\'ufo2'\\xd2\\DISK.BIN");
  58.  HO=open(Fname,O_BINARY | O_CREAT | O_TRUNC | O_RDWR,S_IWRITE);
  59.  if (HO==-1) {perror("Ошибка создания образа диска\7\n");return 1;}
  60.  strcpy(Fname,"d:\\'ufo2'\\Asm80\\xdisk2.a80");
  61.  HASM=fopen(Fname,"w");
  62.  #define IO_Buff_Size 512*16
  63.  char IObuff[IO_Buff_Size]; //Буфер листинга
  64.  if (HASM==0) {perror("Ошибка открытия файла листинга \n\7");return 1;}
  65.  if(setvbuf(HASM,IObuff,_IOFBF,IO_Buff_Size))
  66.                 {printf("I/O error\7\n");return 1;}
  67.  fputs("; Длины файлов для НЛО-2 ***** (c) 1996 Медноногов В.C.\n",HASM);
  68.  fputs("; Номер сектора (1), смещение в секторе/4 (1)\n\n",HASM);
  69.    sprintf(Fname,"d:\\'ufo2'\\xd2\\xbstart2.bin");
  70.    HI=open(Fname,O_RDONLY | O_BINARY);
  71.    if(HI==-1) {perror("Fatal!!! \7");return 1;}
  72.    blen=filelength(HI);
  73.    if (blen>1024) {printf("Sec 9 fatal!\n");return 1;}
  74.    blen=1024;
  75.    printf("  Sec 9: 1024\n");
  76.    char *mem=(char*)malloc(blen);
  77.    if(mem==0){perror("No mem 1024!\7");return 1;}
  78.    read(HI,mem,blen);
  79.    write(HO,mem,blen);
  80.    close (HI);
  81.    free(mem);
  82.    long unsigned sumlen=0;
  83.    unsigned shift=0;
  84.    unsigned secn=0;
  85.  
  86.  for(i=1;i<fnum+1;i++)
  87.   {
  88.    sprintf(Fname,"d:\\'ufo2'\\zx_disc\\x%s.lpc",fn[i-1]);
  89.    printf("d:\\'ufo2'\\zx_disc\\x%s.lpc",fn[i-1]);
  90.    HI=open(Fname,O_RDONLY | O_BINARY);
  91.    if(HI==-1) {perror("Fatal! \7");return 1;}
  92.    blen=filelength(HI);
  93.    printf("   Длина: %u\r",blen);
  94.    char *mem=(char*)malloc(blen);
  95.    if(mem==0){perror("No mem!\7");return 1;}
  96.    read(HI,mem,blen);
  97.    j=blen%4;
  98.    if (j!=0) blen=blen-j+4;
  99.    write(HO,mem,blen);
  100.    close (HI);
  101.    free(mem);
  102.    fprintf(HASM,"\tDEFB\t%u,%u ;#%u (%s)\n",secn,shift,i,fn[i-1]);
  103.    sumlen+=(long unsigned)blen;
  104.    shift=(sumlen%1024L)/4;
  105.    secn=sumlen/1024L;
  106.    if (secn>=256) secn-=256;
  107.   }
  108.   fprintf(HASM,"\tDEFB\t%u,%u ;the end\n\n",secn,shift);
  109.   close(HO);
  110.   fclose(HASM);
  111.   return 0;
  112. }
  113.  
  114. int disk1() // ***MAIN***
  115. {
  116.  char *z,*b,*m,*name;
  117.  unsigned i,j,k;
  118.  char *Fname=(char*)malloc(80);
  119.  for (fnum=0;fn1[fnum][0]!='0';fnum++);
  120.  strcpy(Fname,"d:\\'ufo2'\\xd1\\DISK.BIN");
  121.  HO=open(Fname,O_BINARY | O_CREAT | O_TRUNC | O_RDWR,S_IWRITE);
  122.  if (HO==-1) {perror("Ошибка создания образа диска\7\n");return 1;}
  123.  strcpy(Fname,"d:\\'ufo2'\\Asm80\\xdisk1.a80");
  124.  HASM=fopen(Fname,"w");
  125.  #define IO_Buff_Size 512*16
  126.  char IObuff[IO_Buff_Size]; //Буфер листинга
  127.  if (HASM==0) {perror("Ошибка открытия файла листинга \n\7");return 1;}
  128.  if(setvbuf(HASM,IObuff,_IOFBF,IO_Buff_Size))
  129.                 {printf("I/O error\7\n");return 1;}
  130.  fputs("; Длины файлов на диске 1 *** (c) 1996 Медноногов В.C.\n",HASM);
  131.  fputs(";  Cектор(1), трек(1), длина/512 (1) \n\n",HASM);
  132.  
  133.    sprintf(Fname,"d:\\'ufo2'\\xd1\\xbstart.bin");
  134.    HI=open(Fname,O_RDONLY | O_BINARY);
  135.    if(HI==-1) {perror("Fatal!!! \7");return 1;}
  136.    blen=filelength(HI);
  137.    if (blen>1024) {printf("Sec 9/disk1 fatal!\n");return 1;}
  138.    blen=1024;
  139.    printf("  Sec 9: 1024\n");
  140.    char *mem=(char*)malloc(blen);
  141.    if(mem==0){perror("No mem 1024!\7");return 1;}
  142.    read(HI,mem,blen);
  143.    write(HO,mem,blen);
  144.    close (HI);
  145.    free(mem);
  146.  
  147.  unsigned trk=1;
  148.  unsigned sec=0;
  149.  for(i=1;i<fnum+1;i++)
  150.   {
  151.    sprintf(Fname,"d:\\'ufo2'\\xd1\\%s",fn1[i-1]);
  152.    printf("d:\\'ufo2'\\xd1\\%s",fn1[i-1]);
  153.    if (fn1[i-1][0] != '?')
  154.     {
  155.      HI=open(Fname,O_RDONLY | O_BINARY);
  156.      if(HI==-1) {perror("Fatal! \7");return 1;}
  157.      blen=filelength(HI);
  158.      printf(" * Длина: %u\n",blen);
  159.      if (blen%512>0) blen=(blen/512+1)*512;
  160.      char *mem=(char*)malloc(blen);
  161.      if(mem==0){perror("No mem!\7");return 1;}
  162.      read(HI,mem,blen);
  163.      write(HO,mem,blen);
  164.      close (HI);
  165.      free(mem);
  166.      blen/=512;
  167.      fprintf(HASM,"\tDEFB\t%u,%u ; File #%u\n",sec+0xF5,trk,i);
  168.      fprintf(HASM,"\tDEFB\t%u ; (%s)\n",blen,fn1[i-1]);
  169.     }
  170.    else
  171.     {
  172.      fprintf(HASM,"\tDEFB\t#F6,%u,32 ; none\n",i*3);
  173.      blen=0;
  174.     }
  175.    for (;blen>0;blen--)
  176.     {
  177.      sec++;
  178.      if (sec>8) {sec=0;trk++;}
  179.     }
  180.   }
  181.   close(HO);
  182.   fclose(HASM);
  183.   return 0;
  184. }
  185.  
  186. int main()
  187. {
  188.  printf("\n\t (c)1995,96  Медноногов В.C.\t\t");
  189.  printf("\n\tСоздание файлов disk.bin\n");
  190.  printf("\tдля дисков 1 и 2 игры\n");
  191.  printf("\tиз %u LPC-файлов\n\n",fnum);
  192.   disk2();
  193.   disk1();
  194.   return 0;
  195. }