MAG Disk (Jul 1991) : MadBlanker / MadBlanker.c

/**************************************************************************/
/*                                                                        */
/*  MadBlanker version v2.0           (Y.A.U.P.)                          */
/*                                   (Yet Another Useless Program)        */
/*                                                                        */
/*  A screen blanker that opens a bouncing window on a blank screen       */
/*  through which you can see the screen behind.                          */
/*                                                                        */
/*    Written by a Paranoid FOR Paranoids.                                */
/*                                                                        */
/*  The source, executable, and document are completely public domain.    */
/*                                                                        */
/*  As always, feel free to improve the program... it could have been     */
/*  a little more original than a bouncing box! I'm just too lazy :-)     */
/*                (a bouncing ball maybe ? ;-)                            */
/*                                                                        */
/*      Enjoy,                                                            */
/*                                                                        */
/*         Khaled Mardam-Bey                                              */
/*                                                                        */
/*                                                                        */
/*    Compiled with ManxC 3.6a                                            */
/*                                                                        */
/**************************************************************************/

#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/diskfont.h>
#include <devices/timer.h>
#include <devices/trackdisk.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <exec/lists.h>
#include <exec/libraries.h>
#include <exec/io.h>
#include <exec/execbase.h>
#include <exec/types.h>
#include <exec/devices.h>
#include <exec/memory.h>
#include <exec/exec.h>
#include <exec/ports.h>
#include <exec/tasks.h>
#include <exec/types.h>
#include <exec/interrupts.h>
#include <exec/memory.h>
#include <exec/ports.h>
#include <functions.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/rastport.h>
#include <graphics/view.h>
#include <graphics/copper.h>
#include <graphics/gels.h>
#include <graphics/regions.h>
#include <graphics/clip.h>
#include <graphics/text.h>
#include <hardware/dmabits.h>
#include <hardware/custom.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>

#define LAMIGA      0x66
#define QUITSKEY    0x3A

#define BLANKON     0x1
#define WINNY       0x2
#define CHANGEPRI   0x4
#define QUIT        0x8

char PortName[]    = "MaDbLAnk";
char defPortName[] = "MadBlaNKeR";
char writtenby[]   = " MadBlanker v2.0 by K.Mardam-Bey 1st November 1990\n\n";

struct IntuitionBase *IntuitionBase   = NULL;
struct GfxBase       *GfxBase         = NULL;
struct MsgPort       *inputPort       = NULL;
struct IOStdReq      *inputReq        = NULL;
struct Screen        *s2, *wbs, *s    = NULL;
struct Window        *w = NULL, *w2   = NULL;
struct ViewPort      *vp = NULL, *vp2 = NULL;
struct ColorMap      *cm              = NULL;
struct UCopList      *cl              = NULL;
struct TextAttr      attr             = NULL;
struct TextFont      *newfont         = NULL;
struct IntuiMessage *message          = NULL;
struct BitMap        b2;
struct RastPort      rp, rp2;
struct Preferences   MyCopy;

struct NewScreen newscreen = {
  0,0,0,0,0,0,0,NULL,CUSTOMSCREEN,NULL,(UBYTE *)"MadBlankerScreen",NULL,NULL
};

struct NewWindow newwindow = {
  0,0,0,0,3,2,  NULL,NULL,  NULL,NULL,  NULL,
  NULL,  NULL,  0,0,0,0, WBENCHSCREEN
};

struct NewWindow newwindow2 = {
5,5,10,10,0,0,
MOUSEBUTTONS | MOUSEMOVE | RAWKEY,
REPORTMOUSE | NOCAREREFRESH | ACTIVATE | BORDERLESS | BACKDROP,
NULL,NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN
};

UWORD colours;
USHORT WB = 0x11;
USHORT bitplanes, bg = 0;
USHORT PointerData[POINTERSIZE];

