home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / hard / misc / Joystick.lha / main12.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-09  |  22.7 KB  |  613 lines

  1. /*                                                                        *
  2.  * Joystick test program  V1.0 (09.02.1997)                               *
  3.  *                                                                        *
  4.  * Christian T. Steigies © 1997  (steigies@physik.uni-kiel.de)            *
  5.  *                                                                        *
  6. #define DEBUG
  7.  *                                                                        */
  8. /*+ "includes" */
  9. #include <exec/types.h> /* must be included before any other Amiga Include */
  10.  
  11. #include <intuition/intuitionbase.h>
  12. #include <intuition/gadgetclass.h>
  13. #include <intuition/imageclass.h>
  14.  
  15. #include <graphics/gfxbase.h>
  16.  
  17. #include <clib/exec_protos.h>
  18. #include <clib/graphics_protos.h>
  19. #include <clib/intuition_protos.h>
  20. #include <clib/gadtools_protos.h> /* will #include <libraries/gadtools.h> */
  21. #include <clib/dos_protos.h>
  22. #include <clib/lowlevel_protos.h> /* will #include <libraries/lowlevel.h> */
  23. #include <libraries/lowlevel.h>
  24.  
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27.  
  28. /*- */
  29. /* ---------------------------------------------------------------------- */
  30. /*+ "function prototypes" */
  31. int     main(int argc, char *argv[]);
  32. void    bail_out(int code);
  33. BOOL    HandleMenuEvent(UWORD code);
  34. BOOL    HandleJoyportEvent(ULONG joystick);
  35. /*- */
  36. /* ---------------------------------------------------------------------- */
  37. /*+ "menu contents" */
  38. /* Here we specify what we want our menus to contain: */
  39.  
  40. struct NewMenu mynewmenu[] =
  41. {
  42.         { NM_TITLE, "Project",    0 , 0, 0, 0,},
  43.         {  NM_ITEM, "About",     "?", 0, 0, 0,},
  44.         {  NM_ITEM, NM_BARLABEL,  0 , 0, 0, 0,},
  45.         {  NM_ITEM, "Quit...",   "Q", 0, 0, 0,},
  46.  
  47.         { NM_TITLE, "Options",    0 , 0, 0, 0,},
  48.         {  NM_ITEM, "Port 0",    "0", CHECKIT, ~1, 0,},
  49.         {  NM_ITEM, "Port 1",    "1", CHECKIT|CHECKED, ~2, 0,},
  50. /*        {  NM_ITEM, NM_BARLABEL,  0 , 0, 0, 0,}, */
  51.         {  NM_ITEM, "Port 2",    "2", CHECKIT, ~4, 0,},
  52.         {  NM_ITEM, "Port 3",    "3", CHECKIT, ~8, 0,},
  53.  
  54.         {   NM_END, 0,            0 , 0, 0, 0,},
  55. };
  56. /*- */
  57. /* ---------------------------------------------------------------------- */
  58. /*+ "images" */
  59. static UWORD __chip emptyData[32] =
  60.    {
  61.    0x000f, 0x0000,
  62.    0x000f, 0x0000,
  63.    0x000f, 0x0000,
  64.    0x000f, 0x0000,
  65.    0x000f, 0x0000,
  66.    0x000f, 0x0000,
  67.    0x000f, 0x0000,
  68.    0x000f, 0x0000,
  69.    0x000f, 0x0000,
  70.    0x000f, 0x0000,
  71.    0x000f, 0x0000,
  72.    0x000f, 0x0000,
  73.    0x000f, 0x0000,
  74.    0x000f, 0x0000,
  75.    0x000f, 0x0000,
  76.    0x000f, 0x0000,
  77.    };
  78. struct Image emptyImage = { 0,0, 34,17, 1, emptyData, 0x0,0x0, NULL };
  79.  
  80.  
  81. static UWORD __chip arr_upData[] =
  82.    {
  83.    0x0001, 0x8000,    /* ...............##............... */
  84.    0x0007, 0xe000,    /* .............######............. */
  85.    0x001f, 0xf800,    /* ...........##########........... */
  86.    0x007f, 0xfe00,    /* .........##############......... */
  87.    0x01ff, 0xff80,    /* .......##################....... */
  88.    0x07ff, 0xffe0,    /* .....######################..... */
  89.    0x1fff, 0xfff8,    /* ...##########################... */
  90.    0x7fff, 0xfffe,    /* .##############################. */
  91.    0x001f, 0xf800,    /* ...........##########........... */
  92.    0x001f, 0xf800,    /* ...........##########........... */
  93.    0x001f, 0xf800,    /* ...........##########........... */
  94.    0x001f, 0xf800,    /* ...........##########........... */
  95.    0x001f, 0xf800,    /* ...........##########........... */
  96.    0x001f, 0xf800,    /* ...........##########........... */
  97.    0x001f, 0xf800,    /* ...........##########........... */
  98.    };
  99. struct Image arr_upImage = { 0,0, 31,15, 1, arr_upData, 0x1,0x0, NULL };
  100.  
  101.  
  102. static UWORD __chip arr_downData[] =
  103.    {
  104.    0x001f, 0xf800,    /* ...........##########........... */
  105.    0x001f, 0xf800,    /* ...........##########........... */
  106.    0x001f, 0xf800,    /* ...........##########........... */
  107.    0x001f, 0xf800,    /* ...........##########........... */
  108.    0x001f, 0xf800,    /* ...........##########........... */
  109.    0x001f, 0xf800,    /* ...........##########........... */
  110.    0x001f, 0xf800,    /* ...........##########........... */
  111.    0x7fff, 0xfffe,    /* .##############################. */
  112.    0x1fff, 0xfff8,    /* ...##########################... */
  113.    0x07ff, 0xffe0,    /* .....######################..... */
  114.    0x01ff, 0xff80,    /* .......##################....... */
  115.    0x007f, 0xfe00,    /* .........##############......... */
  116.    0x001f, 0xf800,    /* ...........##########........... */
  117.    0x0007, 0xe000,    /* .............######............. */
  118.    0x0001, 0x8000,    /* ...............##............... */
  119.    };
  120. struct Image arr_downImage = { 0,0, 31,15, 1, arr_downData, 0x1,0x0, NULL };
  121.  
  122. static UWORD __chip arr_leftData[] =
  123.    {
  124.    0x0006, 0x0000,    /* .............##................. */
  125.    0x001e, 0x0000,    /* ...........####................. */
  126.    0x007e, 0x0000,    /* .........######................. */
  127.    0x01fe, 0x0000,    /* .......########................. */
  128.    0x07ff, 0xfff8,    /* .....########################... */
  129.    0x1fff, 0xfff8,    /* ...##########################... */
  130.    0x7fff, 0xfff8,    /* .############################... */
  131.    0x1fff, 0xfff8,    /* ...##########################... */
  132.    0x07ff, 0xfff8,    /* .....########################... */
  133.    0x01fe, 0x0000,    /* .......########................. */
  134.    0x007e, 0x0000,    /* .........######................. */
  135.    0x001e, 0x0000,    /* ...........####................. */
  136.    0x0006, 0x0000,    /* .............##................. */
  137.    };
  138. struct Image arr_leftImage = { 0,0, 31,13, 1, arr_leftData, 0x1,0x0, NULL };
  139.  
  140.  
  141. static UWORD __chip arr_rightData[] =
  142.    {
  143.    0x0003, 0x0000,    /* ..............##................ */
  144.    0x0003, 0xc000,    /* ..............####.............. */
  145.    0x0003, 0xf000,    /* ..............######............ */
  146.    0x0003, 0xfc00,    /* ..............########.......... */
  147.    0xffff, 0xff00,    /* ########################........ */
  148.    0xffff, 0xffc0,    /* ##########################...... */
  149.    0xffff, 0xfff0,    /* ############################.... */
  150.    0xffff, 0xffc0,    /* ##########################...... */
  151.    0xffff, 0xff00,    /* ########################........ */
  152.    0x0003, 0xfc00,    /* ..............########.......... */
  153.    0x0003, 0xf000,    /* ..............######............ */
  154.    0x0003, 0xc000,    /* ..............####.............. */
  155.    0x0003, 0x0000,    /* ..............##................ */
  156.    };
  157. struct Image arr_rightImage = { 0,0, 31,13, 1, arr_rightData, 0x1,0x0, NULL };
  158.  
  159.  
  160. static UWORD __chip buttonData[] =
  161.    {
  162.    0x000f, 0xfe00, 0x0000,    /* ............###########......................... */
  163.    0x00ff, 0xffe0, 0x0000,    /* ........###################..................... */
  164.    0x03ff, 0xfff8, 0x0000,    /* ......#######################................... */
  165.    0x0ffc, 0x07fe, 0x0000,    /* ....##########.......##########................. */
  166.    0x1fe0, 0x00ff, 0x0000,    /* ...########.............########................ */
  167.    0x3fc0, 0x007f, 0x8000,    /* ..########...............########............... */
  168.    0x3f80, 0x003f, 0x8000,    /* ..#######.................#######............... */
  169.    0x7f00, 0x001f, 0xc000,    /* .#######...................#######.............. */
  170.    0x7f00, 0x001f, 0xc000,    /* .#######...................#######.............. */
  171.    0x7f00, 0x001f, 0xc000,    /* .#######...................#######.............. */
  172.    0x3f80, 0x003f, 0x8000,    /* ..#######.................#######............... */
  173.    0x3fc0, 0x007f, 0x8000,    /* ..########...............########............... */
  174.    0x1fe0, 0x00ff, 0x0000,    /* ...########.............########................ */
  175.    0x0ffc, 0x07fe, 0x0000,    /* ....##########.......##########................. */
  176.    0x03ff, 0xfff8, 0x0000,    /* ......#######################................... */
  177.    0x00ff, 0xffe0, 0x0000,    /* ........###################..................... */
  178.    0x000f, 0xfe00, 0x0000,    /* ............###########......................... */
  179.  
  180.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  181.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  182.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  183.    0x0003, 0xf800, 0x0000,    /* ..............#######........................... */
  184.    0x001f, 0xff00, 0x0000,    /* ...........#############........................ */
  185.    0x003f, 0xff80, 0x0000,    /* ..........###############....................... */
  186.    0x007f, 0xffc0, 0x0000,    /* .........#################...................... */
  187.    0x00ff, 0xffe0, 0x0000,    /* ........###################..................... */
  188.    0x00ff, 0xffe0, 0x0000,    /* ........###################..................... */
  189.    0x00ff, 0xffe0, 0x0000,    /* ........###################..................... */
  190.    0x007f, 0xffc0, 0x0000,    /* .........#################...................... */
  191.    0x003f, 0xff80, 0x0000,    /* ..........###############....................... */
  192.    0x001f, 0xff00, 0x0000,    /* ...........#############........................ */
  193.    0x0003, 0xf800, 0x0000,    /* ..............#######........................... */
  194.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  195.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  196.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  197.  
  198.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  199.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  200.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  201.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  202.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  203.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  204.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  205.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  206.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  207.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  208.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  209.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  210.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  211.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  212.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  213.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  214.    0x0000, 0x0000, 0x0000,    /* ................................................ */
  215.    };
  216. struct Image buttonImage = { 0,0, 34,17, 3, buttonData, 0x7,0x0, NULL };
  217.  
  218. /*- */
  219. /* ---------------------------------------------------------------------- */
  220. /*+ "structs & global variables" */
  221. struct  GfxBase *GfxBase = NULL;
  222. struct  IntuitionBase *IntuitionBase = NULL;
  223. struct  Library *GadToolsBase = NULL;
  224. struct  Library *LowLevelBase = NULL;
  225. struct  Screen *mysc = NULL;
  226. struct  Menu *menu = NULL;
  227. struct  Window *mywin = NULL;
  228. void    *vi = NULL;
  229. struct  DrawInfo *dri = NULL;
  230.  
  231. BOOL    shell;
  232. BOOL    terminated;
  233. ULONG   joyport;
  234. /*- */
  235. /* ---------------------------------------------------------------------- */
  236. /*+ "int main(int argc, char *argv[])" */
  237. int
  238. main(int argc, char *argv[])
  239. {
  240.         struct  IntuiMessage *imsg;
  241.         ULONG   imsgClass;
  242.         UWORD   imsgCode;
  243.         ULONG   joystick;
  244.         ULONG   o_joy;
  245. /*        struct  TagItem tags[1]; */
  246. /* no more need for tags, using SetJoyPortAttrs instead of SetJoyPortAttrsA */
  247.  
  248.         shell = TRUE;
  249. /*        shell = FALSE; */
  250.         terminated = FALSE;
  251.         joyport = 1;
  252.         joystick = 0;
  253.         o_joy = 0;
  254. /* ---------------------------------------------------------------------- */
  255.         if (shell) puts("Do NOT run me from the ZSHell !!!");
  256. /*+ "args" */
  257.         if (argc == 2)
  258.         {
  259.                 printf("Usage:\n\tJoystick <options>\nwhat options???\n");
  260.                 bail_out(0);
  261.         }
  262. /*- */
  263. /*+ "Open all libraries" */
  264.         if (!(GfxBase = (struct GfxBase *) OpenLibrary((UBYTE *)"graphics.library", 39L)))
  265.                 bail_out(20);
  266.  
  267.         if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary((UBYTE *)"intuition.library", 39L)))
  268.                 bail_out(20);
  269.  
  270.         if (!(GadToolsBase = OpenLibrary((UBYTE *)"gadtools.library", 39L)))
  271.                 bail_out(20);
  272.  
  273.         if (!(LowLevelBase = OpenLibrary((UBYTE *)"lowlevel.library", 40L)))
  274.                 bail_out(20);
  275.  
  276.         if (!(mysc = LockPubScreen(NULL)))
  277.                 bail_out(20);
  278.  
  279.         if (!(vi = GetVisualInfo(mysc,
  280.             TAG_DONE)))
  281.                 bail_out(20);
  282.  
  283.         if (!(dri = GetScreenDrawInfo(mysc)))
  284.                 bail_out(20);
  285. #ifdef DEBUG
  286.         if (shell) puts("libraries opened!");
  287. #endif
  288. /*- */
  289. /*+ "create menu and open window" */
  290.         if (!(menu = CreateMenus(mynewmenu,
  291.                 TAG_DONE)))
  292.         {
  293.                 bail_out(20);
  294.         }
  295.  
  296.         if (!LayoutMenus(menu, vi,
  297. /*        GTMN_TextAttr, tattr, */
  298.                 GTMN_NewLookMenus, TRUE,
  299.                 TAG_DONE))
  300.                 bail_out(20);
  301.  
  302.         if (!(mywin = OpenWindowTags(NULL,
  303.                 WA_InnerWidth, 150,
  304.                 WA_InnerHeight, 100,
  305.                 WA_Top, 50,
  306.                 WA_Left, 50,
  307.  
  308.                 WA_Activate, TRUE,
  309.                 WA_DragBar, TRUE,
  310.                 WA_DepthGadget, TRUE,
  311.                 WA_CloseGadget, TRUE,
  312. /*                WA_SizeGadget, TRUE, */
  313.                 WA_SmartRefresh, TRUE,
  314.  
  315. /* NOTE: NOCAREREFRESH is not allowed if you use GadTools Gadgets! */
  316.                 WA_NoCareRefresh, TRUE,
  317.  
  318.                 WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_MENUPICK,
  319.  
  320.                 WA_MaxWidth,  150,
  321.                 WA_MaxHeight, 100,
  322.                 WA_MinWidth,  150,
  323.                 WA_MinHeight, 100,
  324.                 WA_Title, "Joystick",
  325.                 WA_ScreenTitle, "Joystick Tester ©1997 Christian T. Steigies",
  326.                 WA_NewLookMenus, TRUE,
  327.                 TAG_DONE)))
  328.                 bail_out(20);
  329.  
  330.         SetMenuStrip(mywin, menu);
  331. #ifdef DEBUG
  332.         if (shell) puts("window opened!");
  333. #endif
  334.  
  335. /*- */
  336. /* ---------------------------------------------------------------------- */
  337. /*+ "main loop" */
  338.     if (!SetJoyPortAttrs( joyport, SJA_TYPE_JOYSTK )) {
  339.             if (shell) puts("Failure!");
  340.     }
  341.     while (!terminated)
  342.     {
  343. /*        if (!SetJoyPortAttrs( joyport, SJA_TYPE_JOYSTK )) {
  344.                 if (shell) puts("Failure!");
  345.         } */
  346.         joystick = ReadJoyPort(joyport); /* & (JP_DIRECTION_MASK | JP_BUTTON_MASK); */
  347.         HandleJoyportEvent(joystick);
  348.  
  349.         if (imsg = (struct IntuiMessage *)GetMsg(mywin->UserPort))
  350.         {
  351.             if (shell) printf("current joyport is: %d\n",joyport);
  352.             imsgClass = imsg->Class;
  353.             imsgCode = imsg->Code;
  354.             ReplyMsg((struct Message *)imsg);
  355.             switch (imsgClass) {
  356.                 case IDCMP_MENUPICK:
  357.                     terminated = HandleMenuEvent(imsgCode);
  358.                     break;
  359.  
  360.                 case IDCMP_CLOSEWINDOW:
  361.                     if (shell) printf("CLOSEWINDOW.\n");
  362.                     terminated = TRUE;
  363.                     break;
  364.             } /* switch */
  365.         } /* if */
  366.         Delay(1);
  367.     } /* while */
  368. /*- */
  369. /* ---------------------------------------------------------------------- */
  370.         bail_out(0);
  371. }
  372. /*- */
  373. /* ---------------------------------------------------------------------- */
  374. /*+ "void bail_out(int code)" */
  375. /*
  376.  * Function to close down or free any opened or allocated stuff, and then
  377.  * exit.
  378.  *
  379.  */
  380. void
  381. bail_out(int code)
  382. {
  383.         int     i;
  384.  
  385.  
  386.         if (LowLevelBase)
  387.         {
  388.                 for (i = 0; i++; i <= 3) {
  389.                         SetJoyPortAttrs(i, SJA_Reinitialize);
  390.                 } /* for */
  391.  
  392.                 CloseLibrary(LowLevelBase);
  393.         }
  394.  
  395.         if (mywin)
  396.         {
  397.                 ClearMenuStrip(mywin);
  398.                 CloseWindow(mywin);
  399.         }
  400.  
  401.     /* None of these two calls mind a NULL parameter, so it's not
  402.      * necessary to check for non-NULL before calling.  If we do that,
  403.      * we must be certain that the OpenLibrary() of GadTools succeeded,
  404.      * or else we would be jumping into outer space:
  405.      */
  406.         if (GadToolsBase)
  407.         {
  408.                 FreeMenus(menu);
  409.                 FreeVisualInfo(vi);
  410.                 CloseLibrary(GadToolsBase);
  411.         }
  412.  
  413.         if (dri)
  414.         {
  415.                 FreeScreenDrawInfo( mysc, dri );
  416.         }
  417.  
  418.         if (mysc)
  419.         {
  420.                 UnlockPubScreen(NULL, mysc);
  421.         }
  422.  
  423.         if (IntuitionBase)
  424.         {
  425.                 CloseLibrary( (struct Library *) IntuitionBase );
  426.         }
  427.  
  428.         if (GfxBase)
  429.         {
  430.                 CloseLibrary( (struct Library *) GfxBase );
  431.         }
  432.  
  433.         exit(code);
  434. }
  435.  
  436. /*- */
  437. /* ---------------------------------------------------------------------- */
  438. /*+ "BOOL HandleMenuEvent(UWORD code)" */
  439. /*
  440.  * This function handles IntuiMessage events of type MENUPICK.
  441.  *
  442.  */
  443. BOOL
  444. HandleMenuEvent(UWORD code)
  445. {
  446.     /* Your code goes here */
  447. #ifdef DEBUG
  448.         if (shell) {
  449.                 printf( "imsgCode: %i\t",code );
  450.                 printf( "Menu Nr.: %i\t",( MENUNUM(code) ) );
  451.                 printf( "Item Nr.: %i\t",( ITEMNUM(code) ) );
  452.                 printf( "Sub  Nr.: %i\n",( SUBNUM(code) ) );
  453.         }
  454. #endif
  455.         switch (MENUNUM(code)) {
  456.                 case 0: /* Project */
  457.                         switch (ITEMNUM(code))
  458.                         {
  459.                                 case 0: /* About */
  460.                                         if (shell) puts("About!");
  461.                                         break;
  462.                                 case 2: /* Quit */
  463.                                         if (shell) puts("Terminated by Menu :-(");
  464.                                         return TRUE;
  465.                                         break;
  466.                         }
  467.                        break;
  468.                 case 1: /* Options */
  469.                         switch (ITEMNUM(code))
  470.                         {
  471.                                 case 0: /* Port 0 */
  472.                                         if (shell) puts("Joystick in Port 0 selected");
  473.                                         if (!SetJoyPortAttrs(0 , SJA_TYPE_JOYSTK)) {
  474.                                                 if (shell) puts("Failure!");
  475.                                         }
  476.                                         joyport = 0;
  477.                                         break;
  478.                                 case 1: /* Port 1 */
  479.                                         if (shell) puts("Joystick in Port 1 selected");
  480.                                         if (!SetJoyPortAttrs(1 , SJA_TYPE_JOYSTK)) {
  481.                                                 if (shell) puts("Failure!");
  482.                                         }
  483.                                         joyport = 1;
  484.                                         break;
  485.                                 case 2: /* Port 2 */
  486.                                         if (shell) puts("Joystick in Port 2 selected (4-player adapter)");
  487.                                         if (!SetJoyPortAttrs(2 , SJA_TYPE_JOYSTK)) {
  488.                                                 if (shell) puts("Failure!");
  489.                                         }
  490.                                         joyport = 2;
  491.                                         break;
  492.                                 case 3: /* Port 3 */
  493.                                         if (shell) puts("Joystick in Port 3 selected (4-player adapter)");
  494.                                         if (!SetJoyPortAttrs(3 , SJA_TYPE_JOYSTK)) {
  495.                                                 if (shell) puts("Failure!");
  496.                                         }
  497.                                         joyport = 3;
  498.                                         break;
  499.                         }
  500.                         break;
  501.         }
  502.         return(FALSE);
  503. }
  504. /*- */
  505. /* ---------------------------------------------------------------------- */
  506. /*+ "BOOL HandleJoyportEvent(ULONG joystick)" */
  507. BOOL
  508. HandleJoyportEvent(ULONG joystick)
  509. {
  510. /* SystemControlA() ?*/
  511. #ifdef DEBUG
  512.         BOOL    newline;
  513.  
  514.         newline = FALSE;
  515.         if (joystick & JP_TYPE_JOYSTK) {
  516.             if (shell) puts("Joystick");
  517.         }
  518.         if (joystick & JP_TYPE_MOUSE) {
  519.             if (shell) puts("Mouse");
  520.         }
  521.         if (joystick & JP_TYPE_NOTAVAIL) {
  522.             if (shell) puts("Notavail");
  523.         }
  524.         if (joystick & JP_TYPE_GAMECTLR) {
  525.             if (shell) puts("Game");
  526.         }
  527.         if (joystick & JP_TYPE_UNKNOWN) {
  528.             if (shell) puts("Unknown");
  529.         }
  530. #endif
  531.  
  532.         if (joystick & JPF_BUTTON_RED) {
  533.             DrawImage(mywin->RPort, &buttonImage, 20-3, 20);
  534. #ifdef DEBUG
  535.             if (shell) printf("LEFT FIRE BUTTON ");
  536.             newline = TRUE;
  537. #endif
  538.         } else {
  539.             DrawImage(mywin->RPort, &emptyImage, 20-3, 20);
  540.         }
  541.  
  542.         if (joystick & JPF_BUTTON_BLUE) {
  543.             DrawImage(mywin->RPort, &buttonImage, 100-3, 20);
  544. #ifdef DEBUG
  545.             if (shell) printf("RIGHT FIRE BUTTON ");
  546.             newline = TRUE;
  547. #endif
  548.         } else {
  549.             DrawImage(mywin->RPort, &emptyImage, 100-3, 20);
  550.         }
  551.  
  552.         if (joystick & JPF_BUTTON_PLAY) {
  553.             DrawImage(mywin->RPort, &buttonImage, 60-3, 20);
  554. #ifdef DEBUG
  555.             if (shell) printf("MIDDLE FIRE BUTTON ");
  556.             newline = TRUE;
  557. #endif
  558.         } else {
  559.             DrawImage(mywin->RPort, &emptyImage, 60-3, 20);
  560.         }
  561.  
  562.         if (joystick & JPF_JOY_UP) {
  563.             DrawImage(mywin->RPort, &arr_upImage, 60, 40);
  564. #ifdef DEBUG
  565.             if (shell) printf("UP ");
  566.             newline = TRUE;
  567. #endif
  568.         } else {
  569.             DrawImage(mywin->RPort, &emptyImage, 60, 40);
  570.         }
  571.  
  572.         if (joystick & JPF_JOY_DOWN) {
  573.             DrawImage(mywin->RPort, &arr_downImage, 60, 80);
  574. #ifdef DEBUG
  575.             if (shell) printf("DOWN ");
  576.             newline = TRUE;
  577. #endif
  578.         } else {
  579.             DrawImage(mywin->RPort, &emptyImage, 60, 80);
  580.         }
  581.  
  582.         if (joystick & JPF_JOY_LEFT) {
  583.             DrawImage(mywin->RPort, &arr_leftImage, 20, 60);
  584. #ifdef DEBUG
  585.             if (shell) printf("LEFT ");
  586.             newline = TRUE;
  587. #endif
  588.         } else {
  589.             DrawImage(mywin->RPort, &emptyImage, 20, 60);
  590.         }
  591.  
  592.         if (joystick & JPF_JOY_RIGHT) {
  593.             DrawImage(mywin->RPort, &arr_rightImage, 100, 60);
  594. #ifdef DEBUG
  595.             if (shell) printf("RIGHT ");
  596.             newline = TRUE;
  597. #endif
  598.         } else {
  599.             DrawImage(mywin->RPort, &emptyImage, 100, 60);
  600.         }
  601.  
  602. #ifdef DEBUG
  603.         if (newline) {
  604.             if (shell) printf("\n");
  605.             newline = FALSE;
  606.         }
  607. #endif
  608.         return(TRUE);
  609. }
  610. /*- */
  611. /* ---------------------------------------------------------------------- */
  612.  
  613.