2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function GetSprite()
8 #include <graphics/gfxbase.h>
9 #include <graphics/sprite.h>
10 #include <proto/exec.h>
11 #include "graphics_intern.h"
13 /*****************************************************************************
16 #include <proto/graphics.h>
18 AROS_LH2(WORD
, GetSprite
,
21 AROS_LHA(struct SimpleSprite
*, sprite
, A0
),
22 AROS_LHA(WORD
, pick
, D0
),
25 struct GfxBase
*, GfxBase
, 68, Graphics
)
28 Try to get a hardware sprite for the simple sprite manager.
29 There are eight sprites available in the system and by calling
30 this function you can allocate one for yourself. You have to
31 call this function before talking to other sprite routines.
32 If you want a 15 color sprite, you must allocate both sprites
33 (see the manual!) and set the SPRITE_ATTACHED bit in the
34 odd sprite's posctldata array.
38 sprite - pointer to a SimpleSprite structure
39 pick - number of the sprite (0-7) of -1 if you just want
40 the next available sprite
43 -1 - if the selected sprite is not available (pick was 0-7) or
44 no further sprites are available (pick was -1). -1 will
45 also be found in the SimpleSprite structure.
46 0-7: The sprite number of your allocated sprite. The number will
47 also be found in the SimpleSprite structure.
54 On some machines this will never return anything else than -1!
57 FreeSprite(), ChangeSprite(), MoveSprite(), GetSprite(), graphics/sprite.h
63 *****************************************************************************/
69 if (pick
> 7 && pick
!= -1) {
72 /* let nobody else interrupt us while we're looking for a free
79 /* user just wants the next available sprite */
82 /* look for the first not allocated sprite */
83 while (0 != (GfxBase
->SpriteReserved
& SearchMask
) && Count
< 8) {
89 /* we were able to allocated a free sprite */
90 /* mark the sprite as reserved for the user */
91 GfxBase
->SpriteReserved
|= SearchMask
;
94 /* no sprite was available for the user */
99 /* user wants one specific sprite */
100 SearchMask
= 0x01 << pick
;
102 /* is that sprite still available? */
103 if (0 == (GfxBase
->SpriteReserved
& SearchMask
) ) {
104 /* yes -> mark it as reserved for the user */
105 GfxBase
->SpriteReserved
|= SearchMask
;
107 /* no, it's not available any more */