home *** CD-ROM | disk | FTP | other *** search
- #include "cp.h"
- #include "spr.h"
-
- UBYTE *version_string = "$VER: cp 3.0 (26.10.93)";
-
- LONG __oslibversion = 37; /* requires KickStart 37 */
- LONG __BackGroundIO = 1;
- LONG __stack = 8192; /* stack size doesn't seem to work ??? */
- UBYTE *__procname = "cP regnoC"; /* process name */
-
- extern BPTR _Backstdout; /* keep stdout till we get past startup */
-
- struct List *SetList = NULL;
- struct RDArgs *cli_args = NULL;
- struct RDArgs *env_args = NULL;
- struct TextFont *fontPtr = NULL;
- struct TextAttr CPFont = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
- struct TextAttr *cPFont = NULL;
-
-
- /* Set Defaults */
-
- BOOL grid = FALSE; /* No Grid */
- BOOL LOGX = FALSE; /* Lin X */
- BOOL LOGY = FALSE; /* Lin Y */
- BOOL sym = FALSE; /* No Symbols */
- BOOL DEFS = FALSE; /* Don't make cP */
- BOOL MONO = FALSE; /* color default */
- BOOL CPANEL = TRUE; /* control panel on */
- BOOL NOFNAME = FALSE; /* ussually put filename boxes on screen */
-
- LONG Disp = HIRESLACE_KEY; /* Hires Lace Default */
-
- UBYTE *path; /* extern pointer to Path */
- UBYTE Path[255]; /* Path String same as path but not external */
-
- UBYTE *fName; /* extern pointer to fontname */
- UBYTE fontName[32]; /* im too lazy to allocate dynamically */
-
- UBYTE *chans = NULL;
- LONG points = 1000000; /* should be enough max per set */
- LONG thin = 1; /* dont depopulate */
-
- WORD lastcolor = 15; /* 16 colors default palette */
- WORD depth = 4;
-
- LONG *idkey; /* pointer to Display ID */
-
- UBYTE **files; /* pointer to pointer to FILES/M/A */
-
- #define ENVSIZE 1024 /* max char length for envvar */
-
- UBYTE *template = "FILES=WILD/A/M,LX=LOGX/S,LY=LOGY/S,GRID/S,SYM/S,ID=DISPLAYID/N/K,FONT/K,FS=SIZE/N/K,LORES/S,HIRES/S,LACE/S,SETDEF/S,W=WIDTH/N/K,H=HEIGHT/N/K,C=BINARY/F/K,P=POINTS/N/K,T=THIN/N/K,D=DEPTH/N/K,MONO/S,CPANEL/S,NOFN=NOFNBOXES/S";
- UBYTE *envtempl = "FILES=WILD/M,LX=LOGX/S,LY=LOGY/S,GRID/S,SYM/S,ID=DISPLAYID/N/K,FONT/K,FS=SIZE/N/K,LORES/S,HIRES/S,LACE/S,SETDEF/S,W=WIDTH/N/K,H=HEIGHT/N/K,C=BINARY/F/K,P=POINTS/N/K,T=THIN/N/K,D=DEPTH/N/K,MONO/S,CPANEL/S,NOFN=NOFNBOXES/S";
-
- LONG cli_array[ 20 ] = { 0L, 0L, 0L, 0L, 0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L, 0L, 0L, 0L, 0L};
- LONG env_array[ 20 ] = { 0L, 0L, 0L, 0L, 0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L ,0L, 0L, 0L, 0L, 0L};
-
- extern void exit(int); /* from stdlib.h */
-
- /* Use the same function to process command line and envvar */
-
- void arg_array_Parse( LONG *arg_array )
- {
- LONG *ptr;
-
- files = ( UBYTE ** ) arg_array[ 0 ];
-
- if ( arg_array[ 1 ] ) LOGX = TRUE;
- if ( arg_array[ 2 ] ) LOGY = TRUE;
- if ( arg_array[ 3 ] ) grid = TRUE;
- if ( arg_array[ 4 ] ) sym = TRUE;
-
- if ( arg_array[ 5 ] )
- {
- ptr = (LONG *)arg_array[ 5 ];
- Disp = *ptr;
- }
-
- if ( arg_array[ 6 ] )
- {
- strcpy( fName, (UBYTE *)arg_array[ 6 ]);
- strcat( fName, ".font");
- cPFont->ta_Name = (STRPTR)fName;
- }
-
- if ( arg_array[ 7 ] )
- {
- ptr = (LONG *)arg_array[ 7 ];
- cPFont->ta_YSize = (UWORD) *ptr;
- }
-
- if ( arg_array[ 8 ] ) Disp = LORES_KEY;
- if ( arg_array[ 9 ] ) Disp = HIRES_KEY;
- if ( arg_array[ 10 ] ) Disp |= LORESLACE_KEY;
- if ( arg_array[ 11 ] ) DEFS = TRUE;
-
- if ( arg_array[ 12 ] )
- {
- ptr = (LONG *)arg_array[ 12 ];
- SWIDTH = *ptr;
- }
-
- if ( arg_array[ 13 ] )
- {
- ptr = (LONG *)arg_array[ 13 ];
- SHEIGHT = *ptr;
- }
- if ( arg_array[ 14 ] )
- {
- chans = AllocVec( 1024, MEMF_CLEAR );
- if ( chans ) strcpy( chans, (UBYTE *)arg_array[ 14 ]);
- }
- if ( arg_array[ 15 ] )
- {
- ptr = (LONG *)arg_array[ 15 ];
- points = *ptr;
- }
- if ( arg_array[ 16 ] )
- {
- ptr = (LONG *)arg_array[ 16 ];
- thin = *ptr;
- if (thin <= 0) thin = 1;
- }
- if ( arg_array[ 17 ] )
- {
- ptr = (LONG *)arg_array[ 17 ];
- depth = (WORD)*ptr;
-
- if (depth <= 1 )
- {
- depth = 1;
- lastcolor = 1;
- MONO = TRUE;
- }
- if (depth == 2) lastcolor = 3;
- if (depth == 3) lastcolor = 7;
- if (depth >= 4)
- {
- depth = 4;
- lastcolor = 15;
- }
- }
- if ( arg_array[ 18 ] )
- {
- MONO = TRUE;
- depth = 1;
- lastcolor = 1;
- }
- if ( arg_array[ 19 ] )
- {
- if ( CPANEL ) CPANEL = FALSE;
- else CPANEL = TRUE;
- }
- if ( arg_array[ 20 ] )
- {
- if ( NOFNAME ) NOFNAME = FALSE;
- else NOFNAME = TRUE;
- }
- }
-
-
- /* Clean up and die duh */
-
- void Death( int v )
- {
- if ( delwinWnd ) ClosedelwinWindow();
-
- if ( PlotWindowWnd ) ClosePlotWindowWindow();
-
- if ( Scr ) CloseDownScreen();
-
- if ( fontPtr ) CloseFont( fontPtr );
-
- FreeAllSets();
-
- if ( cli_args ) FreeArgs( cli_args );
-
- exit( v );
- }
-
-
- void main(void)
- {
- struct AnchorPath anchorpath;
-
- LONG mres;
- struct List slist;
- WORD j = NULL;
- BPTR lock;
- LONG len;
- UBYTE fault[300];
- UBYTE *environ;
-
- slist.lh_Head = (struct Node *) &slist.lh_Tail;
- slist.lh_Tail = 0;
- slist.lh_TailPred = (struct Node *) &slist.lh_Head;
- slist.lh_Type = NT_DATA;
-
- SetList = &slist;
-
- cPFont = &CPFont;
- fName = &fontName[0];
- path = Path;
-
- /* Parse envvar CPCONFIG */
-
- if (( environ = AllocVec( ENVSIZE, MEMF_CLEAR )))
- {
- len = GetVar( "CPCONFIG", environ, ENVSIZE, GVF_GLOBAL_ONLY );
- if ( len > 0 )
- {
- environ[len] = '\n';
- environ[++len] = '\0';
-
- if ((env_args = (struct RDArgs *)AllocDosObject(DOS_RDARGS, TAG_DONE)))
- {
- env_args->RDA_Source.CS_Buffer = environ;
- env_args->RDA_Source.CS_Length = len;
- env_args->RDA_Source.CS_CurChr = 0L;
-
- if( ReadArgs( envtempl, (LONG *)&env_array[ 0 ], env_args ))
- arg_array_Parse( &env_array[ 0 ] );
-
- FreeArgs( env_args );
- FreeDosObject(DOS_RDARGS, env_args);
- }
- }
- FreeVec( environ );
- }
-
- /* Read command line with ReadArgs */
-
- if ( ! ( cli_args = ReadArgs( template, &cli_array[ 0 ], 0L )))
- {
- if ( _Backstdout )
- {
- if ( Fault(IoErr(), template, fault, 300)) FPuts(_Backstdout, fault);
- Close( _Backstdout);
- }
- Death ( 1 );
- }
-
- arg_array_Parse( &cli_array[ 0 ] );
-
- if ( ! (fontPtr = OpencPFont()))
- {
- if ( _Backstdout) Close( _Backstdout);
- Death(10);
- }
-
- if ( OpenGTXScreen())
- {
- if ( _Backstdout) Close( _Backstdout);
- Death(10);
- }
-
- if ( OpenGTXWindow( OpenPlotWindowWindow ))
- {
- if ( _Backstdout) Close( _Backstdout);
- Death(10);
- }
-
- PlotWindowWnd-> RPort-> Font = fontPtr;
-
- SetPointer( PlotWindowWnd, SpriteData, SpriteHeight, 15, -1 , 0 ); /* Set pointer to spr.c image */
-
- SetRGB4( &Scr-> ViewPort, 17,7, 8,15); /* set colors for pointer */
- SetRGB4( &Scr-> ViewPort, 19,15,3,15);
-
-
- /* load files from Wild pattern */
-
- while ( files[ j ] )
- {
- if ( ! Stricmp(files[ j ], "*")) files[ j ] = "#?";
-
- mres = MatchFirst( files[ j ], &anchorpath );
-
- if ( mres == NULL )
- {
- lock = CurrentDir( anchorpath.ap_Current-> an_Lock );
- if(!chans)AddSet( anchorpath.ap_Info.fib_FileName );
- else rhp_Args( anchorpath.ap_Info.fib_FileName, chans);
- CurrentDir( lock );
-
- while( MatchNext( &anchorpath ) == NULL )
- {
- lock = CurrentDir( anchorpath.ap_Current-> an_Lock );
- if(!chans)AddSet( anchorpath.ap_Info.fib_FileName );
- else rhp_Args( anchorpath.ap_Info.fib_FileName, chans);
- CurrentDir( lock );
- }
- }
- else if ( mres == ERROR_OBJECT_NOT_FOUND )
- {
- if ( _Backstdout)
- {
- FPuts( _Backstdout, " ERROR_OBJECT_NOT_FOUND -> ");
- FPuts( _Backstdout, files[ j ]);
- FPutC ( _Backstdout, '\n');
- Close( _Backstdout);
- }
- MatchEnd( &anchorpath );
- Death ( 5 );
- }
- MatchEnd( &anchorpath );
- j++;
- }
-
- if ( chans ) FreeVec( chans );
-
- if ( _Backstdout) Close( _Backstdout); /* close output so we detache from shell */
-
- DrawView( TRUE ); /* draw everything */
-
- /* loop to monitor window events */
-
- do
- {
- Wait ( 1L << PlotWindowWnd-> UserPort-> mp_SigBit );
- }
- while ( HandlePlotWindowIDCMP() );
-
- Death(0); /* normal exit */
- }
-