home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / amiga / appendices / examples / devicesexamples.doc < prev    next >
Text File  |  1995-02-27  |  9KB  |  274 lines

  1. 5    DEVICES
  2.  
  3. 5.1  DEVICES
  4.  
  5. No examples for this chapter.
  6.  
  7.  
  8.  
  9. 5.2  TIMER DEVICE
  10.  
  11. Example 1
  12.   This example demonstrates how you can use the Timer Device.
  13.   The program will be put to sleep for 10 seconds.
  14.  
  15. Example 2
  16.   This example demonstrates how you can send several requests
  17.   to the Timer Device.
  18.  
  19. Example 3
  20.   This example demonstrates how you can use the Timer Device
  21.   to get the current system time. We will then add two hours
  22.   and set the new system time.
  23.  
  24. Example 4
  25.   This example demonstrates how you can compare, add and
  26.   subtract time values with help of the timer device's own
  27.   functions.
  28.  
  29.  
  30.  
  31. 5.3  GAMEPORT DEVICE
  32.  
  33. Example1
  34.   This example demonstrates how to open the Gameport Device,
  35.   and monitor Joystick events. While we are waiting we
  36.   put our task to sleep so we do not waste any computer time.
  37.  
  38. Example2
  39.   Same as example 1, but instead of putting the task to sleep
  40.   while we are waiting for something to happen, we constantly
  41.   try to receive joystick events. This should for example be
  42.   used in games. I am sure that you so not want that all aliens
  43.   should stop attacking the world just because the user has
  44.   not moved the stick.
  45.  
  46. Example3
  47.   This example demonstrates how to open the Gameport Device,
  48.   and monitor mouse events. While we are waiting we put our
  49.   task to sleep so we do not waste any computer time.
  50.  
  51. Example4
  52.   Same as example 3, but instead of putting the task to sleep
  53.   while we are waiting for something to happen, we constantly
  54.   try to receive mouse events.
  55.  
  56.  
  57.  
  58. 5.4  AUDIO DEVICE
  59.  
  60. Example 1
  61.   This program will play some notes (A to G#) with help of the
  62.   Audio Device. It will use one of the audio channels (the
  63.   first one which is free).
  64.  
  65. Example 2
  66.   This program is very similar to the previous example, but
  67.   this time are we using double buffered sounds, and there will
  68.   therefore not be any annoying "clicks" between the notes.
  69.  
  70.   The technique with double buffered sound is that while the
  71.   first sound is played the second sound is already sent to
  72.   the audio device. When the first sound terminates the second
  73.   sound can immediately start without any delay. While the
  74.   second sound is being played the first sound is prepared and
  75.   sent and so on... Because there is never any delay between
  76.   the sounds there will never be any annoying clicks.
  77.  
  78. Example 3
  79.   This program demonstrates how you can play some sampled data.
  80.   Remember that sampled data is just a more complicated
  81.   waveform.
  82.  
  83.   The sampled sound has been converted into numbers by
  84.   "PrintSound", a utility included in the "Sound" manual.
  85.  
  86. Example 4
  87.   This program demonstrates how you can play a sound
  88.   continuously. While the sound is being played we slowly alter
  89.   the period and volume values.
  90.  
  91. Example 5
  92.   This example demonstrates how you can play sounds in STEREO.
  93.   First we play a sound in the left channel, then we switch to
  94.   the right, and then back again, and so on...
  95.  
  96.   In this example are we reserving the audio channels at the
  97.   same time as we open the audio device. We use two audio
  98.   requests, one for the left channel and the other one for the
  99.   right channel.
  100.  
  101. Example 6
  102.   This program will play some notes (A to G#) with help of the
  103.   Audio Device. It will use as many audio channels as possible,
  104.   and we are modifying the hardware registers directly instead
  105.   of using the special Audio Device commands.
  106.  
  107.   You are allowed to use the hardware registers directly if you
  108.   make sure that no other task can steel them from you before
  109.   you have cleared all necessary registers.
  110.  
  111.  
  112.  
  113. 5.5  NARRATOR DEVICE
  114.  
  115. Example 1
  116.   This very simple example demonstrates how to open the
  117.   translator library, translate a string, and finally close
  118.   the library before the program terminates.
  119.  
  120. Example 2
  121.   This example demonstrates how you can use a while loop to
  122.   translate parts of a string until the whole string has been
  123.   translated.
  124.  
  125. Example 3
  126.   This example demonstrates how to translate a string into a
  127.   phonetical string which is then read by the narrator device.
  128.  
  129. Example 4
  130.   This example very similar to the previous one, but this time
  131.   are we using a different voice. By altering the rate, pitch,
  132.   mode, sex and volume, you can produce very different sounds.
  133.  
  134. Example 5
  135.   This example demonstrates how you can let the Amiga read
  136.   small stories. By altering the rate, pitch, mode, sex and
  137.   volume parameters it can sound like several persons are
  138.   talking. It can also be used to express emotions and stress
  139.   important parts of the text.
  140.  
  141.   This example is using some home made functions which makes
  142.   life a little bit easier. If you have to read a lot of text I
  143.   recommend you to use special functions like these. It will
  144.   then be much easier to write (and read) the program code.
  145.  
  146. Example6
  147.   This example demonstrates how to use the mouth request block
  148.   to draw a talking mouth.
  149.  
  150.  
  151.  
  152. 5.6  TRACKDISK DEVICE
  153.  
  154. Example 1
  155.   This program will use the Trackdisk Device to turn on and off
  156.   the internal disk drive's motor.
  157.  
  158. Example 2
  159.   This program demonstrates how you can check what went wrong
  160.   while you were using the Trackdisk Device. This example will
  161.   try to use drive DF3:, which most of us does not have, and
  162.   thus we will receive an error message. (Well if you have four
  163.   disk drives connected to your Amiga there will not be any
  164.   error message.)
  165.  
  166. Example 3
  167.   This example demonstrates how you can read data with help of
  168.   the Trackdisk Device. You give this program four arguments
  169.   (drive, head, cylinder and sector), and it will print out all
  170.   data in that sector. You only have to expand this program a
  171.   little and you will end up with a nice disk viewer.
  172.  
  173.   Example3 drive (0-3) head (0-1) cylinder (0-79) sector (0-10)
  174.  
  175. Example 4
  176.   This example contains a lot of small and useful functions
  177.   that does almost everything you ever would like to do with
  178.   the trackdisk device. The example has been written so you can
  179.   easily use the functions in your own programs.
  180.  
  181.  
  182.  
  183. 5.7  SERIAL DEVICE
  184.  
  185. Example 1
  186.   If you have a Sharp JX-100 scanner you can run this program
  187.   since it will try to turn the lamp on and then off again.
  188.   Very useful! (hmmm...) The program does not check if there
  189.   is any contact with the scanner, nor if the lamp really was
  190.   turned on or not. It simply demonstrates how to send data.
  191.  
  192. Example 2
  193.   This example is rather similar to Example 1, but this time
  194.   we do not wait for the serial port to complete our request.
  195.   Instead we do somethings (well not very much) and now and
  196.   then checks if the request has been completed. Using a busy
  197.   wait.
  198.  
  199. Example 3
  200.   This example is also rather similar to Example 1, but this
  201.   time we try to read and write at the same time. To be able
  202.   to do several requests simultaneously we need one request
  203.   block for each command. In this example we use three
  204.   separate request blocks. Using asynchronous commands but
  205.   puts the task to sleep just before we clear and return 
  206.   everything.
  207.  
  208. Example 4
  209.   This example does not do anything, but it consists of
  210.   several useful functions that you can use yourself after
  211.   small modifications. The functions demonstrates all
  212.   commands there exist for the serial device, so if you
  213.   had problems in understanding how a command was used you
  214.   can look here.
  215.  
  216.  
  217.  
  218. 5.8  PARALLEL DEVICE
  219.  
  220. Example 1
  221.   This program demonstrates how you can use the Parallel Device.
  222.   It does not do very much since I do not know what you have
  223.   connected to your parallel port, but with small modifications
  224.   you should be able to write your own parallel communication
  225.   packages.
  226.  
  227. Example 2
  228.   This example is rather similar to Example 1, but this time
  229.   we do not wait for the parallel port to complete our request.
  230.   Instead we do somethings (well not very much) and now and
  231.   then checks if the request has been completed.
  232.  
  233. Example 3
  234.   This example is rather similar to Example 1, but this time
  235.   we do not wait for the parallel port to complete our request.
  236.   We are also trying to read and write at the same time. To be
  237.   able to do several requests simultaneously we need one request
  238.   block for each command. In this example we use three separate
  239.   request blocks.
  240.  
  241. Example4
  242.   This example does not do anything, but it consists of
  243.   several useful functions that you can use yourself after
  244.   small modifications. The functions demonstrates all
  245.   commands there exist for the parallel device, so if you
  246.   had problems in understanding how a command was used you
  247.   can look here.
  248.  
  249.  
  250.  
  251. 5.9  PRINTER DEVICE
  252.  
  253. Example 1
  254.   This program demonstrates how you can use the Printer
  255.   Device to send (raw as well as translated) text to a
  256.   printer.
  257.  
  258. Example 2
  259.   This program demonstrates how you can use the Printer
  260.   Device to send (raw as well as translated) text to a
  261.   printer. However, instead of waiting for our request to
  262.   be completed as in Example 1, we use asynchronous
  263.   requests.
  264.  
  265. Example 3
  266.   This program demonstrates how you can send printer commands to
  267.   the Printer Device, which will translate these commands with
  268.   help of Preferences, before they are sent to the printer.
  269.  
  270. Example 4
  271.   This example demonstrates how you can print graphics.
  272.   It will dump the workbench's Rastport to the printer.
  273.  
  274.