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