home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
500-599
/
ff589.lza
/
Term
/
TermSrc.lha
/
termInfo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-24
|
8KB
|
321 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1991 by Olaf 'Olsen' Barthel & MXM
*
* Name .....: TermInfo.c
* Created ..: Saturday 02-Feb-91 20:02
* Revision .: 0
*
* Date Author Comment
* ========= ======== ====================
* 02-Feb-91 Olsen Created this file!
*
* $Revision Header ********************************************************/
#include "TermGlobal.h"
/* We need SetWrMsk(). */
#include <graphics/gfxmacros.h>
/* The `term' logo. */
STATIC UWORD __chip InfoBits[144] =
{
0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0xFFFF,0x8003,0xFF00,0x03C0,0xF001,0xF0FE,0x01FE,0x0000,
0xFFFF,0x801F,0xFFC0,0x03CF,0xF001,0xF7FF,0xCFFF,0x8000,
0x07C0,0x003E,0x01F0,0x03DF,0x0001,0xFE07,0xFC0F,0xC000,
0x07C0,0x0078,0x00F0,0x03F8,0x0001,0xF803,0xF003,0xE000,
0x07C0,0x00F0,0x0078,0x03F0,0x0001,0xF001,0xF003,0xE000,
0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x07C0,0x01F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x07C0,0x00F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x07C0,0x00F8,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x07C0,0x007C,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x03E1,0xC03F,0x80F8,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x03FF,0xC00F,0xFFF0,0x03E0,0x0001,0xF001,0xE003,0xE000,
0x00FE,0x0000,0xFF00,0x03E0,0x0001,0xF001,0xE003,0xE000
};
/* A dummy image structure. */
STATIC struct Image InfoImage =
{
0,0,
115,18,1,
(UWORD *)&InfoBits[0],
0x03,0x00,
(struct Image *)NULL
};
/* The real render info. */
struct BitMap InfoBitMap;
/* The text we are about to display. */
STATIC UBYTE *InfoText[] =
{
"This is `term', a GIFT-WARE Telecommunications Program",
"written for use with AmigaOS release 2.0 or higher.",
"",
"term © Copyright 1990,91 by Olaf `Olsen' Barthel & MXM",
"All Rights Reserved",
"",
"If you like this program and use it frequently the author",
"wants you to send him a gift of any kind which you suppose",
"will do as a `payment' for `term' -- thank you!",
"",
"Send suggestions, bug reports, flames & gifts to:",
"",
"Olaf `Olsen' Barthel, MXM",
"Brabeckstrasse 35",
"D-3000 Hannover 71",
"",
"Federal Republic of Germany"
};
/* Height offset for the info window. */
#define HEIGHT ((((sizeof(InfoText) >> 2) + 3) << 3) + 2)
/* ShowInfo():
*
* Open a window, draw the `term' logo, show some text
* and wait for user reaction (believe it or not, this took
* me two hours to program!).
*/
VOID
ShowInfo(BYTE Ticks)
{
struct Window *InfoWindow;
LONG i,Length,MaxWidth,Offset = (Ticks ? 0 : 16);
/* Find the longest string. */
for(i = MaxWidth = 0 ; i < (sizeof(InfoText) >> 2) ; i++)
{
if((Length = strlen(InfoText[i])) > MaxWidth)
MaxWidth = Length;
}
MaxWidth = (MaxWidth << 3) + 10;
/* Open the window. */
if(InfoWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - MaxWidth) >> 1,
WA_Top, (Screen -> Height - (HEIGHT + InfoImage . Height + 1 + Offset)) >> 1,
WA_InnerWidth, MaxWidth,
WA_InnerHeight, HEIGHT + InfoImage . Height + Offset,
WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_INTUITICKS | IDCMP_INACTIVEWINDOW | BUTTONIDCMP,
WA_ReportMouse, TRUE,
WA_Activate, TRUE,
WA_RMBTrap, TRUE,
WA_SmartRefresh, TRUE,
WA_GimmeZeroZero, TRUE,
WA_CustomScreen, Screen,
TAG_DONE))
{
struct Gadget *GadgetList = NULL,
*Gadget = NULL;
if(Ticks)
goto Skip;
if(Gadget = CreateContext(&GadgetList))
{
struct NewGadget NewGadget;
memset(&NewGadget,0,sizeof(struct NewGadget));
NewGadget . ng_Width = 80;
NewGadget . ng_Height = 16;
NewGadget . ng_GadgetText = "_Continue";
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_VisualInfo = VisualInfo;
NewGadget . ng_GadgetID = 0;
NewGadget . ng_Flags = NULL;
NewGadget . ng_LeftEdge = (InfoWindow -> Width - NewGadget . ng_Width) >> 1;
NewGadget . ng_TopEdge = InfoWindow -> Height - (NewGadget . ng_Height + 8);
Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
Skip: if(Gadget || Ticks)
{
struct RastPort *IPort;
LONG Left,Top;
struct IntuiMessage *Massage;
BYTE Terminated = FALSE;
BYTE FgPen,BgPen;
LONG TickCount = 0;
if(Gadget)
{
AddGList(InfoWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,InfoWindow,NULL,(UWORD)-1);
GT_RefreshWindow(InfoWindow,NULL);
}
/* Adapt the rendering pens accordingly. */
switch(Config . ColourMode)
{
case COLOUR_EIGHT: FgPen = 7;
BgPen = 4;
break;
case COLOUR_SIXTEEN: FgPen = 15;
BgPen = 8;
break;
case COLOUR_AMIGA: BgPen = 1;
FgPen = 2;
break;
case COLOUR_MONO: BgPen = 1;
FgPen = 1;
break;
}
/* Just a shortcut. */
IPort = InfoWindow -> RPort;
/* Set up rendering modes. */
SetDrMd(IPort,JAM1);
SetFont(IPort,Topaz);
/* Set up the logo. */
InitBitMap(&InfoBitMap,IPort -> BitMap -> Depth,115,18);
for(i = 0 ; i < IPort -> BitMap -> Depth ; i++)
InfoBitMap . Planes[i] = (PLANEPTR)&InfoBits[0];
if(Config . ColourMode != COLOUR_MONO)
{
/* Draw the logo shadow. */
SetWrMsk(IPort,BgPen);
BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1) + 2,8 + 1,InfoImage . Width,InfoImage . Height,0xC0);
/* Clear out the bright part. */
SetWrMsk(IPort,~0);
BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0x20);
}
/* Add the bright part. */
SetWrMsk(IPort,FgPen);
BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0xE0);
/* Return to normal rendering. */
SetWrMsk(IPort,~0);
/* Determine first line. */
Top = (InfoWindow -> GZZHeight - HEIGHT - Offset) + Topaz -> tf_Baseline - 1 + InfoImage . Height;
/* Walk down the text list. */
for(i = 0 ; i < (sizeof(InfoText) >> 2) ; i++)
{
/* Can we print this line? */
if(Length = strlen(InfoText[i]))
{
/* Centre it. */
Left = (InfoWindow -> GZZWidth - (Length << 3)) >> 1;
/* Draw the shadow. */
if(Config . ColourMode != COLOUR_MONO)
{
SetAPen(IPort,BgPen);
Move(IPort,Left + 2,Top + 1);
Text(IPort,InfoText[i],Length);
}
/* Draw the bright part. */
SetAPen(IPort,FgPen);
Move(IPort,Left,Top);
Text(IPort,InfoText[i],Length);
}
/* Jump to next line. */
Top += Topaz -> tf_YSize;
}
/* Ignore any previously received input. */
while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
ReplyMsg(Massage);
if(Ticks)
Say("Welcome to term.");
ActivateWindow(InfoWindow);
/* Wait for mouse/key event. */
while(!Terminated)
{
WaitPort(InfoWindow -> UserPort);
while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
{
if(Ticks)
{
if(Massage -> Class == IDCMP_INTUITICKS)
{
if(TickCount++ == 50)
Terminated = TRUE;
}
else
Terminated = TRUE;
}
else
{
if((Massage -> Class == IDCMP_VANILLAKEY && ToUpper(Massage -> Code) == 'C') || Massage -> Class == IDCMP_GADGETUP)
Terminated = TRUE;
}
ReplyMsg(Massage);
}
}
if(Gadget)
RemoveGList(InfoWindow,GadgetList,(UWORD)-1);
}
}
FreeGadgets(GadgetList);
/* Close the window and exit. */
CloseWindow(InfoWindow);
}
}