home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
new
/
amigalibdisks
/
d991
/
aswarmii
/
source
/
aswarm.c
next >
Wrap
C/C++ Source or Header
|
1994-04-04
|
60KB
|
2,179 lines
/*
ASwarm II V2.0 - The Original One
Written by Markus "Ill" Illenseer markus@Techfak.Uni-Bielefeld.de
and Matthias "Tron" Scheler tron@uni-paderborn.de
Based upon Jeff Buterworths XSwarm.
Now released as MUI Application.
Please leave this source intact. ASwarm is freely distributable,
but no longer 'Public Domain'. If you have suggestions or Bug-Reports,
please contact us.
Read the Manuals for known Bugs and Contact-Adresses.
*/
#include <hardware/cia.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/execbase.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <intuition/intuitionbase.h>
#include <intuition/gadgetclass.h>
#include <libraries/commodities.h>
#include <libraries/gadtools.h>
#include <libraries/mui.h>
#include <workbench/startup.h>
#include <workbench/icon.h>
#include <workbench/workbench.h>
#include <dos/dosextens.h>
#include <dos/dostags.h>
#include <dos/rdargs.h>
#include <clib/diskfont_protos.h>
#include <clib/alib_protos.h>
#include <clib/commodities_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/graphics_protos.h>
#include <clib/icon_protos.h>
#include <clib/intuition_protos.h>
#include <clib/macros.h>
#include <clib/muimaster_protos.h>
#include <string.h>
#include <stdlib.h>
#ifdef __SASC /* some stuff for SAS-C */
#include <pragmas/muimaster_pragmas.h>
#include <pragmas/commodities_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_sysbase_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/icon_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#define VOID_GETA4 void __interrupt __saveds
#define REGARGS(rv) rv __regargs
#define CHIP(dt) dt __chip
#define ASM(rv) rv __saveds __asm
#define REG(r) register __ ## r
CxObj *HotKey(UBYTE *,struct MsgPort *,long);
void NewList(struct List *);
UBYTE *Version = "$VER: ASwarm II 2.0 (compiled with SAS/C)";
/* Attention ! ASwarm<ALT SPACE>II ... */
void chkabort(void)
{}
#else /* some stuff for Dice */
#define VOID_GETA4 __stkargs __geta4 void
#define REGARGS(rv) __regargs rv
#define CHIP(dt) __chip dt
#define ASM(rv) __geta4 rv
#define REG(r) __ ## r
UBYTE *Version = "$VER: ASwarm II 2.0 (compiled with DICE)";
/* Attention ! ASwarm<ALT SPACE>II ... */
void main(LONG,UBYTE **);
void wbmain(struct WBStartup *WBS)
{
if (WBS->sm_NumArgs) (void)CurrentDir(WBS->sm_ArgList->wa_Lock);
main(0L,(UBYTE **)WBS);
}
#endif
/*
Common Definitions
*/
#define custom (*((struct Custom *)0xDFF000L)) /* Hardwarebangers :-) */
#define ciaa (*((struct CIA *)0xBFE001L))
extern struct ExecBase *SysBase;
extern struct DosLibrary *DOSBase;
#define FINDPROCPORT (&((struct Process *)SysBase->ThisTask)->pr_MsgPort)
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *CxBase,*MUIMasterBase,*IconBase;
LONG WBStarted;
#define NUMTOOLTYPES 17
char *ToolTypeIDs[NUMTOOLTYPES] =
{"CX_PRIORITY","CX_POPUP","CX_POPKEY","BLANKKEY",
"TIMEOUT","CLIENTTIMEOUT",
"DISPLAY","CYCLE","AIM",
"WASP","BEES","SPEED","TIGHTNESS",
"MOUSEBLANKMETHOD","VELOCITY","JOYSTICK","FINALTIMEOUT"};
/*
MUI stuff
*/
/* Defines for the Guide-Node-entries */
#define GUIDE_FILE "ASwarm.guide"
#define NODE_MAIN_MAIN "EDIT"
#define NODE_MAIN_HIDE "HIDE"
#define NODE_MAIN_BLANK "BLANK"
#define NODE_MAIN_QUIT "QUIT"
#define NODE_COMM_MAIN "COMM"
#define NODE_COMM_TIMEOUT "TIME"
#define NODE_COMM_POPKEY "POPKEY"
#define NODE_COMM_CLTIME "CLIENT"
#define NODE_COMM_BLANKKEY "BLANKKEY"
#define NODE_COMM_FITIME "FINAL"
#define NODE_COMM_JOYSTICK "JOYSTICK"
#define NODE_SWARM_MAIN "OPTIONS"
#define NODE_SWARM_SPEED "SPEED"
#define NODE_SWARM_WASPS "WASPS"
#define NODE_SWARM_BEES "BEES"
#define NODE_SWARM_VELO "VELO"
#define NODE_SWARM_TIGHT "TIGHT"
#define NODE_SWARM_COLOR "COLOR"
#define NODE_SWARM_AIM "AIM"
#define NODE_DISPLAY_MAIN "DISPLAY"
#define NODE_DISPLAY_LIST "SCREEN"
#define NODE_DISPLAY_MOUSE "MOUSE"
APTR AP_ASwarm,WI_Config;
APTR ST_Time,ST_Pop,ST_Client,ST_Blank,ST_Final;
APTR CY_Speed,CY_Mouse;
APTR SL_Wasps,SL_Bees,SL_Velo,SL_Tight;
APTR CM_Cycle,CM_Aim,CM_JoyStick;
APTR LV_Modes;
#define ID_OPEN_WINDOW 1L
#define ID_CLOSE_WINDOW 2L
#define ID_BLANK 3L
#define ID_TIMEOUT 10L
#define ID_POPKEY 11L
#define ID_CLIENTTIMEOUT 12L
#define ID_BLANKKEY 13L
#define ID_FINALTIMEOUT 14L
#define ID_JOYSTICK 15L
#define ID_SPEED 20L
#define ID_MOUSE 21L
#define ID_WASPS 22L
#define ID_BEES 23L
#define ID_VELOCITY 24L
#define ID_TIGHTNESS 25L
#define ID_CYCLE 26L
#define ID_AIM 27L
#define ID_MODES 30L
#define ID_LOAD_CONFIG 40L
#define ID_SAVE_CONFIG 41L
#define ID_ABOUT 42L
#define ID_DEFAULTS 43L
char *CE_Speed[5],*CE_SpeedPreDef[] =
{
"Slow Motion","Very Slow","Slow",
"Normal","Fast","Very Fast","Incredible"
};
char *CE_MouseBlank[] = {"Hardware","Window",NULL};
struct NewMenu NM_Config[] =
{NM_TITLE,"Project",NULL,0,0L,NULL,
NM_ITEM,"Load Config","L",0,0L,(APTR)ID_LOAD_CONFIG,
NM_ITEM,"Save Config","S",0,0L,(APTR)ID_SAVE_CONFIG,
NM_ITEM,NM_BARLABEL,NULL,0,0L,NULL,
NM_ITEM,"About ...",NULL,0,0L,(APTR)ID_ABOUT,
NM_ITEM,NM_BARLABEL,NULL,0,0L,NULL,
NM_ITEM,"Hide","H",0,0L,(APTR)ID_CLOSE_WINDOW,
NM_ITEM,"Quit","Q",0,0L,(APTR)MUIV_Application_ReturnID_Quit,
NM_TITLE,"Edit",NULL,0,0L,NULL,
NM_ITEM,"Reset To Defaults","D",0,0L,(APTR)ID_DEFAULTS,
NM_END,NULL,NULL,0,0L,NULL};
/*
Definitions for our Commodity
*/
CxObj *Broker,*PopKeyFilter,*BlankKeyFilter;
struct MsgPort *CxPort;
LONG CxPri,CxPopUp;
UBYTE PopKey[128],BlankKey[128];
LONG JoyStick;
#define EVENT_OPEN_WINDOW 4711L /* What is that number for, Tron ? */
#define EVENT_BLANK 4712L
#define DEF_CX_PRI 0L
#define DEF_POPKEY "CONTROL ALT s" /* Hot Key for the Edit Window */
#define DEF_BLANKKEY "CONTROL ALT b" /* Hot Key for immediate Blank */
LONG TimeLeft,InitTimeLeft,TimeOut,ClientTimeOut,FinalTimeOut;
#define MAX_TIMEOUT 3600L
#define MAX_CLIENT_TIMEOUT 60L
#define MAX_FINAL_TIMEOUT 3600L
#define DEF_TIMEOUT 60L
#define DEF_CLIENT_TIMEOUT 5L
#define DEF_FINAL_TIMEOUT 0L
#define SERVER_PRI 5L /* Don't change this, saves live */
#define CLIENT_PRI -40L
/*
Definitions for our Blanker Screen
*/
CHIP(UWORD) EmptyPointer[] = {0,0,0,0}; /* Dummy Pointer when using the
One-Pixel-Window-Trick */
struct ModeNode
{
struct Node mn_Node;
UWORD mn_Index;
ULONG mn_DisplayID;
char mn_Name[DISPLAYNAMELEN];
};
struct List *ModeList;
struct ModeNode *DisplayMode;
#define FindMode(l,n) ((struct ModeNode *)FindName(l,n))
#define DEF_MODE HIRES
#define DEF_MODE_NAME "HighRes"
/* Mini and Maximum definitions for possible parameters */
#define MAX_SPEED 4L
#define MAX_WASPS 10L
#define MAX_BEES 500L
#define MAX_TIGHTNESS 10L
#define MAX_VEL 15L
#define DEF_SPEED 4L
#define DEF_WASPS 2L
#define DEF_BEES 25L
#define DEF_TIGHTNESS 5L
#define DEF_VEL 5L
char *Template = /* extra extra extra long :-) */
"CX_PRIORITY/N/K,CX_POPKEY/K,CX_POPUP/S,BLANKKEY/K,SECONDS=TIMEOUT/N/K,"
"CLIENTTIMEOUT/N/K,DISPLAY/K,CYCLE/S,AIM/S,WASPS/N/K,BEES/N/K,SPEED/N/K,"
"TIGHTNESS/N/K,MOUSEBLANKMETHOD/K,VELOCITY/N/K,JOYSTICK/S,FINALTIMEOUT/N/K";
/*
Definitions for Server/Client Communication
*/
BYTE bsp_TimeOut,bsp_InputSig,bsp_ClientSig;
struct Task *BlankerServerProcess;
#define MASK(n) (1L<<(n))
struct BlankerClientMsg
{
struct Message bcm_Message;
struct Screen *bcm_Screen;
LONG bcm_Status;
ULONG bcm_SigMask;
LONG bcm_Wasps,bcm_Bees,bcm_Speed,bcm_Tightness,bcm_Velocity;
LONG bcm_Cycle,bcm_AimMode,bcm_MouseBlank,bcm_FinalTimeOut;
} BlankerClientMsg;
/*
Definitions or Swarm Movement
*/
#define BEEACC 3
#define BEEVELOC 2
#define WASPACC 5
#define WASPVELOC 5
#define BORDER 20
#define WASPVEL