home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ALIVE / ALIVE10A.MSA / FILEZ / DIM2ST.ZIP / DIM2ST / dim2st.lst
File List  |  2005-05-13  |  3KB  |  122 lines

  1. '
  2. ' .dim -> .st
  3. '
  4. ' Coded by GGN of KÜA software productions in GFA BASIC 3.50E
  5. ' Edited a bit to go with my article for Alive
  6. '
  7. DEFWRD "A-z"
  8. FILESELECT DIR$(GEMDOS(25)+65),"",n$
  9. DIM a|(20*512),b|(5*1024),cluster_map|(2880)
  10. CLS
  11. PRINT
  12. PRINT "Read disk conf:"
  13. PRINT "Get sectors:"
  14. PRINT "Sides:"
  15. PRINT "Sectors:"
  16. PRINT "Start track:"
  17. PRINT "End track:"
  18. PRINT "Sector size:"
  19. PRINT "Sectors per cluster:"
  20. PRINT "Cluster size:"
  21. PRINT "Root dir size (sectors):"
  22. PRINT "FAT size (sectors):"
  23. PRINT "FAT + bootsector size (sectors):"
  24. PRINT "Total system size (sectors):"
  25. PRINT AT(1,1);n$'
  26. OPEN "i",#1,n$
  27. a%=V:a|(0)                      !a|()=read buffer
  28. b%=V:b|(0)                      !b|()=empty cluster buffer
  29. BGET #1,a%,32
  30. IF DPEEK(a%)=&H4242             !"BB"=FCopy pro header
  31.   PRINT "- FCopy pro image     "
  32.   disk_conf!=PEEK(a%+2)         !true=yes, false=no
  33.   get_sec!=PEEK(a%+3)           !true=used, false=all
  34.   sides=PEEK(a%+6)
  35.   sects=PEEK(a%+8)
  36.   st_track=PEEK(a%+10)
  37.   end_track=PEEK(a%+12)
  38.   sect_size=DPEEK(a%+14)
  39.   sect_per_clust=DPEEK(a%+16)
  40.   clust_size=DPEEK(a%+18)
  41.   root_size=DPEEK(a%+20)
  42.   fat1_size=DPEEK(a%+22)
  43.   fat2_size=DPEEK(a%+24)
  44.   total_size=DPEEK(a%+26)
  45.   no_of_clusts=DPEEK(a%+28)
  46.   IF disk_conf!
  47.     PRINT AT(17,2);"Yes"
  48.   ELSE
  49.     PRINT AT(17,2);"No "
  50.   ENDIF
  51.   IF get_sec!
  52.     PRINT AT(14,3);"Used"
  53.   ELSE
  54.     PRINT AT(14,3);"All "
  55.   ENDIF
  56.   PRINT AT(8,4);sides+1
  57.   PRINT AT(10,5);sects'
  58.   PRINT AT(14,6);st_track'
  59.   PRINT AT(12,7);end_track'
  60.   PRINT AT(14,8);sect_size'
  61.   PRINT AT(22,9);sect_per_clust'
  62.   PRINT AT(15,10);clust_size
  63.   PRINT AT(26,11);root_size
  64.   PRINT AT(20,12);fat1_size
  65.   PRINT AT(25,13);fat2_size
  66.   PRINT AT(30,14);total_size
  67.   f2$=LEFT$(n$,LEN(n$)-3)+"ST"
  68.   track_size=sect_size*sects
  69. ELSE
  70.   ~FORM_ALERT(1,"[3][Baaah!|Not a FCopy pro image!][Drat!]")
  71.   END
  72. ENDIF
  73. PRINT SPACE$(10*80);
  74. PRINT AT(1,15);
  75. @dump
  76. CLOSE #1
  77. '
  78. PROCEDURE dump
  79.   OPEN "o",#2,f2$
  80.   fat1=fat1_size*512
  81.   BGET #1,a%,total_size*512
  82.   BPUT #2,a%,total_size*512
  83.   ARRAYFILL b|(),PEEK(a%+512)           !fill empty cluster with data
  84.   c%=a%+512+fat1_size*512+3             !point to 2nd FAT first entry!
  85.   j=0
  86.   ARRAYFILL cluster_map|(),255
  87.   '
  88.   ' Here we check the FAT to see which clusters are used
  89.   ' Note that bad sectors are not handled yet (dunno if they should be)
  90.   ' Just for the record, we just check the entry to see if it is in the
  91.   ' range $ff1 to $ff7
  92.   '
  93.   FOR k=0 TO ((end_track+1)*sides*sects)/sect_per_clust-1
  94.     temp|=PEEK(c%+1)
  95.     temp=SHL&(temp| AND 15,8)+PEEK(c%)
  96.     IF temp=0 OR (temp=>&HFF1 AND temp<=&HFF7)  !Check first 12 bits ("even" entry)
  97.       cluster_map|(j)=0
  98.     ENDIF
  99.     temp=SHL&(PEEK(c%+2),4)+SHR|(temp| AND 240,4)
  100.     IF temp=0 OR (temp>=&HFF1 AND temp<=&HFF7) !Check last 12 bits ("odd" entry)
  101.       cluster_map|(j+1)=0
  102.     ENDIF
  103.     ADD c%,3
  104.     ADD j,2
  105.   NEXT k
  106.   '
  107.   ' Now we check if each cluster is empty or not. If empty, dump an
  108.   ' "empty" cluster. If not, read from the file and dump it
  109.   '
  110.   FOR i=0 TO no_of_clusts-1
  111.     IF cluster_map|(i)
  112.       BGET #1,a%,clust_size
  113.       BPUT #2,a%,clust_size
  114.       PRINT "O";
  115.     ELSE
  116.       BPUT #2,b%,clust_size
  117.       PRINT "o";
  118.     ENDIF
  119.   NEXT i
  120.   CLOSE #2
  121. RETURN
  122.