[Main]
Name=Sprite8
Type=Function
Subtype=tigcc.a
Header Files=sprites.h
Definition=void Sprite8 (short x, short y, short height, const unsigned char *sprite, void *vm_addr, short mode);
See Also=sprites.h/ClipSprite8
[Library Call]
Asm=1
[Registers]
x=d0
y=d1
height=d2
sprite=a0
vm_addr=a1
mode=d3
[Description]
Draws a sprite with a width of 8 pixels or less on the screen.
[Explanation]
Sprite8 draws a sprite with a width of 8 pixels or less on the screen. See ClipSprite8
for a version that handles out-of-screen sprites gracefully, and Sprite16, ClipSprite16,
Sprite32 or ClipSprite32 for wider sprites.
This routine is much faster than TIOS routines such as DrawIcon,
BitmapPut, etc.
x and y are the coordinates of the upper left corner of the sprite.
height is the height of the sprite. sprite is a pointer to the array of
unsigned characters which define the shape of the sprite (line by line). vm_addr is the pointer
to the video plane; it should be LCD_MEM if you are not using
grayscale or the PortSet function. mode is the drawing
mode, and it may have one of the following values (these constants are defined in the enum
SprtModes):
SPRT_XOR | XOR the sprite into a background. This is used only for non-masked sprites. XOR mode switches every pixel with a corresponding '1' bit in the sprite array from white to black and verse vica. |
SPRT_OR | OR the sprite into a background. This is mainly used for masked sprites together with SPRT_AND. OR means that every pixel with a corresponding '1' bit in the sprite array will be set to black, but all other pixels stay the same. If you want to turn all other pixels to white instead, use SPRT_RPLC. |
SPRT_AND | AND the sprite into a background. This is used for masked sprites together with SPRT_OR. AND turns off every pixel with a corresponding '0' bit in the sprite array, but all other pixels remain untouched. If you want to turn all other pixels to black instead, use SPRT_RPLC. |
SPRT_RPLC | RePLaCe the sprite into a background.
RPLC sets every pixel with a corresponding '1' bit to black and every pixel with a corresponding '0' bit to white.
This is equivalent to calling Sprite8(x,y,h,sprite,plane,SPRT_AND); Sprite8(x,y,h,sprite,plane,SPRT_OR); . |
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
, but it needs to
be inverted before passing it to the Sprite8 function. For this purpose, the operator '~' may be
very useful. Note that '~' is "bitwise NOT". Of course, ~0xFF is the same as 0x00, but this notation
makes the program more clear (and it does not increase the code size, because the inverting will
be performed at compilation time). And if you want to use Sprite16,
ClipSprite16, Sprite32 or
ClipSprite32, the notation ~0xFF will still be valid in a short int
array, or in a long int array if you add the 'L' suffix (see the respective info about
Sprite32 and ClipSprite32).
Without this notation, you must use 0x00 in Sprite8, but 0xFF00 in
Sprite16/ClipSprite16, and
0xFFFFFF00 in Sprite32/ClipSprite32.
This is why a notation like ~0xFF is more universal.
static const unsigned char sprite[]={ 0b11111111, 0b10000001, 0b10000001, 0b10000001, 0b10000001, 0b10000001, 0b10000001, 0b11111111};