- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / rom / intuition / pointerclass.c
blob6af27da56fd4029f1004f01f286077640f3bb011
1 /*
2 Copyright © 1995-2005, 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 /***********************************************************************************/
29 #undef IntuitionBase
30 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
32 /***********************************************************************************/
34 UWORD posctldata[] =
36 0x0000,0x0000
39 /***********************************************************************************/
41 IPTR PointerClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
43 D(kprintf("PointerClass: OM_NEW\n"));
45 if (cl)
47 struct TagItem *tags = msg->ops_AttrList;
48 struct BitMap *bitmap = (struct BitMap *)GetTagData(POINTERA_BitMap, (IPTR)NULL, tags);
50 //ULONG xResolution = GetTagData(POINTERA_XResolution, POINTERXRESN_DEFAULT, tags);
51 //ULONG yResolution = GetTagData(POINTERA_YResolution, POINTERYRESN_DEFAULT, tags);
55 struct TagItem *tagscan=tags;
57 while(tagscan->ti_Tag != 0)
59 kprintf(" 0x%08lx, %08lx\n",tagscan->ti_Tag,tagscan->ti_Data);
60 tagscan++;
65 if (1) // bitmap
67 struct TagItem spritetags[] =
69 {SPRITEA_Width , 0 },
70 {TAG_SKIP , 0 },
71 {TAG_SKIP , 0 },
72 {TAG_DONE }
74 struct ExtSprite *sprite;
75 struct BitMap *spritedata=(struct BitMap *)bitmap;
77 if(spritedata != NULL)
79 spritetags[0].ti_Data = GetTagData(POINTERA_WordWidth,
80 ((GetBitMapAttr(bitmap, BMA_WIDTH) + 15) & ~15)>>4, tags) * 16;
81 spritetags[1].ti_Tag = TAG_SKIP;
82 spritetags[2].ti_Tag = TAG_SKIP;
84 else
86 D(kprintf("PointerClass: OM_NEW called without bitmap, using dummy sprite !\n"));
88 spritetags[0].ti_Data = 16;
89 spritetags[1].ti_Tag = SPRITEA_OutputHeight;
90 spritetags[1].ti_Data = 1;
91 spritetags[2].ti_Tag = SPRITEA_OldDataFormat;
92 spritetags[2].ti_Data = TRUE;
93 bitmap = (struct BitMap *)posctldata;
97 sprite = AllocSpriteDataA(bitmap, spritetags);
99 D(kprintf("PointerClass: extSprite 0x%lx\n",sprite));
100 D(kprintf("MoveSprite data 0x%lx, height %ld, x %ld, y %ld, num %ld, wordwidth, 0x%lx, flags 0x%lx\n",
101 sprite->es_SimpleSprite.posctldata,
102 sprite->es_SimpleSprite.height,
103 sprite->es_SimpleSprite.x,
104 sprite->es_SimpleSprite.y,
105 sprite->es_SimpleSprite.num,
106 sprite->es_wordwidth,
107 sprite->es_flags));
109 if (sprite)
111 struct SharedPointer *shared = CreateSharedPointer(sprite,
112 GetTagData(POINTERA_XOffset, 0, tags),
113 GetTagData(POINTERA_YOffset, 0, tags),
114 IntuitionBase);
116 if (shared)
118 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
120 if (o)
122 struct PointerData *data = INST_DATA(cl, o);
124 data->shared_pointer = shared;
125 //data->xRes = xResolution;
126 //data->yRes = yResolution;
127 D(kprintf("PointerClass: set extSprite 0x%lx and XOffset %ld YOffset %ld\n",shared->sprite,shared->xoffset,shared->yoffset));
129 else
131 D(kprintf("PointerClass: free sprite\n"));
132 ReleaseSharedPointer(shared, IntuitionBase);
135 else
137 D(kprintf("PointerClass: free sprite\n"));
138 FreeSpriteData(sprite);
142 else
144 D(kprintf("PointerClass: OM_NEW called without bitmap !\n"));
148 return (IPTR)o;
151 /***********************************************************************************/
153 IPTR PointerClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
155 struct PointerData *data = INST_DATA(cl, o);
157 D(kprintf("PointerClass: OM_GET\n"));
159 switch (msg->opg_AttrID)
161 case POINTERA_SharedPointer:
162 *msg->opg_Storage = (IPTR)data->shared_pointer;
163 break;
165 case POINTERA_XOffset:
166 *msg->opg_Storage = data->shared_pointer->xoffset;
167 break;
169 case POINTERA_YOffset:
170 *msg->opg_Storage = data->shared_pointer->yoffset;
171 break;
173 default:
174 return DoSuperMethodA(cl, o, (Msg)msg);
176 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));
178 return (IPTR)1;
181 /***********************************************************************************/
183 IPTR PointerClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
185 struct PointerData *data = INST_DATA(cl, o);
187 D(kprintf("PointerClass: OM_DISPOSE\n"));
188 D(kprintf("PointerClass: extSprite 0x%lx\n",data->shared_pointer->sprite));
189 ReleaseSharedPointer(data->shared_pointer, IntuitionBase);
191 return DoSuperMethodA(cl, o, msg);
194 /***********************************************************************************/