Difference between revisions of "Locomotive BASIC"
(→History: Added info on differences between BASIC 1.0 and BASIC 1.1 in using DATA statements) |
PulkoMandy (Talk | contribs) (→History: Added the AUTO command to the list of differences, removed useless links) |
||
Line 19: | Line 19: | ||
== History == | == History == | ||
− | The CPC implementation of Locomotive BASIC was developed directly from [[Locomotive Software]]'s existing Z80 BASIC. The existence of this is cited as one of the reasons Locomotive requested that [[Amstrad]] change the CPC's processor from a | + | The CPC implementation of Locomotive BASIC was developed directly from [[Locomotive Software]]'s existing Z80 BASIC. The existence of this is cited as one of the reasons Locomotive requested that [[Amstrad]] change the CPC's processor from a 6502 to a [[Z80]]. |
− | The 464 shipped with | + | The 464 shipped with BASIC 1.0 on ROM. |
− | The language was revised and debugged for the 664, 6128 and Plus machines to become | + | The language was revised and debugged for the 664, 6128 and Plus machines to become BASIC 1.1. Changes were minor but significant for the programmer, and included: |
* DEC$ bug removed (in BASIC 1.0, it required two opening brackets and was undocumented) | * DEC$ bug removed (in BASIC 1.0, it required two opening brackets and was undocumented) | ||
Line 37: | Line 37: | ||
* ON BREAK CONT (disable ESCape) | * ON BREAK CONT (disable ESCape) | ||
* CLEAR INPUT (flush keyboard buffer) | * CLEAR INPUT (flush keyboard buffer) | ||
+ | * The AUTO command show the whole line if it exist, it only printed a * on the 464 | ||
Some parts of 'BASIC' were actually housed in the firmware ROM, but were not officially accessible to other programs. This included the line editor. | Some parts of 'BASIC' were actually housed in the firmware ROM, but were not officially accessible to other programs. This included the line editor. |
Revision as of 04:02, 24 September 2006
Locomotive BASIC was a BASIC interpreter for the Amstrad CPC range of computers.
Contents
- 1 Description
- 2 History
- 3 Command list
- 3.1 Commands and operators
- 3.1.1 AFTER I[,t] GOSUB Ln
- 3.1.2 AUTO [Ln, i]
- 3.1.3 BORDER
- 3.1.4 CALL add[,list of parameters]
- 3.1.5 CAT
- 3.1.6 CHAIN
- 3.1.7 CHAIN MERGE
- 3.1.8 CLEAR
- 3.1.9 CLG [ink]
- 3.1.10 CLOSEIN
- 3.1.11 CLOSEOUT
- 3.1.12 CLS
- 3.1.13 CONT
- 3.1.14 CURSOR
- 3.1.15 DATA
- 3.1.16 DEF
- 3.1.17 DEFINT
- 3.1.18 DEFREAL
- 3.1.19 DEFSTR
- 3.1.20 DEG
- 3.1.21 DELETE
- 3.1.22 DI
- 3.1.23 DIM
- 3.1.24 DRAW x,y [,[i1][,i2]]
- 3.1.25 DRAWR xr, y2, [[i1][,i2]]
- 3.1.26 EDIT
- 3.1.27 EI
- 3.1.28 END
- 3.1.29 ENT
- 3.1.30 ENV
- 3.1.31 ERASE v[$(i1[,i2])
- 3.1.32 ERL
- 3.1.33 ERROR i
- 3.1.34 EVERY
- 3.1.35 FILL i
- 3.1.36 FN
- 3.1.37 FOR TO STEP NEXT
- 3.1.38 FRAME
- 3.1.39 GOSUB i
- 3.1.40 GOTO i
- 3.1.41 GRAPHICS
- 3.1.42 IF THEN ELSE
- 3.1.43 INK
- 3.1.44 INPUT
- 3.1.45 KEY
- 3.1.46 LET
- 3.1.47 LINE
- 3.1.48 LIST
- 3.1.49 LOAD
- 3.1.50 LOCATE
- 3.1.51 MASK
- 3.1.52 MEMORY
- 3.1.53 MERGE
- 3.1.54 MID$
- 3.1.55 MODE
- 3.1.56 MOVE
- 3.1.57 MOVER
- 3.1.58 NEW
- 3.1.59 ON BREAK
- 3.1.60 ON ERROR
- 3.1.61 OPENIN
- 3.1.62 OPENOUT
- 3.1.63 ORIGIN
- 3.1.64 OUT
- 3.1.65 PAPER
- 3.1.66 PEN
- 3.1.67 PLOT
- 3.1.68 PLOTR
- 3.1.69 POKE
- 3.1.70 PRINT
- 3.1.71 RAD
- 3.1.72 RANDOMIZE
- 3.1.73 READ
- 3.1.74 RELEASE
- 3.1.75 REM
- 3.1.76 REM
- 3.1.77 RENUM
- 3.1.78 RESTORE
- 3.1.79 RESUME
- 3.1.80 RETURN
- 3.1.81 RUN
- 3.1.82 SAVE
- 3.1.83 SOUND
- 3.1.84 SPC
- 3.1.85 SPEED
- 3.1.86 SQ
- 3.1.87 STOP
- 3.1.88 SUB
- 3.1.89 SWAP
- 3.1.90 SYMBOL
- 3.1.91 TAB
- 3.1.92 TAG
- 3.1.93 TAGOFF
- 3.1.94 TROFF
- 3.1.95 TRON
- 3.1.96 USING
- 3.1.97 WAIT
- 3.1.98 WHILE WEND
- 3.1.99 WIDTH
- 3.1.100 WINDOW
- 3.1.101 WRITE
- 3.1.102 ZONE
- 3.2 Operators
- 3.3 Functions
- 3.3.1 ABS (n)
- 3.3.2 ASC
- 3.3.3 ATN (n)
- 3.3.4 BIN$ (i1,[i2])
- 3.3.5 CHR$
- 3.3.6 CINT
- 3.3.7 COPYCHR$
- 3.3.8 COS
- 3.3.9 CREAL
- 3.3.10 DEC$
- 3.3.11 DERR
- 3.3.12 EOF
- 3.3.13 ERR
- 3.3.14 EXP
- 3.3.15 FIX
- 3.3.16 FRE
- 3.3.17 HEX$
- 3.3.18 HIMEM
- 3.3.19 INKEY
- 3.3.20 INKEY$
- 3.3.21 INP
- 3.3.22 INSTR
- 3.3.23 INT
- 3.3.24 JOY
- 3.3.25 LEFT$
- 3.3.26 LEN
- 3.3.27 LOG
- 3.3.28 LOG10
- 3.3.29 LOWER$
- 3.3.30 MAX
- 3.3.31 MIN
- 3.3.32 PEEK
- 3.3.33 PI
- 3.3.34 POS
- 3.3.35 REMAIN
- 3.3.36 RIGHT$
- 3.3.37 RND [(n)]
- 3.3.38 ROUND (n[,i1])
- 3.3.39 SGN (n)
- 3.3.40 SIN (n)
- 3.3.41 SPACE$
- 3.3.42 SQ (channel)
- 3.3.43 SQR (n)
- 3.3.44 STR$
- 3.3.45 STRING$
- 3.3.46 TAN
- 3.3.47 TEST
- 3.3.48 TESTR
- 3.3.49 TIME
- 3.3.50 UNT
- 3.3.51 UPPER$
- 3.3.52 VAL
- 3.3.53 VPOS (#st)
- 3.3.54 XPOS
- 3.3.55 YPOS
- 3.1 Commands and operators
- 4 Other Basic Dialects avaliable for the CPC
- 5 Web links
Description
Locomotive BASIC, was one of the best and fastest BASIC implementations of the era. The language benefited both from a clean, well-thought out implementation of the core language by Locomotive, and by the excellent firmware of the CPC, which lent most of its advanced features to the BASIC.
Unlike the competing Commodore 64, it featured a comprehensive graphic capabilities with its PLOT, DRAW, PAPER, INK, PEN, BORDER and (in BASIC 1.1) FILL commands. It had extensive sound commands, granting control of the AY-3-8912 via the firmware's volume and tone envelope system. With the SOUND command, you could select channels, set envelopes, pitch, noise and volume. That was something unmatched by other computers of that era.
Also there was simple interface for memory management, with MEMORY and LOAD commands. The latter allowed for loading of raw screen data, thus providing easy picture showing. Both through this (combined with CALL, PEEK and POKE) and the firmware's RSX system, it was easy to mix BASIC and assembly code, thereby speeding up programs by coding the slowest parts directly in machine code. Many successful programs, including games such as Radzone and applications such as PowerPage, made use of this technique.
With DEF FN, ON variable GOTO and ON variable GOSUB, Locomotive BASIC provided the rudiments of "structured programming", though nowhere near the extent of the PROCedures of BBC BASIC.
All in all, if you compare BASIC interpreters of that era, the Locomotive's seems to be the best 'all-rounder' regarding the combination of speed and complexity, and still some of its features were unmatched by others.
History
The CPC implementation of Locomotive BASIC was developed directly from Locomotive Software's existing Z80 BASIC. The existence of this is cited as one of the reasons Locomotive requested that Amstrad change the CPC's processor from a 6502 to a Z80.
The 464 shipped with BASIC 1.0 on ROM.
The language was revised and debugged for the 664, 6128 and Plus machines to become BASIC 1.1. Changes were minor but significant for the programmer, and included:
- DEC$ bug removed (in BASIC 1.0, it required two opening brackets and was undocumented)
- Better handling of string arguments to RSXs (|DIR,"*.BAS" rather than a$="*.BAS":|DIR,@a$)
- DATA statements can appear anywhere within a line; in BASIC 1.0, they had to be at the end of a line
- FILL command (fill area with solid colour)
- COPYCHR$ function (fetch character from screen)
- Better garbage collection
- Some number-handling bugs removed (e.g. in FOR loops with negative start/end values)
- FRAME (CALL &BD19)
- Extra, optional 'plotting mode' parameter for DRAW/PLOT commands (supported only through control codes on BASIC 1.0)
- GRAPHICS PAPER, GRAPHICS PEN commands
- ON BREAK CONT (disable ESCape)
- CLEAR INPUT (flush keyboard buffer)
- The AUTO command show the whole line if it exist, it only printed a * on the 464
Some parts of 'BASIC' were actually housed in the firmware ROM, but were not officially accessible to other programs. This included the line editor.
The 'pure BASIC' parts of Locomotive BASIC - i.e. those not concerned with CPC-specific firmware and hardware features - were upgraded to become Mallard BASIC, the CP/M language shipped with the PCW. This also featured exceptionally advanced random-access file handling, a feature missing from the CPC.
Command list
Commands and operators
AFTER I[,t] GOSUB Ln
- Waits for i/50 seconds and then jumps to the subruotine at line Ln.
AUTO [Ln, i]
- Automaticaly generates line numbers starting at line Ln with increment i between line numbers.
- Use [ESC to leave AUTO mode. Default value for Ln and i is 10.
- Example:
- AUTO 100,5 - generates line numbers 100, 105, 110...
BORDER
- [...]
CALL add[,list of parameters]
- Allows an externally developed subroutine to be called by BASIC
- Example:
- CALL 0 - resets the computer completely
CAT
- Displays the names of all existing programes on the tape or disk.
- Examples:
- CAT [ENTER] - lists all disk files in alpha-numeric order
- TAPE [ENTER]
- CAT [ENTER] - lists names of all tape files in their storage order
CHAIN
- [...]
CHAIN MERGE
- [...]
CLEAR
- Clears all variables from memory, leaving the program in memory unchanged. All open files are abandoned.
CLG [ink]
- Clears the graphics screen to colour specified by ink. If parameter ink is not specified them the graphics screen is cleared to the colour specified by the GRAPHICS PAPER statement.
CLOSEIN
- [...]
CLOSEOUT
- [...]
CLS
- [...]
CONT
- [...]
CURSOR
- [...]
DATA
- [...]
DEF
- [...]
DEFINT
- [...]
DEFREAL
- [...]
DEFSTR
- [...]
DEG
- [...]
DELETE
- [...]
DI
- Disables interrupts (but not[ESC]) until re-enabled by EI command or by RETURN at end of an interrupts service routine.
DIM
- [...]
DRAW x,y [,[i1][,i2]]
- Draws a line from the current cursor position to position x,y. i1 specifies colour, i2 is the logical colour.
i2 = 0 normal colour i2 = 2 AND colour i2 = 1 XOR colour i2 = 3 OR colour
- Example:
- CLG 2
- DRAW 500,400,0 - draws a line from 0,0 to 500,400
DRAWR xr, y2, [[i1][,i2]]
- Draws a line from current graphics cursor position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as DRAW.
- Example:
- Move 200,200
- DRAWR 100,100,0 - draws a line from 200,200 to 300,300
EDIT
- [...]
EI
- Enable interrupts which have been disabled by DI
END
- Indicates end of program
ENT
- [...]
ENV
- [...]
ERASE v[$(i1[,i2])
- Clears the contents of an array that is no longer required.
ERL
- [...]
ERROR i
- Returns the error message whose error code number is i.
EVERY
- [...]
FILL i
- Fills an area of a graphics screen i colour i (0-15). Default value of i is the current graphics pen colour. Only available in Basic 1.1.
FN
- [...]
FOR TO STEP NEXT
- [...]
FRAME
- Smooths character and graphics movement and reduces flicker (waits for a VSYNC signal). Only available in Basic 1.1. On a CPC 464 you can use CALL &BD19 instead.
GOSUB i
- Jumps to subroutine which is given as argument.
- Example:
10 PRINT "Calling subroutine" 20 GOSUB 100 30 PRINT "Back from subroutine" 40 END 100 REM Begin of the subroutine 110 PRINT "Subroutine started" 120 RETURN
GOTO i
- Jumps to the line number which is given as argument.
- Example:
10 GOTO 100 20 REM not executed 30 REM not executed 100 PRINT "Hello World!"
GRAPHICS
- [...]
IF THEN ELSE
- [...]
INK
- [...]
INPUT
- [...]
KEY
- [...]
LET
- [...]
LINE
- [...]
LIST
- [...]
LOAD
- [...]
LOCATE
- [...]
MASK
- [...]
MEMORY
- [...]
MERGE
- [...]
MID$
- [...]
MODE
- [...]
MOVE
- [...]
MOVER
- [...]
NEW
- [...]
ON BREAK
- [...]
ON ERROR
- [...]
OPENIN
- [...]
OPENOUT
- [...]
ORIGIN
- [...]
OUT
- [...]
PAPER
- [...]
PEN
- [...]
PLOT
- [...]
PLOTR
- [...]
POKE
- [...]
- [...]
RAD
- [...]
RANDOMIZE
- [...]
READ
- [...]
RELEASE
- [...]
REM
- [...]
REM
- [...]
RENUM
- [...]
RESTORE
- [...]
RESUME
- [...]
RETURN
- [...]
RUN
- [...]
SAVE
- [...]
SOUND
- [...]
SPC
- [...]
SPEED
- [...]
SQ
- [...]
STOP
- [...]
SUB
- [...]
SWAP
- [...]
SYMBOL
- [...]
TAB
- [...]
TAG
- [...]
TAGOFF
- [...]
TROFF
- [...]
TRON
- [...]
USING
- [...]
WAIT
- [...]
WHILE WEND
- [...]
WIDTH
- [...]
WINDOW
- [...]
WRITE
- [...]
ZONE
- [...]
Operators
AND
- [...]
MOD
- [...]
NOT
- [...]
OR
- [...]
XOR
- [...]
Functions
ABS (n)
- Returns the absolute value of n by ignoring the sign value.
- Example
- PRINT ABS(-3.5) - prints 3.5
ASC
- [...]
ATN (n)
- Returns the arctangent of n.
BIN$ (i1,[i2])
- Returns binary representation of i1 between -32768 and 65535. The number of binary digits (0s and 1s) is specified by i2 (0-16)
- Example:
- PRINT BIN$(66,8) - prints 01000010
CHR$
- [...]
CINT
- [...]
COPYCHR$
- [...]
COS
- [...]
CREAL
- [...]
DEC$
- [...]
DERR
- [...]
EOF
- [...]
ERR
- [...]
EXP
- [...]
FIX
- [...]
FRE
- [...]
HEX$
- [...]
HIMEM
- [...]
INKEY
- [...]
INKEY$
- [...]
INP
- [...]
INSTR
- [...]
INT
- [...]
JOY
- [...]
LEFT$
- [...]
LEN
- [...]
LOG
- [...]
LOG10
- [...]
LOWER$
- [...]
MAX
- [...]
MIN
- [...]
PEEK
- [...]
PI
- [...]
POS
- [...]
REMAIN
- [...]
RIGHT$
- [...]
RND [(n)]
- Generates the next random number in the current squence if n is positive or omitted. If n = 0, the random number generated will be the same as the last random number generated.
ROUND (n[,i1])
- Rounds n to a number of decimal places or to the power of ten specified by i. If i is negative, the n is rounded to give an absolute integer with i zeros before the decimal point.
- Example
- PRINT ROUND(1562.357,2):PRINT ROUND(1562.375,-2) - prints 1562.36 1600
SGN (n)
- Returns 1 if n is positive, 0 if n = 0, -1 if n is negative.
SIN (n)
- Returns sine of n in degree or radian mode (see DEG and RAD)
SPACE$
- [...]
SQ (channel)
- Returns a bit significant integer showing state of the sound queue for specified channel where channel 1, 2, 3 = A, B, C.
Bits 0,1 and 2 number of free entries in the queue Bits 3,4 and 5 redezvous state at head of the queue Bit 6 head of the queue is held Bit 7 channel is currently active
SQR (n)
- Returns the square root of n.
STR$
- [...]
STRING$
- [...]
TAN
- [...]
TEST
- [...]
TESTR
- [...]
TIME
- Returns time elapsed since the computer was switched on or reset.
- One second = TIME/300.
UNT
- [...]
UPPER$
- [...]
VAL
- [...]
VPOS (#st)
- Reports the current row (line) position of the text cursor relative to the top of the text windows of the specified stream.
XPOS
- [...]
YPOS
- [...]
(Please, fill in. Looks like a lot of work ;-) ...)