Home > CBM > BASIC > Keywords > Sprsav | |||||||||||||||||||||||||||||||||||||||||||||||||||
SPRSAV { { sourceSprite , { saveSprite | image2 } } | { image1 , { saveSprite | image2 } } }
Data initialization / State management; Copy a sprite definition to a string or another sprite, or initialize a sprite definition from a string.
SPRSAV provides three ways to read/write (load/store) a SPRITE's image definition:
SPRSAV also allows a fourth form: SPRSAV image1, image2. However, this form does not (neccessarily) copy sprite data; it is equivalant to LET. The third form is often used in a program to initialize the image of a sprite (an alternative is to BLOAD sprite image(s)). The second form may occassionaly be used to create a "stamp" that may be drawn repeatedly on a bitmap. The first form is rarely used, except in direct mode (program design). The fourth form is just silly. The first form works flawlessly assuming the Syntax is correct and the sourceSprite and saveSprite are both the same "color type" (both high-resolution or both multi-color). The second form creates (or replaces) a string which holds an image of the sprite. This may be used in subsequent SPRSAV statements, or with GSHAPE to "stamp" the bitmap with the image. The resulting image string will be 67 bytes which consists of 63 bytes for the sprite image itself, plus a 4-byte "footer" used by GSHAPE (describes the dimensions of the image). For the third form, image1 is a string which should have been created with SPRSAV or SSHAPE. If not, strange images will result (but there will be no error if the Syntax is correct). An image created with SSHAPE should always be 21 pixels tall and either 24 or 12 pixels wide, depending if you want a high-resolution or multi-color SPRITE, respectively. The SSHAPE image should have come from high-resolution or multi-color bitmap respectively. If not, the SPRITE will receive a strange image. In forms 2 and 4, image2 must be a string variable (not a literal or expression), otherwise SYNTAX ERROR will occur. If a parameter is omitted or is invalid, or if any extra parameter(s) are given, then SYNTAX ERROR is generated. If image1 or image2 (when present) is not a string, or sourceSprite or saveSprite (when present) is not numeric, then TYPE MISMATCH ERROR occurs. The values for sourceSprite and/or saveSprite may be manually converted from string to numeric with VAL. Floating-point values of sourceSprite and/or saveSprite are automatically converted with INT. If any parameter is not a Legal Value (see above) an ILLEGAL QUANTITY ERROR is generated. Note that a SPRITE has more properties that define it besides its image (see SPRITE). SPRSAV does not copy any sprite characteristics other than the image pixels. In particular, no color information is copied. Once you haved saved an image, it is easy to make copies in memory with simple variable assignments (see LET), although there is seldom any reason to do this. Examples:
If you try those examples, then afterwards you can use GSHAPE A$,x,y to stamp the bitmap
with an image of sprite 1.
© H2Obsession, 2014 |