Category:Locomotive Basic: Difference between revisions
Turned off HoPL reference.
No edit summary |
(Turned off HoPL reference.) |
||
(9 intermediate revisions by one other user not shown) | |||
Line 1:
{{language|Locomotive Basic
|exec=interpreted
|site=http://www.grimware.org/doku.php/documentations/software/locomotive.basic/
|hopl=no
}}
{{implementation|BASIC}}
'''Locomotive BASIC''' is a variant of BASIC that is built into the ROM of the [[wp:Amstrad CPC|Amstrad CPC]] series of
The CPC came with a built-in cassette deck (CPC 464) or 3" disk drive (CPC 664 and ▼
6128) as storage devices and a green screen or color monitor which also housed the power supply. Amstrad CPC sales were particularly strong in the UK, Germany, France, and Spain.▼
[https://www.retrovm.com/ CPCBox] is another option for the web browser, a whole-machine JavaScript CPC emulator mainly for games which has good compatibility but which lacks copy and paste support.
Today, Locomotive BASIC can be used via native CPC emulators such as [http://www.winape.net/ WinAPE] (Windows) or [http://sourceforge.net/projects/javacpc/ JavaCPC] (Windows/macOS/Linux), which is also perfectly legal because Amstrad has given their permission for distributing CPC ROM images with emulators.▼
▲
▲For web browsers there is also a [https://benchmarko.github.io/CPCBasic/cpcbasic.html JavaScript emulator for Locomotive Basic] itself, which allows easy pasting of code from Rosetta Code. Note however that programs will run much faster than on a real CPC (or a realistic emulator), so some code may require an extra delay loop each frame, e.g. <lang locobasic>for delay=1 to 10000:next</lang> [https://www.retrovm.com/ CPCBox] is another web browser option, a whole-machine JavaScript CPC emulator mainly for games which has good compatibility but which lacks copy and paste support.
==Getting started with Locomotive BASIC==▼
==Features==▼
Either use
In CPCBasic, enter your program, e.g.
into the "CPC Basic" text box at the top and then press the Run button below it. Output goes to the blue CPC screen below. You can also interact with the CPC screen directly if you first click on it with the mouse. The Reset button stops a running program and returns you to the Ready prompt.
<lang locobasic>10 print "Hello World!"
run</lang>▼
to run your first Locomotive BASIC program.▼
▲==CPC Features==
▲The CPC was based on a Zilog Z80 CPU running at 4 MHz and came with a built-in cassette deck (CPC 464) or 3" disk drive (CPC 664 and
▲6128) as storage devices and a green screen or color monitor which also housed
Locomotive BASIC was comparatively advanced for its time (with e.g. software interrupts and comprehensive graphics and audio commands) and is very cleanly implemented, just like the rest of the Amstrad CPC ROM. No doubt this was partly because the CPC debuted relatively late during the era of 8-bit machines, so Locomotive Software had more of an opportunity to consider the good and bad software design decisions in existing home computers.
System calls are made with <tt>CALL</tt> via dedicated jump blocks in RAM, so they are unaffected by changes to the ROM between CPC models. This makes software very compatible between the original three CPC models and ''mostly'' compatible for the later, considerably less popular "Plus" models that came out in 1990. Together with AMSDOS, the '''Ams'''trad '''D'''isk '''O'''perating '''S'''ystem, Locomotive BASIC is also used for disk and tape operations. (Some commands however, e.g. <tt>disckit3</tt> for formatting disks, are only available under CP/M.)
===Screen modes===
*mode 0: 160x200 pixels, 16 colors, 20x25 characters
*mode 1: 320x200 pixels, 4 colors, 40x25 characters
*mode 2: 640x200 pixels, 2 colors, 80x25 characters
*mode 3 (CPCBasic only!): 640x400 pixels, 16 colors, 80x50 characters
Pixels are addressed in physical units from BASIC, i.e. the center of the screen is always at 320, 200 and the top right corner is always at 639, 399, regardless of selected mode.
▲Locomotive BASIC was comparatively advanced for its time (with e.g. software interrupts and comprehensive graphics and audio commands) and is very cleanly implemented, just like the rest of the Amstrad CPC ROM. No doubt this was partly because the CPC debuted relatively late during the era of 8-bit machines, so Locomotive Software had more of an opportunity to consider the good and bad software design decisions in existing home computers. System calls are made with <tt>CALL</tt> via dedicated jump blocks in RAM, so they are unaffected by changes to the ROM between CPC models. This makes software very compatible between the original three CPC models and ''mostly'' compatible for the later, considerably less popular "Plus" models that came out in 1990. Together with AMSDOS, the '''Ams'''trad '''D'''isk '''O'''perating '''S'''ystem, Locomotive BASIC is also used for disk and tape operations. (Some commands however, e.g. <tt>disckit3</tt> for formatting disks, are only available under CP/M.)
==Z80 Extensions==
Line 34 ⟶ 66:
The extensive CPC user manual features a finely written introduction to BASIC that does not feel as rushed or dumbed-down as in some other manuals of the time. Obviously Amstrad expected many customers would want to program their CPCs themselves, not just use them with off-the-shelf software. There are even some pretty decent BASIC type-in games in appendix 3, such as clones of the arcade classics ''[[wp:Breakout (video game)|Breakout]]'' and ''[[wp:Pong|Pong]]''.
▲==Getting started with Locomotive BASIC==
▲Either use a browser-based CPC emulator (http://www.cpcbox.com/) or download a binary for your platform. A list of emulators is available at http://cpcwiki.eu/index.php/Emulators. JavaCPC (http://sourceforge.net/projects/javacpc/) or WinAPE (http://www.winape.net/) are particularly recommended. An advantage of native emulators is that they tend to have copy-and-paste functionality, so you can edit programs in external editors.
▲In the emulator, type
▲<lang locobasic>10 print "Goodbye, World!"
▲run</lang>
▲to run your first Locomotive BASIC program.
==References==
|