?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оздание ТАР файла
  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.  
  35.  
  36. int main() // ***MAIN***
  37. {
  38.  char *z,*b,*m,*name;
  39.  unsigned i,j,k;
  40.  char *Fname=(char*)malloc(80);
  41.  for (;fn[fnum][0]!='0';fnum++);
  42.  printf("\n\t (c)1995,96  Медноногов В.C.\t\t");
  43.  printf("\n\tСоздание файла xcom.tap\n");
  44.  printf("\tиз %u LPC-файлов\n\n",fnum);
  45.  strcpy(Fname,"d:\\'ufo2'\\zx_disc\\xcom.tap");
  46.  HO=open(Fname,O_BINARY | O_CREAT | O_TRUNC | O_RDWR,S_IWRITE);
  47.  if (HO==-1) {perror("Ошибка создания ленточного файла\7\n");return 1;}
  48.  strcpy(Fname,"d:\\'ufo2'\\Asm80\\xtap.a80");
  49.  HASM=fopen(Fname,"w");
  50.  #define IO_Buff_Size 512*16
  51.  char IObuff[IO_Buff_Size]; //Буфер листинга
  52.  if (HASM==0) {perror("Ошибка открытия файла листинга \n\7");return 1;}
  53.  if(setvbuf(HASM,IObuff,_IOFBF,IO_Buff_Size))
  54.                 {printf("I/O error\7\n");return 1;}
  55.  fputs("; Длины файлов для НЛО-2 ***** (c) 1996 Медноногов В.C.\n\n",HASM);
  56.  
  57.  for(i=1;i<fnum+1;i++)
  58.   {
  59.    sprintf(Fname,"d:\\'ufo2'\\zx_disc\\x%s.lpc",fn[i-1]);
  60.    printf("d:\\'ufo2'\\zx_disc\\x%s.lpc",fn[i-1]);
  61.    HI=open(Fname,O_RDONLY | O_BINARY);
  62.    if(HI==-1) {perror("Fatal! \7");return 1;}
  63.    unsigned blen=filelength(HI);
  64.    printf("   Длина: %u\n",blen);
  65.    char *mem=(char*)malloc(blen);
  66.    if(mem==0){perror("No mem!\7");return 1;}
  67.    read(HI,mem,blen);
  68.    blen=blen;
  69.    blen+=2;
  70.    write(HO,&blen,2);
  71.    write(HO,&i,1);
  72.    blen-=2;
  73.    write(HO,mem,blen);
  74.    char ccr=(char)i;
  75.    for(k=0;k<blen;k++)ccr^=mem[k];
  76.    write(HO,&ccr,1);
  77.    close (HI);
  78.    free(mem);
  79.    fprintf(HASM,"\tDEFW\t\%5u ;#%u (%s)\n",blen,i,fn[i-1]);
  80.   }
  81.   close(HO);
  82.   fclose(HASM);
  83.   return 0;
  84. }