Path: utzoo!attcan!uunet!mcvax!philmds!leo
From: leo@philmds.UUCP (Leo de Wit)
Newsgroups: comp.sys.atari.st
Subject: null fill eliminated
Message-ID: <490@philmds.UUCP>
Date: 1 Jun 88 06:58:11 GMT
Reply-To: leo@philmds.UUCP (L. J. M. de Wit)
Organization: Philips I&E DTS Eindhoven
Lines: 98

Remember the discussion about the slow null filling routine TOS uses after 
loading a program? Here's a nice small, fast and, what you hackers will like
most, dirty piece of code I made yesterday evening. It just eliminates the
null fill (there could be a 1/(vbls/sec) delay %-) and is guaranteed NOT to 
work on all ROM versions 8-).
The main problem will be the addresses (start, end) of the fill-routine in ROM.
If you know them, you can substitute them (fillhigh and filllow). I don't have
other ROM's or disassemblies. Maybe someone else can pop up a more general
solution?
The central function is fastload, that checks if the PC is the critical region;
if so, D5 will be given a big value on return from the VBL interrupt, which
causes the fill routine to end.
The search for a zero VBL pointer starts at the queue address + 4, because I
suspect some program (maybe it's GEM) to write a vector at queue_address[0],
no matter what is already there. Now fastload.prg can be put into the AUTO
folder.

	module fastload

	section s.ccode

gemdos		equ 1
bios		equ 13
super		equ $20
ptermres	equ $31
conws		equ 9
pterm		equ $4c
vbl_queue	equ $456
nvbl		equ $454
bpaglen		equ $100
textlen		equ 12
datalen		equ 20
bsslen		equ 28
fillhigh	equ $fc859c
filllow		equ $fc858a
bigint		equ $7cccccc0

fastinit
	clr.l	-(sp)
	move.w	#super,-(sp)
	trap	#gemdos
	addq.l	#6,sp
	move.l	d0,-(sp)	* Save ssp on stack
	move.w	nvbl,d0
	movea.l	vbl_queue,a0
	addq.l	#4,a0
	subq.l	#1,d0
	bmi.s	tstque2
	bra.s	tstque1
tstque0
	tst.l	(a0)+
tstque1
	dbeq	d0,tstque0
	beq.s	tstok
tstque2
	pea	noque(pc)
	move.w	#conws,-(sp)
	trap	#gemdos
	addq.l	#6,sp
	move.w	#1,-(sp)
	move.w	#pterm,-(sp)
	trap	#gemdos		* Ends here
tstok
	lea	fastload(pc),a1
	move.l	a1,-(a0)
	move.w	#super,-(sp)
	trap	#gemdos		* Restore ssp that is on stack
	addq.l	#6,sp
	move.l	4(sp),a0	* Basepage start
	move.l	#bpaglen,d0	* Basepage length
	add.l	textlen(a0),d0	* + text length
	add.l	datalen(a0),d0	* + data length
	add.l	bsslen(a0),d0	* + bss length
	clr.w	-(sp)		* Return value: 0 for success
	move.l	d0,-(sp)	* # bytes to keep
	move.w	#ptermres,-(sp)	* Keep process
	trap	#gemdos		* Stops here

fastload
	movea.l	74(sp),a0	* PC
	cmpa.l	#fillhigh,a0
	bhi.s	fastdone
	cmpa.l	#filllow,a0
	blt.s	fastdone
	move.l	#bigint,32(sp)	* Maximize D5 on stack
fastdone
	rts

	section s.data

noque	dc.b	'No vbl entry available!',13,10,0

	end

I hope no little beasties have crept in while I was typing it over (have no
modem connection yet). Have fun!

	Leo.