/[projet1]/public/pc/tools/osdk/main/tap2dsk/sources/tap2dsk.c
Defence Force logotype

Diff of /public/pc/tools/osdk/main/tap2dsk/sources/tap2dsk.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1508 by dbug, Sat Oct 24 15:33:07 2015 UTC revision 1509 by dbug, Sat Apr 13 12:04:39 2019 UTC
# Line 9  Line 9 
9  #include <stdio.h>  #include <stdio.h>
10  #include <stdlib.h>  #include <stdlib.h>
11  #include <string.h>  #include <string.h>
12    #define DIRTRACK 20
13  #define NBTRACKS 21  #define NBTRACKS 21
14  #define NBSECT 17  #define NBSECT 17
15    
# Line 195  int main(int argc, char *argv[]) Line 196  int main(int argc, char *argv[])
196    char name[17];    char name[17];
197    byte file_buffer[48*1024];    byte file_buffer[48*1024];
198    FILE *tape, *dsk;    FILE *tape, *dsk;
199    int dir_track=20, dir_sect=4;    int dir_track= DIRTRACK, dir_sect=4;
200    int tracks=21; // minimum track number    int tracks= DIRTRACK+1; // minimum track number
201    int total_sectors,free_sectors;    int total_sectors,free_sectors;
202    int tape_num,i;    int tape_num,i;
203    int tape_name_index = -1;    int tape_name_index = -1;
204    int paper_color = -1;    int paper_color = -1;
205    int ink_color = -1;    int ink_color = -1;
206    
207    printf("Tap2dsk V2.1\n");    printf("Tap2dsk V2.1.1\n");
208    
209    if (argc<2)    if (argc<2)
210    {    {
# Line 308  int main(int argc, char *argv[]) Line 309  int main(int argc, char *argv[])
309      int sector = i%NBSECT + 1;      int sector = i%NBSECT + 1;
310      allocate_sector(track,sector,sedoric+i*256);      allocate_sector(track,sector,sedoric+i*256);
311    }    }
312    allocate_sector(20,1,system_sect);    allocate_sector(DIRTRACK,1,system_sect);
313    allocate_sector(20,2,bitmap);    allocate_sector(DIRTRACK,2,bitmap);
314    allocate_sector(20,4,directory);    allocate_sector(DIRTRACK,4,directory);
315    
316    for (tape_num=1; tape_num<argc-1; tape_num++)    for (tape_num=1; tape_num<argc-1; tape_num++)
317    {    {
# Line 327  int main(int argc, char *argv[]) Line 328  int main(int argc, char *argv[])
328      while (fgetc(tape)!=EOF)      while (fgetc(tape)!=EOF)
329      {      {
330        int start,end,i;        int start,end,i;
331        while (fgetc(tape)!=0x24)        int readByte;
332          ;        while ( (readByte = fgetc(tape)) != 0x24)
333          {
334            if (readByte < 0)
335            {
336              break;
337            }
338          };
339          if (readByte < 0)
340          {
341            // Case where we miss an EOF because of some invalidl tape file
342            break;
343          }
344    
345        for (i=0;i<9;i++) header[i]=fgetc(tape);        for (i=0;i<9;i++) header[i]=fgetc(tape);
346        for (i=0;i<17;i++) {        for (i=0;i<17;i++) {
347          name[i]=fgetc(tape);          name[i]=fgetc(tape);
# Line 406  int main(int argc, char *argv[]) Line 419  int main(int argc, char *argv[])
419    bitmap[3]=free_sectors >> 8;    bitmap[3]=free_sectors >> 8;
420    bitmap[6]=tracks;    bitmap[6]=tracks;
421    bitmap[9]=tracks;    bitmap[9]=tracks;
422    update_sector(20,2,bitmap);    update_sector(DIRTRACK,2,bitmap);
423    
424    imageheader.tracks=tracks;    imageheader.tracks=tracks;
425    fwrite(&imageheader,sizeof(imageheader),1,dsk);    fwrite(&imageheader,sizeof(imageheader),1,dsk);

Legend:
Removed from v.1508  
changed lines
  Added in v.1509

  ViewVC Help
Powered by ViewVC 1.1.26