2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Internal function for improved gels handling.
8 #include <aros/debug.h>
10 #include <graphics/gels.h>
11 #include <graphics/rastport.h>
12 #include <exec/memory.h>
13 #include <proto/graphics.h>
14 #include <proto/exec.h>
15 #include "gels_internal.h"
16 #include "graphics_intern.h"
18 struct IntVSprite
* _CreateIntVSprite(struct VSprite
* vs
,
20 struct GfxBase
* GfxBase
)
22 struct IntVSprite
* ivs
= AllocMem(sizeof(struct IntVSprite
),
29 * Don't call the validate function when rp=NULL, i.e. when
30 * called by InitGels().
33 _ValidateIntVSprite(ivs
,
42 VOID
_DeleteIntVSprite(struct VSprite
* vs
,
43 struct GfxBase
* GfxBase
)
45 struct IntVSprite
* ivs
= vs
->IntVSprite
;
48 if (NULL
!= ivs
->ImageData
)
49 FreeBitMap(ivs
->ImageData
);
51 if (NULL
!= ivs
->SaveBuffer
)
52 FreeBitMap(ivs
->SaveBuffer
);
54 FreeMem(ivs
, sizeof(struct IntVSprite
));
55 vs
->IntVSprite
= NULL
;
61 * Check whether the appearance of the VSprite has been changed
62 * somehow. If for example the Image Data has changed, then
63 * I will try to update the BitMap of the IntVSprite structure
64 * to the new image data.
66 BOOL
_ValidateIntVSprite(struct IntVSprite
* ivs
,
69 struct GfxBase
* GfxBase
)
71 struct VSprite
* vs
= ivs
->VSprite
;
73 * Check whether the ImageData pointer has changed
75 if (vs
->ImageData
!= ivs
->OrigImageData
||
80 kprintf("%s: Imagedata has changed (old:%p-new:%p)!\n",
84 kprintf("PlanePick: %02x, rp->BitMap:%p\n",vs
->PlanePick
,rp
->BitMap
);
87 * Only need to get a new bitmap if
88 * something in the size of the bob has changed.
90 if ((ivs
->Width
!= vs
->Width
) ||
91 (ivs
->Height
!= vs
->Height
) ||
92 (ivs
->Depth
!= vs
->Depth
) ) {
93 if (NULL
!= ivs
->ImageData
)
94 FreeBitMap(ivs
->ImageData
);
96 if (NULL
!= ivs
->SaveBuffer
)
97 FreeBitMap(ivs
->SaveBuffer
);
99 * Now get a new bitmap
102 ivs
->ImageData
= AllocBitMap(vs
->Width
<<4,
108 ivs
->SaveBuffer
= AllocBitMap(vs
->Width
<<4,
113 ivs
->Width
= vs
->Width
;
114 ivs
->Height
= vs
->Height
;
115 ivs
->Depth
= vs
->Depth
;
118 ivs
->OrigImageData
= vs
->ImageData
;
121 * Blit the image data from the VSprite into the
122 * ImageData (BitMap) of the IntVSprite
130 UBYTE
*imagedata
= (UBYTE
*)vs
->ImageData
;
133 for (d
= 0, shift
= 1; d
< 8; d
++, shift
*= 2)
135 if (vs
->PlanePick
& shift
)
137 bm
.Planes
[d
] = imagedata
;
138 imagedata
+= (bm
.Rows
* bm
.BytesPerRow
);
142 bm
.Planes
[d
] = (vs
->PlaneOnOff
& shift
) ? (PLANEPTR
)-1 : NULL
;
166 * Erase the VSprite from the list and follow the clear path
167 * first, if necessary! This way of organizing the ClearPath
168 * makes it easy to implement RemIBob but it leads to a recursion!
169 * RemIBob could simply call this function here and then redraw
171 * If a recursion is not what we want this can be easily
175 void _ClearBobAndFollowClearPath(struct VSprite
* CurVSprite
,
176 struct RastPort
* rp
,
177 struct GfxBase
* GfxBase
)
180 * If the bob has not been drawn, yet, then don't do anything.
181 * If the bob has already been cleared, then also leave here!
182 * It does happen that this routine gets called for
183 * a sprite that has been cleared already.
185 if (0 != (CurVSprite
->VSBob
->Flags
& (BWAITING
|BOBNIX
))) {
186 CurVSprite
->VSBob
->Flags
&= ~BWAITING
;
190 if (NULL
!= CurVSprite
->ClearPath
) {
192 * Clear the next one first. (recursion!!!)
194 _ClearBobAndFollowClearPath(CurVSprite
->ClearPath
,
197 CurVSprite
->ClearPath
= NULL
;
202 * Only restore the background if the bob image
203 * that is currently there is to be replaced by
204 * the background. If SAVEBOB is set the user
205 * might want some kind of a brush effect.
208 if (0 == (CurVSprite
->Flags
& SAVEBOB
)) {
209 if (0 != (CurVSprite
->Flags
& BACKSAVED
)) {
210 BltBitMapRastPort(CurVSprite
->IntVSprite
->SaveBuffer
,
216 CurVSprite
->Width
<< 4,
219 CurVSprite
->Flags
&= ~BACKSAVED
;
221 } /* if (0 != (CurVSprite->Flags & BACKSAVED)) */
224 * No background was saved. So let's restore the
225 * standard background!
230 CurVSprite
->OldX
+ ( CurVSprite
->Width
<< 4 ) - 1,
231 CurVSprite
->OldY
+ CurVSprite
->Height
- 1);
234 * Mark the BOB as cleared.
236 CurVSprite
->VSBob
->Flags
|= BOBNIX
;
237 } /* if (0 == (CurVSprite->Flags & SAVEBOB)) */