home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.atari.st.tech
- Path: sparky!uunet!decwrl!pa.dec.com!decprl!decprl!amos
- From: amos@prl.dec.com (Samos)
- Subject: The ultimate sprite routine, Generated code and the other one..
- Message-ID: <1992Aug27.083319.11106@prl.dec.com>
- Sender: amos@prl.dec.com (Amos Rosenberg)
- Nntp-Posting-Host: prl341.prl.dec.com
- Organization: Digital Equipment Corporation - Paris Research Laboratory
- Date: Thu, 27 Aug 1992 08:33:19 GMT
- Lines: 65
-
- For color monitors (4 bit-plans)
-
- Less memory :
-
- In fact, the best routine before the generated code was the preshifted one, but
- I've got an optimisation :
- Let's say you preshift 16 times a sprite, and also the masks.
- For the masks, you should also have twice the same mask for 8 bytes, (so a mask would take
- 4 bytes instead of 2..)
-
- The routine would go like this :
- lea mask_predecal,a0
- lea Sprite_predecal,a1
- lea Screen_address,a2
-
- you have the x and y, in d0-d1
- so y*160 + (x >> 4) << 3 for the screen offset, and (x && 15) for the sprtie decal pointer.
-
- then x*sprite_size to point on the sprite shifted at (x && 15) position, + a1
-
- then movem.l d1-dx/a3-ax (x for left registers you have)
- move.l (a0)+,d0
- and.l d0,(a1)
- or.l d1,(a1)+
- and.l d0,(a1)
- or.l d2,(a1)+
- ... for the sprite size .
- So here, you have optimized and with the movem, and with the double masks..
-
-
-
- Generated code, the best, but it takes a lot of memory:
-
- Let's imagine the sprite. If you poke as warwick@cs.uq.oz.au (Warwick Allison) said,
- directly the code at the screen with the masks like :
- and.l #xxx,y(a0)
- or.l #www,y(a0)
- ...
-
- And if you generate this code, instead of typing all the xxx yyy zzz too many times..
- you generate the and.l #xxx,y(a0) in memory (I do not remember how it is exactly coded..),
- then you would have to jump in the address where the sprite is printed !
- So you make a routine that looks at the sprite, and generate and.l and or.l, and shifts
- the sprites, then you look at the x offset and just jump in the routine you have made in
- the beginning of the program. Now, the other advantage, is that when you see that the sprite
- has 16 black pixels, as it is a sprite, you generally and.l #$ffff,(a0) or.l #0,(a0)
- so here you do not and anything and just increments a0 ! you save precious cycles..
- If you want to push the routine as its best optimization, in your routine at the begging
- you redraw the sprites : try to see the 4 colors that appear the more in the sprite, and
- put them on different plans, the other colors on the 11 left colors, then you would often
- have only to or.l 1 plan (but still masking 4) because the color is always in his 16 pix. blocks.
-
- By re-reading me, it looks very confused. If you want more information about generated code, or
- a source, just ask it..
-
-
- The results are : on a 8Mhz STf, 20 32*32 sprites in 1 VBL ! or huge sprites.. very cool
-
- Amos.
-
-
-
-
-
-
-