Tag - STOS

Control Extension

Written by Les Greenhalgh, this useful extension allows you access to the ST’s parallel port, the ability to create mega zones, and a host of other useful commands.

Feb 2025 Update:

After being lost for over 30 years, a registered version of the control extension 3.6 has been uncovered. This extension was primarily designed to allow STOS to create games using the larger screen sizes supported by the STE. Version 3.6 adds support for the bitter to many of the screen manipulation commands.

The download link has been updated to offer a fully registered v3.6b in both interpreter and compiler versions.

DOWNLOAD

Variables and Dimensions

Variables and Dimensions are a way of storing information in STOS to use in your program. The two main pieces of information are words and numbers. Your program would make a decision if one of these equaled something and act upon it. Here’s a simple example of a variable being used.

VARIABLES

10 print “Please type in a number”
20 input A
30 print “You choose the number”;A

What happens here is that the computer labels a little box as ‘A’ and inserts the number you typed in at the input prompt into it. The number you typed is now stored in the computer’s memory in a little box called ‘A’. Line 30 looks in the box and prints its contents to the screen, which of course is the number you entered. ‘A’ is the name we have chosen for the variable and the input command is one way of putting information into it. Another way to put information into a variable is like this.

10 let NUMBER=100
20 print NUMBER

Line 10 tells the computer to get one of its boxes and stick a label on it and call it NUMBER, then puts the value ‘100’ inside it. Note, the use of the command ‘let’ is optional and can be removed so your routine would be.

10 NUMBER=100
20 print NUMBER

Variables can be called anything you wish, using letters, words and symbols, but you must make sure that there are no STOS commands in the name or else you get something like this……

10 sin GLE=10

If you used the word ‘SINGLE’ then STOS finds the command ‘sin’ and gets confused. Try different names until you find one that appears in capitals.

Not only numbers can be used in variables, so can words or letters. If you wanted to put a word into a variable then you must add a ‘$’ to the variable’s name and the word must be put in between two quotes. For example.

10 NAME$=”DEANO”
20 print “MY NAME IS “;NAME$

10 input “What is your name”;NAME$
20 print “Hello There “;NAME$

You can also add variable values together which can be used in a game to add points to your score, for example.

10 SC=100
20 print “Your score is “;SC
30 print “Press a Key”
40 SC=SC+10 : goto 20

Line 40 tells the variable SC to equal the value of itself which is ‘100’ and the add ’10’ to itself. The same applies to letters, usually known as strings of characters. For example.

10 input “What is your first name”;NAME$
20 input “What is your second name”;SURNAME$
30 A$=NAME$+” “+SURNAMES
40 print “Hello “;A$

DIMENSIONS

As you know, a variable is a little box inside the computers memory. A dimension is a large box full of little boxes. Think of a cassette box, it’s one big box with so many slots for your cassettes. A dimension allows you to store so many pieces of information inside one variable. Here’s an example of how one could be used.

10 dim A(2) : rem Set up one variable box with two slots
20 A(1)=100 : A(2)=200
30 print A(1),A(2)

The same method can be used with strings.

10 dim NAME$(2)
20 NAME$(1)=”ST” : NAME$(2)=”PLUS”
30 print NAME$(1),NAME$(2)

Dimensions can be used exactly the same way as variables, the only difference is that with dimensions you use the variable name plus the number of slots in the variable box….IE: dim SC(10).

Another type of dimension is the two way dimension. This is setting up so many boxes with so many slots. Try this example.

10 dim NUMBER(5,10) : rem Set up five boxes each with ten slots.
20 NUMBER(1,1)=100 : rem Put ‘100’ in box one, slot one
30 NUMBER(2,1)=500 : rem Put ‘500’ in box two, slot one.
40 print NUMBER(1,1)
50 print NUMBER(2,1)

This is useful for directions in adventure games. For example this routine sets up a dimension with five locations and four exits.

10 dim D$(5,4)
20 for X=1 to 5 : For Y=1 to 4
30 read D$(X,Y)
40 next Y : next X
50 data 2,3,4,5
60 data 1,2,3,4
70 data 5,2,4,3
80 data 7,6,2,1
90 data 2,4,1,2

I recommend you use clear variable names and plenty of REM statements in your program so you can keep track on what each variable and dimension does.

