Advertisement
Yesideez

NibbleADF v0.01

Aug 22nd, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | Source Code | 0 0
  1. -> $VER: NibbleADF.e v0.01 (22-Aug-2024)
  2.  
  3. /* To add:
  4. ** > Write verify
  5. ** > Validate file size when writing
  6. ** > Add QUIET option
  7. ***************************************/
  8.  
  9. MODULE 'dos','exec/io','amigalib/io','devices/trackdisk'
  10.  
  11. ENUM ERR_USAGE,ERR_MPORT,ERR_STDIO,ERR_TDDEV,ERR_MEM
  12.  
  13. DEF unit=0,opt=7,file[255]:STRING,write=FALSE,startTrack=0,endTrack=79,msgPort=0,verify=0,
  14. ioreq=0:PTR TO iostd,dev=1,res,buffer=0,totalTracks=0,fileptr=NIL:PTR TO LONG,flen=0,i
  15.  
  16. CONST INT_FULLDISK=901120,
  17. INT_TRACKSIZE=11264 ->INT_FULLDISK/80
  18.  
  19. PROC main() HANDLE
  20. DEF options:PTR TO LONG,rdargs
  21. options:=[0,0,0,0]
  22. IF rdargs:=ReadArgs('FILE/A,UNIT/N/A,OPT/N/A,WRITE/S',options,NIL)
  23. StrCopy(file,options[0])
  24. unit:=Long(options[1])
  25. opt:=Long(options[2])
  26. write:=options[3]
  27. FreeArgs(rdargs)
  28. ELSE
  29. usage()
  30. CleanUp(20)
  31. ENDIF
  32. SELECT opt
  33. CASE 1;startTrack:=0;endTrack:=19 ->first quarter
  34. CASE 2;startTrack:=20;endTrack:=39 ->second quarter
  35. CASE 3;startTrack:=40;endTrack:=59 ->third quarter
  36. CASE 4;startTrack:=60;endTrack:=79 ->fourth quarter
  37. CASE 5;startTrack:=0;endTrack:=39 ->first half
  38. CASE 6;startTrack:=40;endTrack:=79 ->second half
  39. DEFAULT;startTrack:=0;endTrack:=79 ->full disk
  40. ENDSELECT
  41. totalTracks:=endTrack-startTrack+1
  42. ->WriteF('From \d to \d (\d tracks, \d bytes)\n',startTrack,endTrack,totalTracks,totalTracks*INT_TRACKSIZE)
  43. IF ((msgPort:=CreateMsgPort())=0) THEN Raise(ERR_MPORT)
  44. IF ((ioreq:=createStdIO(msgPort))=0) THEN Raise(ERR_STDIO)
  45. IF (dev:=OpenDevice('trackdisk.device',unit,ioreq,0)) THEN Raise(ERR_TDDEV)
  46. IF ((buffer:=New(INT_TRACKSIZE))=0) THEN Raise(ERR_MEM)
  47. fileptr:=Open(file,IF write THEN OLDFILE ELSE NEWFILE)
  48. IF write THEN flen:=FileLength(file) ELSE flen:=0
  49. IF (flen=-1) OR (fileptr=NIL)
  50. WriteF('ERROR: Unable to \s file "\s"\n',IF write THEN 'open' ELSE 'create',file)
  51. CleanUp(20)
  52. ELSE
  53. FOR i:=startTrack TO endTrack
  54. WriteF('\sing track \d of \d (\d bytes)\b',IF write THEN 'Writ' ELSE 'Read',i,endTrack,i+1*INT_TRACKSIZE)
  55. ioreq.length:=INT_TRACKSIZE
  56. ioreq.data:=buffer
  57. ioreq.offset:=i*INT_TRACKSIZE
  58. IF write
  59. Read(fileptr,buffer,INT_TRACKSIZE)
  60. ioreq.command:=CMD_WRITE
  61. res:=DoIO(ioreq)
  62. IF res<>0 THEN WriteF('error \d\n',res)
  63. ELSE
  64. ioreq.command:=CMD_READ
  65. res:=DoIO(ioreq)
  66. IF res=0 THEN Write(fileptr,buffer,INT_TRACKSIZE) ELSE WriteF('error \d\n',res)
  67. ENDIF
  68. ENDFOR
  69. ioreq.command:=TD_MOTOR
  70. ioreq.length:=0
  71. DoIO(ioreq)
  72. Close(fileptr)
  73. WriteF(' \b')
  74. ENDIF
  75. CleanUp(0)
  76. EXCEPT DO
  77. SELECT exception
  78. CASE ERR_MPORT;WriteF('ERROR: Unable to create message port\n')
  79. CASE ERR_STDIO;WriteF('ERROR: Unable to create message iorequest\n')
  80. CASE ERR_TDDEV;WriteF('ERROR: Unable to open trackdisk.device on unit \d\n',unit)
  81. CASE ERR_MEM;WriteF('ERROR: Unable to allocate \d bytes\n',INT_TRACKSIZE)
  82. CASE ERR_USAGE;usage()
  83. ENDSELECT
  84. IF buffer THEN Dispose(buffer)
  85. IF dev=0 THEN CloseDevice(ioreq)
  86. IF ioreq THEN deleteStdIO(ioreq)
  87. IF msgPort THEN DeleteMsgPort(msgPort)
  88. ENDPROC
  89.  
  90. PROC usage()
  91. PutStr('\e[0;1;4mNibbleADF v0.01 by Zeb/SLP (22-Aug-2024)\e[0m\n\n')
  92. PutStr('Usage: NibbleADF <file> <unit> <opt> [WRITE]\n\n')
  93. PutStr('Where unit: 0-3 (disk drive to use)\n')
  94. PutStr(' opt: 1=tracks 0-19 (first quarter)\n')
  95. PutStr(' 2=tracks 20-39 (second quarter)\n')
  96. PutStr(' 3=tracks 40-59 (third quarter)\n')
  97. PutStr(' 4=tracks 60-79 (fourth quarter)\n')
  98. PutStr(' 5=tracks 0-39 (first half)\n')
  99. PutStr(' 6=tracks 40-79 (second half)\n')
  100. PutStr(' 7=tracks 0-79 (full disk)\n\n')
  101. PutStr('This program will read an AmigaDOS disk and rip the raw data to a file, As\n')
  102. PutStr('this program is designed for users with only 512KB installed memory, it will\n')
  103. PutStr('either rip quarter of a disk at a time, half a disk or a full disk at once.\n')
  104. PutStr('The quarter or half files can be put onto floppy disks, copied to another\n')
  105. PutStr('machine and then joined together.\n')
  106. ENDPROC
  107.  
  108. CHAR '$VER: NibbleADF v0.01 (22-Aug-2024)',0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement