/**Globals.c*************************************************************
 *									*
 *   SeePix -- by Hank Schafer						*
 *									*
 *   SeePix is an IFF Picture Viewer.  It works with Lo-Res,		*
 *   Med-Res, Hi-Res, HAM, and EHB formats.  I'm working on support     *
 *   for X-Specs, and Anim5 formats.					*
 *									*
 *   SeePix is based on a program by Olaf Barthel, called		*
 *   'LoadImage'.  As released, LoadImage had a couple of bugs. 	*
 *   The Amiga-Key alternatives to menu use didn't all work.  That's	*
 *   been fixed.  There were two separate print functions in LoadImage	*
 *   which behaved exactly the same.  The redundancy was eliminated.	*
 *   LoadImage used the Topaz ROMFONT, and made no allowances for a	*
 *   different system default font (under 2.04).  I added a built-in	*
 *   font.  I've reworked the code considerably from the original       *
 *   release, to allow for optimizations based on time and space.	*
 *									*
 *   SeePix features a palette tool which allows "tweaking" of colors	*
 *   prior to printing, allowing you to modify the color printout to	*
 *   more closely resemble the original graphics (Blue is Blue, not	*
 *   Purple).  SeePix can be Iconified.  SeePix features an ARP 	*
 *   interface.  SeePix now uses the PathMaster File Selector.		*
 *									*
 ************************************************************************
 *                                                                      *
 *   SeePix Copyright © 1992 by Hank Schafer; all rights reserved.      *
 *                                                                      *
 *   This program is free software; you can redistribute it and/or      *
 *   modify it under the terms of the GNU General Public License as     *
 *   published by the Free Software Foundation, either version 1, or    *
 *   (at your option) any later version.                                *
 *                                                                      *
 *   This program is distributed in the hope that it will be useful,    *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of     *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
 *   General Public License for more details.                           *
 *                                                                      *
 *   You should have received a copy of the GNU General Public License  *
 *   along with this program; if not, write to:                         *
 *                 Free Software Foundation, Inc.                       *
 *                 675 Massachusetts Ave.                               *
 *                 Cambridge  MA  02139, USA                            *
 *                                                                      *
 **************** Special Function Copyright Notices ********************
 *									*
 ****LoadImage Copyright Notice:					*
 *									*
 *   LoadImage is © Copyright 1988, 1989, 1990 by MXM, all rights	*
 *   reserved, written by Olaf Barthel.  No guarantees of any kind are	*
 *   made that this program is 100% reliable.  Use this program on	*
 *   your own risk!							*
 *									*
 ****Iconify Copyright Notice:						*
 *									*
 *   Copyright 1987 by Leo L. Schwab.					*
 *   Permission is hereby granted for use in any and all programs,	*
 *   both Public Domain and commercial in nature, provided this 	*
 *   Copyright notice is left intact.					*
 *									*
 ****ColorWindow (Palette) Copyright Notice:				*
 *									*
 * ColorWindow Routine	--  Color Window Routines			*
 *     from Book 1 of the Amiga Programmers' Suite by RJ Mical          *
 *									*
 * Copyright (C) 1986, 1987, Robert J. Mical				*
 * All Rights Reserved. 						*
 *									*
 ****PathMaster Copyright Notice:					*
 *									*
 * -------------------------------------------------------------------- *
 *   Copyright © 1989 Justin V. McCormick.  All Rights Reserved.	*
 * -------------------------------------------------------------------- *
 *									*
 *    The PathMaster name is a trademark of Justin V. McCormick.	*
 *									*
 *   PathMaster File Selector source and documentation written by:	*
 *									*
 *			 Justin V. McCormick.				*
 *	       Copyright © 1989 by Justin V. McCormick. 		*
 *			 All Rights Reserved.				*
 *									*
 * -------------------------------------------------------------------- *
 ************************************************************************
 *									*
 *   Hope this is something you can use and enjoy.			*
 *									*
 ************************************************************************/

/*
 * The necessary header files, a few function prototypes, some data
 * definitions and some just plain miscellaneous stuff.
 */

