From: dvljrt@cs.umu.se (Joakim Rosqvist)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: Need help - Simple use of blitter with assembly
Date: 7 Apr 92 15:18:28 GMT
Organization: Dep. of Info.Proc, Umea Univ., Sweden

In article <1992Apr3.214149.17466@galileo.cc.rochester.edu> rjw@merlin.cvs.rochester.edu (Robert Wilson) writes:
>
>There was still some shaking when I used 2 bitplanes, and 15 circles
>of diameter 30.  I figured some of the time taken might be in the C
>blitter routines: how they do their own setting up of registers, etc.
>I figured I could put together some assembly routines to do this with
>less overhead.
>
>Well, it hasn't been all that easy.  Instead of getting circles copied,
>I'm getting the whole bitplanes copied.  Solid rectangles, moving
>across the screen.

Of course, since you're copying new circles on the old ones.
You should OR the new circles into the bitmap.

About writing to DFF-regs:
They are all write-only or read-only, so don't use CLR, OR or AND on them.
(On 68020+ it's ok to use clr)


>; ********************************************************************
>; Initializing the blitter registers
>;
>; Some of the register values don't change, no matter how many blits are
>; made.  Because of this, they can be set up at the beginning of each
>; set of blits.
>; Set up:    BLTCON0 (controls for blitting)
>;	      BLTCON1 (more controls)
>;	      BLTAMOD (# bytes skipped over per row when being read)
>;	      BLTDMOD (# bytes skipped over per row when writing)
>;	      BLTAPT  (address to copy from)
	      ^^^^^^

That one can't be preset, after a blit it points to the first address
not read from.

>      xdef _BlittInit
>_BlittInit:
>      link	a5,#$FFF4      ; link up routine

?? LINK?? You don't use A5 at all in this routine?!


>      lea	_custom,a1	; get pointer to custom chips
>      bsr	waitblit	 ; wait until blitter is free
>      clr.w	bltamod(a1)	 ; no bytes skipped in copying source
>      clr.w	bltcon1(a1)	 ; no special modes

No clr's please.

>      move.w	#$FFFF,bltafwm ; first and last word masks are not
>      move.w	#$FFFF,bltalwm ; used here

should be changed to:
       moveq #-1,d0
       move.l d0,bltafwm(a1)


>      move.w	#$00F0,bltcon0(a1)   ; copy from source A
>      or.w	#BC0F_SRCA,bltcon0(a1)	    ; activate source A
>      or.w	#BC0F_DEST,bltcon0(a1)	    ; activate destination

Argh! You should have  $0BFA in bltcon0 to OR SrcA to the screen (assuming
bltdptr=bltcptr), but you can't preset bltcon0 anyway since you need to change
the Ashift value.


>      xdef _BlittGrit
>_BlittGrit:
>      link	A5,#$FFF4      ; link up
>      lea	_custom,A1	; pointer to custom chips
>      bsr	waitblit	 ; wait until blitter is free

If you want some speed, kill LINK, move the lea _custom outside this routine,
put waitblit inline, and the whole BlittGrit inline.

>      move.l	_toAddress,bltdpt(A1)	; set up address to write to

..and to bltcpt as well.

>      and.w	#$0FFF,bltcon0(A1)	; clear previous shift
>      move.w	_shft,d0
>      or.w	d0,bltcon0(A1)	       ; set up new one

You obviously already have the _shft value shifted up to bit 12-15. Add
th constant $BFA to _shft as well so that it contains $xBFA where x is the
shift value. Then the code here gets:

      move.w  _shft,bltcon0(a1)

All those variable references go faster if you have them PC-relative or even
better in a register.

>      move.w	_blitSize,bltsize(A1)	; start blit going
>      unlk	A5		 ; unlink subroutine
>      rts		       ; return


Let those circles fly!

/Joakim Rosqvist     ($DR.HEX$)   Email to: dvljrt@cs.umu.se
----------------------------------
Hi! I am a .signature virus. Copy me into your .signature to join in!
Newsgroups: comp.sys.amiga.programmer