Stacking a Memory Bank

As you know, there are only fifteen memory banks that you can use in STOS. Yet some games have more than fifteen pictures or music files overcoming the fifteen bank limit. This is done by simply sticking all the files into one bank on top of each other. This is called Stacking a Bank.

Let’s say we have five pieces of chip music that we want to save along with the program in one bank and call each piece when we need it. Well first to get them all in the bank we need to add up the total length of the files and reserve a bank to this length. If you put your five selected tunes on a disk then type ‘dir’ you should get a list like this.

Drive A:

MADMAX.MUS 4200
KILLING.MUS 2100
CIRCUS.MUS 8244
ALEC.MUS 4774
STOMP.MUS 8000

Here we have first the filenames followed by the file length, the file lengths need to be added up and then a bank reserved…..

4200+2100+8244+4774+8000=27318

10 reserve as work 5,27320+100

Note how the value in line 10 is slightly higher than the calculated figure. This is because we must always reserve a round figure for the length, we then add 100 bytes just to make a bit more space in the bank. Now we can add more lines to this routine to load the music files into the bank.

20 bload “MADMAX.MUS”,start(5)
30 bload “KILLING.MUS”,start(5)+4200
40 bload “CIRCUS.MUS”,start(5)+4200+2100
50 bload “ALEC.MUS”,start(5)+4200+2100+8250
60 bload “STOMP.MUS”,start(5)+4200+2100+8250+4780
70 rem SAVE BANK
80 bsave “M_BANK.DAT”,start(5) to start(5)+length(5)

The first file has loaded into the large bank starting from the start of the bank so it has taken up 4200 bytes of the bank which is the length of the first file (MADMAX.MUS). To load the second file in we have to make sure it slots in after the first one so we load in into the bank starting at the position where the first file ends. The next file has to load in and slot in the bank after the first two so we add the values of the first two files to give us the starting position where to load the third file.

So basically, we are loading in each file after the other adding up the values of the previous files to find the start position of the present file in the large reserved bank. Rather than have all this value+value bit we can add up the values into one length like so.

20 bload “MADMAX.MUS”,start(5)
30 bload “KILLING.MUS”,start(5)+4200 : rem Length of first file
40 bload “CIRCUS.MUS”,start(5)+6300 : rem Length of files 1 and 2
50 bload “ALEC.MUS”,start(5)+14550 : rem Length of files 1,2 and 3
60 bload “STOMP.MUS”,start(5)+19330 : rem Length of files 1,2,3 and 4

Note its also important that file lengths that are not even must be rounded up to the nearest even figure for the bank to stack properly.

In order to use the stacked bank in our program we just reserve a bank to the full length and bload it in. Now the easiest and quickest way to play the music is like this. First we need two arrays which will hold the start address of each file, and the length of each file. The music can easily be played by one line, saving a load of IF statements.

10 reserve as work 5,27320+100
20 bload “M_BANK.DAT”,5
30 dim MUS_ST(5) : rem Reserve array for start addresses
40 dim MUS_LE(5): rem Reserve array for file lengths
50 MUS_ST(1)=0 : MUS_ST(2)=4200 : MUS_ST(3)=6300 : MUS_ST(4)=14550 :
MUS_ST(5)=19330
60 MUS_LE(1)=4200 : MUS_LE(2)=2100 : MUS_LE(3)=8250 : MUS_LE(4)=4780 :
MUS_LE(5)=8000
70 input “Choose tune to play (1 to 5)”;PL
80 if PL=0 or PL>5 then goto 70
90 rem Play chosen music file
100 A=musauto(start(5)+MUS_ST(PL),1,MUS_LE(PL))
110 wait key
120 A=musauto(0,0,0) : goto 70

You can use the same method with packed pictures. In your game you just load in the bank of stacked binary packed pictures and call them up in the same way……for example.

10 reserve as work 10,50000
20 bload “PICS.PAC”,10
30 dim SCR_ST(4)
40 SCR_ST(1)=4000 : SCR_ST(2)=3200 : SCR_ST(3)=6500 : SCR_ST(4)=9000
50 for X=1 to 5
60 unpack start(5)+SCR_ST(X) : wait 50
70 next X

So there you have it. With this method you can have as many binary files in a bank as memory permits, and put an end to the bank limit.