Personal Computer News


White Lightning

 
Published in Personal Computer News #074

The blinding speed and versatility of games developer White Lightning impressed David Janda.

Electifying Graphics

The blinding speed and versatility of games developer White Lightning impressed David Janda

This high-quality graphics development system offers Spectrum games designers the flexibility missing in menu-driven utilities, or packages where separate routines perform a particular operation only, leaving the programmer to thread them together with the crude Basic control constructs available.

Oasis Software has approached the problem of games design in a completely different way. Over a period of time it has produced an integrated high-level graphics development system to make others in the field redundant.

This has been achieved by providing the programmer with a flexible tool - Forth. Add to the standard definitions a sprite/graphics extension called Ideal, throw in a separate sprite generator and you have the White Lightning graphics development system.

Features

Most of the features are described in the boxes opposite, but here is a general overview.

At the system's core is a full implementation of Fig-Forth. As well as the standard words there are Basic/Forth words and the Ideal subset. Programs can be written in Spectra Forth (as Oasis calls it) or space can be reserved for the inclusion of Sinclair Basic. Using this feature it is possible to write Forth programs that call Basic as a subroutine or vice versa.

When a program is finished and debugged it can be compiled and the resultant source code will be ready to run. The source can also incorporate Basic. This means the string handling and floating-point bits don't have to be written in Forth.

The system works quite happily with the Kempston Joystick and Oasis claims it should work with many types of interface, though not Interface 1.

Very large programs can be compiled in stages. This is done by loading source code into one or two screens and compiling it a bit at a time.

In Use

The package is definitely not of the load-and-go variety. It took me three days, on and off, to get to grips with the 131-page manual, let alone fiddle about with the language.

The sprite designer was the first part of the WL system I tackled. The 167 characters provided offer characters from many of the popular games and can be edited and changed easily.

Creating a sprite was simple enough at first, provided fancy features were kept for a later date. Using the various features of the package was quite easy. Careful thought has gone into the use of the keyboard with the cursor controlled by keys five to seven, and colour attributes accessed by using the keys with their associated keywords.

Completed sprites can be saved to tape for loading into the main part of the package.

Once Spectra Forth is loaded and running it provides a typical Forth environment with the OK prompt and the flashing cursor.

Entering VLIST, however, reveals the Basic/Forth words and the many words that make up the Ideal extension.

Bashing in Forth source code is not the easiest thing to do as many Forths have only a primitive editor. WL incorporates this editor for compatibility but the EDIT command allows you to edit a line (a la Spectrum). It also lists the current screen and does a FLUSH - neat.

The wealth of graphics words available are surprisingly easy to remember because they end with a letter corresponding to a particular type of operation, M for memory, S for screen/sprite and so on.

The question with a package such as this is its speed. If the demonstration tape doesn't convince you, nothing will. It should be noted that speed also depends on how efficient the source code is in the first place, and for those who require machine code to be incorporated, it can be called from Forth.

Verdict

While Lightning is the best package I have used on the Spectrum. Its features and flexibility are second to none and have to be seen to be believed.

That it can be used as a Basic extension means the less experienced will be able to have a go without fear of getting bogged down, which is why I give it the thumbs up. And at £14.95 it represents tremendous value for money.

Hybrid Programming And The Basic Interface

WL allows the programmer to use Basic, Forth or a combination of the two. This gives greater flexibility in programming as some applications are best suited to a particular language.

There are three types of language interfacing, each designed for a particular purpose.

Within the Ideal extension there are 18 Forth/Basic words, such as DRAW, CIRCLE and so on. These words are treated as Forth words, and must be used as such. All arguments and parameters are taken from or put on the stack, and in operation they are faster than the Basic equivalent because all floating point interpretation is avoided when the word is being executed.

The second method of hybrid programming is to use lines of Basic as subroutines, i.e. call them from Forth. To do this, space for the Basic source is first set aside using the Ideal word RESERVE. This is followed by a number representing the amount of space to be reserved in bytes.

Basic is called from Forth by placing the line number on the stack and using GOTO. Control can then be returned to Forth with PRINT USR 3006, which then executes the very next word - not the next colon definition.

Forth can be called as a subroutine. Here, a RANDOMIZE 3000 is used to enter Forth and a return is made by using the Ideal word RETUSR.

To select the word to be called, a variable can be defined from Forth and its address found.

Once done, the variable can be poked from Basic and, on calling Forth, a CASE or IF can be used to select the appropriate word, CASE 2 OF "SECOND WORD", for instance.

The Sprite Generator

The two major stages in designing a game with WL are writing the game itself and defining the sprites it uses. For the latter, a sprite generator program is included with the WL package, but used separately.

The package allows you to define and edit sprites of various sizes and colours, which can be saved to tape for re-editing at a later date, or loaded into WL.

Oasis has provided 167 predefined sprites which cover popular games such as Pac-Man, Space Invaders, Defender and so on, as well as sprites used in the demonstration program.

The editor is made up of a 15 x 15 sprite screen, and a smaller 8 x 8 CHR$ SQR, which is used to edit and create the sprite while the sprite screen is used to manipulate and transform sprites. Also provided on screen is information relating to attributes, logical operations and sprite information, including size and so on.

Data for sprites can be entered in two ways. First, the CHR$ SQR can be used to fill in pixels, and secondly data can be entered as Hex.

Once done, it can be 'moved' to the sprite window where it can then be manipulated.

Sprites can be made up of several characters, and sprites can be placed within sprites. All the usual attributes can be set to the sprite as a whole or individual characters. It is also possible to set Boolean operations on sprites (AND, OR, XOR) which produce interesting effects.

Up to 255 sprites can be defined, and if more are needed there's a merging procedure.

The Ideal Extension

Fig-Forth is the host language of the White Language package, but the graphics end of things is the Ideal extension. Ideal (Interrupt Drive Extendable Animation Language) consists of 110 sprite/screen data manipulation words. These words perform operations on particular areas of the screen and sprites. There are words for screen, sprites, screen/sprites, screen/sprint windows, sprite/sprite windows and sprite/sprite operations.

A total of 27 variables are provided in Ideal, and these store data relating to windows, position of sprites and so on.

Many Ideal words are similar, allowing pixel/sprite data to be scrolled in four directions by a certain number of pixels. A number of GET and PUT commands allow sprites to be displayed with different effects on the data already there. Other graphics commands for colour and drawing are provided by the Basic/Forth words which are part of Ideal.

Sprites and screen may be inverted and reflected, and sprites can be spun and enlarged. Automatic sprites are not catered for, but a routine is provided in the manual to achieve the same thing.

One of the main features of the White Lightning package is the ability to perform background processing i.e. multi-tasking. This feature is crucial in games, where a landscape needs to be scrolled, for example.

A background task may be performed up to 50 times a second. Though the background task continues until the task is finished, careful programming allows the programmer to do several jobs giving the impression that more than one task is happening at once.

Conflict can occur between Ideal variables when a background task is in operation, so it is possible to disable the interrupts. This allows a task to get on with the job in hand without being interrupted.

Rating

Features 5/5
Documentation 5/5
Performance 5/5
Usability 5/5
Reliability 5/5
Overall Value 5/5

David Janda