DDT - DEEP DISK TESTER by Richard Karsmakers When I recently visited the CCV (that, my friends, it the Computer Club Veldhoven, one of the cosiest computer clubs in Southern Netherlands) someone (his name slipped my mind, sorry) gave me the idea to write a program that can test every data-bit of a disk - also when the disk was already written on. He came up with the above name as well (through lack of sheer creativity, I would never have been able to think of something quite like it - especially when writing'n'programming on a 40 degrees Celcius attic). The program just asks you to insert the disk to be tested, then checks the bootsector (to get number of sides, tracks and sectors per track) and starts testing every single bit it can normally read. The Deep Disk Tester cannot test protected disks (e.g. with checksum errors or something of the kind deliberately brought upon it) - these erroneous tracks will simply be ignored in the test. How does it work? The actual test routine is actually made up like this: 1 - Read a sector 2 - Xor all bytes with 255 (every bit is inverted) 3 - Write the sector back 4 - Read it again and compare it with the sector as it should be 5 - If everything is OK, then the whole things should be Xor-ed again and written back This way, every single bit of the disk is tested. Originally published in ST NEWS Volume 2 Issue 5. oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ********************************* * Agf Basic Listing * ********************************* ' DDT - Deep Disk Tester Rev.1.0 ' ' Program design, development and programming by Richard Karsmakers ' Idea by Mr. I-forgot-his-name (in Veldhoven), but not mine anyway... ' Sunday, July 19th 1987 ' Alert 1,"Please insert disk|to be tested|in Drive A",1,"OK",Dummy% ' ' Read bootsector of disk to analyse the number of sides, tracks, sectors ' Boot$=Space$(512) !For bootsector Check$=Space$(512) !For check-sector Dim B%(512) !Wrong byte arrays A%=Xbios(8,L:Varptr(Boot$),L:0,W:0,W:1,W:0,W:0,W:1) !Read bootsector If A%<>0 !Error occured? Alert 1,"An error occured!|Test aborted!",1,"Oh",Dummy% Edit Endif ' Sec%=Asc(Mid$(Boot$,20,1))+256*(Asc(Mid$(Boot$,21,1))) !Sectors on disk Spt%=Asc(Mid$(Boot$,25,1))+256*(Asc(Mid$(Boot$,26,1))) !Sectors per track Sid%=Asc(Mid$(Boot$,27,1))+256*(Asc(Mid$(Boot$,28,1))) !Sides Tps%=(Sec%/Spt%)/Sid% !Tracks per side ' Cls Print "The disk has the following characteristics:" Print "Total number of sectors : ";Sec% Print "Sectors per track : ";Spt% Print "Number of sides : ";Sid% Print "Nunber of tracks per side: ";Tps% ' ' The actual reading/checking takes place here ' For S%=0 To Sid%-1 !Sides For T%=0 To Tps%-1 !Tracks per side For C%=1 To Spt% !Sectors per track Print "Testing side: ";S%;", track: ";T%;", sector: ";C% @Check Next C% Next T% Next S% ' ' The check routine ' Procedure Check ' Read in sector A%=Xbios(8,L:Varptr(Check$),L:0,W:0,W:C%,W:T%,W:S%,W:1) If A%<>0 Print "Read error on side: ";S%;", track: ";T%;", sector: ";C% Goto Label1 Endif ' Buffer contents Buffer$=Check$ ' Invert bits For X%=1 To Len(Check$) Mid$(Check$,X%,1)=Chr$(Asc(Mid$(Check$,X%,1)) Xor 255) Next X% ' Write sector back A%=Xbios(9,L:Varptr(Check$),L:0,W:0,W:C%,W:T%,W:S%,W:1) If A%<>0 Print "Write error on side: ";S%;", track: ";T%;", sector: ";C% Goto Label1 Endif ' Read it again A%=Xbios(8,L:Varptr(Check$),L:0,W:0,W:C%,W:T%,W:S%,W:1) If A%<>0 Print "Read error on side: ";S%;", track: ";T%;", sector: ";C% Goto Label1 Endif ' Invert bits For X%=1 To Len(Check$) Mid$(Check$,X%,1)=Chr$(Asc(Mid$(Check$,X%,1)) Xor 255) Next X% ' Check if buffer$ is still equal to the sector P%=0 Arrayfill B%(),0 For X%=1 To Len(Check$) If Mid$(Check$,X%,1)<>Mid$(Buffer$,X%,1) B%(P%)=X% Inc P% Endif Next X% ' Faulty bits? If P%>0 Print "Byte faulty on side: ";S%;", track: ";T%;", sector: ";C% For X%=0 To P% Print "Faulty byte #";P%+1;": ";B%(P%) Next X% Goto Label1 Endif ' Write sector back A%=Xbios(9,L:Varptr(Buffer$),L:0,W:0,W:C%,W:T%,W:S%,W:1) If A%<>0 Print "Write error on side: ";S%;", track: ";T%;", sector: ";C% Endif Label1: Return