;-----------------------------------------------------------------------------
;
;
;             HyperWare Application Program Interface (API)
;
;
;-----------------------------------------------------------------------------
;
; HyperWare products share a common DOS multiplex Interrupt number (Int 2F).
; The following key factors apply to the interface operations:
;
; The DOS Multiplex Interrupt Number (INT 2f) is incrementally searched to
; find a free multiplex number. The beginning number is 0DFh. If this number
; is in use, then 0C0h,0C1h,0C2h,... are each quired until a free number
; is found.
;
; Each HyperWare Product uses a unique Product Code placed in the BX register,
; specifing the intended product for communications.
;
; Currently installation checks exist for all HyperWare products.
; HyperDisk also provides simple inquire and selections of the major cacheing
; functions. 
;
;
;-----------------------------------------------------------------------------
;
; HyperDisk installation check.
;
; Call and return register descriptions for Interrupt 2Fh:
;
; Calling Registers:
;
;	AH = Trial Multiplex Number 	; Initially 0DFh
;	AL = 00h		  	; Installed?? request code
;	BX ='DH'			; Disk, HyperWare
;	CX = 00h			; Clear to comfirm return codes
;	DX = 00h			; Clear to comfirm return codes
;
;
; Return Registers, Case 1 nothing installed using the Trial Multiplex Number:
;
;	AL = 00h			; Nothing install
;
;
; Return Registers, Case 2 something install, not HyperWare product:
;
;	AL = 0FFh			; Multiplex Number in use
;
;	CX = not 'YH'			; not a HyperWare Product!
;					; increment Trial Multiplex Number
;					; and try again until either a free
;					; number found, or a HyperWare product
;					; found, or Multiplex Number > 0FFh.
;
;
; Return Registers, Case 3 HyperWare product, but not HyperDisk
;
;	AL = 0FFh			; Multiplex Number in use
;
;	CX = 'YH'			; HyperWare Product selected by BX
;					; is installed.
;					; 
;	DX = 00h			; zero indicates selected product not
;					; found
;
;
; Return Registers, Case 4 HyperDisk installed!
;	AH = HyperWare Multiplex Number	; result of multiplex # search
;	AL = 0FFh		  	; Number in use
;	BX = CS segment of HyperDisk	; Valid if DX not zero
;
;	CX = 'YH'		  	; HyperWare Product selected by BX
;					; is installed.
;
;	DX = HyperDisk Local Data Version # (Not HyperDisk Product Version)
;
;
;
;--------------------------------------------------------------------------
;
;
; Example assembly language:
;

HyperCallout		db	0DFh		; Dos MultiPlex Number for HyperWare

HyDkProductCode	equ	'DH'			; Product Code for HyperDisk

HyKyProductCode	equ	'KH'			; Product Code for HyperKey

HyScProductCode	equ	'SH'			; Product Code for HyperScreen

HyScProductCode	equ	'BH'			; Product Code for HyperStb

;-----------------------------------------------------------------------------

SearchHyAPI	proc	near
	mov	ax,352fh		; get vector for Dos Multiplex
	int	21h			; call dos
	mov	cx,es			; must not be zero!
	jcxz	short SearchHyAPIRet	; if zero then no multiplex established

SearchHyAPILp:
	xor	cx,cx			; zero cx
	xor	dx,dx			; zero dx
	mov	bx,HydkProductCode	; Looking for HyperDisk

	mov	ah,HyperCallOut		; Disk Cache installed?
	xor	al,al			; install check request

	push	ds			; make sure not changed
	int	2fh			; go do multiplex interrupt
	pop	ds

	or	al,al			; zero...no change
	je	short SearchHyAPIRet	; nothing installed

	cmp	al,-1			; something installed is -1
	jne	short SearchHyAPINxt	; try next Multiplex number if not -1

	cmp	cx,'YH'			; HyperWare Product?
	jne	short SearchHyAPINxt	; if not skip to next Multiplex number

	or	dx,dx			; non-zero if HyperDisk installed
	jz	short SearchHyAPIRet	; HyperDisk not here

SearchHyAPIFound:			; Found Product, Carry is clear
	ret				; AH = Multiplex #
					; BX = CS segment of HyperDisk
					; DX = HyperDisk Local Data Version #


SearchHyAPINxt:
	inc	HyperCallOut		; Disk Cache installed?
	jnz	short SearchHyAPILp	; stop at 0FFh

SearchHyAPIRet:
	stc				; not found, carry Set
	ret


SearchHyAPI	endp

