Contents | < Browse | Browse >

===========================================================================
                            AMOS With The CD32
  C. Edward Stewart                                    joehick@golden.net
===========================================================================

Whether or not you happen to have a CD32, you may have access to a CD32
joypad.  With it, you have the option of programming a lot more neat
options (because it has a lot of buttons).  There have been several
different programs out there to read the CD32 joypad, but they all lack in
one way or another.  Here's my procedure that does it:

Procedure PAD
CD=0 : CD32=0
Lib Open 1,"lowlevel.library",40
Dreg(0)=1
CD=Lib Call(1,-30)
Lib Close 1
If CD and 1 Then CD32=CD32+%1
If CD and 2 Then CD32=CD32+%10
If CD and 4 Then CD32=CD32+%100
If CD and 8 Then CD32=CD32+%1000
If CD and 131072 Then CD32=CD32+%10000
If CD and 262144 Then CD32=CD32+%100000
If CD and 524288 Then CD32=CD32+%1000000
If CD and 1048576 Then CD32=CD32+%10000000
If CD and 2097152 Then CD32=CD32+%100000000
If CD and 4194304 Then CD32=CD32+%1000000000
If CD and 8388608 Then CD32=CD32+%10000000000
End Proc[CD32]

To use this procedure, you'll need to get the lowlevel.library (and a CD32
joypad) if you don't have it.  Now, the procedure is nice, but without the
code to use it, it's just so many cool AMOS commands.

Do
PAD=0
PAD : PAD=Param
If PAD and 1 Then PAD_RIGHT
If PAD and 2 Then PAD_LEFT
If PAD and 4 Then PAD_DOWN
If PAD and 8 Then PAD_UP
If PAD and 16 Then PAD_PAUSE
If PAD and 32 Then PAD_REWIND
If PAD and 64 Then PAD_FASTFORWARD
If PAD and 128 Then PAD_GREEN
If PAD and 256 Then PAD_YELLOW
If PAD and 512 Then PAD_RED
If PAD and 1024 Then PAD_BLUE
Loop

This loop checks all the buttons and acts on them.  If you want different
buttons to be sensed sooner, move them up on the list.  I've got all the
different buttons labeled as procedures, but you could use Goto's or
commands just as easily.  The code above just shows you what values
represent which buttons.

Most CD32s don't have keyboards attached, so don't put places in your
program for users to type unless you use some sort of CD32 joypad procedure
to get the characters.  Say something like the one below.

Procedure CD32_TEXT
CHAR$="" : CHAR=0 : A$="" : IN$="" : PAD=0
CHAR$="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.!?() 1234567890"
CHAR=1
Curs Off
CD32:
If CHAR<1 Then CHAR=69
If CHAR>69 Then CHAR=1
A$=Mid$(CHAR$,CHAR,1)
Locate 0,0 : Print IN$;A$;" ";Cleft$;Cleft$;
CD32A:
Do : PAD=0 : PAD : PAD=Param : If PAD=0 Then Loop
If PAD and 4 Then CHAR=CHAR-1 : Wait 5 : Goto CD32
If PAD and 8 Then CHAR=CHAR+1 : Wait 5 : Goto CD32
If PAD and 128
  IN$=IN$+A$
  Locate 0,0
  Print IN$
  Goto CD32B
End If
If PAD and 512 Then IN$=Left$(IN$,Len(IN$)-1) : Wait 15 : Goto CD32
If PAD and 1024 Then IN$=IN$+A$ : Wait 10 : Goto CD32
Goto CD32A
CD32B:
End Proc[IN$]

To use the text procedure use the following code:

CD32_TEXT : IN$=Param$

CD32 joypad up and down scroll through the letters.  Blue advances a
character.  Red deletes a character.  Green terminates input.  The
parameter in IN$ will contain the text entered by the user.

With these procedures, you can write AMOS programs that can be included on
CD32 coverdisk CDs.  Also, you can have access to all those neat buttons on
the CD32 joypad.

You may be wondering why anyone would want to use a CD32 joypad.  For one
simple reason: More commands at your fingertips!  So go get a CD32 joypad
and start writing cool multi-button programs.