int same, ham = 0, cleared = 0;
short f, n, n2, n3, r, wt = 0, showstatus = 0;
short s2depth, myc = 0, ht = 0, black = 0, event, lpri;
short waiting = 0, blank = 0, i = 0, k = 0, j = 0, c = 0;
short lamiga = 0, bk = 0;
long lsec = 0, micro = 0, cols, class, signum = -1, cw;

struct InputEvent phoney;
struct HotInfo
{
  struct Task *hotTask;
  long  hotSig;
} hotStuff;

struct Interrupt handlerStuff;
struct defPort
{
  struct MsgPort mp;
  short quit;
  short wait;
  short now;
  short rgb;
  short windo;
  short grow;
  short pri;
  short bench;
  short delay;
  short scroll;
  short x,y;
  struct Window *win;
};

struct defPort *dPtr;

void HandlerInterface()
{
#asm
  movem.l a4,-(sp)
  jsr _geta4#
  movem.l   A0/A1,-(sp)
  jsr       _myhandler
  addq.l    #8,A7
  movem.l (sp)+,a4
#endasm
}

struct InputEvent *myhandler(ev1, hotStuff)
struct InputEvent *ev1;
struct HotInfo *hotStuff;
{
  struct InputEvent *ev, *last;
  short removeit;
  short evcode;

  event = 0;

  for (ev=ev1,last = NULL; ev; ev=ev->ie_NextEvent)
  {
    evcode = ev->ie_Code;
    removeit = 0;

    if ((ev->ie_Class == IECLASS_RAWKEY) || (ev->ie_Class == IECLASS_RAWMOUSE)) {
      waiting = 0;

      if (evcode == (LAMIGA | 0x80)) lamiga = 0;
      else
      if (evcode == LAMIGA) lamiga = 1;
      else
      if ((evcode == QUITSKEY) && (lamiga)) {
        removeit = 1;
        bk = 1;
        event |= QUIT;
      }
    }
    else
    if ((ev->ie_Class == IECLASS_TIMER))
    {
      if (lpri != dPtr->pri) event |= CHANGEPRI;

      if (dPtr->quit) { dPtr->quit = 0; event |= QUIT; }

      if ((dPtr->now) && (!blank)) {
        dPtr->now = 0;
        blank = 1;
        event |= BLANKON;
      }

      if ((waiting >= dPtr->wait) && (!blank)) {
        blank = 1;
        event |= BLANKON;
      }

      if ((ev->ie_TimeStamp.tv_secs != lsec) && (ev->ie_TimeStamp.tv_micro >= 500000)) {
        lsec = ev->ie_TimeStamp.tv_secs;

        if (dPtr->win != NULL) {
          wt += 1;
          if (wt >= 3) { wt = 0; event |= WINNY; }
        }

        waiting = waiting + 1;
      }
    }

    if (removeit)
      if (last == NULL)
        ev1 = ev->ie_NextEvent;
      else
        last->ie_NextEvent = ev->ie_NextEvent;
    else
      last = ev;
    }

  if (event)
    Signal(hotStuff->hotTask,hotStuff->hotSig);
  return(ev1);
}