;
;-----------------------------------------------------------------------------
;
;
; Get Current HyperDisk Cache State
;
; Call and return register descriptions for Interrupt 2Fh:
;
; Calling Registers:
;
;	AH = Multiplex Number	; Value determined by Install Check
;	AL = 01h		; Get current HyperDisk Cache State
;	BX ='DH'		; Product = Disk, HyperWare
;
;
; Return Registers:
;
;	AX = 0000h		; function supported
;	BX = UsedBuffers	; number of cache buffers in use
;	CX = ModifiedBuffers	; number of modified buffers
;	DL = Current Cache values: 0 = Disabled, 1 = Enabled
;	     Bit 0..StagedFloppy: Stage Write floppy drive write operations
;	     Bit 1....StagedHard: Stage Write hard drive write operations
; 	     Bit 2..VerifyFloppy: Verify floppy drive write operations
; 	     Bit 3....VerifyHard: Verify hard drive write operations
; 	     Bit 4.....Reserved0: Reserved always 0
; 	     Bit 5.....Reserved1: Reserved always 0
; 	     Bit 6..FloppyEnable: Enable floppy caching
; 	     Bit 7..CacheEnabled: Enable all caching functions
;
;
;
; Example assembly language:
;
;
	mov	ah,HyperCallOut		; HyperWare Multiplex Number
	mov	bx,HydkProductCode	; HyperDisk product selector
	mov	al,01h			; Get current cache state

	int	2fh			; do multiplex interrupt

					; AX = 0, if supported
; 					; BX = UsedBuffers	
; 					; CX = ModifiedBuffers	
;
; 					; Bit x: 0 = Disabled, 1 = Enabled
;					; DL = Bit 0..StagedFloppy
;					;      Bit 1....StagedHard
;					;      Bit 2..VerifyFloppy
;					;      Bit 3....VerifyHard
;					;      Bit 4.....Reserved0
; 					;      Bit 5.....Reserved1
; 					;      Bit 6..FloppyEnable
;					;      Bit 7..CacheEnabled
;
;
;-----------------------------------------------------------------------------
;
;
; Set HyperDisk Cache State, return previous Cache State
;
;
; Call and return register descriptions for Interrupt 2Fh:
;
; Calling Registers:
;
;	AH = Multiplex Number	; Value determined by Install Check
;	AL = 01h		; Get current HyperDisk Cache State
;	BX ='DH'		; Product = Disk, HyperWare
;	DL = New Cache values: 0 = Disabled, 1 = Enabled
;	     Bit 0..StagedFloppy: Stage Write floppy drive write operations
;	     Bit 1....StagedHard: Stage Write hard drive write operations
; 	     Bit 2..VerifyFloppy: Verify floppy drive write operations
; 	     Bit 3....VerifyHard: Verify hard drive write operations
; 	     Bit 4.....Reserved0: Reserved always 0
; 	     Bit 5.....Reserved1: Reserved always 0
; 	     Bit 6..FloppyEnable: Enable floppy caching
; 	     Bit 7..CacheEnabled: Enable all caching functions
;
;
;
; Return Registers:
;
;	AX = 0000h		; function supported and asynchronously queued
;	BX = UsedBuffers	; number of cache buffers in use
;	CX = ModifiedBuffers	; number of modified buffers
;	DH = Previous Cache values: 0 = Disabled, 1 = Enabled
;	     Bit 0..StagedFloppy: Stage Write floppy drive write operations
;	     Bit 1....StagedHard: Stage Write hard drive write operations
; 	     Bit 2..VerifyFloppy: Verify floppy drive write operations
; 	     Bit 3....VerifyHard: Verify hard drive write operations
; 	     Bit 4.....Reserved0: Reserved always 0
; 	     Bit 5.....Reserved1: Reserved always 0
; 	     Bit 6..FloppyEnable: Enable floppy caching
; 	     Bit 7..CacheEnabled: Enable all caching functions
;
;
;
; Example assembly language:
;
;
	mov	ah,HyperCallOut		; HyperWare Multiplex Number
	mov	bx,HydkProductCode	; HyperDisk product selector

	mov	dl,11001111b		; DL = Bit 0..StagedFloppy
					;      Bit 1....StagedHard
					;      Bit 2..VerifyFloppy
 					;      Bit 3....VerifyHard
 					;      Bit 4.....Reserved0
 					;      Bit 5.....Reserved1
 					;      Bit 6..FloppyEnable
 					;      Bit 7..CacheEnabled
 					;
	mov	al,02h			; Set current cache state

	int	2fh			; do multiplex interrupt

					; AX = 0, if supported
; 					; BX = UsedBuffers	
; 					; CX = ModifiedBuffers	
; 					;
;					; DH = Bit 0..StagedFloppy
;					;      Bit 1....StagedHard
;					;      Bit 2..VerifyFloppy
;					;      Bit 3....VerifyHard
;					;      Bit 4.....Reserved0
; 					;      Bit 5.....Reserved1
; 					;      Bit 6..FloppyEnable
;					;      Bit 7..CacheEnabled
;
;
;-----------------------------------------------------------------------------
;
;
;







