Contents | < Browse | Browse >

===========================================================================
           AMOS Tips, Tricks and Stuff They Should Have Told Us
  C. Edward Stewart                          joehick@ophelia.waterloo.net
===========================================================================

AMOS is a good programming language, that's not in doubt.  Unfortunately,
the manual is a bit obscure on some points and there are a lot of
errors/omissions that make for some frustrating programming sessions.  To
combat the agony of programming, I've been compiling a list of `Things They
Should Have Told Us' that I use on a regular basis.  I decided to put a few
together for the users at large and this is the result.

Changing the Mouse Pointer
To change the mouse pointer to anything other than the arrow, crosshairs
and clock (quite an ugly clock, too!) you need to do the following:

- Draw your images in a Bob Editor or import them from a paint program or
whatever.  They must be FOUR COLOUR LORES images.  Standard size is 16 by
16 pixels, but don't let that stop you.

- To activate your new image, load your Bobs (Load "YourFile.Abk",1) and
issue the command to change the mouse (Change Mouse 4).  The Bob images are
called by using four and above (just add 3 to the actual Bob number to get
the mouse image number).

- To change the colours of the mouse, use colours 17-19 (on a 16 colour
screen).  Colour 17 is the highlighted (lightest) colour, Colour 18 is the
body (medium) colour and Colour 19 is the shade (darkest) colour.

Menu Colours
After setting up a menu, you activate it, only to find it looks like
something from a Sixties flashback.  Menu colours are another item that the
manual neglects to mention.

- To set your menu to colours that you can live with, you need to set the
Paper and Pen to the opposite of normal; that is the paper command defines
the colour of the text and the pen command defines the colour of the menu
bar itself.

That Pesky Floppy
I'm sure you all know already that using DF0: is a no-no.  Use the volume
name instead, so then hard drive fanatics can install your programs without
sending you nasty email.

To check for your volume, try this:

A=Exist("VolumeName:")
If A=True Then Print "Found It!"
If A=False Then Print "VolumeName: Not Found."

The True and False keywords (-1 and 0 respectively) make it a bit easier to
read your code and figure out what you were trying to do.

Now that you know it's there, you can write to it, right?  Wrong.  Floppies
can be write protected.  So how can we get around that?  Try this:

Poke $BFD100,%10000
A=Btst(3,$BFE001)
If A=True Then Print "Disk is write enabled."
If A=False Then Print "Disk is write protected."

This checks DF0:.  Change the %10000 to %1000 to check DF1:.

A Nifty Startup
We all know that AMOS is a good language, but it has a reputation for
inferiority in the general population, due to some bad programs put out
when AMOS was in its infancy.  The following code will start your AMOS
program without showing its AMOS roots.

A=Peek(Leek(4)+530)
If A=60 Then COUNTRY_HEIGHT=200 : COUNTRY_SPEED=60
If A=50 Then COUNTRY_HEIGHT=256 : COUNTRY_SPEED=50

Screen Open 1,640,COUNTRY_HEIGHT,16,Hires
Curs Off : Flash Off : Hide
Colour 0,$0 : Colour 1,$AAA : Cls 0
Paper 0 : Pen 1

Print "Checking system."

If COUNTRY_SPEED=60 Then Print "NTSC Amiga"
If COUNTRY_SPEED=50 Then Print "PAL Amiga"

A=Chip Free
B=A/1024
Print "Chip Memory:";B;"k"

A=Fast Free
B=A/1024
Print "Fast Memory:";B;"k"

A$=" 00"
A=Deek(Leek(4)+296)
For B=0 To 3
If Btst(B,A) Then A$=Str$(B+1)+"0"
Next B
B$="680"+Right$(A$,2)
Print "Processor: ";B$

A$=""
If Btst(4,A) Then A$="68881"
If Btst(5,A) Then A$="68882"
If A$<>"" Then Print "CoProcessor: ";A$

Wait COUNTRY_SPEED

This startup will identify the internal timing of the Amiga it is run on,
as well as the memory and processor information.

To keep the illusion of non-AMOS up, never use the default (0) screen. 
When compiling, deselect the `Create Default Screen' option.  This will
avoid that ugly orange screen popping up and giving away the AMOSness of
the program.

You could add these lines to make your program even more system friendly:

If COUNTRY_SPEED=60 Then Goto PAL_IT
If COUNTRY_SPEED=50 Then Goto _NTSC_IT
Goto MAIN

PAL_IT:
Print "Switch to PAL (y/n)?"
A$=""
Do : A$=Inkey$ : If A$="" Then Loop
A$=Lower$(A$)
If A$="y"
Doke $DFF1DC,$20
Poke Leek(4)+530,50
COUNTRY_HEIGHT=256
COUNTRY_SPEED=50
Goto MAIN
End If
If A$<>"n" Then Goto PAL_IT
Goto MAIN

_NTSC_IT:
Print "Switch to NTSC (y/n)?"
A$=""
Do : A$=Inkey$ : If A$="" Then Loop
A$=Lower$(A$)
If A$="y"
Doke $DFF1DC,$0
Poke Leek(4)+530,60
COUNTRY_HEIGHT=200
COUNTRY_SPEED=60
Goto MAIN
End If
If A$<>"n" Then Goto _NTSC_IT
Goto MAIN

MAIN:
Your program begins here

This added bit lets you not only check for NTSC/PAL, but switch the Amiga
into the mode you require for your program.  This allows European
programmers to write games in PAL that will sense NTSC Amigas and switch
them to PAL.  Conversely, the information is there for any programmer to
adjust his graphics to match the information in COUNTRY_HEIGHT and
COUNTRY_SPEED.

Obviously, these aren't all the tips and tricks that I've found, but it's
enough to whet your appetite and get some of the beginners off to a good
start.

I'd like to point out right now that I am not the only author of this
article.  A few of these tips are based on information in the AMOS List on
the InterNet.  My most recent acquisition was the CPU testing procedure
that I modified for my startup program.  It was sent to me by Paul Burkey,
author of Sneech (a great game).

I'd give you my email address for any questions or comments, but it will be
changing before this goes to press.  You can find me on the AMOS List at:
amos-list@conan.eds-ms.com and you can find programs written by me on the
AmiNet, notably FBN-D21u.lha and FBN-Remi.lha.