#include <ARPFunctions.h>
#include <CLib/Macros.h>
#include <Devices/InputEvent.h>
#include <Devices/Printer.h>
#include <Devices/Timer.h>
#include <Exec/Devices.h>
#include <Exec/ExecBase.h>
#include <Exec/Interrupts.h>
#include <Exec/IO.h>
#include <Exec/Libraries.h>
#include <Exec/Lists.h>
#include <Exec/Memory.h>
#include <Exec/Nodes.h>
#include <Exec/Ports.h>
#include <Exec/Semaphores.h>
#include <Exec/Tasks.h>
#include <Exec/Types.h>
#include <Fcntl.h>
#include <Graphics/GFX.h>
#include <Graphics/GFXBase.h>
#include <Graphics/Layers.h>
#include <Graphics/RastPort.h>
#include <Graphics/Text.h>
#include <Graphics/View.h>
#include <Hardware/IntBits.h>
#include <Intuition/Intuition.h>
#include <Intuition/IntuitionBase.h>
#include <Libraries/ARPBase.h>
#include <Libraries/DOS.h>
#include <Libraries/DOSExtens.h>
#include <Libraries/FileHandler.h>
#include <StdDef.h>
#include <StdIO.h>
#include <StdLib.h>
#include <String.h>
#include <WorkBench/StartUp.h>
#include "Config.h"

#ifndef FALSE
#define FALSE 0L
#endif				/* FALSE */
#ifndef TRUE
#define TRUE 1L
#endif				/* TRUE */

/* Some useful macros. */

#define SetFlag(v,f) ((v)|=(f))
#define ClearFlag(v,f) ((v)&=~(f))
#define ToggleFlag(v,f) ((v)^=(f))
#define FlagIsSet(v,f) ((BOOL)(((v)&(f))!=0))
#define FlagIsClear(v,f) ((BOOL)(((v)&(f))==0))
#define ABS(n) (((n)<0)?(-(n)):(n))
#define BoundaryOff(r) ((r)->Flags &= ~AREAOUTLINE)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define LineBytes(n) (((n + 15) >> 4) << 1)

/* Macro expressions to set the pointer for our window. */

#define SetPoint(wind) SetPointer(wind,PointData,7,16,-4,-3)
#define SetSnooze(wind) SetPointer(wind,Snooze,13,16,-4,-3)
#define SetSize(wind) SetPointer(wind,SizeData,13,16,-4,-3)

/*
 * Required for the centering macros in Main.c & Iconize.c -- Change these to
 * the default resolution of your Workbench Screen.
 */

#define	WinW	640		/* Workbench Screen Width */
#define	WinH	200		/* Workbench Screen Height */

/* Sprite dump for the pointer image. */

UWORD           PointData[(2 + 7) * 2] =
{
    0x0000, 0x0000,
    0x0000, 0x1000,
    0x1000, 0x0000,
    0x1000, 0x1000,
    0x6C00, 0xAA00,
    0x1000, 0x1000,
    0x1000, 0x0000,
    0x0000, 0x1000,
    0x0000, 0x0000
};

/* Clock wait pointer. */

UWORD           Snooze[(2 + 13) * 2] = {
    0x0000, 0x0000,
    0x0f80, 0x0d80,
    0x1040, 0x1040,
    0x2220, 0x2020,
    0x4210, 0x4010,
    0x8208, 0x8008,
    0x8208, 0x8008,
    0x8388, 0x0000,
    0x8008, 0x8008,
    0x8008, 0x8008,
    0x4010, 0x4010,
    0x2020, 0x2020,
    0x1040, 0x1040,
    0x0f80, 0x0D80,
    0x0000, 0x0000
};

/* The Rubber Band "Size" pointer used when printing */

UWORD           SizeData[(2 + 13) * 2] =
{
    0x0000, 0x0000,
    0x0000, 0x1000,
    0x1000, 0x0000,
    0x1000, 0x1000,
    0x6C00, 0xAA00,
    0x1000, 0x1000,
    0x1000, 0x0000,
    0x0000, 0x1000,
    0x0000, 0x0000,
    0x0D77, 0x0D77,
    0x1114, 0x1114,
    0x1D27, 0x1D27,
    0x0544, 0x0544,
    0x1977, 0x1977,
    0x0000, 0x0000
};

