ORG 100H .z80 rstchan equ 50h drive0 equ 0h sel equ 0 stepl equ 1 steph equ 2 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 cmdchan stepdeì eqõ  01cè ;steð delaù foò  ST-506 settle equ 0 ;head settle for ST-506 secsiz equ 7 ;1024 byte sectors reset equ 54H arg0 equ 07 ;command arguments arg1 equ 08 ;command arguments arg2 equ 09 ;command arguments arg3 equ 0ah ;command arguments cnsts equ 04h ;load constants cmd 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 init1: ld ix,channel ld (ix + sel),a ;zero select byte ld (ix + stepl),a ;zero steps ld (ix + steph),a ;zero steps ld (ix + arg0),a ;zero cyl argument ld (ix + arg2),a ;zero head settle ld a,stepdel ;3 ms steps ld (ix + arg1),a ld a,secsiz ld (ix + arg3),a ;1024 sectors ld a, cnsts ;load constants cmd ld (ix + cmnd),a call loop loop1: dec c ;wait for controller to reset jr nz,loop1 start: ld a,step Š ld (ix + cmnd),a ;step command ld a,0 ld (ix + status),a ;null the status ld a,0ffh ld (ix + stepl),a ld (ix + steph),a ld a,stepout or b ;or in the drive number ld (ix + sel),a ;send it home constant call loop goout: ld a,stepin ld (ix + status),a ;null the status or b ;for each drive ld (ix + sel),a ;constant to seek in ld a,maxtrac ;09bh for seagate ld (ix + stepl),a xor a ld (ix + steph),a call loop inc b bit 2,b jr z,start ;once for each drive jp cpm ;warm boot 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 cmdchan equ $ end