home *** CD-ROM | disk | FTP | other *** search
- 5 DEVICES
-
- 5.1 DEVICES
-
- No examples for this chapter.
-
-
-
- 5.2 TIMER DEVICE
-
- Example 1
- This example demonstrates how you can use the Timer Device.
- The program will be put to sleep for 10 seconds.
-
- Example 2
- This example demonstrates how you can send several requests
- to the Timer Device.
-
- Example 3
- This example demonstrates how you can use the Timer Device
- to get the current system time. We will then add two hours
- and set the new system time.
-
- Example 4
- This example demonstrates how you can compare, add and
- subtract time values with help of the timer device's own
- functions.
-
-
-
- 5.3 GAMEPORT DEVICE
-
- Example1
- This example demonstrates how to open the Gameport Device,
- and monitor Joystick events. While we are waiting we
- put our task to sleep so we do not waste any computer time.
-
- Example2
- Same as example 1, but instead of putting the task to sleep
- while we are waiting for something to happen, we constantly
- try to receive joystick events. This should for example be
- used in games. I am sure that you so not want that all aliens
- should stop attacking the world just because the user has
- not moved the stick.
-
- Example3
- This example demonstrates how to open the Gameport Device,
- and monitor mouse events. While we are waiting we put our
- task to sleep so we do not waste any computer time.
-
- Example4
- Same as example 3, but instead of putting the task to sleep
- while we are waiting for something to happen, we constantly
- try to receive mouse events.
-
-
-
- 5.4 AUDIO DEVICE
-
- Example 1
- This program will play some notes (A to G#) with help of the
- Audio Device. It will use one of the audio channels (the
- first one which is free).
-
- Example 2
- This program is very similar to the previous example, but
- this time are we using double buffered sounds, and there will
- therefore not be any annoying "clicks" between the notes.
-
- The technique with double buffered sound is that while the
- first sound is played the second sound is already sent to
- the audio device. When the first sound terminates the second
- sound can immediately start without any delay. While the
- second sound is being played the first sound is prepared and
- sent and so on... Because there is never any delay between
- the sounds there will never be any annoying clicks.
-
- Example 3
- This program demonstrates how you can play some sampled data.
- Remember that sampled data is just a more complicated
- waveform.
-
- The sampled sound has been converted into numbers by
- "PrintSound", a utility included in the "Sound" manual.
-
- Example 4
- This program demonstrates how you can play a sound
- continuously. While the sound is being played we slowly alter
- the period and volume values.
-
- Example 5
- This example demonstrates how you can play sounds in STEREO.
- First we play a sound in the left channel, then we switch to
- the right, and then back again, and so on...
-
- In this example are we reserving the audio channels at the
- same time as we open the audio device. We use two audio
- requests, one for the left channel and the other one for the
- right channel.
-
- Example 6
- This program will play some notes (A to G#) with help of the
- Audio Device. It will use as many audio channels as possible,
- and we are modifying the hardware registers directly instead
- of using the special Audio Device commands.
-
- You are allowed to use the hardware registers directly if you
- make sure that no other task can steel them from you before
- you have cleared all necessary registers.
-
-
-
- 5.5 NARRATOR DEVICE
-
- Example 1
- This very simple example demonstrates how to open the
- translator library, translate a string, and finally close
- the library before the program terminates.
-
- Example 2
- This example demonstrates how you can use a while loop to
- translate parts of a string until the whole string has been
- translated.
-
- Example 3
- This example demonstrates how to translate a string into a
- phonetical string which is then read by the narrator device.
-
- Example 4
- This example very similar to the previous one, but this time
- are we using a different voice. By altering the rate, pitch,
- mode, sex and volume, you can produce very different sounds.
-
- Example 5
- This example demonstrates how you can let the Amiga read
- small stories. By altering the rate, pitch, mode, sex and
- volume parameters it can sound like several persons are
- talking. It can also be used to express emotions and stress
- important parts of the text.
-
- This example is using some home made functions which makes
- life a little bit easier. If you have to read a lot of text I
- recommend you to use special functions like these. It will
- then be much easier to write (and read) the program code.
-
- Example6
- This example demonstrates how to use the mouth request block
- to draw a talking mouth.
-
-
-
- 5.6 TRACKDISK DEVICE
-
- Example 1
- This program will use the Trackdisk Device to turn on and off
- the internal disk drive's motor.
-
- Example 2
- This program demonstrates how you can check what went wrong
- while you were using the Trackdisk Device. This example will
- try to use drive DF3:, which most of us does not have, and
- thus we will receive an error message. (Well if you have four
- disk drives connected to your Amiga there will not be any
- error message.)
-
- Example 3
- This example demonstrates how you can read data with help of
- the Trackdisk Device. You give this program four arguments
- (drive, head, cylinder and sector), and it will print out all
- data in that sector. You only have to expand this program a
- little and you will end up with a nice disk viewer.
-
- Example3 drive (0-3) head (0-1) cylinder (0-79) sector (0-10)
-
- Example 4
- This example contains a lot of small and useful functions
- that does almost everything you ever would like to do with
- the trackdisk device. The example has been written so you can
- easily use the functions in your own programs.
-
-
-
- 5.7 SERIAL DEVICE
-
- Example 1
- If you have a Sharp JX-100 scanner you can run this program
- since it will try to turn the lamp on and then off again.
- Very useful! (hmmm...) The program does not check if there
- is any contact with the scanner, nor if the lamp really was
- turned on or not. It simply demonstrates how to send data.
-
- Example 2
- This example is rather similar to Example 1, but this time
- we do not wait for the serial port to complete our request.
- Instead we do somethings (well not very much) and now and
- then checks if the request has been completed. Using a busy
- wait.
-
- Example 3
- This example is also rather similar to Example 1, but this
- time we try to read and write at the same time. To be able
- to do several requests simultaneously we need one request
- block for each command. In this example we use three
- separate request blocks. Using asynchronous commands but
- puts the task to sleep just before we clear and return
- everything.
-
- Example 4
- This example does not do anything, but it consists of
- several useful functions that you can use yourself after
- small modifications. The functions demonstrates all
- commands there exist for the serial device, so if you
- had problems in understanding how a command was used you
- can look here.
-
-
-
- 5.8 PARALLEL DEVICE
-
- Example 1
- This program demonstrates how you can use the Parallel Device.
- It does not do very much since I do not know what you have
- connected to your parallel port, but with small modifications
- you should be able to write your own parallel communication
- packages.
-
- Example 2
- This example is rather similar to Example 1, but this time
- we do not wait for the parallel port to complete our request.
- Instead we do somethings (well not very much) and now and
- then checks if the request has been completed.
-
- Example 3
- This example is rather similar to Example 1, but this time
- we do not wait for the parallel port to complete our request.
- We are also trying to read and write at the same time. To be
- able to do several requests simultaneously we need one request
- block for each command. In this example we use three separate
- request blocks.
-
- Example4
- This example does not do anything, but it consists of
- several useful functions that you can use yourself after
- small modifications. The functions demonstrates all
- commands there exist for the parallel device, so if you
- had problems in understanding how a command was used you
- can look here.
-
-
-
- 5.9 PRINTER DEVICE
-
- Example 1
- This program demonstrates how you can use the Printer
- Device to send (raw as well as translated) text to a
- printer.
-
- Example 2
- This program demonstrates how you can use the Printer
- Device to send (raw as well as translated) text to a
- printer. However, instead of waiting for our request to
- be completed as in Example 1, we use asynchronous
- requests.
-
- Example 3
- This program demonstrates how you can send printer commands to
- the Printer Device, which will translate these commands with
- help of Preferences, before they are sent to the printer.
-
- Example 4
- This example demonstrates how you can print graphics.
- It will dump the workbench's Rastport to the printer.
-
-