/* Requester border coordinates. */

WORD            ReqBrdDat[] =
{
    -3, -2, 234, -2, 234, 17, -3, 17, -3, -2,
    -6, -4, 237, -4, 237, 19, -6, 19, -6, -4,
    0, 0, 293, 0, 293, 172, 0, 172, 0, 0,
    0, 0, 295, 0, 295, 172, 0, 172, 0, 0
};

/* Empty color information. */

UWORD           BlackIsBlack[32] =
{
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0
};

/* The real BitMapHeader... */

typedef struct {
    UWORD           w, h;	/* Raster width & height. */
    UWORD           x, y;	/* Pixel position. */
    UBYTE           nPlanes;	/* Number of source bitplanes. */
    UBYTE           masking;	/* Masking... maybe good for nothing. */
    UBYTE           compression;/* Compressed or not? */
    UBYTE           pad1;	/* We don't like odd length structures. */
    UWORD           transparentColor;	/* Maybe good for... */
    UBYTE           xAspect, yAspect;	/* Kind of quotient, width/height. */
    WORD            pageWidth, pageHeight;	/* Source page size. */
}               BitMapHeader;

/* The typical format of a DPaint color cycling range. */

typedef struct {
    WORD            pad1;	/* Not used. */
    WORD            rate;	/* Cycling speed. */
    WORD            active;	/* Is it active? Which way is it cycling? */
    UBYTE           low, high;	/* Start and stop color. */
}               CRange;

/* The mystical, archetypical IFF chunk... */

typedef struct {
    ULONG           IFF_Type;	/* Chunk type. */
    LONG            IFF_Length;	/* Chunk length. */
}               IFF_Chunk;

/* Check for ^C signal. */

#define BreakCheck() (SetSignal(0,0) & SIGBREAKF_CTRL_C)

/* Miscellaneous error codes. */

#define ERR_NOIFF 1		/* Not an IFF-ILBM file. */
#define ERR_NOCOLMAP 2		/* No color map. */
#define ERR_NOMEM 3		/* Not enough memory. */
#define ERR_DOS 4		/* A DOS error. */

/* Miscellaneous Pragmas */

#pragma regcall(MkID(a0))
#pragma regcall(FindChunk(a0,a1))

/* Misc declarations */

UBYTE           WasCycling;
UWORD           Colors[32];
WORD            ColorNumber;

/* Stuff needed by Iconize(); and iconify(); */

#define	ICON_IMAGE 0
#define	ICON_BORDER 1
#define	BCopy(src, dest, len) movmem(src, dest, len);
#define	ikonW 47
#define	ikonH 9

/* Stuff needed by the palette requester */

#define COLOR_LEFT 0
#define COLOR_TOP 9
#define COLOR_KNOB_BODY 0x1000
#define NEW_EXTRALEFT 24
#define COLORWINDOW_WIDTH (208 + NEW_EXTRALEFT + COLOR_LEFT)
#define COLORWINDOW_HEIGHT (91 + COLOR_TOP)
#define CHARACTER_WIDTH 8
#define CHARACTER_HEIGHT 8
#define COLOR_BOX_LEFT (COLOR_LEFT + 7)
#define COLOR_BOX_TOP (COLOR_TOP + 6)
#define COLOR_BOX_RIGHT (COLOR_BOX_LEFT + 15)
#define COLOR_BOX_BOTTOM (COLOR_BOX_TOP + 29)
#define COLOR_COLOR_TOP (COLOR_TOP + 45)
#define COLOR_PROP_LEFT (COLOR_LEFT + 41)
#define COLOR_PROP_TOP (COLOR_TOP + 4)
#define COLOR_PROP_WIDTH 165
#define COLOR_PROP_HEIGHT 10
#define COLOR_CLUSTER_LEFT (COLOR_LEFT + 144)
#define COLOR_CLUSTER_TOP (COLOR_TOP + 41)
#define COLOR_CLUSTER_WIDTH (CHARACTER_WIDTH * 6 + 10 + NEW_EXTRALEFT)
#define COLOR_CLUSTER_HEIGHT 9
#define COLOR_HSL_TOP COLOR_PROP_TOP
#define COLOR_HSL_LEFT (COLOR_PROP_LEFT - 14)
#define COLOR_VALUE_X (COLOR_PROP_LEFT + COLOR_PROP_WIDTH + 4)
#define COLOR_VALUE_REDY (COLOR_PROP_TOP + 1 + 6)
#define COLOR_VALUE_GREENY (COLOR_VALUE_REDY + COLOR_PROP_HEIGHT + 1)
#define COLOR_VALUE_BLUEY (COLOR_VALUE_GREENY + COLOR_PROP_HEIGHT + 1)
#define COLOR_COPY 0
#define COLOR_RANGE 1
#define COLOR_OK 2
#define COLOR_CANCEL 3
#define COLOR_GREEN 4
#define COLOR_RED 5
#define COLOR_BLUE 6
#define COLOR_HSL_RGB 7
#define COLOR_GADGETS_COUNT 8
#define RGBHSL_SIZE 29

