Annotation of uae/src/od-win32/win32gui.c, revision 1.1.1.2

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: 
        !           493: static void init_aboutdlg (HWND hDlg)
        !           494: {
        !           495:     CHARFORMAT CharFormat;
        !           496:     CharFormat.cbSize = sizeof (CharFormat);
        !           497: 
        !           498:     SetDlgItemText (hDlg, IDC_RICHEDIT1, "UAE for Win32/DirectX");
        !           499:     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           500:     CharFormat.dwMask |= CFM_BOLD | CFM_SIZE | CFM_FACE;
        !           501:     CharFormat.dwEffects = CFE_BOLD;
        !           502:     CharFormat.yHeight = 18 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           503: 
        !           504:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           505:     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           506:     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           507: 
        !           508:     SetDlgItemText (hDlg, IDC_RICHEDIT2, PROGNAME);
        !           509:     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           510:     CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
        !           511:     CharFormat.yHeight = 10 * 20;
        !           512:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           513:     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           514:     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           515: 
        !           516:     SetDlgItemText (hDlg, IDC_AMIGAHOME, "Amiga");
        !           517:     SendDlgItemMessage (hDlg, IDC_AMIGAHOME, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           518:     CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
        !           519:     CharFormat.dwEffects = CFE_UNDERLINE;
        !           520:     CharFormat.yHeight = 12 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           521: 
        !           522:     CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
        !           523:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           524:     SendDlgItemMessage (hDlg, IDC_AMIGAHOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           525:     SendDlgItemMessage (hDlg, IDC_AMIGAHOME, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           526: 
        !           527:     SetDlgItemText (hDlg, IDC_CLOANTOHOME, "Cloanto");
        !           528:     SendDlgItemMessage (hDlg, IDC_CLOANTOHOME, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           529:     CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
        !           530:     CharFormat.dwEffects = CFE_UNDERLINE;
        !           531:     CharFormat.yHeight = 12 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           532: 
        !           533:     CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
        !           534:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           535:     SendDlgItemMessage (hDlg, IDC_CLOANTOHOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           536:     SendDlgItemMessage (hDlg, IDC_CLOANTOHOME, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           537: 
        !           538:     SetDlgItemText (hDlg, IDC_WINUAEHOME, "WinUAE");
        !           539:     SendDlgItemMessage (hDlg, IDC_WINUAEHOME, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           540:     CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
        !           541:     CharFormat.dwEffects = CFE_UNDERLINE;
        !           542:     CharFormat.yHeight = 12 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           543: 
        !           544:     CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
        !           545:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           546:     SendDlgItemMessage (hDlg, IDC_WINUAEHOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           547:     SendDlgItemMessage (hDlg, IDC_WINUAEHOME, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           548: 
        !           549:     SetDlgItemText (hDlg, IDC_UAEHOME, "UAE");
        !           550:     SendDlgItemMessage (hDlg, IDC_UAEHOME, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           551:     CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
        !           552:     CharFormat.dwEffects = CFE_UNDERLINE;
        !           553:     CharFormat.yHeight = 12 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           554: 
        !           555:     CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
        !           556:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           557:     SendDlgItemMessage (hDlg, IDC_UAEHOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           558:     SendDlgItemMessage (hDlg, IDC_UAEHOME, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           559: 
        !           560:     SetDlgItemText (hDlg, IDC_PICASSOHOME, "Picasso96");
        !           561:     SendDlgItemMessage (hDlg, IDC_PICASSOHOME, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        !           562:     CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
        !           563:     CharFormat.dwEffects = CFE_UNDERLINE;
        !           564:     CharFormat.yHeight = 12 * 20;      /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
        !           565: 
        !           566:     CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
        !           567:     strcpy (CharFormat.szFaceName, "Times New Roman");
        !           568:     SendDlgItemMessage (hDlg, IDC_PICASSOHOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        !           569:     SendDlgItemMessage (hDlg, IDC_PICASSOHOME, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
        !           570: }
        !           571: 
        !           572: static BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !           573: {
        !           574:     switch (msg) {
        !           575:      case WM_INITDIALOG:
        !           576:        pages[ABOUT_ID] = hDlg;
        !           577:        init_aboutdlg (hDlg);
        !           578:        break;
        !           579: 
        !           580:      case WM_COMMAND:
        !           581:        if (wParam == IDC_CONTRIBUTORS) {
        !           582:            DisplayContributors (hDlg);
        !           583:        }
        !           584:        break;
        !           585:      case WM_LBUTTONDOWN:
        !           586:        show_url_from_click (hDlg, lParam);
        !           587:        break;
        !           588:      case WM_NOTIFY:
        !           589:        switch (((NMHDR *) lParam)->code) {
        !           590:        case PSN_RESET:
        !           591:            if (allow_quit) {
        !           592:                quit_program = 1;
        !           593:                regs.spcflags |= SPCFLAG_BRK;
        !           594:            }
        !           595:            break;
        !           596:        }
        !           597:        break;
        !           598:     }
        !           599: 
        !           600:     return FALSE;
        !           601: }
        !           602: 
        !           603: static struct win32_displaymode *GetDisplayMode (int logical_number)
        !           604: {
        !           605:     struct win32_displaymode *dm = win32_displaymode_list;
        !           606:     while (logical_number > 0 && dm != 0)
        !           607:        dm = dm->next, logical_number--;
        !           608:     return dm;
        !           609: }
        !           610: 
        !           611: static void enable_for_adisplaydlg (HWND hDlg)
        !           612: {
        !           613:     if (! full_property_sheet) {
        !           614:        /* Disable certain controls which are only to be set once at start-up... */
        !           615:        EnableWindow (GetDlgItem (hDlg, IDC_LORES), FALSE);
        !           616:        EnableWindow (GetDlgItem (hDlg, IDC_XCENTER), FALSE);
        !           617:        EnableWindow (GetDlgItem (hDlg, IDC_YCENTER), FALSE);
        !           618:        EnableWindow (GetDlgItem (hDlg, IDC_ASPECT), FALSE);
        !           619:        EnableWindow (GetDlgItem (hDlg, IDC_LINEDBL), FALSE);
        !           620:        EnableWindow (GetDlgItem (hDlg, IDC_RESOLUTION), FALSE);
        !           621:        EnableWindow (GetDlgItem (hDlg, IDC_XSIZE), FALSE);
        !           622:        EnableWindow (GetDlgItem (hDlg, IDC_YSIZE), FALSE);
        !           623:        EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_NONE), FALSE);
        !           624:        EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_SIMPLE), FALSE);
        !           625:        EnableWindow (GetDlgItem (hDlg, IDC_XCENTER_SMART), FALSE);
        !           626:        EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_NONE), FALSE);
        !           627:        EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_SIMPLE), FALSE);
        !           628:        EnableWindow (GetDlgItem (hDlg, IDC_YCENTER_SMART), FALSE);
        !           629:     }
        !           630: }
        !           631: 
        !           632: static void values_to_adisplaydlg (HWND hDlg)
        !           633: {
        !           634:     char buffer[40];
        !           635: 
        !           636:     sprintf (buffer, "%d", workprefs.gfx_width);
        !           637:     SetDlgItemText (hDlg, IDC_XSIZE, buffer);
        !           638:     sprintf (buffer, "%d", workprefs.gfx_height);
        !           639:     SetDlgItemText (hDlg, IDC_YSIZE, buffer);
        !           640: 
        !           641:     SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPOS, TRUE, workprefs.framerate);
        !           642:     sprintf (buffer, "Every %sFrame", nth[workprefs.framerate - 1]);
        !           643:     SetDlgItemText (hDlg, IDC_RATETEXT, buffer);
        !           644: 
        !           645:     CheckDlgButton (hDlg, IDC_LINEDBL, workprefs.gfx_linedbl);
        !           646:     CheckDlgButton (hDlg, IDC_AFULLSCREEN, workprefs.gfx_afullscreen);
        !           647:     CheckDlgButton (hDlg, IDC_ASPECT, workprefs.gfx_correct_aspect);
        !           648:     CheckDlgButton (hDlg, IDC_LORES, workprefs.gfx_lores);
        !           649:     
        !           650:     if (workprefs.gfx_ycenter == 0)
        !           651:        CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_NONE);
        !           652:     else if (workprefs.gfx_ycenter == 1)
        !           653:        CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_SIMPLE);
        !           654:     else
        !           655:        CheckRadioButton (hDlg, IDC_YCENTER_NONE, IDC_YCENTER_SMART, IDC_YCENTER_SMART);
        !           656: 
        !           657:     if (workprefs.gfx_xcenter == 0)
        !           658:        CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_NONE);
        !           659:     else if (workprefs.gfx_xcenter == 1)
        !           660:        CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_SIMPLE);
        !           661:     else
        !           662:        CheckRadioButton (hDlg, IDC_XCENTER_NONE, IDC_XCENTER_SMART, IDC_XCENTER_SMART);
        !           663: }
        !           664: 
        !           665: static void init_resolution_combo (HWND hDlg)
        !           666: {
        !           667:     struct win32_displaymode *dm;
        !           668: 
        !           669:     SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_RESETCONTENT, 0, 0);
        !           670:     for (dm = win32_displaymode_list; dm != 0; dm = dm->next) {
        !           671:        char tmpstr[50];
        !           672:        sprintf (tmpstr, "%dx%d", dm->width, dm->height);
        !           673:        SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) tmpstr);
        !           674:        memset (tmpstr, 0, sizeof tmpstr);
        !           675:     }
        !           676: }
        !           677: 
        !           678: static void values_from_adisplaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !           679: {
        !           680:     workprefs.gfx_afullscreen = IsDlgButtonChecked (hDlg, IDC_AFULLSCREEN);
        !           681:     workprefs.gfx_lores = IsDlgButtonChecked (hDlg, IDC_LORES);
        !           682:     workprefs.gfx_correct_aspect = IsDlgButtonChecked (hDlg, IDC_ASPECT);
        !           683:     workprefs.gfx_linedbl = IsDlgButtonChecked (hDlg, IDC_LINEDBL);
        !           684: 
        !           685:     workprefs.framerate = SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_GETPOS, 0, 0);
        !           686: 
        !           687:     {
        !           688:        char buffer[40];
        !           689:        sprintf (buffer, "Every %sFrame", nth[workprefs.framerate - 1]);
        !           690:        SetDlgItemText (hDlg, IDC_RATETEXT, buffer);
        !           691: 
        !           692:        GetDlgItemText (hDlg, IDC_XSIZE, buffer, sizeof buffer);
        !           693:        workprefs.gfx_width = atoi (buffer);
        !           694:        GetDlgItemText (hDlg, IDC_YSIZE, buffer, sizeof buffer);
        !           695:        workprefs.gfx_height = atoi (buffer);
        !           696:     }
        !           697:     workprefs.gfx_xcenter = (IsDlgButtonChecked (hDlg, IDC_XCENTER_SMART) ? 2
        !           698:                             : IsDlgButtonChecked (hDlg, IDC_XCENTER_SIMPLE) ? 1 : 0);
        !           699:     workprefs.gfx_ycenter = (IsDlgButtonChecked (hDlg, IDC_YCENTER_SMART) ? 2
        !           700:                             : IsDlgButtonChecked (hDlg, IDC_YCENTER_SIMPLE) ? 1 : 0);
        !           701: 
        !           702:     if (msg == WM_COMMAND && LOWORD (wParam) == IDC_RESOLUTION && HIWORD (wParam) == CBN_SELCHANGE) {
        !           703:        LONG posn;
        !           704:        struct win32_displaymode *dm;
        !           705:        posn = SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_GETCURSEL, 0, 0);
        !           706:        if (posn == CB_ERR)
        !           707:            return;
        !           708:        dm = GetDisplayMode (posn);
        !           709:        if (dm == 0) {
        !           710:            printf ("Bug...\n");
        !           711:            return;
        !           712:        }
        !           713:        workprefs.gfx_width = dm->width;
        !           714:        workprefs.gfx_height = dm->height;
        !           715:     }
        !           716: }
        !           717: 
        !           718: static BOOL CALLBACK ADisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !           719: {
        !           720:     static int recursive = 0;
        !           721:     switch (msg) {
        !           722:      case WM_INITDIALOG:
        !           723:        pages[ADISPLAY_ID] = hDlg;
        !           724:        SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPAGESIZE, 0, 1);
        !           725:        SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETRANGE, TRUE, MAKELONG (MIN_REFRESH_RATE, MAX_REFRESH_RATE));
        !           726:        init_resolution_combo (hDlg);
        !           727: 
        !           728:      case WM_USER:
        !           729:        recursive++;
        !           730:        values_to_adisplaydlg (hDlg);
        !           731:        recursive--;
        !           732:        enable_for_adisplaydlg (hDlg);
        !           733:        break;
        !           734: 
        !           735:      case WM_HSCROLL:
        !           736:      case WM_COMMAND:
        !           737:        if (recursive > 0)
        !           738:            break;
        !           739:        recursive++;
        !           740:        values_from_adisplaydlg (hDlg, msg, wParam, lParam);
        !           741:        values_to_adisplaydlg (hDlg);
        !           742:        recursive--;
        !           743:        break;
        !           744: 
        !           745:      case WM_NOTIFY:
        !           746:        switch (((NMHDR *) lParam)->code) {
        !           747:         case PSN_APPLY:
        !           748:            accept_workprefs ();
        !           749:            break;
        !           750: 
        !           751:         case PSN_RESET:
        !           752:            if (allow_quit) {
        !           753:                quit_program = 1;
        !           754:                regs.spcflags |= SPCFLAG_BRK;
        !           755:            }
        !           756:            break;
        !           757:        }
        !           758:     }
        !           759:     return FALSE;
        !           760: }
        !           761: 
        !           762: static void enable_for_pdisplaydlg (HWND hDlg)
        !           763: {
        !           764:     EnableWindow (GetDlgItem (hDlg, IDC_GFXCARDTEXT), ! workprefs.address_space_24);
        !           765:     EnableWindow (GetDlgItem (hDlg, IDC_P96RAM), ! workprefs.address_space_24);
        !           766:     EnableWindow (GetDlgItem (hDlg, IDC_P96MEM), ! workprefs.address_space_24);
        !           767:     EnableWindow (GetDlgItem (hDlg, IDC_PFULLSCREEN), ! workprefs.address_space_24);
        !           768: }
        !           769: 
        !           770: static void values_to_pdisplaydlg (HWND hDlg)
        !           771: {
        !           772:     int mem_size;
        !           773: 
        !           774:     CheckDlgButton (hDlg, IDC_PFULLSCREEN, workprefs.gfx_pfullscreen);
        !           775: 
        !           776:     switch (workprefs.gfxmem_size) {
        !           777:      case 0x00000000: mem_size = 0; break;
        !           778:      case 0x00100000: mem_size = 1; break;
        !           779:      case 0x00200000: mem_size = 2; break;
        !           780:      case 0x00400000: mem_size = 3; break;
        !           781:      case 0x00800000: mem_size = 4; break;
        !           782:     }
        !           783:     SendDlgItemMessage (hDlg, IDC_P96MEM, TBM_SETPOS, TRUE, mem_size);
        !           784:     SetDlgItemText (hDlg, IDC_P96RAM, memsize_names[msi_gfx[mem_size]]);
        !           785: }
        !           786: 
        !           787: static BOOL CALLBACK PDisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !           788: {
        !           789:     static int recursive = 0;
        !           790:     switch (msg) {
        !           791:      case WM_INITDIALOG:
        !           792:        pages[PDISPLAY_ID] = hDlg;
        !           793:        SendDlgItemMessage (hDlg, IDC_P96MEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_P96_MEM, MAX_P96_MEM));
        !           794: 
        !           795:      case WM_USER:
        !           796:        recursive++;
        !           797:        values_to_pdisplaydlg (hDlg);
        !           798:        enable_for_pdisplaydlg (hDlg);
        !           799:        recursive--;
        !           800:        break;
        !           801: 
        !           802:     case WM_HSCROLL:
        !           803:     case WM_COMMAND:
        !           804:        if (recursive > 0)
        !           805:            break;
        !           806:        recursive++;
        !           807:        workprefs.gfx_pfullscreen = IsDlgButtonChecked (hDlg, IDC_PFULLSCREEN);
        !           808:        workprefs.gfxmem_size = memsizes[msi_gfx[SendMessage (GetDlgItem (hDlg, IDC_P96MEM), TBM_GETPOS, 0, 0)]];
        !           809:        values_to_pdisplaydlg (hDlg);
        !           810:        recursive--;
        !           811:        break;
        !           812: 
        !           813:     case WM_NOTIFY:
        !           814:        switch (((NMHDR *) lParam)->code) {
        !           815:         case PSN_APPLY:
        !           816:            accept_workprefs ();
        !           817:            break;
        !           818: 
        !           819:        case PSN_RESET:
        !           820:            if (allow_quit) {
        !           821:                quit_program = 1;
        !           822:                regs.spcflags |= SPCFLAG_BRK;
        !           823:            }
        !           824:            break;
        !           825:        }
        !           826:     }
        !           827:     return FALSE;
        !           828: }
        !           829: 
        !           830: static void KickStuffSelection (HWND hDlg, int which)
        !           831: {
        !           832:     OPENFILENAME openFileName;
        !           833:     char full_path[MAX_PATH] = "";
        !           834:     char file_name[MAX_PATH] = "";
        !           835:     char init_path[MAX_PATH] = "";
        !           836:     char *amiga_path = NULL;
        !           837: 
        !           838:     if ((amiga_path = getenv ("AmigaPath")) != NULL) {
        !           839:        strncpy (init_path, amiga_path, MAX_PATH);
        !           840:        strncat (init_path, "\\ROM\\", MAX_PATH);
        !           841:     } else if (start_path) {
        !           842:        strncpy (init_path, start_path, MAX_PATH);
        !           843:        strncat (init_path, "\\..\\shared\\ROM\\", MAX_PATH);
        !           844:     }
        !           845:     openFileName.lStructSize = sizeof (OPENFILENAME);
        !           846:     openFileName.hwndOwner = hDlg;
        !           847:     openFileName.hInstance = hInst;
        !           848:     if (which) {
        !           849:        openFileName.lpstrFilter = "Amiga Kickstart Files (*.ROM)\0*.ROM\0\0";
        !           850:        openFileName.lpstrTitle = "Select an Amiga ROM file...";
        !           851:        openFileName.lpstrDefExt = "ROM";
        !           852:     } else {
        !           853:        openFileName.lpstrFilter = "Amiga Kickstart Key-Files (*.KEY)\0*.KEY\0\0";
        !           854:        openFileName.lpstrTitle = "Select an Amiga Key-File...";
        !           855:        openFileName.lpstrDefExt = "KEY";
        !           856:     }
        !           857:     openFileName.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
        !           858:     openFileName.lpstrCustomFilter = NULL;
        !           859:     openFileName.nMaxCustFilter = 0;
        !           860:     openFileName.nFilterIndex = 0;
        !           861:     openFileName.lpstrFile = full_path;
        !           862:     openFileName.nMaxFile = MAX_PATH;
        !           863:     openFileName.lpstrFileTitle = file_name;
        !           864:     openFileName.nMaxFileTitle = MAX_PATH;
        !           865:     if (start_path)
        !           866:        openFileName.lpstrInitialDir = init_path;
        !           867:     else
        !           868:        openFileName.lpstrInitialDir = NULL;
        !           869:     openFileName.lpfnHook = NULL;
        !           870:     openFileName.lpTemplateName = NULL;
        !           871:     openFileName.lCustData = 0;
        !           872:     if (GetOpenFileName (&openFileName) == FALSE)
        !           873:        write_log ("GetOpenFileName() failed.\n");
        !           874:     else {
        !           875:        if (which)
        !           876:            SetDlgItemText (hDlg, IDC_ROMFILE, full_path);
        !           877:        else
        !           878:            SetDlgItemText (hDlg, IDC_KEYFILE, full_path);
        !           879:     }
        !           880: }
        !           881: 
        !           882: static void enable_for_startupdlg (HWND hDlg)
        !           883: {
        !           884:     EnableWindow (GetDlgItem (hDlg, IDC_Z3TEXT), ! workprefs.address_space_24);
        !           885:     EnableWindow (GetDlgItem (hDlg, IDC_Z3FASTRAM), ! workprefs.address_space_24);
        !           886:     EnableWindow (GetDlgItem (hDlg, IDC_Z3FASTMEM), ! workprefs.address_space_24);
        !           887:     EnableWindow (GetDlgItem (hDlg, IDC_FASTMEM), workprefs.chipmem_size <= 0x200000);
        !           888:     EnableWindow (GetDlgItem (hDlg, IDC_FASTRAM), workprefs.chipmem_size <= 0x200000);
        !           889:     EnableWindow (GetDlgItem (hDlg, IDC_FASTTEXT), workprefs.chipmem_size <= 0x200000);
        !           890: }
        !           891: 
        !           892: static void values_to_startupdlg (HWND hDlg)
        !           893: {
        !           894:     uae_u32 mem_size = 0;
        !           895: 
        !           896:     SetDlgItemText (hDlg, IDC_ROMFILE, romfile);
        !           897:     SetDlgItemText (hDlg, IDC_KEYFILE, keyfile);
        !           898: 
        !           899:     CheckDlgButton (hDlg, IDC_ILLEGAL, workprefs.illegal_mem);
        !           900: 
        !           901:     switch (workprefs.chipmem_size) {
        !           902:      case 0x00080000: mem_size = 0; break;
        !           903:      case 0x00100000: mem_size = 1; break;
        !           904:      case 0x00200000: mem_size = 2; break;
        !           905:      case 0x00400000: mem_size = 3; break;
        !           906:      case 0x00800000: mem_size = 4; break;
        !           907:     }
        !           908:     SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETPOS, TRUE, mem_size);
        !           909:     SetDlgItemText (hDlg, IDC_CHIPRAM, memsize_names[msi_chip[mem_size]]);
        !           910: 
        !           911:     switch (workprefs.fastmem_size) {
        !           912:      case 0x00000000: mem_size = 0; break;
        !           913:      case 0x00100000: mem_size = 1; break;
        !           914:      case 0x00200000: mem_size = 2; break;
        !           915:      case 0x00400000: mem_size = 3; break;
        !           916:      case 0x00800000: mem_size = 4; break;
        !           917:      case 0x01000000: mem_size = 5; break;
        !           918:     }
        !           919:     SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETPOS, TRUE, mem_size);
        !           920:     SetDlgItemText (hDlg, IDC_FASTRAM, memsize_names[msi_fast[mem_size]]);
        !           921: 
        !           922:     switch (workprefs.bogomem_size) {
        !           923:      case 0x00000000: mem_size = 0; break;
        !           924:      case 0x00080000: mem_size = 1; break;
        !           925:      case 0x00100000: mem_size = 2; break;
        !           926:     }
        !           927:     SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETPOS, TRUE, mem_size);
        !           928:     SetDlgItemText (hDlg, IDC_SLOWRAM, memsize_names[msi_bogo[mem_size]]);
        !           929: 
        !           930:     switch (workprefs.z3fastmem_size) {
        !           931:      case 0x00000000: mem_size = 0; break;
        !           932:      case 0x00100000: mem_size = 1; break;
        !           933:      case 0x00200000: mem_size = 2; break;
        !           934:      case 0x00400000: mem_size = 3; break;
        !           935:      case 0x00800000: mem_size = 4; break;
        !           936:      case 0x01000000: mem_size = 5; break;
        !           937:      case 0x02000000: mem_size = 6; break;
        !           938:      case 0x04000000: mem_size = 7; break;
        !           939:     }
        !           940:     SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETPOS, TRUE, mem_size);
        !           941:     SetDlgItemText (hDlg, IDC_Z3FASTRAM, memsize_names[msi_z3fast[mem_size]]);
        !           942: }
        !           943: 
        !           944: static void fix_values_startupdlg (void)
        !           945: {
        !           946:     if (workprefs.chipmem_size > 0x200000)
        !           947:        workprefs.fastmem_size = 0;
        !           948: }
        !           949: 
        !           950: static BOOL CALLBACK StartupDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !           951: {
        !           952:     switch (msg) {
        !           953:      case WM_INITDIALOG:
        !           954:        pages[STARTUP_ID] = hDlg;
        !           955:        SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CHIP_MEM, MAX_CHIP_MEM));
        !           956:        SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_FAST_MEM, MAX_FAST_MEM));
        !           957:        SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_SLOW_MEM, MAX_SLOW_MEM));
        !           958:        SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_Z3_MEM, MAX_Z3_MEM));
        !           959: 
        !           960:      case WM_USER:
        !           961:        fix_values_startupdlg ();
        !           962:        values_to_startupdlg (hDlg);
        !           963:        enable_for_startupdlg (hDlg);
        !           964:        return TRUE;
        !           965: 
        !           966:     case WM_COMMAND:
        !           967:        switch (wParam) {
        !           968:         case IDC_KICKCHOOSER:
        !           969:            KickStuffSelection (hDlg, 1);
        !           970:            break;
        !           971:         case IDC_KEYCHOOSER:
        !           972:            KickStuffSelection (hDlg, 0);
        !           973:            break;
        !           974:         default:
        !           975:            GetDlgItemText (hDlg, IDC_ROMFILE, romfile, CFG_ROM_LENGTH);
        !           976:            GetDlgItemText (hDlg, IDC_KEYFILE, keyfile, CFG_KEY_LENGTH);
        !           977:            workprefs.illegal_mem = IsDlgButtonChecked (hDlg, IDC_ILLEGAL);
        !           978:        }
        !           979:        break;
        !           980: 
        !           981:     case WM_HSCROLL:
        !           982:        workprefs.chipmem_size = memsizes[msi_chip[SendMessage (GetDlgItem (hDlg, IDC_CHIPMEM), TBM_GETPOS, 0, 0)]];
        !           983:        workprefs.bogomem_size = memsizes[msi_bogo[SendMessage (GetDlgItem (hDlg, IDC_SLOWMEM), TBM_GETPOS, 0, 0)]];
        !           984:        workprefs.fastmem_size = memsizes[msi_fast[SendMessage (GetDlgItem (hDlg, IDC_FASTMEM), TBM_GETPOS, 0, 0)]];
        !           985:        workprefs.z3fastmem_size = memsizes[msi_z3fast[SendMessage (GetDlgItem (hDlg, IDC_Z3FASTMEM), TBM_GETPOS, 0, 0)]];
        !           986:        fix_values_startupdlg ();
        !           987:        values_to_startupdlg (hDlg);
        !           988:        enable_for_startupdlg (hDlg);   
        !           989:        break;
        !           990: 
        !           991:     case WM_NOTIFY:
        !           992:        switch (((NMHDR *) lParam)->code) {
        !           993:         case PSN_APPLY:
        !           994:            accept_workprefs ();
        !           995:            break;
        !           996:         case PSN_RESET:
        !           997:            if (allow_quit) {
        !           998:                quit_program = 1;
        !           999:                regs.spcflags |= SPCFLAG_BRK;
        !          1000:            }
        !          1001:            break;
        !          1002:        }
        !          1003:     }
        !          1004:     return FALSE;
        !          1005: }
        !          1006: 
        !          1007: static int logging_ids[] = { IDC_CPU0, IDC_CPU1, IDC_CPU2, IDC_CPU3 };
        !          1008: 
        !          1009: static void enable_for_advanceddlg (HWND hDlg)
        !          1010: {
        !          1011:     if (! running_winnt) {
        !          1012:        EnableWindow (GetDlgItem (hDlg, IDC_LOGGING0), FALSE);
        !          1013:        EnableWindow (GetDlgItem (hDlg, IDC_LOGGING2), FALSE);
        !          1014:     }
        !          1015: }
        !          1016: 
        !          1017: static void values_to_advanceddlg (HWND hDlg)
        !          1018: {
        !          1019:     CheckDlgButton (hDlg, IDC_BLITIMM, workprefs.immediate_blits);
        !          1020:     CheckDlgButton (hDlg, IDC_BLIT32, workprefs.blits_32bit_enabled);
        !          1021:     CheckDlgButton (hDlg, IDC_JULIAN, julian_mode);
        !          1022:     CheckRadioButton (hDlg, IDC_LOGGING0, IDC_LOGGING3, logging_ids[debug_logging]);
        !          1023: }
        !          1024: 
        !          1025: static BOOL CALLBACK AdvancedDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1026: {
        !          1027:     switch (msg) {
        !          1028:      case WM_INITDIALOG:
        !          1029:        pages[ADVANCED_ID] = hDlg;
        !          1030: 
        !          1031:      case WM_USER:
        !          1032:        values_to_advanceddlg (hDlg);
        !          1033:        enable_for_advanceddlg (hDlg);
        !          1034:        return TRUE;
        !          1035: 
        !          1036:      case WM_COMMAND:
        !          1037:        debug_logging = (IsDlgButtonChecked (hDlg, IDC_LOGGING0) ? 0
        !          1038:                         : IsDlgButtonChecked (hDlg, IDC_LOGGING1) ? 1
        !          1039:                         : IsDlgButtonChecked (hDlg, IDC_LOGGING2) ? 2 : 3);
        !          1040:        workprefs.immediate_blits = IsDlgButtonChecked (hDlg, IDC_BLITIMM);
        !          1041:        workprefs.blits_32bit_enabled = IsDlgButtonChecked (hDlg, IDC_BLIT32);
        !          1042:        julian_mode = IsDlgButtonChecked (hDlg, IDC_JULIAN);
        !          1043:        break;
        !          1044: 
        !          1045:      case WM_NOTIFY:
        !          1046:        switch (((NMHDR *) lParam)->code) {
        !          1047:         case PSN_APPLY:
        !          1048:            accept_workprefs ();
        !          1049:            break;
        !          1050: 
        !          1051:         case PSN_RESET:
        !          1052:            if (allow_quit) {
        !          1053:                quit_program = 1;
        !          1054:                regs.spcflags |= SPCFLAG_BRK;
        !          1055:            }
        !          1056:            break;
        !          1057:        }
        !          1058:     }
        !          1059:     return FALSE;
        !          1060: }
        !          1061: 
        !          1062: static int cpu_ids[] = { IDC_CPU0, IDC_CPU1, IDC_CPU2, IDC_CPU3 };
        !          1063: 
        !          1064: static void enable_for_cpudlg (HWND hDlg)
        !          1065: {
        !          1066:     EnableWindow (GetDlgItem (hDlg, IDC_SPEED), workprefs.m68k_speed > 0);
        !          1067:     EnableWindow (GetDlgItem (hDlg, IDC_CS_CPU_TEXT), workprefs.m68k_speed > 0);
        !          1068:     EnableWindow (GetDlgItem (hDlg, IDC_CS_CHIPSET_TEXT), workprefs.m68k_speed > 0);
        !          1069:     EnableWindow (GetDlgItem (hDlg, IDC_COMPATIBLE), workprefs.cpu_level == 0);
        !          1070:     EnableWindow (GetDlgItem (hDlg, IDC_24BIT), workprefs.cpu_level > 0);
        !          1071: }
        !          1072: 
        !          1073: static void values_to_cpudlg (HWND hDlg)
        !          1074: {
        !          1075:     SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, workprefs.m68k_speed <= 0 ? 1 : workprefs.m68k_speed);
        !          1076: 
        !          1077:     CheckDlgButton (hDlg, IDC_24BIT, workprefs.address_space_24);
        !          1078:     CheckDlgButton (hDlg, IDC_COMPATIBLE, workprefs.cpu_compatible);
        !          1079:     CheckRadioButton (hDlg, IDC_CPU0, IDC_CPU3, cpu_ids[workprefs.cpu_level]);
        !          1080: 
        !          1081:     if (workprefs.m68k_speed == -1)
        !          1082:        CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_HOST);
        !          1083:     else if (workprefs.m68k_speed == 0)
        !          1084:        CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_68000);
        !          1085:     else
        !          1086:        CheckRadioButton (hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_ADJUSTABLE);
        !          1087: }
        !          1088: 
        !          1089: static void values_from_cpudlg (HWND hDlg)
        !          1090: {
        !          1091:     int newcpu;
        !          1092: 
        !          1093:     workprefs.cpu_compatible = IsDlgButtonChecked (hDlg, IDC_COMPATIBLE);
        !          1094:     workprefs.address_space_24 = IsDlgButtonChecked (hDlg, IDC_24BIT);
        !          1095:     workprefs.m68k_speed = (IsDlgButtonChecked (hDlg, IDC_CS_HOST) ? -1
        !          1096:                            : IsDlgButtonChecked (hDlg, IDC_CS_68000) ? 0
        !          1097:                            : SendMessage (GetDlgItem (hDlg, IDC_SPEED), TBM_GETPOS, 0, 0));
        !          1098: 
        !          1099:     newcpu = (IsDlgButtonChecked (hDlg, IDC_CPU0) ? 0
        !          1100:              : IsDlgButtonChecked (hDlg, IDC_CPU1) ? 1
        !          1101:              : IsDlgButtonChecked (hDlg, IDC_CPU2) ? 2 : 3);
        !          1102:     if (newcpu != workprefs.cpu_level) {
        !          1103:        /* When switching away from 68000, disable 24 bit addressing.  */
        !          1104:        if (workprefs.cpu_level == 0)
        !          1105:            workprefs.address_space_24 = 0;
        !          1106:        if (newcpu > 0)
        !          1107:            workprefs.cpu_compatible = 0;
        !          1108:        else
        !          1109:            workprefs.address_space_24 = 1;
        !          1110:        workprefs.cpu_level = newcpu;
        !          1111:     }
        !          1112:     if (pages[STARTUP_ID])
        !          1113:        SendMessage (pages[STARTUP_ID], WM_USER, 0, 0);
        !          1114:     if (pages[PDISPLAY_ID])
        !          1115:        SendMessage (pages[PDISPLAY_ID], WM_USER, 0, 0);
        !          1116: }
        !          1117: 
        !          1118: static BOOL CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1119: {
        !          1120:     static int recursive = 0;
        !          1121:     switch (msg) {
        !          1122:      case WM_INITDIALOG:
        !          1123:        pages[CPU_ID] = hDlg;
        !          1124:        SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETRANGE, TRUE, MAKELONG (MIN_M68K_PRIORITY, MAX_M68K_PRIORITY));
        !          1125:        SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPAGESIZE, 0, 1);
        !          1126: 
        !          1127:      case WM_USER:
        !          1128:        recursive++;
        !          1129:        values_to_cpudlg (hDlg);
        !          1130:        enable_for_cpudlg (hDlg);
        !          1131:        recursive--;
        !          1132:        return TRUE;
        !          1133: 
        !          1134:      case WM_COMMAND:
        !          1135:        if (recursive > 0)
        !          1136:            break;
        !          1137:        recursive++;
        !          1138:        values_from_cpudlg (hDlg);
        !          1139:        values_to_cpudlg (hDlg);
        !          1140:        enable_for_cpudlg (hDlg);
        !          1141:        recursive--;
        !          1142:        break;
        !          1143: 
        !          1144:      case WM_NOTIFY:
        !          1145:        switch (((NMHDR *) lParam)->code) {
        !          1146:         case PSN_APPLY:
        !          1147:            accept_workprefs ();
        !          1148:            break;
        !          1149: 
        !          1150:         case PSN_RESET:
        !          1151:            if (allow_quit) {
        !          1152:                quit_program = 1;
        !          1153:                regs.spcflags |= SPCFLAG_BRK;
        !          1154:            }
        !          1155:            break;
        !          1156:        }
        !          1157:     }
        !          1158:     return FALSE;
        !          1159: }
        !          1160: 
        !          1161: static void enable_for_sounddlg (HWND hDlg)
        !          1162: {
        !          1163:     EnableWindow (GetDlgItem (hDlg, IDC_FREQUENCY), workprefs.produce_sound > 0);
        !          1164:     EnableWindow (GetDlgItem (hDlg, IDC_11KHZ), workprefs.produce_sound > 0);
        !          1165:     EnableWindow (GetDlgItem (hDlg, IDC_22KHZ), workprefs.produce_sound > 0);
        !          1166:     EnableWindow (GetDlgItem (hDlg, IDC_44KHZ), workprefs.produce_sound > 0);
        !          1167:     EnableWindow (GetDlgItem (hDlg, IDC_48KHZ), workprefs.produce_sound > 0);
        !          1168: 
        !          1169:     EnableWindow (GetDlgItem (hDlg, IDC_SOUNDSIZE), workprefs.produce_sound > 0);
        !          1170:     EnableWindow (GetDlgItem (hDlg, IDC_8BIT), workprefs.produce_sound > 0);
        !          1171:     EnableWindow (GetDlgItem (hDlg, IDC_16BIT), workprefs.produce_sound > 0);
        !          1172: 
        !          1173:     EnableWindow (GetDlgItem (hDlg, IDC_STEREO), workprefs.produce_sound > 0);
        !          1174:     EnableWindow (GetDlgItem (hDlg, IDC_DIRECTSOUND), full_property_sheet);
        !          1175: }
        !          1176: 
        !          1177: static void values_to_sounddlg (HWND hDlg)
        !          1178: {
        !          1179:     int which_button;
        !          1180: 
        !          1181:     if (workprefs.sound_freq <= 11025)
        !          1182:        which_button = IDC_11KHZ;
        !          1183:     else if (workprefs.sound_freq <= 22050)
        !          1184:        which_button = IDC_22KHZ;
        !          1185:     else if (workprefs.sound_freq <= 44100)
        !          1186:        which_button = IDC_44KHZ;
        !          1187:     else
        !          1188:        which_button = IDC_48KHZ;
        !          1189:     CheckRadioButton (hDlg, IDC_11KHZ, IDC_48KHZ, which_button);
        !          1190: 
        !          1191:     CheckRadioButton (hDlg, IDC_8BIT, IDC_16BIT, workprefs.sound_bits == 16 ? IDC_16BIT : IDC_8BIT);
        !          1192: 
        !          1193:     switch (workprefs.produce_sound) {
        !          1194:      case 0: which_button = IDC_SOUND0; break;
        !          1195:      case 1: which_button = IDC_SOUND1; break;
        !          1196:      case 2: which_button = IDC_SOUND2; break;
        !          1197:      case 3: which_button = IDC_SOUND3; break;
        !          1198:     }
        !          1199:     
        !          1200:     CheckRadioButton (hDlg, IDC_SOUND0, IDC_SOUND3, which_button);
        !          1201: 
        !          1202:     CheckDlgButton (hDlg, IDC_STEREO, workprefs.stereo);
        !          1203:     CheckDlgButton (hDlg, IDC_DIRECTSOUND, use_direct_sound);
        !          1204: }
        !          1205: 
        !          1206: static void values_from_sounddlg (HWND hDlg)
        !          1207: {
        !          1208:     workprefs.sound_bits = IsDlgButtonChecked (hDlg, IDC_8BIT) ? 8 : 16;
        !          1209:     workprefs.sound_freq = (IsDlgButtonChecked (hDlg, IDC_11KHZ) ? 11025
        !          1210:                            : IsDlgButtonChecked (hDlg, IDC_22KHZ) ? 22050
        !          1211:                            : IsDlgButtonChecked (hDlg, IDC_44KHZ) ? 44100 : 48000);
        !          1212:     workprefs.produce_sound = (IsDlgButtonChecked (hDlg, IDC_SOUND0) ? 0
        !          1213:                               : IsDlgButtonChecked (hDlg, IDC_SOUND1) ? 1
        !          1214:                               : IsDlgButtonChecked (hDlg, IDC_SOUND2) ? 2 : 3);
        !          1215:     workprefs.stereo = IsDlgButtonChecked (hDlg, IDC_STEREO) ? 1 : 0;
        !          1216:     use_direct_sound = IsDlgButtonChecked (hDlg, IDC_DIRECTSOUND) ? 1 : 0;
        !          1217: }
        !          1218: 
        !          1219: static BOOL CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1220: {
        !          1221:     static int recursive = 0;
        !          1222:     switch (msg) {
        !          1223:      case WM_INITDIALOG:
        !          1224:        pages[SOUND_ID] = hDlg;
        !          1225: 
        !          1226:      case WM_USER:
        !          1227:        recursive++;
        !          1228:        values_to_sounddlg (hDlg);
        !          1229:        enable_for_sounddlg (hDlg);
        !          1230:        recursive--;
        !          1231:        return TRUE;
        !          1232: 
        !          1233:      case WM_COMMAND:
        !          1234:        if (recursive > 0)
        !          1235:            break;
        !          1236:        recursive++;
        !          1237:        values_from_sounddlg (hDlg);
        !          1238:        enable_for_sounddlg (hDlg);
        !          1239:        recursive--;
        !          1240:        break;
        !          1241: 
        !          1242:      case WM_NOTIFY:
        !          1243:        switch (((NMHDR *) lParam)->code) {
        !          1244:         case PSN_APPLY:
        !          1245:            accept_workprefs ();
        !          1246:            break;
        !          1247:         case PSN_RESET:
        !          1248:            if (allow_quit) {
        !          1249:                quit_program = 1;
        !          1250:                regs.spcflags |= SPCFLAG_BRK;
        !          1251:            }
        !          1252:            break;
        !          1253:        }
        !          1254:        break;
        !          1255:     }
        !          1256:     return FALSE;
        !          1257: }
        !          1258: 
        !          1259: struct fsvdlg_vals
        !          1260: {
        !          1261:     char volume[4096];
        !          1262:     char rootdir[4096];
        !          1263:     int rw;
        !          1264: };
        !          1265: 
        !          1266: static struct fsvdlg_vals empty_fsvdlg = { "", "", 1 };
        !          1267: static struct fsvdlg_vals current_fsvdlg;
        !          1268: 
        !          1269: struct hfdlg_vals
        !          1270: {
        !          1271:     char volumename[4096];
        !          1272:     char filename[4096];
        !          1273:     char sectors[16];
        !          1274:     char reserved[16];
        !          1275:     char surfaces[16];
        !          1276:     char cylinders[16];
        !          1277:     int rw;
        !          1278: };
        !          1279: 
        !          1280: static struct hfdlg_vals empty_hfdlg = { "", "", "", "", "", "", 1 };
        !          1281: static struct hfdlg_vals current_hfdlg;
        !          1282: 
        !          1283: static int CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1284: {
        !          1285:     static int recursive = 0;
        !          1286:     BROWSEINFO browse_info;
        !          1287:     char directory_path[MAX_PATH] = "";
        !          1288:     LPITEMIDLIST browse;
        !          1289:     LONG setting;
        !          1290: 
        !          1291:     browse_info.hwndOwner = hDlg;
        !          1292:     browse_info.pidlRoot = NULL;
        !          1293:     browse_info.pszDisplayName = directory_path;
        !          1294:     browse_info.lpszTitle = "Please select your file-system root directory...";
        !          1295:     browse_info.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS;
        !          1296:     browse_info.lpfn = NULL;
        !          1297:     browse_info.iImage = 0;
        !          1298: 
        !          1299:     switch (msg) {
        !          1300:      case WM_INITDIALOG:
        !          1301:        recursive++;
        !          1302:        SetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume);
        !          1303:        SetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir);
        !          1304:        CheckDlgButton (hDlg, IDC_RW, current_fsvdlg.rw);
        !          1305:        recursive--;
        !          1306:        return TRUE;
        !          1307: 
        !          1308:      case WM_COMMAND:
        !          1309:        if (recursive)
        !          1310:            break;
        !          1311:        recursive++;
        !          1312:        if (HIWORD (wParam) == BN_CLICKED) {
        !          1313:            switch (LOWORD (wParam)) {
        !          1314:             case IDC_SELECTOR:
        !          1315:                if ((browse = SHBrowseForFolder (&browse_info)) != NULL) {
        !          1316:                    SHGetPathFromIDList (browse, directory_path);
        !          1317:                    SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
        !          1318:                }
        !          1319:                break;
        !          1320:             case IDOK:
        !          1321:                if (strlen (current_fsvdlg.rootdir) == 0) {
        !          1322:                    MessageBox (hDlg, "You must select a path!", "Settings Error",
        !          1323:                                MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1324:                    break;
        !          1325:                }
        !          1326:                if (strlen (current_fsvdlg.volume) == 0) {
        !          1327:                    MessageBox (hDlg, "You must select a name for the volume!", "Settings Error",
        !          1328:                                MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1329:                    break;
        !          1330:                }
        !          1331:                EndDialog (hDlg, 1);
        !          1332: 
        !          1333:                break;
        !          1334:             case IDCANCEL:
        !          1335:                EndDialog (hDlg, 0);
        !          1336:                break;
        !          1337:            }
        !          1338:        }
        !          1339:        GetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir, sizeof current_fsvdlg.rootdir);
        !          1340:        GetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume, sizeof current_fsvdlg.volume);
        !          1341:        current_fsvdlg.rw = IsDlgButtonChecked (hDlg, IDC_RW);
        !          1342:        recursive--;
        !          1343:        break;
        !          1344:     }
        !          1345:     return FALSE;
        !          1346: }
        !          1347: 
        !          1348: static int CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1349: {
        !          1350:     static int recursive = 0;
        !          1351:     LONG setting;
        !          1352: 
        !          1353:     switch (msg) {
        !          1354:      case WM_INITDIALOG:
        !          1355:        recursive++;
        !          1356:        SetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename);
        !          1357:        SetDlgItemText (hDlg, IDC_SECTORS, current_hfdlg.sectors);
        !          1358:        SetDlgItemText (hDlg, IDC_HEADS, current_hfdlg.surfaces);
        !          1359:        SetDlgItemText (hDlg, IDC_RESERVED, current_hfdlg.reserved);
        !          1360:        CheckDlgButton (hDlg, IDC_RW, current_hfdlg.rw);
        !          1361:        recursive--;
        !          1362:        return TRUE;
        !          1363: 
        !          1364:      case WM_COMMAND:
        !          1365:        if (recursive)
        !          1366:            break;
        !          1367:        recursive++;
        !          1368: 
        !          1369:        if (HIWORD (wParam) == BN_CLICKED) {
        !          1370:            switch (LOWORD (wParam)) {
        !          1371:             case IDC_CREATEHF:
        !          1372:                setting = CalculateHardfileSize (hDlg);
        !          1373:                CreateHardFile (hDlg, setting);
        !          1374:                break;
        !          1375:             case IDC_SELECTOR:
        !          1376:                DiskSelection (hDlg, IDC_PATH_NAME, 2);
        !          1377:                break;
        !          1378:             case IDOK:
        !          1379:                if (strlen (current_hfdlg.filename) == 0) {
        !          1380:                    MessageBox (hDlg, "You must select a file...", "Settings Error",
        !          1381:                                MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1382:                    break;
        !          1383:                }
        !          1384:                EndDialog (hDlg, 1);
        !          1385:                break;
        !          1386:             case IDCANCEL:
        !          1387:                EndDialog (hDlg, 0);
        !          1388:                break;
        !          1389:            }
        !          1390:        }
        !          1391: 
        !          1392:        GetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename, sizeof current_hfdlg.filename);
        !          1393:        GetDlgItemText (hDlg, IDC_SECTORS, current_hfdlg.sectors, sizeof current_hfdlg.sectors);
        !          1394:        GetDlgItemText (hDlg, IDC_RESERVED, current_hfdlg.reserved, sizeof current_hfdlg.reserved);
        !          1395:        GetDlgItemText (hDlg, IDC_HEADS, current_hfdlg.surfaces, sizeof current_hfdlg.surfaces);
        !          1396:        current_hfdlg.rw = IsDlgButtonChecked (hDlg, IDC_RW);
        !          1397:        recursive--;
        !          1398: 
        !          1399:        break;
        !          1400:     }
        !          1401:     return FALSE;
        !          1402: }
        !          1403: 
        !          1404: static char *hd_columns[] = { "Volume", "Path", "R/W", "Sectors", "Surfaces", "Reserved" };
        !          1405: 
        !          1406: static void init_harddisk_list (HWND hDlg, HWND list)
        !          1407: {
        !          1408:     int i;
        !          1409:     
        !          1410:     for (i = 0; i < 6; i++) {
        !          1411:        LV_COLUMN lvcolumn;
        !          1412:        int width;
        !          1413:        lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
        !          1414:        lvcolumn.iSubItem = i;
        !          1415:        lvcolumn.fmt = LVCFMT_LEFT;
        !          1416:        lvcolumn.pszText = hd_columns[i];
        !          1417:        width = ListView_GetStringWidth (list, hd_columns[i]) + 15;
        !          1418:        lvcolumn.cx = width;
        !          1419:        ListView_InsertColumn (list, i, &lvcolumn);
        !          1420:        ListView_SetColumnWidth (list, i, width);
        !          1421:     }
        !          1422: 
        !          1423:     /* Turn on full-row-select option */
        !          1424:     ListView_SetExtendedListViewStyle (list, LVS_EX_FULLROWSELECT);
        !          1425: }
        !          1426: 
        !          1427: static void fill_harddisk_entry (HWND hDlg, HWND list, int i)
        !          1428: {
        !          1429:     char *volume, *rootdir;
        !          1430:     int size, cylinders, sectors, reserved, surfaces, readonly;
        !          1431:     int count;
        !          1432: 
        !          1433:     get_filesys_unit (work_mountinfo, i, &volume, &rootdir, &readonly,
        !          1434:                      &sectors, &surfaces, &reserved, &cylinders, &size);
        !          1435: 
        !          1436:     count = ListView_GetItemCount (list);
        !          1437:     while (i >= count) {
        !          1438:        LV_ITEM lvstruct;
        !          1439:        lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
        !          1440:        lvstruct.pszText = "";
        !          1441:        lvstruct.lParam = 0;
        !          1442:        lvstruct.iItem = count;
        !          1443:        lvstruct.iSubItem = 0;
        !          1444:        ListView_InsertItem (list, &lvstruct);
        !          1445:        count++;
        !          1446:     }
        !          1447: 
        !          1448:     if (is_hardfile (work_mountinfo, i)) {
        !          1449:        char buffer[20];
        !          1450:        ListView_SetItemText (list, i, 0, volume);
        !          1451:        ListView_SetItemText (list, i, 1, rootdir);
        !          1452:        ListView_SetItemText (list, i, 2, readonly ? "yes" : "no");
        !          1453:        sprintf (buffer, "%d", sectors);
        !          1454:        ListView_SetItemText (list, i, 3, buffer);
        !          1455:        sprintf (buffer, "%d", surfaces);
        !          1456:        ListView_SetItemText (list, i, 4, buffer);
        !          1457:        sprintf (buffer, "%d", reserved);
        !          1458:        ListView_SetItemText (list, i, 5, buffer);
        !          1459:     } else {
        !          1460:        ListView_SetItemText (list, i, 0, volume);
        !          1461:        ListView_SetItemText (list, i, 1, rootdir);
        !          1462:        ListView_SetItemText (list, i, 2, "n/a");
        !          1463:        ListView_SetItemText (list, i, 3, "n/a");
        !          1464:        ListView_SetItemText (list, i, 4, "n/a");
        !          1465:        ListView_SetItemText (list, i, 5, "n/a");
        !          1466:     }
        !          1467: 
        !          1468:     if (volume)
        !          1469:        free (volume);
        !          1470:     if (rootdir)
        !          1471:        free (rootdir);
        !          1472: }
        !          1473: 
        !          1474: static void values_to_harddiskdlg (HWND hDlg)
        !          1475: {
        !          1476:     HWND list = GetDlgItem (hDlg, IDC_VOLUMELIST);
        !          1477:     int nr = nr_units (work_mountinfo);
        !          1478:     int i;
        !          1479:     
        !          1480:     ListView_DeleteAllItems (list);
        !          1481:     for (i = 0; i < nr; i++) {
        !          1482:        fill_harddisk_entry (hDlg, list, i);
        !          1483:     }
        !          1484: }
        !          1485: 
        !          1486: static void new_filesys (HWND hDlg)
        !          1487: {
        !          1488:     const char *result;
        !          1489: 
        !          1490:     result = add_filesys_unit (work_mountinfo, current_fsvdlg.volume,
        !          1491:                               current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0);
        !          1492:     if (result)
        !          1493:        MessageBox (hDlg, result, "Bad directory",
        !          1494:                    MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1495:     else
        !          1496:        workprefs.mountinfo = work_mountinfo;
        !          1497: }
        !          1498: 
        !          1499: static void new_hardfile (HWND hDlg)
        !          1500: {
        !          1501:     int sectors, reserved, surfaces;
        !          1502:     const char *result;
        !          1503:     sectors = atoi (current_hfdlg.sectors);
        !          1504:     surfaces = atoi (current_hfdlg.surfaces);
        !          1505:     reserved = atoi (current_hfdlg.reserved);
        !          1506: 
        !          1507:     result = add_filesys_unit (work_mountinfo, 0, current_hfdlg.filename,
        !          1508:                               ! current_hfdlg.rw, sectors, surfaces, reserved);
        !          1509:     if (result)
        !          1510:        MessageBox (hDlg, result, "Bad hardfile",
        !          1511:                    MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1512:     else
        !          1513:        workprefs.mountinfo = work_mountinfo;
        !          1514: }
        !          1515: 
        !          1516: static void harddisk_remove (HWND hDlg)
        !          1517: {
        !          1518:     int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
        !          1519:     if (entry < 0)
        !          1520:        return;
        !          1521:     kill_filesys_unit (work_mountinfo, entry);
        !          1522:     workprefs.mountinfo = work_mountinfo;
        !          1523: }
        !          1524: 
        !          1525: static void harddisk_move (HWND hDlg, int up)
        !          1526: {
        !          1527:     int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
        !          1528:     if (entry < 0)
        !          1529:        return;
        !          1530:     if (move_filesys_unit (work_mountinfo, entry, up ? entry - 1 : entry + 1) >= 0)
        !          1531:        workprefs.mountinfo = work_mountinfo;
        !          1532: }
        !          1533: 
        !          1534: static void harddisk_edit (HWND hDlg)
        !          1535: {
        !          1536:     char *volume, *rootdir;
        !          1537:     int size, cylinders, sectors, reserved, surfaces, readonly;
        !          1538: 
        !          1539:     int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST));
        !          1540:     if (entry < 0)
        !          1541:        return;
        !          1542: 
        !          1543:     get_filesys_unit (work_mountinfo, entry, &volume, &rootdir, &readonly,
        !          1544:                      &sectors, &surfaces, &reserved, &cylinders, &size);
        !          1545: 
        !          1546:     if (volume == 0) {
        !          1547:        /* Hardfile */
        !          1548:        strncpy (current_hfdlg.filename, rootdir, (sizeof current_hfdlg.filename) - 1);
        !          1549:        current_hfdlg.filename[(sizeof current_hfdlg.filename) - 1] = '\0';
        !          1550:        sprintf (current_hfdlg.sectors, "%d", sectors);
        !          1551:        sprintf (current_hfdlg.reserved, "%d", reserved);
        !          1552:        sprintf (current_hfdlg.surfaces, "%d", surfaces);
        !          1553:        sprintf (current_hfdlg.cylinders, "%d", cylinders);
        !          1554:        current_hfdlg.rw = readonly;
        !          1555:        if (DialogBox (hInst, MAKEINTRESOURCE (IDD_HARDFILE), hDlg, HardfileSettingsProc)) {
        !          1556:            const char *result;
        !          1557:            sectors = atoi (current_hfdlg.sectors);
        !          1558:            surfaces = atoi (current_hfdlg.surfaces);
        !          1559:            reserved = atoi (current_hfdlg.reserved);
        !          1560:            cylinders = atoi (current_hfdlg.cylinders);
        !          1561:            result = set_filesys_unit (work_mountinfo, entry, 0, current_hfdlg.filename,
        !          1562:                                       ! current_hfdlg.rw, sectors, surfaces, reserved);
        !          1563:            if (result)
        !          1564:                MessageBox (hDlg, result, "Bad hardfile",
        !          1565:                            MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1566:            else
        !          1567:                workprefs.mountinfo = work_mountinfo;
        !          1568:        }
        !          1569:     } else {
        !          1570:        /* Filesystem */
        !          1571:        strncpy (current_fsvdlg.rootdir, rootdir, (sizeof current_fsvdlg.rootdir) - 1);
        !          1572:        current_fsvdlg.rootdir[(sizeof current_fsvdlg.rootdir) - 1] = '\0';
        !          1573:        strncpy (current_fsvdlg.volume, volume, (sizeof current_fsvdlg.volume) - 1);
        !          1574:        current_fsvdlg.volume[(sizeof current_fsvdlg.volume) - 1] = '\0';
        !          1575:        current_fsvdlg.rw = readonly;
        !          1576:        if (DialogBox (hInst, MAKEINTRESOURCE (IDD_FILESYS), hDlg, VolumeSettingsProc)) {
        !          1577:            const char *result;
        !          1578:            result = set_filesys_unit (work_mountinfo, entry, current_fsvdlg.volume,
        !          1579:                                       current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0);
        !          1580:            if (result)
        !          1581:                MessageBox (hDlg, result, "Bad hardfile",
        !          1582:                            MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
        !          1583:            else
        !          1584:                workprefs.mountinfo = work_mountinfo;
        !          1585:        }
        !          1586:     }
        !          1587:     free (volume);
        !          1588:     free (rootdir);
        !          1589: 
        !          1590: }
        !          1591: 
        !          1592: static void harddiskdlg_button (HWND hDlg, int button)
        !          1593: {
        !          1594:     int i;
        !          1595:     int clicked_entry;
        !          1596:     switch (button) {
        !          1597:      case IDC_NEW_FS:
        !          1598:        current_fsvdlg = empty_fsvdlg;
        !          1599:        if (DialogBox (hInst, MAKEINTRESOURCE (IDD_FILESYS), hDlg, VolumeSettingsProc))
        !          1600:            new_filesys (hDlg);
        !          1601:        break;
        !          1602: 
        !          1603:      case IDC_NEW_HF:
        !          1604:        current_hfdlg = empty_hfdlg;
        !          1605:        if (DialogBox (hInst, MAKEINTRESOURCE (IDD_HARDFILE), hDlg, HardfileSettingsProc))
        !          1606:            new_hardfile (hDlg);
        !          1607:        break;
        !          1608: 
        !          1609:      case IDC_EDIT:
        !          1610:        harddisk_edit (hDlg);
        !          1611:        break;
        !          1612: 
        !          1613:      case IDC_REMOVE:
        !          1614:        harddisk_remove (hDlg);
        !          1615:        break;
        !          1616: 
        !          1617:      case IDC_UP:
        !          1618:        harddisk_move (hDlg, 1);
        !          1619:        break;
        !          1620: 
        !          1621:      case IDC_DOWN:
        !          1622:        harddisk_move (hDlg, 0);
        !          1623:        break;
        !          1624:     }
        !          1625: }
        !          1626: 
        !          1627: static void harddiskdlg_volume_notify (HWND hDlg, NM_LISTVIEW *nmlistview)
        !          1628: {
        !          1629:     HWND list = nmlistview->hdr.hwndFrom;
        !          1630:     int dblclick = 0;
        !          1631:     int entry = 0;
        !          1632: 
        !          1633:     switch (nmlistview->hdr.code) {
        !          1634:      case NM_DBLCLK:
        !          1635:        dblclick = 1;
        !          1636:        /* fall through */
        !          1637:      case NM_CLICK:
        !          1638:        entry = listview_entry_from_click (list);
        !          1639:        if (entry >= 0 && dblclick) {
        !          1640:            harddisk_edit (hDlg);
        !          1641:            values_to_harddiskdlg (hDlg);
        !          1642:        }
        !          1643:        break;
        !          1644:     }
        !          1645: }
        !          1646: 
        !          1647: static BOOL CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1648: {
        !          1649:     int i;
        !          1650:     drive_specs tempdrive;
        !          1651: 
        !          1652:     switch (msg) {
        !          1653:      case WM_INITDIALOG:
        !          1654:        pages[HARDDISK_ID] = hDlg;
        !          1655: 
        !          1656:        init_harddisk_list (hDlg, GetDlgItem (hDlg, IDC_VOLUMELIST));
        !          1657: 
        !          1658:      case WM_USER:
        !          1659:        values_to_harddiskdlg (hDlg);
        !          1660:        break;
        !          1661: 
        !          1662:      case WM_COMMAND:
        !          1663:        if (HIWORD (wParam) == BN_CLICKED)
        !          1664:            harddiskdlg_button (hDlg, LOWORD (wParam));
        !          1665:        values_to_harddiskdlg (hDlg);
        !          1666:        break;
        !          1667: 
        !          1668:      case WM_NOTIFY:
        !          1669:        if (((LPNMHDR) lParam)->idFrom == IDC_VOLUMELIST)
        !          1670:            harddiskdlg_volume_notify (hDlg, (NM_LISTVIEW *) lParam);
        !          1671:        else {
        !          1672:            switch (((NMHDR *) lParam)->code) {
        !          1673:             case PSN_APPLY:
        !          1674:                accept_workprefs ();
        !          1675:                break;
        !          1676:             case PSN_RESET:
        !          1677:                if (allow_quit) {
        !          1678:                    quit_program = 1;
        !          1679:                    regs.spcflags |= SPCFLAG_BRK;
        !          1680:                }
        !          1681:                break;
        !          1682:            }
        !          1683:        }
        !          1684:        return TRUE;
        !          1685:      default:
        !          1686:        return FALSE;
        !          1687:     }
        !          1688: 
        !          1689:     return FALSE;
        !          1690: }
        !          1691: 
        !          1692: static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1693: {
        !          1694:     static int recursive = 0;
        !          1695: 
        !          1696:     switch (msg) {
        !          1697:      case WM_INITDIALOG:
        !          1698:        pages[FLOPPY_ID] = hDlg;
        !          1699: 
        !          1700:      case WM_USER:
        !          1701:        recursive++;
        !          1702:        SetDlgItemText (hDlg, IDC_DF0TEXT, workprefs.df[0]);
        !          1703:        SetDlgItemText (hDlg, IDC_DF1TEXT, workprefs.df[1]);
        !          1704:        SetDlgItemText (hDlg, IDC_DF2TEXT, workprefs.df[2]);
        !          1705:        SetDlgItemText (hDlg, IDC_DF3TEXT, workprefs.df[3]);
        !          1706:        recursive--;
        !          1707:        break;
        !          1708: 
        !          1709:      case WM_COMMAND:
        !          1710:        if (recursive > 0)
        !          1711:            break;
        !          1712:        recursive++;
        !          1713:        switch (wParam) {
        !          1714:         case IDC_DF0:
        !          1715:            DiskSelection (hDlg, wParam, 0);
        !          1716:            break;
        !          1717:         case IDC_DF1:
        !          1718:            DiskSelection (hDlg, wParam, 0);
        !          1719:            break;
        !          1720:         case IDC_DF2:
        !          1721:            DiskSelection (hDlg, wParam, 0);
        !          1722:            break;
        !          1723:         case IDC_DF3:
        !          1724:            DiskSelection (hDlg, wParam, 0);
        !          1725:            break;
        !          1726:         case IDC_EJECT0:
        !          1727:            SetDlgItemText (hDlg, IDC_DF0TEXT, "");
        !          1728:            break;
        !          1729:         case IDC_EJECT1:
        !          1730:            SetDlgItemText (hDlg, IDC_DF1TEXT, "");
        !          1731:            break;
        !          1732:         case IDC_EJECT2:
        !          1733:            SetDlgItemText (hDlg, IDC_DF2TEXT, "");
        !          1734:            break;
        !          1735:         case IDC_EJECT3:
        !          1736:            SetDlgItemText (hDlg, IDC_DF3TEXT, "");
        !          1737:            break;
        !          1738:         case IDC_CREATE:
        !          1739:            DiskSelection (hDlg, wParam, 1);
        !          1740:            break;
        !          1741:        }
        !          1742:        GetDlgItemText (hDlg, IDC_DF0TEXT, workprefs.df[0], 255);
        !          1743:        GetDlgItemText (hDlg, IDC_DF1TEXT, workprefs.df[1], 255);
        !          1744:        GetDlgItemText (hDlg, IDC_DF2TEXT, workprefs.df[2], 255);
        !          1745:        GetDlgItemText (hDlg, IDC_DF3TEXT, workprefs.df[3], 255);
        !          1746:        recursive--;
        !          1747:        break;
        !          1748: 
        !          1749:      case WM_NOTIFY:
        !          1750:        switch (((NMHDR *) lParam)->code) {
        !          1751:         case PSN_APPLY:
        !          1752:            accept_workprefs ();
        !          1753:            break;
        !          1754:         case PSN_RESET:
        !          1755:            if (allow_quit) {
        !          1756:                quit_program = 1;
        !          1757:                regs.spcflags |= SPCFLAG_BRK;
        !          1758:            }
        !          1759:            break;
        !          1760:        }
        !          1761:        return TRUE;
        !          1762:      default:
        !          1763:        return FALSE;
        !          1764:     }
        !          1765: 
        !          1766:     return FALSE;
        !          1767: }
        !          1768: 
        !          1769: static void values_from_portsdlg (HWND hDlg)
        !          1770: {
        !          1771:     int item;
        !          1772:     char joyspec[3] = "MA";
        !          1773:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY0)) {
        !          1774:        if (joystickspresent[0])
        !          1775:            joyspec[1] = '0';
        !          1776:        else
        !          1777:            joyspec[1] = 'A';
        !          1778:     }
        !          1779:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_JOY1)) {
        !          1780:        if (joystickspresent[1])
        !          1781:            joyspec[1] = '1';
        !          1782:        else
        !          1783:            joyspec[1] = 'B';
        !          1784:     }
        !          1785:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_MOUSE))
        !          1786:        joyspec[0] = 'M';
        !          1787:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDA))
        !          1788:        joyspec[0] = 'A';
        !          1789:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDB))
        !          1790:        joyspec[0] = 'B';
        !          1791:     if (IsDlgButtonChecked (hDlg, IDC_PORT0_KBDC))
        !          1792:        joyspec[0] = 'C';
        !          1793: 
        !          1794:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY0)) {
        !          1795:        if (joystickspresent[0])
        !          1796:            joyspec[1] = '0';
        !          1797:        else
        !          1798:            joyspec[1] = 'A';
        !          1799:     }
        !          1800:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_JOY1)) {
        !          1801:        if (joystickspresent[1])
        !          1802:            joyspec[1] = '1';
        !          1803:        else
        !          1804:            joyspec[1] = 'B';
        !          1805:     }
        !          1806:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_MOUSE))
        !          1807:        joyspec[1] = 'M';
        !          1808:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDA))
        !          1809:        joyspec[1] = 'A';
        !          1810:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDB))
        !          1811:        joyspec[1] = 'B';
        !          1812:     if (IsDlgButtonChecked (hDlg, IDC_PORT1_KBDC))
        !          1813:        joyspec[1] = 'C';
        !          1814: 
        !          1815:     workprefs.fake_joystick = parse_joy_spec (joyspec);
        !          1816: 
        !          1817:     GetDlgItemText (hDlg, IDC_PARALLEL, prtname, CFG_PAR_LENGTH);
        !          1818: 
        !          1819:     item = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETCURSEL, 0, 0L);
        !          1820:     switch (item) {
        !          1821:      case 1:
        !          1822:      case 2:
        !          1823:      case 3:
        !          1824:      case 4:
        !          1825:        workprefs.use_serial = 1;
        !          1826: #ifdef __GNUC__
        !          1827:        sprintf (sername, "COM%d", item);
        !          1828: #else
        !          1829:        _snprintf (sername, CFG_SER_LENGTH, "COM%d", item);
        !          1830: #endif
        !          1831:        break;
        !          1832:      default:
        !          1833:        workprefs.use_serial = 0;
        !          1834:        break;
        !          1835:     }
        !          1836: }
        !          1837: 
        !          1838: static void values_to_portsdlg (HWND hDlg)
        !          1839: {
        !          1840:     LONG item_height;
        !          1841:     RECT rect;
        !          1842: 
        !          1843:     UpdateRadioButtons (hDlg, GetDlgItem (hDlg, IDC_PORT0));
        !          1844:     UpdateRadioButtons (hDlg, GetDlgItem (hDlg, IDC_PORT1));
        !          1845:     SetDlgItemText (hDlg, IDC_PARALLEL, prtname);
        !          1846:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_RESETCONTENT, 0, 0L);
        !          1847:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "None");
        !          1848:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM1");
        !          1849:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM2");
        !          1850:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM3");
        !          1851:     SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM) "COM4");
        !          1852:     if (workprefs.use_serial == 0)
        !          1853:        SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 0, 0L);
        !          1854:     else {
        !          1855:        switch (sername[strlen (sername) - 1]) {
        !          1856:         case '2':
        !          1857:            SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 2, 0L);
        !          1858:            break;
        !          1859:         case '3':
        !          1860:            SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 3, 0L);
        !          1861:            break;
        !          1862:         case '4':
        !          1863:            SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 4, 0L);
        !          1864:            break;
        !          1865:         default:
        !          1866:            SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, 1, 0L);
        !          1867:            break;
        !          1868:        }
        !          1869:     }
        !          1870: 
        !          1871:     /* Retrieve the height, in pixels, of a list item. */
        !          1872:     item_height = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETITEMHEIGHT, 0, 0L);
        !          1873:     if (item_height != CB_ERR) {
        !          1874:        /* Get actual box position and size. */
        !          1875:        GetWindowRect (GetDlgItem (hDlg, IDC_SERIAL), &rect);
        !          1876:        rect.bottom = (rect.top + item_height * 5
        !          1877:                       + SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETITEMHEIGHT, (WPARAM) - 1, 0L)
        !          1878:                       + item_height);
        !          1879:        SetWindowPos (GetDlgItem (hDlg, IDC_SERIAL), 0, 0, 0, rect.right - rect.left,
        !          1880:                      rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER);
        !          1881:     }
        !          1882: }
        !          1883: 
        !          1884: /* Handle messages for the Joystick Settings page of our property-sheet */
        !          1885: static BOOL CALLBACK PortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        !          1886: {
        !          1887:     static int recursive = 0;
        !          1888: 
        !          1889:     switch (msg) {
        !          1890:      case WM_INITDIALOG:
        !          1891:        pages[PORTS_ID] = hDlg;
        !          1892:        if (! full_property_sheet) {
        !          1893:            EnableWindow (GetDlgItem (hDlg, IDC_SERIAL), FALSE);
        !          1894:            EnableWindow (GetDlgItem (hDlg, IDC_PARALLEL), FALSE);
        !          1895:        }
        !          1896: 
        !          1897:      case WM_USER:
        !          1898:        recursive++;
        !          1899:        values_to_portsdlg (hDlg);
        !          1900:        recursive--;
        !          1901:        return TRUE;
        !          1902: 
        !          1903:      case WM_COMMAND:
        !          1904:        if (recursive > 0)
        !          1905:            break;
        !          1906:        recursive++;
        !          1907:        values_from_portsdlg (hDlg);
        !          1908:        recursive--;
        !          1909:        break;
        !          1910: 
        !          1911:      case WM_NOTIFY:
        !          1912:        switch (((NMHDR *) lParam)->code) {
        !          1913:         case PSN_APPLY:
        !          1914:            accept_workprefs ();
        !          1915:            break;
        !          1916:         case PSN_RESET:
        !          1917:            if (allow_quit) {
        !          1918:                quit_program = 1;
        !          1919:                regs.spcflags |= SPCFLAG_BRK;
        !          1920:            }
        !          1921:            break;
        !          1922:        }
        !          1923:        return FALSE;
        !          1924:     }
        !          1925:     return FALSE;
        !          1926: }
        !          1927: 
        !          1928: static void CALLBACK InitPropertySheet (HWND hDlg, UINT msg, LPARAM lParam)
        !          1929: {
        !          1930:     int i;
        !          1931: 
        !          1932:     switch (msg) {
        !          1933:      case PSCB_INITIALIZED:
        !          1934: #if 0
        !          1935:        if (! full_property_sheet) {
        !          1936:            PropSheet_RemovePage (hDlg, 0, NULL);
        !          1937:            PropSheet_RemovePage (hDlg, 0, NULL);
        !          1938:            PropSheet_RemovePage (hDlg, 0, NULL);
        !          1939:            PropSheet_RemovePage (hDlg, 2, NULL);
        !          1940:        }
        !          1941: #endif
        !          1942: 
        !          1943:        for (i = 0; i < C_PAGES; i++)
        !          1944:            pages[i] = NULL;
        !          1945: 
        !          1946:        break;
        !          1947:     }
        !          1948: }
        !          1949: 
        !          1950: 
        !          1951: #ifdef __GNUC__
        !          1952: #define DUN1 u1 ## .
        !          1953: #define DUN2 u2 ## .
        !          1954: #define DUN3 u3 ## .
        !          1955: #else
        !          1956: #define DUN1
        !          1957: #define DUN2
        !          1958: #define DUN3
        !          1959: #endif
        !          1960: 
        !          1961: static void init_page (PROPSHEETPAGE *ppage, int id, int tmpl, int icon, int title,
        !          1962:                       BOOL (* CALLBACK func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam))
        !          1963: {
        !          1964:     ppage[id].dwSize = sizeof (PROPSHEETPAGE);
        !          1965:     ppage[id].dwFlags = PSP_USETITLE | PSP_USEICONID;
        !          1966:     ppage[id].hInstance = hInst;
        !          1967:     ppage[id].DUN1 pszTemplate = MAKEINTRESOURCE (tmpl);
        !          1968:     ppage[id].DUN2 pszIcon = MAKEINTRESOURCE (icon);
        !          1969:     ppage[id].pszTitle = MAKEINTRESOURCE (title);
        !          1970:     ppage[id].pfnDlgProc = (LPFNPSPCALLBACK) func;
        !          1971:     ppage[id].lParam = 0;
        !          1972:     ppage[id].pfnCallback = NULL;
        !          1973:     ppage[id].pcRefParent = NULL;
        !          1974: }
        !          1975: 
        !          1976: int GetSettings (int all_options)
        !          1977: {
        !          1978:     int psresult;
        !          1979:     PROPSHEETPAGE ppage[C_PAGES];
        !          1980:     PROPSHEETHEADER pHeader;
        !          1981: 
        !          1982:     full_property_sheet = all_options;
        !          1983:     allow_quit = ! all_options;
        !          1984:     pguiprefs = all_options ? &currprefs : &changed_prefs;
        !          1985:     workprefs = *pguiprefs;
        !          1986:     printf ("A\n");
        !          1987:     work_mountinfo = dup_mountinfo (pguiprefs->mountinfo);
        !          1988:     printf ("B\n");
        !          1989: 
        !          1990:     init_page (ppage, LOADSAVE_ID, IDD_LOADSAVE, IDI_LOADSAVE, IDS_LOADSAVE, LoadSaveDlgProc);
        !          1991:     init_page (ppage, STARTUP_ID, IDD_STARTUP, IDI_STARTUP, IDS_STARTUP, StartupDlgProc);
        !          1992:     init_page (ppage, SOUND_ID, IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc);
        !          1993:     init_page (ppage, ADISPLAY_ID, IDD_ADISPLAY, IDI_ADISPLAY, IDS_ADISPLAY, ADisplayDlgProc);
        !          1994:     init_page (ppage, PDISPLAY_ID, IDD_PDISPLAY, IDI_PDISPLAY, IDS_PDISPLAY, PDisplayDlgProc);
        !          1995:     init_page (ppage, CPU_ID, IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc);
        !          1996:     init_page (ppage, HARDDISK_ID, IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc);
        !          1997:     init_page (ppage, FLOPPY_ID, IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc);
        !          1998:     init_page (ppage, PORTS_ID, IDD_PORTS, IDI_PORTS, IDS_PORTS, PortsDlgProc);
        !          1999:     init_page (ppage, ADVANCED_ID, IDD_ADVANCED, IDI_ADVANCED, IDS_ADVANCED, AdvancedDlgProc);
        !          2000:     init_page (ppage, ABOUT_ID, IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc);
        !          2001: 
        !          2002:     pHeader.dwSize = sizeof (PROPSHEETHEADER);
        !          2003:     pHeader.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK | PSH_NOAPPLYNOW;
        !          2004:     if (! all_options && workprefs.gfx_afullscreen && workprefs.gfx_width < 640)
        !          2005:        pHeader.hwndParent = NULL;
        !          2006:     else
        !          2007:        pHeader.hwndParent = hAmigaWnd;
        !          2008:     pHeader.hInstance = hInst;
        !          2009:     pHeader.DUN1 pszIcon = MAKEINTRESOURCE (IDI_UAEICON);
        !          2010:     pHeader.pszCaption = "WinUAE";
        !          2011:     pHeader.nPages = C_PAGES;
        !          2012:     pHeader.DUN2 nStartPage = 0;
        !          2013:     pHeader.DUN3 ppsp = ppage;
        !          2014:     pHeader.pfnCallback = (PFNPROPSHEETCALLBACK) InitPropertySheet;
        !          2015: 
        !          2016:     psresult = PropertySheet (&pHeader);
        !          2017: 
        !          2018:     free_mountinfo (work_mountinfo);
        !          2019: 
        !          2020:     if (psresult == -1 || quit_program)
        !          2021:        return 0;
        !          2022: 
        !          2023:     return 1;
        !          2024: }
        !          2025: 
        !          2026: int gui_init (void)
        !          2027: {
        !          2028:     GetSettings (1);
        !          2029:     return 1;
        !          2030: }
        !          2031: 
        !          2032: int gui_update (void)
        !          2033: {
        !          2034:     return 1;
        !          2035: }
        !          2036: 
        !          2037: void gui_exit (void)
        !          2038: {
        !          2039: }
        !          2040: 
        !          2041: char *labels[5] =
        !          2042: {"Power", "0", "1", "2", "3"};
        !          2043: extern HWND hStatusWnd;
        !          2044: int led_states[5];
        !          2045: 
        !          2046: void gui_led (int led, int on)
        !          2047: {
        !          2048:     WORD type;
        !          2049: 
        !          2050:     return;
        !          2051: 
        !          2052:     if (hStatusWnd == 0)
        !          2053:        return;
        !          2054: 
        !          2055:     if (led_states[led] == on)
        !          2056:        return;
        !          2057: 
        !          2058:     led_states[led] = on;
        !          2059: 
        !          2060:     if (on)
        !          2061:        type = SBT_POPOUT;
        !          2062:     else
        !          2063:        type = 0;
        !          2064: 
        !          2065:     PostMessage (hStatusWnd, SB_SETTEXT, (WPARAM) ((led + 1) | type), (LPARAM) labels[led]);
        !          2066: }
        !          2067: 
        !          2068: void gui_filename (int num, const char *name)
        !          2069: {
        !          2070: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.