Example #1
0
/**
 * Show and process the floppy disk image dialog.
 */
void DlgFloppy_Main(void)
{
	int32_t but, i;
	char *newdisk;
	char dlgname[MAX_FLOPPYDRIVES][64], dlgdiskdir[64];

	SDLGui_CenterDlg(floppydlg);

	/* Set up dialog to actual values: */

	/* Disk name 0: */
	if(currprefs.floppyslots[1 - 1].df!=NULL)
		File_ShrinkName(dlgname[0], currprefs.floppyslots[0].df,floppydlg[FLOPPYDLG_DISKA].w);
	else
		dlgname[0][0] = '\0';

	floppydlg[FLOPPYDLG_DISKA].txt = dlgname[0];

	/* Disk name 1: */
	if(currprefs.floppyslots[2 - 1].df!=NULL)
		File_ShrinkName(dlgname[1], currprefs.floppyslots[1].df,floppydlg[FLOPPYDLG_DISKB].w);
	else
		dlgname[1][0] = '\0';
	floppydlg[FLOPPYDLG_DISKB].txt = dlgname[1];


	/* Disk name 2: */
	if(currprefs.floppyslots[3 - 1].df!=NULL)
		File_ShrinkName(dlgname[2], currprefs.floppyslots[2].df,floppydlg[FLOPPYDLG_DISK2].w);
	else
		dlgname[0][0] = '\0';

	floppydlg[FLOPPYDLG_DISK2].txt = dlgname[2];

	/* Disk name 3: */
	if(currprefs.floppyslots[4 - 1].df!=NULL)
		File_ShrinkName(dlgname[3],currprefs.floppyslots[3].df,floppydlg[FLOPPYDLG_DISK3].w);
	else
		dlgname[1][0] = '\0';
	floppydlg[FLOPPYDLG_DISK3].txt = dlgname[3];


	/* Default image directory: */
	File_ShrinkName(dlgdiskdir,szDiskImageDirectory,
	                floppydlg[FLOPPYDLG_IMGDIR].w);
	floppydlg[FLOPPYDLG_IMGDIR].txt = dlgdiskdir;


	/* Draw and process the dialog */
	do
	{
		but = SDLGui_DoDialog(floppydlg, NULL);
		switch (but)
		{
		 case FLOPPYDLG_EJECTA:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(0);
			dlgname[0][0] = '\0';

				changed_prefs.floppyslots[0].df[0] = 0;
				DISK_check_change();
				disk_eject(0);
			break;
		 case FLOPPYDLG_BROWSEA:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[0], 0, FLOPPYDLG_DISKA);

			if (strlen(szDiskFileName[0]) > 0){

					if (currprefs.nr_floppies-1 < 0 ) {
						currprefs.nr_floppies = 0  + 1;
					}

					//check whether drive is enabled
					if (currprefs.floppyslots[0].dfxtype < 0) {
						changed_prefs.floppyslots[0 ].dfxtype = 0;
						DISK_check_change();
					}
					strcpy (changed_prefs.floppyslots[0 ].df,szDiskFileName[0]);

					DISK_check_change();
					//disk_eject(0);
					//disk_insert (0, changed_prefs.floppyslots[0 ].df, false);

			}

			break;
		 case FLOPPYDLG_EJECTB:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(1);
			dlgname[1][0] = '\0';

				changed_prefs.floppyslots[1].df[0] = 0;
				DISK_check_change();
				disk_eject(1);

			break;
		case FLOPPYDLG_BROWSEB:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[1], 1, FLOPPYDLG_DISKB);
			if (strlen(szDiskFileName[1]) > 0){

					if (currprefs.nr_floppies-1 < 1 ) {
						currprefs.nr_floppies = 1  + 1;
					}

					//check whether drive is enabled
					if (currprefs.floppyslots[1].dfxtype < 0) {
						changed_prefs.floppyslots[1 ].dfxtype = 0;
						DISK_check_change();
					}
					strcpy (changed_prefs.floppyslots[1 ].df,szDiskFileName[1]);
					DISK_check_change();
			}


		 case FLOPPYDLG_EJECT2:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(2);
			dlgname[2][0] = '\0';

				changed_prefs.floppyslots[2].df[0] = 0;
				DISK_check_change();
				disk_eject(2);
			break;
		 case FLOPPYDLG_BROWSE2:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[2], 0, FLOPPYDLG_DISK2);

			if (strlen(szDiskFileName[2]) > 0){

					if (currprefs.nr_floppies-1 < 2 ) {
						currprefs.nr_floppies = 2  + 1;
					}

					//check whether drive is enabled
					if (currprefs.floppyslots[2].dfxtype < 0) {
						changed_prefs.floppyslots[2 ].dfxtype = 0;
						DISK_check_change();
					}
					strcpy (changed_prefs.floppyslots[2 ].df,szDiskFileName[2]);

					DISK_check_change();
					//disk_eject(0);
					//disk_insert (0, changed_prefs.floppyslots[0 ].df, false);

			}

			break;
		 case FLOPPYDLG_EJECT3:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(3);
			dlgname[3][0] = '\0';

				changed_prefs.floppyslots[3].df[0] = 0;
				DISK_check_change();
				disk_eject(3);

			break;
		case FLOPPYDLG_BROWSE3:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[3], 1, FLOPPYDLG_DISKB);
			if (strlen(szDiskFileName[3]) > 0){

					if (currprefs.nr_floppies-1 < 3 ) {
						currprefs.nr_floppies = 3  + 1;
					}

					//check whether drive is enabled
					if (currprefs.floppyslots[3].dfxtype < 0) {
						changed_prefs.floppyslots[3 ].dfxtype = 0;
						DISK_check_change();
					}
					strcpy (changed_prefs.floppyslots[3 ].df,szDiskFileName[3]);
					DISK_check_change();
			}

			break;
		 case FLOPPYDLG_BROWSEIMG:
			DlgDisk_BrowseDir(dlgdiskdir,
			                 /*ConfigureParams.DiskImage.*/szDiskImageDirectory,
			                 floppydlg[FLOPPYDLG_IMGDIR].w);
			break;
