18

The Amstrad CPC range of Z80 machines shipped with a ROM BASIC, designed and implemented by Locomotive Software. The most well known competitor was the Sinclair ZX Spectrum, also a Z80 machine, with similar capabilities.

I'm aware that both Sinclair and Locomotive Basics were more advanced than the C64 Microsoft implementation, but neither had the procedure functions or other niceties of BBC BASIC.

In what ways did Locomotive BASIC significantly improve the language when compared to Sinclair BASIC, for example on the 48k or 128k Spectrum?

Incidentally, I'm not interested in comparisons between the two machines.

  • 5
    I had both machines and I thought the CPC was far superior in every way but thats just my opinion – djack109 Nov 25 '19 at 19:44
  • 1
    Same here, but you'd expect that given price and age, Spectrum released in 1982 and Amstrad 1984. – davidjwest Nov 26 '19 at 11:52
  • 1
    Yes, hence my question focused on the structure of the language, not the capabilities of each machine. – Mark Williams Nov 26 '19 at 12:52
22

The big improvement to the language in Locomotive BASIC, compared to Sinclair BASIC (and many other BASICs), was the addition of timer support:

AFTER 50,0 GOSUB 320

would call the subroutine at line 320 after a second, and

EVERY 500,0 GOSUB 320

would call the subroutine every ten seconds. In both cases, the first value is the interval in fiftieths of a second, and the second is the timer channel (there are four timers, with different priorities, driven by a 300Hz timer interrupt).

There were also improvements to the sound support but they were hardware-specific and not really improvements to the language itself. These provided access to the AY-3-8912’s features, within the limitations of the BASIC interpreter: tone shape control, volume shape control, multiple channels, etc.

Compared to many BASICs Locomotive BASIC had good graphics support, but Sinclair BASIC also had decent graphics support, and both used similar commands (INK, DRAW, FILL etc.) — Locomotive’s main improvement here was the addition of windows, i.e. a way to subdivide the screen into up to eight areas, and send different output streams to each one.

  • I'm really curious what units the 50 and 500 are in...? Or is it a typo and they should be 60 and 600? – T.J. Crowder Nov 25 '19 at 16:37
  • 1
    @T.J.Crowder the Amstrad was a resolutely European machine, so 50 Hz timers were natural – scruss Nov 25 '19 at 18:40
  • 2
    Timing on the CPC isn't based on mains frequency, but on a 300 Hz timer interrupt, called fast timer. Every 6th tick all 50 Hz queues were handled. The OS is prepared to work at every 5th as well for 60 Hz environments, but that was never used - and is buggy as well. The queue system is quite comfortable and unlike other 8-bit machines of that time. Most internal management is asynchronous and based thereon. Sound isn't hard to the sound chip, but rather abstract handed in the timer queue system. I would account it more on the abstract BASIC side. – Raffzahn Nov 26 '19 at 0:18
  • 1
    It's only indirectly related to the mains power frequency. Most likely the timer is driven from the vertical blanking interval timer, ie. the 50Hz frequency is due to the display standard (PAL). TV specifications took the locally prevailing mains frequency into account to make it easier to provide a stable picture on a CRT. – Chromatix Nov 26 '19 at 0:18
  • 1
    @Mast and amazingly enough that’s still a consideration on more recent systems! – Stephen Kitt Nov 26 '19 at 15:14
20

Was Locomotive BASIC significantly better than Sinclair BASIC?

TL;DR: Oh, yes, it was!


I'm aware that both Basics were more advanced than the C64 Microsoft implementation,

Comparison of C64 BASIC to other BASICs of the same time is never in favour for the C64, as it's a quick port of the original 1977 PET Version.

but neither [Locomotive BASIC, BBC BASIC] had the subroutine functions or other niceties of BBC BASIC.

While Locomotive BASIC differs in some parts, it is quite close to BBC Basic - in functionality and due to history - while offering many improvements over BBC BASIC.

In what ways did Locomotive BASIC significantly improve the language when compared to Sinclair BASIC, for example on the 48k or 128k Spectrum?

Sinclair BASIC, developed by Nine Tiles in Cambridge is a rather conventional BASIC, based on the standards set by Microsoft regarding functionality. The Spectrum version is a straight evolution from the 4 KiB BASIC of the ZX80, over the 8 KiB ZX81 BASIC, which grew out of the FP version for the ZX80, to the 16 KiB Spectrum ROM. In fact, its development had much in common with the way Commodore BASIC evolved. Much like Tramiel, Sinclair's focus was on the product to be sold - with a core point about cramping as much functionality in at a given cost point.

Unlike Tramiel, he could be convinced by his developers about necessary improvements - like doubling the ROM size for the Spectrum to cover new functionality. Still he didn't give them a go for a real redesign, while adding much time pressure(*1), resulting in untidy and slow code, while at the same time missing essential functionality - to be fixed with the shadow ROM of the Interface 1 (*2).

As a result, Sinclair Spectrum BASIC is a straightforward standard BASIC with additions to handle

  • Screen (AT, ATTR, INVERSE, OVER, SCREEN$)
  • Colour (BORDER, FLASH, INK, PAPER)
  • Graphics (CIRCLE, DRAW, PLOT, POINT)
  • SOUND (BEEP)
  • File I/O for microdrives (CAT, ERASE, FORMAT)

Plus the quite helpful BIN to enter binary numbers for graphics.

for example on the 48k or 128k Spectrum

Above is true for the original 48 KiB Spectrum as the 128 is a beast of its own - well, when not looking at all the unfinished features :))

Locomotive BASIC in contrast is a newer development based on the BASIC for the Z80 tube. Development started for a proposed but never released Z80-based business system by Acorn. It was thus heavily influenced by Acorn/BBC BASIC. It's last incarnation is Mallard BASIC for the PCW.

