static void do_file_dialog (unsigned int type) { struct FileRequester *FileRequest; struct Window *win; char buf[80]; char path[512]; const char *req_prompt; const char *req_pattern = 0; const char *req_lastdir; int req_do_save = FALSE; #ifdef __amigaos4__ int release_asl = 0; #endif if (type >= FILEDIALOG_MAX) return; if (!AslBase) { AslBase = OpenLibrary ("asl.library", 36); if (!AslBase) { write_log ("Can't open asl.library v36.\n"); return; } else { #ifdef __amigaos4__ IAsl = (struct AslIFace *) GetInterface ((struct Library *)AslBase, "main", 1, NULL); if (!IAsl) { CloseLibrary (AslBase); AslBase = 0; write_log ("Can't get asl.library interface\n"); } #endif } #ifdef __amigaos4__ } else { IAsl->Obtain (); release_asl = 1; #endif } FileRequest = AllocAslRequest (ASL_FileRequest, NULL); if (!FileRequest) { write_log ("Unable to allocate file requester.\n"); return; } /* Find this task's default window */ win = ((struct Process *) FindTask (NULL))->pr_WindowPtr; if (win == (struct Window *)-1) win = 0; /* * Prepare requester. */ switch (type) { default: /* to stop GCC complaining */ case FILEDIALOG_INSERT_DF0: case FILEDIALOG_INSERT_DF1: case FILEDIALOG_INSERT_DF2: case FILEDIALOG_INSERT_DF3: sprintf (buf, "Select image to insert in drive DF%d:", FILEDIALOG_DRIVE(type)); req_prompt = buf; req_pattern = "(#?.(ad(f|z)|dms|ipf|zip)#?|df?|?)"; req_lastdir = get_last_floppy_dir (); break; case FILEDIALOG_SAVE_STATE: req_prompt = "Select file to save emulator state to"; req_pattern = "#?.uss"; req_lastdir = get_last_savestate_dir (); req_do_save = TRUE; break; case FILEDIALOG_LOAD_STATE: req_prompt = "Select saved state file to load"; req_pattern = "#?.uss"; req_lastdir = get_last_savestate_dir (); break; } /* * Do the file request. */ if (AslRequestTags (FileRequest, ASLFR_TitleText, req_prompt, ASLFR_InitialDrawer, req_lastdir, ASLFR_InitialPattern, req_pattern, ASLFR_DoPatterns, req_pattern != 0, ASLFR_DoSaveMode, req_do_save, ASLFR_RejectIcons, TRUE, ASLFR_Window, win, TAG_DONE)) { /* * User selected a file. * * Construct file path to selected image. */ strcpy (path, FileRequest->fr_Drawer); if (strlen (path) && !(path[strlen (path) - 1] == ':' || path[strlen (path) - 1] == '/')) strcat (path, "/"); strcat (path, FileRequest->fr_File); /* * Process selected file. */ switch (type) { default: /* to stop GCC complaining */ case FILEDIALOG_INSERT_DF0: case FILEDIALOG_INSERT_DF1: case FILEDIALOG_INSERT_DF2: case FILEDIALOG_INSERT_DF3: set_last_savestate_dir (FileRequest->fr_Drawer); strcpy (changed_prefs.df[FILEDIALOG_DRIVE(type)], path); break; case FILEDIALOG_SAVE_STATE: set_last_savestate_dir (FileRequest->fr_Drawer); savestate_initsave (path, 1, 0); save_state (path, "Description"); break; case FILEDIALOG_LOAD_STATE: set_last_savestate_dir (FileRequest->fr_Drawer); savestate_initsave (path, 1, 0); savestate_state = STATE_DORESTORE; write_log ("Restoring state from '%s'...\n", path); break; } } FreeAslRequest (FileRequest); #ifdef __amigaos4__ if (release_asl) IAsl->Release (); #endif return; }
/** * Show the "about" dialog: */ void Dialog_MiscDlg(void) { int but; SDLGui_CenterDlg(miscdlg); if(currprefs.leds_on_screen==1){ miscdlg[DLGMISC_LEDON].state |= SG_SELECTED; miscdlg[DLGMISC_LEDOFF].state &= ~SG_SELECTED; } else { miscdlg[DLGMISC_LEDON].state &= ~SG_SELECTED; miscdlg[DLGMISC_LEDOFF].state |= SG_SELECTED; } miscdlg[DLGMISC_SPEED100].state &= ~SG_SELECTED; miscdlg[DLGMISC_SPEED200].state &= ~SG_SELECTED; miscdlg[DLGMISC_SPEED400].state &= ~SG_SELECTED; miscdlg[DLGMISC_SPEED800].state &= ~SG_SELECTED; switch(currprefs.floppy_speed){ case 100:miscdlg[DLGMISC_SPEED100].state |= SG_SELECTED; break; case 200:miscdlg[DLGMISC_SPEED200].state |= SG_SELECTED; break; case 400:miscdlg[DLGMISC_SPEED400].state |= SG_SELECTED; break; case 800:miscdlg[DLGMISC_SPEED800].state |= SG_SELECTED; break; } sprintf(sMaxSlot, "%3i", stateSlot); do { but=SDLGui_DoDialog(miscdlg, NULL); sprintf(thumbPath, "%sstate%03d.img\0", SAVE_PATH, stateSlot); loadthumb(thumbPath,256,300); switch(but){ case DLGMISC_INC: stateSlot++;if(stateSlot>100)stateSlot=1; sprintf(sMaxSlot, "%3i", stateSlot); break; case DLGMISC_DEC: stateSlot--;if(stateSlot<1)stateSlot=100; sprintf(sMaxSlot, "%3i", stateSlot); break; case DLGMISC_LOAD: sprintf(tmpPath, "%sstate%03d.asf\0", SAVE_PATH, stateSlot); if (fsel_file_exists(tmpPath)) { savestate_initsave (tmpPath, 0, 0, 0); //savestate_initsave (tmpPath, 1,1,1); savestate_state = STATE_DORESTORE; return; } break; case DLGMISC_SAVE: sprintf(tmpPath, "%sstate%03d.asf\0", SAVE_PATH, stateSlot); sprintf(thumbPath, "%sstate%03d.img\0", SAVE_PATH, stateSlot); dothumb(thumbPath,640,480,128,96); if (!fsel_file_exists(tmpPath)) { fsel_file_create(tmpPath); } savestate_initsave (tmpPath, 0, 0, 0); save_state (tmpPath, "puae"); //savestate_initsave (tmpPath, 1); //save_state (tmpPath, "p-uae"); break; } gui_poll_events(); } while (but != DLGMISC_EXIT && but != SDLGUI_QUIT && but != SDLGUI_ERROR && !bQuitProgram); if(miscdlg[DLGMISC_LEDON].state& SG_SELECTED){ currprefs.leds_on_screen = 1; } else if(miscdlg[DLGMISC_LEDOFF].state& SG_SELECTED){ currprefs.leds_on_screen = 0; clean_led_area(); } if(miscdlg[DLGMISC_SPEED100].state & SG_SELECTED)changed_prefs.floppy_speed=100; else if(miscdlg[DLGMISC_SPEED200].state & SG_SELECTED)changed_prefs.floppy_speed=200; else if(miscdlg[DLGMISC_SPEED400].state & SG_SELECTED)changed_prefs.floppy_speed=400; else if(miscdlg[DLGMISC_SPEED800].state & SG_SELECTED)changed_prefs.floppy_speed=800; DISK_check_change(); }