Spectrum +3 basic

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

Spectrum +3 basic

Post by retro_collector » Mon Sep 16, 2019 5:04 pm

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
0 x

User avatar
spider
Microbot
Posts: 112
Joined: Wed May 01, 2019 9:59 am
Location: UK
Contact:

Re: Spectrum +3 basic

Post by spider » Mon Sep 16, 2019 5:12 pm

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.
0 x

retro_collector
Berk
Posts: 15
Joined: Fri Sep 13, 2019 6:58 pm
Location: Chicago, IL USA

Re: Spectrum +3 basic

Post by retro_collector » Mon Sep 16, 2019 7:17 pm

Thanks Andy!

Everything works great!

Thanks for taking the time to explain it to me!

Bill
1 x

User avatar
spider
Microbot
Posts: 112
Joined: Wed May 01, 2019 9:59 am
Location: UK
Contact:

Re: Spectrum +3 basic

Post by spider » Mon Sep 16, 2019 7:48 pm

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

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

Bill
You're very welcome. Enjoy! :)
0 x

Post Reply