| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
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 |