/** * Let user browse given disk, insert disk if one selected. */ static void DlgDisk_BrowseDisk(char *dlgname, int drive, int diskid) { char *selname, *zip_path; const char *tmpname, *realname; assert(drive >= 0 && drive < MAX_FLOPPYDRIVES); if (szDiskFileName[drive][0]) tmpname = szDiskFileName[drive]; else tmpname = szDiskImageDirectory; selname = SDLGui_FileSelect(tmpname, &zip_path, false); if (!selname) return; printf("in)d%d:(%s)\n",drive,selname); if (File_Exists(selname)) {printf("----------Exist)\n"); realname = Floppy_SetDiskFileName(drive, selname, zip_path); if (realname) File_ShrinkName(dlgname, realname, floppydlg[diskid].w); } else {printf("---------not found\n"); Floppy_SetDiskFileNameNone(drive); dlgname[0] = '\0'; } if (zip_path) free(zip_path); free(selname); }
/** * Set given floppy drive image file name and handle * different image extensions. * Return corrected file name on success and NULL on failure. */ const char* Floppy_SetDiskFileName(int Drive, const char *pszFileName, const char *pszZipPath) { char *filename; int i; /* setting to empty or "none" ejects */ if (!*pszFileName || strcasecmp(pszFileName, "none") == 0) { return Floppy_SetDiskFileNameNone(Drive); } /* See if file exists, and if not, get/add correct extension */ if (!File_Exists(pszFileName)) filename = File_FindPossibleExtFileName(pszFileName, pszDiskImageNameExts); else filename = strdup(pszFileName); if (!filename) { Log_AlertDlg((const char *)LOG_INFO, "Image '%s' not found", pszFileName); return NULL; } #if 0 /* If we insert a disk into Drive A, should we try to put disk 2 into drive B? */ if (Drive == 0 && ConfigureParams.DiskImage.bAutoInsertDiskB) { /* Attempt to make up second filename, eg was 'auto_100a' to 'auto_100b' */ char *szDiskBFileName = Floppy_CreateDiskBFileName(filename); if (szDiskBFileName) { /* recurse with Drive B */ Floppy_SetDiskFileName(1, szDiskBFileName, pszZipPath); free(szDiskBFileName); } } #endif /* validity checks */ assert(Drive >= 0 && Drive < MAX_FLOPPYDRIVES); for (i = 0; i < MAX_FLOPPYDRIVES; i++) { if (i == Drive) continue; /* prevent inserting same image to multiple drives */ if (strcmp(filename, /*ConfigureParams.DiskImage.*/szDiskFileName[i]) == 0) { Log_AlertDlg((const char *)LOG_ERROR, "ERROR: Cannot insert same floppy to multiple drives!"); return NULL; } } /* do the changes */ if (pszZipPath) strcpy(szDiskZipPath[Drive], pszZipPath); else szDiskZipPath[Drive][0] = '\0'; strcpy(szDiskFileName[Drive], filename); free(filename); //File_MakeAbsoluteName(ConfigureParams.DiskImage.szDiskFileName[Drive]); return szDiskFileName[Drive]; }
/** * Shorcut to load a disk image */ static void ShortCut_InsertDisk(int drive) { char *selname, *zip_path = NULL; const char *tmpname; char FileNameB[ FILENAME_MAX ]; char ZipPathB[ FILENAME_MAX ]; if (SDLGui_SetScreen(sdlscrn)) return; /* Save current names for drive 1 before checking autoinsert */ strcpy ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] ); strcpy ( ZipPathB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] ); if (ConfigureParams.DiskImage.szDiskFileName[drive][0]) tmpname = ConfigureParams.DiskImage.szDiskFileName[drive]; else tmpname = ConfigureParams.DiskImage.szDiskImageDirectory; Main_PauseEmulation(true); selname = SDLGui_FileSelect("Floppy image:", tmpname, &zip_path, false); if (selname) { if (File_Exists(selname)) Floppy_SetDiskFileName(drive, selname, zip_path); else Floppy_SetDiskFileNameNone(drive); if (zip_path) free(zip_path); free(selname); Floppy_InsertDiskIntoDrive(0); /* Check if inserting into drive 0 also changed drive 1 with autoinsert */ if ( ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskFileName[ 1 ] ) != 0 ) || ( strcmp ( FileNameB , ConfigureParams.DiskImage.szDiskZipPath[ 1 ] ) != 0 ) ) Floppy_InsertDiskIntoDrive(1); } Main_UnPauseEmulation(); }
/** * 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); }
/** * 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); }
/** * 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; } } */ }