Created
June 12, 2018 17:36
-
-
Save mnaberez/119d1926f29039597c88a12af2d3e663 to your computer and use it in GitHub Desktop.
CBM BASIC program that reads a real disk and creates a D80 image. Alternate version that handles bad sectors and writes the error map at the end of the image file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;d80 read 2 ==0801== | |
5 input"source unit";su | |
6 input"destination unit";du | |
7 input"image filename";f$ | |
8 if right$(f$,4)=".d80" then f$=left$(f$, len(f$)-4) | |
9 fi$=f$+".d80":fe$=f$+".txt" | |
10 bl$="":rem bad sector list | |
30 open2,du,2,fi$+",p,w" | |
35 open15,su,15 | |
40 open3,su,3,"#" | |
45 lt=77 | |
50 for t=1 to lt | |
60 if t>=1 and t<=39 then ls=28 | |
70 if t>=40 and t<=53 then ls=26 | |
80 if t>=54 and t<=64 then ls=24 | |
90 if t>=65 and t<=77 then ls=22 | |
98 bs=0:rem this sector bad flag | |
99 pb=0:rem prev sector bad flag | |
100 for s=00 to ls:print"{down}t";t;"s";s | |
110 gosub 1300:rem try to read sector | |
115 pb=bs | |
130 if bs=0 then gosub 1100 | |
135 if bs=1 then gosub 1200 | |
200 next s : next t | |
205 print "{down}";fi$;" written to unit";du | |
210 close2:close3:print#15,"i0":close15 | |
215 gosub 1500 | |
220 end | |
1000 rem check error | |
1001 ok=1 | |
1005 input#15,en$,em$,et$,es$ | |
1010 print" "o$" "en$" "em$" "et$" "es$ | |
1020 if en$<>"00" then ok=0 | |
1025 return | |
1100 rem copy sector bytes | |
1105 for by=0 to 255 | |
1110 get #3, b$ | |
1120 if b$="" then b$=chr$(0) | |
1125 print#2,b$; | |
1130 next by | |
1135 return | |
1200 rem dummy bytes for bad sector | |
1210 forby=0to255:print#2,chr$(0);:nextby | |
1220 return | |
1300 rem read sector with retry | |
1301 if pb=0 then i=1 | |
1302 if pb=1 then i=3:rem no retries if previous sector bad | |
1303 bs=0 | |
1305 o$="u1":print#15,o$;3;0;t;s | |
1310 gosub1000 | |
1315 if ok=1 then return | |
1317 i=i+1 | |
1320 if i > 3 then bs=1:bl$=bl$+"t"+str$(t)+", s"+str$(s)+chr$(13):return | |
1321 print "retry ";i | |
1330 goto 1305 | |
1500 rem write bad sector list | |
1505 if bl$="" then print"{down}no bad sectors":return | |
1515 open2,du,2,fe$+",s,w" | |
1520 print#2,fi$+" bad sectors"+chr$(13) | |
1525 print#2,bl$:print"{down}bad sectors:";chr$(13);bl$ | |
1530 close2 | |
1540 return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment