ORG 100H .z80 ;**************************************************************** ;* * ;* This program reads the bad map on a Seagate ST-506 * ;* and prints out the bad areas. The bad map sector is * ;* assumed to be at cylinder 0, head 2, sector 0. * ;* * ;**************************************************************** rstchan equ 50h drive0 equ 0h sel equ 0 stepl equ 1 steph equ 2 hdsel equ 3 dmal equ 4 ;dma data pointer dmah equ 5 dmax equ 6 arg0 equ 7 ;command argument pointer arg1 equ 8 arg2 equ 9 arg3 equ 0ah cmnd equ 0bh status equ 0ch stepin equ 0h ;constant to go to track 152, drive 0 stepout equ 10h ;constant to go to track 0, drive 0 step equ 06h attn equ 55h maxtrac equ 09bh ;number of tracks for ST-506 cpm equ 0 ;warm boot channel equ 80h reset equ 54H init: ld sp,100h ld b,0 ld c,10H ld hl,channel ld (rstchan),hl ld (channel + 0dh),hl ;link field init xor a ld (rstchan + 2),a ;channel address @ 80h ld (channel + 0fh),a ;link field init out (reset),a loop1: dec c ;wait for controller to reset jr nz,loop1 start: ld ix,channel ;get the channel address ld a,step ld (ix + cmnd),a ;step command ld a,0 ld (ix + status),a ;null the status ld (ix + dmal),a ;low byte data dma address ld (ix + dmax),a ;extended data dma address ld (ix + steph),a ;null high step byte ld a,0ffh ld (ix + stepl),a ld a,stepout ld (ix + dmah),a ;high byte of dma address ld (ix + sel),a ;send it home constant call loop ;send it home call nulsek ;clear the step bytes ld (ix + cmd),a ;read command ld (ix + status),a ;null the status byte ld (ix + arg0),a ;cylinder 0 ld (ix + arg1),a ld (ix + arg3),a ;sector 0 ld a,02h ld (ix + arg2),a ;head 2 call loop ;read it check: ld hl,1000h ;beginning of map ld a,0 ;normal map entry if no errors check1: cp (hl) call nz,error inc hl bit 6,l ;check for sector end jr nz,check1 jp cpm error: call crlf ld c,09h ld de,mess0 push hl call bdos pop hl ld a,(hl) call number inc hl call crl nulsek: xor a ld (ix + stepl),a ld (ix + steph),a ret mess0: db 'Cylinder ,$' mess1: db 'Head ,$' mess2: db 'Sector ,$' loop: out (attn),a ;kick controller ld hl,0 ld c,10h ;1 minute to respond loop0: ld a,(ix + status) cp 0ffh ret z dec hl ld a,h or l jr nz,loop0 dec c jr nz,loop0 jp cpm end