/*
***************************************************************************
*
* Datei:
*    RSysPre.h
*
* Inhalt:
*
*      --- Globale Routinen ---
*
*
*      --- Lokale  Routinen ---
*
*
* Bemerkungen:
*    Dise Datei wird vorkompiliert (Zeitgewinn beim Übersetzen
*    einzelner Module.
*
* Erstellungsdatum:
*    19-Jul-93    Rolf Böhme
*
* Änderungen:
*    19-Jul-93    Rolf Böhme    Erstellung
*
***************************************************************************
*/

#include <clib/icon_protos.h>
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/expansion_protos.h>
#include <clib/asl_protos.h>
#include <clib/commodities_protos.h>
#include <clib/wb_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/utility_protos.h>
#include <clib/translator_protos.h>
#include <clib/iffparse_protos.h>
#include <clib/macros.h>
#include <clib/layers_protos.h>
#include <clib/keymap_protos.h>

#include <pragmas/icon_lib.h>
#include <pragmas/exec_lib.h>
#include <pragmas/gadtools_lib.h>
#include <pragmas/graphics_lib.h>
#include <pragmas/intuition_lib.h>
#include <pragmas/dos_lib.h>
#include <pragmas/expansion_lib.h>
#include <pragmas/asl_lib.h>
#include <pragmas/commodities_lib.h>
#include <pragmas/wb_lib.h>
#include <pragmas/diskfont_lib.h>
#include <pragmas/utility_lib.h>
#include <pragmas/translator_lib.h>

#include <devices/audio.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <devices/timer.h>
#include <devices/trackdisk.h>
#include <devices/narrator.h>
#include <devices/prtbase.h>
#include <devices/printer.h>

#include <dos/exall.h>
#include <dos/rdargs.h>
#include <dos/dostags.h>
#include <dos/dosextens.h>
#include <dos/filehandler.h>

#include <exec/alerts.h>
#include <exec/devices.h>
#include <exec/execbase.h>
#include <exec/interrupts.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <exec/types.h>

#include <graphics/displayinfo.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/text.h>

#include <hardware/cia.h>
#include <hardware/intbits.h>
#include <hardware/custom.h>

#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/gadgetclass.h>
#include <intuition/imageclass.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <intuition/preferences.h>

#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/expansionbase.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include <libraries/commodities.h>
#include <libraries/diskfont.h>
#include <libraries/translator.h>
#include <libraries/iffparse.h>

#include <workbench/startup.h>
#include <workbench/workbench.h>

#include <limits.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <ctype.h>

#include <libraries/amigaguide.h>
#include <clib/amigaguide_protos.h>
#include <pragmas/amigaguide_pragma.h>

#include "RSysDebug.h"

#define NAME		"RSys"
#define VERSION	"1.3"
#define DATE		__DATE__
#define TIME		__TIME__
#define COPYRIGHT "(c) by Rolf Boehme (GiftWare and PD)"

#define UNSETLVPOS				-1
#define NO_CASE					0
#define CASE						1
#define HOTKEYS					7
#define MAXSHOW					10
#define SYSTEMINFO				12
#define TITLELEN					15
#define PWDLEN 					20
#define ENVLEN 					20
#define PARTSIZE					20
#define MAXSTRLEN 				30
#define BUFSIZE               60
#define PATTERNLEN				50
#define SEC 						50
#define HELPLINESIZE 			50
#define PATHPARTWIDTH			80
#define PARSEPATLEN				102
#define MAXFULLNAME				108
#define MAXLINESIZE				150
#define MAXWRITESIZE 			200
#define CRCTABSIZE				256
#define MAXLARGEMEM				512
#define FRAC						8192
#define FULL						65536

#define CRC16                 0
#define CRC32                 1

   /*
    * Window-Gadgets-Counter
    */
#define ChgPri_CNT            5
#define ShowFont_TNUM         1
#define CRC_CNT               5
#define Crypt_CNT             8
#define Formatter_CNT         8
#define FindFile_CNT          10
#define FormatDisk_CNT        10
#define SaveAWindow_CNT       3
#define MemMonitor_CNT        13
#define SearchStr_CNT         3
#define Sys_CNT               19

#define NOSCREENTITLECHANGE	((UBYTE *)(-1))

#define R13 						TRUE
#define CRY 						FALSE

