home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / hacks / led.c < prev    next >
C/C++ Source or Header  |  1991-01-20  |  1KB  |  36 lines

  1. /* LED                                                               */
  2. /* This fantastic useful program does what all true hackers have     */
  3. /* dreamt of. Enjoy your Amiga's fantastic ability to flash one LED! */
  4.  
  5.  
  6. #include <exec/types.h>
  7. #include <hardware/cia.h>
  8.  
  9.  
  10. /* The address of the CIAA chip: */
  11. #define CIAA 0xBFE001
  12.  
  13. /* Declare a pointer to the CIA (8520) chip: */
  14. struct CIA *cia = (struct CIA *) CIAA;
  15.  
  16. void _main();
  17.  
  18. /* NOTE! Since we have declared our main() function as _main(), */
  19. /* no Consol window will be opened if it is run from the        */
  20. /* Workbench. The disadvantage is that we must NEVER use the    */
  21. /* printf() or similar console functions. It would crash the    */
  22. /* system.                                                      */
  23.  
  24. void _main()
  25. {
  26.   int loop;
  27.   
  28.   for( loop = 0; loop < 40000; loop++ )
  29.   {
  30.     /* We change the second bit in the ciapra register. If the bit is */
  31.     /* unset (0) the LED is on, if the bit is set (1) the LED is off. */
  32.     if( loop % 1000 == 0 )
  33.       cia->ciapra ^= CIAF_LED;
  34.   }
  35. }
  36.