/*
		 case FLOPPYDLG_CREATEIMG:
			newdisk = DlgNewDisk_Main();
			if (newdisk)
			{
				DlgFloppy_QueryInsert(dlgname[0], FLOPPYDLG_DISKA,
						      dlgname[1], FLOPPYDLG_DISKB,
						      newdisk);
				free(newdisk);
			}
			break;
*/
		}
                gui_poll_events();
	}
	while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
	        && but != SDLGUI_ERROR && !bQuitProgram);



}
Example #2
0
/**
 * Show and process the floppy disk image dialog.
 */
void DlgFloppy_Main(void)
{
	int but, i;
	char *newdisk;
	char dlgname[MAX_FLOPPYDRIVES][64], dlgdiskdir[64];

	SDLGui_CenterDlg(floppydlg);

	/* Set up dialog to actual values: */
 const char *name;

 floppydlg[FLOPPYDLG_AUTORUN].state &= ~SG_SELECTED;

 name = DISKA_NAME; /* Filename */
 if (!name)dlgname[0][0] = '\0';
 else File_ShrinkName(dlgname[0], name,floppydlg[FLOPPYDLG_DISKA].w);
 floppydlg[FLOPPYDLG_DISKA].txt = dlgname[0];

 name = DISKB_NAME; /* Filename */
 if (!name)dlgname[1][0] = '\0';
 else File_ShrinkName(dlgname[1], name,floppydlg[FLOPPYDLG_DISKB].w);
 floppydlg[FLOPPYDLG_DISKB].txt = dlgname[1];

 name = TAPE_NAME; /* Filename */
 if (!name)dlgname[2][0] = '\0';
 else File_ShrinkName(dlgname[2], name,floppydlg[FLOPPYDLG_DISK2].w);
 floppydlg[FLOPPYDLG_DISK2].txt = dlgname[2];

 name = CART_NAME; /* Filename */
 if (!name)dlgname[3][0] = '\0';
 else File_ShrinkName(dlgname[3], name,floppydlg[FLOPPYDLG_DISK3].w);
 floppydlg[FLOPPYDLG_DISK3].txt = dlgname[3];

	/* Default image directory: */
	File_ShrinkName(dlgdiskdir,szDiskImageDirectory,
	                floppydlg[FLOPPYDLG_IMGDIR].w);
	floppydlg[FLOPPYDLG_IMGDIR].txt = dlgdiskdir;


	/* Draw and process the dialog */
	do
	{       
		but = SDLGui_DoDialog(floppydlg, NULL);
		switch (but)
		{
		 case FLOPPYDLG_EJECTA:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(0);
			dlgname[0][0] = '\0';
			DiskImage_RemoveDisk(0);

			break;
		 case FLOPPYDLG_BROWSEA:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[0], 0, FLOPPYDLG_DISKA);

			if (strlen(szDiskFileName[0]) > 0){

				if (GenericInterface_InsertDiskImage(0, szDiskFileName[0])) {
					printf("Error loading drivea:%s\n", szDiskFileName[0]);
				}	
				else {

					if(floppydlg[FLOPPYDLG_AUTORUN].state & SG_SELECTED){
	
						char AutoType_String[256];	
						char *pBuffer = malloc(512*5);
						int nAutoRunResult = AMSDOS_GenerateAutorunCommand(pBuffer,AutoType_String);

						if(nAutoRunResult==0){
							printf("auto(%s)\n",AutoType_String);
							AutoType_SetString(AutoType_String, TRUE, TRUE);
						}
						else printf("error auto(%d)\n",nAutoRunResult);
						free(pBuffer);
					}

					sprintf(DISKA_NAME,"%s",szDiskFileName[0]);
				}

			}

			break;
		 case FLOPPYDLG_EJECTB:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(1);
			dlgname[1][0] = '\0';
			DiskImage_RemoveDisk(1);

			break;
		case FLOPPYDLG_BROWSEB:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[1], 1, FLOPPYDLG_DISKB);

			if (strlen(szDiskFileName[1]) > 0){

				if (GenericInterface_InsertDiskImage(1, szDiskFileName[1])) {
					printf("Error loading driveb:%s\n", szDiskFileName[1]);
				}	
				else sprintf(DISKB_NAME,"%s",szDiskFileName[1]);
				
			}

		 case FLOPPYDLG_EJECT2:                         /* Eject tape  */
			Floppy_SetDiskFileNameNone(2);
			dlgname[2][0] = '\0';
			Tape_Remove();
 			sprintf(TAPE_NAME,"\0");

			break;
		 case FLOPPYDLG_BROWSE2:                        /* Choose a new tape */
			DlgDisk_BrowseDisk(dlgname[2], 2, FLOPPYDLG_DISK2);

			if (strlen(szDiskFileName[2]) > 0){

				if (GenericInterface_InsertTape(szDiskFileName[2])) {
					printf("Error loading Tape:%s\n", szDiskFileName[2]);
				}
				else {
					sprintf(TAPE_NAME,"%s",szDiskFileName[2]);
					AutoType_SetString( "|TAPE\nRUN\"\n\n", TRUE, TRUE);
				}

			}

			break;

		 case FLOPPYDLG_EJECT3:                         /* Eject cart  */
			Floppy_SetDiskFileNameNone(3);
			dlgname[3][0] = '\0';
			GenericInterface_RemoveCartridge();
 			sprintf(CART_NAME,"\0");
			break;
		case FLOPPYDLG_BROWSE3:                         /* Choose a new cart */
			DlgDisk_BrowseDisk(dlgname[3], 3, FLOPPYDLG_DISK3);

			if (strlen(szDiskFileName[3]) > 0){

				if(strcmp (szDiskFileName[3],"/home/tech/Bureau/GIT/arnold/roms/parados.rom") == 0){

					GenericInterface_LoadRom(7, szDiskFileName[3]);
					CPC_Reset();
					break;
				}

				if (GenericInterface_InsertCartridge(szDiskFileName[3])) {
					printf("Error loading cart:%s\n",szDiskFileName[3]);
				}	
				else sprintf(CART_NAME,"%s",szDiskFileName[3]);

//					strcpy(prefs->DrivePath[3], szDiskFileName[3]);
			}

			break;

		 case FLOPPYDLG_BROWSEIMG:
			DlgDisk_BrowseDir(dlgdiskdir,szDiskImageDirectory,floppydlg[FLOPPYDLG_IMGDIR].w);
			break;
/*
		 case FLOPPYDLG_CREATEIMG:
			newdisk = DlgNewDisk_Main();
			if (newdisk)
			{
				DlgFloppy_QueryInsert(dlgname[0], FLOPPYDLG_DISKA,
						      dlgname[1], FLOPPYDLG_DISKB,
						      newdisk);
				free(newdisk);
			}
			break;
*/
		}
                gui_poll_events();
	}
	while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
	        && but != SDLGUI_ERROR && !bQuitProgram);


}
Example #3
0
/**
 * Show and process the floppy disk image dialog.
 */
