; Fake - null display
; External Video Driver for
; Flaming Plus/4 emulator for the Amiga
;
; version 1.0

	MACHINE	68020

	INCDIR	Include:

	INCLUDE exec/types.i
	INCLUDE	exec/exec_lib.i
	INCLUDE	exec/memory.i
	INCLUDE	intuition/intuition_lib.i
	INCLUDE	intuition/intuition.i
	INCLUDE	macros.i

;*** Handler structure

 STRUCTURE vxd_handler,0
  LONG intuibase
  LONG myscr
  LONG mywin
  LONG emuscr
 LABEL	vxd_handler_SIZEOF

JSRLIB	MACRO
	jsr	_LVO\1(a6)
	ENDM

;*** Let's begin

	moveq.l	#0,d0
	rts

	dc.b "FLAMINGOXVD"
	dc.b "1"

	dc.l Name
	dc.l Author
	dc.w 1
	dc.w 0

	dc.l drv_Init
	dc.l drv_Done
	dc.l 0			;nothing to configure
;	dc.l drv_Configure
	dc.l drv_OpenScreen
	dc.l drv_CloseScreen
	dc.l drv_Refresh

Name:	dc.b	'Fake (null display) External Video Driver',10
	dc.b	'Only for speed test',0
Author:	dc.b	'Álmos Rajnai',0

	EVEN

;*** Functions

drv_Init:
	movem.l	a0-a1,-(sp)		;Saving infos
	move.l	#MEMF_PUBLIC|MEMF_CLEAR,d1
	move.l	#vxd_handler_SIZEOF,d0
	move.l	4.w,a6
	jsr	_LVOAllocVec(a6)
	move.l	d0,a2
	tst.l	d0
	beq.b	.error
	movem.l	(sp)+,a0-a1		;Recover infos
        move.l	8(a0),intuibase(a2)	;Saving intuition.library base
	move.l	a1,myscr(a2)		;Saving pubscreen
	move.l	a2,d0
.error	moveq.l	#0,d1			;no msg
	rts

drv_Done:
	move.l	a0,a1
	cmpa.l	#0,a1
	beq.b	.1
	move.l	4.w,a6
	jsr	_LVOFreeVec(a6)
.1	rts

;drv_Configure:		-> Nothing to configure
;	rts

drv_OpenScreen:
	move.l	a0,a5
	moveq.l	#0,d0
	move.l	d0,d1
	move.w	(a1)+,d0
	move.w	(a1),d1
	mulu.w	d1,d0
	move.l	#MEMF_PUBLIC|MEMF_CLEAR,d1
	move.l	4.w,a6
	jsr	_LVOAllocVec(a6)
	move.l	d0,emuscr(a5)		;allocating emulator screen
	beq.b	.error
	move.l	myscr(a5),wscr
	move.l	intuibase(a5),a6
	suba.l	a0,a0
	lea	wintags,a1
	JSRLIB	OpenWindowTagList	;opening a fake window
	move.l	d0,mywin(a5)
	beq.b	.error
	move.l	d0,a0
	move.l	wd_UserPort(a0),d0	;get IDCMP port
	move.l	emuscr(a5),d2		;get emulator screen
.error	moveq.l	#0,d1			;no msg
	moveq.l	#0,d3			;no chunky modulo
	rts

drv_CloseScreen:
	move.l	a0,a5
	move.l	intuibase(a5),a6
	move.l	mywin(a5),a0
	cmpa.l	#0,a0
	beq.b	.2
	JSRLIB	CloseWindow

.2	move.l	emuscr(a5),a1
	cmpa.l	#0,a1
	beq.b	.1
	move.l	4.w,a6
	jsr	_LVOFreeVec(a6)
.1
	rts

drv_Refresh:
	move.l	emuscr(a0),d0		;chunky buffer back
	rts

wintags:
	dc.l    WA_Left,0
	dc.l	WA_Top,0
	dc.l	WA_Width,300
	dc.l	WA_Height,100
	dc.l	WA_MinWidth,20
	dc.l	WA_MinHeight,20
	dc.l	WA_MaxWidth,600
	dc.l	WA_MaxHeight,500
	dc.l	WA_IDCMP,IDCMP_RAWKEY
	dc.l	WA_Flags,WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SIZEGADGET
	dc.l    WA_Title,wintitle
	dc.l	WA_NoCareRefresh,TRUE
	dc.l	WA_PubScreen
wscr:	dc.l    0
	dc.l	WA_SimpleRefresh,TRUE
	dc.l	WA_Activate,TRUE
	dc.l	TAG_DONE

wintitle:	dc.b	'Flamingo Plus/4 emulator fake screen',0