/* ColorMode definitions */

#define COPYCOLOR 1
#define RANGE_FIRST 2
#define RANGE_SECOND 3

/* These are the dimensions of the color hit box */

#define COLOR_COLOR_ROWS (4 * 10)
#define COLOR_COLOR_COLS (8 * 15)
#define COLOR_COLOR_RIGHT (COLOR_BOX_LEFT + COLOR_COLOR_COLS - 1)
#define COLOR_COLOR_BOTTOM (COLOR_COLOR_TOP + COLOR_COLOR_ROWS - 1)

extern struct TextFont *MainFont;
extern struct TextAttr SPFont[3];
#define PATHSTRSIZE 300		/* 10 subdirs worth of space */
#define FILESTRSIZE 32		/* Room for filename + null + roundoff */

#ifdef	PATHMASTER

/* Stuff needed by the PathMaster File Selector */

#define __regargs
#define __stdargs
#define __fARGS(a) ()
#define __ARGS(a) ()

#define MATCHSTRSIZE 32		/* Room for 30 char pattern + null + " */

/* File node structure */

struct node_data {
    BYTE            alphadata[58];	/* ascii data */
    WORD            filetype;	/* Dir or file flag */
    WORD            showit;	/* 0=skip, 1=showable */
    WORD            textcolor;	/* Color to render this file as */
    WORD            namelength;	/* Actual length of file name */
    ULONG           filesize;	/* File size in bytes */
    ULONG           days;	/* File creation date */
    ULONG           minutes;
    ULONG           ticks;
};

struct file_node {
    struct MinNode  fn_Node;	/* Exec List linkage */
    struct node_data *info;	/* file info structure */
    WORD            idnum;	/* numerical list position */
};

/* Struct for list of Devices found */

struct dev_node {
    struct MinNode  dn_Node;
    UBYTE           name[FILESTRSIZE];
};

/* File selector request structure */

struct FSRequest {

    /* Contents of the "PATH" string gadget */

    BYTE            dirname[PATHSTRSIZE];

    /* Contents of the "FILE" string gadget */

    BYTE            filename[FILESTRSIZE];

    /* Contents of the "PATTERN" string gadget */

    BYTE            matchpattern[MATCHSTRSIZE];

    /* Window initial X & Y positions, user modifiable */

    WORD            leftedge;
    WORD            topedge;

    /* -1=No Sort; 0=Alpha; 1=Size; 2=Time */

    WORD            sorttype;

    /* See flags below */

    UWORD           flags;

    /* Special window flags */

    ULONG           windowflags;

    /* Must point to BYTE[344] space for full path! */

    BYTE           *fullname;

    /* Wilcard to skip files, e.g. "*.info" */

    BYTE           *ignorepattern;

    /* "PATH" or equivalent string gadget label */

    BYTE           *pathgadstr;

    /* "FILE", "NAME" string gadget label */

    BYTE           *filegadstr;

    /* Static titlebar message, i.e. "SeePix" */

    BYTE           *titlestr;

    /* "Reading..." or appropriate substitute */

    BYTE           *readingstr;

    /* "Sorting..." or equivalent message */

