home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser05.arj
/
stoser05.msa
/
A
/
45.PNE
< prev
next >
Wrap
Text File
|
1987-04-22
|
11KB
|
448 lines
STOS BITS 'N PIECES
by
Martin Cubitt July 1993
You will probably be aware of the
command inc V which would automatically
increment (add 1 to) the variable V.
What you may not be aware of is the
fact that it is quicker to do two INC's
than to add 2 to a variable too. So:
V=V+2
would be replaced by
inc V : inc V
----------------------------------------
The TAB(n) function of STOS does not
work as one who has used other BASICs
would expect.
Normally the function will locate the
cursor at the column specified by n. So
print TAB(7) would locate the cursor in
the x coordinate 7 on the current line,
a bit like locate 7, same.
However, in the STOS version the cursor
moves n places to the right of its curr-
ent position. Not the same thing if the
cursor is not at position 0.
To get over this I have written a comm-
and VTAB and a command LTAB in my EXTRA
extension (quick plug!). These work by
returning the cursor to the start of the
current line and then moving on n
places. The VTAB command does not work
on a printer as the control code is dif-
ferent.
The LTAB command works on both screen
and printer but it moves right by plac-
ing a space (ASCII 32) at the cursor
position. This means that anything on
the screen before the tab position will
be erased.
So to summarise, use VTAB(n) when the
output will not be sent to a printer and
use LTAB when it is.
----------------------------------------
A bug (don't know if it has been fixed
yet!) concerns random access files.
When defining fields using field #N, 15
as A$, 23 as B$ etc. you have to add one
to the length of the fields if the data
uses the entire field length, otherwise
the data will not be stored correctly!
So in the above example you would have
to change the 15 to 16 and the 23 to 24
if the real maximum sizes are 15 and 23!
Got it?
----------------------------------------
Memory problems? Not you, your Atari!
You have probably been told a million
times but just in case you did not know
you can save memory my ensuring that you
boot STOS from an AUTO folder, avoiding
GEM being installed until you exit your
program.
GEM controls the windows etc. on the
desktop. Many program use GEM functions.
STOS uses its own (typical!).
This means that STOS does not require
GEM to be present in order to run. Boot-
ing from an AUTO folder means that GEM
is not loaded. When GEM is loaded it
takes up around 32K, so not loading it
means you have an extra 32K to play
with.
Another way of saving memory is to
remove REM statements from programs.
Personally I think that this is not a
good idea. Trying to follow a program
which you have not used for a while, or
somebody else uses, can be hard enough
to understand at the best of times with
comments. Remove these and remove the
educational value of your code.
You would not sell a washing machine
without instructions to save a little
bit of space, would you?
You can also save memory (and speed up
your program) by using a memory bank
instead of arrays. As long as you clear-
ly comment how the data will be stored
in the bank this is fine. It is import-
ant to comment fully on the structure of
the bank so that data can be retrieved
easily.
For example, if you had an array to
hold values 0-255 with 5000 elements
(dim V(5000)) you can save a lot of
space.
STOS stores variables in their longword
form which means they take up four bytes
whatever their minimum or maximum size
is.
So by reserving a bank of 5000*1 = 5000
bytes saves you having an array taking
up 5000*4 = 20000 bytes, a saving of
15000 bytes!
This example should make the use of
this method a little clearer...
10 dim N(5000)
20 for LOOP=1 to 5000
30 N(LOOP)=rnd(255)
40 next LOOP
50 input "Element to check (1-5000):";E
60 if E=0 then 100
70 if E<1 or E>5000 then 50
80 print N(E)
90 goto 50
100 end
The above program uses standard arrays,
the replacement program...
10 reserve as work 5,5000
20 NARRAY=start(5)
30 for LOOP=1 to 5000
40 poke NARRAY+LOOP-1,rnd(255)
50 next LOOP
60 input "Element to check (1-5000):";E
70 if E=0 then 110
80 if E<1 or E>5000 then 60
90 print peek(NARRAY+E-1)
100 goto 60
110 end
Note that the actual position is -1
from where you want to look. ThIs is
because the memory bank actually goes 0
to 4999 whereas the array goes 1 to 5000
Mathematics can of course be carried
out as if it were a normal array,
instead of
N(12)=N(12)+10
use
poke NARRAY+12-1
peek(NARRAY+12-1)+10
Note (again) that if the value of a
calculation is constant (as in 12-1
above) it is better to actually type
the result so STOS does not need to work
it out.
poke NARRAY+11
peek(NARRAY+11)+10
The same principal can be applied to
multi-dimensional arrays. So the array
N(30,50) becomes a bank of size 30*50=
1500 and B=A(X,Y) becomes B=peek(NARRAY+
(X-1)*30+(Y-1)).
That's a little confusing so we'll
leave that there!
A few people have mentioned that by re-
naming extensions and STOS libraries can
save memory.
As far as the interpreter library goes,
yes. As long as your program (and the
editor/compiler) does not use it then
there is no need to load it, ie. if you
are writing a program which does not use
any extensions except, say, the STOS
compactor then rename all other
extension (*.EX? files in your STOS
folder). I rename using the last letter
so EXTRA.EXZ becomes EXTRA.ZZZ. That way
I know what extension letter it is if I
want to re-employ it.
You may want to rename the FLOAT102.LIB
to FLOAT102.LI if your program does not
use floating point.
You must be careful, however. The mouse
needs the SPRITES library and the file
selector uses the WINDOW library.
As far as the compiler goes things are
a little different. Individual commands
from extensions are only loaded if they
are used. For example, if your program
uses the PACK command from the STOS
compactor extension only the code for
that will be loaded, ignoring the code
for UNPACK. Therefore there is no point
in renaming extensions in your Compiler
folder.
From my experience you cannot (despite
other people's comments) rename the LIB
routines in the compiler folder other-
wise the compiler has a disk error
because it needs to load all libraries.
----------------------------------------
Did you know there is a bug in the SET
PATTERN command?
If you are using a monochrome monitor
you'll be okay. However the low and med-
ium resolution version do not work.
Actually Richard Vanner of Mandarin is
quoted in the STOS Newsletter issues 5
and 6 as saying that these versions of
the command were never finished. Whoops!
Sounds like some pretty amateur program-
mers to me!
----------------------------------------
Ever heard of the game Gilbert? Well it
was quite a popular game a year or two
ago. It was written in STOS. It was
compiled using the first working of the
compiler to arrive from France.
The funny thing is Chris Payne at
Mandarin allowed the development team
(from Again Again) to leave of the norm-
ally mandatory STOS credits, on the
understanding the truth be revealed
after the game had been on the market
for a few months.
The worry was that people would not buy
it if it was written in BASIC.
Would you buy a game if it was written
in BASIC and compiled to machine code?
Talking of commercial companies using
STOS, did you know that the maps for
Rainbow Island (the follow up to the
excellent Bubble Bobble) were created by
Andrew Braybrook using STOS?
----------------------------------------
Back to the bugs.
There are quite a number of 'bugs' in
the STOS compiler. Many of them are
minor bugs, that is that you can change
your code to fix the problem.
You cannot use calculated ON...GOTO or
ON...GOSUB where the condition is calcu-
lated.
For example,
on (a*3+1) goto ...
will not compile. Instead you must use
c=a*3+1
on c goto ...
This is also true of the collide funct-
ion. The command
if collide ((X*Y+LOOP),X*3+4,Y*2)=1
then ...
must be replaced with
A=(X*Y+LOOP)
B=X*3+4
C=Y*2
if collide (A,B,C)=1 then...
----------------------------------------
One of the most annoying bugs in STOS
caused me a lot of grief before I real-
ised that Francois was a complete
STOSSER with a silent leading S! (No
offence but at the time I was very
annoyed!)
It concerns the MID$ command. Some of
you may have come across the bug.
Consider the following simple program:
10 input A$
20 B$=A$
30 mid$(A$,2,1)=" "
40 print B$
Okay, a simple little 4 liner. But it
does not work.
Suppose you entered ABC when prompted
from the input A$ command. A$ now
contains "ABC". Agreed? I hope so!
Line 20 stores the contents of A$ into
B$. So now B$ also contains "ABC". Still
with it?
Line 30 stores a space at position 2 in
the variable A$. So position two was a
"B" but that will be replaced by an A.
Well the good news is that it does. So
it works? No. Line 40 will print out B$.
This should still be "ABC" as we have
not modified since line 20. However, B$
also has a space at position two.
Apparently (according to Mandarin so
take it with a pinch of salt) the bug
concerns use of MID$ after the input and
inkey$ commands. STOS still regard B$ as
A$ because the variable pointers are the
same. Nice one Mandarin!
More importantly you can get around this
by using the following command instead:
B$=left$(A$,n-1)+" "+right$(A$,len(A$)
-n)
where n is the position you which to
replace and the space in " " can be re-
placed with any character or string of
characters.
It's fortunate that STOS does not mind
if you use
left$(A$,0)
as it returns a null ("")
Many BASICS will not let you do that
because technically it is incorrect.
----------------------------------------
Not a bug (hooray) this one but an un-
documented feature of STOS.
When using the SPRITE command you can
omit the sprite number on the successive
use of the command. That is, as long as
you have at least one
sprite N,X,Y,P
STOS will regard all subsequent sprite
commands as regarding the previously
used one so you can then use
sprite N,X,Y
Facinating!
----------------------------------------
Did you know...
The FREQUENCY command which should only
be used with a colour monitor. Using it
with a normal television which cannot
support the frequency change can cause
serious permanent damage to you set. You
have been warned.
The command can only be used in inter-
preter mode. Goodness knows why! If
people want it I can write a simple com-
mand for the EXTRA extension so that
compiled programs can use it. I do not
know what I would call the command
though.
(How about TOGGLE HERTZ? - Ed.)
Also, did you know that you can use the
change mouse command to use a sprite as
the mouse? Of course you did. According
to the STOS Newsletter issue 8 any bank
access or using FILE SELECT$ changes the
mouse back to normal. How annoying!
CUBITTM/STOS0004/190793