Graphics BASIC is a third-party
extension
Extension, extend or extended may refer to:
Mathematics
Logic or set theory
* Axiom of extensionality
* Extensible cardinal
* Extension (model theory)
* Extension (predicate logic), the set of tuples of values that satisfy the predicate
* E ...
to the
Commodore BASIC V2.0 programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
of the
Commodore 64 computer. It was originally written in 1983 by
Ron Gilbert and
Tom McFarlane. The program was licensed to
Hesware
Human Engineered Software (HES, also known as HesWare) was an American software developer and publisher from 1980 until 1984. The company sold video games and educational and productivity software, in addition to several hardware products. It fo ...
, which briefly sold the program in 1984 as part of its product line before going out of business. The program was later extended by
Ken Rose and
Jack Thornton, and repackaged and sold in 1985 by
Epyx
Epyx, Inc. was a video game developer and publisher active in the late 1970s and 1980s. The company was founded as Automated Simulations by Jim Connelley and Jon Freeman, originally using Epyx as a brand name for action-oriented games before ren ...
under the title ''Programmers BASIC Toolkit''.
Graphics BASIC adds over 100 new commands to the
BASIC language, providing an easy-to-use
API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
to the relatively advanced (at the time) graphics and sound hardware capabilities of the Commodore 64. The only access to these features with Commodore BASIC alone is through the cumbersome use of
PEEK and POKE commands. Graphics BASIC was delivered on a single 5.25"
floppy disk, containing the language itself and numerous, very simple demo programs showing off the new features of the language. A cartridge version was also available.
Features
Graphics
Graphics BASIC's main feature is its easy-to-use graphics commands, including commands to draw dots, lines, circles, ellipses, rectangles, and polygons. The following gives an example of how the commands were used:
DOT 160,100
LINE 80,50 TO 240,150
BOX 10,10 TO 20,20
As can be seen from the above, the syntax is somewhat similar to that of
GW-BASIC
GW-BASIC is a dialect of the BASIC programming language developed by Microsoft from IBM BASICA. Functionally identical to BASICA, its BASIC interpreter is a fully self-contained executable and does not need the Cassette BASIC ROM found in the ...
's or
AmigaBASIC
AmigaBASIC is an interpreted BASIC programming language implementation for the Amiga, designed and written by Microsoft. AmigaBASIC shipped with AmigaOS versions 1.1 to 1.3. It succeeded MetaComCo's ABasiC, which was included in AmigaOS 1.0 ...
's graphics commands, but different enough to prevent source-code compatibility.
The Commodore 64 has separate video modes for text and graphics. Switching between these is extremely easy in Graphics BASIC.
TEXT
switches to text mode,
HIRES
switches to 320×200 two-colour graphics, and
MULTI
switches to 160×200 four-colour graphics. Graphics BASIC also allows the screen to be horizontally split between multiple modes.
Using all 16 colours is possible in both HiRes and Multi modes, but if two incompatible colours are drawn onto the same 8×8 pixel block, the entire block fills with the colour drawn later. This is due to a technical limitation of the Commodore 64's
VIC-II
The VIC-II (Video Interface Chip II), specifically known as the MOS Technology 6567/8562/8564 (NTSC versions), 6569/8565/8566 ( PAL), is the microchip tasked with generating Y/C video signals (combined to composite video in the RF modulator) and ...
display chip.
One of the more unusual choices of syntax in Graphics BASIC was the setting of graphics colours. To set the foreground and background colours of the text mode, you use the commands
COLOUR
and
BACKGROUND
, followed by either a number from 0 to 15, or a pre-defined symbolic constant such as
WHITE
or
BLACK
. To set the colours of the graphics mode, the command syntax is of the form:
COLOUR HIRES x ON y
where x is the foreground colour and y is the background colour. (For example,
COLOUR HIRES BLACK ON WHITE
).
Sprites
Graphics BASIC also provides commands to manipulate the Commodore 64's eight
sprites. These sprites are 24×21 pixels in size, drawn in either 2 colours (1 colour + background) or 4 colours (3 colours + background). Each sprite has one individual colour to its own. In 3-colour mode, the horizontal resolution is halved, and all 3-colour sprites share the same 2 extra colours.
The compact syntax of the sprite commands has more in common with the
command-line options of
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
programs than conventional programming languages. In essence, several sprite manipulations can be combined into one command, starting with the word
SPRITE
and the sprite's number, from 1 to 8. This is then followed by any number of keywords, and the parameters they need. As an example,
SPRITE 1 ON AT 160,100 COLOUR BLUE XYSIZE 2,2
does a total of four things: set sprite 1 as visible, move it into the location (160, 100) on the screen, set its individual colour to blue, and double its physical size both horizontally and vertically.
Graphics BASIC also supports automatic sprite movement (change in place), animation (change in shape), and collision detection. This is implemented in the language core itself by adding hooks into the Commodore 64's
software interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
routines. (The language does not support adding your own interrupt hooks.)
Sprite shapes can be drawn by hand with a built-in sprite editor, accessed with the command
EDIT
. The editor, while simple to use, was somewhat rudimentary. Sprite shapes can be loaded or saved to disk with the
SPRITE LOAD
and
SPRITE SAVE
commands. Programmatically drawing new sprite shapes can be done by drawing the shapes on the normal hires or multicolor screen, then copying the shapes with the
COPY HIRES TO SPRITE
or
COPY MULTI TO SPRITE
command.
Sound
Graphics BASIC also provides various commands to control the Commodore 64's built-in
audio synthesizer, allowing the selection of waveform type, tone (frequency), and amplitude envelopes. In addition, sequences of tones can be specified and played automatically in the background.
Other commands
In addition to graphics and sound commands, Graphics BASIC also provides various other useful commands such as
DIR
to list the file directory of a device,
JOY
to return the position of a joystick,
KEY
to program function keys,
REN
to renumber the current program line numbers. Graphics BASIC also added an
ON ERROR
command to perform error capturing, a
PROCEDURE
command that allowed variables to be passed to subroutines, and added
ELSE
to the
IF/THEN
command.
{{BASIC
BASIC extensions
Commodore 64 software