    BYTE           *sortingstr;

    /* "Empty Directory" or equivalent */

    BYTE           *emptydirstr;

    /* "Nothing matched PATTERN" or equivalent */

    BYTE           *nomatchstr;

    /* "Select File:" or equivalent */

    BYTE           *selectfilestr;

    /* "Okay", "Load", etc. gadget text */

    BYTE           *selectstr;

    /* "Cancel", "Exit", etc. gadget text */

    BYTE           *cancelstr;

    /* Text for optional user-definable gadget */

    BYTE           *specgadstr;

    /* Screen to open requester on or 0L for WBench */

    struct Screen  *userscreen;

    /* port to Wait on, then call userfunc or 0L */

    struct MsgPort *userport;

    /* Function called if specgadstr != 0L on GADGETUP	 */

                    LONG(*specgadfunc) __fARGS((struct FSRequest *, struct Window *, struct Gadget *));

    /* Clicked on a directory function */

                    LONG(*dirfunc) __fARGS((struct FSRequest *, struct Window *));

    /* Clicked on a filename function or 0L	 	 */

                    LONG(*filefunc) __fARGS((struct FSRequest *, struct Window *));

    /* Function called when Signal at userport set	 */

                    LONG(*userfunc) __fARGS((struct FSRequest *, struct Window *));

    /* Called right after OpenWindow for SetPointering	 */

                    LONG(*initfunc) __fARGS((struct FSRequest *, struct Window *));

    /* Called for each node_data, your chance to accept/reject/change */

                    LONG(*matchfunc) __fARGS((struct FSRequest *, BYTE *, struct file_node *));
};

/* FSRequest flags */

#define FS_NO_DCLICK_EXIT (1L << 0)	/* Disable Double-Click	exit */
#define FS_NO_STRING_EXIT (1L << 1)	/* Disable File String Gadget exit */
#define FS_NO_STRING_OKAY (1L << 2)	/* Allow exit with no file name */
#define FS_SHOW_FILES_FIRST (1L << 3)	/* Show files first in mixture */
#define FS_SHOW_DIRS_FIRST (1L << 4)	/* Show dirs first in mixture */
#define FS_SHOW_FILES_ONLY (1L << 5)	/* Don't show dirs */
#define FS_SHOW_DIRS_ONLY (1L << 6)	/* Don't show files */
#define FS_DELAYED_SORT (1L << 7)	/* Don't sort till user hits slide */

/*
 * PathMaster File Selector control code.
 */

extern struct IORequest *CreateExtIO __ARGS((struct MsgPort *, LONG));

/* Extern CODE */