main(argc,argv)
int argc;
char *argv[];
{
  IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  if (!IntuitionBase) Eggzit("[IntuitionBase Hiding]",0);

  GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0L);
  if (!GfxBase) Eggzit("[GfxBase Hiding]",0);

  GetPointer();

  dPtr = (struct defPort *) FindPort(defPortName);

  if (dPtr) {
    if (argc < 2) {
      dPtr->quit = 1;
      if (!dPtr->windo) printf("MadBlanker Removed\n");
      Eggzit(NULL,1);
    }

    DoParms(argc,argv);

    if (showstatus) { MadStatus(); printf("%s",writtenby); }
    else DisplayInfo("MadBlanker Informed",0);

    Eggzit(NULL,1);
  }

  if (dPtr == NULL)
  {
    if ((dPtr = (struct defPort *) AllocMem((long)sizeof(struct defPort),MEMF_PUBLIC | MEMF_CLEAR)) == NULL)
      Eggzit("[Couldn't Allocate Memory]",0);

    dPtr->quit = 0;
    dPtr->now = 0;
    dPtr->wait = 180;
    dPtr->rgb = 0;
    dPtr->windo = 1;
    dPtr->grow = 1;
    dPtr->win = NULL;
    dPtr->bench = 0;
    dPtr->pri = 0;
    dPtr->delay = 0;
    dPtr->scroll = 0;
    dPtr->x = 60;
    dPtr->y = 50;

    if (argc > 0) {
      DoParms(argc,argv);

      if (showstatus) {
        MadStatus();
        if (argc <= 2) {
          printf(" MadBlanker NOT Installed\n\n%s",writtenby);
          Eggzit(NULL,0);
        }
        printf(" Attempting to Install MadBlanker...\n\n%s",writtenby);
      }
    }
  }
  else {
    DisplayInfo("MadBlanker Informed",0);
    Eggzit(NULL,1);
  }

  dPtr->mp.mp_Node.ln_Pri = 0;
  dPtr->mp.mp_Node.ln_Type = NT_MSGPORT;
  NewList(&(dPtr->mp.mp_MsgList));
  dPtr->mp.mp_Node.ln_Name = (char *) &(defPortName);

  AddPort(dPtr);

  lpri = dPtr->pri;

  if((signum = AllocSignal((long)-1)) == -1)
    Eggzit("[Couldn't Allocate Signal]",0);

  hotStuff.hotSig = 1 << signum;
  hotStuff.hotTask = FindTask(NULL);

  if(!(inputPort = CreatePort(PortName,0)))
    Eggzit("[Couldn't CreatePort]",0);

  if(!(inputReq = CreateStdIO(inputPort)))
    Eggzit("[Couldn't CreateStdIO]",0);

  handlerStuff.is_Data = (APTR)&hotStuff;
  handlerStuff.is_Code = HandlerInterface;
  handlerStuff.is_Node.ln_Pri = 57;
  handlerStuff.is_Node.ln_Name = "MAdBlnkHan";

  if(OpenDevice("input.device",0L,inputReq,0L) != 0)
    Eggzit("[Couldn't OpenDevice]",0);

  inputReq->io_Command = IND_ADDHANDLER;
  inputReq->io_Data = (APTR)&handlerStuff;

  DoIO(inputReq);

  (void)SetTaskPri(FindTask(NULL),(long)dPtr->pri);

  DisplayInfo("MadBlanker v2.0 Installed",0);
  printf("Type Left-Amiga-/ To EXIT\n");

  for (;;)
  {
    Wait(hotStuff.hotSig);

    if (event & CHANGEPRI) {
      lpri = dPtr->pri;
      (void)SetTaskPri(FindTask(NULL),(long)dPtr->pri);
    }

    if (event & WINNY)
      CloseWin();

    if (event & BLANKON) {
      if (BlankOn()) {
        OhBabyUScrollMeAround();
        BlankOff();
      }
    }

    if (event & QUIT)
      Eggzit("MadBlanker Removed",0);
  }
}

CloseWin()
{
  if (dPtr->win) CloseWindow(dPtr->win);
  dPtr->win = NULL;
}

