PAGE ; S E L E C T D I S K D R I V E ; ; Select the disk drive for subsequent disk transfers and ; return the appropriate DPB address. This routine ; diverges from the normal CP/M implementation of just ; saving the disk selection value until the transfer is ; performed. This divergence is required because floppy ; disks are a removable media and come in more than on ; format. This routine determines the correct format and ; initializes the DPH with the appropriate values for the ; format type. ; ; ENTRY C = disk delection value. ; DE and 1 = 0, must determine disk type. ; = 1, drive type has been determined. ; ; EXIT HL = 0, if drive not selectable. ; HL = DPH address if drive is selectable. ; ; DPH is intialized for the appropriate floppy ; disk format. SELDSK: proc CMP CL,#NDSK JL SELD2 ;If valid drive SELD1: LD BX,#0 ;Flag invalid drive selection RET SELD2: PUSH DX ;Save drive selection mask LD CH,#0 MOV BX,CX ADD BX,#DSKMSK LD AL,[BX] STO AL,SEKDSK ;Save selection code MOV BX,CX ;Compute DPH address SHL BX ;*2 SHL BX ;*4 SHL BX ;*8 SHL BX ;*16 ADD BX,#DPBASE MOV DX,BX ;Save DPH address LD BX,[BX+5*2] ;DPH DPB address DEC BX LD AL,[BX] ;Get disk type from DPB STO AL,SEKTYP ;Save disk type MOV BX,DX ;BX = DPH address POP DX ;Restore Drive selction mask CMP AL,#MAXFTP JG SELD3 ;If hard disk AND DL,#1 ;Mask selected bit JNZ SELD3 ;If drive previously selected PUSH BX ;Save DPH address PUSH CX ;Save drive selection CALL TREAD ;Determine disk type POP CX ;Restore drive selection POP DX ;Restore DPH address JNZ SELD1 ;If disk type not determined STO AL,SEKTYP ;Save disk type LD AH,#0 PUSH AX SHL AX ;*2 SHL AX ;*4 SHL AX ;*8 SHL AX ;*16 ADD AX,#DPBS1+1 ;AX = DPB address MOV BX,DX ;BX = DPH address STO AX,[BX+5*2] ;Set DPB address into DPH POP BX ;Restore disk type AND BL,#0FEh ;Remove sided bit ADD BX,#XTABLE ;Compute translation table address LD AX,[BX] ;Get translation table address MOV BX,DX STO AX,[BX] ;address into DPH SELD3: RET PAGE ; H O M E ; ; Return disk to home. This routine sets the track number ; to zero. The current host disk buffer is flushed to the ; disk. HOME: CALL FLUSH ;Flush host buffer XOR AX,AX STO AL,HSTACT ;Clear host active flag STO AL,UNACNT ;Clear sector count STO AX,SEKTRK RET SPACE 4,10 ; S E T T R A C K. ; ; Set track number. The track number is saved for later ; use during a disk transfer operation. ; ; ENTRY BC = track number. SETTRK: STO CX,SEKTRK ;Set track LD AX,UNATRK CMP AX,CX JNE CUNACT ;If not same track RET SPACE 4,10 ; Clear Unallocated block count (force pre-reads). CUNACT: LD AL,#0 ;A = 0 STO AL,UNACNT ;Clear unallocated block count RET SPACE 4,10 ; Set the sector for later use in the disk transfer. No ; actual disk operations are perfomed. ; ; Entry BC = sector number. SETSEC: STO CL,SAVSEC ;sector to seek RET SPACE 4,10 ; Set Disk memory address for subsequent disk read or ; write routines. This address is saved in DMAADR until ; the disk transfer is performed. ; ; ENTRY BC = Disk memory address. ; ; EXIT DMAADR = BC. SETDMA: STO CX,DMAADR RET SPACE 4,10 ; Translate sector number from logical to physical. ; ; ENTRY DE = 0, no translation required. ; DE = translation table address. ; BC = sector number to translate. ; ; EXIT HL = translated sector. SECTRN: LD AL,UNASEC CMP AL,CL JZ :7 ;If sectors match CALL CUNACT :7: STO CL,LOGSEC MOV BX,CX ADD BX,DX ;Sector + translation table address OR DH,DL JZ :8 ;If no translation LD BL,[BX] LD BH,#0 :8: RET SPACE 4,10 ; S E T E X T E N D E D B A N K ; ; Set the extended bank data tranfer address. ; ; ENTRY C = Extended address bank. ; ; EXIT DMAADE = C. SETXAD: STO CX,DMASEG RET