void DlgFloppy_Main(void)
{
	int but, i;
	char *newdisk;
	char dlgname[MAX_FLOPPYDRIVES][64], dlgdiskdir[64];

	SDLGui_CenterDlg(floppydlg);

	/* Set up dialog to actual values: */
 const char *name;

 floppydlg[FLOPPYDLG_ATTACH2FLIPLIST].state &= ~SG_SELECTED;

 name = file_system_get_disk_name(8); /* Filename */
 if (!name)dlgname[0][0] = '\0';
 else File_ShrinkName(dlgname[0], name,floppydlg[FLOPPYDLG_DISKA].w);
 floppydlg[FLOPPYDLG_DISKA].txt = dlgname[0];

 name = file_system_get_disk_name(9); /* Filename */
 if (!name)dlgname[1][0] = '\0';
 else File_ShrinkName(dlgname[1], name,floppydlg[FLOPPYDLG_DISKB].w);
 floppydlg[FLOPPYDLG_DISKB].txt = dlgname[1];

 name = file_system_get_disk_name(10); /* Filename */
 if (!name)dlgname[2][0] = '\0';
 else File_ShrinkName(dlgname[2], name,floppydlg[FLOPPYDLG_DISK2].w);
 floppydlg[FLOPPYDLG_DISK2].txt = dlgname[2];

 name = file_system_get_disk_name(11); /* Filename */
 if (!name)dlgname[3][0] = '\0';
 else File_ShrinkName(dlgname[3], name,floppydlg[FLOPPYDLG_DISK3].w);
 floppydlg[FLOPPYDLG_DISK3].txt = dlgname[3];

	/* Default image directory: */
	File_ShrinkName(dlgdiskdir,szDiskImageDirectory,
	                floppydlg[FLOPPYDLG_IMGDIR].w);
	floppydlg[FLOPPYDLG_IMGDIR].txt = dlgdiskdir;


	/* Draw and process the dialog */
	do
	{       
		but = SDLGui_DoDialog(floppydlg, NULL);
		switch (but)
		{
		 case FLOPPYDLG_EJECTA:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(0);
			dlgname[0][0] = '\0';
			file_system_detach_disk(GET_DRIVE(8));

			break;
		 case FLOPPYDLG_BROWSEA:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[0], 0, FLOPPYDLG_DISKA);

			if (strlen(szDiskFileName[0]) > 0){

			int drivetype;

			printf("load (%s)-",szDiskFileName[0]);
			resources_get_int_sprintf("Drive%iType", &drivetype, GET_DRIVE(8));
			printf("(Drive%iType)\n",drivetype);

			cartridge_detach_image(-1);
			tape_image_detach(1);
//			file_system_detach_disk(GET_DRIVE(8));

			if(File_DoesFileExtensionMatch(szDiskFileName[0],"CRT"))
				cartridge_attach_image(CARTRIDGE_CRT, szDiskFileName[0]);
			else {
//FIXME
/*
				if(File_DoesFileExtensionMatch(szDiskFileName[0],"D81") && drivetype!=1581)
						resources_set_int_sprintf("Drive%iType", 1581,  GET_DRIVE(8));
				else if (drivetype!=1542 && !File_DoesFileExtensionMatch(szDiskFileName[0],"D81"))
						resources_set_int_sprintf("Drive%iType", 1542,  GET_DRIVE(8));
*/			

				if (floppydlg[FLOPPYDLG_ATTACH2FLIPLIST].state & SG_SELECTED){
					file_system_detach_disk(GET_DRIVE(8));
					printf("Attach to flip list\n");
					file_system_attach_disk(8, szDiskFileName[0]);
					fliplist_add_image(8)	;
				}
				else {
					printf("autostart\n");
					autostart_autodetect(szDiskFileName[0], NULL, 0, AUTOSTART_MODE_RUN);
				}

			}

			}

			break;
		 case FLOPPYDLG_EJECTB:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(1);
			dlgname[1][0] = '\0';
			file_system_detach_disk(GET_DRIVE(9));

			break;
		case FLOPPYDLG_BROWSEB:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[1], 1, FLOPPYDLG_DISKB);

			if (strlen(szDiskFileName[1]) > 0){
				
			file_system_detach_disk(GET_DRIVE(9));
     		file_system_attach_disk(9, szDiskFileName[1]);
	
			}

		 case FLOPPYDLG_EJECT2:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(2);
			dlgname[2][0] = '\0';
			file_system_detach_disk(GET_DRIVE(10));
			break;
		 case FLOPPYDLG_BROWSE2:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[2], 0, FLOPPYDLG_DISK2);

			if (strlen(szDiskFileName[2]) > 0){
					//strcpy(prefs->DrivePath[2], szDiskFileName[2]);
			}

			break;
		 case FLOPPYDLG_EJECT3:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(3);
			dlgname[3][0] = '\0';
			file_system_detach_disk(GET_DRIVE(11));
			break;
		case FLOPPYDLG_BROWSE3:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[3], 1, FLOPPYDLG_DISKB);

			if (strlen(szDiskFileName[3]) > 0){

//					strcpy(prefs->DrivePath[3], szDiskFileName[3]);
			}

			break;
		 case FLOPPYDLG_BROWSEIMG:
			DlgDisk_BrowseDir(dlgdiskdir,szDiskImageDirectory,floppydlg[FLOPPYDLG_IMGDIR].w);
			break;
/*
		 case FLOPPYDLG_CREATEIMG:
			newdisk = DlgNewDisk_Main();
			if (newdisk)
			{
				DlgFloppy_QueryInsert(dlgname[0], FLOPPYDLG_DISKA,
						      dlgname[1], FLOPPYDLG_DISKB,
						      newdisk);
				free(newdisk);
			}
			break;
*/
		}
                gui_poll_events();
	}
	while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
	        && but != SDLGUI_ERROR && !bQuitProgram);

/*
	if (floppydlg[FLOPPYDLG_AUTOSTART].state & SG_SELECTED){

			if(!ThePrefs.Emul1541Proc){
					prefs->Emul1541Proc = !prefs->Emul1541Proc;
			}
	}
	else {
			if(ThePrefs.Emul1541Proc){
					prefs->Emul1541Proc = !prefs->Emul1541Proc;
			}	

	}
*/

}