BlankOn()
{
  blank = 1;
  waiting = 0;

  if (s) Eggzit("Error! Screen Exists! Quitting...",0);

  if (!dPtr->bench)
    s2 = IntuitionBase->FirstScreen;
  else {
    s = IntuitionBase->FirstScreen;
    do {
      if (s->Flags == WB) goto foundit;
      s = s->NextScreen;
    } while (s);
    s = NULL;

  foundit:
    if (s == NULL)
      s2 = IntuitionBase->FirstScreen;
    else s2 = s;
  }

  vp2 = &s2->ViewPort;
  cm = vp2->ColorMap;
  s2depth = s2->BitMap.Depth;

  Randomize();

  GetPointer();

  newscreen.LeftEdge = s2->LeftEdge;
  newscreen.TopEdge = s2->TopEdge;
  newscreen.Width = s2->Width;
  newscreen.Height = s2->Height;
  newscreen.DetailPen = s2->DetailPen;
  newscreen.BlockPen = s2->BlockPen;
  newscreen.Depth = s2depth;
  newscreen.ViewModes = vp2->Modes;

  if (newscreen.Width > 640) newscreen.Width = 640;
  if (newscreen.Height > 400) newscreen.Height = 400;

  n2 = dPtr->rgb;

  if (s2depth >= 4) dPtr->rgb = 1;

  bitplanes = s2depth;
  for (cols = 1; bitplanes; bitplanes--)
    cols *= 2;

  same = black = ham = 0;

  if (newscreen.ViewModes & DUALPF) { blank = 0; return(0); }
  if (newscreen.Depth == 6) ham = 1;

  if (ham || dPtr->rgb) { dPtr->rgb = 1; black = 0; }
  else {
    for (j=0;j<cols;j++) {
      colours = GetRGB4(cm,j);
      if (colours == (short)0) {
        black = j;
        same = 1;
        j = cols + 1;
      }
    }

    if (same == 0) {
      same = 5;
      ht = 4000;
      for (j=1;j<cols;j++) {
        colours = GetRGB4(cm,j);
        if (ht >= colours) { ht = colours; black = j; }
      }
    }
  }

  for (i=0; i<POINTERSIZE; i++)
    MyCopy.PointerMatrix[i] = NULL;
  SetPrefs(&MyCopy, (long) sizeof(MyCopy));

  cleared = 1;

  if ((s = (struct Screen *)OpenScreen(&newscreen)) == NULL)
    Eggzit("[Couldn't Open Screen]",0);

  ShowTitle(s,0L);

  vp = &s->ViewPort;
  rp = s->RastPort;

  newwindow2.Screen = s;

  if ((w2 = (struct Window *) OpenWindow(&newwindow2)) == NULL)
    { Eggzit("[Couldn't Open Screen Window]\n"); return(0); }

  if (!dPtr->rgb) {
    SetRGB4(vp,0L,0L,0L,0L);
    SetRast(&rp,0L);
  }

  for (j=(1-dPtr->rgb); j<cols; j++) {
    colours = GetRGB4(cm,j);
    SetRGB4( vp, j, (LONG) ( ( colours >> 8) & 15 ),
       (LONG) ( ( colours >> 4) & 15 ), (LONG) ( colours & 15 ) );
  }

  if (!dPtr->rgb) {
    SetRGB4(vp,black,0L,0L,0L);
    SetRast(&rp,black);
  }

  if (dPtr->rgb) {
    black = 0;
    SetRast(&rp,black);
  }
  else {
    if (same == 5) {
      SetRGB4(vp,black,0L,0L,0L);
      SetRast(&rp,black);
    }
  }

  myc = 1;
  ht = 0;

  for (j=0;j<cols;j++) {
    colours = GetRGB4(cm,j);
    if (ht < colours) { ht = colours; myc = j; }
  }

  b2 = s2->BitMap;

  SetAPen(&rp,black);
  SetBPen(&rp,black);
  SetOPen(&rp,black);

  if (!dPtr->rgb) {
    cl = AllocMem(sizeof(struct UCopList),MEMF_PUBLIC|MEMF_CLEAR);
    bg = (USHORT)GetRGB4(cm,0);

    CINIT(cl,4L);
    for (f = 0; f < 200; f++) {

      if (s->BitMap.Depth == 1) cw = 64;
      else if (s->BitMap.Depth == 2) cw = 64;
      else if (s->BitMap.Depth == 3) cw = 62;
      else cw = 64;

      CWAIT(cl,(LONG)(f),(long)cw);
      CMOVE(cl,custom.color[0],(USHORT)bg);

      if (s->BitMap.Depth == 1) cw = 223;
      else if (s->BitMap.Depth == 2) cw = 223;
      else if (s->BitMap.Depth == 3) cw = 223;
      else cw = 223;

      CWAIT(cl,(LONG)(f),(long)cw);
      CMOVE(cl,custom.color[0],(USHORT)0);
    }
    CEND(cl);

    vp->UCopIns = cl;
    RethinkDisplay();
  }

  while (message = (struct IntuiMessage *)GetMsg(w2->UserPort)) {
    class = message->Class;
    ReplyMsg(message);
  }

  dPtr->rgb = n2;

  return(1);
}