It is said that it was Locomotive Software's request that changed the CPC design from using a 6502 to be Z80-based. Amstrad agreed, as it would save quite some cost in software development (*3). As a result, Locomotive Software delivered most system software for the CPC, including AMSDOS.

Listing everything where Locomotive BASIC is enhanced over standard BASIC would go way off-road - much like doing the same for BBC BASIC. But comparing the latter two is an interesting point, due to their common origin. Here Locomotive BASIC improves a lot of the rather awkward parts. For example, most of the cryptic *FX and VDU commands in BBC BASIC have nice keywords in Locomotive BASIC. Of course hardware-related issues will differ - like screen modes, colour numbers or coordinates - as they did on almost any machine back then.

Comparing two BASICs is, to some degree, up to taste and opinion - as many articles show. For a somewhat objective approach it has been proven useful to see what effort it is to port/convert a program between two BASIC dialects.

When porting BBC BASIC programs to Locomotive BASIC, only the BBC's approach to (somewhat) structured programming is a hurdle. While TRUE and FALSE can be replaced by 0 and -1 and REPEAT ... UNITL replaced by WHILE ... WEND with an inverted test, the mentioned PROCedures are missing at all and needs replacement by classic parameter passing and GOSUB.

Porting the other way around is way more challenging, as Locomotive BASIC added a lot of directly accessible functionality. It not only made screen handling much more readable, it also added basic functionality which would need large code sections or assembly routines in BBC BASIC. For example, the timer handling as mentioned by Stephen Kitt, but also really comfortable sound management, including queue management, text windowing and much more.

Conclusion:

While BBC BASIC has an advantage with the mentioned PROCedure in structuring, Locomotive and BBC are quite feature rich BASICs of their time and in general on par with Locomotive being the richer of both - no wonder, given it being the newer of both.

Sinclair BASIC on the other hand is a much more simple implementation than either. It does cover the basic functionality of its machine quite well, due to fitting commands, while missing innovation on the BASIC side.


*1 - Again, as the same already happened with the ZX81 ROMs resulting in the infamous square root of .25 bug for the first series.

*2 - A nice twist of history here is, that Sinclair never owned the rights to the original ROMs, just the shadow ROM patches. So Amstrad had to buy them from Nine Tiles later on.

*3 - Back then BASIC interpreters, and next to all other system software, was written in Assembly, making the choice of the CPU to be used reliant on more than just speed and chip cost.

  • Thanks for the additional comparison of Locomotive with BBC BASIC. I didn't ask, because I assumed that BBC was the gold standard of the time period. – Mark Williams Nov 26 '19 at 12:54
  • 1
    @MarkWilliams Sure, while MS-BASIC is kind of a lower limit, BBC BASIC was rather an upper end benchmark than an upper limit - after all, it can always get better. Locomotive BASIC had several years to improve upon. While points can be made for either side, I think Locomotive BASIC did depose BBC quite clear - only to be dwarfed by QL's SuperBASIC soon after. Locomotive BASIC may mark peak of (widely distributed) classic ROM BASICs. After that an era ended anyway. – Raffzahn Nov 26 '19 at 13:16
9

Considering how much of a rush job Locomotive BASIC was, it's remarkably good. But it's not perfect.

Sinclair BASIC has one powerful keyword that Locomotive BASIC lacks: VAL. Sure, Locomotive BASIC has a VAL() function, but Sinclair's one is a function evaluator:

10 FOR X=-5 TO 5
20 PRINT X,VAL ("X * X")
30 NEXT X

This would fail on an Amstrad CPC, but on a ZX Spectrum it prints out -5 … 5 and the squares of those numbers. This is similar to BBC BASIC's EVAL keyword.

A few of Locomotive BASIC's shortcomings include:

  • Even with a disc drive, Locomotive BASIC has no random access functions. You're limited to one file open as input and one as output, all with sequential access only.

  • AMSDOS relied heavily on RSXs (resident system extensions, aka “bar commands”, eg |CPM, |DIR) instead of adding commands to the interepreter.

  • The syntax of those RSXs changed from BASIC 1.0 + AMSDOS on the CPC464 to BASIC 1.1 on the CPC664/CPC6128. In Locomotive BASIC 1.0, you couldn't give a string as an RSX parameter. So, for example, to delete FILE.DAT:

    Locomotive BASIC 1.0: A$="FILE.DAT": |ERA, @A$

    Locomotive BASIC 1.1: |ERA, "FILE.DAT"

  • 2
    What's more, Sinclair BASIC evaluated every input, which could be very helpful. If the program does INPUT x, the user could input SIN(SQR(3)/2), and it would be calculated. Or could even use existing variables. I've never encountered such feature in any other BASIC dialects. – Zeus Nov 25 '19 at 6:02
  • 1
    VAL and the related evaluation of numeric input may be nice form a tool PoV, but then again, they are as well a wide open door for bugs. – Raffzahn Nov 25 '19 at 11:24
  • Presumably the use of RSXs was to maintain back compatibility in case anyone had used those keywords as variables? – Mark Williams Nov 25 '19 at 17:11
  • 1
    @MarkWilliams - I suppose so. Locomotive BASIC's | had much the same function as the BBC Micro's *: look for commands registered through a system method. I know that the AMSDOS ROM was supposed to have bits of DR-LOGO in it, I wonder if the CP/M 2.2 ERA and REN commands were called from ROM too? – scruss Nov 25 '19 at 18:37
  • 1
    That story on The Register was a good read - thanks for the link to that and subsequent nostalgia trip! The name Locomotive Software has stuck in my mind for years due to their Basic 2 bundled with GEM Desktop on my Amstrad PC1512. – Aaron F Nov 26 '19 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.