extern BYTE    *__stdargs FibFileDate __ARGS((struct DateStamp *));
extern BYTE    *__stdargs myrindex __ARGS((BYTE *, LONG));
extern LONG __stdargs AllocFSFib __ARGS((VOID));
extern LONG __stdargs FSCheckFlagChange __ARGS((VOID));
extern LONG __stdargs FSGetNextFib __ARGS((VOID));
extern LONG __stdargs ioerrnum __ARGS((LONG));
extern LONG __stdargs lstrcmp __ARGS((BYTE *, BYTE *));
extern struct dev_node *__stdargs AllocDevNode __ARGS((VOID));
extern struct file_node *__stdargs AllocFileNode __ARGS((VOID));
extern VOID __stdargs CheckFSArrows __ARGS((VOID));
extern VOID __stdargs FillFileNode __ARGS((struct file_node *));
extern VOID __stdargs FreeAllDNodes __ARGS((VOID));
extern VOID __stdargs FreeAllFNodes __ARGS((VOID));
extern VOID __stdargs FreeFileSelect __ARGS((VOID));
extern VOID __stdargs FSAssignEntryText __ARGS((struct file_node *, LONG));
extern VOID __stdargs FSClearLock __ARGS((VOID));
extern VOID __stdargs FSDisableAllFGads __ARGS((VOID));
extern VOID __stdargs FSDoFileGad __ARGS((LONG));
extern VOID __stdargs FSDoGadget __ARGS((ULONG));
extern VOID __stdargs FSDoSlideGadget __ARGS((VOID));
extern VOID __stdargs FSDoSortGadget __ARGS((LONG));
extern VOID __stdargs FSEndString __ARGS((VOID));
extern VOID __stdargs FSMatchPattern __ARGS((VOID));
extern VOID __stdargs FSPutPath __ARGS((VOID));
extern VOID __stdargs FSResetKnob __ARGS((VOID));
extern VOID __stdargs FSScrollFileGads __ARGS((LONG));
extern VOID __stdargs FSSetFileGads __ARGS((VOID));
extern VOID __stdargs FSSetKnob __ARGS((VOID));
extern VOID __stdargs FSStartScrollGad __ARGS((ULONG));
extern VOID __stdargs FSUpdateSort __ARGS((VOID));
extern VOID __stdargs FSWinTitle __ARGS((VOID));
extern VOID __stdargs HCompEntry __ARGS((ULONG));
extern VOID __stdargs MakePathString __ARGS((struct FileLock *, BYTE *));
extern VOID __stdargs MyActivateGad __ARGS((struct Gadget *, struct Window *));
extern VOID __stdargs safestrcpy __ARGS((BYTE *, BYTE *, LONG));
extern VOID __stdargs SetDevGads __ARGS((VOID));
extern BPTR     FSLock;
extern BYTE    *fserrmsgs[];
extern BYTE    *FSPathBuf;
extern BYTE    *OldFSPathBuf;
extern BYTE     fserrmsg22[];
extern BYTE     fserrmsg24[];
extern BYTE     fserrmsg27[];
extern BYTE     fserrmsg28[];
extern BYTE     fserrmsg29[];
extern BYTE     FSIgnorePat[];
extern BYTE     FSPatternUndoBuffer[];
extern BYTE     FSWinTitleStr[];
extern BYTE     FSwstr[];
extern BYTE     RamDirNameStr[];
extern BYTE     SplatStr[];
extern BYTE     TimerName[];
extern struct DateStamp FSdirstamp;
extern struct dev_node *lastdev;
extern struct DosLibrary *DOSBase;
extern struct FileInfoBlock *FSFib;
extern struct file_node *FSFileNodes[];
extern struct file_node *topfin;
extern struct FSRequest *FSReq;
extern struct Gadget FSFileGad;
extern struct Gadget FSPathGad;
extern struct Gadget FSSelectGad;
extern struct Gadget FSUserGad;
extern struct IntuiText FSCancelTxt;
extern struct IntuiText FSFileTxt;
extern struct IntuiText FSPathTxt;
extern struct IntuiText FSSelectTxt;
extern struct IntuiText FSUserTxt;
extern struct List *devList;
extern struct List *fnList;
extern struct MsgPort *FSTimerPort;
extern struct NewWindow FSnw;
extern struct RastPort *FSRPort;
extern struct StringInfo FSFileInfo;
extern struct StringInfo FSPathInfo;
extern struct StringInfo FSPatternInfo;
extern struct timerequest *FSDelayReq;
extern struct Window *FSWin;
extern UBYTE    FSFileLabelStr[];
extern UBYTE    FSPathLabelStr[];
extern ULONG    fscursecs, fscurmicros;
extern ULONG    fsoldsecs, fsoldmicros;
extern ULONG    FSSignal;
extern ULONG    FSSignalMask;
extern ULONG    FSUserSignal;
extern UWORD    fsflags;
extern WORD     FSCountDown;
extern WORD     fsdirlocked;
extern WORD     FSDone;
extern WORD     fsnumentries;
extern WORD     fsstartedstr;
extern WORD     fstitlelength;
extern WORD     fstitstatus;
extern WORD     fsvirgindir;

/* Local CODE */

extern LONG CreateVBTimer __ARGS((BYTE *, struct MsgPort **, struct timerequest **));
extern LONG FSGetDevs __ARGS((VOID));
extern LONG FSGrabEntry __ARGS((VOID));
extern LONG FSLockDir __ARGS((VOID));
extern LONG FSTestOldLock __ARGS((VOID));
extern LONG InitFSVBDelay __ARGS((VOID));
extern LONG InitFSWindow __ARGS((VOID));
extern VOID AbortAsyncIO __ARGS((struct IORequest *));
extern VOID CheckFSIDCMP __ARGS((VOID));
extern VOID FreeFSVBDelay __ARGS((VOID));
extern VOID FreeVBTimer __ARGS((struct MsgPort **, struct timerequest **));
extern VOID __stdargs FSVBDelay __ARGS((ULONG));
extern LONG FileSelect __ARGS((struct FSRequest *));

