; MetaGraph metafiling interface
; Copyright 1996 by Daniel Mahrenholz


INCLUDE	grdef.asm

IDEAL


INCLUDE	"MetaGlob.inc"

SEGMENT	Data	word	public
ASSUME	ds:Data

	tx1	dw	?
	tx2	dw	?
	ty1	dw	?
	ty2	dw	?

ENDS

SEGMENT	Code	byte	public
ASSUME	cs: Code

P386

LOCALS @@

PROC	M_VL near

	mov	ax, [MetaState]
	and	ax, ms_Record
	jz	@@1

        metafile 3, @@1
	add	sp, 6
	ret
@@1:
	jmp	[P_VL]

	ret

ENDP


PROC 	M_HL near

	mov	ax, [MetaState]
	and	ax, ms_Record
	jz	@@1

        metafile   3, @@1
	add	sp, 6
	ret
@@1:
	jmp	[P_HL]

	ret

ENDP


PROC	M_Bar near

	mov	ax, [MetaState]
	and	ax, ms_Record
	jz	@@1

        metafile   4, @@1
	add	sp, 8
	ret
@@1:
	jmp	[P_Bar]

	ret


ENDP

PROC	M_Point near

	mov	ax, [MetaState]
	and	ax, ms_Record
	jz	@@1
        metafile   3, @@1
@@2:
	add	sp, 6
	ret
@@1:
	jmp	[P_Point]

	ret

ENDP

PROC	F_Point256	near

	push	[(word DColor256)]
	jmp	[P_Point]

ENDP

PROC	F_Point16	near

	push	[DColor16]
	jmp	[P_Point]

ENDP

PROC 	M_GetP near

	jmp	[P_GetP]

	ret

ENDP

PROC	M_Line near

	mov	ax, [MetaState]
	and	ax, ms_Record
	jz	@@1

        metafile   4, @@1
	add	sp, 8
	ret
@@1:
	cmp	[daThickness], 1
	jne	@@2
	jmp	[P_Line]
	ret
@@2:
	pop	[ty1] [ty2] [tx1] [tx2]
	mov	ax, [daThickness]
	shr	ax, 1
	mov	bx, [tx2]
	sub	bx, [tx1]
	jns	@@t1
	neg	bx
@@t1:
	mov	cx, [ty2]
	sub	cx, [ty1]
	jns	@@t2
	neg	cx
@@t2:
	cmp	bx, cx
	jg	@@t3
	sub	[tx1], ax
	sub	[tx2], ax
	mov	cx, [daThickness]
@@t4:
	push	cx offset(@@t5) [tx2] [tx1] [ty2] [ty1]
	jmp	[P_Line]
@@t5:
	pop	cx
	inc	[tx1]
	inc	[tx2]
	loop	@@t4
	ret
@@t3:
	sub	[ty1], ax
	sub	[ty2], ax
	mov	cx, [daThickNess]
@@t6:
	push	cx offset(@@t7) [tx2] [tx1] [ty2] [ty1]
	jmp	[P_Line]
@@t7:
	pop	cx
	inc	[ty1]
	inc	[ty2]
	loop	@@t6
	ret

ENDP

ENDS

END