This is an old version from the tos.hyp. The new is on GitHub!

HomeLine-AUndraw spriteCopy raster form

6.18 Draw sprite

Name: ğDraw spriteĞ
Line-A number: $A00D
Syntax: See 'Bindings for draw_sprite'
Description: This Line-A function draws a sprite on the screen. The X-position is passed in D0, the Y-position in d1. A0 points to a structure of the type SDB that describes the construction of the sprite. A2 points to the sprite-save buffer which stores the saved background and has to have a minimum size of 10 + 64 * number of colour planes. The register A6 will be destroyed.
typedef struct
{
  int16_t xhot,       /* X-offset                   */
          yhot,       /* Y-offset                   */
          form,       /* Format (1 = VDI, -1 = XOR) */
          bgcol,      /* Background colour          */
          fgcol,      /* Foreground colour          */
          image[32];  /* Sprite image               */
} SDB;
Variable Meaning
   
xhot X-coordinate of the hot-spot of the sprite, as for Transform mouse
yhot Y-coordinate of the hot-spot of the sprite, as for Transform mouse
form 1 for the VDI format and -1 for the XOR format
bgcol The colour of the background
fgcol The colour of the foreground
image The data for the foreground and the background of the 16*16 pixel-sized sprite. The data is stored interleaved - first a WORD of the background and then a WORD of the foreground.


The result on the screen depends on the format set in form and can be gathered for each 1 bit from the foreground and background data from the following table. Old is the existing image point, new the new one after drawing the sprite:

Foregrnd. Backgrnd. VDI format XOR format
0 0 new = old new = old
0 1 new = bgcol new = bgcol
1 0 new = fgcol new = fgcol xor old
1 1 new = fgcol new = fgcol
Return value: The function does not return a result.
Availability: All TOS versions.
See also: Binding   Transform mouse   Undraw sprite

6.18.1 Bindings for draw_sprite

Pure-C:
typedef struct
{
  int16_t xhot,       /* X-offset                   */
          yhot,       /* Y-offset                   */
          form,       /* Format (1 = VDI, -1 = XOR) */
          bgcol,      /* Background colour          */
          fgcol,      /* Foreground colour          */
          image[32];  /* Sprite image               */
} SDB;

typedef int16_T SSB[10 + 4 * 64];

void draw_sprite( int16_t x, int16_t y, SDB *pSdb, SSB *pSsb );
Assembler:
movem.l   D0-D2/A0-A2/A6,-(A7) ; Save registers
move.w    x,D0                 ; X-position to D0
move.w    y,D1                 ; Y-position to D1
move.l    pSdb,A0              ; Pointer sprite-definition block to A0
move.l    pSsb,A2              ; Pointer sprite-save block to A2
dc.w      $A00D                ; Line-A opcode
movem.l   (A7)+,D0-D2/A0-A2/A6 ; Restore registers

HomeLine-AUndraw spriteCopy raster form