Flashback: Sprite BASIC

In Flashback I present selected posts recycled from the first iteration of SolidState blog.

Sprite BASIC is an expansion of 47 new commands for the C64 BASIC, written by Andreas Schulteiß and originally published as a type-in on the Spanish magazine Commodore World #33 of January 1987 (and possibly also in the RUN magazine in other places of Europe and the U.S.A.).
Sprite BASIC uses interrupts to handle sprites and their collisions, and also the sound, that way it’s posible to sprites moving on the screen and sound while the BASIC program continue execution.

Commands for customized sprites and characters

SHOW sprite number (1-8 ), multicolor flag (0-1), priority (0-1) Makes visible a sprite. Example:

SHOW1,1,0 shows sprite 1 in multicolor and without priority over the background

HIDE sprite number (1-8 ) Hides a sprite. Example:

HIDE 1 hides sprite 1.

SET sprite number (1-8 ), X position (0-511), Y position (0-255). Places a sprite in a determined position on the screen. Example:

SET3,160,130 places sprite 3 on the center of the screen

BLOCK sprite number (1-8 ), block number (0-63). Selects the data storage area for the sprite. Example:

BLOCK1,10 selects block 10 for sprite 1.

COLOR sprite number (1-8 ), color (0-15). Selects the color of the sprite. Example:

COLOR7,1 selects white color for sprite 1.

MULTI color1 (0-15), color2 (0-15). Defines the multi-colors for all sprites. Example:

MULTI6,2 selects the colors blue and red

SIZE sprite number (1-8 ), X expansion (0-1), Y expansion (0-1). Defines X and Y expansion of the sprite. Example:

SIZE4,1,0 sprite 4 expands in horizontal.

SPREDIT block number (0-63). Sets the block number or sprite data bank that is going to be edited with the PAT command(see below). Example:

SPREDIT12 selects block 12

CHREDIT character number (0-511). Sets the character that is going to be edited with PAT. Example:

CHREDIT1 the character "A" is going to be edited.
CHREDIT257 the "A" of the second character set is the one that is going to be edited.

PAT “definition string”. Used to define a sprite or character shape. If the string lenght is of 8 characters, a character is defined (see CHREDIT) and 8 definitions would be needed. If it is of 24, a sprite is created (see SPREDIT) and 24 definitions would be needed. A character “.” means pixel off, and any other character, pixel on. Example:

PAT "...***.."

MPAT “definition string” (12 characters). Used to define multicolor sprites: “.” is pixel off, “A” pixel in sprite’s color, “B” pixel in multicolor1 and “C” pixel in multicolor2. Example:

MPAT " AA...BB...CC "

OLD copies back the two character sets in the ROM of the C-64, thus the characters defined with CHREDIT and PAT are replaced by normal characters.
COPY bloque1 (0-63), bloque2 (0-63). Copies a block from one place to another. Example:

COPY1,2 copies block 1 over block 2.

Movement commands

MOVE sprite number (1-8 ), angle (0-360, counterclockwise according to the horizontal), steps size, speed (0-127, 1 the maximun), number of steps (0-65535, 0 is continuous movement), BASIC flag(0 continue program, 1 stop until sprite stops moving). Used to move sprites on the screen. Example:

MOVE1,90,1,1,10,1 sprite 1 moves upwards at maximum speed in 1 pixel steps. It takes ten steps in total and then the BASIC program continues.            

MOVE8,77,4,4,20,0,0 sprite 8 moves continuously in an angle of 77 degrees at speed 20, in 4 pixels steps. The BASIC program continues execution meanwhile.

NOMOVE sprite number (1-8 ). Stop the movement of a sprite. Example:

NOMOVE3 stops the movement of sprite 3.

TURN sprite number (1-8 ), angle (0-360), number of steps (0-65535), number of repetitions (0-255, being 0 uninterrupted). Indicates a sprite to change it’s direction of movement after a determined number of steps. Example:

TURN1,90,10,20 sprite 1 turns 90 degrees after taking 10 steps, repeating this 20 times.

NOTURN sprite number (1-8 ). Stops the change of direction of a sprite and it return to move normally. Example:


ANIMATE sprite number (1-8 ), first block (0-63), number of blocks (0-63), number of steps. Sprite changes alternatively of shape. Example:

ANIMATE1,13,3,10 sprite 1 changes of shape (data bank) after each 10 steps, beginning in the block 13 and following in 14-15.

NOANIMATE sprite number (1-8 ). Stops the animation. Example:

NOANIMATE4 stops the animation of sprite 4

Collision handling commands

SPCOL sprite number (1-8 ), line number (0-63999). Make the program to branch to the specified line number when a sprite-sprite collision is detected. Example:

SPCOL1,1000 if sprite 1 collides with another sprite the program branchs to the line 1000.

NOSPCOL sprite number. Reverts the previous command. Example:


CHCOL sprite number (1-8 ), line number (0-63999). As SPCOL but for character-sprite collisions.

NOCHCOL sprite number (1-8 ). Reverts CHCOL.
BACK After SPCOL or CHCOL, the program will jump back when finding this order, to the exact place from which it bracnh. The result is like GOSUB/RETURN.
POP Erases the direction for BACK. In this way it can return to any part of the program with GOTO instead of BACK.
CLFLAG The collision flag remains activated when CHCOL or SPCOL is executed, thus if another collision takes place it would not be detected, that’s why it’s recommendable to put this command at the end of the collision subroutine, or immediately after the collision condition has been solved.
(Note: The magazine recommends to place this command at the beginning of the subroutine, but that way, as the condition that produced the subroutine call has not been resolved yet, the result is that the subroutine is executed again and again, resulting in a stack overflow and the conclusion of the program.)

Sound commands

VOL volume (0-15). Sets the volume. Example:


ADSR voice (1-3), attack (0-15), decay (0-15), sustain (0-15), release (0-15). Sets the sound envelope. Example:

ADSR1,1,9,0,0 produces piano sound.

WAVE voice (1-3), waveform (0-3). Sets the waveform. It can be: 0=triangle, 1=sawtooth, 2=square, 3=white noise. Example:

WAVE1,3 voice 1 produces noise

PULSE voice (1-3), pulse width (0-65535). Sets the pulse width for a square wave. Example:

PULSE2,2000 voice 2 has a relation of 1:2000.

PLAY voice (1-3), frequency in Hertz, duration in seconds, flag (0=the program continues. 1=the program stops until the sound finishes). Plays a note. Example:

PLAY1,400,1,0 Plays the A note for 1 second while the BASIC program is executed.

Other commands

CURSOR column (0-39), row (0-24). Sets the cursor on a defined screen position. Example:

CURSOR20,12 places the cursor on the center of the screen

PLOT column (0-39), row (0-24), code (0-255), color (0-15). Places a character on the screen including color. Example:

PLOT20,12,1,0 prints a black A on center of the screen.

BORDER color (0-15). Changes the screen border color.
PAPER color (0-15). Changes the screen background color.
INK color (0-15). Sets the character color for the following PRINT sentences.
NOBREAK Disables the STOP key
RENEW Recovers a BASIC program erased with NEW or reset.
KILL Disables Sprite BASIC.


SPX(S). Contain the X coordinate of sprite S. Example:


SPY(S). Contains the Y coordinate of sprite S. Example:


ANG(S) Indicates the angle the sprite S is moving.
SCOL(S) Indicates if sprite S has hit (1) or not (0) another sprite. Example:


CCOL(S) If sprite S has hit a character on the screen returns 1, if not, 0.
CHAR(X, Y) Returns the character that is on column X, row Y of the screen (in screen code).
FIRE(P) Returns the state of the fire button of the joystick in port P. Example:


JOY(N) This function allows the use of the joystick at any moment: N=1 “asks” joystick 2 in all directions. N=2 joystick 2 only in horizontal direction (180 and 360 degrees). N=3 only in vertical (90 and 270 degrees). N=4 horizontal and vertical without the diagonals. N=5 to 8 are the equivalents for port 1.

Download zipped D64 image: spritebasic

The image contians:

  • SBASICGEN: BASIC generator of Sprite BASIC, typed from the magazine.
  • SPRITE BASIC: The Sprite BASIC executable, load this to start using Sprite BASIC.
  • CARS: Small demo game written in Sprite BASIC, load this after initializing Sprite BASIC.

One thought on “Flashback: Sprite BASIC”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>