home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / ac5_disk / kp_ejp / pad_1.c < prev   
Encoding:
C/C++ Source or Header  |  1997-04-21  |  2.9 KB  |  143 lines

  1. /*
  2. **    pad_1.c
  3. **
  4. **    Written by Xav to accompany the EJP series in
  5. **    Atari Computing. Designed for Lattice C, but should
  6. **    be adaptable to suit any compiler.
  7. **
  8. **
  9. **    Your homework, should you choose to accept it, is to
  10. **    modify this code (and the ejp.h header file) to check
  11. **    port B as well. 
  12. **
  13. **    At the moment the program doesn't actually end, so you could 
  14. **    try adding some code to detect a particular combination of 
  15. **    buttons on the joypad in order to quit the program. 
  16. **    Alternatively, if your C programming is a little more 
  17. **    advanced than that, you could check for a mouse button or 
  18. **    a keypress.
  19. **
  20. **    It also doesn't do any checks to see whether or not the
  21. **    machine actually has EJPs, so you might like to make it a
  22. **    little more "bullet proof" by checking the _MCH cookie for
  23. **    an STe (but not a Mega STe) or a Falcon030
  24. */
  25.  
  26.  
  27.  
  28. #include "ejp.h"
  29.  
  30.  
  31.  
  32. /* Function prototypes    */
  33.  
  34. void main(void);                                /* Program entry        */
  35.  
  36.  
  37.  
  38.  
  39. /*
  40. **    void main (void);
  41. **
  42. **    Program entry point. Since this is such a minor program,
  43. **    all the processsing also takes place here (apart from the
  44. **    actual reading of the EJP - see ejp.h for details).
  45. */
  46.  
  47. void main(void)
  48. {
  49.     struct JOYPAD joypad_A;    /* Defined in ejp_defs.h    */
  50.     
  51.     
  52.     while(1)                                /* To loop indefinitely            */
  53.     {
  54.         /* First fill the structure                                                */
  55.         read_joypadA(&joypad_A);        /* Defined in ejp.h            */
  56.         
  57.         
  58.         /* Now just print out the results. Note that we        */
  59.         /* can't just use a "case" statement as there            */
  60.         /* may be more than one button being pressed.            */
  61.         
  62.         if(joypad_A.UP == TRUE)
  63.             printf("Up, ");
  64.     
  65.         if(joypad_A.DOWN == TRUE)
  66.             printf("Down, ");
  67.     
  68.         if(joypad_A.LEFT == TRUE)
  69.             printf("Left, ");
  70.         
  71.         if(joypad_A.RIGHT == TRUE)
  72.             printf("Right, ");
  73.             
  74.         if(joypad_A.FIRE_A == TRUE)
  75.             printf("A, ");
  76.  
  77.         if(joypad_A.FIRE_B == TRUE)
  78.             printf("B, ");
  79.  
  80.         if(joypad_A.FIRE_C == TRUE)
  81.             printf("C, ");
  82.     
  83.         if(joypad_A.PAUSE == TRUE)
  84.             printf("Pause, ");
  85.             
  86.         if(joypad_A.OPTION == TRUE)
  87.             printf("Option, ");                
  88.         
  89.         if(joypad_A.NUMPAD_1 == TRUE)
  90.             printf("1, ");
  91.         
  92.         if(joypad_A.NUMPAD_2 == TRUE)
  93.             printf("2, ");
  94.     
  95.         if(joypad_A.NUMPAD_3 == TRUE)
  96.             printf("3, ");
  97.                 
  98.         if(joypad_A.NUMPAD_4 == TRUE)
  99.             printf("4, ");
  100.  
  101.         if(joypad_A.NUMPAD_5 == TRUE)
  102.             printf("5, ");
  103.         
  104.         if(joypad_A.NUMPAD_6 == TRUE)
  105.             printf("6, ");
  106.     
  107.         if(joypad_A.NUMPAD_7 == TRUE)
  108.             printf("7, ");
  109.     
  110.         if(joypad_A.NUMPAD_8 == TRUE)
  111.             printf("8, ");
  112.  
  113.         if(joypad_A.NUMPAD_9 == TRUE)
  114.             printf("9, ");
  115.  
  116.         if(joypad_A.NUMPAD_STAR == TRUE)
  117.             printf("*, ");
  118.  
  119.         if(joypad_A.NUMPAD_0 == TRUE)
  120.             printf("0, ");
  121.  
  122.         if(joypad_A.NUMPAD_HASH == TRUE)
  123.             printf("#, ");
  124.  
  125.  
  126.         /* Finally, move the cursor onto the next line    */
  127.         printf("\n");
  128.     
  129.     }    /* End of while loop    */
  130.     
  131.  
  132.     /* Never actually reaches this line    */
  133.     return;
  134. }
  135.     
  136.     
  137. /*
  138. **    There. Who said EJP programming was difficult?
  139. */
  140.  
  141.     
  142.         
  143.