|
|
1.1.1.2 root 1: /*==========================================================================
2: *
3: * Copyright (C) 1996 Brian King
4: *
5: * File: wingui.c
6: * Content: Win32-specific gui features for UAE port.
7: *
8: -U 4 -c 4 -F 8 -n i3 -w 2 -m system3.1:d:\amiga\hd0 -m work:d:\amiga\hd1
9: ***************************************************************************/
10:
11: #include <stdio.h>
12: #include <stdlib.h>
13: #include <io.h>
14: #include <windows.h>
15: #include <windowsx.h>
16: #include <mmsystem.h>
17: #include <commctrl.h>
18: #include <commdlg.h>
19: #include <dlgs.h>
20: #include <winuser.h>
21: #include <ddraw.h>
22: #include <process.h>
23: #include <shlobj.h>
24: #include <prsht.h>
25: #include <richedit.h>
26:
27: #include "config.h"
28: #include "resource.h"
29: #include "sysconfig.h"
30: #include "sysdeps.h"
31: #include "gui.h"
32: #include "options.h"
33: #include "include/memory.h"
34: #include "custom.h"
35: #include "readcpu.h"
36: #include "newcpu.h"
37: #include "disk.h"
38: #include "uae.h"
39: #include "autoconf.h"
40:
41: #include "picasso96.h"
42: #include "osdep/win32gui.h"
43: #include "osdep/win32.h"
44: #include "sounddep/sound.h"
45:
46: /* HACK HACK HACK */
47: extern int debug_logging;
48: /* ! HACK HACK HACK */
49:
50: static int allow_quit;
51: static int full_property_sheet;
52: static struct uae_prefs *pguiprefs;
53: static struct uae_prefs workprefs;
54: static struct uaedev_mount_info *work_mountinfo;
55:
56: extern int use_direct_sound;
57: extern BOOL running_winnt;
58: extern HINSTANCE hInst;
59: extern HWND hAmigaWnd;
60: extern uae_u8 julian_mode;
61:
62: extern int mouseactive;
63: extern char *start_path;
64: extern int joystickspresent[MAXJOYSTICKS];
65: extern int parse_joy_spec (char *spec);
66:
67: HANDLE win32uae_key = NULL;
68: drive_specs blankdrive =
69: {"", "", 1, 32, 1, 2, 0, 0};
70:
71: #define Error(x) MessageBox( NULL, (x), "WinUAE Error", MB_OK )
72:
73: /* Number of pages in the settings dialog */
74: #define C_PAGES 11
75: enum {
76: LOADSAVE_ID, STARTUP_ID, SOUND_ID, FLOPPY_ID,
77: ADISPLAY_ID, PDISPLAY_ID, CPU_ID,
78: HARDDISK_ID, PORTS_ID, ADVANCED_ID, ABOUT_ID
79: };
80:
81: #define MIN_CHIP_MEM 0
82: #define MAX_CHIP_MEM 4
83: #define MIN_FAST_MEM 0
84: #define MAX_FAST_MEM 4
85: #define MIN_SLOW_MEM 0
86: #define MAX_SLOW_MEM 2
87: #define MIN_Z3_MEM 0
88: #define MAX_Z3_MEM 7
89: #define MIN_P96_MEM 0
90: #define MAX_P96_MEM 4
91: #define MIN_M68K_PRIORITY 1
92: #define MAX_M68K_PRIORITY 16
93: #define MIN_REFRESH_RATE 1
94: #define MAX_REFRESH_RATE 10
95:
96: #define MAX_LINES 580
97:
98: static void accept_workprefs (void)
99: {
100: struct uaedev_mount_info *oldmi = pguiprefs->mountinfo;
101: *pguiprefs = workprefs;
102: if (oldmi != workprefs.mountinfo) {
103: free_mountinfo (oldmi);
104: /* Ugh. This isn't very nice. */
105: currprefs.mountinfo = workprefs.mountinfo;
106: } else
107: free_mountinfo (work_mountinfo);
108: work_mountinfo = dup_mountinfo (workprefs.mountinfo);
109: }
110:
111: static void CreateDiskFile (char *name)
112: {
113: HANDLE adf;
114: int i, file_size = 880 * 1024;
115: char *chunk = NULL;
116: DWORD count;
117:
118: SetCursor (LoadCursor (NULL, IDC_WAIT));
119: adf = CreateFile (name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
120: if (adf != INVALID_HANDLE_VALUE) {
121: if ((chunk = malloc (10240)) != NULL) {
122: for (i = 0; i < file_size; i += 10240) {
123: WriteFile (adf, chunk, 10240, &count, NULL);
124: }
125: }
126: CloseHandle (adf);
127: }
128: SetCursor (LoadCursor (NULL, IDC_ARROW));
129: }
130:
131: static void DiskSelection (HWND hDlg, WPARAM wParam, int flag)
132: {
133: OPENFILENAME openFileName;
134: char full_path[MAX_PATH] = "";
135: char file_name[MAX_PATH] = "";
136: char init_path[MAX_PATH] = "";
137: BOOL result = FALSE;
138: char *amiga_path = NULL;
139:
140: if ((amiga_path = getenv ("AmigaPath")) != NULL) {
141: strncpy (init_path, amiga_path, MAX_PATH);
142: if (flag == 2)
143: strncat (init_path, "\\hdf\\", MAX_PATH);
144: else
145: strncat (init_path, "\\adf\\", MAX_PATH);
146: } else if (start_path) {
147: strncpy (init_path, start_path, MAX_PATH);
148: if (flag == 2 || flag == 3)
149: strncat (init_path, "\\..\\shared\\hdf\\", MAX_PATH);
150: else
151: strncat (init_path, "\\..\\shared\\adf\\", MAX_PATH);
152: }
153: openFileName.lStructSize = sizeof (OPENFILENAME);
154: openFileName.hwndOwner = hDlg;
155: openFileName.hInstance = hInst;
156: switch (flag) {
157: case 0:
158: openFileName.lpstrTitle = "Select an Amiga Disk File image...";
159: openFileName.lpstrDefExt = "ADF";
160: openFileName.lpstrFilter = "Amiga Disk Files (*.ADF;*.ADZ;*.DMS)\0*.ADF;*.ADZ;*.DMS\0";
161: break;
162: case 1:
163: openFileName.lpstrTitle = "Choose your blank Amiga Disk File...";
164: openFileName.lpstrDefExt = "ADF";
165: openFileName.lpstrFilter = "Amiga Disk Files (*.ADF)\0*.ADF\0";
166: break;
167: case 2:
168: case 3:
169: openFileName.lpstrTitle = "Select a Hard Disk File...";
170: openFileName.lpstrDefExt = "HDF";
171: openFileName.lpstrFilter = "Hard Disk Files (*.HDF)\0*.HDF\0";
172: break;
173: }
174: openFileName.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
175: openFileName.lpstrCustomFilter = NULL;
176: openFileName.nMaxCustFilter = 0;
177: openFileName.nFilterIndex = 0;
178: openFileName.lpstrFile = full_path;
179: openFileName.nMaxFile = MAX_PATH;
180: openFileName.lpstrFileTitle = file_name;
181: openFileName.nMaxFileTitle = MAX_PATH;
182: if (start_path)
183: openFileName.lpstrInitialDir = init_path;
184: else
185: openFileName.lpstrInitialDir = NULL;
186: openFileName.lpfnHook = NULL;
187: openFileName.lpTemplateName = NULL;
188: openFileName.lCustData = 0;
189: if (flag == 1 || flag == 3)
190: result = GetSaveFileName (&openFileName);
191: else
192: result = GetOpenFileName (&openFileName);
193:
194: if (result == FALSE)
195: write_log ("GetOpenFileName() failed.\n");
196: else {
197: switch (wParam) {
198: case IDC_PATH_NAME:
199: SetDlgItemText (hDlg, wParam, full_path);
200: break;
201: case IDC_DF0:
202: SetDlgItemText (hDlg, IDC_DF0TEXT, full_path);
203: break;
204: case IDC_DF1:
205: SetDlgItemText (hDlg, IDC_DF1TEXT, full_path);
206: break;
207: case IDC_DF2:
208: SetDlgItemText (hDlg, IDC_DF2TEXT, full_path);
209: break;
210: case IDC_DF3:
211: SetDlgItemText (hDlg, IDC_DF3TEXT, full_path);
212: break;
213: case IDC_CREATE:
214: CreateDiskFile (full_path);
215: break;
216: }
217: }
218: }
219:
220: static long CreateHardFile (HWND hDlg, LONG hfsize)
221: {
222: HANDLE hf;
223: long result = 0;
224: int i = 0, file_size = hfsize * 1024 * 1024;
225:
226: char init_path[MAX_PATH] = "";
227: char *chunk = NULL;
228: DWORD count;
229:
230: DiskSelection (hDlg, IDC_PATH_NAME, 3);
231: GetDlgItemText (hDlg, IDC_PATH_NAME, init_path, MAX_PATH);
232: if (*init_path) {
233: SetCursor (LoadCursor (NULL, IDC_WAIT));
234: hf = CreateFile (init_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
235: if (hf != INVALID_HANDLE_VALUE) {
236: chunk = malloc (1024);
237: if (chunk != 0) {
238: memset (chunk, 0, 1024);
239: for (i; i < file_size; i += 1024) {
240: WriteFile (hf, chunk, 1024, &count, NULL);
241: }
242: }
243: CloseHandle (hf);
244: result = i;
245: }
246: SetCursor (LoadCursor (NULL, IDC_ARROW));
247: }
248: return result;
249: }
250:
251: static const char *memsize_names[] = {
252: "None", "256 K", "512 K", "1 Meg", "2 Megs", "4 Megs", "8 Megs", "16 Megs", "32 Megs", "64 Megs"
253: };
254:
255: static unsigned long memsizes[] = {
256: 0, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000, 0x1000000, 0x2000000, 0x4000000
257: };
258:
259: static int msi_chip[] = { 2, 3, 4, 5, 6, 7 };
260: static int msi_bogo[] = { 0, 2, 3 };
261: static int msi_fast[] = { 0, 3, 4, 5, 6 };
262: static int msi_z3fast[] = { 0, 3, 4, 5, 6, 7, 8, 9 };
263: static int msi_gfx[] = { 0, 3, 4, 5, 6 };
264:
265: static HWND pages[C_PAGES];
266:
267: static LONG CalculateHardfileSize (HWND hDlg)
268: {
269: return 1 << SendDlgItemMessage (hDlg, IDC_HARDFILE_SLIDER, TBM_GETPOS, 0, 0);
270: }
271:
272: static int joy0idc[] = {
273: IDC_PORT0_JOY0, IDC_PORT0_JOY1, IDC_PORT0_MOUSE, IDC_PORT0_KBDA, IDC_PORT0_KBDB, IDC_PORT0_KBDC
274: };
275:
276: static int joy1idc[] = {
277: IDC_PORT1_JOY0, IDC_PORT1_JOY1, IDC_PORT1_MOUSE, IDC_PORT1_KBDA, IDC_PORT1_KBDB, IDC_PORT1_KBDC
278: };
279:
280: static void UpdateRadioButtons (HWND hDlg, HWND lParam)
281: {
282: int which_button;
283:
284: if (GetDlgItem (hDlg, IDC_PORT0) == lParam) {
285: which_button = joy0idc[workprefs.fake_joystick & 0x00FF];
286: if (CheckRadioButton (hDlg, IDC_PORT0_JOY0, IDC_PORT0_KBDC, which_button) == 0)
287: which_button = 0;
288: } else if (GetDlgItem (hDlg, IDC_PORT1) == lParam) {
289: which_button = joy1idc[(workprefs.fake_joystick & 0xFF00) >> 8];
290: if (CheckRadioButton (hDlg, IDC_PORT1_JOY0, IDC_PORT1_KBDC, which_button) == 0)
291: which_button = 0;
292: }
293: }
294:
295: static const char *nth[] = {
296: "", "second ", "third ", "fourth ", "fifth ", "sixth ", "seventh ", "eighth ", "ninth ", "tenth "
297: };
298:
299: static int listview_find_selected (HWND list)
300: {
301: int i, items;
302: items = ListView_GetItemCount (list);
303: for (i = 0; i < items; i++) {
304: if (ListView_GetItemState (list, i, LVIS_SELECTED) == LVIS_SELECTED)
305: return i;
306: }
307: return -1;
308: }
309:
310: static int listview_entry_from_click (HWND list)
311: {
312: POINT point;
313: DWORD pos = GetMessagePos ();
314: int items, entry;
315:
316: point.x = LOWORD (pos);
317: point.y = HIWORD (pos);
318: ScreenToClient (list, &point);
319: entry = ListView_GetTopIndex (list);
320: items = entry + ListView_GetCountPerPage (list);
321: if (items > ListView_GetItemCount (list))
322: items = ListView_GetItemCount (list);
323:
324: while (entry <= items) {
325: RECT rect;
326: /* Get the bounding rectangle of an item. If the mouse
327: * location is within the bounding rectangle of the item,
328: * you know you have found the item that was being clicked. */
329: ListView_GetItemRect (list, entry, &rect, LVIR_BOUNDS);
330: if (PtInRect (&rect, point)) {
331: UINT flag = LVIS_SELECTED | LVIS_FOCUSED;
332: ListView_SetItemState (list, entry, flag, flag);
333: return entry;
334: }
335: entry++;
336: }
337: return -1;
338: }
339:
340: static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
341: {
342: char name_buf[MAX_PATH] = "", desc_buf[128] = "";
343: HWND list;
344: int dblclick = 0;
345: NM_LISTVIEW *nmlistview;
346: int items = 0, entry = 0;
347:
348: switch (msg) {
349: case WM_INITDIALOG:
350: pages[LOADSAVE_ID] = hDlg;
351: if (! full_property_sheet) {
352: EnableWindow (GetDlgItem (hDlg, IDC_SAVE), FALSE);
353: EnableWindow (GetDlgItem (hDlg, IDC_IMPORT), FALSE);
354: }
355: return TRUE;
356:
357: case WM_USER:
358: break;
359:
360: case WM_COMMAND:
361: switch (wParam) {
362: case IDC_SAVE:
363: break;
364: case IDC_LOAD:
365: break;
366: case IDC_DELETE:
367: break;
368: }
369: break;
370:
371: case WM_NOTIFY:
372: if (((LPNMHDR) lParam)->idFrom == IDC_CONFIGLIST) {
373: nmlistview = (NM_LISTVIEW *) lParam;
374: list = nmlistview->hdr.hwndFrom;
375:
376: switch (nmlistview->hdr.code) {
377: case NM_DBLCLK:
378: dblclick = 1;
379: /* fall-through */
380: case NM_CLICK:
381: entry = listview_entry_from_click (list);
382: /* Copy the item's name and description to the gadgets at the bottom... */
383: if (entry >= 0) {
384: ListView_GetItemText (list, entry, 0, name_buf, MAX_PATH);
385: ListView_GetItemText (list, entry, 1, desc_buf, 128);
386: SetDlgItemText (hDlg, IDC_EDITNAME, name_buf);
387: SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, desc_buf);
388: ListView_RedrawItems (list, 0, items);
389:
390: if (dblclick) {
391: /* do the config-loading */
392:
393: /* start the emulation... */
394: }
395: }
396: break;
397: }
398: } else {
399: switch (((NMHDR *) lParam)->code) {
400: case PSN_RESET:
401: if (allow_quit) {
402: quit_program = 1;
403: regs.spcflags |= SPCFLAG_BRK;
404: }
405: break;
406: }
407: }
408: break;
409: }
410:
411: return FALSE;
412: }
413:
414: static int CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
415: {
416: CHARFORMAT CharFormat;
417:
418: switch (msg) {
419: case WM_COMMAND:
420: if (wParam == ID_OK) {
421: EndDialog (hDlg, 1);
422: return TRUE;
423: }
424: break;
425: case WM_INITDIALOG:
426: CharFormat.cbSize = sizeof (CharFormat);
427:
428: SetDlgItemText (hDlg, IDC_CONTRIBUTORS,
429: "Bernd Schmidt - The Grand-Master\n"
430: "Mathias Ortmann - WinUAE Main Guy\n"
431: "Brian King - Picasso96 Support, Integrated GUI for WinUAE, AHI (Working on it)\n"
432: "Gustavo Goedert/Peter Remmers/Michael Sontheimer/Tomi Hakala/Tim Gunn/Nemo Pohle - DOS Port Stuff\n"
433: "Samuel Devulder/Olaf Barthel - Amiga Port\n"
434: "Krister Bergman - XFree86 and OS/2 Port\n"
435: "A. Blanchard/Ernesto Corvi - MacOS Port\n"
436: "Christian Bauer - BeOS Port\n"
437: "Ian Stephenson - NextStep Port\n"
438: "Peter Teichmann - Acorn/RiscOS Port\n"
439: "Stefan Reinauer - ZorroII/III AutoConfig, Serial Support\n"
440: "Christian Schmitt/Chris Hames - Serial Support\n"
441: "Herman ten Brugge - 68020/68881 Emulation Code\n"
442: "Tauno Taipaleenmaki - Various UAE-Control/UAE-Library Support\n"
443: "Brett Eden/Tim Gunn/Paolo Besser/Nemo Pohle - Various Docs and Web-Sites\n"
444: "Special thanks to Alexander Kneer and Tobias Abt (The Picasso96 Team)");
445:
446: SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
447: CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
448: CharFormat.yHeight = 10 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
449:
450: strcpy (CharFormat.szFaceName, "Times New Roman");
451: SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
452: /* SendDlgItemMessage(hDlg, IDC_CONTRIBUTORS, EM_SETBKGNDCOLOR,0,GetSysColor( COLOR_3DFACE ) ); */
453:
454: return TRUE;
455: }
456: return FALSE;
457: }
458:
459: static void DisplayContributors (HWND hDlg)
460: {
461: DialogBox (hInst, MAKEINTRESOURCE (IDD_CONTRIBUTORS), hDlg, ContributorsProc);
462: }
463:
464: static void show_url_from_click (HWND hDlg, LPARAM pos)
465: {
466: static int ids[5] = { IDC_CLOANTOHOME, IDC_AMIGAHOME, IDC_PICASSOHOME, IDC_UAEHOME, IDC_WINUAEHOME };
467: static const char *urls[5] = {
468: "http://www.cloanto.com/amiga/forever",
469: "http://www.amiga.de",
470: "http://www.villagetronic.com/amiga/support/ftp96.html",
471: "http://www.freiburg.linux.de/~uae/",
472: "http://www.CodePoet.com/UAE"
473: };
474: int i;
475: POINT point;
476:
477: point.x = LOWORD (pos);
478: point.y = HIWORD (pos);
479:
480: for (i = 0; i < 5; i++) {
481: RECT rect;
482:
483: GetWindowRect (GetDlgItem (hDlg, ids[i]), &rect);
484: ScreenToClient (hDlg, (POINT *) & rect);
485: ScreenToClient (hDlg, (POINT *) & (rect.right));
486: if (PtInRect (&rect, point)) {
487: ShellExecute (NULL, NULL, urls[i] , NULL, NULL, SW_SHOWNORMAL);
488: return;
489: }
490: }
491: }
492:
1.1.1.3 ! root 493: static void SetupRichText (HWND hDlg, UINT id, char *text)
! 494: {
! 495: CHARFORMAT CharFormat;
! 496: CharFormat.cbSize = sizeof (CharFormat);
! 497:
! 498: SetDlgItemText (hDlg, id, text);
! 499: SendDlgItemMessage (hDlg, id, EM_GETCHARFORMAT, 0, (LPARAM)&CharFormat);
! 500: CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
! 501: CharFormat.dwEffects = CFE_UNDERLINE;
! 502: CharFormat.yHeight = 12 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
! 503:
! 504: CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
! 505: strcpy (CharFormat.szFaceName, "Times New Roman");
! 506: SendDlgItemMessage (hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CharFormat);
! 507: SendDlgItemMessage (hDlg, id, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
! 508: }
! 509:
1.1.1.2 root 510: static void init_aboutdlg (HWND hDlg)
511: {
512: CHARFORMAT CharFormat;
513: CharFormat.cbSize = sizeof (CharFormat);
514:
515: SetDlgItemText (hDlg, IDC_RICHEDIT1, "UAE for Win32/DirectX");
516: SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
517: CharFormat.dwMask |= CFM_BOLD | CFM_SIZE | CFM_FACE;
518: CharFormat.dwEffects = CFE_BOLD;
519: CharFormat.yHeight = 18 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
520:
521: strcpy (CharFormat.szFaceName, "Times New Roman");
522: SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
523: SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
524:
525: SetDlgItemText (hDlg, IDC_RICHEDIT2, PROGNAME);
526: SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
527: CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
528: CharFormat.yHeight = 10 * 20;
529: strcpy (CharFormat.szFaceName, "Times New Roman");
530: SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
531: SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
532:
1.1.1.3 ! root 533: SetupRichText( hDlg, IDC_AMIGAHOME, "Amiga Inc." );
! 534: SetupRichText( hDlg, IDC_CLOANTOHOME, "Cloanto's Amiga Forever" );
! 535: SetupRichText( hDlg, IDC_WINUAEHOME, "WinUAE Home Page" );
! 536: SetupRichText( hDlg, IDC_AIABHOME, "" ); // "Amiga In A Box"
! 537: SetupRichText( hDlg, IDC_UAEHOME, "UAE Home Page" );
! 538: SetupRichText( hDlg, IDC_PICASSOHOME, "Picasso96 Home Page" );
1.1.1.2 root 539: }
540:
541: static BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
542: {
543: switch (msg) {
544: case WM_INITDIALOG:
545: pages[ABOUT_ID] = hDlg;
546: init_aboutdlg (hDlg);
547: break;
548:
549: case WM_COMMAND:
550: if (wParam == IDC_CONTRIBUTORS) {
551: DisplayContributors (hDlg);
552: }
553: break;
554: case WM_LBUTTONDOWN:
555: show_url_from_click (hDlg, lParam);
556: break;
557: case WM_NOTIFY:
558: switch (((NMHDR *) lParam)->code) {
559: case PSN_RESET:
560: if (allow_quit) {
561: quit_program = 1;
562: regs.spcflags |= SPCFLAG_BRK;
563: }
564: break;
565: }
566: break;
567: }
568:
569: return FALSE;
570: }
571:
572: static struct win32_displaymode *GetDisplayMode (int logical_number)
573: {
574: struct win32_displaymode *dm = win32_displaymode_list;
575: while (logical_number > 0 && dm != 0)
576: dm = dm->next, logical_number--;
577: return dm;
578: }
579:
580: static void enable_for_adisplaydlg (HWND hDlg)
581: {
582: if (! full_property_sheet) {
583: /* Disable certain controls which are only to be set once at start-up... */
584: EnableWindow (GetDlgItem (hDlg, IDC_LORES), FALSE);
585: EnableWindow (GetDlgItem (hDlg, IDC_XCENTER), FALSE);
586: EnableWindow (GetDlgItem (hDlg, IDC_YCENTER), FALSE);
587: EnableWindow (GetDlgItem (hDlg, IDC_ASPECT), FALSE);
588: EnableWindow (GetDlgItem (hDlg, IDC_LINEDBL), FALSE);
589: EnableWindow (GetDlgItem (hDlg, IDC_RESOLUTION), FALSE);
590: EnableWindow (GetDlgItem (hDlg, IDC_XSIZE), FALSE);
591: EnableWindow (GetDlgItem (hDlg, IDC_YSIZE), FALSE);
592: EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_NONE), FALSE);
593: EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_SIMPLE), FALSE);
594: EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_SMART), FALSE);
595: EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_NONE), FALSE);
596: EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_SIMPLE), FALSE);
597: EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_SMART), FALSE);
598: }
599: }
600:
601: static void values_to_adisplaydlg (HWND hDlg)
602: {
603: char buffer[40];
604:
605: sprintf (buffer, "%d", workprefs.gfx_width);
606: SetDlgItemText (hDlg, IDC_XSIZE, buffer);
607: sprintf (buffer, "%d", workprefs.gfx_height);
608: SetDlgItemText (hDlg, IDC_YSIZE, buffer);
609:
610: SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPOS, TRUE, workprefs.framerate);
611: sprintf (buffer, "Every %sFrame", nth[workprefs.framerate - 1]);
612: SetDlgItemText (hDlg, IDC_RATETEXT, buffer);
613:
614: CheckDlgButton (hDlg, IDC_LINEDBL, workprefs.gfx_linedbl);
615: CheckDlgButton (hDlg, IDC_AFULLSCREEN, workprefs.gfx_afullscreen);
616: CheckDlgButton (hDlg, IDC_ASPECT, workprefs.gfx_correct_aspect);
617: CheckDlgButton (hDlg, IDC_LORES, workprefs.gfx_lores);
618:
619: if (workprefs.gfx_ycenter == 0)
620: CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_NONE);
621: else if (workprefs.gfx_ycenter == 1)
622: CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_SIMPLE);
623: else
624: CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_SMART);
625:
626: if (workprefs.gfx_xcenter == 0)
627: CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_NONE);
628: else if (workprefs.gfx_xcenter == 1)
629: CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_SIMPLE);
630: else
631: CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_SMART);
632: }
633:
634: static void init_resolution_combo (HWND hDlg)
635: {
636: struct win32_displaymode *dm;
637:
638: SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_RESETCONTENT, 0, 0);
639: for (dm = win32_displaymode_list; dm != 0; dm = dm->next) {
640: char tmpstr[50];
641: sprintf (tmpstr, "%dx%d", dm->width, dm->height);
642: SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) tmpstr);
643: memset (tmpstr, 0, sizeof tmpstr);
644: }
645: }
646:
647: static void values_from_adisplaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
648: {
649: workprefs.gfx_afullscreen = IsDlgButtonChecked (hDlg, IDC_AFULLSCREEN);
650: workprefs.gfx_lores = IsDlgButtonChecked (hDlg, IDC_LORES);
651: workprefs.gfx_correct_aspect = IsDlgButtonChecked (hDlg, IDC_ASPECT);
652: workprefs.gfx_linedbl = IsDlgButtonChecked (hDlg, IDC_LINEDBL);
653:
654: workprefs.framerate = SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_GETPOS, 0, 0);
655:
656: {
657: char buffer[40];
658: sprintf (buffer, "Every %sFrame", nth[workprefs.framerate - 1]);
659: SetDlgItemText (hDlg, IDC_RATETEXT, buffer);
660:
661: GetDlgItemText (hDlg, IDC_XSIZE, buffer, sizeof buffer);
662: workprefs.gfx_width = atoi (buffer);
663: GetDlgItemText (hDlg, IDC_YSIZE, buffer, sizeof buffer);
664: workprefs.gfx_height = atoi (buffer);
665: }
666: workprefs.gfx_xcenter = (IsDlgButtonChecked (hDlg, IDC_XCENTER_SMART) ? 2
667: : IsDlgButtonChecked (hDlg, IDC_XCENTER_SIMPLE) ? 1 : 0);
668: workprefs.gfx_ycenter = (IsDlgButtonChecked (hDlg, IDC_YCENTER_SMART) ? 2
669: : IsDlgButtonChecked (hDlg, IDC_YCENTER_SIMPLE) ? 1 : 0);
670:
671: if (msg == WM_COMMAND && LOWORD (wParam) == IDC_RESOLUTION && HIWORD (wParam) == CBN_SELCHANGE) {
672: LONG posn;
673: struct win32_displaymode *dm;
674: posn = SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_GETCURSEL, 0, 0);
675: if (posn == CB_ERR)
676: return;
677: dm = GetDisplayMode (posn);
678: if (dm == 0) {
679: printf ("Bug...\n");
680: return;
681: }
682: workprefs.gfx_width = dm->width;
683: workprefs.gfx_height = dm->height;
684: }
685: }
686:
687: static BOOL CALLBACK ADisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
688: {
689: static int recursive = 0;
690: switch (msg) {
691: case WM_INITDIALOG:
692: pages[ADISPLAY_ID] = hDlg;
693: SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPAGESIZE, 0, 1);
694: SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETRANGE, TRUE, MAKELONG (MIN_REFRESH_RATE, MAX_REFRESH_RATE));
695: init_resolution_combo (hDlg);
696:
697: case WM_USER:
698: recursive++;
699: values_to_adisplaydlg (hDlg);
700: recursive--;
701: enable_for_adisplaydlg (hDlg);
702: break;
703:
704: case WM_HSCROLL:
705: case WM_COMMAND:
706: if (recursive > 0)
707: break;
708: recursive++;
709: values_from_adisplaydlg (hDlg, msg, wParam, lParam);
710: values_to_adisplaydlg (hDlg);
711: recursive--;
712: break;
713:
714: case WM_NOTIFY:
715: switch (((NMHDR *) lParam)->code) {
716: case PSN_APPLY:
717: accept_workprefs ();
718: break;
719:
720: case PSN_RESET:
721: if (allow_quit) {
722: quit_program = 1;
723: regs.spcflags |= SPCFLAG_BRK;
724: }
725: break;
726: }
727: }
728: return FALSE;
729: }
730:
731: static void enable_for_pdisplaydlg (HWND hDlg)
732: {
733: EnableWindow (GetDlgItem (hDlg, IDC_GFXCARDTEXT), ! workprefs.address_space_24);
734: EnableWindow (GetDlgItem (hDlg, IDC_P96RAM), ! workprefs.address_space_24);
735: EnableWindow (GetDlgItem (hDlg, IDC_P96MEM), ! workprefs.address_space_24);
736: EnableWindow (GetDlgItem (hDlg, IDC_PFULLSCREEN), ! workprefs.address_space_24);
737: }
738:
739: static void values_to_pdisplaydlg (HWND hDlg)
740: {
741: int mem_size;
742:
743: CheckDlgButton (hDlg, IDC_PFULLSCREEN, workprefs.gfx_pfullscreen);
744:
745: switch (workprefs.gfxmem_size) {
746: case 0x00000000: mem_size = 0; break;
747: case 0x00100000: mem_size = 1; break;
748: case 0x00200000: mem_size = 2; break;
749: case 0x00400000: mem_size = 3; break;
750: case 0x00800000: mem_size = 4; break;
751: }
752: SendDlgItemMessage (hDlg, IDC_P96MEM, TBM_SETPOS, TRUE, mem_size);
753: SetDlgItemText (hDlg, IDC_P96RAM, memsize_names[msi_gfx[mem_size]]);
754: }
755:
756: static BOOL CALLBACK PDisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
757: {
758: static int recursive = 0;
759: switch (msg) {
760: case WM_INITDIALOG:
761: pages[PDISPLAY_ID] = hDlg;
762: SendDlgItemMessage (hDlg, IDC_P96MEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_P96_MEM, MAX_P96_MEM));
763:
764: case WM_USER:
765: recursive++;
766: values_to_pdisplaydlg (hDlg);
767: enable_for_pdisplaydlg (hDlg);
768: recursive--;
769: break;
770:
771: case WM_HSCROLL:
772: case WM_COMMAND:
773: if (recursive > 0)
774: break;
775: recursive++;
776: workprefs.gfx_pfullscreen = IsDlgButtonChecked (hDlg, IDC_PFULLSCREEN);
777: workprefs.gfxmem_size = memsizes[msi_gfx[SendMessage (GetDlgItem (hDlg, IDC_P96MEM), TBM_GETPOS, 0, 0)]];
778: values_to_pdisplaydlg (hDlg);
779: recursive--;
780: break;
781:
782: case WM_NOTIFY:
783: switch (((NMHDR *) lParam)->code) {
784: case PSN_APPLY:
785: accept_workprefs ();
786: break;
787:
788: case PSN_RESET:
789: if (allow_quit) {
790: quit_program = 1;
791: regs.spcflags |= SPCFLAG_BRK;
792: }
793: break;
794: }
795: }
796: return FALSE;
797: }
798:
799: static void KickStuffSelection (HWND hDlg, int which)
800: {
801: OPENFILENAME openFileName;
802: char full_path[MAX_PATH] = "";
803: char file_name[MAX_PATH] = "";
804: char init_path[MAX_PATH] = "";
805: char *amiga_path = NULL;
806:
807: if ((amiga_path = getenv ("AmigaPath")) != NULL) {
808: strncpy (init_path, amiga_path, MAX_PATH);
809: strncat (init_path, "\\ROM\\", MAX_PATH);
810: } else if (start_path) {
811: strncpy (init_path, start_path, MAX_PATH);
812: strncat (init_path, "\\..\\shared\\ROM\\", MAX_PATH);
813: }
814: openFileName.lStructSize = sizeof (OPENFILENAME);
815: openFileName.hwndOwner = hDlg;
816: openFileName.hInstance = hInst;
817: if (which) {
818: openFileName.lpstrFilter = "Amiga Kickstart Files (*.ROM)\0*.ROM\0\0";
819: openFileName.lpstrTitle = "Select an Amiga ROM file...";
820: openFileName.lpstrDefExt = "ROM";
821: } else {
822: openFileName.lpstrFilter = "Amiga Kickstart Key-Files (*.KEY)\0*.KEY\0\0";
823: openFileName.lpstrTitle = "Select an Amiga Key-File...";
824: openFileName.lpstrDefExt = "KEY";
825: }
826: openFileName.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
827: openFileName.lpstrCustomFilter = NULL;
828: openFileName.nMaxCustFilter = 0;
829: openFileName.nFilterIndex = 0;
830: openFileName.lpstrFile = full_path;
831: openFileName.nMaxFile = MAX_PATH;
832: openFileName.lpstrFileTitle = file_name;
833: openFileName.nMaxFileTitle = MAX_PATH;
834: if (start_path)
835: openFileName.lpstrInitialDir = init_path;
836: else
837: openFileName.lpstrInitialDir = NULL;
838: openFileName.lpfnHook = NULL;
839: openFileName.lpTemplateName = NULL;
840: openFileName.lCustData = 0;
841: if (GetOpenFileName (&openFileName) == FALSE)
842: write_log ("GetOpenFileName() failed.\n");
843: else {
844: if (which)
845: SetDlgItemText (hDlg, IDC_ROMFILE, full_path);
846: else
847: SetDlgItemText (hDlg, IDC_KEYFILE, full_path);
848: }
849: }
850:
851: static void enable_for_startupdlg (HWND hDlg)
852: {
853: EnableWindow (GetDlgItem (hDlg, IDC_Z3TEXT), ! workprefs.address_space_24);
854: EnableWindow (GetDlgItem (hDlg, IDC_Z3FASTRAM), ! workprefs.address_space_24);
855: EnableWindow (GetDlgItem (hDlg, IDC_Z3FASTMEM), ! workprefs.address_space_24);
856: EnableWindow (GetDlgItem (hDlg, IDC_FASTMEM), workprefs.chipmem_size <= 0x200000);
857: EnableWindow (GetDlgItem (hDlg, IDC_FASTRAM), workprefs.chipmem_size <= 0x200000);
858: EnableWindow (GetDlgItem (hDlg, IDC_FASTTEXT), workprefs.chipmem_size <= 0x200000);
859: }
860:
861: static void values_to_startupdlg (HWND hDlg)
862: {
863: uae_u32 mem_size = 0;
864:
865: SetDlgItemText (hDlg, IDC_ROMFILE, romfile);
866: SetDlgItemText (hDlg, IDC_KEYFILE, keyfile);
867:
868: CheckDlgButton (hDlg, IDC_ILLEGAL, workprefs.illegal_mem);
869:
870: switch (workprefs.chipmem_size) {
871: case 0x00080000: mem_size = 0; break;
872: case 0x00100000: mem_size = 1; break;
873: case 0x00200000: mem_size = 2; break;
874: case 0x00400000: mem_size = 3; break;
875: case 0x00800000: mem_size = 4; break;
876: }
877: SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETPOS, TRUE, mem_size);
878: SetDlgItemText (hDlg, IDC_CHIPRAM, memsize_names[msi_chip[mem_size]]);
879:
880: switch (workprefs.fastmem_size) {
881: case 0x00000000: mem_size = 0; break;
882: case 0x00100000: mem_size = 1; break;
883: case 0x00200000: mem_size = 2; break;
884: case 0x00400000: mem_size = 3; break;
885: case 0x00800000: mem_size = 4; break;
886: case 0x01000000: mem_size = 5; break;
887: }
888: SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETPOS, TRUE, mem_size);
889: SetDlgItemText (hDlg, IDC_FASTRAM, memsize_names[msi_fast[mem_size]]);
890:
891: switch (workprefs.bogomem_size) {
892: case 0x00000000: mem_size = 0; break;
893: case 0x00080000: mem_size = 1; break;
894: case 0x00100000: mem_size = 2; break;
895: }
896: SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETPOS, TRUE, mem_size);
897: SetDlgItemText (hDlg, IDC_SLOWRAM, memsize_names[msi_bogo[mem_size]]);
898:
899: switch (workprefs.z3fastmem_size) {
900: case 0x00000000: mem_size = 0; break;
901: case 0x00100000: mem_size = 1; break;
902: case 0x00200000: mem_size = 2; break;
903: case 0x00400000: mem_size = 3; break;
904: case 0x00800000: mem_size = 4; break;
905: case 0x01000000: mem_size = 5; break;
906: case 0x02000000: mem_size = 6; break;
907: case 0x04000000: mem_size = 7; break;
908: }
909: SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETPOS, TRUE, mem_size);
910: SetDlgItemText (hDlg, IDC_Z3FASTRAM, memsize_names[msi_z3fast[mem_size]]);
911: }
912:
913: static void fix_values_startupdlg (void)
914: {
915: if (workprefs.chipmem_size > 0x200000)
916: workprefs.fastmem_size = 0;
917: }
918:
919: static BOOL CALLBACK StartupDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
920: {
921: switch (msg) {
922: case WM_INITDIALOG:
923: pages[STARTUP_ID] = hDlg;
924: SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CHIP_MEM, MAX_CHIP_MEM));
925: SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_FAST_MEM, MAX_FAST_MEM));
926: SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_SLOW_MEM, MAX_SLOW_MEM));
927: SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_Z3_MEM, MAX_Z3_MEM));
928:
929: case WM_USER:
930: fix_values_startupdlg ();
931: values_to_startupdlg (hDlg);
932: enable_for_startupdlg (hDlg);
933: return TRUE;
934:
935: case WM_COMMAND:
936: switch (wParam) {
937: case IDC_KICKCHOOSER:
938: KickStuffSelection (hDlg, 1);
939: break;
940: case IDC_KEYCHOOSER:
941: KickStuffSelection (hDlg, 0);
942: break;
943: default:
944: GetDlgItemText (hDlg, IDC_ROMFILE, romfile, CFG_ROM_LENGTH);
945: GetDlgItemText (hDlg, IDC_KEYFILE, keyfile, CFG_KEY_LENGTH);
946: workprefs.illegal_mem = IsDlgButtonChecked (hDlg, IDC_ILLEGAL);
947: }
948: break;
949:
950: case WM_HSCROLL:
951: workprefs.chipmem_size = memsizes[msi_chip[SendMessage (GetDlgItem (hDlg, IDC_CHIPMEM), TBM_GETPOS, 0, 0)]];
952: workprefs.bogomem_size = memsizes[msi_bogo[SendMessage (GetDlgItem (hDlg, IDC_SLOWMEM), TBM_GETPOS, 0, 0)]];
953: workprefs.fastmem_size = memsizes[msi_fast[SendMessage (GetDlgItem (hDlg, IDC_FASTMEM), TBM_GETPOS, 0, 0)]];
954: workprefs.z3fastmem_size = memsizes[msi_z3fast[SendMessage (GetDlgItem (hDlg, IDC_Z3FASTMEM), TBM_GETPOS, 0, 0)]];
955: fix_values_startupdlg ();
956: values_to_startupdlg (hDlg);
957: enable_for_startupdlg (hDlg);
958: break;
959:
960: case WM_NOTIFY:
961: switch (((NMHDR *) lParam)->code) {
962: case PSN_APPLY:
963: accept_workprefs ();
964: break;
965: case PSN_RESET:
966: if (allow_quit) {
967: quit_program = 1;
968: regs.spcflags |= SPCFLAG_BRK;
969: }
970: break;
971: }
972: }
973: return FALSE;
974: }
975:
976: static int logging_ids[] = { IDC_CPU0, IDC_CPU1, IDC_CPU2, IDC_CPU3 };
977:
978: static void enable_for_advanceddlg (HWND hDlg)
979: {
980: if (! running_winnt) {
981: EnableWindow (GetDlgItem (hDlg, IDC_LOGGING0), FALSE);
982: EnableWindow (GetDlgItem (hDlg, IDC_LOGGING2), FALSE);
983: }
984: }
985:
986: static void values_to_advanceddlg (HWND hDlg)
987: {
988: CheckDlgButton (hDlg, IDC_BLITIMM, workprefs.immediate_blits);
989: CheckDlgButton (hDlg, IDC_BLIT32, workprefs.blits_32bit_enabled);
990: CheckDlgButton (hDlg, IDC_JULIAN, julian_mode);
991: CheckRadioButton (hDlg, IDC_LOGGING0, IDC_LOGGING3, logging_ids[debug_logging]);
992: }
993:
994: static BOOL CALLBACK AdvancedDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
995: {
996: switch (msg) {
997: case WM_INITDIALOG:
998: pages[ADVANCED_ID] = hDlg;
999:
1000: case WM_USER:
1001: values_to_advanceddlg (hDlg);
1002: enable_for_advanceddlg (hDlg);
1003: return TRUE;
1004:
1005: case WM_COMMAND:
1006: debug_logging = (IsDlgButtonChecked (hDlg, IDC_LOGGING0) ? 0
1007: : IsDlgButtonChecked (hDlg, IDC_LOGGING1) ? 1
1008: : IsDlgButtonChecked (hDlg, IDC_LOGGING2) ? 2 : 3);
1009: workprefs.immediate_blits = IsDlgButtonChecked (hDlg, IDC_BLITIMM);
1010: workprefs.blits_32bit_enabled = IsDlgButtonChecked (hDlg, IDC_BLIT32);
1011: julian_mode = IsDlgButtonChecked (hDlg, IDC_JULIAN);
1012: break;
1013:
1014: case WM_NOTIFY:
1015: switch (((NMHDR *) lParam)->code) {
1016: case PSN_APPLY:
1017: accept_workprefs ();
1018: break;
1019:
1020: case PSN_RESET:
1021: if (allow_quit) {
1022: quit_program = 1;
1023: regs.spcflags |= SPCFLAG_BRK;
1024: }
1025: break;
1026: }
1027: }
1028: return FALSE;
1029: }
1030:
1031: static int cpu_ids[] = { IDC_CPU0, IDC_CPU1, IDC_CPU2, IDC_CPU3 };
1032:
1033: static void enable_for_cpudlg (HWND hDlg)
1034: {
1035: EnableWindow (GetDlgItem (hDlg, IDC_SPEED), workprefs.m68k_speed > 0);
1036: EnableWindow (GetDlgItem (hDlg, IDC_CS_CPU_TEXT), workprefs.m68k_speed > 0);
1037: EnableWindow (GetDlgItem (hDlg, IDC_CS_CHIPSET_TEXT), workprefs.m68k_speed > 0);
1038: EnableWindow (GetDlgItem (hDlg, IDC_COMPATIBLE), workprefs.cpu_level == 0);
1039: EnableWindow (GetDlgItem (hDlg, IDC_24BIT), workprefs.cpu_level > 0);
1040: }
1041:
1042: static void values_to_cpudlg (HWND hDlg)
1043: {
1044: SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, workprefs.m68k_speed <= 0 ? 1 : workprefs.m68k_speed);
1045:
1046: CheckDlgButton (hDlg, IDC_24BIT, workprefs.address_space_24);
1047: CheckDlgButton (hDlg, IDC_COMPATIBLE, workprefs.cpu_compatible);
1048: CheckRadioButton (hDlg, IDC_CPU0, IDC_CPU3, cpu_ids[workprefs.cpu_level]);
1049:
1050: if (workprefs.m68k_speed == -1)
1051: CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_HOST);
1052: else if (workprefs.m68k_speed == 0)
1053: CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_68000);
1054: else
1055: CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_ADJUSTABLE);
1056: }
1057:
1058: static void values_from_cpudlg (HWND hDlg)
1059: {
1060: int newcpu;
1061:
1062: workprefs.cpu_compatible = IsDlgButtonChecked (hDlg, IDC_COMPATIBLE);
1063: workprefs.address_space_24 = IsDlgButtonChecked (hDlg, IDC_24BIT);
1064: workprefs.m68k_speed = (IsDlgButtonChecked (hDlg, IDC_CS_HOST) ? -1
1065: : IsDlgButtonChecked (hDlg, IDC_CS_68000) ? 0
1066: : SendMessage (GetDlgItem (hDlg, IDC_SPEED), TBM_GETPOS, 0, 0));
1067:
1068: newcpu = (IsDlgButtonChecked (hDlg, IDC_CPU0) ? 0
1069: : IsDlgButtonChecked (hDlg, IDC_CPU1) ? 1
1070: : IsDlgButtonChecked (hDlg, IDC_CPU2) ? 2 : 3);
1071: if (newcpu != workprefs.cpu_level) {
1072: /* When switching away from 68000, disable 24 bit addressing. */
1073: if (workprefs.cpu_level == 0)
1074: workprefs.address_space_24 = 0;
1075: if (newcpu > 0)
1076: workprefs.cpu_compatible = 0;
1077: else
1078: workprefs.address_space_24 = 1;
1079: workprefs.cpu_level = newcpu;
1080: }
1081: if (pages[STARTUP_ID])
1082: SendMessage (pages[STARTUP_ID], WM_USER, 0, 0);
1083: if (pages[PDISPLAY_ID])
1084: SendMessage (pages[PDISPLAY_ID], WM_USER, 0, 0);
1085: }
1086:
1087: static BOOL CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1088: {
1089: static int recursive = 0;
1090: switch (msg) {
1091: case WM_INITDIALOG:
1092: pages[CPU_ID] = hDlg;
1093: SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETRANGE, TRUE, MAKELONG (MIN_M68K_PRIORITY, MAX_M68K_PRIORITY));
1094: SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPAGESIZE, 0, 1);
1095:
1096: case WM_USER:
1097: recursive++;
1098: values_to_cpudlg (hDlg);
1099: enable_for_cpudlg (hDlg);
1100: recursive--;
1101: return TRUE;
1102:
1103: case WM_COMMAND:
1104: if (recursive > 0)
1105: break;
1106: recursive++;
1107: values_from_cpudlg (hDlg);
1108: values_to_cpudlg (hDlg);
1109: enable_for_cpudlg (hDlg);
1110: recursive--;
1111: break;
1112:
1113: case WM_NOTIFY:
1114: switch (((NMHDR *) lParam)->code) {
1115: case PSN_APPLY:
1116: accept_workprefs ();
1117: break;
1118:
1119: case PSN_RESET:
1120: if (allow_quit) {
1121: quit_program = 1;
1122: regs.spcflags |= SPCFLAG_BRK;
1123: }
1124: break;
1125: }
1126: }
1127: return FALSE;
1128: }
1129:
1130: static void enable_for_sounddlg (HWND hDlg)
1131: {
1132: EnableWindow (GetDlgItem (hDlg, IDC_FREQUENCY), workprefs.produce_sound > 0);
1133: EnableWindow (GetDlgItem (hDlg, IDC_11KHZ), workprefs.produce_sound > 0);
1134: EnableWindow (GetDlgItem (hDlg, IDC_22KHZ), workprefs.produce_sound > 0);
1135: EnableWindow (GetDlgItem (hDlg, IDC_44KHZ), workprefs.produce_sound > 0);
1136: EnableWindow (GetDlgItem (hDlg, IDC_48KHZ), workprefs.produce_sound > 0);
1137:
1138: EnableWindow (GetDlgItem (hDlg, IDC_SOUNDSIZE), workprefs.produce_sound > 0);
1139: EnableWindow (GetDlgItem (hDlg, IDC_8BIT), workprefs.produce_sound > 0);
1140: EnableWindow (GetDlgItem (hDlg, IDC_16BIT), workprefs.produce_sound > 0);
1141:
1142: EnableWindow (GetDlgItem (hDlg, IDC_STEREO), workprefs.produce_sound > 0);
1143: EnableWindow (GetDlgItem (hDlg, IDC_DIRECTSOUND), full_property_sheet);
1144: }
1145:
1146: static void values_to_sounddlg (HWND hDlg)
1147: {
1148: int which_button;
1149:
1150: if (workprefs.sound_freq <= 11025)
1151: which_button = IDC_11KHZ;
1152: else if (workprefs.sound_freq <= 22050)
1153: which_button = IDC_22KHZ;
1154: else if (workprefs.sound_freq <= 44100)
1155: which_button = IDC_44KHZ;
1156: else
1157: which_button = IDC_48KHZ;
1158: CheckRadioButton (hDlg, IDC_11KHZ, IDC_48KHZ, which_button);
1159:
1160: CheckRadioButton (hDlg, IDC_8BIT, IDC_16BIT, workprefs.sound_bits == 16 ? IDC_16BIT : IDC_8BIT);
1161:
1162: switch (workprefs.produce_sound) {
1163: case 0: which_button = IDC_SOUND0; break;
1164: case 1: which_button = IDC_SOUND1; break;
1165: case 2: which_button = IDC_SOUND2; break;
1166: case 3: which_button = IDC_SOUND3; break;
1167: }
1168:
1169: CheckRadioButton (hDlg, IDC_SOUND0, IDC_SOUND3, which_button);
1170:
1171: CheckDlgButton (hDlg, IDC_STEREO, workprefs.stereo);
1172: CheckDlgButton (hDlg, IDC_DIRECTSOUND, use_direct_sound);
1173: }
1174:
1175: static void values_from_sounddlg (HWND hDlg)
1176: {
1177: workprefs.sound_bits = IsDlgButtonChecked (hDlg, IDC_8BIT) ? 8 : 16;
1178: workprefs.sound_freq = (IsDlgButtonChecked (hDlg, IDC_11KHZ) ? 11025
1179: : IsDlgButtonChecked (hDlg, IDC_22KHZ) ? 22050
1180: : IsDlgButtonChecked (hDlg, IDC_44KHZ) ? 44100 : 48000);
1181: workprefs.produce_sound = (IsDlgButtonChecked (hDlg, IDC_SOUND0) ? 0
1182: : IsDlgButtonChecked (hDlg, IDC_SOUND1) ? 1
1183: : IsDlgButtonChecked (hDlg, IDC_SOUND2) ? 2 : 3);
1184: workprefs.stereo = IsDlgButtonChecked (hDlg, IDC_STEREO) ? 1 : 0;
1185: use_direct_sound = IsDlgButtonChecked (hDlg, IDC_DIRECTSOUND) ? 1 : 0;
1186: }
1187:
1188: static BOOL CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1189: {
1190: static int recursive = 0;
1191: switch (msg) {
1192: case WM_INITDIALOG:
1193: pages[SOUND_ID] = hDlg;
1194:
1195: case WM_USER:
1196: recursive++;
1197: values_to_sounddlg (hDlg);
1198: enable_for_sounddlg (hDlg);
1199: recursive--;
1200: return TRUE;
1201:
1202: case WM_COMMAND:
1203: if (recursive > 0)
1204: break;
1205: recursive++;
1206: values_from_sounddlg (hDlg);
1207: enable_for_sounddlg (hDlg);
1208: recursive--;
1209: break;
1210:
1211: case WM_NOTIFY:
1212: switch (((NMHDR *) lParam)->code) {
1213: case PSN_APPLY:
1214: accept_workprefs ();
1215: break;
1216: case PSN_RESET:
1217: if (allow_quit) {
1218: quit_program = 1;
1219: regs.spcflags |= SPCFLAG_BRK;
1220: }
1221: break;
1222: }
1223: break;
1224: }
1225: return FALSE;
1226: }
1227:
1228: struct fsvdlg_vals
1229: {
1230: char volume[4096];
1231: char rootdir[4096];
1232: int rw;
1233: };
1234:
1235: static struct fsvdlg_vals empty_fsvdlg = { "", "", 1 };
1236: static struct fsvdlg_vals current_fsvdlg;
1237:
1238: struct hfdlg_vals
1239: {
1240: char volumename[4096];
1241: char filename[4096];
1242: char sectors[16];
1243: char reserved[16];
1244: char surfaces[16];
1245: char cylinders[16];
1246: int rw;
1247: };
1248:
1249: static struct hfdlg_vals empty_hfdlg = { "", "", "", "", "", "", 1 };
1250: static struct hfdlg_vals current_hfdlg;
1251:
1252: static int CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1253: {
1254: static int recursive = 0;
1255: BROWSEINFO browse_info;
1256: char directory_path[MAX_PATH] = "";
1257: LPITEMIDLIST browse;
1258: LONG setting;
1259:
1260: browse_info.hwndOwner = hDlg;
1261: browse_info.pidlRoot = NULL;
1262: browse_info.pszDisplayName = directory_path;
1263: browse_info.lpszTitle = "Please select your file-system root directory...";
1264: browse_info.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS;
1265: browse_info.lpfn = NULL;
1266: browse_info.iImage = 0;
1267:
1268: switch (msg) {
1269: case WM_INITDIALOG:
1270: recursive++;
1271: SetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume);
1272: SetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir);
1273: CheckDlgButton (hDlg, IDC_RW, current_fsvdlg.rw);
1274: recursive--;
1275: return TRUE;
1276:
1277: case WM_COMMAND:
1278: if (recursive)
1279: break;
1280: recursive++;
1281: if (HIWORD (wParam) == BN_CLICKED) {
1282: switch (LOWORD (wParam)) {
1283: case IDC_SELECTOR:
1284: if ((browse = SHBrowseForFolder (&browse_info)) != NULL) {
1285: SHGetPathFromIDList (browse, directory_path);
1286: SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
1287: }
1288: break;
1289: case IDOK:
1290: if (strlen (current_fsvdlg.rootdir) == 0) {
1291: MessageBox (hDlg, "You must select a path!", "Settings Error",
1292: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1293: break;
1294: }
1295: if (strlen (current_fsvdlg.volume) == 0) {
1296: MessageBox (hDlg, "You must select a name for the volume!", "Settings Error",
1297: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1298: break;
1299: }
1300: EndDialog (hDlg, 1);
1301:
1302: break;
1303: case IDCANCEL:
1304: EndDialog (hDlg, 0);
1305: break;
1306: }
1307: }
1308: GetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir, sizeof current_fsvdlg.rootdir);
1309: GetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume, sizeof current_fsvdlg.volume);
1310: current_fsvdlg.rw = IsDlgButtonChecked (hDlg, IDC_RW);
1311: recursive--;
1312: break;
1313: }
1314: return FALSE;
1315: }
1316:
1317: static int CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1318: {
1319: static int recursive = 0;
1320: LONG setting;
1321:
1322: switch (msg) {
1323: case WM_INITDIALOG:
1324: recursive++;
1325: SetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename);
1326: SetDlgItemText (hDlg, IDC_SECTORS, current_hfdlg.sectors);
1327: SetDlgItemText (hDlg, IDC_HEADS, current_hfdlg.surfaces);
1328: SetDlgItemText (hDlg, IDC_RESERVED, current_hfdlg.reserved);
1329: CheckDlgButton (hDlg, IDC_RW, current_hfdlg.rw);
1330: recursive--;
1331: return TRUE;
1332:
1333: case WM_COMMAND:
1334: if (recursive)
1335: break;
1336: recursive++;
1337:
1338: if (HIWORD (wParam) == BN_CLICKED) {
1339: switch (LOWORD (wParam)) {
1340: case IDC_CREATEHF:
1341: setting = CalculateHardfileSize (hDlg);
1342: CreateHardFile (hDlg, setting);
1343: break;
1344: case IDC_SELECTOR:
1345: DiskSelection (hDlg, IDC_PATH_NAME, 2);
1346: break;
1347: case IDOK:
1348: if (strlen (current_hfdlg.filename) == 0) {
1349: MessageBox (hDlg, "You must select a file...", "Settings Error",
1350: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1351: break;
1352: }
1353: EndDialog (hDlg, 1);
1354: break;
1355: case IDCANCEL:
1356: EndDialog (hDlg, 0);
1357: break;
1358: }
1359: }
1360:
1361: GetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename, sizeof current_hfdlg.filename);
1362: GetDlgItemText (hDlg, IDC_SECTORS, current_hfdlg.sectors, sizeof current_hfdlg.sectors);
1363: GetDlgItemText (hDlg, IDC_RESERVED, current_hfdlg.reserved, sizeof current_hfdlg.reserved);
1364: GetDlgItemText (hDlg, IDC_HEADS, current_hfdlg.surfaces, sizeof current_hfdlg.surfaces);
1365: current_hfdlg.rw = IsDlgButtonChecked (hDlg, IDC_RW);
1366: recursive--;
1367:
1368: break;
1369: }
1370: return FALSE;
1371: }
1372:
1373: static char *hd_columns[] = { "Volume", "Path", "R/W", "Sectors", "Surfaces", "Reserved" };
1374:
1375: static void init_harddisk_list (HWND hDlg, HWND list)
1376: {
1377: int i;
1378:
1379: for (i = 0; i < 6; i++) {
1380: LV_COLUMN lvcolumn;
1381: int width;
1382: lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
1383: lvcolumn.iSubItem = i;
1384: lvcolumn.fmt = LVCFMT_LEFT;
1385: lvcolumn.pszText = hd_columns[i];
1386: width = ListView_GetStringWidth (list, hd_columns[i]) + 15;
1387: lvcolumn.cx = width;
1388: ListView_InsertColumn (list, i, &lvcolumn);
1389: ListView_SetColumnWidth (list, i, width);
1390: }
1391:
1392: /* Turn on full-row-select option */
1393: ListView_SetExtendedListViewStyle (list, LVS_EX_FULLROWSELECT);
1394: }
1395:
1396: static void fill_harddisk_entry (HWND hDlg, HWND list, int i)
1397: {
1398: char *volume, *rootdir;
1399: int size, cylinders, sectors, reserved, surfaces, readonly;
1400: int count;
1401:
1402: get_filesys_unit (work_mountinfo, i, &volume, &rootdir, &readonly,
1403: §ors, &surfaces, &reserved, &cylinders, &size);
1404:
1405: count = ListView_GetItemCount (list);
1406: while (i >= count) {
1407: LV_ITEM lvstruct;
1408: lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
1409: lvstruct.pszText = "";
1410: lvstruct.lParam = 0;
1411: lvstruct.iItem = count;
1412: lvstruct.iSubItem = 0;
1413: ListView_InsertItem (list, &lvstruct);
1414: count++;
1415: }
1416:
1417: if (is_hardfile (work_mountinfo, i)) {
1418: char buffer[20];
1419: ListView_SetItemText (list, i, 0, volume);
1420: ListView_SetItemText (list, i, 1, rootdir);
1421: ListView_SetItemText (list, i, 2, readonly ? "yes" : "no");
1422: sprintf (buffer, "%d", sectors);
1423: ListView_SetItemText (list, i, 3, buffer);
1424: sprintf (buffer, "%d", surfaces);
1425: ListView_SetItemText (list, i, 4, buffer);
1426: sprintf (buffer, "%d", reserved);
1427: ListView_SetItemText (list, i, 5, buffer);
1428: } else {
1429: ListView_SetItemText (list, i, 0, volume);
1430: ListView_SetItemText (list, i, 1, rootdir);
1431: ListView_SetItemText (list, i, 2, "n/a");
1432: ListView_SetItemText (list, i, 3, "n/a");
1433: ListView_SetItemText (list, i, 4, "n/a");
1434: ListView_SetItemText (list, i, 5, "n/a");
1435: }
1436:
1437: if (volume)
1438: free (volume);
1439: if (rootdir)
1440: free (rootdir);
1441: }
1442:
1443: static void values_to_harddiskdlg (HWND hDlg)
1444: {
1445: HWND list = GetDlgItem (hDlg, IDC_VOLUMELIST);
1446: int nr = nr_units (work_mountinfo);
1447: int i;
1448:
1449: ListView_DeleteAllItems (list);
1450: for (i = 0; i < nr; i++) {
1451: fill_harddisk_entry (hDlg, list, i);
1452: }
1453: }
1454:
1455: static void new_filesys (HWND hDlg)
1456: {
1457: const char *result;
1458:
1459: result = add_filesys_unit (work_mountinfo, current_fsvdlg.volume,
1460: current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0);
1461: if (result)
1462: MessageBox (hDlg, result, "Bad directory",
1463: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1464: else
1465: workprefs.mountinfo = work_mountinfo;
1466: }
1467:
1468: static void new_hardfile (HWND hDlg)
1469: {
1470: int sectors, reserved, surfaces;
1471: const char *result;
1472: sectors = atoi (current_hfdlg.sectors);
1473: surfaces = atoi (current_hfdlg.surfaces);
1474: reserved = atoi (current_hfdlg.reserved);
1475:
1476: result = add_filesys_unit (work_mountinfo, 0, current_hfdlg.filename,
1477: ! current_hfdlg.rw, sectors, surfaces, reserved);
1478: if (result)
1479: MessageBox (hDlg, result, "Bad hardfile",
1480: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1481: else
1482: workprefs.mountinfo = work_mountinfo;
1483: }
1484:
1485: static void harddisk_remove (HWND hDlg)
1486: {
1487: int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
1488: if (entry < 0)
1489: return;
1490: kill_filesys_unit (work_mountinfo, entry);
1491: workprefs.mountinfo = work_mountinfo;
1492: }
1493:
1494: static void harddisk_move (HWND hDlg, int up)
1495: {
1496: int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
1497: if (entry < 0)
1498: return;
1499: if (move_filesys_unit (work_mountinfo, entry, up ? entry - 1 : entry + 1) >= 0)
1500: workprefs.mountinfo = work_mountinfo;
1501: }
1502:
1503: static void harddisk_edit (HWND hDlg)
1504: {
1505: char *volume, *rootdir;
1506: int size, cylinders, sectors, reserved, surfaces, readonly;
1507:
1508: int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
1509: if (entry < 0)
1510: return;
1511:
1512: get_filesys_unit (work_mountinfo, entry, &volume, &rootdir, &readonly,
1513: §ors, &surfaces, &reserved, &cylinders, &size);
1514:
1515: if (volume == 0) {
1516: /* Hardfile */
1517: strncpy (current_hfdlg.filename, rootdir, (sizeof current_hfdlg.filename) - 1);
1518: current_hfdlg.filename[(sizeof current_hfdlg.filename) - 1] = '\0';
1519: sprintf (current_hfdlg.sectors, "%d", sectors);
1520: sprintf (current_hfdlg.reserved, "%d", reserved);
1521: sprintf (current_hfdlg.surfaces, "%d", surfaces);
1522: sprintf (current_hfdlg.cylinders, "%d", cylinders);
1523: current_hfdlg.rw = readonly;
1524: if (DialogBox (hInst, MAKEINTRESOURCE (IDD_HARDFILE), hDlg, HardfileSettingsProc)) {
1525: const char *result;
1526: sectors = atoi (current_hfdlg.sectors);
1527: surfaces = atoi (current_hfdlg.surfaces);
1528: reserved = atoi (current_hfdlg.reserved);
1529: cylinders = atoi (current_hfdlg.cylinders);
1530: result = set_filesys_unit (work_mountinfo, entry, 0, current_hfdlg.filename,
1531: ! current_hfdlg.rw, sectors, surfaces, reserved);
1532: if (result)
1533: MessageBox (hDlg, result, "Bad hardfile",
1534: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1535: else
1536: workprefs.mountinfo = work_mountinfo;
1537: }
1538: } else {
1539: /* Filesystem */
1540: strncpy (current_fsvdlg.rootdir, rootdir, (sizeof current_fsvdlg.rootdir) - 1);
1541: current_fsvdlg.rootdir[(sizeof current_fsvdlg.rootdir) - 1] = '\0';
1542: strncpy (current_fsvdlg.volume, volume, (sizeof current_fsvdlg.volume) - 1);
1543: current_fsvdlg.volume[(sizeof current_fsvdlg.volume) - 1] = '\0';
1544: current_fsvdlg.rw = readonly;
1545: if (DialogBox (hInst, MAKEINTRESOURCE (IDD_FILESYS), hDlg, VolumeSettingsProc)) {
1546: const char *result;
1547: result = set_filesys_unit (work_mountinfo, entry, current_fsvdlg.volume,
1548: current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0);
1549: if (result)
1550: MessageBox (hDlg, result, "Bad hardfile",
1551: MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
1552: else
1553: workprefs.mountinfo = work_mountinfo;
1554: }
1555: }
1556: free (volume);
1557: free (rootdir);
1558:
1559: }
1560:
1561: static void harddiskdlg_button (HWND hDlg, int button)
1562: {
1563: int i;
1564: int clicked_entry;
1565: switch (button) {
1566: case IDC_NEW_FS:
1567: current_fsvdlg = empty_fsvdlg;
1568: if (DialogBox (hInst, MAKEINTRESOURCE (IDD_FILESYS), hDlg, VolumeSettingsProc))
1569: new_filesys (hDlg);
1570: break;
1571:
1572: case IDC_NEW_HF:
1573: current_hfdlg = empty_hfdlg;
1574: if (DialogBox (hInst, MAKEINTRESOURCE (IDD_HARDFILE), hDlg, HardfileSettingsProc))
1575: new_hardfile (hDlg);
1576: break;
1577:
1578: case IDC_EDIT:
1579: harddisk_edit (hDlg);
1580: break;
1581:
1582: case IDC_REMOVE:
1583: harddisk_remove (hDlg);
1584: break;
1585:
1586: case IDC_UP:
1587: harddisk_move (hDlg, 1);
1588: break;
1589:
1590: case IDC_DOWN:
1591: harddisk_move (hDlg, 0);
1592: break;
1593: }
1594: }
1595:
1596: static void harddiskdlg_volume_notify (HWND hDlg, NM_LISTVIEW *nmlistview)
1597: {
1598: HWND list = nmlistview->hdr.hwndFrom;
1599: int dblclick = 0;
1600: int entry = 0;
1601:
1602: switch (nmlistview->hdr.code) {
1603: case NM_DBLCLK:
1604: dblclick = 1;
1605: /* fall through */
1606: case NM_CLICK:
1607: entry = listview_entry_from_click (list);
1608: if (entry >= 0 && dblclick) {
1609: harddisk_edit (hDlg);
1610: values_to_harddiskdlg (hDlg);
1611: }
1612: break;
1613: }
1614: }
1615:
1616: static BOOL CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1617: {
1618: int i;
1619: drive_specs tempdrive;
1620:
1621: switch (msg) {
1622: case WM_INITDIALOG:
1623: pages[HARDDISK_ID] = hDlg;
1624:
1625: init_harddisk_list (hDlg, GetDlgItem (hDlg, IDC_VOLUMELIST));
1626:
1627: case WM_USER:
1628: values_to_harddiskdlg (hDlg);
1629: break;
1630:
1631: case WM_COMMAND:
1632: if (HIWORD (wParam) == BN_CLICKED)
1633: harddiskdlg_button (hDlg, LOWORD (wParam));
1634: values_to_harddiskdlg (hDlg);
1635: break;
1636:
1637: case WM_NOTIFY:
1638: if (((LPNMHDR) lParam)->idFrom == IDC_VOLUMELIST)
1639: harddiskdlg_volume_notify (hDlg, (NM_LISTVIEW *) lParam);
1640: else {
1641: switch (((NMHDR *) lParam)->code) {
1642: case PSN_APPLY:
1643: accept_workprefs ();
1644: break;
1645: case PSN_RESET:
1646: if (allow_quit) {
1647: quit_program = 1;
1648: regs.spcflags |= SPCFLAG_BRK;
1649: }
1650: break;
1651: }
1652: }
1653: return TRUE;
1654: default:
1655: return FALSE;
1656: }
1657:
1658: return FALSE;
1659: }
1660:
1661: static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1662: {
1663: static int recursive = 0;
1664:
1665: switch (msg) {
1666: case WM_INITDIALOG:
1667: pages[FLOPPY_ID] = hDlg;
1668:
1669: case WM_USER:
1670: recursive++;
1671: SetDlgItemText (hDlg, IDC_DF0TEXT, workprefs.df[0]);
1672: SetDlgItemText (hDlg, IDC_DF1TEXT, workprefs.df[1]);
1673: SetDlgItemText (hDlg, IDC_DF2TEXT, workprefs.df[2]);
1674: SetDlgItemText (hDlg, IDC_DF3TEXT, workprefs.df[3]);
1675: recursive--;
1676: break;
1677:
1678: case WM_COMMAND:
1679: if (recursive > 0)
1680: break;
1681: recursive++;
1682: switch (wParam) {
1683: case IDC_DF0:
1684: DiskSelection (hDlg, wParam, 0);
1685: break;
1686: case IDC_DF1:
1687: DiskSelection (hDlg, wParam, 0);
1688: break;
1689: case IDC_DF2:
1690: DiskSelection (hDlg, wParam, 0);
1691: break;
1692: case IDC_DF3:
1693: DiskSelection (hDlg, wParam, 0);
1694: break;
1695: case IDC_EJECT0:
1696: SetDlgItemText (hDlg, IDC_DF0TEXT, "");
1697: break;
1698: case IDC_EJECT1:
1699: SetDlgItemText (hDlg, IDC_DF1TEXT, "");
1700: break;
1701: case IDC_EJECT2:
1702: SetDlgItemText (hDlg, IDC_DF2TEXT, "");
1703: break;
1704: case IDC_EJECT3:
1705: SetDlgItemText (hDlg, IDC_DF3TEXT, "");
1706: break;
1707: case IDC_CREATE:
1708: DiskSelection (hDlg, wParam, 1);
1709: break;
1710: }
1711: GetDlgItemText (hDlg, IDC_DF0TEXT, workprefs.df[0], 255);
1712: GetDlgItemText (hDlg, IDC_DF1TEXT, workprefs.df[1], 255);
1713: GetDlgItemText (hDlg, IDC_DF2TEXT, workprefs.df[2], 255);
1714: GetDlgItemText (hDlg, IDC_DF3TEXT, workprefs.df[3], 255);
1715: recursive--;
1716: break;
1717:
1718: case WM_NOTIFY:
1719: switch (((NMHDR *) lParam)->code) {
1720: case PSN_APPLY:
1721: accept_workprefs ();
1722: break;
1723: case PSN_RESET:
1724: if (allow_quit) {
1725: quit_program = 1;
1726: regs.spcflags |= SPCFLAG_BRK;
1727: }
1728: break;
1729: }
1730: return TRUE;
1731: default:
1732: return FALSE;
1733: }
1734:
1735: return FALSE;
1736: }
1737:
1738: static void values_from_portsdlg (HWND hDlg)
1739: {
1740: int item;
1741: char joyspec[3] = "MA";
1742: if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY0)) {
1743: if (joystickspresent[0])
1744: joyspec[1] = '0';
1745: else
1746: joyspec[1] = 'A';
1747: }
1748: if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY1)) {
1749: if (joystickspresent[1])
1750: joyspec[1] = '1';
1751: else
1752: joyspec[1] = 'B';
1753: }
1754: if (IsDlgButtonChecked (hDlg, IDC_PORT0_MOUSE))
1755: joyspec[0] = 'M';
1756: if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDA))
1757: joyspec[0] = 'A';
1758: if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDB))
1759: joyspec[0] = 'B';
1760: if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDC))
1761: joyspec[0] = 'C';
1762:
1763: if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY0)) {
1764: if (joystickspresent[0])
1765: joyspec[1] = '0';
1766: else
1767: joyspec[1] = 'A';
1768: }
1769: if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY1)) {
1770: if (joystickspresent[1])
1771: joyspec[1] = '1';
1772: else
1773: joyspec[1] = 'B';
1774: }
1775: if (IsDlgButtonChecked (hDlg, IDC_PORT1_MOUSE))
1776: joyspec[1] = 'M';
1777: if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDA))
1778: joyspec[1] = 'A';
1779: if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDB))
1780: joyspec[1] = 'B';
1781: if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDC))
1782: joyspec[1] = 'C';
1783:
1784: workprefs.fake_joystick = parse_joy_spec (joyspec);
1785:
1786: GetDlgItemText (hDlg, IDC_PARALLEL, prtname, CFG_PAR_LENGTH);
1787:
1788: item = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETCURSEL, 0, 0L);
1789: switch (item) {
1790: case 1:
1791: case 2:
1792: case 3:
1793: case 4:
1794: workprefs.use_serial = 1;
1795: #ifdef __GNUC__
1796: sprintf (sername, "COM%d", item);
1797: #else
1798: _snprintf (sername, CFG_SER_LENGTH, "COM%d", item);
1799: #endif
1800: break;
1801: default:
1802: workprefs.use_serial = 0;
1803: break;
1804: }
1805: }
1806:
1807: static void values_to_portsdlg (HWND hDlg)
1808: {
1809: LONG item_height;
1810: RECT rect;
1811:
1812: UpdateRadioButtons (hDlg, GetDlgItem (hDlg, IDC_PORT0));
1813: UpdateRadioButtons (hDlg, GetDlgItem (hDlg, IDC_PORT1));
1814: SetDlgItemText (hDlg, IDC_PARALLEL, prtname);
1815: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_RESETCONTENT, 0, 0L);
1816: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "None");
1817: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM1");
1818: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM2");
1819: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM3");
1820: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM4");
1821: if (workprefs.use_serial == 0)
1822: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 0, 0L);
1823: else {
1824: switch (sername[strlen (sername) - 1]) {
1825: case '2':
1826: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 2, 0L);
1827: break;
1828: case '3':
1829: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 3, 0L);
1830: break;
1831: case '4':
1832: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 4, 0L);
1833: break;
1834: default:
1835: SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 1, 0L);
1836: break;
1837: }
1838: }
1839:
1840: /* Retrieve the height, in pixels, of a list item. */
1841: item_height = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETITEMHEIGHT, 0, 0L);
1842: if (item_height != CB_ERR) {
1843: /* Get actual box position and size. */
1844: GetWindowRect (GetDlgItem (hDlg, IDC_SERIAL), &rect);
1845: rect.bottom = (rect.top + item_height * 5
1846: + SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETITEMHEIGHT, (WPARAM) - 1, 0L)
1847: + item_height);
1848: SetWindowPos (GetDlgItem (hDlg, IDC_SERIAL), 0, 0, 0, rect.right - rect.left,
1849: rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER);
1850: }
1851: }
1852:
1853: /* Handle messages for the Joystick Settings page of our property-sheet */
1854: static BOOL CALLBACK PortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1855: {
1856: static int recursive = 0;
1857:
1858: switch (msg) {
1859: case WM_INITDIALOG:
1860: pages[PORTS_ID] = hDlg;
1861: if (! full_property_sheet) {
1862: EnableWindow (GetDlgItem (hDlg, IDC_SERIAL), FALSE);
1863: EnableWindow (GetDlgItem (hDlg, IDC_PARALLEL), FALSE);
1864: }
1865:
1866: case WM_USER:
1867: recursive++;
1868: values_to_portsdlg (hDlg);
1869: recursive--;
1870: return TRUE;
1871:
1872: case WM_COMMAND:
1873: if (recursive > 0)
1874: break;
1875: recursive++;
1876: values_from_portsdlg (hDlg);
1877: recursive--;
1878: break;
1879:
1880: case WM_NOTIFY:
1881: switch (((NMHDR *) lParam)->code) {
1882: case PSN_APPLY:
1883: accept_workprefs ();
1884: break;
1885: case PSN_RESET:
1886: if (allow_quit) {
1887: quit_program = 1;
1888: regs.spcflags |= SPCFLAG_BRK;
1889: }
1890: break;
1891: }
1892: return FALSE;
1893: }
1894: return FALSE;
1895: }
1896:
1897: static void CALLBACK InitPropertySheet (HWND hDlg, UINT msg, LPARAM lParam)
1898: {
1899: int i;
1900:
1901: switch (msg) {
1902: case PSCB_INITIALIZED:
1903: #if 0
1904: if (! full_property_sheet) {
1905: PropSheet_RemovePage (hDlg, 0, NULL);
1906: PropSheet_RemovePage (hDlg, 0, NULL);
1907: PropSheet_RemovePage (hDlg, 0, NULL);
1908: PropSheet_RemovePage (hDlg, 2, NULL);
1909: }
1910: #endif
1911:
1912: for (i = 0; i < C_PAGES; i++)
1913: pages[i] = NULL;
1914:
1915: break;
1916: }
1917: }
1918:
1919:
1920: #ifdef __GNUC__
1921: #define DUN1 u1 ## .
1922: #define DUN2 u2 ## .
1923: #define DUN3 u3 ## .
1924: #else
1925: #define DUN1
1926: #define DUN2
1927: #define DUN3
1928: #endif
1929:
1930: static void init_page (PROPSHEETPAGE *ppage, int id, int tmpl, int icon, int title,
1931: BOOL (* CALLBACK func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam))
1932: {
1933: ppage[id].dwSize = sizeof (PROPSHEETPAGE);
1934: ppage[id].dwFlags = PSP_USETITLE | PSP_USEICONID;
1935: ppage[id].hInstance = hInst;
1936: ppage[id].DUN1 pszTemplate = MAKEINTRESOURCE (tmpl);
1937: ppage[id].DUN2 pszIcon = MAKEINTRESOURCE (icon);
1938: ppage[id].pszTitle = MAKEINTRESOURCE (title);
1939: ppage[id].pfnDlgProc = (LPFNPSPCALLBACK) func;
1940: ppage[id].lParam = 0;
1941: ppage[id].pfnCallback = NULL;
1942: ppage[id].pcRefParent = NULL;
1943: }
1944:
1945: int GetSettings (int all_options)
1946: {
1947: int psresult;
1948: PROPSHEETPAGE ppage[C_PAGES];
1949: PROPSHEETHEADER pHeader;
1950:
1951: full_property_sheet = all_options;
1952: allow_quit = ! all_options;
1953: pguiprefs = all_options ? &currprefs : &changed_prefs;
1954: workprefs = *pguiprefs;
1955: printf ("A\n");
1956: work_mountinfo = dup_mountinfo (pguiprefs->mountinfo);
1957: printf ("B\n");
1958:
1959: init_page (ppage, LOADSAVE_ID, IDD_LOADSAVE, IDI_LOADSAVE, IDS_LOADSAVE, LoadSaveDlgProc);
1960: init_page (ppage, STARTUP_ID, IDD_STARTUP, IDI_STARTUP, IDS_STARTUP, StartupDlgProc);
1961: init_page (ppage, SOUND_ID, IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc);
1962: init_page (ppage, ADISPLAY_ID, IDD_ADISPLAY, IDI_ADISPLAY, IDS_ADISPLAY, ADisplayDlgProc);
1963: init_page (ppage, PDISPLAY_ID, IDD_PDISPLAY, IDI_PDISPLAY, IDS_PDISPLAY, PDisplayDlgProc);
1964: init_page (ppage, CPU_ID, IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc);
1965: init_page (ppage, HARDDISK_ID, IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc);
1966: init_page (ppage, FLOPPY_ID, IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc);
1967: init_page (ppage, PORTS_ID, IDD_PORTS, IDI_PORTS, IDS_PORTS, PortsDlgProc);
1968: init_page (ppage, ADVANCED_ID, IDD_ADVANCED, IDI_ADVANCED, IDS_ADVANCED, AdvancedDlgProc);
1969: init_page (ppage, ABOUT_ID, IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc);
1970:
1971: pHeader.dwSize = sizeof (PROPSHEETHEADER);
1972: pHeader.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK | PSH_NOAPPLYNOW;
1973: if (! all_options && workprefs.gfx_afullscreen && workprefs.gfx_width < 640)
1974: pHeader.hwndParent = NULL;
1975: else
1976: pHeader.hwndParent = hAmigaWnd;
1977: pHeader.hInstance = hInst;
1978: pHeader.DUN1 pszIcon = MAKEINTRESOURCE (IDI_UAEICON);
1979: pHeader.pszCaption = "WinUAE";
1980: pHeader.nPages = C_PAGES;
1981: pHeader.DUN2 nStartPage = 0;
1982: pHeader.DUN3 ppsp = ppage;
1983: pHeader.pfnCallback = (PFNPROPSHEETCALLBACK) InitPropertySheet;
1984:
1985: psresult = PropertySheet (&pHeader);
1986:
1987: free_mountinfo (work_mountinfo);
1988:
1989: if (psresult == -1 || quit_program)
1990: return 0;
1991:
1992: return 1;
1993: }
1994:
1995: int gui_init (void)
1996: {
1997: GetSettings (1);
1998: return 1;
1999: }
2000:
2001: int gui_update (void)
2002: {
2003: return 1;
2004: }
2005:
2006: void gui_exit (void)
2007: {
2008: }
2009:
2010: char *labels[5] =
2011: {"Power", "0", "1", "2", "3"};
2012: extern HWND hStatusWnd;
2013: int led_states[5];
2014:
2015: void gui_led (int led, int on)
2016: {
2017: WORD type;
2018:
2019: return;
2020:
2021: if (hStatusWnd == 0)
2022: return;
2023:
2024: if (led_states[led] == on)
2025: return;
2026:
2027: led_states[led] = on;
2028:
2029: if (on)
2030: type = SBT_POPOUT;
2031: else
2032: type = 0;
2033:
2034: PostMessage (hStatusWnd, SB_SETTEXT, (WPARAM) ((led + 1) | type), (LPARAM) labels[led]);
2035: }
2036:
2037: void gui_filename (int num, const char *name)
2038: {
2039: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.