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 >
Wrap
C/C++ Source or Header
|
1991-07-06
|
7KB
|
274 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1990 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 USHORT __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,
(USHORT *)&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",
"especially for release 2.x of the Kickstart Operating System.",
"",
"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"
};
/* Width/height offsets for the info window. */
#define WIDTH (2)
#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;
/* Find the longest string. */
for(i = MaxWidth = 0 ; i < (sizeof(InfoText) >> 2) ; i++)
{
if((Length = strlen(InfoText[i])) > MaxWidth)
MaxWidth = Length;
}
MaxWidth = (MaxWidth << 3) + WIDTH;
/* Open the window. */
if(InfoWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - MaxWidth) >> 1,
WA_Top, (Screen -> Height - (HEIGHT + InfoImage . Height + 1)) >> 1,
WA_InnerWidth, MaxWidth,
WA_InnerHeight, HEIGHT + InfoImage . Height,
WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_RAWKEY | IDCMP_INTUITICKS,
WA_ReportMouse, TRUE,
WA_Activate, TRUE,
WA_RMBTrap, TRUE,
WA_SmartRefresh, TRUE,
WA_GimmeZeroZero, TRUE,
WA_CustomScreen, Screen,
TAG_DONE))
{
struct RastPort *IPort;
LONG Left,Top;
struct IntuiMessage *Massage;
BYTE Terminated = FALSE;
BYTE FgPen,BgPen;
LONG TickCount = 0;
/* 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) + 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.");
/* Wait for mouse/key event. */
while(!Terminated)
{
WaitPort(InfoWindow -> UserPort);
while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
{
if(Massage -> Class == IDCMP_INTUITICKS)
{
if(Ticks)
if(TickCount++ == 50)
Terminated = TRUE;
}
else
{
if(Massage -> Class != IDCMP_RAWKEY || !(Massage -> Code & IECODE_UP_PREFIX))
Terminated = TRUE;
}
ReplyMsg(Massage);
}
}
/* Close the window and exit. */
CloseWindow(InfoWindow);
}
}