4 * Handling of pointer-shape changing
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Steel library.
13 * Steel is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Steel is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Steel. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 static BOOL pointer__notDefault;
39 * os_error *pointer__magicSpriteOp(sprite_area *a,
44 * Performs a sprite op of the appropriate kind for the sprite area given.
47 * sprite_area *a == the sprite area to do the op on
48 * sprite_id *sid == the sprite id to do it to
49 * os_regset r == other registers for the op
55 static os_error *pointer__magicSpriteOp(sprite_area *a,
59 if (a==(sprite_area *)1)
61 /* --- The WIMP sprite area --- */
64 r->r[2]=(int)sid->s.name;
65 return (os_swix(XWimp_SpriteOp,r));
69 /* --- The nasty system sprite area --- */
72 r->r[2]=(int)sid->s.name;
73 return (os_swix(XOS_SpriteOp,r));
77 /* --- A nice user sprite area --- */
83 r->r[2]=(int)sid->s.addr;
88 r->r[2]=(int)sid->s.name;
92 return (os_swix(XOS_SpriteOp,r));
97 * BOOL pointer__spriteExist(sprite_area *a,char *name)
100 * Returns whether a named sprite exists in the given area
103 * sprite_area *a == the sprite area
104 * char *name == the name of the sprite to test
107 * TRUE if the sprite is there
110 static BOOL pointer__spriteExist(sprite_area *a,char *name)
119 return (!pointer__magicSpriteOp(a,&sid,&r));
123 * os_error *pointer_set_shape(sprite_area *a,sprite_id *sid,int x,int y)
126 * Sets the pointer shape to be the pointer specified. If a pointer with
127 * name `name<dx><dy>' is found in the sprite area, that's used instead, and
128 * the active point is scaled assuming that the original was specified in
129 * mode-8 type coordinates.
132 * sprite_area *a == the sprite area containing the sprite
133 * sprite_id *sid == pointer to the sprite identifier (dumb idea)
134 * int x,int y == coordinates (in pixels) of the hot-spot
137 os_error *pointer_set_shape(sprite_area *a,sprite_id *sid,int x,int y)
145 /* --- Try and find a good match for the mode --- */
147 sprintf(buffer,"%s%i%i",sid->s.name,wimpt_dx(),wimpt_dy());
148 if (pointer__spriteExist(a,buffer))
158 /* --- Now set up the pointer shape --- */
161 r.r[3]=2; /* Set everything up as nicely as possible */
164 r.r[6]=r.r[7]=0; /* No translation table, no zoom box */
165 pointer__notDefault=TRUE;
166 return (pointer__magicSpriteOp(a,sid,&r));
170 * void pointer_reset_shape(void)
173 * Resets the pointer shape
176 void pointer_reset_shape(void)
178 if (pointer__notDefault)
180 pointer__notDefault=FALSE;