|
|
1.1 ! root 1: /* ! 2: Hatari - dlgDisc.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. ! 6: */ ! 7: char DlgDisc_rcsid[] = "Hatari $Id: dlgDisc.c,v 1.7 2004/07/05 15:38:36 thothy Exp $"; ! 8: ! 9: #include "main.h" ! 10: #include "configuration.h" ! 11: #include "dialog.h" ! 12: #include "sdlgui.h" ! 13: #include "memAlloc.h" ! 14: #include "file.h" ! 15: #include "floppy.h" ! 16: #include "gemdos.h" ! 17: #include "hdc.h" ! 18: ! 19: ! 20: #define DISCDLG_EJECTA 4 ! 21: #define DISCDLG_BROWSEA 5 ! 22: #define DISCDLG_DISCA 6 ! 23: #define DISCDLG_EJECTB 8 ! 24: #define DISCDLG_BROWSEB 9 ! 25: #define DISCDLG_DISCB 10 ! 26: #define DISCDLG_IMGDIR 12 ! 27: #define DISCDLG_BROWSEIMG 13 ! 28: #define DISCDLG_AUTOB 14 ! 29: #define DISCDLG_CREATEIMG 15 ! 30: #define DISCDLG_EJECTHDIMG 19 ! 31: #define DISCDLG_BROWSEHDIMG 20 ! 32: #define DISCDLG_DISCHDIMG 21 ! 33: #define DISCDLG_UNMOUNTGDOS 23 ! 34: #define DISCDLG_BROWSEGDOS 24 ! 35: #define DISCDLG_DISCGDOS 25 ! 36: #define DISCDLG_BOOTHD 26 ! 37: #define DISCDLG_EXIT 27 ! 38: ! 39: ! 40: /* The discs dialog: */ ! 41: static SGOBJ discdlg[] = ! 42: { ! 43: { SGBOX, 0, 0, 0,0, 64,25, NULL }, ! 44: { SGBOX, 0, 0, 1,1, 62,11, NULL }, ! 45: { SGTEXT, 0, 0, 25,1, 12,1, "Floppy discs" }, ! 46: { SGTEXT, 0, 0, 2,2, 8,1, "Drive A:" }, ! 47: { SGBUTTON, 0, 0, 46,2, 7,1, "Eject" }, ! 48: { SGBUTTON, 0, 0, 54,2, 8,1, "Browse" }, ! 49: { SGTEXT, 0, 0, 3,3, 58,1, NULL }, ! 50: { SGTEXT, 0, 0, 2,4, 8,1, "Drive B:" }, ! 51: { SGBUTTON, 0, 0, 46,4, 7,1, "Eject" }, ! 52: { SGBUTTON, 0, 0, 54,4, 8,1, "Browse" }, ! 53: { SGTEXT, 0, 0, 3,5, 58,1, NULL }, ! 54: { SGTEXT, 0, 0, 2,7, 30,1, "Default disk images directory:" }, ! 55: { SGTEXT, 0, 0, 3,8, 58,1, NULL }, ! 56: { SGBUTTON, 0, 0, 54,7, 8,1, "Browse" }, ! 57: { SGCHECKBOX, 0, 0, 2,10, 16,1, "Auto insert B" }, ! 58: { SGBUTTON, 0, 0, 42,10, 20,1, "Create blank image" }, ! 59: { SGBOX, 0, 0, 1,13, 62,9, NULL }, ! 60: { SGTEXT, 0, 0, 27,13, 10,1, "Hard discs" }, ! 61: { SGTEXT, 0, 0, 2,14, 9,1, "HD image:" }, ! 62: { SGBUTTON, 0, 0, 46,14, 7,1, "Eject" }, ! 63: { SGBUTTON, 0, 0, 54,14, 8,1, "Browse" }, ! 64: { SGTEXT, 0, 0, 3,15, 58,1, NULL }, ! 65: { SGTEXT, 0, 0, 2,17, 13,1, "GEMDOS drive:" }, ! 66: { SGBUTTON, 0, 0, 46,17, 7,1, "Eject" }, ! 67: { SGBUTTON, 0, 0, 54,17, 8,1, "Browse" }, ! 68: { SGTEXT, 0, 0, 3,18, 58,1, NULL }, ! 69: { SGCHECKBOX, 0, 0, 2,20, 14,1, "Boot from HD" }, ! 70: { SGBUTTON, 0, 0, 22,23, 20,1, "Back to main menu" }, ! 71: { -1, 0, 0, 0,0, 0,0, NULL } ! 72: }; ! 73: ! 74: ! 75: /*-----------------------------------------------------------------------*/ ! 76: /* ! 77: Show and process the disc image dialog. ! 78: */ ! 79: void Dialog_DiscDlg(void) ! 80: { ! 81: int but; ! 82: char dlgnamea[64], dlgnameb[64], dlgdiscdir[64]; ! 83: char dlgnamegdos[64], dlgnamehdimg[64]; ! 84: char *tmpname; ! 85: char *zip_path; ! 86: ! 87: /* Allocate memory for tmpname and zip_path: */ ! 88: tmpname = Memory_Alloc(2 * FILENAME_MAX); ! 89: zip_path = tmpname + FILENAME_MAX; ! 90: zip_path[0] = 0; ! 91: ! 92: SDLGui_CenterDlg(discdlg); ! 93: ! 94: /* Set up dialog to actual values: */ ! 95: ! 96: /* Disc name A: */ ! 97: if( EmulationDrives[0].bDiscInserted ) ! 98: File_ShrinkName(dlgnamea, EmulationDrives[0].szFileName, discdlg[DISCDLG_DISCA].w); ! 99: else ! 100: dlgnamea[0] = 0; ! 101: discdlg[DISCDLG_DISCA].txt = dlgnamea; ! 102: ! 103: /* Disc name B: */ ! 104: if( EmulationDrives[1].bDiscInserted ) ! 105: File_ShrinkName(dlgnameb, EmulationDrives[1].szFileName, discdlg[DISCDLG_DISCB].w); ! 106: else ! 107: dlgnameb[0] = 0; ! 108: discdlg[DISCDLG_DISCB].txt = dlgnameb; ! 109: ! 110: /* Default image directory: */ ! 111: File_ShrinkName(dlgdiscdir, DialogParams.DiscImage.szDiscImageDirectory, discdlg[DISCDLG_IMGDIR].w); ! 112: discdlg[DISCDLG_IMGDIR].txt = dlgdiscdir; ! 113: ! 114: /* Auto insert disc B: */ ! 115: if( DialogParams.DiscImage.bAutoInsertDiscB ) ! 116: discdlg[DISCDLG_AUTOB].state |= SG_SELECTED; ! 117: else ! 118: discdlg[DISCDLG_AUTOB].state &= ~SG_SELECTED; ! 119: ! 120: /* Boot from harddisk? */ ! 121: if( DialogParams.HardDisc.bBootFromHardDisc ) ! 122: discdlg[DISCDLG_BOOTHD].state |= SG_SELECTED; ! 123: else ! 124: discdlg[DISCDLG_BOOTHD].state &= ~SG_SELECTED; ! 125: ! 126: /* GEMDOS Hard disc directory: */ ! 127: if( strcmp(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0])!=0 ! 128: || GEMDOS_EMU_ON ) ! 129: File_ShrinkName(dlgnamegdos, DialogParams.HardDisc.szHardDiscDirectories[0], discdlg[DISCDLG_DISCGDOS].w); ! 130: else ! 131: dlgnamegdos[0] = 0; ! 132: discdlg[DISCDLG_DISCGDOS].txt = dlgnamegdos; ! 133: ! 134: /* Hard disc image: */ ! 135: if( ACSI_EMU_ON ) ! 136: File_ShrinkName(dlgnamehdimg, DialogParams.HardDisc.szHardDiscImage, discdlg[DISCDLG_DISCHDIMG].w); ! 137: else ! 138: dlgnamehdimg[0] = 0; ! 139: discdlg[DISCDLG_DISCHDIMG].txt = dlgnamehdimg; ! 140: ! 141: /* Draw and process the dialog */ ! 142: do ! 143: { ! 144: but = SDLGui_DoDialog(discdlg); ! 145: switch(but) ! 146: { ! 147: case DISCDLG_EJECTA: /* Eject disc in drive A: */ ! 148: Floppy_EjectDiscFromDrive(0, FALSE); ! 149: dlgnamea[0] = 0; ! 150: break; ! 151: case DISCDLG_BROWSEA: /* Choose a new disc A: */ ! 152: if( EmulationDrives[0].bDiscInserted ) ! 153: strcpy(tmpname, EmulationDrives[0].szFileName); ! 154: else ! 155: strcpy(tmpname, DialogParams.DiscImage.szDiscImageDirectory); ! 156: if( SDLGui_FileSelect(tmpname, zip_path, FALSE) ) ! 157: { ! 158: if( !File_DoesFileNameEndWithSlash(tmpname) && File_Exists(tmpname) ) ! 159: { ! 160: Floppy_ZipInsertDiscIntoDrive(0, tmpname, zip_path); /* FIXME: This shouldn't be done here but in Dialog_CopyDialogParamsToConfiguration */ ! 161: File_ShrinkName(dlgnamea, tmpname, discdlg[DISCDLG_DISCA].w); ! 162: } ! 163: else ! 164: { ! 165: Floppy_EjectDiscFromDrive(0, FALSE); /* FIXME: This shouldn't be done here but in Dialog_CopyDialogParamsToConfiguration */ ! 166: dlgnamea[0] = 0; ! 167: } ! 168: } ! 169: break; ! 170: case DISCDLG_EJECTB: /* Eject disc in drive B: */ ! 171: Floppy_EjectDiscFromDrive(1, FALSE); ! 172: dlgnameb[0] = 0; ! 173: break; ! 174: case DISCDLG_BROWSEB: /* Choose a new disc B: */ ! 175: if( EmulationDrives[1].bDiscInserted ) ! 176: strcpy(tmpname, EmulationDrives[1].szFileName); ! 177: else ! 178: strcpy(tmpname, DialogParams.DiscImage.szDiscImageDirectory); ! 179: if( SDLGui_FileSelect(tmpname, zip_path, FALSE) ) ! 180: { ! 181: if( !File_DoesFileNameEndWithSlash(tmpname) && File_Exists(tmpname) ) ! 182: { ! 183: Floppy_ZipInsertDiscIntoDrive(1, tmpname, zip_path); /* FIXME: This shouldn't be done here but in Dialog_CopyDialogParamsToConfiguration */ ! 184: File_ShrinkName(dlgnameb, tmpname, discdlg[DISCDLG_DISCB].w); ! 185: } ! 186: else ! 187: { ! 188: Floppy_EjectDiscFromDrive(1, FALSE); /* FIXME: This shouldn't be done here but in Dialog_CopyDialogParamsToConfiguration */ ! 189: dlgnameb[0] = 0; ! 190: } ! 191: } ! 192: break; ! 193: case DISCDLG_BROWSEIMG: ! 194: strcpy(tmpname, DialogParams.DiscImage.szDiscImageDirectory); ! 195: if( SDLGui_FileSelect(tmpname, NULL, FALSE) ) ! 196: { ! 197: char *ptr; ! 198: ptr = strrchr(tmpname, '/'); ! 199: if( ptr!=NULL ) ptr[1]=0; ! 200: strcpy(DialogParams.DiscImage.szDiscImageDirectory, tmpname); ! 201: File_ShrinkName(dlgdiscdir, DialogParams.DiscImage.szDiscImageDirectory, discdlg[DISCDLG_IMGDIR].w); ! 202: } ! 203: break; ! 204: case DISCDLG_CREATEIMG: ! 205: DlgNewDisc_Main(); ! 206: break; ! 207: case DISCDLG_UNMOUNTGDOS: ! 208: GemDOS_UnInitDrives(); /* FIXME: This shouldn't be done here but it's the only quick solution I could think of */ ! 209: strcpy(DialogParams.HardDisc.szHardDiscDirectories[0], ConfigureParams.HardDisc.szHardDiscDirectories[0]); ! 210: dlgnamegdos[0] = 0; ! 211: break; ! 212: case DISCDLG_BROWSEGDOS: ! 213: strcpy(tmpname, DialogParams.HardDisc.szHardDiscDirectories[0]); ! 214: if( SDLGui_FileSelect(tmpname, NULL, FALSE) ) ! 215: { ! 216: char *ptr; ! 217: ptr = strrchr(tmpname, '/'); ! 218: if( ptr!=NULL ) ptr[1]=0; /* Remove file name from path */ ! 219: strcpy(DialogParams.HardDisc.szHardDiscDirectories[0], tmpname); ! 220: File_ShrinkName(dlgnamegdos, DialogParams.HardDisc.szHardDiscDirectories[0], discdlg[DISCDLG_DISCGDOS].w); ! 221: } ! 222: break; ! 223: case DISCDLG_EJECTHDIMG: ! 224: DialogParams.HardDisc.szHardDiscImage[0] = 0; ! 225: DialogParams.HardDisc.bUseHardDiscImage = FALSE; ! 226: dlgnamehdimg[0] = 0; ! 227: break; ! 228: case DISCDLG_BROWSEHDIMG: ! 229: strcpy(tmpname, DialogParams.HardDisc.szHardDiscImage); ! 230: if( SDLGui_FileSelect(tmpname, NULL, FALSE) ) ! 231: { ! 232: strcpy(DialogParams.HardDisc.szHardDiscImage, tmpname); ! 233: if( !File_DoesFileNameEndWithSlash(tmpname) && File_Exists(tmpname) ) ! 234: { ! 235: File_ShrinkName(dlgnamehdimg, tmpname, discdlg[DISCDLG_DISCHDIMG].w); ! 236: DialogParams.HardDisc.bUseHardDiscImage = TRUE; ! 237: } ! 238: else ! 239: { ! 240: dlgnamehdimg[0] = 0; ! 241: } ! 242: } ! 243: break; ! 244: } ! 245: } ! 246: while(but!=DISCDLG_EXIT && !bQuitProgram); ! 247: ! 248: /* Read values from dialog */ ! 249: DialogParams.DiscImage.bAutoInsertDiscB = (discdlg[DISCDLG_AUTOB].state & SG_SELECTED); ! 250: DialogParams.HardDisc.bBootFromHardDisc = (discdlg[DISCDLG_BOOTHD].state & SG_SELECTED); ! 251: ! 252: Memory_Free(tmpname); ! 253: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.