I'm trying to write some programs from an old magazine that were specified to run on an ZX80/ZX81 but I'm using a Sinclair BASIC interpreter for the Spectrum.
Is there any significant changes in BASIC instructions for those computers?
I'm trying to write some programs from an old magazine that were specified to run on an ZX80/ZX81 but I'm using a Sinclair BASIC interpreter for the Spectrum.
Is there any significant changes in BASIC instructions for those computers?
Spectrum BASIC is a superset of the earlier BASICs (all the colour commands, etc), so pedantically the answer to the question is the title of the post is "yes, there are significant differences".
However, if you're asking whether a earlier BASIC program can be run on the Spectrum, the answer is mostly yes. Possibly the most notable changes are:
PLOT works differently on the earlier machines (where it functioned on a 64x44 grid) and the Spectrum (where it functioned on a 256x176 grid). If not corrected, PLOT statements will all end up in the bottom-left corner of the Spectrum's screen.
UNPLOT does not exist on the Spectrum; it can be emulated with PLOT INVERSE 1 or similar with the same caveats as for PLOT.FAST and SLOW mode (as it didn't use the Z80 to render the screen); just ignore those commands.0 to 9 and A to Z are contiguous ranges in both sets so a lot of stuff will work).(X/4)*4) then you will need to scatter some INT calls in the ZX81/Spectrum code.There was even a utility back in the day, ZX Slowloader, which emulated the ZX81's tape loading routine so ZX81 tapes could be loaded into the Spectrum.
PLOT thing will plot things in the bottom-left corner, as Y coords where bottom-up. My 11-year-old self was really confused - I typed some PLOT-based ZX81 on my Spectrum, and couldn't figure out the point of those tiny drawings. Fun times!
– Jonathan
Apr 19 '22 at 07:14
"" in a listing but " when printed; the Spectrum allows you to insert a " in a string by simply doubling it.
– Neil
Apr 19 '22 at 11:04
SCROLL statement on the ZX81 -- the nearest equivalent on the Spectrum is POKE 23692,255: PRINT AT 21,0: PRINT
– john_e
Apr 28 '22 at 10:28
The Spectrum's character set was based on 7-bit ASCII. The main printing sets (20-7F) are nearly pure ASCII, the only differences are that 60="£" in Speccy, but "`" in ASCII, likewise 7F is "©" instead of DEL. My reference¹ shows 5C is "/" whereas ASCII has "\" but I think this may be a typo since 2F is also "/". The Speccy did, however, use the first 32 codes and all codes after 80 for its own purposes. 0D is mapped to ENTER, which matches with ASCII's CR. 80-8F are block graphics, 90-A4 are user-defined graphics and A5 to FF are the tokenised commands for BASIC.
The ZX80's character set has no relation to ASCII:² 00→space, 01→null string, 02-0B→chunky graphics, 0C-1B→"£$:?()_+*/=><;,.", 1C-25→"0-9", 26-3F→"A-Z", 40-7F (undefined) 80-BF inverses of 00-3F, D4-FF→tokens and some more punctuation.
Unfortunately I have no reliable copy of the ZX81 mappings. I've found the character code tables for the ZX81 between 007E and 01FB in the ROM.³ As pointed out by Tommy in a comment below, they are similar not quite identical, eg "<" is at 0x17 on a ZX80 but 0x12 in the ZX81 ROM.
Others have mentioned number representation: ZX80-integer only, ZX81-float only, Speccy-both. The ZX80 could not display a screen and calculate at the same time. The ZX81 had fast mode which was like the ZX80, and slow mode which used the NMI to interrupt calculations and display a screen before returning to calculate during frame fly-back. The Speccy used hardware to handle the screen.
¹Database Publications. The Complete Spectrum. Stockport: Database Publications, 1984. 004.165/SIN.
²Maunder, Bob, Terry Trotter, and Ian Logan. The ZX80 Companion. Second edition. Middlesbrough, England: Linsac, 1980. 004.165/SIN.
³Logan, I., and F. O’Hara. The Complete Timex TS1000 [and] Sinclair ZX81 ROM Disassembly. P.A. Cheddington, Leighton Buzzard, Bedfordshire: Melbourne House Publ, 1982. 005.265/SIN
11/2 to return anything other than 5.5.
– Philip Kendall
Apr 19 '22 at 11:40
Question is about translating ZX81 Basic to ZX Spectrum.
It's been about 40 years since I last did this from magazine listings, but the one thing that used to trip me up was not the bulk of the Basic listing but some POKEs and PEEKs. Or little bits of machine code to scroll screens or implement user defined characters etc, were common in ZX81 code
From memory, something like a peek of free RAM was different between the two, so that these didn't translate well without a cheatsheet of common peek/poke locations
(3/2) > 1. – Philip Kendall Apr 18 '22 at 22:11If that's not obvious, what's the problem?
If that is obvious, what's the Question?
In ordinary English this would be pedantic. In terms of programming languages, you're not trying to write, only to replicate. Is that difference not significant to you?
In many cases older Sinclair code will be upwards compatible but that's not guaranteed.
More…
– Robbie Goodwin Apr 21 '22 at 21:07To replicate legacy Sinclair coding on a modern machine, please accept Sinclair refused to use, or endorse, standard keyboards. Sir Clive's insistence on his own designs meant Sinclair kit was hugely more difficult to work with, in ways today's Users may find unimaginable.
Since we cannot now usefully replicate Sinclair's button technology, which today looks cheapskate, there's no possibility of a useful comparison.
Would you like details?
– Robbie Goodwin Apr 21 '22 at 21:52