home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
dicepj11.lha
/
diceproject
/
options.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-12
|
13KB
|
521 lines
#include <exec/types.h>
#include <libraries/asl.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/gadtools_protos.h>
#include <clib/asl_protos.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/graphics_protos.h>
#include <stdlib.h>
#include <string.h>
#include "project.h"
extern BOOL done,saved;
extern AttachList( void );
extern DettachList( void );
struct CompilerOpts Config = {
CPU30,FPU82,
SMALL,SMALL,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
REGARG,
FALSE,
0
};
char *OptLine;
char *OptFile;
char *DICEDir;
char *SourceDir;
char *DestDir;
char *IncludeDir;
char *LibDir;
char *ObjDir;
ULONG DisplayScreen = PAL_MONITOR_ID|HIRESLACE_KEY;
struct CompilerOpts Config2;
void MakeOptions( void ) {
char temp[70];
strcpy( temp , " -2.0" );
switch( Config.CPU ) {
case 1:
strcat( temp , " -020" );
break;
case 2:
strcat( temp , " -030" );
break;
}
switch( Config.FPU ) {
case 1:
strcat( temp , " -881" );
break;
case 2:
strcat( temp , " -882" );
break;
}
if ( Config.Data == SMALL )
strcat( temp , " -md" );
else
strcat( temp , " -mD" );
if ( Config.Code == SMALL )
strcat( temp , " -mc" );
else
strcat( temp , " -mC" );
if ( Config.RCalls == REGARG )
strcat( temp , " -mRR" );
if ( Config.ICalls )
strcat( temp , " -mi" );
if ( Config.Resident )
strcat( temp , " -r" );
if ( Config.DStack )
strcat( temp , " -gs" );
if ( Config.Chip )
strcat( temp , " -chip" );
if ( Config.Hunk )
strcat( temp , " -pi" );
if ( Config.DebugI )
strcat( temp , " -s" );
if ( Config.DebugL )
strcat( temp , " -d1" );
switch( Config.HunkCode ) {
case 1:
strcat( temp , " -ms" );
break;
case 2:
strcat( temp , " -ms2" );
break;
}
ReplaceChar( &OptLine , temp );
}
/****************************************************************************
*** ***
*** Actions des boutons de la fenêtre DirSet ***
*** ***
****************************************************************************/
int SourceClicked( void )
{
struct FileRequester *fr;
struct ModuleNode *wn=ModuleList->lh_Head;
if (fr = AskDirectory( "Select sources path" , SourceDir )) {
ReplaceChar( &SourceDir , fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)SourceDir;
GT_SetGadgetAttrsA( DirSetGadgets[6] , DirSetWnd , NULL , ttag );
}
}
int DestClicked( void )
{
struct FileRequester *fr;
if (fr = AskDirectory( "Select destination path" , DestDir )) {
ReplaceChar( &DestDir , fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)DestDir;
GT_SetGadgetAttrsA( DirSetGadgets[7] , DirSetWnd , NULL , ttag );
}
}
int IncludeClicked( void )
{
struct FileRequester *fr;
if (fr = AskDirectory( "Select includes path" , IncludeDir )) {
ReplaceChar( &IncludeDir , fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)IncludeDir;
GT_SetGadgetAttrsA( DirSetGadgets[8] , DirSetWnd , NULL , ttag );
}
}
int LibClicked( void )
{
struct FileRequester *fr;
if (fr = AskDirectory( "Select libraries path" , LibDir )) {
ReplaceChar( &LibDir , fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)LibDir;
GT_SetGadgetAttrsA( DirSetGadgets[9] , DirSetWnd , NULL , ttag );
}
}
int ObjClicked( void )
{
struct FileRequester *fr;
if (fr = AskDirectory( "Select objects path" , ObjDir )) {
ReplaceChar( &ObjDir , fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)ObjDir;
GT_SetGadgetAttrsA( DirSetGadgets[10] , DirSetWnd , NULL , ttag );
}
}
int PrgClicked( void )
{
struct FileRequester *fr;
if (fr = AskDirectory( "Select objects path" , DICEDir )) {
ChangeDICEDir( fr->rf_Dir );
FreeAslRequest(fr);
ttag[0].ti_Data = (long)DICEDir;
GT_SetGadgetAttrsA( DirSetGadgets[11] , DirSetWnd , NULL , ttag );
}
}
/****************************************************************************
*** ***
*** Action des boutons de la fenêtre d'options de compilation ***
*** ***
****************************************************************************/
int RelocClicked( void )
{
if ( CompilerOptGadgets[0]->Flags & GFLG_SELECTED )
Config2.Hunk = TRUE;
else
Config2.Hunk = FALSE;
}
int ResidentClicked( void )
{
if ( CompilerOptGadgets[1]->Flags & GFLG_SELECTED )
Config2.Resident = TRUE;
else
Config2.Resident = FALSE;
}
int DInfoClicked( void )
{
if ( CompilerOptGadgets[2]->Flags & GFLG_SELECTED )
Config2.DebugI = TRUE;
else
Config2.DebugI = FALSE;
}
int DLevelClicked( void )
{
if ( CompilerOptGadgets[3]->Flags & GFLG_SELECTED )
Config2.DebugL = TRUE;
else
Config2.DebugL = FALSE;
}
int StackClicked( void )
{
if ( CompilerOptGadgets[4]->Flags & GFLG_SELECTED )
Config2.DStack = TRUE;
else
Config2.DStack = FALSE;
}
int ChipClicked( void )
{
if ( CompilerOptGadgets[5]->Flags & GFLG_SELECTED )
Config2.Chip = TRUE;
else
Config2.Chip = FALSE;
}
int CPUClicked( void )
{
Config2.CPU = CompilerOptMsg.Code;
}
int FPUClicked( void )
{
Config2.FPU = CompilerOptMsg.Code;
}
int DataClicked( void )
{
Config2.Data = CompilerOptMsg.Code;
}
int CodeClicked( void )
{
Config2.Code = CompilerOptMsg.Code;
}
int CallsClicked( void )
{
Config2.RCalls = CompilerOptMsg.Code;
}
int InlineClicked( void )
{
if ( CompilerOptGadgets[11]->Flags & GFLG_SELECTED )
Config2.ICalls = TRUE;
else
Config2.ICalls = FALSE;
}
int HunkClicked( void )
{
Config2.HunkCode = CompilerOptMsg.Code;
}
int ProjectDirectory( void )
{
char *SSource,*SDest,*SInclude,*SLib,*SObj,*SDICE;
SSource = strdup( SourceDir );
SDest = strdup( DestDir );
SInclude = strdup( IncludeDir );
SLib = strdup( LibDir );
SObj = strdup( ObjDir );
SDICE = strdup( DICEDir );
if ( !OpenDirSetWindow( ) ) {
ttag[0].ti_Data = (long)SourceDir;
GT_SetGadgetAttrsA( DirSetGadgets[6] , DirSetWnd , NULL , ttag );
ttag[0].ti_Data = (long)DestDir;
GT_SetGadgetAttrsA( DirSetGadgets[7] , DirSetWnd , NULL , ttag );
ttag[0].ti_Data = (long)IncludeDir;
GT_SetGadgetAttrsA( DirSetGadgets[8] , DirSetWnd , NULL , ttag );
ttag[0].ti_Data = (long)LibDir;
GT_SetGadgetAttrsA( DirSetGadgets[9] , DirSetWnd , NULL , ttag );
ttag[0].ti_Data = (long)ObjDir;
GT_SetGadgetAttrsA( DirSetGadgets[10] , DirSetWnd , NULL , ttag );
ttag[0].ti_Data = (long)DICEDir;
GT_SetGadgetAttrsA( DirSetGadgets[11] , DirSetWnd , NULL , ttag );
while ( !done ) {
Wait( 1 << DirSetWnd->UserPort->mp_SigBit );
HandleDirSetIDCMP( );
}
done = FALSE;
CloseDirSetWindow( );
RemoveAssign( );
MakeAssign( );
UpdateNameList( );
if ( strcmp( SSource , SourceDir ) || strcmp( SDest , DestDir ) ||
strcmp( SInclude , IncludeDir ) || strcmp( SLib , LibDir ) ||
strcmp( SObj , ObjDir ) || strcmp( SDICE , DICEDir ) )
saved = FALSE;
}
free( SSource );
free( SDest );
free( SInclude );
free( SLib );
free( SObj );
free( SDICE );
}
int ProjectCompilerOpt( void )
{
struct TagItem CheckTag[] = { GTCB_Checked , 0 , TAG_DONE };
struct TagItem MXTag[] = { GTMX_Active , 0 , TAG_DONE };
if ( !OpenCompilerOptWindow( ) ) {
memcpy( &Config2 , &Config , sizeof( struct CompilerOpts ) );
CheckTag[0].ti_Data = (long)Config2.Hunk;
GT_SetGadgetAttrsA( CompilerOptGadgets[0] , CompilerOptWnd , NULL , CheckTag );
CheckTag[0].ti_Data = (long)Config2.Resident;
GT_SetGadgetAttrsA( CompilerOptGadgets[1] , CompilerOptWnd , NULL , CheckTag );
MXTag[0].ti_Data = (long)Config2.HunkCode;
GT_SetGadgetAttrsA( CompilerOptGadgets[12] , CompilerOptWnd , NULL , MXTag );
CheckTag[0].ti_Data = (long)Config2.ICalls;
GT_SetGadgetAttrsA( CompilerOptGadgets[11] , CompilerOptWnd , NULL , CheckTag );
MXTag[0].ti_Data = (long)Config2.RCalls;
GT_SetGadgetAttrsA( CompilerOptGadgets[10] , CompilerOptWnd , NULL , MXTag );
MXTag[0].ti_Data = (long)Config2.Code;
GT_SetGadgetAttrsA( CompilerOptGadgets[9] , CompilerOptWnd , NULL , MXTag );
MXTag[0].ti_Data = (long)Config2.Data;
GT_SetGadgetAttrsA( CompilerOptGadgets[8] , CompilerOptWnd , NULL , MXTag );
MXTag[0].ti_Data = (long)Config2.FPU;
GT_SetGadgetAttrsA( CompilerOptGadgets[7] , CompilerOptWnd , NULL , MXTag );
MXTag[0].ti_Data = (long)Config2.CPU;
GT_SetGadgetAttrsA( CompilerOptGadgets[6] , CompilerOptWnd , NULL , MXTag );
CheckTag[0].ti_Data = (long)Config2.Chip;
GT_SetGadgetAttrsA( CompilerOptGadgets[5] , CompilerOptWnd , NULL , CheckTag );
CheckTag[0].ti_Data = (long)Config2.DStack;
GT_SetGadgetAttrsA( CompilerOptGadgets[4] , CompilerOptWnd , NULL , CheckTag );
CheckTag[0].ti_Data = (long)Config2.DebugL;
GT_SetGadgetAttrsA( CompilerOptGadgets[3] , CompilerOptWnd , NULL , CheckTag );
CheckTag[0].ti_Data = (long)Config2.DebugI;
GT_SetGadgetAttrsA( CompilerOptGadgets[2] , CompilerOptWnd , NULL , CheckTag );
while( !done ) {
Wait( 1 << CompilerOptWnd->UserPort->mp_SigBit );
HandleCompilerOptIDCMP( );
}
CloseCompilerOptWindow( );
done = FALSE;
if ( memcmp( &Config , &Config2 , sizeof( struct CompilerOpts ) ) )
saved = FALSE;
memcpy( &Config , &Config2 , sizeof( struct CompilerOpts ) );
MakeOptions( );
}
}
struct ScreenNode {
struct Node node;
char *name;
ULONG ID;
};
void FreeScrList( struct List *ScrList ) {
struct ScreenNode *mn,*on;
if ( ScrList ) {
mn = ScrList->lh_Head;
while( on = mn->node.ln_Succ ) {
free( mn->name );
Remove( (struct Node *)mn );
free( mn );
mn = on;
}
ScrList = NULL;
}
}
void AddScrList( struct List *ScrList , char *name , ULONG ID ) {
struct ScreenNode *mn = malloc( sizeof(struct ScreenNode) );
if ( FindName( ScrList , name ) )
return;
mn->name = strdup( name );
mn->ID = ID;
mn->node.ln_Name = mn->name;
AddTail( ScrList , (struct Node *)mn );
}
void UpdateScreen( void ) {
DettachList( );
MessCloseWindow( );
CloseProjectWindow( );
CloseDownScreen( );
SetupScreen( );
OpenProjectWindow( );
ChangeProjectName( ProjectPathName );
AttachList( );
}
int ProjectScreenOpt( void )
{
ULONG DisplayID=INVALID_ID;
struct List ScreenList;
struct ScreenNode *node;
char buf[200];
ULONG OldDispID = DisplayScreen;
NewList( &ScreenList );
do {
DisplayID = NextDisplayInfo( DisplayID );
if ( GetDisplayInfoData( NULL , buf , 200 , DTAG_NAME , DisplayID ) )
AddScrList( &ScreenList , &buf[16] , DisplayID );
} while( DisplayID != INVALID_ID );
if ( node = ChooseInList( "Select Display Mode :" , &ScreenList ) ) {
DisplayScreen = node->ID;
if ( DisplayScreen != OldDispID ) {
UpdateScreen( );
saved = FALSE;
}
}
FreeScrList( &ScreenList );
}
BOOL VerifPrj( char *prj , char *ct , FILE *in ) {
char name[200];;
InputString( name , 200 , in );
if ( strcmp( name , ct ) ) {
strcpy( name , "File " );
strcat( name , BaseName( prj ) );
strcat( name , " is not a project file !" );
Message( ProjectWnd , name , "OK" );
return( FALSE );
}
return( TRUE );
}
BOOL LoadOptions( char *pf , FILE *fin ) {
char name[201];
if ( VerifPrj( pf , "%PROJECTFILE%" , fin ) ) {
if ( VerifPrj( pf , "%SCREEN%" , fin ) ) {
fread( &DisplayScreen , 4 , 1 , fin );
if ( VerifPrj( pf , "%OPTS%" , fin ) ) {
fread( &Config , sizeof(struct CompilerOpts) , 1 , fin );
MakeOptions( );
if ( VerifPrj( pf , "%DIRS%" , fin ) ) {
InputString( name , 200 , fin );
ChangeDICEDir( name );
InputString( name , 200 , fin );
ReplaceChar( &SourceDir , name );
InputString( name , 200 , fin );
ReplaceChar( &DestDir , name );
InputString( name , 200 , fin );
ReplaceChar( &IncludeDir , name );
InputString( name , 200 , fin );
ReplaceChar( &LibDir , name );
InputString( name , 200 , fin );
ReplaceChar( &ObjDir , name );
return( TRUE );
}
}
}
}
return( FALSE );
}
void SaveOptions( FILE *fout ) {
fputs( "%PROJECTFILE%\n" , fout );
fputs( "%SCREEN%\n" , fout );
fwrite( &DisplayScreen , 4 , 1 , fout );
fputs( "%OPTS%\n" , fout );
fwrite( &Config , sizeof(struct CompilerOpts) , 1 , fout );
fputs( "%DIRS%\n" , fout );
OutputString( DICEDir , fout );
OutputString( SourceDir , fout );
OutputString( DestDir , fout );
OutputString( IncludeDir , fout );
OutputString( LibDir , fout );
OutputString( ObjDir , fout );
}
void LoadPrefs( void )
{
FILE *in;
if ( in=fopen("ENV:project.prefs","r") ) {
LoadOptions( "ENV:project.prefs" , in );
fclose( in );
}
}
void SavePrefs( void )
{
FILE *out;
if ( out=fopen("ENVARC:project.prefs","w") ) {
SaveOptions( out );
fclose( out );
}
if ( out=fopen("ENV:project.prefs","w") ) {
SaveOptions( out );
fclose( out );
}
}