.COMMENT % ######################################################### # # # PUTSTS AND PUTOVL PROGRAM # # FOR THE KAYPRO 10 # # # # by Gilbert Ohynsty # # for Non-Linear Systems. # # # # Copyright (c) by Kaypro Corporation, 1983. # # Copyright (c) by Non-Linear Systems, 1983. # # # # No Warranty is made, expressed or implied. # # # #=======================================================# # # # Revision: 1.4 19-Oct-83 # # Revision: 1.3 25-Aug-83 # # Revision: 1.2 -------83 # # # #=======================================================# # # # Changes, revision 1.4: Added conditional # # equate for inverted hard disk reset line. # # (M. Sherman, 19-Oct-83) # # Changes, revision 1.3: Corrected error in # # error reporting. # # # ######################################################### % .Z80 ; Hard Disk Definitions: false equ 0 true equ not false hdrinv equ true ; true for new inverted reset, else false systyp equ true ; true if putsys, false if putovl sysimage equ 900H ; image to write ; conditional hard disk reset equates if hdrinv hdcsel equ 00h else hdcsel equ 02H endif hdcmsk equ 11111101b ; hard disk reset line mask ; ports: bitport equ 14H hdbase equ 80h hddata equ hdbase ; data register hdetyp equ hdbase+1 ; error type register hdwrtp equ hdbase+1 ; write precomp cylinder/4 hdscnt equ hdbase+2 ; number of sectors count hdsec equ hdbase+3 ; first sector to read/write hdclo equ hdbase+4 ; cylinder number low byte hdchi equ hdbase+5 ; cylinder number high byte hdsdh equ hdbase+6 ; size/drive/head register hdcmd equ hdbase+7 ; command register hdstat equ hdbase+7 ; status register ;commands: longrw equ 00000010b ; long read/write bit multrw equ 00000100b ; multiple read/write bit hddmam equ 00001000b ; dma mode on read bit rt35uS equ 00000000b ; 035 uS step rate (fastest) rt05mS equ 00000001b ; 0.5 mS step rate (rest in inc. of this one) rt10mS equ rt05mS*2 ; 1.0 mS step rate rt30mS equ rt05mS*6 ; 3.0 mS step rate rt60mS equ rt05mS*12 ; 6.0 mS step rate rt75mS equ rt05mS*15 ; 7.5 mS step rate (slowest) eccmod equ 10000000b ; error correcting mode sec512 equ 00100000b ; 512 byte sector size ;if production then use 101000x0b pattern for hdsel, else 101010x0b if systyp hdsel equ 10101000b ; disk select pattern (Drive A) else hdsel equ 10101010b ; disk select pattern (Drive B) endif hdinir equ 00010000b+rt60mS ; restore used for initialization hdrstr equ 00010000b+rt05mS ; restore used for normal home command hdseek equ 01110000b+rt35uS ; fast seek hdred equ 00100000b ; read sector hdredl equ 00100000b+longrw ; long read (sector + ECC bytes) hdwrt equ 00110000b ; write sector hdwrtl equ 00110000b+longrw ; long write (sector + ECC bytes) ; hard disk info lzone equ 329 ; for IMI drives maxcyl equ 305 ; for IMI drives (0-305=306) print macro x .xlist ld c,9 ld de,x call 5 .list endm print hello call dohome ; home hd ld hl,0 xor a ld (@hsttrk),hl ; first track and sector ld (@hstsec),a ld hl,sysimage ld a,0 loop0: ld (hstbuf),hl ld (@hstsec),a push af call writehst ; write to hd ld hl,(hstbuf) ; bump memory pointer ld de,512 add hl,de pop af inc a cp 17 ; another sector? jr nz,loop0 call dohome ; home hd ld hl,1 ; do flip side xor a ld (@hsttrk),hl ; first track and sector ld (@hstsec),a ld hl,sysimage ld a,0 loop1: ld (hstbuf),hl ld (@hstsec),a push af call writehst ; write to hd ld hl,(hstbuf) ; bump memory pointer ld de,512 add hl,de pop af inc a cp 17 ; another sector? jr nz,loop1 ret writehst:call hstcom call hdwrite ret z print fault self: jp self fault: db 0DH,0AH,'DISK WRITE FAULT',0DH,0AH,'$' hstcom: ld a,(@hsttrk) ld c,a call trkset ld a,(@hstsec) ld c,a call secset ret dohome: call ready ld a,hdrstr ; restore out (hdcmd),a call hdbsy xor a out (hdclo),a out (hdchi),a ld a,hdseek out (hdcmd),a ; set future (implied) seek speed hdbsy: in a,(hdstat) bit 7,a jr nz,hdbsy ret trkset: ld hl,(@hsttrk) ; shift right 1 lsb is head sel srl h rr l ld a,l out (hdclo),a ld a,h out (hdchi),a ret secset: ld a,c out (hdsec),a ret ready: in a,(bitport) and hdcmsk ; clear hd reset bit or hdcsel ; clear wd reset (select controller) out (bitport),a ld a,(@hsttrk) ; select head and 1 or hdsel out (hdsdh),a ret hdwrite:call ready in a,(hdclo) out (hdclo),a ; clear data request line. ld bc,0000h+hddata ld hl,(hstbuf) ld a,hdwrt ; that's right, you out (hdcmd),a ; issue the command otir ; before the data. otir call hdbsy and 01 ; error flag ret if systyp hello: defb 0DH,0AH,'PUTSYS VER 1.4 ',0DH,0AH,'$' else hello: defb 0DH,0AH,'PUTOVL VER 1.4 ',0DH,0AH,'$' endif @hsttrk:defw 0 @hstsec:defw 0 hstbuf: defw 0 end