
;**********************************************************************
;The following macro builds the required BGI header block.
;This macro is derived from Borland's own BGI toolkit
;from the DEVICE.INC file for compatibilty.

BGI	macro	name		; the following macro builds
	public	name		; the required ddo header block

     IF BGIVERSION LT 3

name	proc	far		; the vector table must be at
				; 'ddovec' 
	push	ds		; (push ds, push cs are signature)
	push	cs		; make ds=cs
	pop	ds
	cld			; just in case
	push	bp		; 6 bytes
	call	[DDOVEC+si]	; call the local function
	pop	bp		
	pop	ds		; restore regs
	ret			; ret far
name	endp
	db	'CB'
	db	0		; spare area
verID	db	BGIVERSION	; version id is at offset 15
;emulate must be at offset 16 
EMULATE:ret			; emulate function (nop until
	dw	0,0		; patched by loader)
RESERVED:
NONE:	ret			; near ret for unused functions
     ELSE

name	proc	far		; the vector table must be at
				; 'ddovec' 
	push	ds		; 
	MOV	DS,CS:[ALIAS]	; 
	cld			; clr dir flag just in case
	push	bp		; 
	call	[DDOVEC+si]	; call the local function
	pop	bp		
	pop	ds		; restore regs
	ret			; ret far
name	endp
verID	db	BGIVERSION	; version id is at offset 15
;alias must be at offset 16 with emulate at offset 18
ALIAS	dw	0
EMULATE:ret			; emulate function (nop until
	dw	0,0		; patched by loader)
RESERVED:
NONE:	ret			; near ret for unused functions

     ENDIF

	endm

IFLUSH	MACRO
LOCAL	@@L
	JMP	@@L ;macro to flush prefetched instructions
@@L:
	ENDM

