Locomotive BASIC
Encyclopedia
Locomotive Basic is a proprietary dialect of the BASIC programming language written by Locomotive Software
used only on the Amstrad CPC
(where it was built-in on ROM
). It was the main ancestor of Mallard BASIC
, the interpreter for CP/M
supplied with the Amstrad PCW
and later the Amstrad-designed and built ZX Spectrum
+3.
Also, it granted an almost full control over the CPC sound chip, an AY-3-8912 with 3 melodic channels and 1 noise channel (which was also used on late-model ZX Spectrum
s, as well as the Atari ST
and MSX
computers, with none of them having such a complete built-in SOUND command). Everything, from selecting a particular channel or a combination of channels, setting envelopes, volume, pitch, noise, and so on could be done with a single SOUND command, with up to 7 parameters. The only thing that could not be done with BASIC was perhaps playing back digital sampled sounds, like in the game RoboCop
.
Disk, tape, and file management were managed by BASIC itself, and were usually good enough for simple file management, with commands such as GET, PUT, ERASE, SAVE, MERGE, RUN, CAT, LOAD etc. In fact, during those years, the BASIC supplied as standard with every low-cost home computer also acted as a more or less simple operating system
.
Also available were some special commands for memory allocation and handling, like MEMORY and a parametric LOAD command, allowing, for example, to load a file containing "raw" picture data into video memory, causing it to be displayed, with a couple of BASIC instructions. Adding the right memory address(es) as parameter to the commands LOAD or SAVE would allow easy loading of raw uncompressed 17 KB screen pictures. CALLing another address gave a forced system reset (call 0), the famous "Press Any Key" (call &bb18) or for eliminating flicker in animation by allowing you to synchronize with the monitor's raster scan via "sync frame-flyback" (call &bd19); this was given its own dedicated command in Basic 1.1 - FRAME. With PEEK and POKE
, CALL provided an interface to assembly language programming from BASIC.
's BASIC (Commodore BASIC
), which had no dedicated commands for graphics or sound, allowed doing pretty much anything that was within the standard capabilities of the machine. This was not unimportant, as some other machines of the era using full graphics or sound was limited to assembler
programmers. MSX, Spectrum and some others offered a similar, more or less complete command set for their sound and graphics capabilities. The only things going clearly beyond BASIC capabilities were the overscan modes used in games and demos, weird 27-color graphics modes, digital sound playback, and smooth scrolling.
Unlike Sinclair BASIC
or Commodore 64 BASIC, which had various keyboard command shortcuts or specialized keys for choosing symbols or colors, Locomotive BASIC keywords were typed in full and the interpreter parsed, recognized and tokenised them. However, there were abbreviations like "?" for "PRINT" and a few shortcuts. Programs could be saved onto cassette tape or floppy disk
and retrieved as binary or ASCII
files.
Locomotive Software
Locomotive Software was a small British software house which did most of its development for Amstrad's home and small business computers of the 1980s....
used only on the Amstrad CPC
Amstrad CPC
The Amstrad CPC is a series of 8-bit home computers produced by Amstrad between 1984 and 1990. It was designed to compete in the mid-1980s home computer market dominated by the Commodore 64 and the Sinclair ZX Spectrum, where it successfully established itself primarily in the United Kingdom,...
(where it was built-in on ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...
). It was the main ancestor of Mallard BASIC
Mallard BASIC
Mallard BASIC is a BASIC interpreter for CP/M written by Locomotive Software and supplied with the Amstrad PCW range of small business computers, the ZX Spectrum +3 version of CP/M Plus, and the Acorn BBC Micro Z80 second Processor....
, the interpreter for CP/M
CP/M
CP/M was a mass-market operating system created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc...
supplied with the Amstrad PCW
Amstrad PCW
The Amstrad PCW series was a range of personal computers produced by British company Amstrad from 1985 to 1998, and also sold under licence in Europe as the "Joyce" by the German electronics company Schneider in the early years of the series' life. When it was launched, the cost of a PCW system was...
and later the Amstrad-designed and built ZX Spectrum
ZX Spectrum
The ZX Spectrum is an 8-bit personal home computer released in the United Kingdom in 1982 by Sinclair Research Ltd...
+3.
Version history
It was published in two versions: 1.0 which only came with the CPC model 464, and 1.1 which shipped with all other versions. A special update—or rather, a ROM extension—was available on the Amstrad CPC Plus series machines, which added specialised BASIC commands for taking advantage of the extra capabilities of those machines.Features
It was a rather simple but powerful BASIC implementation by the standards of the day, featuring dedicated commands for handling graphics (such as DRAW, PLOT, INK, and PAPER in all versions; plus FILL in v1.1), even allowing the creation of multiple screens, windows, and the like, although the color system and palette handling was awkward. Interestingly enough, a table giving the numeric codes for the 27 system colors was printed over the built-in 3" disk drive casing on the 664 and later machines. Simple as it was, it did stand out however among other BASICs of the time by offering a timer-based software interrupt mechanism using the EVERY or AFTER commands; this offered a timed repeating or once-off call respectively to the BASIC line number of your choice.Also, it granted an almost full control over the CPC sound chip, an AY-3-8912 with 3 melodic channels and 1 noise channel (which was also used on late-model ZX Spectrum
ZX Spectrum
The ZX Spectrum is an 8-bit personal home computer released in the United Kingdom in 1982 by Sinclair Research Ltd...
s, as well as the Atari ST
Atari ST
The Atari ST is a home/personal computer that was released by Atari Corporation in 1985 and commercially available from that summer into the early 1990s. The "ST" officially stands for "Sixteen/Thirty-two", which referred to the Motorola 68000's 16-bit external bus and 32-bit internals...
and MSX
MSX
MSX was the name of a standardized home computer architecture in the 1980s conceived by Kazuhiko Nishi, then Vice-president at Microsoft Japan and Director at ASCII Corporation...
computers, with none of them having such a complete built-in SOUND command). Everything, from selecting a particular channel or a combination of channels, setting envelopes, volume, pitch, noise, and so on could be done with a single SOUND command, with up to 7 parameters. The only thing that could not be done with BASIC was perhaps playing back digital sampled sounds, like in the game RoboCop
RoboCop
RoboCop is a 1987 American science fiction-action film directed by Paul Verhoeven. Set in a crime-ridden Detroit, Michigan in the near future, RoboCop centers on a police officer who is brutally murdered and subsequently re-created as a super-human cyborg known as "RoboCop"...
.
Disk, tape, and file management were managed by BASIC itself, and were usually good enough for simple file management, with commands such as GET, PUT, ERASE, SAVE, MERGE, RUN, CAT, LOAD etc. In fact, during those years, the BASIC supplied as standard with every low-cost home computer also acted as a more or less simple operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
.
Also available were some special commands for memory allocation and handling, like MEMORY and a parametric LOAD command, allowing, for example, to load a file containing "raw" picture data into video memory, causing it to be displayed, with a couple of BASIC instructions. Adding the right memory address(es) as parameter to the commands LOAD or SAVE would allow easy loading of raw uncompressed 17 KB screen pictures. CALLing another address gave a forced system reset (call 0), the famous "Press Any Key" (call &bb18) or for eliminating flicker in animation by allowing you to synchronize with the monitor's raster scan via "sync frame-flyback" (call &bd19); this was given its own dedicated command in Basic 1.1 - FRAME. With PEEK and POKE
PEEK and POKE
In computing, PEEK is a BASIC programming language extension used for reading the contents of a memory cell at a specified address. The corresponding command to set the contents of a memory cell is POKE.-Statement syntax:...
, CALL provided an interface to assembly language programming from BASIC.
Contemporary rivals
Locomotive BASIC compared to the Commodore 64Commodore 64
The Commodore 64 is an 8-bit home computer introduced by Commodore International in January 1982.Volume production started in the spring of 1982, with machines being released on to the market in August at a price of US$595...
's BASIC (Commodore BASIC
Commodore BASIC
Commodore BASIC, also known as PET BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET of 1977 to the C128 of 1985...
), which had no dedicated commands for graphics or sound, allowed doing pretty much anything that was within the standard capabilities of the machine. This was not unimportant, as some other machines of the era using full graphics or sound was limited to assembler
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...
programmers. MSX, Spectrum and some others offered a similar, more or less complete command set for their sound and graphics capabilities. The only things going clearly beyond BASIC capabilities were the overscan modes used in games and demos, weird 27-color graphics modes, digital sound playback, and smooth scrolling.
Unlike Sinclair BASIC
Sinclair BASIC
Sinclair BASIC is a dialect of the BASIC programming language used in the 8-bit home computers from Sinclair Research and Timex Sinclair...
or Commodore 64 BASIC, which had various keyboard command shortcuts or specialized keys for choosing symbols or colors, Locomotive BASIC keywords were typed in full and the interpreter parsed, recognized and tokenised them. However, there were abbreviations like "?" for "PRINT" and a few shortcuts. Programs could be saved onto cassette tape or floppy disk
Floppy disk
A floppy disk is a disk storage medium composed of a disk of thin and flexible magnetic storage medium, sealed in a rectangular plastic carrier lined with fabric that removes dust particles...
and retrieved as binary or ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...
files.
External links
- Locomotive BASIC reference
- Command reference with code examples
- Command reference (incomplete)
- Additional code examples at Rosetta CodeRosetta CodeRosetta Code is a wiki-based programming chrestomathy website with solutions to various programming problems in many different programming languages. It was created in 2007 by Mike Mol. Rosetta Code includes 450 programming tasks, and covers 351 programming languages...