Graphics BASIC

Graphics BASIC

Graphics BASIC is a third-party extension to the Commodore BASIC V2.0 programming language of the Commodore 64 computer. It was originally written in 1983 by Ron Gilbert and Tom McFarlane. The program was licensed to Hesware, who briefly sold the program in 1984 as part of their product line before going out of business. The program was later repackaged and sold in 1985 by Epyx under the title "Programmers BASIC Toolkit".

Graphics BASIC adds over 100 new commands to the BASIC language, providing an easy-to-use API 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. Graphics BASIC is installed simply by issuing the well-known command:

LOAD "*",8,1

After loading, the language starts automatically, without the need for a separate RUN or SYS command.

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's or AmigaBASIC'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 320x200 two-colour graphics, and MULTI switches to 160x200 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 a technical limitation of the Commodore 64 itself and can not be avoided in software.

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).

prites

Graphics BASIC also provides commands to manipulate the Commodore 64's eight sprites. These sprites are 24x21 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 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 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 was not supported.

ound

Graphics BASIC also provides various commands to control the Commodore 64's built-in audio synthesizers, 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.


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • BASIC 8 — (or BASIC 8.0) mdash; The Enhanced Graphics System For The C128 mdash; developed by Walrusoft of Gainesville, Florida and published in 1986 by Patech Software of Somerset, New Jersey, USA, was an extension of Commodore s BASIC 7.0 for the C128… …   Wikipedia

  • Graphics — (from Greek gr. ; see graphy) are visual presentations on some surface, such as a wall, canvas, computer screen, paper, or stone to brand, inform, illustrate, or entertain. Examples are photographs, drawings, Line Art, graphs, diagrams,… …   Wikipedia

  • BASIC extension — BASIC toolkits (aka BASIC extensions) mdash;not to be confused with widget toolkits mdash;were a common type of program for 1980s 8 bit home computers. Generally third party extensions, they added additional features to a computer s built in… …   Wikipedia

  • BASIC A+ — was developed by Optimized Systems Software of Cupertino, California, USA, to provide the Atari 8 bit family with an extended BASIC compatible with, but faster than, the simpler ROM based Atari BASIC.While Atari BASIC came on an 8 KB ROM… …   Wikipedia

  • Basic Pilot Program — Basic Pilot was the official name of this program for the first ten years of its existence beginning in November 1997. The program s official name has since been changed to e verify but much of the press and public still continues using the… …   Wikipedia

  • BASIC Programming — was released for the Atari 2600 console in 1979. One of only a few non gaming cartridges, this program allowed consumers to create some simple programs using its own unique programming language, which was superficially similar to dialects of… …   Wikipedia

  • Basic Linear Algebra Subprograms — (BLAS) is a de facto application programming interface standard for publishing libraries to perform basic linear algebra operations such as vector and matrix multiplication. They were first published in 1979, and are used to build larger packages …   Wikipedia

  • Graphics processing unit — GPU redirects here. For other uses, see GPU (disambiguation). GeForce 6600GT (NV43) GPU A graphics processing unit or GPU (also occasionally called visual processing unit or VPU) is a specialized circuit designed to rapidly manipulate and alter… …   Wikipedia

  • BASIC — This article is about the programming language. For the think tank, see British American Security Information Council. For the group of countries, see BASIC countries. For other uses, see Basic (disambiguation). BASIC Screenshot of Atari BASIC,… …   Wikipedia

  • Graphics Device Interface — The Graphics Device Interface (GDI) is a Microsoft Windows application programming interface and core operating system component responsible for representing graphical objects and transmitting them to output devices such as monitors and printers …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”