2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function AllocSpriteDataA()
8 #include <proto/exec.h>
9 #include <proto/graphics.h>
10 #include <proto/utility.h>
11 #include <aros/debug.h>
12 #include <graphics/gfx.h>
13 #include <graphics/sprite.h>
14 #include <graphics/scale.h>
15 #include <utility/tagitem.h>
16 #include <exec/exec.h>
18 #include "graphics_intern.h"
20 /*****************************************************************************
23 #include <proto/graphics.h>
25 AROS_LH2(struct ExtSprite
*, AllocSpriteDataA
,
28 AROS_LHA(struct BitMap
*, bitmap
, A2
),
29 AROS_LHA(struct TagItem
*, tagList
, A1
),
32 struct GfxBase
*, GfxBase
, 170, Graphics
)
37 bitmap - pointer to a bitmap. This bitmap provides the source data
39 tags - pointer to a taglist
42 SpritePtr - pointer to a ExtSprite structure,
43 or NULL if there is a failure.
44 You should pass this pointer to FreeSpriteData()
45 when this sprite is not needed anymore.
60 ******************************************************************************/
64 struct ExtSprite
*sprite
= NULL
;
67 #define SCALE_NORMAL 16
68 ULONG height
= (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
);
70 struct TagItem
* tstate
= tagList
;
72 struct BitScaleArgs bsa
;
73 LONG xrep
= 0, yrep
= 0;
75 memset(&bsa
, 0, sizeof(bsa
));
77 while (NULL
!= (tag
= NextTagItem(&tstate
))) {
78 switch (tag
->ti_Tag
) {
83 case SPRITEA_XReplication
:
87 case SPRITEA_YReplication
:
91 case SPRITEA_OutputHeight
:
92 if (tag
->ti_Data
> (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
)) {
95 height
= tag
->ti_Data
;
98 case SPRITEA_Attached
:
105 sprite
= AllocVec(sizeof(*sprite
), MEMF_PUBLIC
| MEMF_CLEAR
);
106 if (NULL
!= sprite
) {
108 bsa
.bsa_SrcWidth
= GetBitMapAttr(bitmap
, BMA_WIDTH
);
109 bsa
.bsa_SrcHeight
= GetBitMapAttr(bitmap
, BMA_HEIGHT
);
112 bsa
.bsa_XDestFactor
= SCALE_NORMAL
<< xrep
;
114 bsa
.bsa_XDestFactor
= SCALE_NORMAL
>> (-xrep
);
118 bsa
.bsa_YDestFactor
= SCALE_NORMAL
<< yrep
;
120 bsa
.bsa_YDestFactor
= SCALE_NORMAL
>> (-yrep
);
123 bsa
.bsa_XSrcFactor
= SCALE_NORMAL
;
124 bsa
.bsa_YSrcFactor
= SCALE_NORMAL
;
125 bsa
.bsa_SrcBitMap
= bitmap
;
126 bsa
.bsa_DestBitMap
= AllocBitMap(width
,
129 BMF_CLEAR
|BMF_DISPLAYABLE
,
133 sprite
->es_SimpleSprite
.height
= height
;
134 sprite
->es_SimpleSprite
.x
= 0;
135 sprite
->es_SimpleSprite
.y
= 0;
136 sprite
->es_SimpleSprite
.num
= 0;
137 sprite
->es_wordwidth
= width
>> 4;
138 sprite
->es_flags
= 0;
139 sprite
->es_BitMap
= bsa
.bsa_DestBitMap
;
146 } /* AllocSpriteDataA */