WIP: add an initial skeleton for a real scsi.device based upon the ata device impleme...
[AROS.git] / rom / intuition / pointerclass.c
blobf8e3ae6a38d0726d113b7e2eda79324d60f6216b
1 /*
2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <hidd/gfx.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"
22 #undef DEBUG
23 #define DEBUG 0
24 #include <aros/debug.h>
26 #include <aros/asmcall.h>
28 /***********************************************************************************/
30 /* Empty sprite */
31 const UWORD posctldata[] =
33 0x0000,0x0000, /* posctl */
34 0x0000,0x0000, /* Empty pixels, one line */
35 0x0000,0x0000 /* Reserved */
38 /***********************************************************************************/
40 #define DEF_POINTER_DEPTH 4
42 IPTR PointerClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
44 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
45 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
46 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
47 OOP_MethodID HiddBitMapBase = ((struct IntIntuitionBase *)IntuitionBase)->ib_HiddBitMapBase;
48 D(kprintf("[Pointer] %s()\n", __func__));
50 if (cl)
52 struct TagItem spritetags[] =
54 {SPRITEA_Width , 0 },
55 {SPRITEA_OutputHeight , 0 },
56 {SPRITEA_OldDataFormat, TRUE},
57 {TAG_DONE }
59 struct ExtSprite *sprite;
60 struct TagItem *tags = msg->ops_AttrList;
61 struct BitMap *bitmap = (struct BitMap *)GetTagData(POINTERA_BitMap, (IPTR)NULL, tags);
63 /* Hack: we accept and pass on to AllocSpriteDataA() these attributes in order to
64 provide code reuse. Applications should not rely on it, this is private! */
65 BOOL oldbitmap = GetTagData(SPRITEA_OldDataFormat, FALSE, tags);
66 IPTR width = GetTagData(SPRITEA_Width, 16, tags);
67 IPTR height = GetTagData(SPRITEA_OutputHeight, 0, tags);
69 //ULONG xResolution = GetTagData(POINTERA_XResolution, POINTERXRESN_DEFAULT, tags);
70 //ULONG yResolution = GetTagData(POINTERA_YResolution, POINTERYRESN_DEFAULT, tags);
74 struct TagItem *tagscan=tags;
76 kprintf("[Pointer] %s: Pointer BitMap @ %p\n", __func__, bitmap);
77 while(tagscan->ti_Tag != 0)
79 kprintf("[Pointer] %s: 0x%08lx, %08lx\n", __func__, tagscan->ti_Tag, tagscan->ti_Data);
80 tagscan++;
85 if (bitmap)
87 if (oldbitmap) {
88 spritetags[0].ti_Data = width;
89 spritetags[1].ti_Data = height;
90 } else {
91 spritetags[0].ti_Data = GetTagData(POINTERA_WordWidth, ((GetBitMapAttr(bitmap, BMA_WIDTH) + 15) & ~15)>>4, tags) * 16;
92 spritetags[1].ti_Tag = TAG_DONE;
95 else
97 D(kprintf("[Pointer] %s: called without bitmap, using dummy sprite !\n", __func__));
99 spritetags[0].ti_Data = 16;
100 spritetags[1].ti_Data = 1;
101 bitmap = (struct BitMap *)posctldata;
104 sprite = AllocSpriteDataA(bitmap, spritetags);
107 kprintf("[Pointer] %s: extSprite 0x%lx\n", __func__, sprite);
108 kprintf("[Pointer] %s: MoveSprite data 0x%lx, height %ld, x %ld, y %ld, num %ld, wordwidth, 0x%lx, flags 0x%lx\n",
109 __func__,
110 sprite->es_SimpleSprite.posctldata,
111 sprite->es_SimpleSprite.height,
112 sprite->es_SimpleSprite.x,
113 sprite->es_SimpleSprite.y,
114 sprite->es_SimpleSprite.num,
115 sprite->es_wordwidth,
116 sprite->es_flags);
119 if (sprite)
121 struct SharedPointer *shared;
123 /* If our pointer doesn't already have a user-supplied colormap, we attach it here.
124 This makes the pointer to always have its own colors on hi- and truecolor screens.
125 In addition it gets an alpha channel.
126 Note that this relies on the fact that AllocSpriteDataA() always generates HIDD bitmap
127 in sprite->es_BitMap. */
128 if (!HIDD_BM_COLMAP(sprite->es_BitMap)) {
129 ULONG i;
130 HIDDT_Color col[DEF_POINTER_DEPTH] = {{0}};
131 struct Color32 *q = GetPrivIBase(IntuitionBase)->Colors;
133 for (i = 1; i < DEF_POINTER_DEPTH; i++ ) {
134 col[i].red = q[i + 7].red >> 16;
135 col[i].green = q[i + 7].green >> 16;
136 col[i].blue = q[i + 7].blue >> 16;
137 col[i].alpha = GetPrivIBase(IntuitionBase)->PointerAlpha;
139 HIDD_BM_SetColors(HIDD_BM_OBJ(sprite->es_BitMap), col, 0, DEF_POINTER_DEPTH);
142 shared = CreateSharedPointer(sprite,
143 GetTagData(POINTERA_XOffset, 0, tags),
144 GetTagData(POINTERA_YOffset, 0, tags),
145 IntuitionBase);
147 if (shared)
149 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
151 if (o)
153 struct PointerData *data = INST_DATA(cl, o);
155 data->shared_pointer = shared;
156 //data->xRes = xResolution;
157 //data->yRes = yResolution;
158 D(kprintf("[Pointer] %s: set extSprite 0x%lx and XOffset %ld YOffset %ld\n",
159 __func__,
160 shared->sprite,
161 shared->xoffset,
162 shared->yoffset));
164 else
166 D(kprintf("[Pointer] %s: releasing shared pointer\n", __func__));
167 ReleaseSharedPointer(shared, IntuitionBase);
170 else
172 D(kprintf("[Pointer] %s: freeing sprite data\n", __func__));
173 FreeSpriteData(sprite);
178 return (IPTR)o;
181 /***********************************************************************************/
183 IPTR PointerClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
185 struct PointerData *data = INST_DATA(cl, o);
187 D(kprintf("[Pointer] %s()\n", __func__));
189 switch (msg->opg_AttrID)
191 case POINTERA_SharedPointer:
192 D(kprintf("[Pointer] %s: current extSprite 0x%lx\n", __func__, data->shared_pointer->sprite));
193 *msg->opg_Storage = (IPTR)data->shared_pointer;
194 break;
196 case POINTERA_XOffset:
197 D(kprintf("[Pointer] %s: current XOffset %ld\n", __func__, data->shared_pointer->xoffset));
198 *msg->opg_Storage = data->shared_pointer->xoffset;
199 break;
201 case POINTERA_YOffset:
202 D(kprintf("[Pointer] %s: current YOffset %ld\n", __func__, data->shared_pointer->yoffset));
203 *msg->opg_Storage = data->shared_pointer->yoffset;
204 break;
206 default:
207 return DoSuperMethodA(cl, o, (Msg)msg);
211 return (IPTR)1;
214 /***********************************************************************************/
216 IPTR PointerClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
218 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
219 struct PointerData *data = INST_DATA(cl, o);
222 kprintf("[Pointer] %s()\n", __func__);
223 kprintf("[Pointer] %s: extSprite 0x%lx\n", __func__, data->shared_pointer->sprite);
225 ReleaseSharedPointer(data->shared_pointer, IntuitionBase);
227 return DoSuperMethodA(cl, o, msg);
230 /***********************************************************************************/