#define ESC 						'\33'

#define ACTION_TOKEN 			"#"

#define COUNT_FLAGS				(GD_HandlerInpGad+1)
#define KEY_RELEASE				0x80
#define KEY_HELP					0x5F
#define KEY_q						0x10
#define KEY_ESC					0x45

#define custom 					(*(struct Custom *)0xDFF000)

#define EVT_HOTKEY				1L

#define CNTMASK					LDF_DEVICES
#define MASK						(CNTMASK|LDF_READ)
#define B2C(x) 					((VOID *)(((LONG)(x))<<2))

#define ID_PORT_NAME 			(UBYTE *)"RSys.rendezvous"

#define STRINGEND 				'\0'

#define KILL						TRUE
#define NO_KILL					FALSE

#define YES 						TRUE
#define NO							FALSE

#define SORT						TRUE
#define NO_SORT					FALSE

#define SPEAK						TRUE
#define NO_SPEAK					FALSE

#define ErrorHandle(str,nr1,nr2,kill) ErrorHandleFull(str,nr1,nr2,kill,__FILE__,__FUNC__,__LINE__)

#define CTRLKEYS (AMIGAKEYS | IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT | \
IEQUALIFIER_CAPSLOCK | IEQUALIFIER_CONTROL | IEQUALIFIER_LALT | IEQUALIFIER_RALT |\
IEQUALIFIER_NUMERICPAD)

	/*
	 * Dieses Template wird von der Funktion ReadArgs()
	 * verwendet, um die Argumente auf der Kommandozeile
	 * zu parsen. Es erscheint auch, wenn man das
	 * Programm RSys mit dem Parameter "?" aufruft
    * Aus RSys.c
	 */
#define TEMPLATE \
(UBYTE *)"T=TASKS/S,L=LIBRARIES/S,M=MEMORY/S,P=PORTS/S,V=VOLUMES/S,\
A=ASSIGNS/S,F=FONTS/S,R=RESOURCES/S,I=INTERRUPTS/S,W=WINDOWS/S,\
S=SCREENS/S,H=INPUTHDL/S"

#define CTRL_C_RECEIVED          (mask & SIGBREAKF_CTRL_C)
#define ID_PORT_SIG_RECEIVED     (mask & (1L << SysIdPort->mp_SigBit))
#define BROKER_PORT_SIG_RECEIVED (mask & (1L << broker_mp->mp_SigBit))
#define WINDOW_PORT_SIG_RECEIVED (mask & (1L << SysWnd->UserPort->mp_SigBit))

#define ESC_PRESSED        ((class == IDCMP_VANILLAKEY) && (code==ESC))
#define MENU_PRESSED       ((class == IDCMP_MENUPICK  ) && (MENUNUM(code) == 0) && (ITEMNUM(code) == 0))

#define ICONIFY_REQUESTED  (Flags.wb_start && (ESC_PRESSED || MENU_PRESSED))

   /*
    * Aus RSysTreeHunks.c
    */
#define RKEY	((struct Remember **)&dekey)
#define SIZEDE sizeof(struct diskhunkentry)

#define IS_SET(pos)	(mask&(1L<<(pos)))
#define SET(pos)		(mask|=(1L<<(pos)))
#define UNSET(pos)	(mask&=(~(1L<<(pos))))

#define IDIR		 "\303"
#define ILASTDIR	 "\300"
#define ISUBDIR	 "\304 "
#define ILEVEL 	 "\263  "

#define ADIR		 "+"
#define ALASTDIR	 "\\"
#define ASUBDIR	 "- "
#define ALEVEL 	 "|  "

   /*
    * Aus RSysCRC.c
    */
	 /*
	  * The width of the cell ring is defined here. A word of warning: never
	  * encrypt a file and forget the access password, since it will be
	  * extremely hard to break the code (with 30 cells there are 256^30
	  * possible values each cell may be initialized to which means that
	  * you could have to try more than 1.7e+72 combinations for each single
	  * password character before actually finding the matching password).
	  * See `Random sequence generation by cellular automata' by Steven
	  * Wolfram (Institute for Advanced Study; Advances in Applied
	  * Mathematics) for more information.
	  */

#define CELL_WIDTH 30

   /*
    * Aus RSysClip.c
    */