/*  Used By the Next TWO functions */

 short widt,higt,xinc,yinc,xs,ys,step,xx,yy,xb,yb;
 short swidth,sheight,xbs,ybs,nstep,tb;
 short tope,lefte,twidth,theight;
 short tt,t;
 short xbor,ybor;

OhBabyUScrollMeAround()
{
  if (dPtr->win) CloseWindow(dPtr->win);
  dPtr->win = NULL;

  xinc = yinc = xs = ys = step = 1;
  nstep = 1;
  xbs = ybs = nstep;
  xbor = 12;
  ybor = 6;

  tt = t = tb = 1;

  swidth = s->Width;
  sheight = s->Height;

  if (swidth > 640) swidth = 640;
  if (sheight > 400) sheight = 400;

  xx = RangeRand(swidth/3) + 5;
  yy = RangeRand(sheight/3) + 5;

  if (!dPtr->grow) {
    if (dPtr->x > (swidth-xbor)) {
      widt = swidth - xbor - xbor;
      xx = xbor;
    }
    else widt = dPtr->x;
    if (dPtr->y > (sheight-ybor)) {
      higt = sheight - ybor - ybor;
      yy = ybor;
    }
    else higt = dPtr->y;
  }
  else {
    widt = RangeRand(swidth/3) + 70;
    higt = RangeRand(sheight/3) + 20;
  }

  xb = swidth / 3;
  yb = sheight / 3;

  lefte = xx;
  tope = yy;
  twidth = widt;
  theight = higt;

  Calculator();

  SetAPen(&rp, black);

      do {

        for (i = 2; i > 0; i--) {
          Move(&rp,lefte - i, tope - i);
          Draw(&rp,lefte + twidth + i, tope - i);
          Draw(&rp,lefte + twidth + i, tope + theight + i);
          Draw(&rp,lefte - i, tope + theight + i);
          Draw(&rp,lefte - i, tope - i);
        }

        if (!CheckS2()) goto stop;
        BltBitMapRastPort(&b2,xb,yb,&rp,lefte,tope,twidth+1,theight+1,0x0C0);

        Calculator();

        if (dPtr->delay) for (i = 0; i < dPtr->delay; i++);

      } while (!CheckWindow());

stop:
  Randomize();
}

/* Lets do some finite math... */

Calculator()
{
        if (dPtr->grow) {

          t += 1;
          if (t > 2) {
            t = 0;
            widt += xinc;
          }
skip1:
          if (widt > (swidth / 2)) { xinc = -step; }
          if (widt < (swidth / 9)) { xinc = step; }

          tt += 1;
          if (tt > 5) {
            tt = 0;

            higt += yinc;
skip2:
            if (higt > (sheight / 2)) { yinc = -step; }
            if (higt < (sheight / 9)) { yinc = step; }
          }
        }

        xx = xx + xs;
        if (xx >= (swidth-widt-xbor)) { xx = swidth-widt-xbor; xs = -step; }
        if (xx < xbor) { xx = xbor; xs = step; }

        yy = yy + ys;
        if (yy >= sheight-higt-ybor) { yy = sheight-higt-ybor; ys = -step; }
        if (yy < ybor) { yy = ybor; ys = step; }

        lefte = xx;
        tope = yy;
        twidth = widt;
        theight = higt;

        if (dPtr->scroll) {
          tb += 1;

          if (tb > 2) {
            xb = xb + xbs;
            if (xb > (swidth-widt-xbor)) { xb = swidth-widt-xbor - 1; xbs = -nstep; }
            if (xb < xbor) { xb = xbor + 1; xbs = nstep; }
          }

          if (tb > 3) {
            yb = yb + ybs;
            if (yb > sheight-higt-ybor) { yb = sheight-higt-ybor - 1; ybs = -nstep; }
            if (yb < ybor) { yb = ybor + 1; ybs = nstep; }
            tb = 0;
          }
        }
        else {
          xb = lefte;
          yb = tope;
        }
}

