Spectrum +3 basic

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
retro_collector
Drutt
Posts: 15
Joined: Fri Sep 13, 2019 7:58 pm
Location: Chicago, IL USA

Spectrum +3 basic

Post by retro_collector »

Hi Everyone,

I am new to Spectrum. Just got my Speccy +3.

When ever I get a new computer I like to look at the characters in ROM. So I wrote a program that works on every computer I have except my new +3.
Can anyone please tell me why this program doesn't work?

10 FOR X=0 to 255
20 PRINT CHR$(X);
30 NEXT X

Thanks!

Bill
User avatar
spider
Dynamite Dan
Posts: 1099
Joined: Wed May 01, 2019 10:59 am
Location: Derby, UK
Contact:

Re: Spectrum +3 basic

Post by spider »

Hi Bill. :)

It does actually "work" but codes lower than 32 are 'control codes' mainly legacy things for printers and also control things like ink/paper colours. Codes above 127 are tokens and will on the Speccy represent keywords like BORDER / PRINT etc as well as some for user defined graphics too. So attempting to print things below 32 will sometimes cause errors as some are unused too.

If you change your program to 'start' at 32 and 'end' at 127 it will work. 32 you won't really 'see' as its the space character and 127 is the copyright Ⓒ character.

Code: Select all

10 FOR X=32 to 127
You could leave the end alone too:

Code: Select all

10 FOR X=32 to 255
Regarding control codes, for instance you can type

Code: Select all

10 PRINT INK 4; " cats and dogs "
or

Code: Select all

10 PRINT CHR$ 16 + CHR$ 4 + " cats and dogs "
That gives the same effect as 16 is 'ink'

There is a list in the Manual at the back under 'character set' , generally speaking ( ! ) the common ones I sometimes use are:

8 = Backspace
13 = Newline
16 = INK
17 = PAPER
18 = FLASH
19 = BRIGHT
20 = INVERSE
21 = OVER
22 = AT
23 = TAB

They have to be followed by a valid value, see my '16+4' line above. AT has to have an x,y so you would for instance use:

Code: Select all

10 PRINT CHR$ 22 + CHR$ 12 + CHR$ 12 + " testing "
That's the same as typing:

Code: Select all

10 PRINT AT 12 , 12 ; " testing "
Hope that helps a bit. It is usually best to not try to 'print/display' control codes out unless you are sure what you're doing. The effects might vary a bit on model (48/128) too possibly.
retro_collector
Drutt
Posts: 15
Joined: Fri Sep 13, 2019 7:58 pm
Location: Chicago, IL USA

Re: Spectrum +3 basic

Post by retro_collector »

Thanks Andy!

Everything works great!

Thanks for taking the time to explain it to me!

Bill
User avatar
spider
Dynamite Dan
Posts: 1099
Joined: Wed May 01, 2019 10:59 am
Location: Derby, UK
Contact:

Re: Spectrum +3 basic

Post by spider »

retro_collector wrote: Mon Sep 16, 2019 8:17 pm Thanks Andy!

Everything works great!
Excellent.
retro_collector wrote: Mon Sep 16, 2019 8:17 pm Thanks for taking the time to explain it to me!

Bill
You're very welcome. Enjoy! :)
Post Reply