Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -> $VER: NibbleADF.e v0.01 (22-Aug-2024)
- /* To add:
- ** > Write verify
- ** > Validate file size when writing
- ** > Add QUIET option
- ***************************************/
- MODULE 'dos','exec/io','amigalib/io','devices/trackdisk'
- ENUM ERR_USAGE,ERR_MPORT,ERR_STDIO,ERR_TDDEV,ERR_MEM
- DEF unit=0,opt=7,file[255]:STRING,write=FALSE,startTrack=0,endTrack=79,msgPort=0,verify=0,
- ioreq=0:PTR TO iostd,dev=1,res,buffer=0,totalTracks=0,fileptr=NIL:PTR TO LONG,flen=0,i
- CONST INT_FULLDISK=901120,
- INT_TRACKSIZE=11264 ->INT_FULLDISK/80
- PROC main() HANDLE
- DEF options:PTR TO LONG,rdargs
- options:=[0,0,0,0]
- IF rdargs:=ReadArgs('FILE/A,UNIT/N/A,OPT/N/A,WRITE/S',options,NIL)
- StrCopy(file,options[0])
- unit:=Long(options[1])
- opt:=Long(options[2])
- write:=options[3]
- FreeArgs(rdargs)
- ELSE
- usage()
- CleanUp(20)
- ENDIF
- SELECT opt
- CASE 1;startTrack:=0;endTrack:=19 ->first quarter
- CASE 2;startTrack:=20;endTrack:=39 ->second quarter
- CASE 3;startTrack:=40;endTrack:=59 ->third quarter
- CASE 4;startTrack:=60;endTrack:=79 ->fourth quarter
- CASE 5;startTrack:=0;endTrack:=39 ->first half
- CASE 6;startTrack:=40;endTrack:=79 ->second half
- DEFAULT;startTrack:=0;endTrack:=79 ->full disk
- ENDSELECT
- totalTracks:=endTrack-startTrack+1
- ->WriteF('From \d to \d (\d tracks, \d bytes)\n',startTrack,endTrack,totalTracks,totalTracks*INT_TRACKSIZE)
- IF ((msgPort:=CreateMsgPort())=0) THEN Raise(ERR_MPORT)
- IF ((ioreq:=createStdIO(msgPort))=0) THEN Raise(ERR_STDIO)
- IF (dev:=OpenDevice('trackdisk.device',unit,ioreq,0)) THEN Raise(ERR_TDDEV)
- IF ((buffer:=New(INT_TRACKSIZE))=0) THEN Raise(ERR_MEM)
- fileptr:=Open(file,IF write THEN OLDFILE ELSE NEWFILE)
- IF write THEN flen:=FileLength(file) ELSE flen:=0
- IF (flen=-1) OR (fileptr=NIL)
- WriteF('ERROR: Unable to \s file "\s"\n',IF write THEN 'open' ELSE 'create',file)
- CleanUp(20)
- ELSE
- FOR i:=startTrack TO endTrack
- WriteF('\sing track \d of \d (\d bytes)\b',IF write THEN 'Writ' ELSE 'Read',i,endTrack,i+1*INT_TRACKSIZE)
- ioreq.length:=INT_TRACKSIZE
- ioreq.data:=buffer
- ioreq.offset:=i*INT_TRACKSIZE
- IF write
- Read(fileptr,buffer,INT_TRACKSIZE)
- ioreq.command:=CMD_WRITE
- res:=DoIO(ioreq)
- IF res<>0 THEN WriteF('error \d\n',res)
- ELSE
- ioreq.command:=CMD_READ
- res:=DoIO(ioreq)
- IF res=0 THEN Write(fileptr,buffer,INT_TRACKSIZE) ELSE WriteF('error \d\n',res)
- ENDIF
- ENDFOR
- ioreq.command:=TD_MOTOR
- ioreq.length:=0
- DoIO(ioreq)
- Close(fileptr)
- WriteF(' \b')
- ENDIF
- CleanUp(0)
- EXCEPT DO
- SELECT exception
- CASE ERR_MPORT;WriteF('ERROR: Unable to create message port\n')
- CASE ERR_STDIO;WriteF('ERROR: Unable to create message iorequest\n')
- CASE ERR_TDDEV;WriteF('ERROR: Unable to open trackdisk.device on unit \d\n',unit)
- CASE ERR_MEM;WriteF('ERROR: Unable to allocate \d bytes\n',INT_TRACKSIZE)
- CASE ERR_USAGE;usage()
- ENDSELECT
- IF buffer THEN Dispose(buffer)
- IF dev=0 THEN CloseDevice(ioreq)
- IF ioreq THEN deleteStdIO(ioreq)
- IF msgPort THEN DeleteMsgPort(msgPort)
- ENDPROC
- PROC usage()
- PutStr('\e[0;1;4mNibbleADF v0.01 by Zeb/SLP (22-Aug-2024)\e[0m\n\n')
- PutStr('Usage: NibbleADF <file> <unit> <opt> [WRITE]\n\n')
- PutStr('Where unit: 0-3 (disk drive to use)\n')
- PutStr(' opt: 1=tracks 0-19 (first quarter)\n')
- PutStr(' 2=tracks 20-39 (second quarter)\n')
- PutStr(' 3=tracks 40-59 (third quarter)\n')
- PutStr(' 4=tracks 60-79 (fourth quarter)\n')
- PutStr(' 5=tracks 0-39 (first half)\n')
- PutStr(' 6=tracks 40-79 (second half)\n')
- PutStr(' 7=tracks 0-79 (full disk)\n\n')
- PutStr('This program will read an AmigaDOS disk and rip the raw data to a file, As\n')
- PutStr('this program is designed for users with only 512KB installed memory, it will\n')
- PutStr('either rip quarter of a disk at a time, half a disk or a full disk at once.\n')
- PutStr('The quarter or half files can be put onto floppy disks, copied to another\n')
- PutStr('machine and then joined together.\n')
- ENDPROC
- CHAR '$VER: NibbleADF v0.01 (22-Aug-2024)',0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement