--- hatari/src/gui-sdl/dlgDisc.c 2019/04/01 07:11:38 1.1 +++ hatari/src/gui-sdl/dlgDisc.c 2019/04/01 07:12:22 1.1.1.2 @@ -4,13 +4,12 @@ This file is distributed under the GNU Public License, version 2 or at your option any later version. Read the file gpl.txt for details. */ -char DlgDisc_rcsid[] = "Hatari $Id: dlgDisc.c,v 1.1 2019/04/01 07:11:38 root Exp $"; +char DlgDisc_rcsid[] = "Hatari $Id: dlgDisc.c,v 1.1.1.2 2019/04/01 07:12:22 root Exp $"; #include "main.h" #include "configuration.h" #include "dialog.h" #include "sdlgui.h" -#include "memAlloc.h" #include "file.h" #include "floppy.h" #include "gemdos.h" @@ -27,21 +26,25 @@ char DlgDisc_rcsid[] = "Hatari $Id: dlgD #define DISCDLG_BROWSEIMG 13 #define DISCDLG_AUTOB 14 #define DISCDLG_CREATEIMG 15 -#define DISCDLG_EJECTHDIMG 19 -#define DISCDLG_BROWSEHDIMG 20 -#define DISCDLG_DISCHDIMG 21 -#define DISCDLG_UNMOUNTGDOS 23 -#define DISCDLG_BROWSEGDOS 24 -#define DISCDLG_DISCGDOS 25 -#define DISCDLG_BOOTHD 26 -#define DISCDLG_EXIT 27 +#define DISCDLG_PROTOFF 17 +#define DISCDLG_PROTON 18 +#define DISCDLG_PROTAUTO 19 +#define DISCDLG_EJECTHDIMG 23 +#define DISCDLG_BROWSEHDIMG 24 +#define DISCDLG_DISCHDIMG 25 +#define DISCDLG_UNMOUNTGDOS 27 +#define DISCDLG_BROWSEGDOS 28 +#define DISCDLG_DISCGDOS 29 +#define DISCDLG_BOOTHD 30 +#define DISCDLG_EXIT 31 /* The discs dialog: */ static SGOBJ discdlg[] = { { SGBOX, 0, 0, 0,0, 64,25, NULL }, - { SGBOX, 0, 0, 1,1, 62,11, NULL }, + + { SGBOX, 0, 0, 1,1, 62,12, NULL }, { SGTEXT, 0, 0, 25,1, 12,1, "Floppy discs" }, { SGTEXT, 0, 0, 2,2, 8,1, "Drive A:" }, { SGBUTTON, 0, 0, 46,2, 7,1, "Eject" }, @@ -51,22 +54,28 @@ static SGOBJ discdlg[] = { SGBUTTON, 0, 0, 46,4, 7,1, "Eject" }, { SGBUTTON, 0, 0, 54,4, 8,1, "Browse" }, { SGTEXT, 0, 0, 3,5, 58,1, NULL }, - { SGTEXT, 0, 0, 2,7, 30,1, "Default disk images directory:" }, + { SGTEXT, 0, 0, 2,7, 32,1, "Default floppy images directory:" }, { SGTEXT, 0, 0, 3,8, 58,1, NULL }, { SGBUTTON, 0, 0, 54,7, 8,1, "Browse" }, { SGCHECKBOX, 0, 0, 2,10, 16,1, "Auto insert B" }, { SGBUTTON, 0, 0, 42,10, 20,1, "Create blank image" }, - { SGBOX, 0, 0, 1,13, 62,9, NULL }, - { SGTEXT, 0, 0, 27,13, 10,1, "Hard discs" }, - { SGTEXT, 0, 0, 2,14, 9,1, "HD image:" }, - { SGBUTTON, 0, 0, 46,14, 7,1, "Eject" }, - { SGBUTTON, 0, 0, 54,14, 8,1, "Browse" }, - { SGTEXT, 0, 0, 3,15, 58,1, NULL }, + { SGTEXT, 0, 0, 2,12, 17,1, "Write protection:" }, + { SGRADIOBUT, 0, 0, 21,12, 5,1, "Off" }, + { SGRADIOBUT, 0, 0, 28,12, 5,1, "On" }, + { SGRADIOBUT, 0, 0, 34,12, 6,1, "Auto" }, + + { SGBOX, 0, 0, 1,14, 62,8, NULL }, + { SGTEXT, 0, 0, 27,14, 10,1, "Hard discs" }, + { SGTEXT, 0, 0, 2,15, 9,1, "HD image:" }, + { SGBUTTON, 0, 0, 46,15, 7,1, "Eject" }, + { SGBUTTON, 0, 0, 54,15, 8,1, "Browse" }, + { SGTEXT, 0, 0, 3,16, 58,1, NULL }, { SGTEXT, 0, 0, 2,17, 13,1, "GEMDOS drive:" }, { SGBUTTON, 0, 0, 46,17, 7,1, "Eject" }, { SGBUTTON, 0, 0, 54,17, 8,1, "Browse" }, { SGTEXT, 0, 0, 3,18, 58,1, NULL }, { SGCHECKBOX, 0, 0, 2,20, 14,1, "Boot from HD" }, + { SGBUTTON, 0, 0, 22,23, 20,1, "Back to main menu" }, { -1, 0, 0, 0,0, 0,0, NULL } }; @@ -78,14 +87,19 @@ static SGOBJ discdlg[] = */ void Dialog_DiscDlg(void) { - int but; + int but, i; char dlgnamea[64], dlgnameb[64], dlgdiscdir[64]; char dlgnamegdos[64], dlgnamehdimg[64]; char *tmpname; char *zip_path; /* Allocate memory for tmpname and zip_path: */ - tmpname = Memory_Alloc(2 * FILENAME_MAX); + tmpname = malloc(2 * FILENAME_MAX); + if (!tmpname) + { + perror("Dialog_DiscDlg"); + return; + } zip_path = tmpname + FILENAME_MAX; zip_path[0] = 0; @@ -112,11 +126,18 @@ void Dialog_DiscDlg(void) discdlg[DISCDLG_IMGDIR].txt = dlgdiscdir; /* Auto insert disc B: */ - if( DialogParams.DiscImage.bAutoInsertDiscB ) + if (DialogParams.DiscImage.bAutoInsertDiscB) discdlg[DISCDLG_AUTOB].state |= SG_SELECTED; - else + else discdlg[DISCDLG_AUTOB].state &= ~SG_SELECTED; + /* Write protection */ + for (i = DISCDLG_PROTOFF; i <= DISCDLG_PROTAUTO; i++) + { + discdlg[i].state &= ~SG_SELECTED; + } + discdlg[DISCDLG_PROTOFF+DialogParams.DiscImage.nWriteProtection].state |= SG_SELECTED; + /* Boot from harddisk? */ if( DialogParams.HardDisc.bBootFromHardDisc ) discdlg[DISCDLG_BOOTHD].state |= SG_SELECTED; @@ -141,7 +162,7 @@ void Dialog_DiscDlg(void) /* Draw and process the dialog */ do { - but = SDLGui_DoDialog(discdlg); + but = SDLGui_DoDialog(discdlg, NULL); switch(but) { case DISCDLG_EJECTA: /* Eject disc in drive A: */ @@ -217,6 +238,7 @@ void Dialog_DiscDlg(void) ptr = strrchr(tmpname, '/'); if( ptr!=NULL ) ptr[1]=0; /* Remove file name from path */ strcpy(DialogParams.HardDisc.szHardDiscDirectories[0], tmpname); + File_CleanFileName(DialogParams.HardDisc.szHardDiscDirectories[0]); File_ShrinkName(dlgnamegdos, DialogParams.HardDisc.szHardDiscDirectories[0], discdlg[DISCDLG_DISCGDOS].w); } break; @@ -243,11 +265,21 @@ void Dialog_DiscDlg(void) break; } } - while(but!=DISCDLG_EXIT && !bQuitProgram); + while (but!=DISCDLG_EXIT && but != SDLGUI_QUIT && !bQuitProgram); + + /* Read values from dialog: */ + + for (i = DISCDLG_PROTOFF; i <= DISCDLG_PROTAUTO; i++) + { + if (discdlg[i].state & SG_SELECTED) + { + DialogParams.DiscImage.nWriteProtection = i-DISCDLG_PROTOFF; + break; + } + } - /* Read values from dialog */ DialogParams.DiscImage.bAutoInsertDiscB = (discdlg[DISCDLG_AUTOB].state & SG_SELECTED); DialogParams.HardDisc.bBootFromHardDisc = (discdlg[DISCDLG_BOOTHD].state & SG_SELECTED); - Memory_Free(tmpname); + free(tmpname); }