;*---------------------------------------------------------------------------
;  :Program.	visionmd4.asm
;  :Contents.	Slave for "Vision Megademo IV"
;  :Author.	BJ
;  :History.	29.09.96
;		23.03.97 output path changed
;		24.06.97 keyboard routine fixed
;		15.08.97 update for key managment
;		30.08.97 keyboard external
;  :Requires.	-
;  :Copyright.	Public Domain
;  :Language.	68000 Assembler
;  :Translator.	Barfly V1.131
;  :To Do.
;  :Time.	3h 40min
;---------------------------------------------------------------------------*

	INCDIR	Includes:
	INCLUDE	whdload.i
	INCLUDE	graphics/gfxbase.i
	INCLUDE	lvo/exec.i

	OUTPUT	"dwart:Vision Megademo IV/visionmd4.slave"
	BOPT	O+ OG+			;enable optimizing
	BOPT	w4-			;disable 64k warnings
	SUPER

;======================================================================

.base		SLAVE_HEADER		;ws_Security + ws_ID
		dc.w	4		;ws_Version
		dc.w	WHDLF_Disk|WHDLF_NoError	;ws_flags
		dc.l	$80000		;ws_BaseMemSize	
		dc.l	$400		;ws_ExecInstall
		dc.w	_Start-.base	;ws_GameLoader
		dc.w	0		;ws_CurrentDir
		dc.w	0		;ws_DontCache
_keydebug	dc.b	$58		;ws_keydebug = F9
_keyexit	dc.b	$59		;ws_keyexit = F10

;======================================================================

	DOSCMD	"WDate >T:date"
		dc.b	"$VER: WEPL "
	INCBIN	"T:date"
		dc.b	0

;======================================================================
_Start	;	A0 = resident loader
;======================================================================

		lea	(_resload,pc),a1
		move.l	a0,(a1)			;save for later use

	;build simple exec=graphics
		lea	$1000,a6	;execbase/graphicsbase
		move.l	a6,4
		patch	_LVOForbid(a6),.rts
		patch	_LVOPermit(a6),.rts
		patch	_LVOOpenLibrary(a6),.openlibrary
		lea	(-4,a6),a0
		move.l	#-2,(a0)	;copperlist
		move.l	a0,(gb_copinit,a6)
		bra	.go

.openlibrary	move.l	a6,d0
.rts		rts
.go

	;install keyboard quitter
		bsr	_SetupKeyboard
	
	;bootblock
		moveq	#0,d0		;offset
		move.l	#2*512,d1	;size
		moveq	#1,d2		;disk
		lea	$7f000-$f4-12,a0
		move.l	(_resload),a2
		jsr	(resload_DiskLoad,a2)
		jsr	$7f000

		move.l	#$400,d0	;offset
		move.l	#$f400,d1	;size
		moveq	#1,d2		;disk
		lea	$30000,a0	;dest
		move.l	(_resload),a2
		jsr	(resload_DiskLoad,a2)
		patch	$300ce,.1	;jmp $1a000
		jmp	$30024		;decrunch exe
.1
		lea	$1a000,a6
		lea	.dummyint6c,a0
		move.l	a0,$6c
		lea	.dummyint78,a0
		move.l	a0,$78
		move.w	#INTF_SETCLR|INTF_INTEN|INTF_VERTB|INTF_EXTER,_custom+intena
		patch	$1ec(a6),.load
		jmp	$3c(a6)		;go !

.load		move.l	$1a1a8,a0
		move.l	(a0)+,d1	;size
		move.l	(a0)+,d0	;offset
		moveq	#1,d2		;disk
		lea	$2f000,a0	;dest
		move.l	a1,-(a7)
		move.l	(_resload),a1
		jsr	(resload_DiskLoad,a1)
		move.l	(a7)+,a1
		rts

.dummyint6c	move.w	#INTF_VERTB,_custom+intreq
		rte
.dummyint78	move.w	#INTF_EXTER,_custom+intreq
		rte

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

_resload	dc.l	0		;address of resident loader

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

_exit		pea	TDREASON_OK.w
		bra	_end
_debug		pea	TDREASON_DEBUG.w
_end		move.l	(_resload),-(a7)
		addq.l	#resload_Abort,(a7)
		rts

;======================================================================

	INCDIR	Sources:whdload
	INCLUDE	keyboard.s

;======================================================================

	END

