	nolist
;:ts=8
*****************************************************************
*                                                               *
* VBRevoM version 1.2, © 1991 Arthur Hagen, All rights reserved *
*                                                               *
* Posted to the Public Domain.                                  *
*                                                               *
* Written using the Aztec Manx C 5.0 Assembler                  *
*                                                               *
* All comments deliberately stripped from source.               *
* If you don't understand it, you should not mess with it!      *
*                                                               *
*****************************************************************

	include	'exec/execbase.i'
	xref    _LVOOldOpenLibrary
	xref    _LVOCloseLibrary
	xref    _LVOSuperState
	xref    _LVOOutput
	xref    _LVOWrite
	xref    _LVOAllocMem
	xref	_LVOPermit
	xref	_LVOFreeMem
	xref	_LVOCopyMemQuick
	list

	machine	mc68010
	public	_VBRevoM
_VBRevoM:
	movea.l	(4).w,a6
	lea	dosname(pc),a1
	jsr	_LVOOldOpenLibrary(a6)
	movea.l	d0,a5
	exg.l	a5,a6
	jsr	_LVOOutput(a6)
	exg.l	a5,a6
	move.l	d0,d7
	moveq	#title_end-title,d3
	lea	title(pc),a0
	bsr.s	wrt
	btst	#AFB_68010,AttnFlags+1(a6)
	beq.s	wrong

	jsr	_LVOSuperState(a6)
	movec	VBR,d2
	move.l	sp,USP
	movea.l	d0,sp
	andi.w	#$dfff,SR
	tst.l	d2
	beq.s	alrdy

	movea.l	d2,a0
	suba.l	a1,a1
	moveq	#64,d6
	rol.w	#4,d6
	move.l	d6,d0
	jsr	_LVOCopyMemQuick(a6)
	jsr	_LVOSuperState(a6)
	moveq	#0,d1
	movec	d1,VBR
	move.l	sp,USP
	movea.l	d0,sp
	andi.w	#$dfff,SR
	movea.l	d2,a1
	move.l	d6,d0
	jsr	_LVOFreeMem(a6)
quit	movea.l	a5,a1
	jmp	_LVOCloseLibrary(a6)

wrong	moveq	#wrongpro_end-wrongpro,d3
	lea	wrongpro(pc),a0

writerr	pea	quit(pc)

wrt	move.l	a0,d2
	move.l	d7,d1
	exg.l	a5,a6
	jsr	_LVOWrite(a6)
	exg.l	a5,a6
	rts

alrdy	moveq	#already_end-already,d3
	lea	already(pc),a0
	bra.s	writerr

	dc.b	'$VER: '
title	dc.b	'VBRevoM 1.2 (30.1.92)',$0A,$0D
	dc.b	'Copyright ',$A9,' 1992 Arthur Hagen.',$0A
title_end
already	dc.b	'VBR not set',$0A
already_end
wrongpro
	dc.b	'You need 68010 or higher!',$0A
wrongpro_end
dosname	dc.b	'dos.library',0
	even
	END
