GFA BASIC TIPS & TRICKS by Richard Karsmakers
Apart from some MEGA-ST tricks that I got from Robert from
"STRIKE-a-LIGHT", I only got three problems through the mail
(good luck for me, because I don't have much time anyway). Let's
kick off with the there problem-cases.
Martin Cadee has had trouble with doing Eval-like things in GfA
Basic. This meant that he couldn't define functions in a program
that could be entered by the user itself. The format of the Eval
command (not in GfA Basic, but used in other basic version) was:
X$="2*A^2"
For A=1 To 3
Print Eval(X$)
Next A
End
Output would then be:
2
8
18
A function like that is not present in GfA Basic, and I don't
think it's possible to do anything like it in GfA Basic either.
The only possible way would be to write your own routine to
analyse a string thoroughly (quite complicated) and then use a
lot of VALs and ASCs to calculate the result. A routine for that
is too complicated to be explained here, however. But it should
be possible!
His second question was: How do I make a GfA Basic program to be
a desk accessory? The answer hereto is, quite simple: It's
impossible (at least, with the current compiler available). I
don't know if Frank Ostrowski will ever write a compiler version
that can make accessories, but I consider it to be theoretically
possible. Who knows, in the future...
Bas Spijkhoven doesn't know how to handle WAVE and ADSR properly.
Well, I think it's quite useless to know how it's done, because
programming sound using WAVE and SOUND is really awful. You
should use Xbios 32 sounds instead, which can be made using Tommy
Software's "Music32". It can then be called from Basic with only
ONE program line (after loading that data, of course). But let me
enhance the WAVE command a bit.
Its format is:
WAVE voice,wave,form,duration,pause
'Voice' can have the following values:
1 = Voice one
2 = Voice two
3 = Voice three
8 = Noise to voice one
16 = Noise to voice two
32 = Noise to voice three
By adding the individual values, you can combine; e.g. if you
want to use all three voices, and if you want to add noise to the
second voice, you should use 1+2+4+16=23 for 'voice'.
You can add the period of the noise generator to that value as
well, using the following formula:
Value=Period*256
Period can have a value from 0-31.
'Wave' determines which voices should be used by the waveform
set (defined using 'form' - explanation in just a second). This
also means that the volume is determines by the WAVE or the SOUND
command. The table of values of 'Wave':
1 = Voice one
2 = Voice two
4 = Voice three
Here, you can again add the individual values together.
'Form' determines the actual waveform.
0 - 3 = Liniary down
4 - 7 = Liniary up
8 = Sawtooth down
9 = Like 0-3
10 = Triangle, starting down
11 = Lineary down, start loud
12 = Sawtooth up
13 = Lineary up, staying
14 = Triangle, start up
15 = Like 4-7
'Duration' determines the period of the waveform. A larger
duration results in a longer waveform.
'Pause' determines the time (in 50th of second) that is waited
before the next instruction is executed.
William Bliek came with another interesting question - although
it was not specifically for GfA Basic. After adding up his
accessories, the programs in memory, etc. and substracting that
from his 512 Kb memory, he turned out to have about 100 Kb
missing. How could that be?
The answer is relatively simple. First: You loose 32 Kb of screen
memory, at the top of your memory. Further, you loose about 100
Kb memory at the bottom: Memory used for buffers, system
variables, GEM, etc. That's where the other pieces of memory
stay.
Now for the "STRIKE-a-LIGHT" stuff.
In the previous issue of ST NEWS, I talked a lot about
undocumented system variables. Most of them could only be used on
the 'old' ST and not on the MEGA ST. Some of those MEGA addresses
are now known:
The mouse locations (x,y, button status) start at $2740.
The joystick (formerly on $E09) is now at $E4F.
The drive WP status is now on $9F8 (drive A) and $9F9 (drive B).
Some more tricks: Sometimes (especially when writing a program
that should handle multiple drives), the system doesn't know when
a new disk is inserted in drive A. This routine handles that
problem:
Spoke(&H4DB8),1
Spoke(&h4DB9),1
Slpoke(&H4DCE+28),1
Slpoke(&H4DCE+28+32),1
Void Dfree(1)
Spoke(&H4DB8),2
Spoke(&H4DB9),2
Slpoke(&H4DCE+28),2
Slpoke(&H4DCE+28+32),2
This works on MEGA STs as well as regular STs.
Another thing that sometimes annoys people: When you select an
option with the mouse that is followed by the display of an alert
box, the mouse sometimes clicks on that alert box without the
user wanting it to happen. This is a symptom of the fact that GfA
Basic doesn't allow GEM to know that the mouse is not longer
pressed. The following routine (to be called before the display
of an alert box) takes care of that problem:
Repeat
Dpoke Gintin,34
Dpoke Gintin+2,1
Dpoke Gintin+4,1
Dpoke Gintin+6,1
Dpoke Gintin+28,10 !10 Milliseconds
Dpoke Gintin+30,0
Gemsys 25
Until Dpeel(Gintout)<>2
Repeat
Until Mousek=0
This routine clears the REAL GEM mouse as well as the GfA mouse.
That's it folks. See you in another issue of ST NEWS.
Disclaimer
The text of the articles is identical to the originals like they appeared
in old ST NEWS issues. Please take into consideration that the author(s)
was (were) a lot younger and less responsible back then. So bad jokes,
bad English, youthful arrogance, insults, bravura, over-crediting and
tastelessness should be taken with at least a grain of salt. Any contact
and/or payment information, as well as deadlines/release dates of any
kind should be regarded as outdated. Due to the fact that these pages are
not actually contained in an Atari executable here, references to scroll
texts, featured demo screens and hidden articles may also be irrelevant.