title: "vbmDrawSpriteE" description: TRSE built-in method (from IDE help)
vbmDrawSpriteE
Systems: VIC20
Parameters: a, a
vbmDrawSprite( [address1], [address2] );
- [address1] - pre-shifted address table for the left side of an 8x16 sprite
- [address2] - pre-shifted address table for the right side of an 8x16 sprite
Description
A simple sprite routine to display an 8x16 sprite on the bitmap using an EOR drawing operation.
Only two parameters are required; the addresses of the pre-shifted 'address table' for the left and right side of a sprite. The pre-shifted address table is a list of addresses to point to where each pre-shifted frame can be found in memory.
For example: $a000, $a080, $a1000, $a180
The address table will need to be defined if you import your sprites already pre-shifted. If you use the vbmSpriteShiftL / R commands, these will build the address table for you.
Limitations
Some compromises have been made for the basic 8x16 sprite command.
Firstly, it will write the sprite to wherever the built in screenmemory zero page pointer is pointing to. This could be partly outside of the bitmap memory ($1100 to $1FFF) if you position your sprite off of the screen edges. Therefore, do not use this command if you wish to place sprite your sprite partly off the screen.
Secondly, this sprite command cannot be used with the vbmScrollLeft / Right commands which re-arrange the character map used for the bitmap.
Should either of the above be requirements, use vbmSpriteSlice instead which allows you to draw each sprite column seperately and you can specify the start and end line of the sprite to draw. As such you can only draw the columns and lines as needed in the correct locations.
There are three ways to draw a sprite:
- vbmDrawSprite - draws a sprite, merging it with the bitmap
- vbmDrawSpriteE - draws a sprite, merging it with the bitmap using the EOR operation
- vbmClearSprite - clears a sprite from the bitmap, effectively 'cutting it out'
Example
x,y :byte;
// define a sprite character
spr8 : array[] of byte = (
%01111110,
%10000001,
%10100101,
%10000001,
%10100101,
%10111101,
%10000001,
%01111110,
%00011000,
%00011000,
%11111111,
%00011000,
%00011000,
%00111100,
%01011010,
%10011001,
);
// where to store the pre-shifted addresses of the sprite
spr8L0 : array[8] of integer; // to store the low addresses of pre-shifted sprites for spr8
spr8R0 : array[8] of integer; // to store the high addresses of pre-shifted sprites for spr8
...
// sprite 8x16 - pre-shift in 8 positions, using 128 bytes ($80)
// pre-shift the right side
vbmSpriteShiftR( spr8, ^$a000, 1, 16, spr8L0 ); // spr8 into addr A000, 1 pixel increments, 16 lines
// pre-shift the left side
vbmSpriteShiftL( spr8, ^$a080, 1, 16, spr8R0 ); // spr8 into addr A080, 1 pixel increments, 16 lines
y := 10;
for x := 0 to 100 do
begin
vbmSetPosition1( x, y ); // position the sprite, 1 pixel increments
vbmDrawSpriteE( spr8L0, spr8R0 ); // draw the sprite
waitforraster( 0 ); // wait for raster
vbmSetPosition1( x, y ); // position the sprite, 1 pixel increments
vbmDrawSpriteE( spr8L0, spr8R0 ); // erase the sprite
end;
See also
- vbmDrawSprite8
- vbmDrawSprite16
- vbmSetPosition1 / 2 / 4