2 Copyright © 1995-2001, 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 ******************************************************************************/
63 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
65 struct ExtSprite
*sprite
= NULL
;
68 #define SCALE_NORMAL 16
69 ULONG height
= (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
);
71 struct TagItem
* tstate
= tagList
;
73 struct BitScaleArgs bsa
;
74 LONG xrep
= 0, yrep
= 0;
76 memset(&bsa
, 0, sizeof(bsa
));
78 while (NULL
!= (tag
= NextTagItem(&tstate
))) {
79 switch (tag
->ti_Tag
) {
84 case SPRITEA_XReplication
:
88 case SPRITEA_YReplication
:
92 case SPRITEA_OutputHeight
:
93 if (tag
->ti_Data
> (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
)) {
96 height
= tag
->ti_Data
;
99 case SPRITEA_Attached
:
106 sprite
= AllocVec(sizeof(*sprite
), MEMF_PUBLIC
| MEMF_CLEAR
);
107 if (NULL
!= sprite
) {
109 bsa
.bsa_SrcWidth
= GetBitMapAttr(bitmap
, BMA_WIDTH
);
110 bsa
.bsa_SrcHeight
= GetBitMapAttr(bitmap
, BMA_HEIGHT
);
113 bsa
.bsa_XDestFactor
= SCALE_NORMAL
<< xrep
;
115 bsa
.bsa_XDestFactor
= SCALE_NORMAL
>> (-xrep
);
119 bsa
.bsa_YDestFactor
= SCALE_NORMAL
<< yrep
;
121 bsa
.bsa_YDestFactor
= SCALE_NORMAL
>> (-yrep
);
124 bsa
.bsa_XSrcFactor
= SCALE_NORMAL
;
125 bsa
.bsa_YSrcFactor
= SCALE_NORMAL
;
126 bsa
.bsa_SrcBitMap
= bitmap
;
127 bsa
.bsa_DestBitMap
= AllocBitMap(width
,
130 BMF_CLEAR
|BMF_DISPLAYABLE
,
134 sprite
->es_SimpleSprite
.height
= height
;
135 sprite
->es_SimpleSprite
.x
= 0;
136 sprite
->es_SimpleSprite
.y
= 0;
137 sprite
->es_SimpleSprite
.num
= 0;
138 sprite
->es_wordwidth
= width
>> 4;
139 sprite
->es_flags
= 0;
140 sprite
->es_BitMap
= bsa
.bsa_DestBitMap
;
147 } /* AllocSpriteDataA */