Home » Personal collection » Acorn hard disk » apps » SCSI » !HFORM/!Runimage
!HFORM/!Runimage
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Personal collection » Acorn hard disk » apps » SCSI |
| Filename: | !HFORM/!Runimage |
| Read OK: | ✔ |
| File size: | 97BA bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
File contents
10REM > !RunImage
130*set HForm$EndStatus 1
140Log2ShareSize%=0
150ShareSize%=1<<Log2ShareSize%
160dev%=FALSE
170Verbose%=dev%
200msgs_file_desc%=0
210msgs_file_open%=FALSE
220ONERRORPROCabort(REPORT$,1)
230VDU26:VDU12
240PROCInit
250PROCGetShape
260IFNOTBigADFS%THEN
280IF(DiscSize2%<>0OR(DiscSize%AND&E0000000)<>0)THEN
290PROCmessage_print_0("DiscSizeError")
300PROCfinish
310ENDIF
320ENDIF
330FormatFlag%=(FNChoose("Q01:","FormatOrInitChoose","FI","")="F")
340SoakStyle$=FNChoose("Q02:","SoakTestChoose","LSN","")
350BootOpt$=FNChoose("BootOpt:","BootOptChoose","YN","")
360IFFNchoose_no_lookup("Q03:",FNmessage_lookup_1("SureChoose",STR$(Drive%)),"YN","")="N"PROCfinish
380PROCDisableEscape
390PROCMoanOp(Specify%,0,0,0)
400IFFormatFlag%THEN
410PROCFormat
420ENDIF
430IFSoakStyle$<>"N"THEN
440SoakFlag%=(SoakStyle$="L")
450PROCVerify
460ENDIF
470PRINT
480PROCStructure
490PROCRestoreEscape
520OSCLI("-ADFS-%MOUNT :"+STR$Drive%)
530OSCLI("-ADFS-%FREE :"+STR$Drive%)
540OSCLI("-ADFS-%DISMOUNT :"+STR$Drive%)
570*set HForm$EndStatus 0
580PROCexit
610DEFPROCInit
620LOCALDriveOffset%
630PROCopen_message_file("<HForm$Dir>.Messages")
640PROCmessage_print_0("Banner")
660autoreply$=FNreadvarval("Hform$Autoreply")
680SYS"XOS_Module",18,"ADFS"TO,,,A%;F%
690IFF%AND1PROCmessage_print_0("NoADFS"):PROCfinish
700A%+=A%!20
710WHILE(?A%<>32)AND(?A%<>9)AND(?A%<>0):A%+=1:ENDWHILE
720IF?A%=0PROCfinish
730WHILE(?A%<ASC"0")OR(?A%>ASC"9"):A%+=1:ENDWHILE
740ADFSVersion%=((?A%-ASC"0")*10+(A%?2)-ASC"0")*10+(A%?3)-ASC"0"
750SYS"ADFS_Drives"TO,,HDiscs%
760IFHDiscs%<1PROCmessage_print_0("NoHardDiscs"):PROCfinish
800BigADFS%=FNBigADFS
820DriveOffset%=INSTR(autoreply$,"Drive=")
830IF(DriveOffset%<>0)THEN
840Drive%=VAL(MID$(autoreply$,DriveOffset%+6))
850ELSE
860REPEAT
870Drive%=FNAsk("DriveAsk",4,4)
880UNTILDrive%>=4AND Drive%<=7
890ENDIF
910IF(Drive%-3)>HDiscs%THEN
920PROCmessage_print_1("SillyDiscNum",STR$(HDiscs%))
930PROCfinish
940ENDIF
950IFADFSVersion%<210THEN
960IDE%=FALSE
970ELSE
980SYS"ADFS_ControllerType",Drive%TODriveType%
990IFDriveType%=0THEN
1000PROCmessage_print_1("DriveNotPresent",STR$(Drive%))
1010PROCfinish
1020ELSE
1030IFDriveType%=3PROCmessage_print_1("DriveIsST506",STR$(Drive%))
1040IFDriveType%=4PROCmessage_print_1("DriveIsIDE",STR$(Drive%))
1050ENDIF
1060IDE%=DriveType%=4
1070ENDIF
1080IFIDE%THEN
1100SYS"XADFS_ControllerType",Drive%-1TOA%;F%
1110IF((F%AND1)=0)AND(A%=4)THENIDEdrive%=1ELSEIDEdrive%=0
1120DIMIDEid%512
1130DIMIDEpb%7
1140IDEpb%!0=0
1150IDEpb%!4=0
1160IDEpb%?5=&A0+(IDEdrive%<<4)
1170IDEpb%?6=&EC
1180SYS"ADFS_IDEUserOp",1<<24,,IDEpb%,IDEid%,512TOr0%,,,,r4%
1190IFr0%<>0ORr4%<>0THEN
1200PROCmessage_print_1("DiscIdError",STR$~(r0%))
1210IDEcyls%=0:IDEheads%=0:IDEsecs%=0
1220ELSE
1230IDEcyls%=(IDEid%!2)AND&FFFF
1240IDEheads%=(IDEid%!6)AND&FFFF
1250IDEsecs%=(IDEid%!12)AND&FFFF
1260IDECapacity%=(IDEid%!(57*2))
1270IDEAddressSpace%=(IDEid%!(60*2))
1280IDEname$=""
1290IF(((IDEid%!98)>>9)AND1)<>0THENIDEHasLBA%=1ELSEIDEHasLBA%=0
1300FORI%=27*2TO46*2STEP2
1310A%=(IDEid%?(I%+1)):B%=(IDEid%?I%)
1320IF(A%<32)OR(A%>=127)A%=ASC"."
1330IDEname$+=CHR$(A%)
1340IF(B%<32)OR(B%>=127)B%=ASC"."
1350IDEname$+=CHR$(B%)
1360NEXT
1370IDEfirm$=""
1380FORI%=23*2TO26*2STEP2
1390A%=(IDEid%?(I%+1)):B%=(IDEid%?I%)
1400IF(A%<32)OR(A%>=127)A%=ASC"."
1410IDEfirm$+=CHR$(A%)
1420IF(B%<32)OR(B%>=127)B%=ASC"."
1430IDEfirm$+=CHR$(B%)
1440NEXT
1450PROCmessage_print_3("IDEDescription",STR$(Drive%),IDEname$,IDEfirm$)
1460PROCmessage_print_3("IDEConfiguration",STR$(IDEcyls%),STR$(IDEheads%),STR$(IDEsecs%))
1470IFIDEHasLBA%<>0THEN
1480PROCmessage_print_0("IDEHasLBA")
1490ENDIF
1500ENDIF
1510ENDIF
1520MakeParams%=7
1530VerifyRetries%=1
1540DefectRetries%=5
1550Verify%=0
1560Read%=1
1570Write%=2
1580WriteTrack%=4
1590Restore%=6
1600Specify%=&F
1610AltDefectBit%=&10
1620DiscStruc%=&14
1640IFIDE%THEN
1650Log2SecSize%=9
1660LowSector%=1
1670ELSE
1680Log2SecSize%=8
1690LowSector%=0
1700ENDIF
1710SecSize%=2^Log2SecSize%
1730OldMapAdd%=0
1740OldMapSize%=&200
1750DirSize%=&800
1770BootAdd%=&C00/SecSize%
1780BootSize%=&200
1870MaxDefects%=(BootSize%-64-&10-4-4)DIV4
1930BigMaxDefects%=MaxDefects%-1
1950EndDefect%=1<<29
2000EndDefect2%=1<<30
2020OldLWM%=&E00
2030FreeLink%=1
2040CrossCheck%=3
2060IFBigADFS%THEN
2070AdfsSwi%=&4024D
2080ELSE
2090AdfsSwi%=&40240
2100ENDIF
2120AdfsDiscErr%=&108C7
2130MaxVerifyBad%=16
2140Patterns%=8
2150DIMBuf%&40000,DiscRec%64+BootSize%,Defect%BootSize%,DirMark%5,Bad%(MaxVerifyBad%),mc%100,Pattern%(Patterns%-1)
2160Boot%=DiscRec%+64
2170BootRec%=Boot%+BootSize%-64
2290Pattern%(2)=&FFFFFF
2300Pattern%(3)=&6DB6DB
2310Pattern%(4)=0
2320Pattern%(5)=&2CB2CB
2330Pattern%(6)=&5A5A5A
2340Pattern%(7)=&4D34D3
2350SecsPerTrk%=32:Heads%=1:Cyls%=1:ParkCyl%=1
2360IFIDE%THEN
2370InitFlag%=0
2380LBAflag%=0
2390ELSE
2400LowCurrentCyl%=1:PreCompCyl%=1
2410ENDIF
2430IFBigADFS%
2440RootDirAdd%=&400/512
2450ELSE
2460RootDirAdd%=&400
2470ENDIF
2490Log2Alloc%=10:LinkBits%=10
2500PROCShareSize
2510IndRootDirAdd%=RootDirAdd%
2560IFIDEHasLBA%THEN
2570SectorsPerDisc%=IDEAddressSpace%
2580ELSE
2590SectorsPerDisc%=IDECapacity%
2600ENDIF
2610DiscSize%=(SectorsPerDisc%AND((1<<(32-Log2SecSize%))-1))<<Log2SecSize%
2620DiscSize2%=(SectorsPerDisc%>>(32-Log2SecSize%))
2640IF(DiscSize%>=(512*1024*1024))OR(DiscSize2%<>0)THEN
2650BigDisc%=TRUE
2660ELSE
2670BigDisc%=FALSE
2680ENDIF
2700SYS"ADFS_Retries",&ff,0TO,,adfs_retries%
2710LOCALERROR
2720ONERRORLOCAL:ONERROROFF:SYS"ADFS_Retries",&ff,adfs_retries%:PROCAsm:ENDPROC
2730OSCLI("-ADFS-%DISMOUNT :"+STR$Drive%)
2740ONERROROFF
2750SYS"ADFS_Retries",&ff,adfs_retries%
2760PROCAsm
2770ENDPROC
2810DEFPROCGetShape
2820Formatted%=FALSE
2830PROCInitBootDefects
2840PROCInitDiscRec
2850SYS"ADFS_Retries",&ff,0TO,,adfs_retries%
2860PROCMoanOp(Restore%,0,0,0)
2870PROCOp(Read%,BootAdd%,Boot%,BootSize%)
2880SYS"ADFS_Retries",&ff,adfs_retries%
2890IFResult%<>0ORNOTFNGoodDefectsTHEN
2900PROCmessage_print_0("NoValidFormat")
2910ELSE
2920PROCOldShape
2930PROCOp(Verify%,0,0,SecSize%*SecsPerTrk%)
2940IFFNConfirmMakeTHENFormatted%=TRUE
2950ENDIF
2970IFNOTFormatted%THEN
2980IFIDE%THEN
2990IFNOTFNCompareMakeTHEN
3010IFINSTR(autoreply$,"NOunknown")PROCabort(FNmessage_lookup_0("UnknownDriveType"),1)
3020PROCAskMake
3030ENDIF
3040ELSE
3060PROCAskMake
3070ENDIF
3080FORI%=0TOBootSize%-4
3090Boot%!I%=0
3100NEXTI%
3110PROCInitBootDefects
3120ENDIF
3140PROCAskShape((NOTFormatted%)AND EnglishMake$="OTHER")
3150PROCmessage_print_1("WillFormat",TransMake$)
3160PROCprintshape(IDE%)
3170PRINT
3180ENDPROC
3210DEFPROCOldShape
3220SecsPerTrk%=BootRec%?1
3230Heads%=BootRec%?2
3240Log2Alloc%=BootRec%?5
3250DiscSize%=BootRec%!&10
3260DiscSize2%=BootRec%!&24
3280IF(DiscSize%>=(512*1024*1024))OR(DiscSize2%<>0)THEN
3290BigDisc%=TRUE
3300ELSE
3310BigDisc%=FALSE
3320ENDIF
3340SectorsPerDisc%=(DiscSize%>>Log2SecSize%)+(DiscSize2%<<(32-Log2SecSize%))
3360Cyls%=SectorsPerDisc%DIV(SecsPerTrk%*Heads%)
3370IFIDE%THEN
3380InitFlag%=(BootRec%?-5)
3390LBAflag%=(BootRec%?-6)
3400ELSE
3410LowCurrentCyl%=(BootRec%!-8)AND&3FF
3420PreCompCyl%=(BootRec%!-6)AND&3FF
3430ENDIF
3440IFBigDisc%THEN
3450ParkCyl%=(BootRec%!-4)DIV(SecsPerTrk%*Heads%)
3460ELSE
3470ParkCyl%=(BootRec%!-4)DIV(SecSize%*SecsPerTrk%*Heads%)
3480ENDIF
3490PROCInitDiscRec
3500ENDPROC
3530DEFPROCAskMake
3540PROCrestoreparams(IDE%)
3550Makes%=0
3560I%=INSTR(autoreply$,"DriveType:")
3570IFI%<>0THEN
3580I%+=LEN("DriveType:")
3590Make%=EVAL(MID$(autoreply$,I%,INSTR(autoreply$,",",I%)-I%))
3600ELSE
3610PROCmessage_print_0("DriveDisclaim")
3620REPEAT
3630READEnglishMake$,TokenMake$
3640TransMake$=FNmessage_lookup_0(TokenMake$)
3650Makes%+=1
3660PROCmessage_print_2("MakeMenu",RIGHT$(" "+STR$Makes%,2),TransMake$)
3670FORI%=1TOMakeParams%
3680READA$
3690NEXTI%
3700UNTILEnglishMake$="OTHER"
3710PRINT
3720Make%=FNInputDec("ManufacturerDec",1,Makes%)
3730PROCrestoreparams(IDE%)
3740ENDIF
3750I%=(Make%-1)*(MakeParams%+2)
3760WHILEI%>0
3770READA$
3780I%-=1
3790ENDWHILE
3800IFIDE%THEN
3810READEnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,InitFlag%,Dummy%,ParkCyl%,LBAflag%
3820ELSE
3830READEnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,LowCurrentCyl%,PreCompCyl%,ParkCyl%
3840ENDIF
3850TransMake$=FNmessage_lookup_0(TokenMake$)
3870IFIDE%THEN
3880IF(EnglishMake$="OTHER")AND(IDEcyls%<>0)THEN
3890SecsPerTrk%=IDEsecs%
3900Heads%=IDEheads%
3910Cyls%=IDEcyls%
3920InitFlag%=1
3930LBAFlag%=1
3940IFINSTR(autoreply$,"LBA:On")<>0THEN
3950LBAFlag%=1
3960ELSE
3970IFINSTR(autoreply$,"LBA:Off")<>0THEN
3980LBAFlag%=0
3990ENDIF
4000ENDIF
4010ParkCyl%=IDEcyls%-1
4020ENDIF
4030ENDIF
4040ENDPROC
4070DEFFNConfirmMake
4080LOCALmatched%
4090PROCrestoreparams(IDE%)
4100REPEAT
4110READEnglishMake$,TokenMake$,P1%,P2%,P3%,P4%,P5%,P6%,P7%
4120TransMake$=FNmessage_lookup_0(TokenMake$)
4130IFEnglishMake$="OTHER"THEN
4140PROCmessage_print_0("NonStandardShape")
4150PROCprintshape(IDE%)
4160PRINT
4170=FNChoose("Q04:","RetainShapeChoose","YN","")="Y"
4180ENDIF
4190matched%=TRUE
4200IFIDE%THEN
4210IFP1%<>SecsPerTrk%ORP2%<>Heads%ORP3%<>Cyls%ORP4%<>InitFlag%ORP6%<>ParkCyl%ORP7%<>LBAflag%ENDIF:matched%=FALSE
4220ELSE
4230IFP1%<>SecsPerTrk%ORP2%<>Heads%ORP3%<>Cyls%ORP4%<>LowCurrentCyl%ORP5%<>PreCompCyl%ORP6%<>ParkCyl%ENDIF:matched%=FALSE
4240ENDIF
4250UNTILmatched%
4270PROCmessage_print_1("StandardShape",TransMake$)
4280PROCprintshape(IDE%)
4290PRINT
4300=FNChoose("Q05:","UseShapeChoose","YN","")="Y"
4330DEFPROCprintshape(itype%)
4340PROCmessage_print_3("PrintShape",STR$(Cyls%),STR$(Heads%),STR$(SecsPerTrk%))
4350IFitype%THEN
4360PROCmessage_print_3("PrintShape3IDE",STR$(ParkCyl%),STR$(InitFlag%),STR$(LBAflag%))
4370ELSE
4380PROCmessage_print_3("PrintShape2ST506",STR$(ParkCyl%),STR$(LowCurrentCyl%),STR$(PreCompCyl%))
4390ENDIF
4400ENDPROC
4440DEFFNCompareMake
4450PROCrestorePROD
4460REPEAT
4470READEnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,InitFlag%,Dummy%,ParkCyl%,LBAflag%
4480TransMake$=FNmessage_lookup_0(TokenMake$)
4490IFEnglishMake$="OTHER"THEN
4500PROCmessage_print_0("UnknownDriveMake")
4510=FALSE
4520ENDIF
4530UNTILFNmatchstrings(EnglishMake$,IDEname$)
4540=FNChoose("Q06:","StandardShapeChoose","YN","")="Y"
4580DEFPROCAskShape(tailored%)
4600IFIDE%OR(INSTR(autoreply$,"NewMap")<>0)THEN
4610NewMap%=TRUE
4620ELSE
4630NewMap%=(FNChoose("OldOrNewMap:","OldNewMapChoose","ON","N")="N")
4640ENDIF
4660IFtailored%THEN
4670SecsPerTrk%=FNAsk("SectorsAsk",SecsPerTrk%,1)
4680IFIDE%THEN
4690REPEAT
4700Heads%=FNAsk("IDEHeadsAsk",Heads%,1)
4710IFHeads%>16PROCmessage_print_0("IDEHeads16")
4720UNTILHeads%<=16
4730ELSE
4740Heads%=FNAsk("ST506HeadsAsk",Heads%,1)
4750IFHeads%>8PROCmessage_print_0("ST506Heads8")
4760ENDIF
4770Cyls%=FNAsk("CylindersAsk",Cyls%,1)
4790IFIDE%THEN
4800InitFlag%=FNAsk("InitAsk",InitFlag%,0)
4810IFIDEHasLBA%THEN
4820LBAFlag%=1
4830IFINSTR(autoreply$,"LBA:On")<>0THEN
4840LBAFlag%=1
4850ELSE
4860IFINSTR(autoreply$,"LBA:Off")<>0THEN
4870LBAFlag%=0
4880ELSE
4890LBAflag%=FNAsk("LBAAsk",LBAflag%,1)
4900ENDIF
4910ENDIF
4920ELSE
4930LBAflag%=0
4940ENDIF
4950ELSE
4960LowCurrentCyl%=FNAsk("LowCylinderAsk",LowCurrentCyl%,0)
4970PreCompCyl%=FNAsk("PrecompCylinderAsk",PreCompCyl%,0)
4980ENDIF
4990ParkCyl%=FNAsk("ParkCylinderAsk",ParkCyl%,0)
5000ENDIF
5020DiscRec%?1=SecsPerTrk%
5030DiscRec%?2=Heads%
5060SectorsPerDisc%=SecsPerTrk%*Heads%*Cyls%
5070IFIDEHasLBA%THEN
5080IFSectorsPerDisc%>IDEAddressSpace%THENSectorsPerDisc%=IDEAddressSpace%
5090ELSE
5100IFSectorsPerDisc%>IDECapacity%THENSectorsPerDisc%=IDECapacity%
5110ENDIF
5130DiscSize%=(SectorsPerDisc%AND((1<<(32-Log2SecSize%))-1))<<Log2SecSize%
5140DiscSize2%=(SectorsPerDisc%>>(32-Log2SecSize%))
5160IF(DiscSize%>=(512*1024*1024))OR(DiscSize2%<>0)THEN
5170BigDisc%=TRUE
5180ELSE
5190BigDisc%=FALSE
5200ENDIF
5220DiscRec%!&10=DiscSize%
5230DiscRec%!&24=DiscSize2%
5240DiscRec%?&28=Log2ShareSize%
5270IF((DiscSize%AND&E0000000)<>0OR(DiscSize2%<>0))THEN
5280DiscRec%?&29=1
5290ELSE
5300DiscRec%?&29=0
5310ENDIF
5330FORI%=0TOBootSize%-4STEP4
5340Defect%!I%=Boot%!I%
5350NEXTI%
5360Boot%!0=EndDefect%
5370REPEAT
5380ptr%=0
5390defectlist%=0
5400IFBigDisc%THEN
5410IFDefect%!ptr%>=EndDefect%THEN
5420IFDefect%!(ptr%+4)<EndDefect2%PROCmessage_print_0("CurrentDefects")
5430ELSE
5440PROCmessage_print_0("CurrentDefects")
5450ENDIF
5460ELSE
5470IFDefect%!(ptr%)<EndDefect%PROCmessage_print_0("CurrentDefects")
5480ENDIF
5490WHILE((Defect%!ptr%<EndDefect%)ANDNOTBigDisc%)OR(Defect%!ptr%<EndDefect2%AND BigDisc%)
5500IF((Defect%!ptr%AND&E0000000)=EndDefect%)THEN
5510ptr%+=4
5520defectlist%=1
5530ELSE
5540IFdefectlist%=0THEN
5550defect%=Defect%!ptr%
5560defect%=defect%DIVSecSize%
5570sector%=(defect%MODSecsPerTrk%)+LowSector%
5580defect%=defect%DIVSecsPerTrk%
5590PRINTTAB(((ptr%DIV4)MOD6)*13);"(";defect%DIVHeads%;",";defect%MODHeads%;",";sector%;")";
5600ptr%=ptr%+4
5610ELSE
5620defect%=Defect%!ptr%
5630sector%=(defect%MODSecsPerTrk%)+LowSector%
5640defect%=defect%DIVSecsPerTrk%
5650PRINTTAB((((ptr%-4)DIV4)MOD6)*13);"(";defect%DIVHeads%;",";defect%MODHeads%;",";sector%;")";
5660ptr%=ptr%+4
5670ENDIF
5680ENDIF
5690ENDWHILE
5700IFBigDisc%THEN
5710Defects%=(ptr%DIV4)-1
5720ELSE
5730Defects%=ptr%DIV4
5740ENDIF
5750IFINSTR(autoreply$,"NOadddefects")=0THEN
5760PRINT:PRINT
5770PROCmessage_print_0("DefectNoMore")
5780PROCmessage_print_0("DefectAdd")
5790IFNewMap%THEN
5800PROCmessage_print_0("DefectAddDisc")
5810ELSE
5820PROCmessage_print_0("DefectAddLogical")
5830ENDIF
5840PROCmessage_print_0("DefectRemove")
5850ENDIF
5860opt$=FNChoose("Q07:","ABCDChoose","ABCD","")
5870PRINT
5880CASEopt$OF
5890WHEN"B","D"
5900cyl%=FNInputDec("CylinderDec",0,Cyls%-1)
5910head%=FNInputDec("HeadDec",0,Heads%-1)
5920IFIDE%THEN
5930sector%=FNInputDec("SectorDec",1,SecsPerTrk%)
5940ELSE
5950sector%=FNInputDec("IndexMFMDec",1-SecsPerTrk%,&10000)
5960IFsector%>=0THEN
5970sector%=sector%DIV320
5980ELSE
5990sector%=-sector%
6000ENDIF
6010ENDIF
6020defect%=((cyl%*Heads%+head%)*SecsPerTrk%+(sector%-LowSector%))
6030IFopt$="B"THEN
6040PROCAddPhysDefect(defect%)
6050ELSE
6060PROCRemovePhysDefect(defect%)
6070ENDIF
6080WHEN"C"
6090IFNewMap%THEN
6100PROCAddPhysDefect((FNInputHex2("DiscAddrHex")))
6110ELSE
6120PROCmessage_print_0("DFormatDefect1")
6130PROCmessage_print_0("DFormatDefect2")
6140PROCmessage_print_0("DFormatDefect3")
6150defect%=(FNInputHex("LogicalAddrHex")DIVSecSize%)
6160PROCAddPhysDefect(FNLogToPhys(defect%))
6170ENDIF
6180ENDCASE
6190UNTILLEFT$(opt$,1)="A"
6200FORI%=0TODiscStruc%-4STEP4
6210BootRec%!I%=DiscRec%!I%
6220NEXTI%
6230PROCInitHardDesc
6240ENDPROC
6260DEFPROCFormat
6270TIME=0
6280LOCALI%,J%,cyl%,head%
6290PROCMoanOp(Specify%,0,0,0)
6300PROCMoanOp(Restore%,0,0,0)
6320PROCmessage_print_0("Formatting")
6330IFIDE%THEN
6340FORI%=0TO512-4STEP4:Buf%!I%=0:NEXT
6350FORI%=0TOSecsPerTrk%-1
6360Buf%?(2*I%+0)=&00
6370Buf%?(2*I%+1)=I%+1
6380NEXT
6390ELSE
6400FORI%=0TO512-4STEP4:Buf%!I%=&077F03FF:NEXT
6410ENDIF
6420FORcyl%=0TOCyls%-1
6430VDU13:PRINTcyl%;
6440FORhead%=0TOHeads%-1
6450IFcyl%<>0ORhead%<>0ORNOTFormatted%THEN
6460IFNOTIDE%THEN
6470J%=cyl%OR(head%<<24)
6480FORI%=0TO(SecsPerTrk%-1)*4STEP4:Buf%!I%=J%OR(I%<<14):NEXT
6490ENDIF
6510PROCOp(WriteTrack%,(cyl%*Heads%+head%)*SecsPerTrk%,Buf%,512)
6520IFResult%PROCmessage_print_0("FormatError")
6530ENDIF
6540NEXT
6550NEXT
6560ENDPROC
6580DEFPROCVerify
6590IFSoakFlag%PROCmessage_print_0("SoakPrompt")
6600LOCALadd%,ptr%,sector%,head%,cyl%,defectlist%
6610Cycle%=1:ErrorCycle%=-100
6620CylSize%=SecsPerTrk%*Heads%
6630suspects%=0:MaxSuspects%=1000
6640DIMCylBuf%CylSize%+4,SusAdd%(MaxSuspects%),SusCount%MaxSuspects%
6650VDU13:PROCmessage_print_0("Verifying")
6660REPEAT
6670IFCycle%>1THEN
6680I%=Cycle%MODPatterns%
6690IFI%>1THEN
6700J%=Pattern%(I%)
6710J%=(J%>>>1)OR((J%AND 1)<<23)
6720Pattern%(I%)=J%
6730ELSE
6740J%=RND(&1000000)-1
6750ENDIF
6760IFNOTSoakFlag%THEN
6770VDU13
6780PROCmessage_print_1("Pattern",STR$~(J%))
6790ENDIF
6800FORI%=CylBuf%TOCylBuf%+CylSize%STEP3:!I%=J%:NEXT
6810ptr%=0
6820defectlist%=0
6830IFBigADFS%THEN
6840IFFormatted%add%=SecsPerTrk%ELSEadd%=0
6850ELSE
6860IFFormatted%add%=SecSize%*SecsPerTrk%ELSEadd%=0
6870ENDIF
6880REPEAT
6890IFDefect%!ptr%>EndDefect%AND Defect%!ptr%<EndDefect2%AND BigADFS%AND BigDisc%AND defectlist%=0THEN
6900ptr%+=4
6910defectlist%=1
6920ENDIF
6940CylEnd%=add%-(add%MODCylSize%)+CylSize%
6960IF(defectlist%=1)THEN
6980defect%=Defect%!ptr%
6990ELSE
7010defect%=(Defect%!ptr%)DIVSecSize%
7020ENDIF
7040IFdefect%>CylEnd%ORdefect%<add%THEN
7050length%=(CylEnd%-add%)*SecSize%
7060ELSE
7070length%=(defect%-add%)*SecSize%
7080ENDIF
7100PROCOp(Write%,add%,0,length%)
7120IFResult%THEN
7130IFBigADFS%THEN
7140add%=(ErrDiscAdd%AND&1FFFFFFF)+1
7150ELSE
7160add%=((ErrDiscAdd%AND&1FFFFF00)DIVSecSize%)+1
7170ENDIF
7180ELSE
7190add%+=length%
7200ENDIF
7210IFadd%=defect%THENadd%+=1:ptr%+=4
7220UNTILadd%>=SectorsPerDisc%
7230ENDIF
7240IFSoakFlag%PRINT".";
7270add%=0
7280ptr%=0
7290defectlist%=0
7300PROCMoanOp(Restore%,0,0,0)
7310REPEAT
7320IFdefectlist%=0THEN
7330REPEAT
7340IF(Defect%!ptr%AND&E0000000)<>EndDefect%THEN
7350IF((Defect%!ptr%)DIVSecSize%)<add%THEN
7360ptr%+=4
7370ENDIF
7380ELSE
7390IFBigDisc%THEN
7400defectlist%=1
7410ptr%+=4
7420ENDIF
7430ENDIF
7440UNTILdefectlist%=1OR((Defect%!ptr%)DIVSecSize%)>=add%
7450ENDIF
7460IFdefectlist%=1THEN
7470WHILEDefect%!ptr%<add%
7480ptr%+=4
7490ENDWHILE
7500ENDIF
7510IFdefectlist%=0THEN
7520defect%=(Defect%!ptr%)DIVSecSize%
7530ELSE
7540defect%=Defect%!ptr%
7550ENDIF
7570IFdefect%>SectorsPerDisc%THEN
7580length%=SectorsPerDisc%-add%
7590ELSE
7600length%=defect%-add%
7610ENDIF
7630PROCOp(Verify%,add%,0,length%*SecSize%)
7650IFResult%THEN
7660IFBigADFS%THEN
7670add%=ErrDiscAdd%AND&1FFFFFFF
7680ELSE
7690add%=(ErrDiscAdd%AND&1FFFFF00)DIVSecSize%
7700ENDIF
7710Try%=0
7720REPEAT
7730Try%+=1
7740PROCMoanOp(Restore%,0,0,0)
7750PROCOp(Verify%,add%,0,SecSize%)
7770UNTILResult%=0ORTry%=5
7780IFResult%Try%+=1
7790sector%=add%
7800head%=sector%DIVSecsPerTrk%
7810sector%=sector%MODSecsPerTrk%
7820cyl%=head%DIVHeads%
7830head%=head%MODHeads%
7840PROCmessage_print_3("VerifyData",STR$(cyl%),STR$(head%),STR$(sector%+LowSector%))
7850sus%=0
7860WHILEsus%<suspects%AND SusAdd%(sus%)<>add%:sus%+=1:ENDWHILE
7870IFsus%=suspects%THEN
7880IFsuspects%=MaxSuspects%THEN
7890sus%=RND(MaxSuspects%)-1
7900ELSE
7910suspects%+=1
7920ENDIF
7930SusAdd%(sus%)=add%
7940SusCount%?sus%=0
7950ENDIF
7960score%=2^(Try%-1)-1
7970IFNOTSoakFlag%score%=score%*4
7980SusCount%?sus%+=score%
7990IF(SusCount%?sus%>30)ORdev%THEN
8000IFSoakFlag%THEN
8010PROCmessage_print_1("DefectTIME",TIME$)
8020ELSE
8030PROCmessage_print_0("Defect")
8040ENDIF
8050PROCAddPhysDefect(add%)
8060ErrorCycle%=Cycle%
8070ELSE
8080IFSoakFlag%THEN
8090TIME=0:REPEATUNTILTIME>500:VDU13:PRINTSPC(78);:VDU13
8100ELSE
8110PROCmessage_print_1("Retries",STR$(Try%))
8120ENDIF
8130ENDIF
8140add%=add%+1
8150ELSE
8160add%=add%+length%+1
8170ENDIF
8180IFadd%>defect%THEN
8190ptr%+=4
8200ENDIF
8210UNTILadd%>=SectorsPerDisc%
8220IFSoakFlag%THEN
8230REPEAT
8240Key%=INKEY(0)
8250UNTILKey%=-1ORKey%=32
8260done%=(Key%=32)
8270ELSE
8280done%=Cycle%>ErrorCycle%+2
8290ENDIF
8300Cycle%+=1
8310IFSoakFlag%VDU&2E
8320UNTILdone%
8330ENDPROC
8360DEFPROCStructure
8370IFNewMap%THEN
8380PROCNewStructure
8390ELSE
8400PROCOldStructure
8410ENDIF
8420ENDPROC
8450DEFPROCOldStructure
8460PROCWriteDefectList
8470PROCWriteOldFsMap
8480PROCWriteRootDir
8490ENDPROC
8520DEFFNRoundUpShare(Secs%)
8530IFLog2ShareSize%=0THEN=Secs%
8540=((Secs%+ShareSize%-1)DIVShareSize%)*ShareSize%
8580DEFFNMapBits(Secs%,Lg%,Lg2SecSize%)
8590LOCALShift%
8600Shift%=Lg2SecSize%-Lg%
8610IF(Shift%>0)THEN
8620=Secs%<<Shift%
8630ELSE
8640=Secs%>>(-Shift%)
8650ENDIF
8670DEFFNRoundSectors(Bits%,Lg%,Lg2SecSize%)
8680LOCALShift%
8690Shift%=Lg2SecSize%-Lg%
8700IF(Shift%>0)THEN
8710=Bits%>>(Shift%)
8720ELSE
8730=Bits%<<(-Shift%)
8740ENDIF
8760DEFFNdoalloc(Verbose%)
8770Log2Alloc%=Log%
8780PROCShareSize
8790MapBits%=FNMapBits(SectorsPerDisc%,Log2Alloc%,Log2SecSize%)
8800RoundSectors%=FNRoundSectors(MapBits%,Log2Alloc%,Log2SecSize%)
8810BestZones%=1<<30
8820BestCylOff%=1<<30
8830FORDummySpare%=1TO1
8840FORSpareBits%=4*8TOZoneBits%-Zone0Bits%-8*8
8850PROCCalcZones
8860LinkBits%=10
8870REPEATLinkBits%+=1
8880PROCCalcIds
8890UNTILIds%<=2^LinkBits%AND LinkBits%>=(Log2SecSize%+3)
8900IFSpareBits%-4*8>0AND SpareBits%-4*8<=LinkBits%NEXTSpareBits%
8910IFOddBits%>0AND OddBits%<=LinkBits%NEXTSpareBits%
8920IFLinkBits%>15ORZones%>127THEN
8930IFVerbose%THENPROCmessage_print_0("TooSmallAlloc")
8940Log2Alloc%+=1
8950NEXTDummySpare%
8960=FALSE
8970ENDIF
8980IFZones%<=BestZones%THEN
8990Crucial%=FNRoundUpShare(Zones%*2)*SecSize%+DirSize%
9000IFMapZone%=0 Crucial%=BootAdd%*SecSize%+BootSize%
9010IFCrucial%<Alloc%*(LinkBits%+1)Crucial%=Alloc%*(LinkBits%+1)
9020CrucialEnd%=MapAdd%+Crucial%/SecSize%
9030defectlist%=0
9040DefPtr%=Defect%
9050REPEAT
9060defect%=!DefPtr%
9070DefPtr%+=4
9080IFdefect%>=EndDefect%AND defectlist%=0AND BigDisc%THEN
9090defect%=!DefPtr%
9100DefPtr%+=4
9110defectlist%=1
9120ENDIF
9130IFdefectlist%=0AND defect%<EndDefect%THENdefect%=defect%/SecSize%
9140UNTILdefect%>=EndDefect%OR(defect%>=MapAdd%AND defect%<CrucialEnd%)
9150CylOff%=MapAdd%MOD(SecsPerTrk%*Heads%)
9160IFdefect%>=EndDefect%AND CylOff%<BestCylOff%THEN
9170BestCylOff%=CylOff%
9180BestLinkBits%=LinkBits%
9190BestSpare%=SpareBits%
9200BestZones%=Zones%
9210ENDIF
9220IFBestCylOff%NEXTSpareBits%
9230NEXTDummySpare%
9240ELSE
9250NEXTDummySpare%
9260ENDIF
9270IFBestZones%=(1<<30)AND Verbose%=TRUETHENPROCmessage_print_0("InvalidAllocSize"):=FALSE
9280=TRUE
9300DEFPROCNewStructure
9310Zone0Bits%=60*8
9320ZoneBits%=SecSize%*8
9330Log2Alloc%=9
9340PROCShareSize
9350IFLog2Alloc%<8THENLog2Alloc%=10:PROCShareSize
9380Alloc%=2^Log2Alloc%:Log%=Log2Alloc%
9390WHILEFNdoalloc(FALSE)=FALSE
9400Alloc%=2^Log2Alloc%:Log%=Log2Alloc%
9410ENDWHILE
9430PRINT
9440REPEAT
9450Alloc%=FNAsk("AllocUnitAsk",2^Log2Alloc%,256)
9460Log%=7
9470REPEAT
9480Log%+=1
9490UNTILAlloc%=2^Log%
9510UNTILFNdoalloc(TRUE)
9530PRINT
9540LinkBits%=BestLinkBits%
9550SpareBits%=BestSpare%
9560PROCCalcZones
9570PROCCalcIds
9580Crucial%=FNRoundUpShare(Zones%*2)*SecSize%+DirSize%
9590IFMapZone%=0 Crucial%=BootAdd%*SecSize%+BootSize%
9600IFCrucial%<Alloc%*(LinkBits%+1)Crucial%=Alloc%*(LinkBits%+1)
9610IFCrucial%MODAlloc%<>0 Crucial%+=Alloc%-Crucial%MODAlloc%
9620IFMapZone%=0THEN
9630RootDirAdd%=BootAdd%+BootSize%/SecSize%
9640IndRootDirAdd%=&200+(BootAdd%*SecSize%+BootSize%)DIVSecSize%+1
9650ELSE
9660RootDirAdd%=MapAdd%+FNRoundUpShare((MapLen%*2)/SecSize%)
9670IndRootDirAdd%=&200+FNRoundUpShare(Zones%*2)/ShareSize%+1
9680ENDIF
9690DiscRec%?4=LinkBits%
9700DiscRec%?5=Log2Alloc%
9710IFBootOpt$="Y"THENDiscRec%!7=2ELSEDiscRec%!7=0
9720DiscRec%?8=LowSector%
9730DiscRec%?9=Zones%
9740DiscRec%?&A=SpareBits%MOD256
9750DiscRec%?&B=SpareBits%DIV256
9760DiscRec%!&C=IndRootDirAdd%
9770DiscRec%?&28=Log2ShareSize%
9780BootRec%!4=DiscRec%!4
9790BootRec%!8=DiscRec%!8
9800BootRec%!&C=DiscRec%!&C
9810BootRec%!&24=DiscRec%!&24
9820BootRec%!&28=DiscRec%!&28
9830FORI%=0TOZones%*SecSize%-4STEP4
9840Buf%!I%=0
9850NEXTI%
9860FORI%=0TO60-4STEP4
9870Buf%!(I%+4)=DiscRec%!I%
9880NEXTI%
9890PROCWriteDefectList
9900PROCmessage_print_0("CreatingMap")
9910ptr%=0
9920DefectStart%=0
9930defectlist%=0
9940DiscEndBit%=FNDiscToMap(SectorsPerDisc%)
9950ZoneStart%=Buf%
9960ZoneStartBit%=0
9970BootStartBit%=0
9980BootEndBit%=0
9990MapStartBit%=0
10000MapEndBit%=0
10010FORzone%=0TOZones%-1
10020!ZoneStart%=1<<(15+FreeLink%*8)
10030ZoneEndBit%=ZoneStartBit%+ZoneBits%
10040UsedZoneEndBit%=ZoneEndBit%-SpareBits%+4*8
10050IFUsedZoneEndBit%>DiscEndBit%THEN
10060UsedZoneEndBit%=DiscEndBit%
10070ENDIF
10080PreFree%=ZoneStartBit%+FreeLink%*8
10090ZoneBit%=ZoneStartBit%+4*8
10100IFzone%=0THEN
10110BootStartBit%=ZoneBit%
10120ZoneBit%=ZoneBit%+Zone0Bits%
10130length%=(BootAdd%*SecSize%+BootSize%)DIVAlloc%
10140IFlength%<LinkBits%+1 length%=LinkBits%+1
10150PROCWriteLink(ZoneBit%,2)
10160PROCWriteLength(ZoneBit%,length%)
10170ZoneBit%=ZoneBit%+length%
10180BootEndBit%=ZoneBit%
10190ELSE
10200IFzone%=MapZone%THEN
10210MapStartBit%=ZoneBit%
10220length%=Crucial%DIVAlloc%
10230PROCWriteLink(ZoneBit%,2)
10240PROCWriteLength(ZoneBit%,length%)
10250ZoneBit%=ZoneBit%+length%
10260MapEndBit%=ZoneBit%
10270ENDIF
10280ENDIF
10290REPEAT
10310IFZoneBit%>DefectStart%THEN
10320IFdefectlist%=0THEN
10330IFDefect%!ptr%>=EndDefect%AND BigDisc%THEN
10340ptr%+=4
10350defectlist%=1
10360DefectStart%=FNDiscToMap(Defect%!ptr%)
10370ELSE
10380DefectStart%=FNDiscToMap((Defect%!ptr%)/SecSize%)
10390ENDIF
10400ELSE
10410DefectStart%=FNDiscToMap(Defect%!ptr%)
10420ENDIF
10430WHILE((zone%=0AND(DefectStart%>=BootStartBit%AND DefectStart%<BootEndBit%)))OR((zone%=MapZone%AND(DefectStart%>=MapStartBit%AND DefectStart%<MapEndBit%)))
10440IFdefectlist%=0THEN
10450defectaddr$=FNhexaddr((Defect%!ptr%)/SecSize%)
10460ELSE
10470defectaddr$=FNhexaddr(Defect%!ptr%)
10480ENDIF
10490IFzone%=0THEN
10500PROCmessage_print_1("BootDefectError",defectaddr$)
10510ELSE
10520PROCmessage_print_1("MapDefectError",defectaddr$)
10530ENDIF
10540ptr%+=4
10550IFdefectlist%=0THEN
10560IFDefect%!ptr%>=EndDefect%THEN
10570ptr%+=4
10580defectlist%=1
10590DefectStart%=FNDiscToMap(Defect%!ptr%)
10600ELSE
10610DefectStart%=FNDiscToMap((Defect%!ptr%)/SecSize%)
10620ENDIF
10630ELSE
10640DefectStart%=FNDiscToMap(Defect%!ptr%)
10650ENDIF
10660ENDWHILE
10670IFDefectStart%>=UsedZoneEndBit%THEN
10680DefectStart%=ZoneEndBit%
10690ELSE
10700DefectEnd%=DefectStart%+1
10710ptr%+=4
10720REPEAT
10730done1%=TRUE
10740REPEAT
10750done2%=TRUE
10760IFdefectlist%=1THEN
10770NextDefect%=FNDiscToMap(Defect%!ptr%)
10780ELSE
10790NextDefect%=FNDiscToMap((Defect%!ptr%)/SecSize%)
10800ENDIF
10810IFNextDefect%<UsedZoneEndBit%THEN
10820IFNextDefect%>ZoneEndBit%-(LinkBits%+1)THEN
10830NextDef%=ZoneEndBit%-(LinkBits%+1)
10840ELSE
10850NextDef%=NextDefect%
10860ENDIF
10870IFNextDef%-DefectEnd%<LinkBits%+1THEN
10880IFNextDefect%+1>DefectEnd%THEN
10890DefectEnd%=NextDefect%+1
10900ENDIF
10910ptr%+=4
10920done2%=FALSE
10930ENDIF
10940ENDIF
10950UNTILdone2%
10960IFDefectEnd%-DefectStart%<LinkBits%+1THEN
10970DefectEnd%=DefectStart%+LinkBits%+1
10980IFDefectEnd%>ZoneEndBit%THEN
10990DefectEnd%=ZoneEndBit%
11000ENDIF
11010done1%=FALSE
11020ENDIF
11030IFDefectEnd%>ZoneEndBit%-(LinkBits%+1)AND DefectEnd%<>ZoneEndBit%THEN
11040DefectEnd%=ZoneEndBit%
11050done1%=FALSE
11060ENDIF
11070IFDefectEnd%-DefectStart%<LinkBits%+1THEN
11080DefectStart%=DefectEnd%-(LinkBits%+1)
11090ENDIF
11100UNTILdone1%
11110ENDIF
11120ENDIF
11130IFZoneBit%>DefectStart%PROCmessage_print_0("ERROR1"):PROCfinish
11140IFDefectStart%-ZoneBit%<=LinkBits%THENDefectStart%=ZoneBit%
11150IFDefectStart%>ZoneBit%THEN
11160PROCWriteLink(PreFree%,ZoneBit%-PreFree%)
11170IFDefectStart%>=UsedZoneEndBit%THEN
11180PROCWriteLength(ZoneBit%,UsedZoneEndBit%-ZoneBit%)
11190IFZoneEndBit%>UsedZoneEndBit%THEN
11200PROCWriteLink(UsedZoneEndBit%,1)
11210PROCWriteLength(UsedZoneEndBit%,ZoneEndBit%-UsedZoneEndBit%)
11220ENDIF
11230ELSE
11240PROCWriteLength(ZoneBit%,DefectStart%-ZoneBit%)
11250ENDIF
11260PreFree%=ZoneBit%
11270ENDIF
11280IFDefectStart%<ZoneEndBit%THEN
11290IFDefectEnd%>UsedZoneEndBit%-(LinkBits%+1)THEN
11300DefectEnd%=ZoneEndBit%
11310ENDIF
11320PROCWriteLink(DefectStart%,1)
11330PROCWriteLength(DefectStart%,DefectEnd%-DefectStart%)
11340ZoneBit%=DefectEnd%
11350ELSE
11360ZoneBit%=ZoneEndBit%
11370ENDIF
11380UNTILZoneBit%=ZoneEndBit%
11390PROCWriteLink(PreFree%,0)
11400IFzone%=0THEN
11410ZoneStart%?CrossCheck%=&FF
11420ELSE
11430ZoneStart%?CrossCheck%=0
11440ENDIF
11450?ZoneStart%=FNNewMapCheck(ZoneStart%,SecSize%)
11460ZoneStart%=ZoneStart%+SecSize%
11470ZoneStartBit%=ZoneEndBit%
11480NEXTzone%
11490PROCmessage_print_0("WritingMap")
11500PROCMoanOp(Write%,MapAdd%,Buf%,MapLen%)
11510PROCMoanOp(Write%,MapAdd%+MapLen%/SecSize%,Buf%,MapLen%)
11520PROCWriteRootDir
11530ENDPROC
11550DEFPROCCalcZones
11560UsedBits%=SecSize%*8-SpareBits%
11570WholeZones%=(MapBits%+Zone0Bits%)DIVUsedBits%
11580OddBits%=(MapBits%+Zone0Bits%)MODUsedBits%
11590IFOddBits%Zones%=WholeZones%+1ELSEZones%=WholeZones%
11600MapZone%=Zones%DIV2
11610IFMapZone%=0THEN
11620MapAdd%=0
11630ELSE
11640IF(Alloc%>SecSize%)THEN
11650MapAdd%=(UsedBits%*MapZone%-Zone0Bits%)*(Alloc%DIVSecSize%)
11660ELSE
11670MapAdd%=(UsedBits%*MapZone%-Zone0Bits%)DIV(SecSize%DIVAlloc%)
11680ENDIF
11690ENDIF
11700MapLen%=Zones%*SecSize%
11710ENDPROC
11730DEFPROCCalcIds
11740IdsPerZone%=UsedBits%DIV(LinkBits%+1)
11750Ids%=IdsPerZone%*WholeZones%+OddBits%DIV(LinkBits%+1)
11760ENDPROC
11810DEFFNDiscToMap(discadd%)
11820LOCALbit%,zone%
11830IF(Alloc%>SecSize%)
11840bit%=(discadd%DIV(Alloc%DIVSecSize%))+Zone0Bits%
11850ELSE
11860bit%=(discadd%*(SecSize%DIVAlloc%))+Zone0Bits%
11870ENDIF
11880zone%=bit%DIVUsedBits%
11890bit%=bit%+(bit%DIVUsedBits%)*SpareBits%+4*8
11900=bit%
11930DEFPROCWriteLink(off%,link%)
11940IFlink%>=2^LinkBits%PROCmessage_print_0("ERROR2"):PROCfinish
11950LOCALbit%,add%,mask%
11960bit%=off%MOD8
11970add%=Buf%+off%DIV8
11980mask%=2^LinkBits%-1
11990!add%=(!add%ANDNOT(mask%<<bit%))ORlink%<<bit%
12000ENDPROC
12020DEFPROCWriteLength(off%,len%)
12030IFlen%<=LinkBits%PROCmessage_print_0("ERROR3"):PROCfinish
12040off%=off%+len%-1
12050Buf%?(off%DIV8)+=2^(off%MOD8)
12060ENDPROC
12080DEFPROCWriteDefectList
12090PROCmessage_print_0("WritingDefects")
12100ptr%=0
12110check%=0
12120WHILEDefect%!ptr%<EndDefect%
12130Boot%!ptr%=Defect%!ptr%
12140PROCCheckPut(Boot%!ptr%)
12150ptr%=ptr%+4
12160ENDWHILE
12170check%=check%EOR(check%>>>16)
12180check%=(check%EOR(check%>>>8))AND&FF
12190Boot%!ptr%=EndDefect%ORcheck%
12220IFBigDisc%THEN
12230ptr%+=4
12240check%=0
12250WHILEDefect%!ptr%<EndDefect%
12260Boot%!ptr%=Defect%!ptr%
12270PROCCheckPut(Boot%!ptr%)
12280ptr%=ptr%+4
12290ENDWHILE
12300check%=check%EOR(check%>>>16)
12310check%=(check%EOR(check%>>>8))AND&FF
12320Boot%!ptr%=EndDefect2%ORcheck%
12330ENDIF
12360WHILEptr%<(MaxDefects%*4)
12370ptr%=ptr%+4
12380Boot%!ptr%=0
12390ENDWHILE
12400PROCSum(Boot%,BootSize%)
12410PROCMoanOp(Write%,BootAdd%,Boot%,BootSize%)
12420ENDPROC
12440DEFPROCWriteOldFsMap
12450PROCmessage_print_0("WritingFreeSpace")
12460LOCALs%,I%
12470s%=OldMapSize%DIV2
12480FORI%=0TOOldMapSize%-4STEP4:Buf%!I%=0:NEXT
12490!Buf%=OldLWM%DIV&100
12500Buf%!s%=(DiscSize%-OldLWM%-Defects%*SecSize%)DIV&100
12510!(Buf%+s%-4)=DiscSize%DIV&100
12520!(Buf%+OldMapSize%-5)=RND(&10000)-1
12530!(Buf%+OldMapSize%-2)=3
12540PROCSum(Buf%,s%)
12550PROCSum(Buf%+s%,s%)
12560PROCMoanOp(Write%,OldMapAdd%p,Buf%,OldMapSize%)
12570ENDPROC
12590DEFPROCWriteRootDir
12600PROCmessage_print_0("WritingRootDir")
12610LOCALBF%
12620FORI%=0TODirSize%-4STEP4:Buf%!I%=0:NEXT
12630IFNewMap%THEN
12640$DirMark%="Hugo"
12650ELSE
12660$DirMark%="Hugo"
12670ENDIF
12680Buf%!1=!DirMark%
12690BF%=Buf%+DirSize%
12700IFNewMap%THEN
12710BF%!-38=IndRootDirAdd%
12720ELSE
12730BF%!-38=IndRootDirAdd%DIV&100
12740ENDIF
12750BF%?-35=ASC"$"
12760BF%?-16=ASC"$"
12770BF%!-5=!DirMark%
12780check%=0
12790PROCCheckPut(!Buf%)
12800PROCCheckPut(Buf%?4)
12810I%=BF%-40
12820WHILEI%AND3
12830PROCCheckPut(?I%)
12840I%=I%+1
12850ENDWHILE
12860WHILEI%<BF%-4
12870PROCCheckPut(!I%)
12880I%=I%+4
12890ENDWHILE
12900check%=check%EOR(check%>>>16)
12910check%=(check%EOR(check%>>>8))AND&FF
12920BF%?-1=check%
12930PROCMoanOp(Write%,RootDirAdd%,Buf%,DirSize%)
12940ENDPROC
12960DEFFNLogToPhys(add%)
12970LOCALptr%
12980ptr%=0
12990WHILEadd%>=(Defect%!ptr%)DIVSecSize%
13000ptr%=ptr%+4
13010add%=add%+SecSize%
13020ENDWHILE
13030=add%
13090DEFPROCAddPhysDefect(add%)
13100LOCALptr%,ptr2%,defect%,defectlist%
13120IF(add%>=SectorsPerDisc%)THEN
13130PROCmessage_print_0("DefectTooBig")
13140ELSE
13150IFNOTBigDisc%THEN
13170IFDefects%<MaxDefects%THEN
13180WHILE((Defect%!ptr%)DIVSecSize%)<add%
13190ptr%=ptr%+4
13200ENDWHILE
13210defect%=(Defect%!ptr%)/SecSize%
13220IFdefect%=add%THEN
13230PROCmessage_print_0("ExistingDefect")
13240ELSE
13250ptr2%=Defects%*4
13260WHILEptr2%>=ptr%
13270Defect%!(ptr2%+4)=Defect%!ptr2%
13280ptr2%=ptr2%-4
13290ENDWHILE
13300Defect%!ptr%=add%*SecSize%
13310Defects%=Defects%+1
13320ENDIF
13330ELSE
13340PROCmessage_print_0("FullDefectList")
13350ENDIF
13360ELSE
13380IFDefects%<BigMaxDefects%THEN
13390IF((add%*SecSize%)AND&E0000000)=0AND(add%>>>(32-Log2SecSize%))=0THEN
13410defectlist%=0
13420ELSE
13440defectlist%=1
13450WHILE(Defect%!ptr%<EndDefect%)
13460ptr%+=4
13470ENDWHILE
13480ptr%+=4
13490ENDIF
13500IFdefectlist%=1THEN
13510WHILE(Defect%!ptr%)<add%
13520ptr%+=4
13530ENDWHILE
13540ELSE
13550WHILE((Defect%!ptr%)/SecSize%)<add%
13560ptr%+=4
13570ENDWHILE
13580ENDIF
13590IFdefectlist%=0THEN
13600defect%=(Defect%!ptr%)/SecSize%
13610ELSE
13620defect%=(Defect%!ptr%)
13630ENDIF
13640IFdefect%=add%THEN
13650PROCmessage_print_0("ExistingDefect")
13660ELSE
13670ptr2%=Defects%*4+4
13680WHILEptr2%>=ptr%
13690Defect%!(ptr2%+4)=Defect%!ptr2%
13700ptr2%=ptr2%-4
13710ENDWHILE
13720IFdefectlist%=0THEN
13730Defect%!ptr%=add%*SecSize%
13740ELSE
13750Defect%!ptr%=add%
13760ENDIF
13770Defects%=Defects%+1
13780ENDIF
13790ELSE
13800PROCmessage_print_0("FullDefectList")
13810ENDIF
13820ENDIF
13830ENDIF
13840ENDPROC
13870DEFPROCRemovePhysDefect(add%)
13880LOCALptr%,ptr2%,defect%,defectlist%
13890ptr%=0
13900defectlist%=1
13910WHILE((Defect%!ptr%)/SecSize%)<add%AND(Defect%!ptr%<EndDefect%)
13920ptr%=ptr%+4
13930ENDWHILE
13940IFDefect%!ptr%>=EndDefect%THEN
13950defectlist%=2
13960ptr%+=4
13970WHILE(Defect%!ptr%)<add%AND(Defect%!ptr%)<EndDefect%
13980ptr%=ptr%+4
13990ENDWHILE
14000ENDIF
14010IFdefectlist%=1THEN
14020defect%=(Defect%!ptr%)/SecSize%
14030ELSE
14040defect%=Defect%!ptr%
14050ENDIF
14060IFdefect%=add%THEN
14070IFBigDisc%THEN
14080WHILEptr%<(Defects%*4+4)
14090Defect%!ptr%=Defect%!(ptr%+4)
14100ptr%=ptr%+4
14110ENDWHILE
14120Defects%=Defects%-1
14130ELSE
14140WHILEptr%<Defects%*4
14150Defect%!ptr%=Defect%!(ptr%+4)
14160ptr%=ptr%+4
14170ENDWHILE
14180Defects%=Defects%-1
14190ENDIF
14200Defects%=Defects%-1
14210ELSE
14220PROCmessage_print_0("MissingDefect")
14230ENDIF
14240ENDPROC
14300DEFFNGoodOldDefectList
14310ptr%=-4
14320check%=0
14330last%=-1
14340good%=TRUE
14350REPEAT
14360ptr%=ptr%+4
14370defect%=Boot%!ptr%
14380IFdefect%<=last%good%=FALSE
14390last%=defect%
14400IFdefect%<EndDefect%PROCCheckPut(defect%)
14410UNTIL(defect%>=EndDefect%)ORNOTgood%
14420OldDefects%=ptr%DIV4
14430check%=check%EOR(check%>>>16)
14440check%=(check%EOR(check%>>>8))AND&FF
14450=good%AND((defect%AND&FF)=check%)
14470DEFFNGoodNewDefectList
14480ptr%=4*OldDefects%
14490check%=0
14500last%=-1
14510good%=TRUE
14520REPEAT
14530ptr%=ptr%+4
14540defect%=Boot%!ptr%
14550IFdefect%<=last%good%=FALSE
14560last%=defect%
14570IFdefect%<EndDefect2%PROCCheckPut(defect%)
14580UNTIL(defect%>=EndDefect2%)ORNOTgood%
14590NewDefects%=ptr%DIV4-OldDefects%-1
14600check%=check%EOR(check%>>>16)
14610check%=(check%EOR(check%>>>8))AND&FF
14620=good%AND((defect%AND&FF)=check%)
14650DEFFNGoodDefects
14660bothgood%=FNGoodOldDefectList
14680IF((BootRec%!&10)>=(512*1024*1024)OR(BootRec%!&26)<>0)AND bothgood%THEN
14690bothgood%=bothgood%ANDFNGoodNewDefectList
14700ENDIF
14710=bothgood%AND(FNsum(Boot%,BootSize%)=Boot%?(BootSize%-1))
14750DEFPROCInitDiscRec
14760FORI%=0TO64-4STEP4
14770DiscRec%!I%=0
14780NEXTI%
14790?DiscRec%=Log2SecSize%
14800DiscRec%?1=SecsPerTrk%
14810DiscRec%?2=Heads%
14820DiscRec%?8=LowSector%
14830DiscRec%!&C=IndRootDirAdd%
14840DiscRec%!&10=DiscSize%
14850DiscRec%!&24=DiscSize2%
14860DiscRec%?&28=Log2ShareSize%
14880IF((DiscSize%AND&E0000000)<>0OR(DiscSize2%<>0))THEN
14890DiscRec%?&29=1
14900ELSE
14910DiscRec%?&29=0
14920ENDIF
14930DiscRec%!&14=RND(&10000)-1
14950$(DiscRec%+&16)="HardDisc"+STR$Drive%
14970DiscRec%?&22=Drive%
14980ENDPROC
15040DEFPROCInitBootDefects
15050!Boot%=EndDefect%
15060Boot%!4=EndDefect2%
15110OldDefects%=0
15120NewDefects%=0
15130PROCInitHardDesc
15140ENDPROC
15170DEFPROCInitHardDesc
15180IFIDE%THEN
15190BootRec%!-&10=0
15200BootRec%!-&C=0
15210BootRec%?-5=InitFlag%
15220BootRec%?-6=LBAflag%
15230ELSE
15240BootRec%!-&10=&00000000
15250BootRec%!-&C=&0D0C200A
15280BootRec%!-8=LowCurrentCyl%OR(PreCompCyl%<<16)
15290ENDIF
15320IFBigDisc%
15330BootRec%!-4=SecsPerTrk%*Heads%*ParkCyl%
15340ELSE
15350BootRec%!-4=SecSize%*SecsPerTrk%*Heads%*ParkCyl%
15360ENDIF
15380BootRec%!-&14=&FFFFFFFF
15390ENDPROC
15420DEFFNAsk(string$,Default%,min%)
15430LOCALX,Y,reply$,value%
15440IFINSTR(autoreply$,"Defaults")AND Default%>=min%THEN
15450=Default%
15460ENDIF
15470PRINT:VDU11
15480PROCmessage_print_0(string$):X=POS:Y=VPOS
15490LOCALERROR
15500ONERRORLOCALIFERR=17PROCabort(REPORT$,1)
15510REPEAT
15520PRINTTAB(X,Y);Default%;SPC3;TAB(X,Y);
15530*FX 15,1
15540INPUT""reply$
15550IFreply$=""THEN
15560value%=Default%
15570ELSE
15580value%=EVAL(reply$)
15590ENDIF
15600UNTILvalue%>=min%
15610PRINTTAB(X,Y);value%;SPC3
15620=value%
15650DEFFNInputDec(string$,min%,max%)
15660LOCALX,Y,reply$,value%
15670PRINT:VDU11
15680PROCmessage_print_2(string$,STR$(min%),STR$(max%)):X=POS:Y=VPOS
15690LOCALERROR
15700ONERRORLOCALIFERR=17PROCabort(REPORT$,1)
15710REPEAT
15720PRINTTAB(X,Y);SPC12;TAB(X,Y);:INPUT""reply$
15730value%=EVAL(reply$)
15740UNTILvalue%>=min%AND value%<=max%
15750=value%
15780DEFFNInputHex(string$)
15790LOCALX,Y,reply$,value%
15800PRINT:VDU11
15810PROCmessage_print_0(string$):X=POS:Y=VPOS
15820LOCALERROR
15830ONERRORLOCALIFERR=17PROCabort(REPORT$,1)
15840PRINTTAB(X,Y);SPC12;TAB(X,Y);:INPUT""reply$
15850=EVAL("&"+reply$)
15870DEFFNInputHex2(string$)
15880LOCALX,Y,reply$,value%
15890PRINT:VDU11
15900PROCmessage_print_0(string$):X=POS:Y=VPOS
15930PRINTTAB(X,Y);SPC12;TAB(X,Y);:INPUT""reply$
15940=FNSectorAddr(reply$)
15970DEFFNSectorAddr(reply$)
15980LOCALadd%,add2%
15990add%=0
16000add2%=0
16020WHILEINSTR("abcdefABCDEF0123456789",LEFT$(reply$,1))<>0ANDLEN(reply$)<>0
16030add2%=(add2%<<4)+(add%>>>28)
16040add%=add%<<4
16050add%=add%+EVAL("&"+LEFT$(reply$,1))
16060reply$=MID$(reply$,2)
16070ENDWHILE
16080=(add%>>>Log2SecSize%)+(add2%<<(32-Log2SecSize%))
16120DEFFNChoose(select$,string$,opt$,default$)
16130=FNchoose_no_lookup(select$,FNmessage_lookup_0(string$),opt$,default$)
16160DEFFNchoose_no_lookup(select$,String$,english_opt$,english_default$)
16170LOCALX,Y,reply$,start,end,opt$,default$
16180opt$=FNmessage_lookup_0(english_opt$)
16190IFenglish_default$<>""THEN
16200default$=MID$(opt$,INSTR(english_opt$,english_default$),1)
16210ELSE
16220default$=""
16230ENDIF
16250IFautoreply$<>""THEN
16260start=INSTR(autoreply$,select$)
16270end=INSTR(autoreply$,",",start+1)
16280IFend=0THENend=LEN(autoreply$)+1
16290IFstart=0THEN
16300PROCmessage_print_2("FailedAuto",select$,String$)
16310PROCfinish
16320ENDIF
16330start+=LEN(select$)
16340IFstart<>endTHEN
16350IFdev%PRINTString$;" ";MID$(autoreply$,start,end-start)
16360=MID$(autoreply$,start,end-start)
16370ENDIF
16380ENDIF
16390PRINT:VDU11
16400PRINTString$;:X=POS:Y=VPOS
16410REPEAT
16420REPEAT
16430PRINTTAB(X,Y);default$;SPC12;TAB(X,Y);:INPUT""reply$
16440IFreply$=""THENreply$=default$
16450UNTILLEN(reply$)=1
16460IFINSTR(opt$,reply$)=0THENreply$=CHR$(ASC(reply$)AND&DF)
16470UNTILINSTR(opt$,reply$)
16500=MID$(english_opt$,INSTR(opt$,reply$),1)
16530DEFFNreadvarval(varname$)
16540LOCALvarlen%,varbuf%
16550DIMvarbuf%256
16560SYS"XOS_ReadVarVal",varname$,varbuf%,256,0,3TO,,varlen%
16570varbuf%?varlen%=13
16580=$varbuf%
16620DEFPROCCheckPut(I%)
16630check%=(check%>>>13)EOR((check%AND(2^13-1))<<(32-13))EOR I%
16640ENDPROC
16670DEFFNsum(base%,len%)
16680sum%=0:c%=0
16690FORI%=len%-2TO0STEP-1
16700sum%=sum%+base%?I%+c%
16710IFsum%<&100 c%=0ELSEsum%=sum%AND&FF:c%=1
16720NEXTI%
16730=sum%
16750DEFPROCSum(base%,len%)
16760base%?(len%-1)=FNsum(base%,len%)
16770ENDPROC
16790DEFFNNewMapCheck(B%,C%)=USR(NewCheck%)
16810DEFPROCAsm
16820FORopt%=0TO2STEP2
16830P%=mc%
16840[OPT opt%
16850.NewCheck%
16860MOV R0,#0
16870ADDS R2,R1,R2\C=0
16880.loop%
16890LDR R3,[R2,#-4]!
16900ADCS R0,R0,R3
16910TEQS R2,R1
16920BNE loop%
16930AND R3,R3,#&FF
16940SUB R0,R0,R3
16950EOR R0,R0,R0,LSR#16
16960EOR R0,R0,R0,LSR#8
16970AND R0,R0,#&FF
16980MOVS PC,R14
16990]
17000NEXTopt%
17010ENDPROC
17030DEFPROCDisableEscape
17040SYS"XOS_Byte",200,1,0TOR0,OldEscState%
17050SYS"XOS_Byte",247,%10101010,0TOR0,OldBreakState%
17060ENDPROC
17080DEFPROCRestoreEscape
17090SYS"XOS_Byte",200,OldEscState%,0
17100SYS"XOS_Byte",247,OldBreakState%,0
17110ENDPROC
17130DEFPROCMoanOp(b%,C%,D%,E%)
17140IFBigADFS%THEN
17150SYSAdfsSwi%,0,b%ORAltDefectBit%OR(DiscRec%<<6),C%ORDrive%<<29,D%,E%
17160ELSE
17170SYSAdfsSwi%,0,b%ORAltDefectBit%OR(DiscRec%<<6),(C%*SecSize%)ORDrive%<<29,D%,E%
17180ENDIF
17190ENDPROC
17220DEFPROCOp(b%,C%,D%,E%)
17230IFBigADFS%THEN
17240SYSAdfsSwi%OR(1<<17),0,b%ORAltDefectBit%OR(DiscRec%<<6),C%ORDrive%<<29,D%,E%TOResult%,R1%,ErrDiscAdd%
17250ELSE
17260SYSAdfsSwi%OR(1<<17),0,b%ORAltDefectBit%OR(DiscRec%<<6),(C%*SecSize%)ORDrive%<<29,D%,E%TOResult%,R1%,ErrDiscAdd%
17270ENDIF
17280IFResult%THEN
17290IFVerbose%THEN
17300PRINT"(""";
17310I%=Result%+4:WHILE?I%VDU?I%:I%+=1:ENDWHILE
17320PROCmessage_print_1("OpError",STR$~(!Result%))
17330ENDIF
17340IF!Result%AND(1<<31)THEN
17350PROCmessage_print_1("Error",STR$~(Result%AND&3FFFFFFF))
17360PROCfinish
17370ELSE
17380IF((!Result%)AND&FFFFFF)=AdfsDiscErr%THEN
17390Result%=Result%?3
17400ELSE
17410PROCmessage_print_1("Error",STR$~(!Result%)):VDU32
17420I%=4
17430WHILEResult%?I%
17440VDUResult%?I%
17450I%=I%+1
17460ENDWHILE
17470PROCfinish
17480ENDIF
17490ENDIF
17500ELSE
17510ENDIF
17520ENDPROC
17550DEFFNmatchstrings(str1$,str2$)
17560LOCALII%,JJ%,LI%,LJ%
17570II%=0:LI%=LEN(str1$)
17580JJ%=0:LJ%=LEN(str2$)
17590REPEAT
17610WHILEII%<LI%ANDASC(MID$(str1$,II%+1,1))=ASC(" "):II%+=1:ENDWHILE
17620WHILEJJ%<LJ%ANDASC(MID$(str2$,JJ%+1,1))=ASC(" "):JJ%+=1:ENDWHILE
17630IFII%<LI%AND JJ%<LJ%THEN
17640IFASC(MID$(str1$,II%+1,1))<>ASC(MID$(str2$,JJ%+1,1))THEN
17650=FALSE
17660ENDIF
17670ELSE
17680IFII%=LI%EOR JJ%=LJ%=FALSE
17690ENDIF
17700IFII%<LI%II%+=1
17710IFJJ%<LJ%JJ%+=1
17720UNTILII%=LI%AND JJ%=LJ%
17730=TRUE
17770DEFPROCabort(why$,failcode%)
17780LOCALdummy$
17790LOCALERROR
17800ONERROROFF
17820IFERR=17THEN
17830PROCmessage_print_0("UserQuit")
17840PROCfinish
17850ENDIF
17870IFmsgs_file_open%THEN
17880PROCmessage_print_2("HFormFailed",why$,STR$(ERL))
17890ELSE
17900PRINT'"HFORM failed : ";why$;" at line ";ERL
17910ENDIF
17930IFINSTR(autoreply$,"NOprompts")=0THEN
17940IFmsgs_file_open%THEN
17950PROCmessage_print_0("PressKey")
17960ELSE
17970PRINT"Press Return to continue ";
17980ENDIF
17990INPUT""dummy$
18000ENDIF
18010PROCfinish
18020ENDPROC
18060DEFPROCfinish
18070*set HForm$EndStatus 20
18080PROCexit
18090ENDPROC
18130DEFPROCexit
18140PROCclose_message_file
18150END
18160ENDPROC
18190DEFPROCrestoreparams(iface%)
18200IFiface%THEN
18210PROCrestorePROD
18220ELSE
18230PROCrestoreST506
18240ENDIF
18250ENDPROC
18280DEFPROCrestorePROD
18290RESTORE+1
18300ENDPROC
18440DATA Conner Peripherals 40MB - CP3044, TypeCP3044, 40, 4, 526, 1, 0, 525, 0
18470DATA Conner Peripherals 42MB - CP2044, TypeCP2044PK, 38, 4, 548, 1, 0, 547, 0
18480DATA Conner Peripherals 63MB - CP2064, TypeCP2064, 38, 4, 823, 1, 0, 822, 0
18490DATA Conner Peripherals 210MB - CFS210A, TypeCFS210A, 38, 16, 685, 1, 0, 684, 0
18500DATA Conner Peripherals 270MB - CFS270A, TypeCFS270A, 63, 14, 600, 1, 0, 599, 0
18510DATA Conner Peripherals 420MB - CFS420A, TypeCFS420A, 63, 16, 826, 1, 0, 825, 0
18520DATA Conner Peripherals 425MB - CFS425A, TypeCFS425A, 62, 16, 839, 1, 0, 838, 0
18530DATA Conner Peripherals 850MB - CFS850A, TypeCFS850A, 63, 16, 1651, 1, 0, 1650, 1
18550DATA OTHER, TypeOTHER, 1, 1, 1, 1, 1, 1, 1: REM Must be last, numbers irrelevant (except must be non zero).
18570DEFPROCrestoreST506
18580RESTORE+1
18590ENDPROC
18630DATA 20Mb Miniscribe 8425, Type8425, 32, 4, 615, &3FF, 128, 663
18640DATA 53Mb Rodime RO3065, TypeRO3065, 32, 7, 872, &3FF, 650, 871
18650DATA 20Mb Kalok KL320, TypeKL320, 32, 4, 615, 615, 300, 615
18670DATA OTHER, TypeOTHER, 32, 4, 612, &3FF, 128, 611:REM MUST BE LAST
18750DEFPROCopen_message_file(filename$)
18760LOCALflags%,size%
18770SYS"MessageTrans_FileInfo",,filename$TOflags%,,size%
18780IF(flags%AND 1)THENmsgs_file_buf%=0ELSEDIMmsgs_file_buf%size%
18790SYS"OS_Module",6,,,17+LEN(filename$)TO,,msgs_file_desc%
18800$(msgs_file_desc%+16)=filename$
18810SYS"MessageTrans_OpenFile",msgs_file_desc%,msgs_file_desc%+16,msgs_file_buf%
18820msgs_file_open%=TRUE
18830msg_lookup_buf_size%=256
18840DIMmsg_lookup_buf%msg_lookup_buf_size%
18850ENDPROC
18900DEFPROCclose_message_file
18910LOCALflags%
18920LOCALERROR
18930ONERROROFF
18950IFmsgs_file_open%THEN
18960SYS"MessageTrans_CloseFile",msgs_file_desc%TO;flags%
18970msgs_file_open%=FALSE
18980IF(flags%AND 1)THENREPORT
18990ENDIF
19010IFmsgs_file_desc%THEN
19020SYS"OS_Module",7,,msgs_file_desc%TO;flags%
19030msgs_file_desc%=0
19040IF(flags%AND 1)THENREPORT
19050ENDIF
19060ENDPROC
19120DEFFNmessage_lookup_0(tag$)
19130=FNmessage_lookup_4(tag$,"","","","")
19150DEFFNmessage_lookup_1(tag$,arg1$)
19160=FNmessage_lookup_4(tag$,arg1$,"","","")
19180DEFFNmessage_lookup_2(tag$,arg1$,arg2$)
19190=FNmessage_lookup_4(tag$,arg1$,arg2$,"","")
19210DEFFNmessage_lookup_3(tag$,arg1$,arg2$,arg3$)
19220=FNmessage_lookup_4(tag$,arg1$,arg2$,arg3$,"")
19240DEFFNmessage_lookup_4(tag$,arg1$,arg2$,arg3$,arg4$)
19250LOCALlen%
19260SYS"MessageTrans_GSLookup",msgs_file_desc%,tag$,msg_lookup_buf%,msg_lookup_buf_size%,arg1$,arg2$,arg3$,arg4$TO,,,len%
19270msg_lookup_buf%?len%=13
19280=$msg_lookup_buf%
19330DEFPROCmessage_print_0(tag$)
19340PROCmessage_print_4(tag$,"","","","")
19350ENDPROC
19370DEFPROCmessage_print_1(tag$,arg1$)
19380PROCmessage_print_4(tag$,arg1$,"","","")
19390ENDPROC
19410DEFPROCmessage_print_2(tag$,arg1$,arg2$)
19420PROCmessage_print_4(tag$,arg1$,arg2$,"","")
19430ENDPROC
19450DEFPROCmessage_print_3(tag$,arg1$,arg2$,arg3$)
19460PROCmessage_print_4(tag$,arg1$,arg2$,arg3$,"")
19470ENDPROC
19490DEFPROCmessage_print_4(tag$,arg1$,arg2$,arg3$,arg4$)
19500LOCALlen%
19510SYS"MessageTrans_GSLookup",msgs_file_desc%,tag$,msg_lookup_buf%,msg_lookup_buf_size%,arg1$,arg2$,arg3$,arg4$TO,,,len%
19520SYS"OS_WriteN",msg_lookup_buf%,len%
19530ENDPROC
19590DEFFNBigADFS
19600LOCALMisc_InfoPtr%
19610LOCALERROR
19620ONERRORLOCAL:RESTOREERROR:=FALSE
19630SYS"ADFS_MiscOp",6TOMisc_InfoPtr%
19640RESTOREERROR
19650=((!Misc_InfoPtr%)AND(1<<9))=(1<<9)
19670DEFPROCShareSize
19680LOCALLFAU%
19690LFAU%=LinkBits%<<Log2Alloc%
19700Log2ShareSize%=0
19710WHILE(253*(SecSize%<<Log2ShareSize%)<LFAU%)
19720Log2ShareSize%+=1
19730ENDWHILE
19740ShareSize%=1<<Log2ShareSize%
19750ENDPROC
19770DEFFNhexaddr(Sector%)
19780LOCALhigh$,low$
19790high$=STR$~(Sector%>>>(32-Log2SecSize%))
19800WHILE(LEN(high$)<8)
19810high$="0"+high$
19820ENDWHILE
19830low$=STR$~(Sector%<<(Log2SecSize%))
19840WHILE(LEN(low$)<8)
19850low$="0"+low$
19860ENDWHILE
19870=high$+low$
� > !RunImage
�*set HForm$EndStatus 1
�Log2ShareSize%=0
� ShareSize%=1<<Log2ShareSize%
�
dev%=�
�Verbose%=dev%
�msgs_file_desc%=0
�msgs_file_open%=�
���abort(�$,1)
��26:�12
� �Init
�
�GetShape
�BigADFS%�
.�(DiscSize2%<>0�(DiscSize%�&E0000000)<>0)�
"%�message_print_0("DiscSizeError")
,�finish
6�
@�
JBFormatFlag%=(�Choose("Q01:","FormatOrInitChoose","FI","")="F")
T8SoakStyle$=�Choose("Q02:","SoakTestChoose","LSN","")
^8BootOpt$=�Choose("BootOpt:","BootOptChoose","YN","")
h[�choose_no_lookup("Q03:",�message_lookup_1("SureChoose",�(Drive%)),"YN","")="N"�finish
|�DisableEscape
��MoanOp(Specify%,0,0,0)
��FormatFlag%�
��Format
��
��SoakStyle$<>"N"�
�SoakFlag%=(SoakStyle$="L")
��Verify
��
��
��Structure
��RestoreEscape
�("-ADFS-%MOUNT :"+�Drive%)
�("-ADFS-%FREE :"+�Drive%)
"�("-ADFS-%DISMOUNT :"+�Drive%)
:*set HForm$EndStatus 0
D �exit
b
��Init
l�DriveOffset%
v.�open_message_file("<HForm$Dir>.Messages")
��message_print_0("Banner")
�-autoreply$=�readvarval("Hform$Autoreply")
�%ș"XOS_Module",18,"ADFS"�,,,A%;F%
�+�F%�1�message_print_0("NoADFS"):�finish
�
A%+=A%!20
�)ȕ(?A%<>32)�(?A%<>9)�(?A%<>0):A%+=1:�
��?A%=0�finish
�#ȕ(?A%<�"0")�(?A%>�"9"):A%+=1:�
�;ADFSVersion%=((?A%-�"0")*10+(A%?2)-�"0")*10+(A%?3)-�"0"
�ș"ADFS_Drives"�,,HDiscs%
�5�HDiscs%<1�message_print_0("NoHardDiscs"):�finish
BigADFS%=�BigADFS
4&DriveOffset%=�autoreply$,"Drive=")
>�(DriveOffset%<>0)�
H)Drive%=�(�autoreply$,DriveOffset%+6))
R�
\�
fDrive%=�Ask("DriveAsk",4,4)
p�Drive%>=4� Drive%<=7
z�
��(Drive%-3)>HDiscs%�
�/�message_print_1("SillyDiscNum",�(HDiscs%))
��finish
��
��ADFSVersion%<210�
�
IDE%=�
��
�-ș"ADFS_ControllerType",Drive%�DriveType%
��DriveType%=0�
�1�message_print_1("DriveNotPresent",�(Drive%))
��finish
��
;�DriveType%=3�message_print_1("DriveIsST506",�(Drive%))
9�DriveType%=4�message_print_1("DriveIsIDE",�(Drive%))
�
$IDE%=DriveType%=4
.�
8
�IDE%�
L+ș"XADFS_ControllerType",Drive%-1�A%;F%
V.�((F%�1)=0)�(A%=4)�IDEdrive%=1�IDEdrive%=0
`�IDEid%512
j�IDEpb%7
tIDEpb%!0=0
~IDEpb%!4=0
�IDEpb%?5=&A0+(IDEdrive%<<4)
�IDEpb%?6=&EC
�:ș"ADFS_IDEUserOp",1<<24,,IDEpb%,IDEid%,512�r0%,,,,r4%
��r0%<>0�r4%<>0�
�+�message_print_1("DiscIdError",�~(r0%))
�%IDEcyls%=0:IDEheads%=0:IDEsecs%=0
��
�IDEcyls%=(IDEid%!2)�&FFFF
�IDEheads%=(IDEid%!6)�&FFFF
�IDEsecs%=(IDEid%!12)�&FFFF
� IDECapacity%=(IDEid%!(57*2))
�$IDEAddressSpace%=(IDEid%!(60*2))
IDEname$=""
6�(((IDEid%!98)>>9)�1)<>0�IDEHasLBA%=1�IDEHasLBA%=0
�I%=27*2�46*2�2
%A%=(IDEid%?(I%+1)):B%=(IDEid%?I%)
(�(A%<32)�(A%>=127)A%=�"."
2IDEname$+=�(A%)
<�(B%<32)�(B%>=127)B%=�"."
FIDEname$+=�(B%)
P�
ZIDEfirm$=""
d�I%=23*2�26*2�2
n%A%=(IDEid%?(I%+1)):B%=(IDEid%?I%)
x�(A%<32)�(A%>=127)A%=�"."
�IDEfirm$+=�(A%)
��(B%<32)�(B%>=127)B%=�"."
�IDEfirm$+=�(B%)
��
�B�message_print_3("IDEDescription",�(Drive%),IDEname$,IDEfirm$)
�M�message_print_3("IDEConfiguration",�(IDEcyls%),�(IDEheads%),�(IDEsecs%))
��IDEHasLBA%<>0�
�!�message_print_0("IDEHasLBA")
��
��
��
�MakeParams%=7
�VerifyRetries%=1
DefectRetries%=5
Verify%=0
Read%=1
"Write%=2
,WriteTrack%=4
6Restore%=6
@Specify%=&F
JAltDefectBit%=&10
TDiscStruc%=&14
h
�IDE%�
rLog2SecSize%=9
|LowSector%=1
��
�Log2SecSize%=8
�LowSector%=0
��
�SecSize%=2^Log2SecSize%
�OldMapAdd%=0
�OldMapSize%=&200
�DirSize%=&800
�BootAdd%=&C00/SecSize%
�BootSize%=&200
N(MaxDefects%=(BootSize%-64-&10-4-4)�4
� BigMaxDefects%=MaxDefects%-1
�EndDefect%=1<<29
�EndDefect2%=1<<30
�OldLWM%=&E00
�FreeLink%=1
�CrossCheck%=3
�BigADFS%�
AdfsSwi%=&4024D
�
*AdfsSwi%=&40240
4�
HAdfsDiscErr%=&108C7
RMaxVerifyBad%=16
\Patterns%=8
fp�Buf%&40000,DiscRec%64+BootSize%,Defect%BootSize%,DirMark%5,Bad%(MaxVerifyBad%),mc%100,Pattern%(Patterns%-1)
pBoot%=DiscRec%+64
zBootRec%=Boot%+BootSize%-64
�Pattern%(2)=&FFFFFF
�Pattern%(3)=&6DB6DB
Pattern%(4)=0
Pattern%(5)=&2CB2CB
Pattern%(6)=&5A5A5A
$Pattern%(7)=&4D34D3
..SecsPerTrk%=32:Heads%=1:Cyls%=1:ParkCyl%=1
8
�IDE%�
BInitFlag%=0
LLBAflag%=0
V�
`"LowCurrentCyl%=1:PreCompCyl%=1
j�
~
�BigADFS%
�RootDirAdd%=&400/512
��
�RootDirAdd%=&400
��
�Log2Alloc%=10:LinkBits%=10
��ShareSize
�IndRootDirAdd%=RootDirAdd%
�IDEHasLBA%�
$SectorsPerDisc%=IDEAddressSpace%
�
SectorsPerDisc%=IDECapacity%
(�
2HDiscSize%=(SectorsPerDisc%�((1<<(32-Log2SecSize%))-1))<<Log2SecSize%
<3DiscSize2%=(SectorsPerDisc%>>(32-Log2SecSize%))
P2�(DiscSize%>=(512*1024*1024))�(DiscSize2%<>0)�
ZBigDisc%=�
d�
nBigDisc%=�
x�
�*ș"ADFS_Retries",&ff,0�,,adfs_retries%
��
�5��::ș"ADFS_Retries",&ff,adfs_retries%:�Asm:�
�"�("-ADFS-%DISMOUNT :"+�Drive%)
�
�&ș"ADFS_Retries",&ff,adfs_retries%
��Asm
��
���GetShape
Formatted%=�
�InitBootDefects
�InitDiscRec
"*ș"ADFS_Retries",&ff,0�,,adfs_retries%
,�MoanOp(Restore%,0,0,0)
6'�Op(Read%,BootAdd%,Boot%,BootSize%)
@&È™"ADFS_Retries",&ff,adfs_retries%
J�Result%<>0���GoodDefects�
T%�message_print_0("NoValidFormat")
^�
h
�OldShape
r)�Op(Verify%,0,0,SecSize%*SecsPerTrk%)
|�ConfirmMake�Formatted%=�
��
��Formatted%�
�
�IDE%�
�笤CompareMake�
�L�autoreply$,"NOunknown")�abort(�message_lookup_0("UnknownDriveType"),1)
��AskMake
��
��
��AskMake
��
�I%=0�BootSize%-4
Boot%!I%=0
�I%
&�InitBootDefects
0�
D2�AskShape((�Formatted%)� EnglishMake$="OTHER")
N-�message_print_1("WillFormat",TransMake$)
X�printshape(IDE%)
b�
l�
���OldShape
�SecsPerTrk%=BootRec%?1
�Heads%=BootRec%?2
�Log2Alloc%=BootRec%?5
�DiscSize%=BootRec%!&10
�DiscSize2%=BootRec%!&24
�2�(DiscSize%>=(512*1024*1024))�(DiscSize2%<>0)�
�BigDisc%=�
��
�BigDisc%=�
��
MSectorsPerDisc%=(DiscSize%>>Log2SecSize%)+(DiscSize2%<<(32-Log2SecSize%))
.Cyls%=SectorsPerDisc%�(SecsPerTrk%*Heads%)
*
�IDE%�
4InitFlag%=(BootRec%?-5)
>LBAflag%=(BootRec%?-6)
H�
R%LowCurrentCyl%=(BootRec%!-8)�&3FF
\"PreCompCyl%=(BootRec%!-6)�&3FF
f�
p�BigDisc%�
z/ParkCyl%=(BootRec%!-4)�(SecsPerTrk%*Heads%)
��
�8ParkCyl%=(BootRec%!-4)�(SecSize%*SecsPerTrk%*Heads%)
��
��InitDiscRec
��
�
��AskMake
��restoreparams(IDE%)
�Makes%=0
� I%=�autoreply$,"DriveType:")
��I%<>0�
�I%+=�("DriveType:")
3Make%=�(�autoreply$,I%,�autoreply$,",",I%)-I%))
�
%�message_print_0("DriveDisclaim")
$�
.�EnglishMake$,TokenMake$
8,TransMake$=�message_lookup_0(TokenMake$)
B
Makes%+=1
L;�message_print_2("MakeMenu",�" "+�Makes%,2),TransMake$)
V�I%=1�MakeParams%
`�A$
j�I%
t�EnglishMake$="OTHER"
~�
�/Make%=�InputDec("ManufacturerDec",1,Makes%)
��restoreparams(IDE%)
��
� I%=(Make%-1)*(MakeParams%+2)
�
ȕI%>0
��A$
� I%-=1
��
�
�IDE%�
�X�EnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,InitFlag%,Dummy%,ParkCyl%,LBAflag%
��
�Y�EnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,LowCurrentCyl%,PreCompCyl%,ParkCyl%
�
,TransMake$=�message_lookup_0(TokenMake$)
�IDE%�
(*�(EnglishMake$="OTHER")�(IDEcyls%<>0)�
2SecsPerTrk%=IDEsecs%
<Heads%=IDEheads%
FCyls%=IDEcyls%
PInitFlag%=1
ZLBAFlag%=1
d�autoreply$,"LBA:On")<>0�
nLBAFlag%=1
x�
��autoreply$,"LBA:Off")<>0�
�LBAFlag%=0
��
��
�ParkCyl%=IDEcyls%-1
��
��
��
�ݤConfirmMake
�
�matched%
��restoreparams(IDE%)
�
8�EnglishMake$,TokenMake$,P1%,P2%,P3%,P4%,P5%,P6%,P7%
,TransMake$=�message_lookup_0(TokenMake$)
"�EnglishMake$="OTHER"�
,(�message_print_0("NonStandardShape")
6�printshape(IDE%)
@�
J4=�Choose("Q04:","RetainShapeChoose","YN","")="Y"
T�
^matched%=�
h
�IDE%�
rc�P1%<>SecsPerTrk%�P2%<>Heads%�P3%<>Cyls%�P4%<>InitFlag%�P6%<>ParkCyl%�P7%<>LBAflag%�:matched%=�
|�
�k�P1%<>SecsPerTrk%�P2%<>Heads%�P3%<>Cyls%�P4%<>LowCurrentCyl%�P5%<>PreCompCyl%�P6%<>ParkCyl%�:matched%=�
��
�
�matched%
�0�message_print_1("StandardShape",TransMake$)
��printshape(IDE%)
��
�1=�Choose("Q05:","UseShapeChoose","YN","")="Y"
���printshape(itype%)
�D�message_print_3("PrintShape",�(Cyls%),�(Heads%),�(SecsPerTrk%))
��itype%�
K�message_print_3("PrintShape3IDE",�(ParkCyl%),�(InitFlag%),�(LBAflag%))
�
U�message_print_3("PrintShape2ST506",�(ParkCyl%),�(LowCurrentCyl%),�(PreCompCyl%))
&�
0�
XݤCompareMake
b�restorePROD
l�
vX�EnglishMake$,TokenMake$,SecsPerTrk%,Heads%,Cyls%,InitFlag%,Dummy%,ParkCyl%,LBAflag%
�,TransMake$=�message_lookup_0(TokenMake$)
��EnglishMake$="OTHER"�
�(�message_print_0("UnknownDriveMake")
�=�
��
�)��matchstrings(EnglishMake$,IDEname$)
�6=�Choose("Q06:","StandardShapeChoose","YN","")="Y"
���AskShape(tailored%)
�%�IDE%�(�autoreply$,"NewMap")<>0)�
NewMap%=�
�
DNewMap%=(�Choose("OldOrNewMap:","OldNewMapChoose","ON","N")="N")
�
4�tailored%�
>0SecsPerTrk%=�Ask("SectorsAsk",SecsPerTrk%,1)
H
�IDE%�
R�
\'Heads%=�Ask("IDEHeadsAsk",Heads%,1)
f,�Heads%>16�message_print_0("IDEHeads16")
p�Heads%<=16
z�
�)Heads%=�Ask("ST506HeadsAsk",Heads%,1)
�,�Heads%>8�message_print_0("ST506Heads8")
��
�&Cyls%=�Ask("CylindersAsk",Cyls%,1)
�
�IDE%�
�)InitFlag%=�Ask("InitAsk",InitFlag%,0)
��IDEHasLBA%�
�LBAFlag%=1
��autoreply$,"LBA:On")<>0�
�LBAFlag%=1
��
��autoreply$,"LBA:Off")<>0�
LBAFlag%=0
�
&LBAflag%=�Ask("LBAAsk",LBAflag%,1)
$�
.�
8�
BLBAflag%=0
L�
V�
`:LowCurrentCyl%=�Ask("LowCylinderAsk",LowCurrentCyl%,0)
j8PreCompCyl%=�Ask("PrecompCylinderAsk",PreCompCyl%,0)
t�
~/ParkCyl%=�Ask("ParkCylinderAsk",ParkCyl%,0)
��
�DiscRec%?1=SecsPerTrk%
�DiscRec%?2=Heads%
�,SectorsPerDisc%=SecsPerTrk%*Heads%*Cyls%
��IDEHasLBA%�
�F�SectorsPerDisc%>IDEAddressSpace%�SectorsPerDisc%=IDEAddressSpace%
��
�>�SectorsPerDisc%>IDECapacity%�SectorsPerDisc%=IDECapacity%
��
HDiscSize%=(SectorsPerDisc%�((1<<(32-Log2SecSize%))-1))<<Log2SecSize%
3DiscSize2%=(SectorsPerDisc%>>(32-Log2SecSize%))
(2�(DiscSize%>=(512*1024*1024))�(DiscSize2%<>0)�
2BigDisc%=�
<�
FBigDisc%=�
P�
dDiscRec%!&10=DiscSize%
nDiscRec%!&24=DiscSize2%
xDiscRec%?&28=Log2ShareSize%
�0�((DiscSize%�&E0000000)<>0�(DiscSize2%<>0))�
�DiscRec%?&29=1
��
�DiscRec%?&29=0
��
��I%=0�BootSize%-4�4
�Defect%!I%=Boot%!I%
��I%
�Boot%!0=EndDefect%
��
ptr%=0
defectlist%=0
�BigDisc%�
"�Defect%!ptr%>=EndDefect%�
,C�Defect%!(ptr%+4)<EndDefect2%�message_print_0("CurrentDefects")
6�
@&�message_print_0("CurrentDefects")
J�
T�
^@�Defect%!(ptr%)<EndDefect%�message_print_0("CurrentDefects")
h�
rPȕ((Defect%!ptr%<EndDefect%)��BigDisc%)�(Defect%!ptr%<EndDefect2%� BigDisc%)
|+�((Defect%!ptr%�&E0000000)=EndDefect%)�
�ptr%+=4
�defectlist%=1
��
��defectlist%=0�
�defect%=Defect%!ptr%
�defect%=defect%�SecSize%
�,sector%=(defect%�SecsPerTrk%)+LowSector%
�defect%=defect%�SecsPerTrk%
�M�((ptr%�4)�6)*13);"(";defect%�Heads%;",";defect%�Heads%;",";sector%;")";
�ptr%=ptr%+4
��
�defect%=Defect%!ptr%
�,sector%=(defect%�SecsPerTrk%)+LowSector%
defect%=defect%�SecsPerTrk%
Q�(((ptr%-4)�4)�6)*13);"(";defect%�Heads%;",";defect%�Heads%;",";sector%;")";
ptr%=ptr%+4
&�
0�
:�
D�BigDisc%�
NDefects%=(ptr%�4)-1
X�
bDefects%=ptr%�4
l�
v#�autoreply$,"NOadddefects")=0�
��:�
�$�message_print_0("DefectNoMore")
�!�message_print_0("DefectAdd")
�
�NewMap%�
�%�message_print_0("DefectAddDisc")
��
�(�message_print_0("DefectAddLogical")
��
�$�message_print_0("DefectRemove")
��
�/opt$=�Choose("Q07:","ABCDChoose","ABCD","")
��
�Ȏopt$�
�"B","D"
+cyl%=�InputDec("CylinderDec",0,Cyls%-1)
)head%=�InputDec("HeadDec",0,Heads%-1)
�IDE%�
*0sector%=�InputDec("SectorDec",1,SecsPerTrk%)
4�
>9sector%=�InputDec("IndexMFMDec",1-SecsPerTrk%,&10000)
H�sector%>=0�
Rsector%=sector%�320
\�
fsector%=-sector%
p�
z�
�Bdefect%=((cyl%*Heads%+head%)*SecsPerTrk%+(sector%-LowSector%))
��opt$="B"�
��AddPhysDefect(defect%)
��
��RemovePhysDefect(defect%)
��
��"C"
�
�NewMap%�
�/�AddPhysDefect((�InputHex2("DiscAddrHex")))
��
�&�message_print_0("DFormatDefect1")
�&�message_print_0("DFormatDefect2")
�&�message_print_0("DFormatDefect3")
2defect%=(�InputHex("LogicalAddrHex")�SecSize%)
'�AddPhysDefect(�LogToPhys(defect%))
�
$�
.��opt$,1)="A"
8�I%=0�DiscStruc%-4�4
BBootRec%!I%=DiscRec%!I%
L�I%
V�InitHardDesc
`�
t��Format
~�=0
��I%,J%,cyl%,head%
��MoanOp(Specify%,0,0,0)
��MoanOp(Restore%,0,0,0)
�"�message_print_0("Formatting")
�
�IDE%�
��I%=0�512-4�4:Buf%!I%=0:�
��I%=0�SecsPerTrk%-1
�Buf%?(2*I%+0)=&00
�Buf%?(2*I%+1)=I%+1
��
��
%�I%=0�512-4�4:Buf%!I%=&077F03FF:�
�
�cyl%=0�Cyls%-1
�13:�cyl%;
(�head%=0�Heads%-1
2"�cyl%<>0�head%<>0��Formatted%�
<�IDE%�
FJ%=cyl%�(head%<<24)
P3�I%=0�(SecsPerTrk%-1)*4�4:Buf%!I%=J%�(I%<<14):�
Z�
n=�Op(WriteTrack%,(cyl%*Heads%+head%)*SecsPerTrk%,Buf%,512)
x+�Result%�message_print_0("FormatError")
��
��
��
��
���Verify
�,�SoakFlag%�message_print_0("SoakPrompt")
�-�add%,ptr%,sector%,head%,cyl%,defectlist%
�Cycle%=1:ErrorCycle%=-100
�CylSize%=SecsPerTrk%*Heads%
�!suspects%=0:MaxSuspects%=1000
�B�CylBuf%CylSize%+4,SusAdd%(MaxSuspects%),SusCount%MaxSuspects%
�%�13:�message_print_0("Verifying")
�
�Cycle%>1�
I%=Cycle%�Patterns%
"
�I%>1�
,J%=Pattern%(I%)
6J%=(J%>>>1)�((J%� 1)<<23)
@Pattern%(I%)=J%
J�
TJ%=�(&1000000)-1
^�
h�SoakFlag%�
r�13
|&�message_print_1("Pattern",�~(J%))
��
�+�I%=CylBuf%�CylBuf%+CylSize%�3:!I%=J%:�
�
ptr%=0
�defectlist%=0
��BigADFS%�
�&�Formatted%add%=SecsPerTrk%�add%=0
��
�/�Formatted%add%=SecSize%*SecsPerTrk%�add%=0
��
��
�Z�Defect%!ptr%>EndDefect%� Defect%!ptr%<EndDefect2%� BigADFS%� BigDisc%� defectlist%=0�
�ptr%+=4
�defectlist%=1
�
)CylEnd%=add%-(add%�CylSize%)+CylSize%
0�(defectlist%=1)�
Ddefect%=Defect%!ptr%
N�
b#defect%=(Defect%!ptr%)�SecSize%
l�
�"�defect%>CylEnd%�defect%<add%�
�#length%=(CylEnd%-add%)*SecSize%
��
�#length%=(defect%-add%)*SecSize%
��
��Op(Write%,add%,0,length%)
�
�Result%�
��BigADFS%�
�"add%=(ErrDiscAdd%�&1FFFFFFF)+1
��
�-add%=((ErrDiscAdd%�&1FFFFF00)�SecSize%)+1
�
�
add%+=length%
�
*!�add%=defect%�add%+=1:ptr%+=4
4�add%>=SectorsPerDisc%
>�
H�SoakFlag%�".";
f
add%=0
p
ptr%=0
zdefectlist%=0
��MoanOp(Restore%,0,0,0)
��
��defectlist%=0�
��
�*�(Defect%!ptr%�&E0000000)<>EndDefect%�
�$�((Defect%!ptr%)�SecSize%)<add%�
�ptr%+=4
��
��
��BigDisc%�
�defectlist%=1
�ptr%+=4
��
�
2�defectlist%=1�((Defect%!ptr%)�SecSize%)>=add%
�
$�defectlist%=1�
.ȕDefect%!ptr%<add%
8ptr%+=4
B�
L�
V�defectlist%=0�
`#defect%=(Defect%!ptr%)�SecSize%
j�
tdefect%=Defect%!ptr%
~�
��defect%>SectorsPerDisc%�
� length%=SectorsPerDisc%-add%
��
�length%=defect%-add%
��
�(�Op(Verify%,add%,0,length%*SecSize%)
�
�Result%�
��BigADFS%�
�add%=ErrDiscAdd%�&1FFFFFFF
�
)add%=(ErrDiscAdd%�&1FFFFF00)�SecSize%
�
Try%=0
(�
2Try%+=1
<�MoanOp(Restore%,0,0,0)
F �Op(Verify%,add%,0,SecSize%)
Z�Result%=0�Try%=5
d�Result%Try%+=1
nsector%=add%
xhead%=sector%�SecsPerTrk%
�sector%=sector%�SecsPerTrk%
�cyl%=head%�Heads%
�head%=head%�Heads%
�I�message_print_3("VerifyData",�(cyl%),�(head%),�(sector%+LowSector%))
�
sus%=0
�3ȕsus%<suspects%� SusAdd%(sus%)<>add%:sus%+=1:�
��sus%=suspects%�
��suspects%=MaxSuspects%�
�sus%=�(MaxSuspects%)-1
��
�suspects%+=1
��
�SusAdd%(sus%)=add%
SusCount%?sus%=0
�
score%=2^(Try%-1)-1
"�SoakFlag%score%=score%*4
,SusCount%?sus%+=score%
6�(SusCount%?sus%>30)�dev%�
@�SoakFlag%�
J%�message_print_1("DefectTIME",�$)
T�
^�message_print_0("Defect")
h�
r�AddPhysDefect(add%)
|ErrorCycle%=Cycle%
��
��SoakFlag%�
��=0:���>500:�13:�(78);:�13
��
�'�message_print_1("Retries",�(Try%))
��
��
�add%=add%+1
��
�add%=add%+length%+1
��
��add%>defect%�
�ptr%+=4
�
�add%>=SectorsPerDisc%
�SoakFlag%�
&�
0
Key%=�(0)
:�Key%=-1�Key%=32
Ddone%=(Key%=32)
N�
Xdone%=Cycle%>ErrorCycle%+2
b�
l
Cycle%+=1
v�SoakFlag%�&2E
�
�done%
��
���Structure
�
�NewMap%�
��NewStructure
��
��OldStructure
��
��
!��OldStructure
!�WriteDefectList
!�WriteOldFsMap
! �WriteRootDir
!*�
!HݤRoundUpShare(Secs%)
!R�Log2ShareSize%=0�=Secs%
!\1=((Secs%+ShareSize%-1)�ShareSize%)*ShareSize%
!�$ݤMapBits(Secs%,Lg%,Lg2SecSize%)
!��Shift%
!�Shift%=Lg2SecSize%-Lg%
!��(Shift%>0)�
!�=Secs%<<Shift%
!��
!�=Secs%>>(-Shift%)
!��
!�)ݤRoundSectors(Bits%,Lg%,Lg2SecSize%)
!��Shift%
!�Shift%=Lg2SecSize%-Lg%
!��(Shift%>0)�
"=Bits%>>(Shift%)
"�
"=Bits%<<(-Shift%)
"$�
"8ݤdoalloc(Verbose%)
"BLog2Alloc%=Log%
"L�ShareSize
"V>MapBits%=�MapBits(SectorsPerDisc%,Log2Alloc%,Log2SecSize%)
"`ARoundSectors%=�RoundSectors(MapBits%,Log2Alloc%,Log2SecSize%)
"jBestZones%=1<<30
"tBestCylOff%=1<<30
"~�DummySpare%=1�1
"�,�SpareBits%=4*8�ZoneBits%-Zone0Bits%-8*8
"��CalcZones
"�LinkBits%=10
"��LinkBits%+=1
"��CalcIds
"�3�Ids%<=2^LinkBits%� LinkBits%>=(Log2SecSize%+3)
"�;�SpareBits%-4*8>0� SpareBits%-4*8<=LinkBits%�SpareBits%
"�/�OddBits%>0� OddBits%<=LinkBits%�SpareBits%
"��LinkBits%>15�Zones%>127�
"�/�Verbose%��message_print_0("TooSmallAlloc")
"�Log2Alloc%+=1
"��DummySpare%
# =�
#
�
#�Zones%<=BestZones%�
#6Crucial%=�RoundUpShare(Zones%*2)*SecSize%+DirSize%
#(4�MapZone%=0 Crucial%=BootAdd%*SecSize%+BootSize%
#2?�Crucial%<Alloc%*(LinkBits%+1)Crucial%=Alloc%*(LinkBits%+1)
#<)CrucialEnd%=MapAdd%+Crucial%/SecSize%
#Fdefectlist%=0
#PDefPtr%=Defect%
#Z�
#ddefect%=!DefPtr%
#nDefPtr%+=4
#x2�defect%>=EndDefect%� defectlist%=0� BigDisc%�
#�defect%=!DefPtr%
#�DefPtr%+=4
#�defectlist%=1
#��
#�?�defectlist%=0� defect%<EndDefect%�defect%=defect%/SecSize%
#�@�defect%>=EndDefect%�(defect%>=MapAdd%� defect%<CrucialEnd%)
#�(CylOff%=MapAdd%�(SecsPerTrk%*Heads%)
#�.�defect%>=EndDefect%� CylOff%<BestCylOff%�
#�BestCylOff%=CylOff%
#�BestLinkBits%=LinkBits%
#�BestSpare%=SpareBits%
#�BestZones%=Zones%
#��
$�BestCylOff%�SpareBits%
$�DummySpare%
$�
$"�DummySpare%
$,�
$6K�BestZones%=(1<<30)� Verbose%=���message_print_0("InvalidAllocSize"):=�
$@=�
$T��NewStructure
$^Zone0Bits%=60*8
$hZoneBits%=SecSize%*8
$rLog2Alloc%=9
$|�ShareSize
$�*�Log2Alloc%<8�Log2Alloc%=10:�ShareSize
$�'Alloc%=2^Log2Alloc%:Log%=Log2Alloc%
$�ȕ�doalloc(�)=�
$�'Alloc%=2^Log2Alloc%:Log%=Log2Alloc%
$��
$��
$��
$�0Alloc%=�Ask("AllocUnitAsk",2^Log2Alloc%,256)
$�
Log%=7
$��
%Log%+=1
%�Alloc%=2^Log%
%&��doalloc(�)
%:�
%DLinkBits%=BestLinkBits%
%NSpareBits%=BestSpare%
%X�CalcZones
%b�CalcIds
%l6Crucial%=�RoundUpShare(Zones%*2)*SecSize%+DirSize%
%v4�MapZone%=0 Crucial%=BootAdd%*SecSize%+BootSize%
%�?�Crucial%<Alloc%*(LinkBits%+1)Crucial%=Alloc%*(LinkBits%+1)
%�8�Crucial%�Alloc%<>0 Crucial%+=Alloc%-Crucial%�Alloc%
%��MapZone%=0�
%�+RootDirAdd%=BootAdd%+BootSize%/SecSize%
%�@IndRootDirAdd%=&200+(BootAdd%*SecSize%+BootSize%)�SecSize%+1
%��
%�;RootDirAdd%=MapAdd%+�RoundUpShare((MapLen%*2)/SecSize%)
%�<IndRootDirAdd%=&200+�RoundUpShare(Zones%*2)/ShareSize%+1
%��
%�DiscRec%?4=LinkBits%
%�DiscRec%?5=Log2Alloc%
%�+�BootOpt$="Y"�DiscRec%!7=2�DiscRec%!7=0
%�DiscRec%?8=LowSector%
&DiscRec%?9=Zones%
&DiscRec%?&A=SpareBits%�256
&DiscRec%?&B=SpareBits%�256
& DiscRec%!&C=IndRootDirAdd%
&*DiscRec%?&28=Log2ShareSize%
&4BootRec%!4=DiscRec%!4
&>BootRec%!8=DiscRec%!8
&HBootRec%!&C=DiscRec%!&C
&RBootRec%!&24=DiscRec%!&24
&\BootRec%!&28=DiscRec%!&28
&f�I%=0�Zones%*SecSize%-4�4
&p
Buf%!I%=0
&z�I%
&��I%=0�60-4�4
&�Buf%!(I%+4)=DiscRec%!I%
&��I%
&��WriteDefectList
&�#�message_print_0("CreatingMap")
&�
ptr%=0
&�DefectStart%=0
&�defectlist%=0
&�+DiscEndBit%=�DiscToMap(SectorsPerDisc%)
&�ZoneStart%=Buf%
&�ZoneStartBit%=0
&�BootStartBit%=0
&�BootEndBit%=0
'MapStartBit%=0
'MapEndBit%=0
'�zone%=0�Zones%-1
'$#!ZoneStart%=1<<(15+FreeLink%*8)
'.'ZoneEndBit%=ZoneStartBit%+ZoneBits%
'8.UsedZoneEndBit%=ZoneEndBit%-SpareBits%+4*8
'B!�UsedZoneEndBit%>DiscEndBit%�
'LUsedZoneEndBit%=DiscEndBit%
'V�
'`&PreFree%=ZoneStartBit%+FreeLink%*8
'jZoneBit%=ZoneStartBit%+4*8
't
�zone%=0�
'~BootStartBit%=ZoneBit%
'� ZoneBit%=ZoneBit%+Zone0Bits%
'�0length%=(BootAdd%*SecSize%+BootSize%)�Alloc%
'�,�length%<LinkBits%+1 length%=LinkBits%+1
'��WriteLink(ZoneBit%,2)
'�"�WriteLength(ZoneBit%,length%)
'�ZoneBit%=ZoneBit%+length%
'�BootEndBit%=ZoneBit%
'��
'��zone%=MapZone%�
'�MapStartBit%=ZoneBit%
'�length%=Crucial%�Alloc%
'��WriteLink(ZoneBit%,2)
( "�WriteLength(ZoneBit%,length%)
(
ZoneBit%=ZoneBit%+length%
(MapEndBit%=ZoneBit%
(�
((�
(2�
(F�ZoneBit%>DefectStart%�
(P�defectlist%=0�
(Z(�Defect%!ptr%>=EndDefect%� BigDisc%�
(dptr%+=4
(ndefectlist%=1
(x)DefectStart%=�DiscToMap(Defect%!ptr%)
(��
(�4DefectStart%=�DiscToMap((Defect%!ptr%)/SecSize%)
(��
(��
(�)DefectStart%=�DiscToMap(Defect%!ptr%)
(��
(��ȕ((zone%=0�(DefectStart%>=BootStartBit%� DefectStart%<BootEndBit%)))�((zone%=MapZone%�(DefectStart%>=MapStartBit%� DefectStart%<MapEndBit%)))
(��defectlist%=0�
(�1defectaddr$=�hexaddr((Defect%!ptr%)/SecSize%)
(��
(�&defectaddr$=�hexaddr(Defect%!ptr%)
(��
(�
�zone%=0�
)3�message_print_1("BootDefectError",defectaddr$)
)�
)2�message_print_1("MapDefectError",defectaddr$)
)"�
),ptr%+=4
)6�defectlist%=0�
)@�Defect%!ptr%>=EndDefect%�
)Jptr%+=4
)Tdefectlist%=1
)^)DefectStart%=�DiscToMap(Defect%!ptr%)
)h�
)r4DefectStart%=�DiscToMap((Defect%!ptr%)/SecSize%)
)|�
)��
)�)DefectStart%=�DiscToMap(Defect%!ptr%)
)��
)��
)�#�DefectStart%>=UsedZoneEndBit%�
)�DefectStart%=ZoneEndBit%
)��
)�DefectEnd%=DefectStart%+1
)�ptr%+=4
)��
)�done1%=�
)��
)�done2%=�
*�defectlist%=1�
*(NextDefect%=�DiscToMap(Defect%!ptr%)
*�
*&3NextDefect%=�DiscToMap((Defect%!ptr%)/SecSize%)
*0�
*:!�NextDefect%<UsedZoneEndBit%�
*D+�NextDefect%>ZoneEndBit%-(LinkBits%+1)�
*N&NextDef%=ZoneEndBit%-(LinkBits%+1)
*X�
*bNextDef%=NextDefect%
*l�
*v%�NextDef%-DefectEnd%<LinkBits%+1�
*��NextDefect%+1>DefectEnd%�
*�DefectEnd%=NextDefect%+1
*��
*�ptr%+=4
*�done2%=�
*��
*��
*��done2%
*�)�DefectEnd%-DefectStart%<LinkBits%+1�
*�'DefectEnd%=DefectStart%+LinkBits%+1
*��DefectEnd%>ZoneEndBit%�
*�DefectEnd%=ZoneEndBit%
*��
+done1%=�
+�
+C�DefectEnd%>ZoneEndBit%-(LinkBits%+1)� DefectEnd%<>ZoneEndBit%�
+ DefectEnd%=ZoneEndBit%
+*done1%=�
+4�
+>)�DefectEnd%-DefectStart%<LinkBits%+1�
+H)DefectStart%=DefectEnd%-(LinkBits%+1)
+R�
+\�done1%
+f�
+p�
+z<�ZoneBit%>DefectStart%�message_print_0("ERROR1"):�finish
+�;�DefectStart%-ZoneBit%<=LinkBits%�DefectStart%=ZoneBit%
+��DefectStart%>ZoneBit%�
+�*�WriteLink(PreFree%,ZoneBit%-PreFree%)
+�#�DefectStart%>=UsedZoneEndBit%�
+�3�WriteLength(ZoneBit%,UsedZoneEndBit%-ZoneBit%)
+�!�ZoneEndBit%>UsedZoneEndBit%�
+�!�WriteLink(UsedZoneEndBit%,1)
+�=�WriteLength(UsedZoneEndBit%,ZoneEndBit%-UsedZoneEndBit%)
+��
+��
+�0�WriteLength(ZoneBit%,DefectStart%-ZoneBit%)
+��
+�PreFree%=ZoneBit%
,�
,�DefectStart%<ZoneEndBit%�
,.�DefectEnd%>UsedZoneEndBit%-(LinkBits%+1)�
,$DefectEnd%=ZoneEndBit%
,.�
,8�WriteLink(DefectStart%,1)
,B6�WriteLength(DefectStart%,DefectEnd%-DefectStart%)
,LZoneBit%=DefectEnd%
,V�
,`ZoneBit%=ZoneEndBit%
,j�
,t�ZoneBit%=ZoneEndBit%
,~�WriteLink(PreFree%,0)
,�
�zone%=0�
,�ZoneStart%?CrossCheck%=&FF
,��
,�ZoneStart%?CrossCheck%=0
,��
,�1?ZoneStart%=�NewMapCheck(ZoneStart%,SecSize%)
,�"ZoneStart%=ZoneStart%+SecSize%
,�ZoneStartBit%=ZoneEndBit%
,�
�zone%
,�"�message_print_0("WritingMap")
,�(�MoanOp(Write%,MapAdd%,Buf%,MapLen%)
,�9�MoanOp(Write%,MapAdd%+MapLen%/SecSize%,Buf%,MapLen%)
- �WriteRootDir
-
�
-��CalcZones
-(#UsedBits%=SecSize%*8-SpareBits%
-2/WholeZones%=(MapBits%+Zone0Bits%)�UsedBits%
-<,OddBits%=(MapBits%+Zone0Bits%)�UsedBits%
-F4�OddBits%Zones%=WholeZones%+1�Zones%=WholeZones%
-PMapZone%=Zones%�2
-Z�MapZone%=0�
-d
MapAdd%=0
-n�
-x�(Alloc%>SecSize%)�
-�=MapAdd%=(UsedBits%*MapZone%-Zone0Bits%)*(Alloc%�SecSize%)
-��
-�=MapAdd%=(UsedBits%*MapZone%-Zone0Bits%)�(SecSize%�Alloc%)
-��
-��
-�MapLen%=Zones%*SecSize%
-��
-�
��CalcIds
-�'IdsPerZone%=UsedBits%�(LinkBits%+1)
-�7Ids%=IdsPerZone%*WholeZones%+OddBits%�(LinkBits%+1)
-��
."ݤDiscToMap(discadd%)
.,�bit%,zone%
.6�(Alloc%>SecSize%)
.@0bit%=(discadd%�(Alloc%�SecSize%))+Zone0Bits%
.J�
.T0bit%=(discadd%*(SecSize%�Alloc%))+Zone0Bits%
.^�
.hzone%=bit%�UsedBits%
.r-bit%=bit%+(bit%�UsedBits%)*SpareBits%+4*8
.| =bit%
.���WriteLink(off%,link%)
.�9�link%>=2^LinkBits%�message_print_0("ERROR2"):�finish
.��bit%,add%,mask%
.�bit%=off%�8
.�add%=Buf%+off%�8
.�mask%=2^LinkBits%-1
.�,!add%=(!add%��(mask%<<bit%))�link%<<bit%
.��
.���WriteLength(off%,len%)
.�6�len%<=LinkBits%�message_print_0("ERROR3"):�finish
/off%=off%+len%-1
/Buf%?(off%�8)+=2^(off%�8)
/�
/0��WriteDefectList
/:&�message_print_0("WritingDefects")
/D
ptr%=0
/Ncheck%=0
/XȕDefect%!ptr%<EndDefect%
/bBoot%!ptr%=Defect%!ptr%
/l�CheckPut(Boot%!ptr%)
/vptr%=ptr%+4
/��
/�check%=check%�(check%>>>16)
/�$check%=(check%�(check%>>>8))�&FF
/� Boot%!ptr%=EndDefect%�check%
/��BigDisc%�
/�ptr%+=4
/�check%=0
/�ȕDefect%!ptr%<EndDefect%
/�Boot%!ptr%=Defect%!ptr%
/��CheckPut(Boot%!ptr%)
/�ptr%=ptr%+4
0�
0check%=check%�(check%>>>16)
0$check%=(check%�(check%>>>8))�&FF
0 !Boot%!ptr%=EndDefect2%�check%
0*�
0Hȕptr%<(MaxDefects%*4)
0Rptr%=ptr%+4
0\Boot%!ptr%=0
0f�
0p�Sum(Boot%,BootSize%)
0z,�MoanOp(Write%,BootAdd%,Boot%,BootSize%)
0��
0���WriteOldFsMap
0�(�message_print_0("WritingFreeSpace")
0�
�s%,I%
0�s%=OldMapSize%�2
0�%�I%=0�OldMapSize%-4�4:Buf%!I%=0:�
0�!Buf%=OldLWM%�&100
0�6Buf%!s%=(DiscSize%-OldLWM%-Defects%*SecSize%)�&100
0�!(Buf%+s%-4)=DiscSize%�&100
0�%!(Buf%+OldMapSize%-5)=�(&10000)-1
0�!(Buf%+OldMapSize%-2)=3
0��Sum(Buf%,s%)
1�Sum(Buf%+s%,s%)
10�MoanOp(Write%,OldMapAdd%p,Buf%,OldMapSize%)
1�
1.��WriteRootDir
18&�message_print_0("WritingRootDir")
1B�BF%
1L"�I%=0�DirSize%-4�4:Buf%!I%=0:�
1V
�NewMap%�
1`$DirMark%="Hugo"
1j�
1t$DirMark%="Hugo"
1~�
1�Buf%!1=!DirMark%
1�BF%=Buf%+DirSize%
1�
�NewMap%�
1�BF%!-38=IndRootDirAdd%
1��
1�BF%!-38=IndRootDirAdd%�&100
1��
1�BF%?-35=�"$"
1�BF%?-16=�"$"
1�BF%!-5=!DirMark%
1�check%=0
1��CheckPut(!Buf%)
2 �CheckPut(Buf%?4)
2
I%=BF%-40
2
ȕI%�3
2�CheckPut(?I%)
2(I%=I%+1
22�
2<ȕI%<BF%-4
2F�CheckPut(!I%)
2PI%=I%+4
2Z�
2dcheck%=check%�(check%>>>16)
2n$check%=(check%�(check%>>>8))�&FF
2xBF%?-1=check%
2�-�MoanOp(Write%,RootDirAdd%,Buf%,DirSize%)
2��
2�ݤLogToPhys(add%)
2� �ptr%
2�
ptr%=0
2�#ȕadd%>=(Defect%!ptr%)�SecSize%
2�ptr%=ptr%+4
2�add%=add%+SecSize%
2��
2� =add%
3"��AddPhysDefect(add%)
3,#�ptr%,ptr2%,defect%,defectlist%
3@�(add%>=SectorsPerDisc%)�
3J$�message_print_0("DefectTooBig")
3T�
3^�BigDisc%�
3r�Defects%<MaxDefects%�
3|$ȕ((Defect%!ptr%)�SecSize%)<add%
3�ptr%=ptr%+4
3��
3�#defect%=(Defect%!ptr%)/SecSize%
3��defect%=add%�
3�&�message_print_0("ExistingDefect")
3��
3�ptr2%=Defects%*4
3�ȕptr2%>=ptr%
3�#Defect%!(ptr2%+4)=Defect%!ptr2%
3�ptr2%=ptr2%-4
3��
3�Defect%!ptr%=add%*SecSize%
3�Defects%=Defects%+1
4�
4�
4&�message_print_0("FullDefectList")
4&�
40�
4D�Defects%<BigMaxDefects%�
4N@�((add%*SecSize%)�&E0000000)=0�(add%>>>(32-Log2SecSize%))=0�
4bdefectlist%=0
4l�
4�defectlist%=1
4�ȕ(Defect%!ptr%<EndDefect%)
4�ptr%+=4
4��
4�ptr%+=4
4��
4��defectlist%=1�
4�ȕ(Defect%!ptr%)<add%
4�ptr%+=4
4��
4��
4�$ȕ((Defect%!ptr%)/SecSize%)<add%
4�ptr%+=4
5�
5�
5�defectlist%=0�
5 #defect%=(Defect%!ptr%)/SecSize%
5*�
54defect%=(Defect%!ptr%)
5>�
5H�defect%=add%�
5R&�message_print_0("ExistingDefect")
5\�
5fptr2%=Defects%*4+4
5pȕptr2%>=ptr%
5z#Defect%!(ptr2%+4)=Defect%!ptr2%
5�ptr2%=ptr2%-4
5��
5��defectlist%=0�
5�Defect%!ptr%=add%*SecSize%
5��
5�Defect%!ptr%=add%
5��
5�Defects%=Defects%+1
5��
5��
5�&�message_print_0("FullDefectList")
5��
5��
6�
6�
6.��RemovePhysDefect(add%)
68#�ptr%,ptr2%,defect%,defectlist%
6B
ptr%=0
6Ldefectlist%=1
6V>ȕ((Defect%!ptr%)/SecSize%)<add%�(Defect%!ptr%<EndDefect%)
6`ptr%=ptr%+4
6j�
6t�Defect%!ptr%>=EndDefect%�
6~defectlist%=2
6�ptr%+=4
6�3ȕ(Defect%!ptr%)<add%�(Defect%!ptr%)<EndDefect%
6�ptr%=ptr%+4
6��
6��
6��defectlist%=1�
6�#defect%=(Defect%!ptr%)/SecSize%
6��
6�defect%=Defect%!ptr%
6��
6��defect%=add%�
6��BigDisc%�
7 ȕptr%<(Defects%*4+4)
7
!Defect%!ptr%=Defect%!(ptr%+4)
7ptr%=ptr%+4
7�
7(Defects%=Defects%-1
72�
7<ȕptr%<Defects%*4
7F!Defect%!ptr%=Defect%!(ptr%+4)
7Pptr%=ptr%+4
7Z�
7dDefects%=Defects%-1
7n�
7xDefects%=Defects%-1
7��
7�%�message_print_0("MissingDefect")
7��
7��
7�ݤGoodOldDefectList
7�ptr%=-4
7�check%=0
7�last%=-1
8good%=�
8�
8ptr%=ptr%+4
8"defect%=Boot%!ptr%
8,�defect%<=last%good%=�
86last%=defect%
8@)�defect%<EndDefect%�CheckPut(defect%)
8J!�(defect%>=EndDefect%)��good%
8TOldDefects%=ptr%�4
8^check%=check%�(check%>>>16)
8h$check%=(check%�(check%>>>8))�&FF
8r!=good%�((defect%�&FF)=check%)
8�ݤGoodNewDefectList
8�ptr%=4*OldDefects%
8�check%=0
8�last%=-1
8�good%=�
8��
8�ptr%=ptr%+4
8�defect%=Boot%!ptr%
8��defect%<=last%good%=�
8�last%=defect%
8�*�defect%<EndDefect2%�CheckPut(defect%)
8�"�(defect%>=EndDefect2%)��good%
8�$NewDefects%=ptr%�4-OldDefects%-1
9check%=check%�(check%>>>16)
9$check%=(check%�(check%>>>8))�&FF
9!=good%�((defect%�&FF)=check%)
9:ݤGoodDefects
9D bothgood%=�GoodOldDefectList
9XD�((BootRec%!&10)>=(512*1024*1024)�(BootRec%!&26)<>0)� bothgood%�
9b*bothgood%=bothgood%��GoodNewDefectList
9l�
9v:=bothgood%�(�sum(Boot%,BootSize%)=Boot%?(BootSize%-1))
9���InitDiscRec
9��I%=0�64-4�4
9�DiscRec%!I%=0
9��I%
9�?DiscRec%=Log2SecSize%
9�DiscRec%?1=SecsPerTrk%
9�DiscRec%?2=Heads%
9�DiscRec%?8=LowSector%
9�DiscRec%!&C=IndRootDirAdd%
9�DiscRec%!&10=DiscSize%
:DiscRec%!&24=DiscSize2%
:DiscRec%?&28=Log2ShareSize%
: 0�((DiscSize%�&E0000000)<>0�(DiscSize2%<>0))�
:*DiscRec%?&29=1
:4�
:>DiscRec%?&29=0
:H�
:RDiscRec%!&14=�(&10000)-1
:f&$(DiscRec%+&16)="HardDisc"+�Drive%
:zDiscRec%?&22=Drive%
:��
:���InitBootDefects
:�!Boot%=EndDefect%
:�Boot%!4=EndDefect2%
;OldDefects%=0
;NewDefects%=0
;�InitHardDesc
;$�
;B��InitHardDesc
;L
�IDE%�
;VBootRec%!-&10=0
;`BootRec%!-&C=0
;jBootRec%?-5=InitFlag%
;tBootRec%?-6=LBAflag%
;~�
;�BootRec%!-&10=&00000000
;�BootRec%!-&C=&0D0C200A
;�0BootRec%!-8=LowCurrentCyl%�(PreCompCyl%<<16)
;��
;�
�BigDisc%
;�+BootRec%!-4=SecsPerTrk%*Heads%*ParkCyl%
;��
;�4BootRec%!-4=SecSize%*SecsPerTrk%*Heads%*ParkCyl%
<