]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/FDISK/MAINMENU.C

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / FDISK / MAINMENU.C
1
2 #include "dos.h" /* AN000 */
3 #include "fdisk.h" /* AN000 */
4 #include "subtype.h" /* AN000 */
5 #include "extern.h" /* AN000 */
6 #include "fdiskmsg.h" /* AN000 */
7
8 /* \f */
9 /******************* START OF SPECIFICATIONS *******************/
10 /* */
11 /* SUBROUTINE NAME: DO_MAIN_MENU */
12 /* */
13 /* DESCRIPTIVE NAME: Main menu display and input routine */
14 /* */
15 /* FUNCTION: */
16 /* Displays the main FDISK menu, accepts and validates */
17 /* input from menu and passes control to requested function */
18 /* */
19 /* NOTES: The following screen is managed by this routine: */
20 /* */
21 /* ³0000000000111111111122222222223333333333³ */
22 /* ³0123456789012345678901234567890123456789³ */
23 /* ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ */
24 /* 00³IBM Personal Computer ³ */
25 /* 01³Fixed Disk Setup Program Version 3.30 ³ */
26 /* 02³(C)Copyright IBM Corp. 1983,1987 ³ */
27 /* 03³ ³ */
28 /* 04³FDISK Options ³ */
29 /* 05³ ³ */
30 /* 06³Current Fixed Disk Drive: # ³ */
31 /* 07³ ³ */
32 /* 08³Choose one of the following: ³ */
33 /* 09³ ³ */
34 /* 10³ 1. Create DOS partition ³ */
35 /* 11³ 2. Change Active Partition ³ */
36 /* 12³ 3. Delete DOS Partition ³ */
37 /* 13³ 4. Display Partition Data ³ */
38 /* 14³ 5. Select Next Fixed Disk Drive ³ */
39 /* 15³ ³ */
40 /* 16³ ³ */
41 /* 17³ ³ */
42 /* 18³Enter choice: [#] ³ */
43 /* 19³ ³ */
44 /* 20³ ³ */
45 /* 21³WARNING! No partitions marked active ³ */
46 /* 22³ ³ */
47 /* 23³Press ESC to return to DOS ³ */
48 /* ÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ */
49 /* */
50 /* ENTRY POINTS: do_main_menu */
51 /* LINKAGE: do_main_menu(); */
52 /* NEAR CALL */
53 /* */
54 /* INPUT: None */
55 /* */
56 /* EXIT-NORMAL: ERROR=FALSE */
57 /* */
58 /* EXIT-ERROR: ERROR=TRUE */
59 /* GOTO internal_program_error if case statement */
60 /* failure when branching to requested function */
61 /* */
62 /* EFFECTS: No data directly modified by this routine, but */
63 /* child routines will modify data. */
64 /* */
65 /* INTERNAL REFERENCES: */
66 /* ROUTINES: */
67 /* clear_screen */
68 /* display */
69 /* get_num_input */
70 /* create_partition */
71 /* change_active_partition */
72 /* delete_partition */
73 /* display_partition_information */
74 /* find_active_partition */
75 /* change_drive */
76 /* internal_program_error */
77 /* */
78 /* EXTERNAL REFERENCES: */
79 /* ROUTINES: */
80 /* */
81 /******************** END OF SPECIFICATIONS ********************/
82
83 /* \f */
84 void do_main_menu()
85
86 BEGIN
87
88 char input;
89 char max_input;
90 unsigned temp;
91 unsigned i;
92
93
94 input = c(NUL); /* AC000 */
95 PercentFlag = (FLAG)FALSE; /* AN000 */
96 /* Intialize cur_disk indicator. It is 0 based for array usage */
97 /* See if first disk readable */
98 cur_disk = c(0); /* AC000 */
99 if (!good_disk[0])
100 BEGIN
101 cur_disk++;
102 END
103
104 /* See if we have a valid combo of disk */
105 if ((good_disk[0]) || ((good_disk[1]) && (number_of_drives == uc(2)))) /* AC000 */
106 BEGIN
107 clear_screen(u(0),u(0),u(24),u(79)); /* AC000 */
108 /* Display the copyright */
109 display(menu_1);
110
111 /* See if we couldn't access drive 1 */
112 if (!good_disk[0])
113 BEGIN
114 insert[0] = c('1'); /* AC000 */
115 display(error_30);
116 END
117
118 /* Display the menu every time this routine is returned to until ESC */
119 input = c(NUL); /* AC000 */
120 while (input !=c(ESC)) /* AC000 */
121 BEGIN
122 /* Put up most of the menu */
123 display(menu_2);
124 display(menu_3);
125 display(menu_7);
126
127 /* Put correct disk in current disk message */
128 insert[0]=cur_disk+1+'0';
129 display(menu_5);
130
131 /* Display warning prompt if no active partitions */
132 /* check to see if there is an avail partition */
133 temp = u(0); /* AC000 */
134 for (i = u(0); i < u(4);i++) /* AC000 */
135 BEGIN
136
137 /* See if any non - zero system id bytes */
138 temp = temp | part_table[cur_disk][i].sys_id ;
139 END
140 /* Any entry that isn't zero means */
141 if (temp != u(0)) /* AC000 */
142 BEGIN
143 /* If there isn't an active partition and this is disk 1, then yell) */
144 if ((!find_active_partition()) && (cur_disk == c(0))) /* AC000 */
145 display(menu_6);
146 END
147
148 /* Get the menu input */
149
150 /* See if more than one fixed disk */
151 if (number_of_drives == uc(2)) /* AC000 */
152 BEGIN
153 display(menu_4);
154 max_input = c(5); /* AC000 */
155 END
156 else /* only 4 options */
157 max_input = c(4); /* AC000 */
158 /* Setup default and go get input */
159 input = get_num_input(c(1),max_input,input_row,input_col); /* AC000 */
160 switch(input)
161 BEGIN
162 case '1': create_partition();
163 break;
164
165 case '2': change_active_partition();
166 break;
167
168 case '3': delete_partition();
169 break;
170
171 case '4': display_partition_information();
172 break;
173
174 case '5': BEGIN
175 if (number_of_drives == uc(1)) /* AC000 */
176 internal_program_error();
177 else
178 BEGIN
179 /* Swap the number */
180 if (cur_disk == c(0)) /* AC000 */
181 BEGIN
182 if (good_disk[1])
183 BEGIN
184 cur_disk++;
185 END
186 else
187 BEGIN
188 /* Disk has error reading */
189 insert[0] = c('2'); /* AC000 */
190 display(error_30);
191 END
192 END
193 else
194 BEGIN
195
196 if (cur_disk == c(1)) /* AC000 */
197 BEGIN
198 if (good_disk[0])
199 BEGIN
200 cur_disk--;
201 END
202 else
203 BEGIN
204 /* Disk has error reading */
205 insert[0] = c('1'); /* AC000 */
206 display(error_30);
207 END
208 END
209 else
210 internal_program_error;
211 END
212 END
213 break;
214 END
215
216 case ESC: break; /* ESC case */
217
218 default: internal_program_error();
219 END
220 END
221 END
222 else
223 BEGIN
224 /* Can't read either drive, so quit */
225 no_fatal_error = c(FALSE); /* AC000 */
226 display(error_2);
227 END
228 return;
229 END
230
231 \1a