BlankOff()
{
  if (s) ScreenToBack(s);

  ResetPointer();

  blank = 0;
  waiting = 0;

  if (w2) {
    CheckWindow();
    CloseWindow(w2);
    w2 = NULL;
  }

  if (s) {
    CloseScreen(s);
    s = NULL;
  }
}

/* Cute routine to open one line window and display info */

DisplayInfo(text,del)
char *text;
int del;
{
  if (strlen(text) < 1) return;

  if (!dPtr->windo) {
    printf("%s\n",text);
    return;
  }

  if (dPtr->win) CloseWindow(dPtr->win);

  attr.ta_Name = (UBYTE *)"topaz.font";
  attr.ta_YSize = 8;
  attr.ta_Style = 0;
  attr.ta_Flags = 0;

  wbs = IntuitionBase->ActiveScreen;

  newfont = (struct TextFont *)OpenFont(&attr);
  if (newfont == NULL) { printf("[Couldn't Get Font]\n"); return(0); }

  newwindow.LeftEdge = (wbs->Width / 2) - ((strlen(text) * 8) / 2) - 15;
  newwindow.TopEdge = 25;
  newwindow.Width = (strlen(text) * 8) + 9;
  newwindow.Height = 11;
  newwindow.Screen = wbs;
  newwindow.Type = WBENCHSCREEN;

  if ((w = (struct Window *) OpenWindow(&newwindow)) == NULL)
    { printf("[Couldn't Open Window]\n"); return(0); }

  SetFont(w->RPort,newfont);

  SetDrMd(w->RPort,JAM1);
  SetAPen(w->RPort,1);
  SetRast(w->RPort,2);
  Move(w->RPort,5,8);
  Text(w->RPort,text,strlen(text));

  CloseFont(newfont);

  if (del != 0) Delay(50L*del);

  if (del != 0) { CloseWindow(w); dPtr->win = NULL; }
  else dPtr->win = w;
  wt = 0;
}

CheckWindow()
{
  class = 0;

  while (message = (struct IntuiMessage *)GetMsg(w2->UserPort)) {
    class = message->Class;
    ReplyMsg(message);
  }

  if (class != 0) return(1);

  return(0);
}

CheckS2()
{
  struct Screen *ss;

  ss = IntuitionBase->FirstScreen;

  while (ss) {
    if (s2 == ss) return(1);
    ss = ss->NextScreen;
  }
  return(0);
}

Randomize()
{
  long seconds,microseconds;

  CurrentTime(&seconds,&microseconds);
  srand((unsigned int)(microseconds));
}

DoParms(argc, argv)
int argc;
char *argv[];
{
  showstatus = 0;

  for (i = 1; i < argc; i++) {
    if (((argv[i][0] & 0x5f) == 'H') || (argv[i][0] == '?'))
      showstatus = 1;
    else
    if ((argv[i][0] & 0x5f) == 'W') dPtr->windo = !dPtr->windo;
    else
    if ((argv[i][0] & 0x5f) == 'B') dPtr->bench = !dPtr->bench;
    else
    if ((argv[i][0] & 0x5f) == 'G') dPtr->grow = !dPtr->grow;
    else
    if ((argv[i][0] & 0x5f) == 'S') dPtr->scroll = !dPtr->scroll;
    else
    if ((argv[i][0] & 0x5f)  == 'D') {
      k = dPtr->delay;
      dPtr->delay = atoi(&argv[i][1]);
      if ((dPtr->delay < 0) || (dPtr->delay > 500000)) dPtr->delay = k;
    }
    else
    if ((argv[i][0] & 0x5f)  == 'P') {
      k = dPtr->pri;
      dPtr->pri = atoi(&argv[i][1]);
      if ((dPtr->pri < -3) || (dPtr->pri > 20)) dPtr->pri = k;
    }
    else
    if ((argv[i][0] & 0x5f)  == 'X') {
      k = dPtr->x;
      dPtr->x = atoi(&argv[i][1]);
      if ((dPtr->x < 5) || (dPtr->x > 900)) dPtr->x = k;
    }
    else
    if ((argv[i][0] & 0x5f)  == 'Y') {
      k = dPtr->y;
      dPtr->y = atoi(&argv[i][1]);
      if ((dPtr->y < 5) || (dPtr->y > 900)) dPtr->y = k;
    }
    else
    if ((argv[i][0] & 0x5f) == 'O') dPtr->now = 1;
    else
    if ((argv[i][0] & 0x5f) == 'R') dPtr->rgb = !dPtr->rgb;
    else {
      k = dPtr->wait;
      dPtr->wait = atoi(&argv[i][0]);
      if ((dPtr->wait < 5) || (dPtr->wait > 3600)) dPtr->wait = k;
    }
  }
}