#endif	/* PATHMASTER */

/* A few function prototypes */

/* CkAbort.c */

LONG            Chk_Abort(VOID);

/* WBParse.c */

VOID            _wb_parse(struct Process * CurrentProcess, struct WBStartup * WBMsg);

/* CLIParse.c */

VOID            _cli_parse(struct Process * pp, long alen, char *aptr);

#ifdef	PATHMASTER

/* FSWindow.c */

LONG            InitFSWindow(void);

/* FSTimer.c */

LONG            CreateVBTimer(BYTE * name, struct MsgPort ** pport, struct timerequest ** ptreq);
LONG            InitFSVBDelay(void);
VOID            FreeFSVBDelay(void);
VOID            FreeVBTimer(struct MsgPort ** pport, struct timerequest ** ptreq);
VOID __stdargs  FSVBDelay(ULONG timedelay);

#endif	/* PATHMASTER */

/* Main.c */

VOID            main(int argc, char **argv);

#ifdef	PATHMASTER

/* FileSelect.c */

LONG            FileSelect(struct FSRequest * fsrequest);

/* FSIO.c */

VOID            AbortAsyncIO(struct IORequest * req);
LONG            FSGrabEntry(void);
LONG            FSLockDir(void);
LONG            FSTestOldLock(void);
LONG            FSGetDevs(void);
VOID            CheckFSIDCMP(void);

#endif	/* PATHMASTER */

/* QwikSort.c */

VOID            QwikSort(char **av, LONG n);

/* QSplit.c */

LONG            QSplit(char **av, LONG n);

/* SeePix.c */

LONG            SeePix(char *FileName, UBYTE ForceScroll, UBYTE ForceLace, UBYTE CycleOnStartup, UBYTE LastOne);

/* Palette.c */

VOID            DrawColorWindow(void);
BOOL            ColorGadgetGotten(struct Gadget * gadget);
VOID            ModifyRGBColors(void);
VOID            ModifyHSLColors(void);
VOID            ModifyColors(void);
VOID            ResetColorProps(void);

/* PrintPix.c */

VOID            PrintPix(void);

/* LoadIFF.c */

LONG            LoadHead(char *FileName, BitMapHeader * BMHeader);
LONG            LoadCMAP(char *FileName, UWORD * ColorMap, LONG MaxCol, BitMapHeader * BMHeader);
UBYTE           LoadRast(char *FileName, PLANEPTR * BitPlanes, BitMapHeader * BMHeader);

/* SPQuit.c */

VOID            SPQuit(void);

/* FadeTo.c */

VOID            FadeTo(struct ViewPort * VPort, UWORD * From, UWORD * To, LONG NumColors, LONG ToCol, LONG FromCol);

/* CloseDisp.c */

VOID            CloseDisp(void);

/* Cycling.c */

static LONG     DoCycle(void);
LONG            InitCycle(struct ViewPort * Cy_ViewPort, UWORD * Cy_ColMap, LONG Cy_ColNum, CRange * Cy_Range, LONG Cy_RangeNum);
VOID            ClearCycle(void);
VOID            ToggleCycle(void);
LONG            IsCycle(void);
LONG            LoadCycleRange(char *FileName, CRange * Range, LONG MaxRange);

/* FindChunk.c */

LONG            FindChunk(char *ChunkName, FILE * FilePointer);

/* MkID.c */

ULONG           MkID(char *IDString);

/* SPExit.c */

VOID            SPExit(LONG ExitCode);

/* Iconize.c */

int             Iconize(void);

/* Iconify.c */

static          OpenUp(void);
static          CloseUp(void);

/* ITBMap.c */

UBYTE           ITBMap(void);

/* GRName.c */

VOID            GRName(char *FullName, char *RealName);

