home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d534 / term.lha / Term / Source.LZH / termInfo.c < prev    next >
C/C++ Source or Header  |  1991-07-06  |  7KB  |  274 lines

  1. /* $Revision Header * Header built automatically - do not edit! *************
  2.  *
  3.  *    (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
  4.  *
  5.  *    Name .....: TermInfo.c
  6.  *    Created ..: Saturday 02-Feb-91 20:02
  7.  *    Revision .: 0
  8.  *
  9.  *    Date            Author          Comment
  10.  *    =========       ========        ====================
  11.  *    02-Feb-91       Olsen           Created this file!
  12.  *
  13.  * $Revision Header ********************************************************/
  14.  
  15. #include "TermGlobal.h"
  16.  
  17.     /* We need SetWrMsk(). */
  18.  
  19. #include <graphics/gfxmacros.h>
  20.  
  21.     /* The `term' logo. */
  22.  
  23. STATIC USHORT __chip InfoBits[144] =
  24. {
  25.     0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  26.     0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  27.     0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  28.     0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  29.     0xFFFF,0x8003,0xFF00,0x03C0,0xF001,0xF0FE,0x01FE,0x0000,
  30.     0xFFFF,0x801F,0xFFC0,0x03CF,0xF001,0xF7FF,0xCFFF,0x8000,
  31.     0x07C0,0x003E,0x01F0,0x03DF,0x0001,0xFE07,0xFC0F,0xC000,
  32.     0x07C0,0x0078,0x00F0,0x03F8,0x0001,0xF803,0xF003,0xE000,
  33.     0x07C0,0x00F0,0x0078,0x03F0,0x0001,0xF001,0xF003,0xE000,
  34.     0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
  35.     0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
  36.     0x07C0,0x01F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
  37.     0x07C0,0x00F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
  38.     0x07C0,0x00F8,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
  39.     0x07C0,0x007C,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
  40.     0x03E1,0xC03F,0x80F8,0x03E0,0x0001,0xF001,0xE003,0xE000,
  41.     0x03FF,0xC00F,0xFFF0,0x03E0,0x0001,0xF001,0xE003,0xE000,
  42.     0x00FE,0x0000,0xFF00,0x03E0,0x0001,0xF001,0xE003,0xE000
  43. };
  44.  
  45.     /* A dummy image structure. */
  46.  
  47. STATIC struct Image InfoImage =
  48. {
  49.     0,0,
  50.     115,18,1,
  51.     (USHORT *)&InfoBits[0],
  52.     0x03,0x00,
  53.     (struct Image *)NULL
  54. };
  55.  
  56.     /* The real render info. */
  57.  
  58. struct BitMap InfoBitMap;
  59.  
  60.     /* The text we are about to display. */
  61.  
  62. STATIC UBYTE *InfoText[] =
  63. {
  64.     "This is `term', a GIFT-WARE Telecommunications Program written",
  65.     "especially for release 2.x of the Kickstart Operating System.",
  66.     "",
  67.     "term © Copyright 1990,91 by Olaf `Olsen' Barthel & MXM",
  68.     "All Rights Reserved",
  69.     "",
  70.     "If you like this program and use it frequently the author",
  71.     "wants you to send him a gift of any kind which you suppose",
  72.     "will do as a `payment' for `term' -- thank you!",
  73.     "",
  74.     "Send suggestions, bug reports, flames & gifts to:",
  75.     "",
  76.     "Olaf `Olsen' Barthel, MXM",
  77.     "Brabeckstrasse 35",
  78.     "D-3000 Hannover 71",
  79.     "",
  80.     "Federal Republic of Germany"
  81. };
  82.  
  83.     /* Width/height offsets for the info window. */
  84.  
  85. #define WIDTH    (2)
  86. #define HEIGHT    ((((sizeof(InfoText) >> 2) + 3) << 3) + 2)
  87.  
  88.     /* ShowInfo():
  89.      *
  90.      *    Open a window, draw the `term' logo, show some text
  91.      *    and wait for user reaction (believe it or not, this took
  92.      *    me two hours to program!).
  93.      */
  94.  
  95. VOID
  96. ShowInfo(BYTE Ticks)
  97. {
  98.     struct Window    *InfoWindow;
  99.     LONG         i,Length,MaxWidth;
  100.  
  101.         /* Find the longest string. */
  102.  
  103.     for(i = MaxWidth = 0 ; i < (sizeof(InfoText) >> 2) ; i++)
  104.     {
  105.         if((Length = strlen(InfoText[i])) > MaxWidth)
  106.             MaxWidth = Length;
  107.     }
  108.  
  109.     MaxWidth = (MaxWidth << 3) + WIDTH;
  110.  
  111.         /* Open the window. */
  112.  
  113.     if(InfoWindow = OpenWindowTags(NULL,
  114.         WA_Left,        (Screen -> Width - MaxWidth) >> 1,
  115.         WA_Top,            (Screen -> Height - (HEIGHT + InfoImage . Height + 1)) >> 1,
  116.         WA_InnerWidth,        MaxWidth,
  117.         WA_InnerHeight,        HEIGHT + InfoImage . Height,
  118.         WA_IDCMP,        IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_RAWKEY | IDCMP_INTUITICKS,
  119.         WA_ReportMouse,        TRUE,
  120.         WA_Activate,        TRUE,
  121.         WA_RMBTrap,        TRUE,
  122.         WA_SmartRefresh,    TRUE,
  123.         WA_GimmeZeroZero,    TRUE,
  124.         WA_CustomScreen,    Screen,
  125.     TAG_DONE))
  126.     {
  127.         struct RastPort        *IPort;
  128.         LONG             Left,Top;
  129.  
  130.         struct IntuiMessage    *Massage;
  131.         BYTE             Terminated = FALSE;
  132.  
  133.         BYTE             FgPen,BgPen;
  134.  
  135.         LONG             TickCount = 0;
  136.  
  137.             /* Adapt the rendering pens accordingly. */
  138.  
  139.         switch(Config . ColourMode)
  140.         {
  141.             case COLOUR_EIGHT:    FgPen = 7;
  142.                         BgPen = 4;
  143.  
  144.                         break;
  145.  
  146.             case COLOUR_SIXTEEN:    FgPen = 15;
  147.                         BgPen = 8;
  148.  
  149.                         break;
  150.  
  151.             case COLOUR_AMIGA:    BgPen = 1;
  152.                         FgPen = 2;
  153.  
  154.                         break;
  155.  
  156.             case COLOUR_MONO:    BgPen = 1;
  157.                         FgPen = 1;
  158.  
  159.                         break;
  160.         }
  161.  
  162.             /* Just a shortcut. */
  163.  
  164.         IPort = InfoWindow -> RPort;
  165.  
  166.             /* Set up rendering modes. */
  167.  
  168.         SetDrMd(IPort,JAM1);
  169.         SetFont(IPort,Topaz);
  170.  
  171.             /* Set up the logo. */
  172.  
  173.         InitBitMap(&InfoBitMap,IPort -> BitMap -> Depth,115,18);
  174.  
  175.         for(i = 0 ; i < IPort -> BitMap -> Depth ; i++)
  176.             InfoBitMap . Planes[i] = (PLANEPTR)&InfoBits[0];
  177.  
  178.         if(Config . ColourMode != COLOUR_MONO)
  179.         {
  180.                 /* Draw the logo shadow. */
  181.  
  182.             SetWrMsk(IPort,BgPen);
  183.             BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1) + 2,8 + 1,InfoImage . Width,InfoImage . Height,0xC0);
  184.  
  185.                 /* Clear out the bright part. */
  186.  
  187.             SetWrMsk(IPort,~0);
  188.             BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0x20);
  189.         }
  190.  
  191.             /* Add the bright part. */
  192.  
  193.         SetWrMsk(IPort,FgPen);
  194.         BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0xE0);
  195.  
  196.             /* Return to normal rendering. */
  197.  
  198.         SetWrMsk(IPort,~0);
  199.  
  200.             /* Determine first line. */
  201.  
  202.         Top = (InfoWindow -> GZZHeight - HEIGHT) + Topaz -> tf_Baseline - 1 + InfoImage . Height;
  203.  
  204.             /* Walk down the text list. */
  205.  
  206.         for(i = 0 ; i < (sizeof(InfoText) >> 2) ; i++)
  207.         {
  208.                 /* Can we print this line? */
  209.  
  210.             if(Length = strlen(InfoText[i]))
  211.             {
  212.                     /* Centre it. */
  213.  
  214.                 Left = (InfoWindow -> GZZWidth - (Length << 3)) >> 1;
  215.  
  216.                     /* Draw the shadow. */
  217.  
  218.                 if(Config . ColourMode != COLOUR_MONO)
  219.                 {
  220.                     SetAPen(IPort,BgPen);
  221.                     Move(IPort,Left + 2,Top + 1);
  222.                     Text(IPort,InfoText[i],Length);
  223.                 }
  224.  
  225.                     /* Draw the bright part. */
  226.  
  227.                 SetAPen(IPort,FgPen);
  228.                 Move(IPort,Left,Top);
  229.                 Text(IPort,InfoText[i],Length);
  230.             }
  231.  
  232.                 /* Jump to next line. */
  233.  
  234.             Top += Topaz -> tf_YSize;
  235.         }
  236.  
  237.             /* Ignore any previously received input. */
  238.  
  239.         while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
  240.             ReplyMsg(Massage);
  241.  
  242.         if(Ticks)
  243.             Say("Welcome to term.");
  244.  
  245.             /* Wait for mouse/key event. */
  246.  
  247.         while(!Terminated)
  248.         {
  249.             WaitPort(InfoWindow -> UserPort);
  250.  
  251.             while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
  252.             {
  253.                 if(Massage -> Class == IDCMP_INTUITICKS)
  254.                 {
  255.                     if(Ticks)
  256.                         if(TickCount++ == 50)
  257.                             Terminated = TRUE;
  258.                 }
  259.                 else
  260.                 {
  261.                     if(Massage -> Class != IDCMP_RAWKEY || !(Massage -> Code & IECODE_UP_PREFIX))
  262.                         Terminated = TRUE;
  263.                 }
  264.  
  265.                 ReplyMsg(Massage);
  266.             }
  267.         }
  268.  
  269.             /* Close the window and exit. */
  270.  
  271.         CloseWindow(InfoWindow);
  272.     }
  273. }
  274.