home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 505b.lha / Ham_e_library / StrokeDemo.c < prev    next >
C/C++ Source or Header  |  1991-05-05  |  14KB  |  594 lines

  1.  
  2. #include <intuition/intuition.h>
  3. #include <exec/types.h>
  4. #include <exec/execbase.h>
  5. #include <graphics/text.h>
  6.  
  7. #include <proto/exec.h>
  8. #include <proto/graphics.h>
  9.  
  10. #include "hame_pragmas.h"
  11.  
  12. #include "HameStruct.h"
  13. #include "HameProtos.h"
  14. #include "HameRev.h"
  15.  
  16. /*   */
  17.  
  18. #include <string.h>
  19. #include <exec/memory.h>
  20. #include <exec/tasks.h>
  21.  
  22. #include <graphics/view.h>
  23. #include <graphics/gfx.h>
  24. #include <graphics/rastport.h>
  25.  
  26. #include <proto/intuition.h>
  27.  
  28. /*   */
  29.  
  30. struct Library *HameBase;
  31. struct HamePort *HamePort;
  32.  
  33. extern struct Screen *OpenScreen();
  34. extern struct Window *OpenWindow();
  35.  
  36. extern struct ExecBase *SysBase;  /* These are all pointers to system */
  37. struct IntuitionBase *IntuitionBase;  /* These are all pointers to system */
  38. struct GfxBase       *GfxBase;        /* data structures I need access to */
  39.  
  40. struct Screen        *screen;
  41. struct Window        *window;
  42.  
  43. struct Clip *clip;
  44. UBYTE  *ptr1, *ptr2;
  45. long ptsize;
  46.  
  47.  
  48. #define WIDTH 640
  49. #define HEIGHT 200
  50.  
  51. struct NewScreen my_screen =
  52.   {
  53.     0, 0, WIDTH, HEIGHT,
  54.     4,
  55.     0, 1,
  56.     HIRES,
  57.     CUSTOMSCREEN,
  58.     (struct TextAttr *) NULL,
  59.     NULL,
  60.     NULL, NULL
  61.   };
  62.  
  63. struct NewWindow my_window =
  64.   {
  65.     0, 2, WIDTH, HEIGHT-2,
  66.     (UBYTE) 0, (UBYTE) 15,
  67.     MOUSEBUTTONS
  68.        | INTUITICKS | CLOSEWINDOW,
  69.     SMART_REFRESH
  70.        | BACKDROP
  71.        | ACTIVATE
  72.        | NOCAREREFRESH
  73.        | REPORTMOUSE
  74.        | RMBTRAP | WINDOWCLOSE,
  75.     NULL, NULL,
  76.     "Black Belt Systems hame.library DEMO - Programming: Pete Patterson",
  77.     NULL, NULL,
  78.     0, 0, 0, 0,
  79.     CUSTOMSCREEN
  80.   };
  81.  
  82.  
  83. UBYTE apat[8][8] = {
  84.  {  1,  1,  1,  1,  1,  1,  1,  1},
  85.  {  1,  1,255,255,255,255,  1,  1},
  86.  {  1,255,  1,  1,  1,  1,255,  1},
  87.  {  1,255,  1,  1,  1,  1,255,  1},
  88.  {  1,255,255,255,255,255,255,  1},
  89.  {  1,255,  1,  1,  1,  1,255,  1},
  90.  {  1,255,  1,  1,  1,  1,255,  1},
  91.  {  1,255,  1,  1,  1,  1,255,  1}
  92.   };
  93.  
  94. UBYTE bpat[8][8] = {
  95.  {  1,  1,  1,  1,  1,  1,  1,  1},
  96.  {  1,255,255,255,255,255,  1,  1},
  97.  {  1,255,  1,  1,  1,  1,255,  1},
  98.  {  1,255,  1,  1,  1,  1,255,  1},
  99.  {  1,255,255,255,255,255,  1,  1},
  100.  {  1,255,  1,  1,  1,  1,255,  1},
  101.  {  1,255,  1,  1,  1,  1,255,  1},
  102.  {  1,255,255,255,255,255,  1,  1}
  103.   };
  104.  
  105. UBYTE cpat[8][8] = {
  106.  {  1,  1,  1,  1,  1,  1,  1,  1},
  107.  {  1,  1,255,255,255,255,  1,  1},
  108.  {  1,255,  1,  1,  1,  1,255,  1},
  109.  {  1,255,  1,  1,  1,  1,  1,  1},
  110.  {  1,255,  1,  1,  1,  1,  1,  1},
  111.  {  1,255,  1,  1,  1,  1,  1,  1},
  112.  {  1,255,  1,  1,  1,  1,255,  1},
  113.  {  1,  1,255,255,255,255,  1,  1}
  114.   };
  115.  
  116. UBYTE dpat[8][8] = { 
  117.  {  1,  1,  1,  1,  1,  1,  1,  1},
  118.  {  1,255,255,255,255,255,  1,  1},
  119.  {  1,255,  1,  1,  1,  1,255,  1},
  120.  {  1,255,  1,  1,  1,  1,255,  1},
  121.  {  1,255,  1,  1,  1,  1,255,  1},
  122.  {  1,255,  1,  1,  1,  1,255,  1},
  123.  {  1,255,  1,  1,  1,  1,255,  1},
  124.  {  1,255,255,255,255,255,  1,  1}
  125.   };
  126.  
  127. UBYTE epat[8][8] = {
  128.  {  1,  1,  1,  1,  1,  1,  1,  1},
  129.  {  1,255,255,255,255,255,  1,  1},
  130.  {  1,255,  1,  1,  1,  1,  1,  1},
  131.  {  1,255,  1,  1,  1,  1,  1,  1},
  132.  {  1,255,255,255,255,  1,  1,  1},
  133.  {  1,255,  1,  1,  1,  1,  1,  1},
  134.  {  1,255,  1,  1,  1,  1,  1,  1},
  135.  {  1,255,255,255,255,255,  1,  1}
  136.   };
  137.  
  138. UBYTE fpat[8][8] = {
  139.  {  1,  1,  1,  1,  1,  1,  1,  1},
  140.  {  1,255,255,255,255,255,  1,  1},
  141.  {  1,255,  1,  1,  1,  1,  1,  1},
  142.  {  1,255,  1,  1,  1,  1,  1,  1},
  143.  {  1,255,255,255,255,  1,  1,  1},
  144.  {  1,255,  1,  1,  1,  1,  1,  1},
  145.  {  1,255,  1,  1,  1,  1,  1,  1},
  146.  {  1,255,  1,  1,  1,  1,  1,  1}
  147.   };
  148.  
  149. UBYTE gpat[8][8] = {
  150.  {  1,  1,  1,  1,  1,  1,  1,  1},
  151.  {  1,  1,255,255,255,255,  1,  1},
  152.  {  1,255,  1,  1,  1,  1,255,  1},
  153.  {  1,255,  1,  1,  1,  1,  1,  1},
  154.  {  1,255,  1,  1,  1,  1,  1,  1},
  155.  {  1,255,  1,  1,  1,255,255,  1},
  156.  {  1,255,  1,  1,  1,  1,255,  1},
  157.  {  1,  1,255,255,255,255,  1,  1}
  158.   };
  159.  
  160. UBYTE hpat[8][8] = {
  161.  {  1,  1,  1,  1,  1,  1,  1,  1},
  162.  {  1,255,  1,  1,  1,  1,255,  1},
  163.  {  1,255,  1,  1,  1,  1,255,  1},
  164.  {  1,255,  1,  1,  1,  1,255,  1},
  165.  {  1,255,255,255,255,255,255,  1},
  166.  {  1,255,  1,  1,  1,  1,255,  1},
  167.  {  1,255,  1,  1,  1,  1,255,  1},
  168.  {  1,255,  1,  1,  1,  1,255,  1}
  169.   };
  170.  
  171. UBYTE ipat[8][8] = {
  172.  {  1,  1,  1,  1,  1,  1,  1,  1},
  173.  {  1,  1,255,255,255,  1,  1,  1},
  174.  {  1,  1,  1,255,  1,  1,  1,  1},
  175.  {  1,  1,  1,255,  1,  1,  1,  1},
  176.  {  1,  1,  1,255,  1,  1,  1,  1},
  177.  {  1,  1,  1,255,  1,  1,  1,  1},
  178.  {  1,  1,  1,255,  1,  1,  1,  1},
  179.  {  1,  1,255,255,255,  1,  1,  1}
  180.   };
  181.  
  182. UBYTE jpat[8][8] = {
  183.  {  1,  1,  1,  1,  1,  1,  1,  1},
  184.  {  1,  1,  1,255,255,255,  1,  1},
  185.  {  1,  1,  1,  1,255,  1,  1,  1},
  186.  {  1,  1,  1,  1,255,  1,  1,  1},
  187.  {  1,  1,  1,  1,255,  1,  1,  1},
  188.  {  1,255,  1,  1,255,  1,  1,  1},
  189.  {  1,255,  1,  1,255,  1,  1,  1},
  190.  {  1,  1,255,255,  1,  1,  1,  1}
  191.   };
  192.  
  193. UBYTE kpat[8][8] = {
  194.  {  1,  1,  1,  1,  1,  1,  1,  1},
  195.  {  1,255,  1,  1,  1,255,  1,  1},
  196.  {  1,255,  1,  1,  1,255,  1,  1},
  197.  {  1,255,  1,  1,255,  1,  1,  1},
  198.  {  1,255,222,255,  1,  1,  1,  1},
  199.  {  1,255,  1,  1,255,  1,  1,  1},
  200.  {  1,255,  1,  1,  1,255,  1,  1},
  201.  {  1,255,  1,  1,  1,255,  1,  1}
  202.   };
  203.  
  204. UBYTE lpat[8][8] = {
  205.  {  1,  1,  1,  1,  1,  1,  1,  1},
  206.  {  1,255,  1,  1,  1,  1,  1,  1},
  207.  {  1,255,  1,  1,  1,  1,  1,  1},
  208.  {  1,255,  1,  1,  1,  1,  1,  1},
  209.  {  1,255,  1,  1,  1,  1,  1,  1},
  210.  {  1,255,  1,  1,  1,  1,  1,  1},
  211.  {  1,255,  1,  1,  1,  1,  1,  1},
  212.  {  1,255,255,255,255,255,  1,  1}
  213.   };
  214.  
  215. UBYTE mpat[8][8] = {
  216.  {  1,  1,  1,  1,  1,  1,  1,  1},
  217.  {  1,255,  1,  1,  1,  1,255,  1},
  218.  {  1,255,  1,  1,  1,  1,255,  1},
  219.  {  1,255,255,  1,  1,255,255,  1},
  220.  {  1,255,255,255,255,255,255,  1},
  221.  {  1,255,  1,255,255,  1,255,  1},
  222.  {  1,255,  1,  1,  1,  1,255,  1},
  223.  {  1,255,  1,  1,  1,  1,255,  1}
  224.   };
  225.  
  226. UBYTE npat[8][8] = {
  227.  {  1,  1,  1,  1,  1,  1,  1,  1},
  228.  {  1,255,  1,  1,  1,  1,255,  1},
  229.  {  1,255,  1,  1,  1,  1,255,  1},
  230.  {  1,255,255,  1,  1,  1,255,  1},
  231.  {  1,255,255,255,  1,  1,255,  1},
  232.  {  1,255,  1,255,255,  1,255,  1},
  233.  {  1,255,  1,  1,255,255,255,  1},
  234.  {  1,255,  1,  1,  1,255,255,  1}
  235.   };
  236.  
  237. UBYTE opat[8][8] = {
  238.  {  1,  1,  1,  1,  1,  1,  1,  1},
  239.  {  1,  1,255,255,255,255,  1,  1},
  240.  {  1,255,  1,  1,  1,  1,255,  1},
  241.  {  1,255,  1,  1,  1,  1,255,  1},
  242.  {  1,255,  1,  1,  1,  1,255,  1},
  243.  {  1,255,  1,  1,  1,  1,255,  1},
  244.  {  1,255,  1,  1,  1,  1,255,  1},
  245.  {  1,  1,255,255,255,255,  1,  1}
  246.   };
  247.  
  248. UBYTE ppat[8][8] = {
  249.  {  1,  1,  1,  1,  1,  1,  1,  1},
  250.  {  1,255,255,255,255,255,  1,  1},
  251.  {  1,255,  1,  1,  1,  1,255,  1},
  252.  {  1,255,  1,  1,  1,  1,255,  1},
  253.  {  1,255,255,255,255,255,  1,  1},
  254.  {  1,255,  1,  1,  1,  1,  1,  1},
  255.  {  1,255,  1,  1,  1,  1,  1,  1},
  256.  {  1,255,  1,  1,  1,  1,  1,  1}
  257.   };
  258.  
  259. UBYTE qpat[8][8] = {
  260.  {  1,  1,  1,  1,  1,  1,  1,  1},
  261.  {  1,  1,255,255,255,255,  1,  1},
  262.  {  1,255,  1,  1,  1,  1,255,  1},
  263.  {  1,255,  1,  1,  1,  1,255,  1},
  264.  {  1,255,  1,  1,  1,  1,255,  1},
  265.  {  1,255,  1,  1,  1,255,255,  1},
  266.  {  1,255,  1,  1,  1,  1,255,  1},
  267.  {  1,  1,255,255,255,255,  1,255}
  268.   };
  269.  
  270. UBYTE rpat[8][8] = {
  271.  {  1,  1,  1,  1,  1,  1,  1,  1},
  272.  {  1,255,255,255,255,255,  1,  1},
  273.  {  1,255,  1,  1,  1,  1,255,  1},
  274.  {  1,255,  1,  1,  1,  1,255,  1},
  275.  {  1,255,255,255,255,255,  1,  1},
  276.  {  1,255,  1,  1,  1,  1,255,  1},
  277.  {  1,255,  1,  1,  1,  1,255,  1},
  278.  {  1,255,  1,  1,  1,  1,255,  1}
  279.   };
  280.  
  281. UBYTE spat[8][8] = {
  282.  {  1,  1,  1,  1,  1,  1,  1,  1},
  283.  {  1,  1,255,255,255,255,  1,  1},
  284.  {  1,255,  1,  1,  1,  1,255,  1},
  285.  {  1,255,  1,  1,  1,  1,  1,  1},
  286.  {  1,  1,255,255,255,255,  1,  1},
  287.  {  1,  1,  1,  1,  1,  1,255,  1},
  288.  {  1,255,  1,  1,  1,  1,255,  1},
  289.  {  1,  1,255,255,255,255,  1,  1}
  290.   };
  291.  
  292. UBYTE tpat[8][8] = {
  293.  {  1,  1,  1,  1,  1,  1,  1,  1},
  294.  {  1,255,255,255,255,255,  1,  1},
  295.  {  1,  1,  1,255,  1,  1,  1,  1},
  296.  {  1,  1,  1,255,  1,  1,  1,  1},
  297.  {  1,  1,  1,255,  1,  1,  1,  1},
  298.  {  1,  1,  1,255,  1,  1,  1,  1},
  299.  {  1,  1,  1,255,  1,  1,  1,  1},
  300.  {  1,  1,  1,255,  1,  1,  1,  1}
  301.   };
  302.  
  303. UBYTE upat[8][8] = {
  304.  {  1,  1,  1,  1,  1,  1,  1,  1},
  305.  {  1,255,  1,  1,  1,  1,255,  1},
  306.  {  1,255,  1,  1,  1,  1,255,  1},
  307.  {  1,255,  1,  1,  1,  1,255,  1},
  308.  {  1,255,  1,  1,  1,  1,255,  1},
  309.  {  1,255,  1,  1,  1,  1,255,  1},
  310.  {  1,255,  1,  1,  1,  1,255,  1},
  311.  {  1,  1,255,255,255,255,  1,  1}
  312.   };
  313.  
  314. UBYTE vpat[8][8] = {
  315.  {  1,  1,  1,  1,  1,  1,  1,  1},
  316.  {  1,255,  1,  1,  1,  1,255,  1},
  317.  {  1,255,  1,  1,  1,  1,255,  1},
  318.  {  1,255,  1,  1,  1,  1,255,  1},
  319.  {  1,255,  1,  1,  1,  1,255,  1},
  320.  {  1,  1,255,  1,  1,255, 1,  1},
  321.  {  1,  1,255,  1,  1,255,  1,  1},
  322.  {  1,  1,  1,255,255,  1,  1,  1}
  323.   };
  324.  
  325. UBYTE wpat[8][8] = {
  326.  {  1,  1,  1,  1,  1,  1,  1,  1},
  327.  {  1,255,  1,  1,  1,  1,255,  1},
  328.  {  1,255,  1,  1,  1,  1,255,  1},
  329.  {  1,255,  1,  1,  1,  1,255,  1},
  330.  {  1,255,  1,255,255,  1,255,  1},
  331.  {  1,255,255,255,255,255,255,  1},
  332.  {  1,255,255,  1,  1,255,255,  1},
  333.  {  1,255,  1,  1,  1,  1,255,  1}
  334.   };
  335.  
  336. UBYTE xpat[8][8] = {
  337.  {  1,  1,  1,  1,  1,  1,  1,  1},
  338.  {  1,  1,  1,  1,  1,  1,  1,  1},
  339.  {  1,255,  1,  1,  1,  1,255,  1},
  340.  {  1,  1,255,  1,  1,255,  1,  1},
  341.  {  1,  1,  1,255,255,  1,  1,  1},
  342.  {  1,  1,  1,255,255,  1,  1,  1},
  343.  {  1,  1,255,  1,  1,255,  1,  1},
  344.  {  1,255,  1,  1,  1,  1,255,  1}
  345.   };
  346.  
  347. UBYTE ypat[8][8] = {
  348.  {  1,  1,  1,  1,  1,  1,  1,  1},
  349.  {  1,255,  1,  1,  1,  1,255,  1},
  350.  {  1,255,  1,  1,  1,  1,255,  1},
  351.  {  1,255,255,  1,  1,255,255,  1},
  352.  {  1,  1,255,255,255,255,  1,  1},
  353.  {  1,  1,  1,255,255,  1,  1,  1},
  354.  {  1,  1,  1,255,255,  1,  1,  1},
  355.  {  1,  1,  1,255,255,  1,  1,  1}
  356.   };
  357.  
  358. UBYTE zpat[8][8] = {
  359.  {  1,  1,  1,  1,  1,  1,  1,  1},
  360.  {  1,255,255,255,255,255,255,  1},
  361.  {  1,  1,  1,  1,  1,255,255,  1},
  362.  {  1,  1,  1,  1,255,255,  1,  1},
  363.  {  1,  1,  1,255,255,  1,  1,  1},
  364.  {  1,  1,255,255,  1,  1,  1,  1},
  365.  {  1,255,255,  1,  1,  1,  1,  1},
  366.  {  1,255,255,255,255,255,255,  1}
  367.   };
  368.  
  369. UBYTE *letters[] = {
  370.     &apat[0][0],
  371.     &bpat[0][0],
  372.     &cpat[0][0],
  373.     &dpat[0][0],
  374.     &epat[0][0],
  375.     &fpat[0][0],
  376.     &gpat[0][0],
  377.     &hpat[0][0],
  378.     &ipat[0][0],
  379.     &jpat[0][0],
  380.     &kpat[0][0],
  381.     &lpat[0][0],
  382.     &mpat[0][0],
  383.     &npat[0][0],
  384.     &opat[0][0],
  385.     &ppat[0][0],
  386.     &qpat[0][0],
  387.     &rpat[0][0],
  388.     &spat[0][0],
  389.     &tpat[0][0],
  390.     &upat[0][0],
  391.     &vpat[0][0],
  392.     &wpat[0][0],
  393.     &xpat[0][0],
  394.     &ypat[0][0],
  395.     &zpat[0][0]
  396.   };
  397.  
  398.  
  399. /*
  400.   Clean up and exit
  401. */
  402. void CloseStuff()
  403.   {
  404.     struct Library *result;
  405.       if (clip)               HAME_DisposeClip(clip);
  406.       if (ptr1)               FreeMem(ptr1, ptsize);
  407.       if (window)             CloseWindow(window);
  408.       if (screen)             CloseScreen(screen);
  409.       if (HamePort)           HAME_Dispose(HamePort);
  410.       if (HameBase)           CloseLibrary(HameBase);
  411.       if (GfxBase)            CloseLibrary(GfxBase);
  412.       if (IntuitionBase)      CloseLibrary(IntuitionBase);
  413.  
  414.       Forbid();
  415.       if ( (result = (struct Library *) 
  416.            FindName(&SysBase->LibList,"hame.library")) != NULL ) 
  417.         {
  418.           RemLibrary(result);
  419.         }
  420.       Permit();
  421.  
  422.       exit(0);
  423.   }
  424.  
  425.  
  426. /*
  427.   Draw a vertical column of pixels at the left margin to prevent hame from
  428.   turning off.
  429. */
  430. void DrawLeftMargin()
  431.   {
  432.   int i;
  433.  
  434.   HAME_SetAPen( HamePort, 1 );
  435.   for ( i = 0; i < 200; i++ )
  436.     {
  437.       HAME_WritePixel( HamePort, 0, i);
  438.     }
  439.   }
  440.  
  441. /*
  442.   Initialize the palette to a grey, a red, a green and a blue scale
  443.   Note that the four groups are intermingled, and not separate groups
  444. */
  445. void palette1()
  446.   {
  447.   int i, j, r;
  448.  
  449.   j = 1;
  450.   for ( i = 0; i < 64; i++ )
  451.     {
  452.       r = i << 2;
  453.       HAME_SetRGB8(HamePort, j++, r, r, r);
  454.       HAME_SetRGB8(HamePort, j++, r, 0, 0);
  455.       HAME_SetRGB8(HamePort, j++, 0, r, 0);
  456.       HAME_SetRGB8(HamePort, j++, 0, 0, r);
  457.     }
  458.   }
  459.  
  460. void DoLetter()
  461.  {
  462.    int l, x, y, c,q,s,e,d;
  463.    UBYTE *ptr;
  464.  
  465.    l = rand() % 26;
  466.    x = rand() % 41;
  467.    y = rand() % 25;
  468.    c = rand() % 251;
  469.    s = (rand() % 253)+2;
  470.    e = (rand() % 253)+2;
  471.    d = rand() % 255;
  472.  
  473.    ptr = letters[l];
  474.    for (q = 0; q < 64; q++)
  475.      {
  476.        if (*(ptr+q) != 1)
  477.          {
  478.            *(ptr+q) = c + 4;
  479.          }
  480.      }
  481.    HAME_8BitRender(HamePort, ptr, x << 3, y << 3, 8, 8);
  482.    if ((d > 32) && (d < 64))
  483.      {
  484.        HAME_CycleLeft(HamePort, s, e);
  485.      }
  486.  }
  487.  
  488.  
  489. /*
  490.   Main routine
  491. */
  492. int main(argc, argv)
  493.   int argc;
  494.   char *argv[];
  495.   {
  496.   ULONG  msg_class;
  497.   USHORT msg_code;
  498.   int    finished=0;
  499.   struct IntuiMessage *message;
  500.   struct Gadget *gadget;
  501.  
  502.  
  503.   if ((IntuitionBase = (struct IntuitionBase *)
  504.        OpenLibrary("intuition.library",33L))==NULL)
  505.     {
  506.       CloseStuff();
  507.     }
  508.  
  509.   if ((GfxBase = (struct GfxBase *)
  510.        OpenLibrary("graphics.library" , 0L))==NULL)
  511.     {
  512.       CloseStuff();
  513.     }
  514.  
  515.   /* Open the hame library */
  516.   if ((HameBase = (struct Library *) 
  517.        OpenLibrary("hame.library",HAMELIB_VERSION)) == NULL)
  518.     {
  519.       printf("No hame.library\n");
  520.       CloseStuff();
  521.     }
  522.  
  523.  
  524.   /* Get a screen to play with */
  525.   if ((screen = OpenScreen(&my_screen))     ==NULL)
  526.     {
  527.       CloseStuff();
  528.     }
  529.  
  530.   my_window.Screen = screen;
  531.  
  532.   /* Get a window to play with */
  533.   if ((window = OpenWindow(&my_window)) == NULL)
  534.     {
  535.       CloseStuff();
  536.     }
  537.  
  538.   ShowTitle( screen, 0 );
  539.   /* Tell the library where to put pixels */
  540.   if ((HamePort = HAME_Init(screen, 640, 400, 400, 0, 12, 4, 184)) == NULL)
  541.     {
  542.       CloseStuff();
  543.     }
  544.  
  545.   /* Set the pallette */
  546.   palette1();
  547.  
  548.   /* Keep hame from turning off because of screen wide color 0 */
  549.   DrawLeftMargin();
  550.  
  551.   while( !finished )
  552.     {
  553.       message = (struct IntuiMessage *) GetMsg(window->UserPort);
  554.       if (message)
  555.         {
  556.           msg_class = message->Class;
  557.           msg_code = message->Code;
  558.           gadget = (struct Gadget *) message->IAddress;
  559.           ReplyMsg((struct Message *)message);
  560.  
  561.           switch( msg_class )
  562.             {
  563.               case MOUSEBUTTONS:
  564.               break;
  565.  
  566.               case INTUITICKS:
  567.                 HAME_SetRGB8(HamePort, (rand() % 251)+4, (rand() % 253)+2,
  568.                                        (rand() % 255)+1, (rand() % 251)+4);
  569.               break;
  570.  
  571.               case CLOSEWINDOW:
  572.                 finished = 1;
  573.               break;
  574.  
  575.               default:
  576.                 printf("?");
  577.             }
  578.         }
  579.       else
  580.         {
  581.           DoLetter();
  582.         }
  583.      }
  584.  
  585.   while ((message = (struct IntuiMessage *)
  586.           GetMsg( window->UserPort )) != NULL)
  587.     {
  588.       ReplyMsg((struct Message *)message);
  589.     }
  590.  
  591.   CloseStuff();
  592. }
  593.  
  594.