/* Include-File zu TaskMon V0.4 */

/* alles Notwendige wird mit eingebunden (types.h etc.) */

#include <intuition/intuition.h>
#include <graphics/gfxbase.h>
#include <exec/execbase.h>
#include <exec/tasks.h>
#include <exec/memory.h>
#include <functions.h>

/* Nun meine Definitionen */
/* zuerst Allgemeines: */

#define WIDTH  580L  /* Fenstergröße */
#define HEIGHT 240L

#define VBLANK (1<<0)  /* Flagbits für Entscheidungen über */
#define LIST   (1<<1)  /* den Programmverlauf  */


/**  Gadget-Stuff  **/

 /* GadgetID`s */

#define RUNGAD    1
#define READYGAD  2
#define WAITGAD   3
#define LISTGAD   4
#define PREVGAD   5
#define NEXTGAD   6 
#define WINDOWGAD 7

#define MAXGADS    7                       /*Maximale Anzahl von Gadgets */
#define GADFLAGS   GADGHCOMP|SELECTED      /* Gadgetflags */
#define ACTIVFLAGS GADGIMMEDIATE|RELVERIFY /* Activationflags */

/* Gadget- u.a. Strukturen */

struct TextAttr font =       /* Damit der Bildaufbau     */
{                            /* auch bei anderen Fonts   */
 (UBYTE *)"topaz.font",      /* funktioniert, hier meine */
 TOPAZ_EIGHTY,               /* eigene Fontdefinition.   */
 FS_NORMAL,
 FPF_ROMFONT
};

SHORT bordervector[10] =      /* Border-Definition */
{                             /* für alle Gadgets  */
 0,0,53,0,53,11,0,11,0,1      /* = 6 Zeichen max.  */
};

struct Border border =        /* für alle das Gleiche */
{
 -3,-2,1,0,JAM1,5,
 (SHORT *)&bordervector,
 NULL
};

struct IntuiText itext =  /* IntuitionText-Def. für */
{                         /* alle G`s gleich */
 3,2,
 JAM1,1,1,
 &font,
 NULL, /* Zeiger auf Text wird bei Programmstart initialisiert */
 NULL
};

struct Gadget gadget =  /* "Mutter"-Gadget für die anderen */
{
 NULL,       /* NextGadget, wird später initalisiert */
 25,15,      /* Left wird auch später initialisiert */
 49,9,       /* Width, Height sind immer gleich ! (s.o.) */
 GADFLAGS,   /* Flags */
 ACTIVFLAGS, /* Activation */
 BOOLGADGET,
 (APTR)&border,NULL,
 NULL,       /* Itextpointer */
 0,NULL,
 0,          /* GadgetID */
 NULL
};

char *gadnames[] =
{
 "RUN   ",
 "READY ",
 "WAIT  ",
 "LIST  ",
 "PREV  ",
 "NEXT  ",
 "WINDOW",
};

/* Zeiger auf die zu erzeugenden Gadgets etc. */

struct IntuiText *itexts[MAXGADS];
struct Gadget    *gadgets[MAXGADS];

/* meine Fensterdefinition */

struct NewWindow newwindow =
{
 10,10,WIDTH,HEIGHT,
 0,1,
 GADGETDOWN|CLOSEWINDOW|ACTIVEWINDOW|INACTIVEWINDOW|MOUSEMOVE,
 ACTIVATE|NOCAREREFRESH|WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|REPORTMOUSE,
 NULL,  /* Gadget-Zeiger */
 NULL,
 (UBYTE *)"TaskMon V0.4 - (c) 1988 by P.Erpenbeck",
 NULL,NULL,0,0,0,0,
 WBENCHSCREEN
};

struct IntuitionBase *IntuitionBase = NULL; /* klar ??!! */
struct GfxBase       *GfxBase = NULL;

struct Window   *window = NULL;    /* Zeiger auf mein Window     */
struct RastPort *wrp;             /*   "    auf Window-RastPort */
struct Remember RememberKey =    /* Speicherverwaltung mit AllocRemember() */
{
 NULL,NULL,NULL
};

extern struct WBStartup *WBenchMsg = NULL;

/**  Task-Stuff  **/

struct ExecBase *SysBase;

static char *states[] =
  {
   "invalid","added","running","ready",
   "waiting","execption","removed"
 };

#ifndef MAXTASKS       /* beim Compilieren kann auch eine */
                       /* andere Zahl angegeben werden.   */
  #define MAXTASKS 25  /* reine Willkür */

#endif

/* Zeiger auf einzelne Tasks */

struct Task *run;
struct Task *wtasks[MAXTASKS];
struct Task *rtasks[MAXTASKS];

UBYTE old_pri;   /* Speicher um die alte Priorität */
                 /* wiederhestellen zu können.     */

/* für das timer.device */

#define WAIT_TIME 2

static struct timerequest  Time_Req ;
static struct Message      *Msg;
static struct MsgPort      *timer_port = NULL;

/* END */