MadStatus()
{
  printf("\n\
 Command Line Parameters                 Current Values\n\n\
  #  -  wait # seconds before blanking        [%d]\n\
 p#  -  Set task priority to #                [%d]\n\
 x#  -  Width of window                       [%d]\n\
 y#  -  Height of window                      [%d]\n\
 d#  -  Delay (in thousands)                  [%d]\n",
 dPtr->wait,dPtr->pri,dPtr->x,dPtr->y,dPtr->delay);

  printf("\n\
  s  -  Scroll inside the square              [%s]\n\
  g  -  Box changes sizes as it scrolls       [%s]\n\
  b  -  Use WorkBench screen as background    [%s]\n",
 dPtr->scroll ? (UBYTE *)"Yes" : (UBYTE *)"No",
 dPtr->grow ? (UBYTE *)"Yes" : (UBYTE *)"No",
 dPtr->bench ? (UBYTE *)"Yes" : (UBYTE *)"No");

  printf("\
  r  -  Use original screen colors only       [%s]\n\
  w  -  Open the small information window     [%s]\n\
 on  -  Blank screen immediately\n\n",
 dPtr->rgb ? (UBYTE *)"Yes" : (UBYTE *) "No",
 dPtr->windo ? (UBYTE *)"Yes" : (UBYTE *)"No");
}

GetPointer()
{
  GetPrefs(&MyCopy,(long)sizeof(MyCopy));
  for (i=0; i<POINTERSIZE; i++)
    PointerData[i] = MyCopy.PointerMatrix[i];
}

ResetPointer()
{
  if (!cleared) return;

  for (i=0; i<POINTERSIZE; i++)
    MyCopy.PointerMatrix[i] = PointerData[i];
  SetPrefs(&MyCopy,(long)sizeof(MyCopy));

  cleared = 0;
}

Eggzit(text,updating)
char *text;
int updating;
{
  ResetPointer();

  if (s) ScreenToBack(s);

  if (!updating)
    {
    if (inputReq)
    {
      inputReq->io_Command = IND_REMHANDLER;
      inputReq->io_Data = (APTR)&handlerStuff;
      DoIO(inputReq);

      CloseDevice(inputReq);
      DeleteStdIO(inputReq);
    }

    if (inputPort)    DeletePort(inputPort);
    if (signum > -1)  FreeSignal(signum);

    if (dPtr->win) CloseWindow(dPtr->win);
    dPtr->win = NULL;

    if (dPtr)
    {
      if (dPtr->mp.mp_Node.ln_Name)
        RemPort(dPtr);
      FreeMem(dPtr,(long)sizeof(struct defPort));
    }
  }

  if (bk) DisplayBeep(NULL);
  else if ((text) && (!updating)) DisplayInfo(text,2);

  if (w2)
    CloseWindow(w2);
  if (s)
    CloseScreen(s);
  if (GfxBase)
    CloseLibrary(GfxBase);
  if (IntuitionBase)
    CloseLibrary(IntuitionBase);

  (void)SetTaskPri(FindTask(NULL),0L);

  exit(0L);
}