Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

SPRDEF

Keyword Abbreviation Token (hex) Version(s) Classification
SPRDEF SPR{Shift+D} FE 1D 7.0 Command and Statement

 
  Syntax   
SPRDEF
  
  Purpose  
Machine statement management.  Suspend BASIC and enter the sprite editor.
 
  Remarks  
SPRDEF invokes an interactive editor for defining sprite images.  Like CBM's screen editor, it is quite easy to use.  The basic operation is you select a sprite to edit, use the cursor keys to select a pixel and press a number key to write/erase the pixel.  Full details follow.  Note that SPRDEF may be used as a statement in a program but is rare; it is normally used as command in direct mode when developing softare.  Although SPRDEF allows you to set most parameters of any sprite you edit (see SPRITE), it provides no way to set either of the two colors which are shared by all multi-color sprites (see SPRCOLOR).
 
When SPRDEF first begins, it will (try to) allocate a VIC-II bitmap if not already allocated.  This may be generate OUT OF MEMORY ERROR.  Otherwise the high-resolution bitmap will be cleared and displayed with a large edit window on the left.
 
  Outer Loop  
The outer loop of SPRDEF begins.  It asks "SPRITE NUMBER?" and waits for you to type a number between 1 and 8 to select a sprite to edit.  If you press Return (or Enter) at this point, the display is switched back to text mode, SPRDEF ends, and BASIC resumes.  Upon resumption, BASIC will check if any parameters were given to SPRDEF; if so, SYNTAX ERROR occurs.  The following assumes you pressed a valid number key.
 
The image of the selected sprite is saved in a temporary buffer.  This allows recovery/undo described later.  Next the selected sprite's motion is halted and it is positioned at sprite coordinate (264, 74) [see MOVSPR] which is on the right half of the screen near the top.  The choosen sprite is enabled and can be seen with its last-set parameters (see SPRITE).  All other sprites are disabled.
 
The pixels of the sprite's image are drawn at 8x magnifaction in the edit window on the left half of the screen.  The sprite-cursor is set to (0,0).  The auto-advance feature is activated; this will automatically advance the sprite-cursor one pixel to the right (with wrap to next line) when a pixel-plotting key (a number) is pressed. Now SPRDEF enters its main / inner loop.
 
  Inner Loop  
SPRDEF renders the sprite-cursor as + or ++ in the large edit window (if the sprite is in high-resolution or multi-color mode, respectively).  Now it waits for you to press a key.  When you press a key, the sprite-cursor is erased.  The following keys are recognized and perform the indicated action:
 
Key(s)  Action
1 erases the pixel (writes a 0 or %00 to the image data)
2 draws pixel with color 1 (writes a 1 or %01 to the image data)  
3 draws pixel with color 2 (writes %10 to the image data); multi-color mode only
draws pixel with color 3 (writes %11 to the image data); multi-color mode only
Control + [1 ~ 8] sets the unique color of the sprite (COLOR 1 ~ 8) 
C= + [1 ~ 8] sets the unique color of the sprite (COLOR 9 ~ 16)
up, down moves the sprite-cursor in the indicated direction; will not wrap from top to bottom
left, right moves the sprite-cursor in the indicated direction; will wrap to next line unless at the top,left or bottom,right
Return, Enter moves the sprite-cursor to the left-most pixel on the next line 
A toggles the auto-advance feature on/off 
copies another sprite's image to this sprite (described below) 
M toggles between multi-color and high-resolution sprite mode
X toggles the sprite's X-expansion (double width)
toggles the sprite's Y-expansion (double height) 
STOP  the undo feature; restores the sprite's original image and exits to the outer loop 
Shift + [Return, Enter] disables the sprite and exits to the outer loop 
 
When you press C (for Copy), SPRDEF will prompt "COPY FROM?" and waits for a number 1 ~ 8 or Return/Enter.  When one of those keys are pressed, the prompt is erased.  If you pressed a number, the selected sprite's image is copied to the sprite currently being edited.  Otherwise nothing is copied.  Nothing effectively happens if you copy from the same sprite being edited.  In any case, the main/inner loop continues.
 
The eight sprite images are stored sequentialy in Bank 0 RAM between 3584 and 4095 inclusive, 64 bytes each (although only the first 63 bytes of each sprite image is used by the VIC-II(e) chip).  The data may be saved with BSAVE or loaded with BLOAD.  You may also use SPRSAV to save a sprite's image to/from a string.
 
Because SPRDEF is an interactive editor, there are no examples of it; however below are examples to save your creation, and load it back later.
BSAVE "SPRITES.BIN", B0, P3584 TOP 4096, U8 : REM device 8, drive 0
SAVING 0:SPRITES.BIN
READY. BLOAD "SPRITES.BIN", B0, P3584, U8 : REM device 8, drive 0 (P3584 not needed) SEARCHING FOR 0:SPRITES.BIN LOADING READY.
 
 
  Compare With  
 
  Contrast With  
  See Also  

© H2Obsession, 2014
Comments