Drag A Sprite

Introduction

The DragASprite module provides SWI calls with which you can make the pointer drag a sprite around the screen. Since not all users will prefer this effect to dragging an outline - whether for aesthetics or performance - there is a bit in the CMOS RAM used to indicate their preference. (See the chapter entitled Non-volatile memory (CMOS RAM).) You should examine that bit before using this module; if it shows that the user would prefer to drag outlines, oblige them!

To drag a sprite:

  1. Prepare a sprite to be dragged (this may be trivial, as the application may have a suitable sprite already to hand).
  2. Call the SWI SWI DragASprite_Start. This takes a copy of your sprite - so you can dispose of your copy whenever you like - and then starts a Wimp drag.
  3. When the Wimp sends you an indication that your drag has finished, you should call the SWI SWI DragASprite_Stop to release the workspace used for the drag.

SWI calls

DragASprite_StartSWI &42400
Start a sprite drag operation
R0=flags :
Bit(s)Meaning
0 - 1Horizontal location of sprite in box:
Bit(s)Meaning
00left
01centre
10right
2 - 3Vertical location of sprite in box:
Bit(s)Meaning
00bottom
01centre
10top
4 - 5Drag bounding box is:
Bit(s)Meaning
00whole screen
01display area of window that the pointer's over
10specified in block pointed to by R4
6Bounding box applies to:
Bit(s)Meaning
0the box
1the pointer
7Control of drop-shadow:
Bit(s)Meaning
0don't do a drop-shadow
1make a drop shadow when copying the sprite
8Control of translucency (just cross-hatching in current version):
Bit(s)Meaning
0dragged sprite will be translucent
1dragged sprite will be solid
9Control of sprite centering:
Bit(s)Meaning
0sprite position is determined by bits 0 - 3
1sprite will be centered on the pointer
10 - 31Reserved for future use - should be set to 0
R1=sprite area holding sprite:
ValueMeaning
0system sprite area
1wimp sprite area
Otheraddress of sprite area
R2=pointer to sprite name
R3=pointer to 16-byte block containing box
R4=pointer to optional 16-byte block containing bounding box (see flags)
R0 - R4preserved
Interrupts are undefined
Fast interrupts are enabled
Processor is in SVC mode
Not defined

This call starts dragging a sprite. The sprite you supply is copied, so there is no problem if you dispose of your copy of the sprite. If there is insufficient memory available to start the drag, the call reverts to a normal drag of a dotted outline.

The blocks pointed to by R3 and - optionally - R4 have the following format:

OffsetNameUse
0x-low
4y-lowbottom-left (x-low, y-low) is inclusive
8x-hightop-right (x-high, y-high) is exclusive
12y-high
DragASprite_StopSWI &42401
Terminates any current drag operation, and releases workspace
None
None
Interrupts are undefined
Fast interrupts are enabled
Processor is in SVC mode
Not defined

This call terminates any current drag operation, and releases any workspace claimed by the DragASprite module to do a drag. You should make this call when your application receives the User_Drag_Box reason code from SWI Wimp_Poll during a drag.