2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <hidd/graphics.h>
8 #include <intuition/intuition.h>
9 #include <intuition/intuitionbase.h>
10 #include <intuition/classes.h>
11 #include <intuition/classusr.h>
12 #include <intuition/pointerclass.h>
13 #include <graphics/sprite.h>
15 #include <proto/exec.h>
16 #include <proto/intuition.h>
17 #include <proto/graphics.h>
18 #include <proto/utility.h>
20 #include "intuition_intern.h"
24 #include <aros/debug.h>
26 #include <aros/asmcall.h>
28 /***********************************************************************************/
31 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
33 /***********************************************************************************/
36 const UWORD posctldata
[] =
38 0x0000,0x0000, /* posctl */
39 0x0000,0x0000, /* Empty pixels, one line */
40 0x0000,0x0000 /* Reserved */
43 /***********************************************************************************/
45 #define DEF_POINTER_DEPTH 4
47 IPTR
PointerClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
49 D(kprintf("PointerClass: OM_NEW\n"));
53 struct TagItem
*tags
= msg
->ops_AttrList
;
54 struct BitMap
*bitmap
= (struct BitMap
*)GetTagData(POINTERA_BitMap
, (IPTR
)NULL
, tags
);
56 /* Hack: we accept and pass on to AllocSpriteDataA() these attributes in order to
57 provide code reuse. Applications should not rely on it, this is private! */
58 BOOL oldbitmap
= GetTagData(SPRITEA_OldDataFormat
, FALSE
, tags
);
59 IPTR width
= GetTagData(SPRITEA_Width
, 16, tags
);
60 IPTR height
= GetTagData(SPRITEA_OutputHeight
, 0, tags
);
62 //ULONG xResolution = GetTagData(POINTERA_XResolution, POINTERXRESN_DEFAULT, tags);
63 //ULONG yResolution = GetTagData(POINTERA_YResolution, POINTERYRESN_DEFAULT, tags);
67 struct TagItem
*tagscan
=tags
;
69 while(tagscan
->ti_Tag
!= 0)
71 kprintf(" 0x%08lx, %08lx\n",tagscan
->ti_Tag
,tagscan
->ti_Data
);
79 struct TagItem spritetags
[] =
82 {SPRITEA_OutputHeight
, 0 },
83 {SPRITEA_OldDataFormat
, TRUE
},
86 struct ExtSprite
*sprite
;
87 struct BitMap
*spritedata
=(struct BitMap
*)bitmap
;
89 if(spritedata
!= NULL
)
92 spritetags
[0].ti_Data
= width
;
93 spritetags
[1].ti_Data
= height
;
95 spritetags
[0].ti_Data
= GetTagData(POINTERA_WordWidth
, ((GetBitMapAttr(bitmap
, BMA_WIDTH
) + 15) & ~15)>>4, tags
) * 16;
96 spritetags
[1].ti_Tag
= TAG_DONE
;
101 D(kprintf("PointerClass: OM_NEW called without bitmap, using dummy sprite !\n"));
103 spritetags
[0].ti_Data
= 16;
104 spritetags
[1].ti_Data
= 1;
105 bitmap
= (struct BitMap
*)posctldata
;
109 sprite
= AllocSpriteDataA(bitmap
, spritetags
);
111 D(kprintf("PointerClass: extSprite 0x%lx\n",sprite
));
112 D(kprintf("MoveSprite data 0x%lx, height %ld, x %ld, y %ld, num %ld, wordwidth, 0x%lx, flags 0x%lx\n",
113 sprite
->es_SimpleSprite
.posctldata
,
114 sprite
->es_SimpleSprite
.height
,
115 sprite
->es_SimpleSprite
.x
,
116 sprite
->es_SimpleSprite
.y
,
117 sprite
->es_SimpleSprite
.num
,
118 sprite
->es_wordwidth
,
123 struct SharedPointer
*shared
;
125 /* If our pointer doesn't already have a user-supplied colormap, we attach it here.
126 This makes the pointer to always have its own colors on hi- and truecolor screens.
127 In addition it gets an alpha channel.
128 Note that this relies on the fact that AllocSpriteDataA() always generates HIDD bitmap
129 in sprite->es_BitMap. */
130 if (!sprite
->es_BitMap
->Planes
[2]) {
132 HIDDT_Color col
[DEF_POINTER_DEPTH
] = {{0}};
133 struct Color32
*q
= GetPrivIBase(IntuitionBase
)->Colors
;
135 for (i
= 1; i
< DEF_POINTER_DEPTH
; i
++ ) {
136 col
[i
].red
= q
[i
+ 7].red
>> 16;
137 col
[i
].green
= q
[i
+ 7].green
>> 16;
138 col
[i
].blue
= q
[i
+ 7].blue
>> 16;
139 col
[i
].alpha
= GetPrivIBase(IntuitionBase
)->PointerAlpha
;
141 HIDD_BM_SetColors((OOP_Object
*)sprite
->es_BitMap
->Planes
[0], col
, 0, DEF_POINTER_DEPTH
);
144 shared
= CreateSharedPointer(sprite
,
145 GetTagData(POINTERA_XOffset
, 0, tags
),
146 GetTagData(POINTERA_YOffset
, 0, tags
),
151 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
155 struct PointerData
*data
= INST_DATA(cl
, o
);
157 data
->shared_pointer
= shared
;
158 //data->xRes = xResolution;
159 //data->yRes = yResolution;
160 D(kprintf("PointerClass: set extSprite 0x%lx and XOffset %ld YOffset %ld\n",shared
->sprite
,shared
->xoffset
,shared
->yoffset
));
164 D(kprintf("PointerClass: free sprite\n"));
165 ReleaseSharedPointer(shared
, IntuitionBase
);
170 D(kprintf("PointerClass: free sprite\n"));
171 FreeSpriteData(sprite
);
177 D(kprintf("PointerClass: OM_NEW called without bitmap !\n"));
184 /***********************************************************************************/
186 IPTR
PointerClass__OM_GET(Class
*cl
, Object
*o
, struct opGet
*msg
)
188 struct PointerData
*data
= INST_DATA(cl
, o
);
190 D(kprintf("PointerClass: OM_GET\n"));
192 switch (msg
->opg_AttrID
)
194 case POINTERA_SharedPointer
:
195 *msg
->opg_Storage
= (IPTR
)data
->shared_pointer
;
198 case POINTERA_XOffset
:
199 *msg
->opg_Storage
= data
->shared_pointer
->xoffset
;
202 case POINTERA_YOffset
:
203 *msg
->opg_Storage
= data
->shared_pointer
->yoffset
;
207 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
209 D(kprintf("PointerClass: current extSprite 0x%lx and XOffset %ld YOffset %ld\n",data
->shared_pointer
->sprite
,data
->shared_pointer
->xoffset
,data
->shared_pointer
->yoffset
));
214 /***********************************************************************************/
216 IPTR
PointerClass__OM_DISPOSE(Class
*cl
, Object
*o
, Msg msg
)
218 struct PointerData
*data
= INST_DATA(cl
, o
);
220 D(kprintf("PointerClass: OM_DISPOSE\n"));
221 D(kprintf("PointerClass: extSprite 0x%lx\n",data
->shared_pointer
->sprite
));
222 ReleaseSharedPointer(data
->shared_pointer
, IntuitionBase
);
224 return DoSuperMethodA(cl
, o
, msg
);
227 /***********************************************************************************/