|
|
1.1 root 1: /*
2: Hatari - dlgHardDisk.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: const char DlgOpticalDisk_fileid[] = "Previous dlgOpticalDisk.c : " __DATE__ " " __TIME__;
8:
9: #include <assert.h>
10: #include "main.h"
11: #include "configuration.h"
12: #include "dialog.h"
13: #include "sdlgui.h"
14: #include "file.h"
15: #include "mo.h"
16:
17:
18: #define DUAL_MO_DRIVE 1
19:
20: #define MODLG_CONNECTED0 3
21: #define MODLG_INSERT0 6
22: #define MODLG_READONLY0 7
23: #define MODLG_DISKNAME0 8
24: #if DUAL_MO_DRIVE
25: #define MODLG_CONNECTED1 10
26: #define MODLG_INSERT1 13
27: #define MODLG_READONLY1 14
28: #define MODLG_DISKNAME1 15
29:
30: #define DISKDLG_EXIT 17
31: #else
32: #define DISKDLG_EXIT 10
33: #endif
34:
35: /* Constant strings */
36: #define MODLG_EJECT_WARNING "WARNING: Don't eject manually if a guest system is running. Risk of data loss. Eject now?"
37: #define MODLG_DUALDRV_WARNING "WARNING: Second drive can cause problems. System may crash or hang due to a kernel bug. Add anyway?"
38:
39: /* Variable strings */
40: char inserteject0[16] = "Insert";
41: char inserteject1[16] = "Insert";
42:
43:
44: /* The magneto optical drive dialog: */
45: static SGOBJ modlg[] =
46: {
47: #if DUAL_MO_DRIVE
48: { SGBOX, 0, 0, 0,0, 64,30, NULL },
49: #else
50: { SGBOX, 0, 0, 0,0, 64,20, NULL },
51: #endif
52: { SGTEXT, 0, 0, 21,1, 10,1, "Magneto-optical drives" },
53:
54: { SGTEXT, 0, 0, 2,4, 14,1, "MO Drive 0:" },
55: { SGCHECKBOX, 0, 0, 16, 4, 11, 1, "Connected" },
56:
57: { SGBOX, 0, 0, 2,6, 60,6, NULL },
58: { SGTEXT, 0, 0, 4,7, 14,1, "Optical disk:" },
59: { SGBUTTON, 0, 0, 20,7, 10,1, inserteject0 },
60: { SGTEXT, 0, 0, 32,7, 17,1, NULL },
61: { SGTEXT, 0, 0, 4,9, 56,1, NULL },
62: #if DUAL_MO_DRIVE
63: { SGTEXT, 0, 0, 2,14, 14,1, "MO Drive 1:" },
64: { SGCHECKBOX, 0, 0, 16, 14, 11, 1, "Connected" },
65:
66: { SGBOX, 0, 0, 2,16, 60,6, NULL },
67: { SGTEXT, 0, 0, 4,17, 14,1, "Optical disk:" },
68: { SGBUTTON, 0, 0, 20,17, 10,1, inserteject1 },
69: { SGTEXT, 0, 0, 32,17, 17,1, NULL },
70: { SGTEXT, 0, 0, 4,19, 56,1, NULL },
71:
72: { SGTEXT, 0, 0, 2,24, 14,1, "Note: Magneto-optical drives only work with non-turbo Cubes." },
73:
74: { SGBUTTON, SG_DEFAULT, 0, 21,27, 21,1, "Back to main menu" },
75: #else
76: { SGTEXT, 0, 0, 2,14, 14,1, "Note: Magneto-optical drives only work with non-turbo Cubes." },
77:
78: { SGBUTTON, SG_DEFAULT, 0, 21,17, 21,1, "Back to main menu" },
79: #endif
80:
81: { -1, 0, 0, 0,0, 0,0, NULL }
82: };
83:
84:
85: /**
86: * Let user browse given directory, set directory if one selected.
87: * return false if none selected, otherwise return true.
88: */
89: /*static bool DlgDisk_BrowseDir(char *dlgname, char *confname, int maxlen)
90: {
91: char *str, *selname;
92:
93: selname = SDLGui_FileSelect(confname, NULL, false);
94: if (selname)
95: {
96: strcpy(confname, selname);
97: free(selname);
98:
99: str = strrchr(confname, PATHSEP);
100: if (str != NULL)
101: str[1] = 0;
102: File_CleanFileName(confname);
103: File_ShrinkName(dlgname, confname, maxlen);
104: return true;
105: }
106: return false;
107: }*/
108:
109:
110: /**
111: * Show and process the hard disk dialog.
112: */
113: void DlgOptical_Main(void)
114: {
115: int but;
116: char dlgname_mo[MO_MAX_DRIVES][64];
117:
118: SDLGui_CenterDlg(modlg);
119:
120: /* Set up dialog to actual values: */
121:
122: /* MO disk image: */
123: if (ConfigureParams.MO.drive[0].bDriveConnected && ConfigureParams.MO.drive[0].bDiskInserted) {
124: File_ShrinkName(dlgname_mo[0], ConfigureParams.MO.drive[0].szImageName,
125: modlg[MODLG_DISKNAME0].w);
126: sprintf(inserteject0, "Eject");
127: } else {
128: dlgname_mo[0][0] = '\0';
129: sprintf(inserteject0, "Insert");
130: }
131: modlg[MODLG_DISKNAME0].txt = dlgname_mo[0];
132: #if DUAL_MO_DRIVE
133: if (ConfigureParams.MO.drive[1].bDriveConnected && ConfigureParams.MO.drive[1].bDiskInserted) {
134: File_ShrinkName(dlgname_mo[1], ConfigureParams.MO.drive[1].szImageName,
135: modlg[MODLG_DISKNAME1].w);
136: sprintf(inserteject1, "Eject");
137: } else {
138: dlgname_mo[1][0] = '\0';
139: sprintf(inserteject1, "Insert");
140: }
141: modlg[MODLG_DISKNAME1].txt = dlgname_mo[1];
142: #endif
143:
144: /* Drive connected true or false? */
145: if (ConfigureParams.MO.drive[0].bDriveConnected)
146: modlg[MODLG_CONNECTED0].state |= SG_SELECTED;
147: else
148: modlg[MODLG_CONNECTED0].state &= ~SG_SELECTED;
149: #if DUAL_MO_DRIVE
150: if (ConfigureParams.MO.drive[1].bDriveConnected)
151: modlg[MODLG_CONNECTED1].state |= SG_SELECTED;
152: else
153: modlg[MODLG_CONNECTED1].state &= ~SG_SELECTED;
154: #endif
155:
156: /* Draw and process the dialog */
157: do
158: {
159: /* Write protection true or false? */
160: if (ConfigureParams.MO.drive[0].bWriteProtected)
161: modlg[MODLG_READONLY0].txt = "read-only";
162: else
163: modlg[MODLG_READONLY0].txt = "";
164: #if DUAL_MO_DRIVE
165: if (ConfigureParams.MO.drive[1].bWriteProtected)
166: modlg[MODLG_READONLY1].txt = "read-only";
167: else
168: modlg[MODLG_READONLY1].txt = "";
169: #endif
170:
171: but = SDLGui_DoDialog(modlg, NULL);
172:
173: switch (but)
174: {
175: case MODLG_INSERT0:
176: if (!ConfigureParams.MO.drive[0].bDiskInserted) {
177: if (SDLGui_DiskSelect(dlgname_mo[0], ConfigureParams.MO.drive[0].szImageName,
178: modlg[MODLG_DISKNAME0].w, &ConfigureParams.MO.drive[0].bWriteProtected)) {
179: ConfigureParams.MO.drive[0].bDiskInserted = true;
180: sprintf(inserteject0, "Eject");
181: if (!ConfigureParams.MO.drive[0].bDriveConnected) {
182: ConfigureParams.MO.drive[0].bDriveConnected = true;
183: modlg[MODLG_CONNECTED0].state |= SG_SELECTED;
184: }
185: MO_Insert(0);
186: }
187: } else {
188: if (DlgAlert_Query(MODLG_EJECT_WARNING)) {
189: ConfigureParams.MO.drive[0].bDiskInserted = false;
190: ConfigureParams.MO.drive[0].bWriteProtected = false;
191: sprintf(inserteject0, "Insert");
192: ConfigureParams.MO.drive[0].szImageName[0] = '\0';
193: dlgname_mo[0][0] = '\0';
194: MO_Eject(0);
195: }
196: }
197: break;
198: case MODLG_CONNECTED0:
199: if (ConfigureParams.MO.drive[0].bDriveConnected) {
200: ConfigureParams.MO.drive[0].bDriveConnected = false;
201: ConfigureParams.MO.drive[0].bDiskInserted = false;
202: sprintf(inserteject0, "Insert");
203: ConfigureParams.MO.drive[0].bWriteProtected = false;
204: ConfigureParams.MO.drive[0].szImageName[0] = '\0';
205: dlgname_mo[0][0] = '\0';
206: } else {
207: ConfigureParams.MO.drive[0].bDriveConnected = true;
208: }
209: break;
210: #if DUAL_MO_DRIVE
211: case MODLG_INSERT1:
212: if (!ConfigureParams.MO.drive[1].bDiskInserted) {
213: if (!ConfigureParams.MO.drive[1].bDriveConnected) {
214: if (!DlgAlert_Query(MODLG_DUALDRV_WARNING)) {
215: break;
216: }
217: }
218: if (SDLGui_DiskSelect(dlgname_mo[1], ConfigureParams.MO.drive[1].szImageName,
219: modlg[MODLG_DISKNAME1].w, &ConfigureParams.MO.drive[1].bWriteProtected)) {
220: if (!ConfigureParams.MO.drive[1].bDriveConnected) {
221: ConfigureParams.MO.drive[1].bDriveConnected = true;
222: modlg[MODLG_CONNECTED1].state |= SG_SELECTED;
223: }
224: ConfigureParams.MO.drive[1].bDiskInserted = true;
225: sprintf(inserteject1, "Eject");
226: MO_Insert(1);
227: }
228: } else {
229: if (DlgAlert_Query(MODLG_EJECT_WARNING)) {
230: ConfigureParams.MO.drive[1].bDiskInserted = false;
231: ConfigureParams.MO.drive[1].bWriteProtected = false;
232: sprintf(inserteject1, "Insert");
233: ConfigureParams.MO.drive[1].szImageName[0] = '\0';
234: dlgname_mo[1][0] = '\0';
235: MO_Eject(1);
236: }
237: }
238: break;
239: case MODLG_CONNECTED1:
240: if (ConfigureParams.MO.drive[1].bDriveConnected) {
241: ConfigureParams.MO.drive[1].bDriveConnected = false;
242: ConfigureParams.MO.drive[1].bDiskInserted = false;
243: sprintf(inserteject1, "Insert");
244: ConfigureParams.MO.drive[1].bWriteProtected = false;
245: ConfigureParams.MO.drive[1].szImageName[0] = '\0';
246: dlgname_mo[1][0] = '\0';
247: } else {
248: if (DlgAlert_Query(MODLG_DUALDRV_WARNING)) {
249: ConfigureParams.MO.drive[1].bDriveConnected = true;
250: } else {
251: modlg[MODLG_CONNECTED1].state &= ~SG_SELECTED;
252: }
253: }
254: break;
255: #endif
256: default:
257: break;
258: }
259: }
260: while (but != DISKDLG_EXIT && but != SDLGUI_QUIT
261: && but != SDLGUI_ERROR && !bQuitProgram);
262: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.