#define ID_FTXT  MAKE_ID('F','T','X','T')
#define ID_CHRS  MAKE_ID('C','H','R','S')

   /*
    * Aus RSysCheckOffsets.c
    */
#define FKEY				((struct Remember **)&FKey)
#define ALLOCF(size) 	AllocRemember(FKEY,(size),MEMF_CLEAR)
#define FREEF(flag)		FreeRemember(FKEY,(flag))

#define MAGIC_ROM_END	((ULONG)0x01000000)
#define MAGIC_ROM_SIZE	((ULONG)(*((ULONG *)0x00FFFFEC)))

#define FUNCOFFS sizeof(struct func)

#define LIBCNT   sizeof(libs)/sizeof(struct _liblist)
#define DEVCNT   sizeof(devs)/sizeof(struct _devlist)

   /*
    * Aus RSysFormatFind.c
    */
#define DF 0
#define FI 1
#define DI 2

#define DEVKEY 	((struct Remember **)&DevKey)
#define FILEKEY	((struct Remember **)&FileKey)

#define CMDFMT "%s DRIVE %s NAME \"%s\" %s %s %s %s"

   /*
    * Aus RSysSpecialList.c
    */
#define MAX_BROKER_ENTRIES 40

   /*
    * Aus RSysSignalTrap.c
    */
#define _NUMSIG				15
#define _FSTSIG				0

   /*
    * Aus RSysHunks.c
    */
#define ERKEY	((struct Remember **)&hekey)
#define ESIZEDE sizeof(struct hunkentry)

   /*
    * Aus RSysSaveWindow.c
    */

	/* Current compression mode. */

#define DUMP		0
#define RUN		1

	/* ByteRun compression data. */

#define MINRUN		3
#define MAXRUN		128
#define MAXDAT		128

	/* Chunk types. */

#define ID_ILBM		MAKE_ID('I','L','B','M')
#define ID_ANNO		MAKE_ID('A','N','N','O')
#define ID_BMHD		MAKE_ID('B','M','H','D')
#define ID_CMAP		MAKE_ID('C','M','A','P')
#define ID_CAMG		MAKE_ID('C','A','M','G')
#define ID_BODY		MAKE_ID('B','O','D','Y')

	/* Masking technique. */

#define mskNone		0

	/* Compression techniques. */

#define cmpNone		0
#define cmpByteRun1	1

   /*
    * Aus RSysSummaryLists.c
    */
#define MEMTYPELEN 15
#define NONE (WORD)(0xFFFF)

#define CNT_DEVELOPER (sizeof(manu)/sizeof(struct Manufacturer))

#define GFXF_AA_ALICE	4
#define GFXF_AA_LISA		8
#define GFXF_AA_MLISA	16	/* internal use only */

   /*
    * Aus RSysGfxIntuiLists.c
    */
#define SETFLAG(gad,flag) ((((gad)->GadgetType)&(flag))==(flag))

   /*
    * Aus RSysDosLists.c
    */
#define BPTR_TO_C(strtag, var)  ((struct strtag *)(BADDR( (ULONG) var)))
#define C_TO_BPTR(var)			  (((ULONG)var)>>2)

   /* 
    * Aus RSysInitData.c
    */
#define HWKEY           ((struct Remember **)&HWKey)
#define ALLOCHW(size)   AllocRemember(HWKEY, (size), MEMF_CLEAR)

#define LOKEY           ((struct Remember **)&LOKey)
#define ALLOCLO(size)   AllocRemember(LOKEY, (size), MEMF_CLEAR)

#define VMKEY           ((struct Remember **)&VMKey)
#define ALLOCVM(size)   AllocRemember(VMKEY, (size), MEMF_CLEAR)

   /* 
    * Aus RSysMonitor.c
    */
#define LINESIZE        16L
#define LINECOUNT       32L
#define BLOCKSIZE       512L
#define DISPLAYCOUNT    4

#define MONKEY             ((struct Remember **)&MonKey)
#define AllocMonMem(size)  AllocRemember(MONKEY,(size),MEMF_CLEAR);

   /* 
    * Aus RSysInit.c
    */
#define GTMN_NewLookMenus    GT_TagBase+67 /* ti_Data is boolean */
#define NEWLEN 24

#define LOCK      TRUE
#define UNLOCK    FALSE
