Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / intuition / pointerclass.c
blobc0aff2fa868cb061efafee3a9084ddc161de0e71
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <intuition/intuition.h>
8 #include <intuition/intuitionbase.h>
9 #include <intuition/classes.h>
10 #include <intuition/classusr.h>
11 #include <intuition/pointerclass.h>
12 #include <graphics/sprite.h>
14 #include <proto/exec.h>
15 #include <proto/intuition.h>
16 #include <proto/graphics.h>
17 #include <proto/utility.h>
19 #include "intuition_intern.h"
21 #undef DEBUG
22 #define DEBUG 0
23 #include <aros/debug.h>
25 #include <aros/asmcall.h>
27 struct PointerData
29 struct SharedPointer *shared_pointer;
32 /***********************************************************************************/
34 #undef IntuitionBase
35 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
37 /***********************************************************************************/
39 #define P(o) ((struct PointerData *)INST_DATA(cl,o))
41 /***********************************************************************************/
43 UWORD posctldata[] =
45 0x0000,0x0000
48 AROS_UFH3S(IPTR, dispatch_pointerclass,
49 AROS_UFHA(Class *, cl, A0),
50 AROS_UFHA(Object *, o, A2),
51 AROS_UFHA(Msg, msg, A1)
54 AROS_USERFUNC_INIT
56 IPTR retval = 0UL;
58 D(kprintf("PointerClass: cl 0x%lx o 0x%lx msg 0x%lx\n",cl,o,msg));
60 switch (msg->MethodID)
62 case OM_NEW:
63 D(kprintf("PointerClass: OM_NEW\n"));
65 if (cl)
67 struct TagItem *tags = ((struct opSet *)msg)->ops_AttrList;
68 struct BitMap *bitmap = (struct BitMap *)GetTagData(POINTERA_BitMap, NULL, tags);
70 //ULONG xResolution = GetTagData(POINTERA_XResolution, POINTERXRESN_DEFAULT, tags);
71 //ULONG yResolution = GetTagData(POINTERA_YResolution, POINTERYRESN_DEFAULT, tags);
75 struct TagItem *tagscan=tags;
77 while(tagscan->ti_Tag != 0)
79 kprintf(" 0x%08lx, %08lx\n",tagscan->ti_Tag,tagscan->ti_Data);
80 tagscan++;
85 if (1) // bitmap
87 struct TagItem spritetags[] =
89 {SPRITEA_Width , 0 },
90 {TAG_SKIP , 0 },
91 {TAG_SKIP , 0 },
92 {TAG_DONE }
94 struct ExtSprite *sprite;
95 struct BitMap *spritedata=(struct BitMap *)bitmap;
97 if(spritedata != NULL)
99 spritetags[0].ti_Data = GetTagData(POINTERA_WordWidth,
100 ((GetBitMapAttr(bitmap, BMA_WIDTH) + 15) & ~15)>>4, tags) * 16;
101 spritetags[1].ti_Tag = TAG_SKIP;
102 spritetags[2].ti_Tag = TAG_SKIP;
104 else
106 D(kprintf("PointerClass: OM_NEW called without bitmap, using dummy sprite !\n"));
108 spritetags[0].ti_Data = 16;
109 spritetags[1].ti_Tag = SPRITEA_OutputHeight;
110 spritetags[1].ti_Data = 1;
111 spritetags[2].ti_Tag = SPRITEA_OldDataFormat;
112 spritetags[2].ti_Data = TRUE;
113 bitmap = (struct BitMap *)posctldata;
117 sprite = AllocSpriteDataA(bitmap, spritetags);
119 D(kprintf("PointerClass: extSprite 0x%lx\n",sprite));
120 D(kprintf("MoveSprite data 0x%lx, height %ld, x %ld, y %ld, num %ld, wordwidth, 0x%lx, flags 0x%lx\n",
121 sprite->es_SimpleSprite.posctldata,
122 sprite->es_SimpleSprite.height,
123 sprite->es_SimpleSprite.x,
124 sprite->es_SimpleSprite.y,
125 sprite->es_SimpleSprite.num,
126 sprite->es_wordwidth,
127 sprite->es_flags));
129 if (sprite)
131 struct SharedPointer *shared = CreateSharedPointer(sprite,
132 GetTagData(POINTERA_XOffset, 0, tags),
133 GetTagData(POINTERA_YOffset, 0, tags),
134 IntuitionBase);
136 if (shared)
138 retval = (IPTR)DoSuperMethodA(cl, o, msg);
140 if (retval)
142 o = (Object *)retval;
143 P(o)->shared_pointer = shared;
144 //P(o)->xRes = xResolution;
145 //P(o)->yRes = yResolution;
146 D(kprintf("PointerClass: set extSprite 0x%lx and XOffset %ld YOffset %ld\n",shared->sprite,shared->xoffset,shared->yoffset));
148 else
150 D(kprintf("PointerClass: free sprite\n"));
151 ReleaseSharedPointer(shared, IntuitionBase);
154 else
156 D(kprintf("PointerClass: free sprite\n"));
157 FreeSpriteData(sprite);
161 else
163 D(kprintf("PointerClass: OM_NEW called without bitmap !\n"));
166 break;
168 case OM_GET:
170 struct opGet *gmsg = (struct opGet *)msg;
172 D(kprintf("PointerClass: OM_GET\n"));
173 retval = 1;
174 switch (gmsg->opg_AttrID)
176 case POINTERA_SharedPointer:
177 *gmsg->opg_Storage = (IPTR)P(o)->shared_pointer;
178 break;
180 case POINTERA_XOffset:
181 *gmsg->opg_Storage = P(o)->shared_pointer->xoffset;
182 break;
184 case POINTERA_YOffset:
185 *gmsg->opg_Storage = P(o)->shared_pointer->yoffset;
186 break;
188 default:
189 retval = DoSuperMethodA(cl, o, msg);
190 break;
192 D(kprintf("PointerClass: current extSprite 0x%lx and XOffset %ld YOffset %ld\n",P(o)->shared_pointer->sprite,P(o)->shared_pointer->xoffset,P(o)->shared_pointer->yoffset));
194 break;
196 case OM_DISPOSE:
197 D(kprintf("PointerClass: OM_DISPOSE\n"));
198 D(kprintf("PointerClass: extSprite 0x%lx\n",P(o)->shared_pointer->sprite));
199 ReleaseSharedPointer(P(o)->shared_pointer, IntuitionBase);
200 /* fall through */
201 default:
202 D(kprintf("PointerClass: DoSuperMethod MethodID 0x%lx\n",msg->MethodID));
203 retval = DoSuperMethodA(cl, o, msg);
204 break;
206 } /* switch */
209 D(kprintf("PointerClass: retval 0x%lx\n",retval));
210 return (retval);
212 AROS_USERFUNC_EXIT
213 } /* dispatch_pointerclass */
215 /***********************************************************************************/
217 #undef IntuitionBase
219 /***********************************************************************************/
221 struct IClass *InitPointerClass (struct IntuitionBase * IntuitionBase)
223 struct IClass *cl = NULL;
225 /* This is the code to make the image class...
227 if ((cl = MakeClass(POINTERCLASS, ROOTCLASS, NULL, sizeof(struct PointerData), 0)))
229 cl->cl_Dispatcher.h_Entry = (APTR)AROS_ASMSYMNAME(dispatch_pointerclass);
230 cl->cl_Dispatcher.h_SubEntry = NULL;
231 cl->cl_UserData = (IPTR)IntuitionBase;
233 AddClass (cl);
236 return (cl);
239 /***********************************************************************************/