PCem
view src/win-config.c @ 113:f749363ad763
Added per-device configuration.
Reworked configuration parser a bit.
Added configuration for S3 ViRGE and 8-bit Sound Blasters.
IRQ 2 routed to IRQ 9 on AT machines.
| author | TomW |
|---|---|
| date | Mon Jun 30 21:31:28 2014 +0100 |
| parents | c5989dbbc2ce |
| children |
line source
1 #define BITMAP WINDOWS_BITMAP
2 #include <windows.h>
3 #include <windowsx.h>
4 #undef BITMAP
6 #include <commctrl.h>
8 #include "ibm.h"
9 #include "cpu.h"
10 #include "device.h"
11 #include "model.h"
12 #include "resources.h"
13 #include "sound.h"
14 #include "video.h"
15 #include "win.h"
17 extern int is486;
18 static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX];
19 static int settings_sound_to_list[20], settings_list_to_sound[20];
21 static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
22 {
23 char temp_str[256];
24 HWND h;
25 int c, d;
26 int rom, gfx, mem, fpu;
27 int temp_cpu, temp_cpu_m, temp_model;
28 int temp_GAMEBLASTER, temp_GUS, temp_SSI2001, temp_sound_card_current;
29 // pclog("Dialog msg %i %08X\n",message,message);
30 switch (message)
31 {
32 case WM_INITDIALOG:
33 pause = 1;
34 h = GetDlgItem(hdlg, IDC_COMBO1);
35 for (c = 0; c < ROM_MAX; c++)
36 romstolist[c] = 0;
37 c = d = 0;
38 while (models[c].id != -1)
39 {
40 pclog("INITDIALOG : %i %i %i\n",c,models[c].id,romspresent[models[c].id]);
41 if (romspresent[models[c].id])
42 {
43 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[c].name);
44 modeltolist[c] = d;
45 listtomodel[d] = c;
46 romstolist[models[c].id] = d;
47 romstomodel[models[c].id] = c;
48 d++;
49 }
50 c++;
51 }
52 SendMessage(h, CB_SETCURSEL, modeltolist[model], 0);
54 h = GetDlgItem(hdlg, IDC_COMBOVID);
55 c = d = 0;
56 while (1)
57 {
58 char *s = video_card_getname(c);
60 if (!s[0])
61 break;
63 if (video_card_available(c) && gfx_present[video_new_to_old(c)])
64 {
65 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
66 if (video_new_to_old(c) == gfxcard)
67 SendMessage(h, CB_SETCURSEL, d, 0);
69 d++;
70 }
72 c++;
73 }
74 if (models[model].fixed_gfxcard)
75 EnableWindow(h, FALSE);
77 h = GetDlgItem(hdlg, IDC_COMBOCPUM);
78 c = 0;
79 while (models[romstomodel[romset]].cpu[c].cpus != NULL && c < 3)
80 {
81 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[romstomodel[romset]].cpu[c].name);
82 c++;
83 }
84 EnableWindow(h, TRUE);
85 SendMessage(h, CB_SETCURSEL, cpu_manufacturer, 0);
86 if (c == 1) EnableWindow(h, FALSE);
87 else EnableWindow(h, TRUE);
89 h = GetDlgItem(hdlg, IDC_COMBO3);
90 c = 0;
91 while (models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[c].cpu_type != -1)
92 {
93 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[c].name);
94 c++;
95 }
96 EnableWindow(h, TRUE);
97 SendMessage(h, CB_SETCURSEL, cpu, 0);
99 h = GetDlgItem(hdlg, IDC_COMBOSND);
100 c = d = 0;
101 while (1)
102 {
103 char *s = sound_card_getname(c);
105 if (!s[0])
106 break;
108 settings_sound_to_list[c] = d;
110 if (sound_card_available(c))
111 {
112 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
113 settings_list_to_sound[d] = c;
114 d++;
115 }
117 c++;
118 }
119 SendMessage(h, CB_SETCURSEL, settings_sound_to_list[sound_card_current], 0);
121 h=GetDlgItem(hdlg, IDC_CHECK3);
122 SendMessage(h, BM_SETCHECK, GAMEBLASTER, 0);
124 h=GetDlgItem(hdlg, IDC_CHECKGUS);
125 SendMessage(h, BM_SETCHECK, GUS, 0);
127 h=GetDlgItem(hdlg, IDC_CHECKSSI);
128 SendMessage(h, BM_SETCHECK, SSI2001, 0);
130 h=GetDlgItem(hdlg, IDC_CHECK2);
131 SendMessage(h, BM_SETCHECK, slowega, 0);
133 h=GetDlgItem(hdlg, IDC_CHECK4);
134 SendMessage(h, BM_SETCHECK, cga_comp, 0);
136 h = GetDlgItem(hdlg, IDC_COMBOCHC);
137 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A little");
138 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A bit");
139 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Some");
140 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A lot");
141 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Infinite");
142 SendMessage(h, CB_SETCURSEL, cache, 0);
144 h = GetDlgItem(hdlg, IDC_COMBOSPD);
145 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"8-bit");
146 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Slow 16-bit");
147 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Fast 16-bit");
148 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Slow VLB/PCI");
149 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Mid VLB/PCI");
150 SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Fast VLB/PCI");
151 SendMessage(h, CB_SETCURSEL, video_speed, 0);
153 h = GetDlgItem(hdlg, IDC_MEMSPIN);
154 SendMessage(h, UDM_SETBUDDY, (WPARAM)GetDlgItem(hdlg, IDC_MEMTEXT), 0);
155 SendMessage(h, UDM_SETRANGE, 0, (1 << 16) | 256);
156 SendMessage(h, UDM_SETPOS, 0, mem_size);
158 h = GetDlgItem(hdlg, IDC_CONFIGUREVID);
159 if (video_card_has_config(video_old_to_new(gfxcard)))
160 EnableWindow(h, TRUE);
161 else
162 EnableWindow(h, FALSE);
164 h = GetDlgItem(hdlg, IDC_CONFIGURESND);
165 if (sound_card_has_config(sound_card_current))
166 EnableWindow(h, TRUE);
167 else
168 EnableWindow(h, FALSE);
170 return TRUE;
172 case WM_COMMAND:
173 switch (LOWORD(wParam))
174 {
175 case IDOK:
176 h = GetDlgItem(hdlg, IDC_MEMTEXT);
177 SendMessage(h, WM_GETTEXT, 255, (LPARAM)temp_str);
178 sscanf(temp_str, "%i", &mem);
179 if (mem < 1 || mem > 256)
180 {
181 MessageBox(NULL, "Invalid memory size\nMemory must be between 1 and 256 MB", "PCem", MB_OK);
182 break;
183 }
186 h = GetDlgItem(hdlg, IDC_COMBO1);
187 temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
189 h = GetDlgItem(hdlg, IDC_COMBOVID);
190 SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
191 gfx = video_new_to_old(video_card_getid(temp_str));
193 h = GetDlgItem(hdlg, IDC_COMBOCPUM);
194 temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
195 h = GetDlgItem(hdlg, IDC_COMBO3);
196 temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
197 fpu = (models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type >= CPU_i486DX) ? 1 : 0;
199 h = GetDlgItem(hdlg, IDC_CHECK3);
200 temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0);
202 h = GetDlgItem(hdlg, IDC_CHECKGUS);
203 temp_GUS = SendMessage(h, BM_GETCHECK, 0, 0);
205 h = GetDlgItem(hdlg, IDC_CHECKSSI);
206 temp_SSI2001 = SendMessage(h, BM_GETCHECK, 0, 0);
208 h = GetDlgItem(hdlg, IDC_COMBOSND);
209 temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
211 if (temp_model != model || gfx != gfxcard || mem != mem_size || fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS || temp_SSI2001 != SSI2001 || temp_sound_card_current != sound_card_current)
212 {
213 if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK)
214 {
215 model = temp_model;
216 romset = model_getromset();
217 gfxcard = gfx;
218 mem_size = mem;
219 cpu_manufacturer = temp_cpu_m;
220 cpu = temp_cpu;
221 GAMEBLASTER = temp_GAMEBLASTER;
222 GUS = temp_GUS;
223 SSI2001 = temp_SSI2001;
224 sound_card_current = temp_sound_card_current;
226 mem_resize();
227 loadbios();
228 resetpchard();
229 }
230 else
231 {
232 EndDialog(hdlg, 0);
233 pause = 0;
234 return TRUE;
235 }
236 }
238 h = GetDlgItem(hdlg, IDC_COMBOSPD);
239 video_speed = SendMessage(h, CB_GETCURSEL, 0, 0);
241 h = GetDlgItem(hdlg, IDC_CHECK4);
242 cga_comp=SendMessage(h, BM_GETCHECK, 0, 0);
244 cpu_manufacturer = temp_cpu_m;
245 cpu = temp_cpu;
246 cpu_set();
248 h = GetDlgItem(hdlg, IDC_COMBOCHC);
249 cache=SendMessage(h, CB_GETCURSEL, 0, 0);
250 mem_updatecache();
252 saveconfig();
254 speedchanged();
256 case IDCANCEL:
257 EndDialog(hdlg, 0);
258 pause=0;
259 return TRUE;
260 case IDC_COMBO1:
261 if (HIWORD(wParam) == CBN_SELCHANGE)
262 {
263 h = GetDlgItem(hdlg,IDC_COMBO1);
264 temp_model = listtomodel[SendMessage(h,CB_GETCURSEL,0,0)];
266 /*Enable/disable gfxcard list*/
267 h = GetDlgItem(hdlg, IDC_COMBOVID);
268 if (!models[temp_model].fixed_gfxcard)
269 {
270 char *s = video_card_getname(video_old_to_new(gfxcard));
272 EnableWindow(h, TRUE);
274 c = 0;
275 while (1)
276 {
277 SendMessage(h, CB_GETLBTEXT, c, (LPARAM)temp_str);
278 if (!strcmp(temp_str, s))
279 break;
280 c++;
281 }
282 SendMessage(h, CB_SETCURSEL, c, 0);
283 }
284 else
285 EnableWindow(h, FALSE);
287 /*Rebuild manufacturer list*/
288 h = GetDlgItem(hdlg, IDC_COMBOCPUM);
289 temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
290 SendMessage(h, CB_RESETCONTENT, 0, 0);
291 c = 0;
292 while (models[temp_model].cpu[c].cpus != NULL && c < 3)
293 {
294 SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[c].name);
295 c++;
296 }
297 if (temp_cpu_m >= c) temp_cpu_m = c - 1;
298 SendMessage(h, CB_SETCURSEL, temp_cpu_m, 0);
299 if (c == 1) EnableWindow(h, FALSE);
300 else EnableWindow(h, TRUE);
302 /*Rebuild CPU list*/
303 h = GetDlgItem(hdlg, IDC_COMBO3);
304 temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
305 SendMessage(h, CB_RESETCONTENT, 0, 0);
306 c = 0;
307 while (models[temp_model].cpu[temp_cpu_m].cpus[c].cpu_type != -1)
308 {
309 SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[temp_cpu_m].cpus[c].name);
310 c++;
311 }
312 if (temp_cpu >= c) temp_cpu = c - 1;
313 SendMessage(h, CB_SETCURSEL, temp_cpu, 0);
314 }
315 break;
316 case IDC_COMBOCPUM:
317 if (HIWORD(wParam) == CBN_SELCHANGE)
318 {
319 h = GetDlgItem(hdlg, IDC_COMBO1);
320 temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
321 h = GetDlgItem(hdlg, IDC_COMBOCPUM);
322 temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
324 /*Rebuild CPU list*/
325 h=GetDlgItem(hdlg, IDC_COMBO3);
326 temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
327 SendMessage(h, CB_RESETCONTENT, 0, 0);
328 c = 0;
329 while (models[temp_model].cpu[temp_cpu_m].cpus[c].cpu_type != -1)
330 {
331 SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[temp_cpu_m].cpus[c].name);
332 c++;
333 }
334 if (temp_cpu >= c) temp_cpu = c - 1;
335 SendMessage(h, CB_SETCURSEL, temp_cpu, 0);
336 }
337 break;
339 case IDC_CONFIGUREVID:
340 h = GetDlgItem(hdlg, IDC_COMBOVID);
341 SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
343 deviceconfig_open(hdlg, (void *)video_card_getdevice(video_card_getid(temp_str)));
344 break;
346 case IDC_COMBOVID:
347 h = GetDlgItem(hdlg, IDC_COMBOVID);
348 SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
349 gfx = video_card_getid(temp_str);
351 h = GetDlgItem(hdlg, IDC_CONFIGUREVID);
352 if (video_card_has_config(gfx))
353 EnableWindow(h, TRUE);
354 else
355 EnableWindow(h, FALSE);
356 break;
358 case IDC_CONFIGURESND:
359 h = GetDlgItem(hdlg, IDC_COMBOSND);
360 temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
362 deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card_current));
363 break;
365 case IDC_COMBOSND:
366 h = GetDlgItem(hdlg, IDC_COMBOSND);
367 temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
369 h = GetDlgItem(hdlg, IDC_CONFIGURESND);
370 if (sound_card_has_config(temp_sound_card_current))
371 EnableWindow(h, TRUE);
372 else
373 EnableWindow(h, FALSE);
374 break;
375 }
376 break;
377 }
378 return FALSE;
379 }
381 void config_open(HWND hwnd)
382 {
383 DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, config_dlgproc);
384 }
