**************************************************
*
* f*cking lame asm shit
*
* blame on me for releasing this ;-)
*
**************************************************

	OPT !
	
******************************************************

	MACHINE 68020

******************************************************

	INCDIR	INCLUDE:
	INCLUDE	exec/funcdef.i
	INCLUDE	exec/exec_lib.i
	INCLUDE	exec/tasks.i
	INCLUDE	exec/macros.i
	INCLUDE	exec/execbase.i

******************************************************

_LVOFindTagItem	EQU	-30			; util..lib

******************************************************

	SECTION TEXT,CODE

******************************************************

	XDEF	_NewVector
	XDEF _OldVector

******************************************************

	XREF	_args

LEFT		EQU	0
TOP		EQU	4
WIDTH	equ	8
HEIGHT	equ	12
BORDER	equ	16
TITLE	equ	20
DELTA	equ	24

******************************************************

call	MACRO
	jsr	_LVO\1(a6)
	ENDM

******************************************************

_NewVector:

	tst.l	a0		; newwindow struct available ?
	beq.b	skip
	tst.l	a1		; tagitems available ?
	beq.b	skip

	movem.l	d0-d7/a0-a6,-(sp)
	move.l	a0,a4	; newwindow
	move.l	a6,a5	; intuitionbase

	movea.l	4.w,a6			; if the calling task is the "Workbench" then...
	lea		wbname(pc),a1
	call		FindTask(a6)
	move.l	d0,d7
	beq.b	skip2
	suba.l	a1,a1
	call		FindTask(a6)
	cmp.l	d0,d7
	bne.b	skip2

	move.l	14(a4),d0
	and.l	#$0000090f,d0		; backdrop+borderless+size/drag/depth/close
	cmp.l	#$00000900,d0		; only backdrop+borderless should be set
	bne.b	skip2			; .. go on

	move.l	a5,a6
	jsr		-$d2(a6)
	move.l	d0,a0
	move.l	_args+TITLE,d0
	jsr		-$11a(a6)	; showtitle ;-)

	tst.l	_args+BORDER
	beq.b	nope
	sub.l	#$800,14(a4)		; force a border
nope
	move.l	_args+LEFT,a0
	tst.l	a0
	beq.b	not1
	move.w	2(a0),0(a4)		; buaeh! arghl! ABSOLUT REFERENCES!
not1	move.l	_args+TOP,a0
	tst.l	a0
	beq.b	not2
	move.w	2(a0),2(a4)		; really, blame on me ;-)
not2	move.l	_args+WIDTH,a0
	tst.l	a0
	beq.b	not3
	tst.l	_args+DELTA
	bne.b	no1
	move.w	2(a0),4(a4)
	bra	not3
no1	move.w	2(a0),d0
	add.w	d0,4(a4)
not3	move.l	_args+HEIGHT,a0
	tst.l	a0
	beq.b	not4
	tst.l	_args+DELTA
	bne.b	no2
	move.w	2(a0),6(a4)
	bra	not4
no2	move.w	2(a0),d0
	add.w	d0,6(a4)
not4
skip2
	movem.l	(sp)+,d0-d7/a0-a6
skip	dc.w 	$4EF9
_OldVector:
	dc.l 	0

******************************************************

wbname:	dc.b	'Workbench',0
		CNOP 4,4

******************************************************

	END

******************************************************
