[comp.sys.amiga.tech] Blit routine

micke@slaka.sirius.se (Mikael Karlsson) (05/29/90)

Forget about all that mad bomber jazz and listen up!

Does anybody out there in netland have a blit routine that gives me
more control over the blitter than the currently available functions
AND takes care of all the fuss (WaitBlit, OwnBlitter, etc)?

Thanks in advance

/Mikael

--

 \_/   Mikael Karlsson, Lovsattersvagen 10, S-585 98  LINKOPING, SWEDEN
  V                           | micke@slaka.sirius.se
  |      Absolut Software     | micke@slaka.UUCP
 ~~~                          | {mcvax,seismo}!sunic!liuida!slaka!micke

bevis@EE.ECN.PURDUE.EDU (Jeff Bevis) (05/30/90)

In article <67293.AA67293@slaka.sirius.se>, micke@slaka.sirius.se (Mikael Karlsson) writes:
>Does anybody out there in netland have a blit routine that gives me
>more control over the blitter than the currently available functions
>AND takes care of all the fuss (WaitBlit, OwnBlitter, etc)?
>
In assembly or C?
I just got Sooooo frustrated with BlitMaskBitMapBlahBlahBlah() etc... that
I took a dive into the OwnBlitter() {do satanic things} DisownBlitter()
realm.  It was, indeed, exhilarating to do the naughty stuff I never let
myself do before!  (Well, to be fair, I call any writing directy to I/O
naughty -- even if in an amiable fashion.)

Basically, the code does this (it's torn from a mix of C & asm):

	(include appropriate files here, like hardware/blit.i)

		movea.l	_GfxBase,a6
		jsr	_LVOOwnBlitter(a6)	; own the blitter
		jsr	_LVOWaitBlit(a6)	; wait before playing
		lea	_custom,a0		; regs def'd in custom.i
		move.w	#$ffff,bltafwm(a0)	; first word mask
		move.w	#$ffff,bltalwm(a0)	; last word mask
		move.w	#$0fca,bltcon0(a0)	; blit ctrl & minterm
		move.w	#$0000,bltcon1(a0)	; more blit ctrl
		move.w	#0,bltamod(a0)		; mask modulo is 0
		move.w	#0,bltbmod(a0)		; same for source image
		move.w	#36,bltcmod(a0)		; dest modulo is 40-4
		move.w	#36,bltdmod(a0)		; same

	loop:
		< figure out addresses for this blit >
		jsr	_LVOWaitBlit(a6)	; wait for last blit to end
		move.l	#DESTADDR,bltdpt(a0)	; destination of blit (WR)
		move.l	#DESTADDR,bltcpt(a0)	; ditto, but read (RD)
		move.l	#SOURCEADDR,bltbpt(a0)	; the source image (RD)
		move.l	#MASKADDR,bltapt(a0)	; the image mask (RD)

		move.w	#$0602,bltsize(a0)	; cause blit to start

		< branch to loop until done blitting all planes >

		jsr	LVODisownBlitter(a6)	; give back what you have
						; stolen (Time Bandits)

		END

This is part of a program I'm currently tinkering with -- it has to blit
64 32x24x5 images, using masks, into a 320x200 screen -- really fast.  It
does.  The modulos for the destination are 36 because the source image is
4 bytes wide and the screen is 40 bytes 'wide'.  40-4==36.

This is exactly how I blit.  No shifts, no fancy stuff, but I can do anything.

(I make no claims about the above code except to say that it works for me)

-------------------------------------------------------------------------------
    "Three is never equal to four, except for very large values of three."
-------------------------------------------------------------------------------
Jeff Bevis		     Purdue Univeristy School of Electrical Engineering
bevis@en.ecn.purdue.edu	  	   	       Give me Amiga or nothing at all.
-------------------------------------------------------------------------------