/od-win32/win32gui.cpp
C++ | 15555 lines | 15110 code | 381 blank | 64 comment | 1330 complexity | eeb3e163cdcafdf0708842f96576f6dc MD5 | raw file
- /*==========================================================================
- *
- * Copyright (C) 1996 Brian King
- *
- * File: win32gui.c
- * Content: Win32-specific gui features for UAE port.
- *
- ***************************************************************************/
- #define CONFIGCACHE 1
- #define FRONTEND 0
- #define _WIN32_WINNT 0x600
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <windowsx.h>
- #include <winspool.h>
- #include <winuser.h>
- #include <mmsystem.h>
- #include <commctrl.h>
- #include <commdlg.h>
- #include <dlgs.h>
- #include <prsht.h>
- #include <richedit.h>
- #include <shellapi.h>
- #include <Shlobj.h>
- #include <shlwapi.h>
- #include <ddraw.h>
- #include <shobjidl.h>
- #include <dbt.h>
- #include <Cfgmgr32.h>
- #include "resource.h"
- #include "sysconfig.h"
- #include "sysdeps.h"
- #include "gui.h"
- #include "options.h"
- #include "memory.h"
- #include "rommgr.h"
- #include "custom.h"
- #include "events.h"
- #include "newcpu.h"
- #include "traps.h"
- #include "disk.h"
- #include "uae.h"
- #include "threaddep/thread.h"
- #include "filesys.h"
- #include "autoconf.h"
- #include "inputdevice.h"
- #include "inputrecord.h"
- #include "xwin.h"
- #include "keyboard.h"
- #include "zfile.h"
- #include "parallel.h"
- #include "audio.h"
- #include "arcadia.h"
- #include "drawing.h"
- #include "fsdb.h"
- #include "blkdev.h"
- #include "dxwrap.h"
- #include "win32.h"
- #include "registry.h"
- #include "picasso96_win.h"
- #include "win32gui.h"
- #include "win32gfx.h"
- #include "sounddep/sound.h"
- #include "od-win32/parser.h"
- #include "od-win32/ahidsound.h"
- #include "target.h"
- #include "savestate.h"
- #include "avioutput.h"
- #include "opengl.h"
- #include "direct3d.h"
- #include "akiko.h"
- #include "cdtv.h"
- #include "gfxfilter.h"
- #include "driveclick.h"
- #include "scsi.h"
- #include "cpuboard.h"
- #include "x86.h"
- #include "sana2.h"
- #ifdef PROWIZARD
- #include "moduleripper.h"
- #endif
- #include "catweasel.h"
- #include "lcd.h"
- #include "uaeipc.h"
- #include "crc32.h"
- #include "rp.h"
- #include "statusline.h"
- #include "zarchive.h"
- #include "gfxboard.h"
- #include "win32_uaenet.h"
- #include "uae/ppc.h"
- #ifdef RETROPLATFORM
- #include "rp.h"
- #endif
- #include "ini.h"
- #include "specialmonitors.h"
- #include "gayle.h"
- #ifdef FLOPPYBRIDGE
- #include "floppybridge/floppybridge_abstract.h"
- #include "floppybridge/floppybridge_lib.h"
- #endif
- #define GUI_SCALE_DEFAULT 100
- #define ARCHIVE_STRING _T("*.zip;*.7z;*.rar;*.lha;*.lzh;*.lzx")
- #define DISK_FORMAT_STRING _T("(*.adf;*.adz;*.gz;*.dms;*.ipf;*.scp;*.fdi;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.ipf;*.scp;*.fdi;*.exe;*.ima;*.wrp;*.dsq;*.st;*.raw;") ARCHIVE_STRING _T("\0")
- #define ROM_FORMAT_STRING _T("(*.rom;*.roz;*.bin;*.a500;*.a600;*.a1200;*.a4000)\0*.rom;*.roz;*.bin;*.a500;*.a600;*.a1200;*.a4000;") ARCHIVE_STRING _T("\0")
- #define USS_FORMAT_STRING_RESTORE _T("(*.uss)\0*.uss;*.gz;") ARCHIVE_STRING _T("\0")
- #define USS_FORMAT_STRING_SAVE _T("(*.uss)\0*.uss\0")
- #define HDF_FORMAT_STRING _T("(*.hdf;*.vhd;*.rdf;*.hdz;*.rdz;*.chd)\0*.hdf;*.vhd;*.rdf;*.hdz;*.rdz;*.chd\0")
- #define INP_FORMAT_STRING _T("(*.inp)\0*.inp\0")
- #define CD_FORMAT_STRING _T("(*.cue;*.ccd;*.mds;*.iso;*.chd;*.nrg)\0*.cue;*.ccd;*.mds;*.iso;*.chd;*.nrg;") ARCHIVE_STRING _T("\0")
- #define GEO_FORMAT_STRING _T("(*.geo)\0*.geo\0")
- #define CONFIG_HOST _T("Host")
- #define CONFIG_HARDWARE _T("Hardware")
- #define SOUND_BUFFER_MULTIPLIER 1024
- static wstring szNone;
- static int allow_quit;
- static int restart_requested;
- int full_property_sheet = 1;
- static struct uae_prefs *pguiprefs;
- struct uae_prefs workprefs;
- static int currentpage = -1;
- static int qs_request_reset;
- static int qs_override;
- int gui_active, gui_left;
- static struct newresource *panelresource;
- int dialog_inhibit;
- #undef HtmlHelp
- #ifndef HH_DISPLAY_TOPIC
- #define HH_DISPLAY_TOPIC 0
- #endif
- extern HWND(WINAPI *pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD);
- void HtmlHelp(HWND a, LPCWSTR b, UINT c, const TCHAR *d)
- {
- if (pHtmlHelp) {
- (*pHtmlHelp)(a, b, c, (LPDWORD)d);
- } else {
- if (gui_message_multibutton(1, _T("Help file is not installed locally, do you want to open online version? (http://www.winuae.net/help/)")) == 1) {
- if ((int)ShellExecute(NULL, _T("open"), _T("http://www.winuae.net/help/"), NULL, NULL, SW_SHOWNORMAL) <= 32) {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString(IDS_NOHELP, szMessage, MAX_DPATH);
- gui_message(szMessage);
- }
- }
- }
- }
- extern TCHAR help_file[MAX_DPATH];
- extern int mouseactive;
- TCHAR config_filename[256] = _T("");
- static TCHAR config_pathfilename[MAX_DPATH];
- static TCHAR config_folder[MAX_DPATH];
- static TCHAR config_search[MAX_DPATH];
- static TCHAR stored_path[MAX_DPATH];
- static int gui_size_changed;
- static int filterstackpos = 2 * MAX_FILTERSHADERS;
- extern std::vector<FloppyBridgeAPI::FloppyBridgeProfileInformation> bridgeprofiles;
- bool isguiactive(void)
- {
- return gui_active > 0;
- }
- static const int defaultaspectratios[] = {
- 5, 4, 4, 3, 16, 10, 15, 9, 27, 16, 128, 75, 16, 9, 256, 135, 21, 9, 16, 3,
- -1
- };
- static int getaspectratioindex (int ar)
- {
- for (int i = 0; defaultaspectratios[i] >= 0; i += 2) {
- if (ar == defaultaspectratios[i + 0] * ASPECTMULT + defaultaspectratios[i + 1])
- return i / 2;
- }
- return 0;
- }
- static int getaspectratio (int index)
- {
- for (int i = 0; defaultaspectratios[i] >= 0; i += 2) {
- if (i == index * 2) {
- return defaultaspectratios[i + 0] * ASPECTMULT + defaultaspectratios[i + 1];
- }
- }
- return 0;
- }
- static void addaspectratios (HWND hDlg, int id)
- {
- for (int i = 0; defaultaspectratios[i] >= 0; i += 2) {
- TCHAR tmp[100];
- _stprintf (tmp, _T("%d:%d (%.2f)"), defaultaspectratios[i + 0], defaultaspectratios[i + 1], (double)defaultaspectratios[i + 0] / defaultaspectratios[i + 1]);
- SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- }
- int scsiromselected = 0;
- static int scsiromselectednum = 0;
- static int scsiromselectedcatnum = 0;
- #define Error(x) MessageBox (NULL, (x), _T("WinUAE Error"), MB_OK)
- wstring WIN32GUI_LoadUIString (DWORD id)
- {
- wchar_t tmp[MAX_DPATH];
- tmp[0] = 0;
- if (LoadString (hUIDLL ? hUIDLL : hInst, id, tmp, MAX_DPATH) == 0)
- LoadString (hInst, id, tmp, MAX_DPATH);
- return wstring(tmp);
- }
- void WIN32GUI_LoadUIString (DWORD id, TCHAR *string, DWORD dwStringLen)
- {
- if (LoadString (hUIDLL ? hUIDLL : hInst, id, string, dwStringLen) == 0)
- LoadString (hInst, id, string, dwStringLen);
- }
- static int quickstart_model = 0, quickstart_conf = 0, quickstart_compa = 1;
- static int quickstart_model_confstore[16];
- static int quickstart_floppy = 1, quickstart_cd = 0, quickstart_ntsc = 0;
- static int quickstart_floppytype[2], quickstart_floppysubtype[2];
- static TCHAR quickstart_floppysubtypeid[2][32];
- static int quickstart_cdtype = 0;
- static TCHAR quickstart_cddrive[16];
- static int quickstart_ok, quickstart_ok_floppy;
- // don't enable yet. issues with quickstart panel
- static bool firstautoloadconfig = false;
- static void addfloppytype (HWND hDlg, int n);
- static void addfloppyhistory (HWND hDlg);
- static void addhistorymenu (HWND hDlg, const TCHAR*, int f_text, int type, bool manglepath, int num);
- static void addcdtype (HWND hDlg, int id);
- static void getfloppyname (HWND hDlg, int n, int cd, int f_text);
- static int C_PAGES;
- #define MAX_C_PAGES 30
- static int LOADSAVE_ID = -1, MEMORY_ID = -1, KICKSTART_ID = -1, CPU_ID = -1,
- DISPLAY_ID = -1, HW3D_ID = -1, CHIPSET_ID = -1, CHIPSET2_ID = -1, SOUND_ID = -1, FLOPPY_ID = -1, DISK_ID = -1,
- HARDDISK_ID = -1, IOPORTS_ID = -1, GAMEPORTS_ID = -1, INPUT_ID = -1, MISC1_ID = -1, MISC2_ID = -1,
- AVIOUTPUT_ID = -1, PATHS_ID = -1, QUICKSTART_ID = -1, ABOUT_ID = -1, EXPANSION_ID = -1, EXPANSION2_ID = -1,
- BOARD_ID = -1, FRONTEND_ID = -1;
- static const int INPUTMAP_ID = MAX_C_PAGES - 1;
- static HWND pages[MAX_C_PAGES];
- #define MAX_IMAGETOOLTIPS 10
- static HWND guiDlg, panelDlg, ToolTipHWND;
- static struct dlgcontext maindctx;
- static HACCEL hAccelTable;
- static HWND customDlg;
- static int customDlgType;
- struct ToolTipHWNDS {
- WNDPROC proc;
- HWND hwnd;
- int imageid;
- };
- static struct ToolTipHWNDS ToolTipHWNDS2[MAX_IMAGETOOLTIPS + 1];
- struct GUIPAGE {
- DLGPROC dlgproc;
- LPCTSTR title;
- LPCTSTR icon;
- HTREEITEM tv;
- int himg;
- int idx;
- const TCHAR *help;
- HACCEL accel;
- int fullpanel;
- struct newresource *nres;
- int focusid;
- };
- static struct GUIPAGE ppage[MAX_C_PAGES];
- static bool ischecked (HWND hDlg, DWORD id)
- {
- return IsDlgButtonChecked (hDlg, id) == BST_CHECKED;
- }
- static void setchecked (HWND hDlg, DWORD id, bool checked)
- {
- CheckDlgButton (hDlg, id, checked ? BST_CHECKED : BST_UNCHECKED);
- }
- static void setfocus (HWND hDlg, int id)
- {
- SendMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, id), TRUE);
- }
- static void ew (HWND hDlg, DWORD id, int enable)
- {
- if (id == -1)
- return;
- HWND w = GetDlgItem (hDlg, id);
- if (!w)
- return;
- if (!enable && w == GetFocus ())
- SendMessage (hDlg, WM_NEXTDLGCTL, 0, FALSE);
- EnableWindow (w, !!enable);
- }
- static void hide (HWND hDlg, DWORD id, int hide)
- {
- HWND w;
- if (id == -1)
- return;
- w = GetDlgItem (hDlg, id);
- if (!w)
- return;
- if (hide && w == GetFocus ())
- SendMessage (hDlg, WM_NEXTDLGCTL, 0, FALSE);
- ShowWindow (w, hide ? SW_HIDE : SW_SHOW);
- }
- static void parsefilepath(TCHAR *path, int maxlen)
- {
- TCHAR *tmp = xmalloc(TCHAR, maxlen + 1);
- _tcscpy(tmp, path);
- TCHAR *p1 = _tcsstr(tmp, _T(" { "));
- TCHAR *p2 = _tcsstr(tmp, _T(" }"));
- if (p1 && p2 && p2 > p1) {
- *p1 = 0;
- memset(path, 0, maxlen * sizeof(TCHAR));
- memcpy(path, p1 + 3, (p2 - p1 - 3) * sizeof(TCHAR));
- _tcscat(path, tmp);
- }
- xfree(tmp);
- }
- static int scsiromselect_table[300];
- static bool getcomboboxtext(HWND hDlg, int id, TCHAR *out, int maxlen)
- {
- out[0] = 0;
- int posn = SendDlgItemMessage(hDlg, id, CB_GETCURSEL, 0, 0L);
- if (posn == CB_ERR) {
- GetDlgItemText(hDlg, id, out, maxlen);
- return true;
- }
- int len = SendDlgItemMessage(hDlg, id, CB_GETLBTEXTLEN, posn, 0);
- if (len < maxlen) {
- len = SendDlgItemMessage(hDlg, id, CB_GETLBTEXT, posn, (LPARAM)out);
- }
- return true;
- }
- static void gui_add_string(int *table, HWND hDlg, int item, int id, const TCHAR *str)
- {
- while (*table >= 0)
- table++;
- *table++ = id;
- *table = -1;
- SendDlgItemMessage(hDlg, item, CB_ADDSTRING, 0, (LPARAM)str);
- }
- static void gui_set_string_cursor(int *table, HWND hDlg, int item, int id)
- {
- int idx = 0;
- while (*table >= 0) {
- if (*table == id) {
- SendDlgItemMessage(hDlg, item, CB_SETCURSEL, idx, 0);
- return;
- }
- idx++;
- table++;
- }
- }
- static int gui_get_string_cursor(int *table, HWND hDlg, int item)
- {
- int posn = SendDlgItemMessage (hDlg, item, CB_GETCURSEL, 0, 0);
- if (posn < 0)
- return CB_ERR;
- return table[posn];
- }
- static void commonproc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- if (msg == WM_DPICHANGED) {
- RECT *const r = (RECT *)lParam;
- SetWindowPos(hDlg, NULL, r->left, r->top, r->right - r->left, r->bottom - r->top, SWP_NOZORDER | SWP_NOACTIVATE);
- }
- }
- static int stringboxdialogactive;
- static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- if (dialog_inhibit)
- return 0;
- switch(msg)
- {
- case WM_DESTROY:
- PostQuitMessage (0);
- return TRUE;
- case WM_CLOSE:
- stringboxdialogactive = 0;
- DestroyWindow (hDlg);
- return TRUE;
- case WM_INITDIALOG:
- return TRUE;
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- stringboxdialogactive = -1;
- DestroyWindow (hDlg);
- return TRUE;
- case IDCANCEL:
- stringboxdialogactive = 0;
- DestroyWindow (hDlg);
- return TRUE;
- }
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static int CALLBACK BrowseForFolderCallback (HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
- {
- TCHAR szPath[MAX_DPATH];
- switch(uMsg)
- {
- case BFFM_INITIALIZED:
- SendMessage (hwnd, BFFM_SETSELECTION, TRUE, pData);
- break;
- case BFFM_SELCHANGED:
- if (SHGetPathFromIDList ((LPITEMIDLIST)lp ,szPath))
- SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szPath);
- break;
- }
- return 0;
- }
- static int DirectorySelection2 (OPENFILENAME *ofn)
- {
- BROWSEINFO bi;
- LPITEMIDLIST pidlBrowse;
- TCHAR buf[MAX_DPATH], fullpath[MAX_DPATH];
- TCHAR *path = ofn->lpstrFile;
- int ret = 0;
- buf[0] = 0;
- memset (&bi, 0, sizeof bi);
- bi.hwndOwner = ofn->hwndOwner;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = buf;
- bi.lpszTitle = NULL;
- bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
- if (path[0] && GetFullPathName (path, sizeof fullpath / sizeof (TCHAR), fullpath, NULL)) {
- bi.lpfn = BrowseForFolderCallback;
- bi.lParam = (LPARAM)fullpath;
- }
- // Browse for a folder and return its PIDL.
- pidlBrowse = SHBrowseForFolder (&bi);
- if (pidlBrowse != NULL) {
- if (SHGetPathFromIDList (pidlBrowse, buf)) {
- _tcscpy (path, buf);
- ret = 1;
- }
- CoTaskMemFree (pidlBrowse);
- }
- return ret;
- }
- static TCHAR *getfilepath (TCHAR *s)
- {
- TCHAR *p = _tcsrchr (s, '\\');
- if (p)
- return p + 1;
- return NULL;
- }
- typedef HRESULT (CALLBACK* SHCREATEITEMFROMPARSINGNAME)
- (PCWSTR,IBindCtx*,REFIID,void**); // Vista+ only
- // OPENFILENAME->IFileOpenDialog wrapper
- static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
- {
- SHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName;
- HRESULT hr;
- IFileOpenDialog *pfd;
- FILEOPENDIALOGOPTIONS pfos;
- IShellItem *shellitem = NULL;
- int ret;
- COMDLG_FILTERSPEC *fs = NULL;
- int filtercnt = 0;
- static const GUID fsdialogguid = { 0xe768b477, 0x3684, 0x4128, { 0x91, 0x55, 0x8c, 0x8f, 0xd9, 0x2d, 0x16, 0x7b } };
- if (isfullscreen () > 0)
- guid = &fsdialogguid;
- hr = E_FAIL;
- ret = 0;
- pSHCreateItemFromParsingName = (SHCREATEITEMFROMPARSINGNAME)GetProcAddress (
- GetModuleHandle (_T("shell32.dll")), "SHCreateItemFromParsingName");
- if (pSHCreateItemFromParsingName)
- hr = CoCreateInstance (mode > 0 ? __uuidof(FileSaveDialog) : __uuidof(FileOpenDialog),
- NULL,
- CLSCTX_INPROC_SERVER,
- mode > 0 ? IID_IFileSaveDialog : IID_IFileOpenDialog, (LPVOID*)&pfd);
- if (FAILED (hr)) {
- if (mode > 0)
- return GetSaveFileName (opn);
- else if (mode == 0)
- return GetOpenFileName (opn);
- else
- return DirectorySelection2 (opn);
- }
- pfd->GetOptions (&pfos);
- pfos |= FOS_FORCEFILESYSTEM;
- if (!(opn->Flags & OFN_FILEMUSTEXIST))
- pfos &= ~FOS_FILEMUSTEXIST;
- if (opn->Flags & OFN_ALLOWMULTISELECT)
- pfos |= FOS_ALLOWMULTISELECT;
- if (mode < 0)
- pfos |= FOS_PICKFOLDERS;
- pfd->SetOptions (pfos);
- opn->nFileOffset = 0;
- if (guid)
- pfd->SetClientGuid (*guid);
- if (opn->lpstrFilter) {
- const TCHAR *p = opn->lpstrFilter;
- int i;
- while (*p) {
- p += _tcslen (p) + 1;
- p += _tcslen (p) + 1;
- filtercnt++;
- }
- if (filtercnt) {
- fs = xmalloc (COMDLG_FILTERSPEC, filtercnt);
- p = opn->lpstrFilter;
- for (i = 0; i < filtercnt; i++) {
- fs[i].pszName = p;
- p += _tcslen (p) + 1;
- fs[i].pszSpec = p;
- p += _tcslen (p) + 1;
- }
- pfd->SetFileTypes (filtercnt, fs);
- }
- pfd->SetFileTypeIndex (opn->nFilterIndex);
- }
- if (mode >= 0 && opn->lpstrFile) {
- pfd->SetFileName(opn->lpstrFile);
- }
- if (opn->lpstrTitle) {
- pfd->SetTitle (opn->lpstrTitle);
- }
- if (opn->lpstrDefExt) {
- pfd->SetDefaultExtension (opn->lpstrDefExt);
- }
- if (opn->lpstrInitialDir) {
- TCHAR tmp[MAX_DPATH];
- const TCHAR *p = opn->lpstrInitialDir;
- if (GetFullPathName (p, sizeof tmp / sizeof (TCHAR), tmp, NULL))
- p = tmp;
- hr = pSHCreateItemFromParsingName (p, NULL, IID_IShellItem, (void**)&shellitem);
- if (SUCCEEDED (hr))
- pfd->SetFolder (shellitem);
- }
- hr = pfd->Show (opn->hwndOwner);
- if (SUCCEEDED (hr)) {
- UINT idx;
- IShellItemArray *pitema;
- opn->lpstrFile[0] = 0;
- opn->lpstrFile[1] = 0;
- if (opn->lpstrFileTitle)
- opn->lpstrFileTitle[0] = 0;
- if (mode > 0) {
- IShellItem *pitem;
- hr = pfd->GetResult (&pitem);
- if (SUCCEEDED (hr)) {
- WCHAR *path = NULL;
- hr = pitem->GetDisplayName (SIGDN_FILESYSPATH, &path);
- if (SUCCEEDED (hr)) {
- TCHAR *p = opn->lpstrFile;
- _tcscpy (p, path);
- p[_tcslen (p) + 1] = 0;
- p = getfilepath (opn->lpstrFile);
- if (p && opn->lpstrFileTitle)
- _tcscpy (opn->lpstrFileTitle, p);
- }
- pitem->Release ();
- }
- } else {
- hr = pfd->GetResults (&pitema);
- if (SUCCEEDED (hr)) {
- DWORD cnt;
- hr = pitema->GetCount (&cnt);
- if (SUCCEEDED (hr)) {
- int i, first = true;
- for (i = 0; i < cnt; i++) {
- IShellItem *pitem;
- hr = pitema->GetItemAt (i, &pitem);
- if (SUCCEEDED (hr)) {
- WCHAR *path = NULL;
- hr = pitem->GetDisplayName (SIGDN_FILESYSPATH, &path);
- if (SUCCEEDED (hr)) {
- TCHAR *ppath = path;
- TCHAR *p = opn->lpstrFile;
- while (*p)
- p += _tcslen (p) + 1;
- TCHAR *pathfilename = _tcsrchr (ppath, '\\');
- if (pathfilename)
- pathfilename++;
- if (first && cnt > 1) {
- opn->nFileOffset = pathfilename - ppath;
- _tcscpy (p, ppath);
- p[opn->nFileOffset - 1] = 0;
- p += _tcslen (p) + 1;
- *p = 0;
- ppath = pathfilename;
- } else if (cnt > 1) {
- ppath = pathfilename;
- } else {
- ppath = path;
- }
- if (!ppath)
- ppath = path;
- if (p - opn->lpstrFile + _tcslen (ppath) + 2 < opn->nMaxFile) {
- _tcscpy (p, ppath);
- p[_tcslen (p) + 1] = 0;
- }
- if (opn->lpstrFileTitle && !opn->lpstrFileTitle[0]) {
- p = getfilepath (opn->lpstrFile);
- if (p && opn->lpstrFileTitle)
- _tcscpy (opn->lpstrFileTitle, p);
- }
- first = false;
- }
- CoTaskMemFree (path);
- }
- }
- }
- pitema->Release ();
- }
- }
- hr = pfd->GetFileTypeIndex (&idx);
- if (SUCCEEDED (hr))
- opn->nFilterIndex = idx;
- ret = 1;
- }
- pfd->Release ();
- if (shellitem)
- shellitem->Release ();
- if (filtercnt) {
- xfree (fs);
- }
- return ret;
- }
- static BOOL GetOpenFileName_2 (HWND parent, OPENFILENAME *opn, const GUID *guid)
- {
- BOOL val;
- val = GetFileDialog (opn, guid, 0);
- return val;
- }
- static BOOL GetSaveFileName_2 (HWND parent, OPENFILENAME *opn, const GUID *guid)
- {
- BOOL val;
- val = GetFileDialog (opn, guid, 1);
- return val;
- }
- int DirectorySelection (HWND hDlg, const GUID *guid, TCHAR *path)
- {
- int val;
- OPENFILENAME ofn = { 0 };
- ofn.hwndOwner = hDlg;
- ofn.lpstrFile = path;
- ofn.lpstrInitialDir = path;
- ofn.nMaxFile = MAX_DPATH;
- val = GetFileDialog (&ofn, NULL, -1);
- fullpath (path, MAX_DPATH);
- return val;
- }
- static const TCHAR *historytypes[] =
- {
- _T("DiskImageMRUList"),
- _T("CDImageMRUList"),
- _T("DirFileSysMRUList"),
- _T("HardfileMRUList"),
- _T("FileSysMRUList"),
- _T("TapeImageMRUList"),
- _T("GenlockImageMRUList"),
- _T("GenlockVideoMRUList"),
- _T("GeometryMRUList"),
- _T("StatefileMRUList"),
- _T("ConfigfileMRUList")
- };
- static int regread;
- static void write_disk_history2 (int type)
- {
- int i, j;
- TCHAR tmp[16];
- UAEREG *fkey;
- if (!(regread & (1 << type)))
- return;
- fkey = regcreatetree (NULL, historytypes[type]);
- if (fkey == NULL)
- return;
- j = 1;
- for (i = 0; i <= MAX_PREVIOUS_IMAGES; i++) {
- TCHAR *s = DISK_history_get (i, type);
- if (s == 0 || _tcslen (s) == 0)
- continue;
- _stprintf (tmp, _T("Image%02d"), j);
- regsetstr (fkey, tmp, s);
- j++;
- }
- while (j <= MAX_PREVIOUS_IMAGES) {
- const TCHAR *s = _T("");
- _stprintf (tmp, _T("Image%02d"), j);
- regsetstr (fkey, tmp, s);
- j++;
- }
- regclosetree (fkey);
- }
- void write_disk_history (void)
- {
- write_disk_history2(HISTORY_FLOPPY);
- write_disk_history2(HISTORY_CD);
- write_disk_history2(HISTORY_DIR);
- write_disk_history2(HISTORY_HDF);
- write_disk_history2(HISTORY_FS);
- write_disk_history2(HISTORY_TAPE);
- write_disk_history2(HISTORY_GENLOCK_IMAGE);
- write_disk_history2(HISTORY_GENLOCK_VIDEO);
- write_disk_history2(HISTORY_GEO);
- write_disk_history2(HISTORY_STATEFILE);
- write_disk_history2(HISTORY_CONFIGFILE);
- }
- void reset_disk_history (void)
- {
- int i, rrold;
- for (i = 0; i < MAX_PREVIOUS_IMAGES; i++) {
- DISK_history_add(NULL, i, HISTORY_FLOPPY, 0);
- DISK_history_add(NULL, i, HISTORY_CD, 0);
- DISK_history_add(NULL, i, HISTORY_DIR, 0);
- DISK_history_add(NULL, i, HISTORY_HDF, 0);
- DISK_history_add(NULL, i, HISTORY_FS, 0);
- DISK_history_add(NULL, i, HISTORY_TAPE, 0);
- DISK_history_add(NULL, i, HISTORY_GENLOCK_IMAGE, 0);
- DISK_history_add(NULL, i, HISTORY_GENLOCK_VIDEO, 0);
- DISK_history_add(NULL, i, HISTORY_GEO, 0);
- DISK_history_add(NULL, i, HISTORY_STATEFILE, 0);
- DISK_history_add(NULL, i, HISTORY_CONFIGFILE, 0);
- }
- rrold = regread;
- regread = (1 << HISTORY_MAX) - 1;
- write_disk_history ();
- regread = rrold;
- }
- UAEREG *read_disk_history (int type)
- {
- TCHAR tmp2[MAX_DPATH];
- int size, size2;
- int idx, idx2;
- UAEREG *fkey;
- TCHAR tmp[MAX_DPATH];
- fkey = regcreatetree (NULL, historytypes[type]);
- if (fkey == NULL || (regread & (1 << type)))
- return fkey;
- idx = 0;
- for (;;) {
- size = sizeof (tmp) / sizeof (TCHAR);
- size2 = sizeof (tmp2) / sizeof (TCHAR);
- if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
- break;
- if (_tcslen (tmp) == 7) {
- idx2 = _tstol (tmp + 5) - 1;
- if (idx2 >= 0)
- DISK_history_add (tmp2, idx2, type, type != HISTORY_FLOPPY && type != HISTORY_CD);
- }
- idx++;
- }
- regread |= 1 << type;
- return fkey;
- }
- void exit_gui (int ok)
- {
- if (!gui_active)
- return;
- if (guiDlg == NULL)
- return;
- SendMessage (guiDlg, WM_COMMAND, ok ? IDOK : IDCANCEL, 0);
- }
- static int getcbn (HWND hDlg, int v, TCHAR *out, int maxlen)
- {
- LRESULT val = SendDlgItemMessage (hDlg, v, CB_GETCURSEL, 0, 0L);
- out[0] = 0;
- if (val == CB_ERR) {
- SendDlgItemMessage (hDlg, v, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)out);
- return 1;
- } else {
- int len = SendDlgItemMessage(hDlg, v, CB_GETLBTEXTLEN, (WPARAM)val, 0);
- if (len < maxlen) {
- val = SendDlgItemMessage (hDlg, v, CB_GETLBTEXT, (WPARAM)val, (LPARAM)out);
- }
- return 0;
- }
- }
- struct favitems
- {
- TCHAR *value;
- TCHAR *path;
- int type;
- };
- #define MAXFAVORITES 30
- #define MAXFAVORITESPACE 99
- static void writefavoritepaths (int num, struct favitems *fitem)
- {
- int i, idx;
- UAEREG *fkey;
- fkey = regcreatetree (NULL, _T("FavoritePaths"));
- if (fkey == NULL)
- return;
- idx = 0;
- for (i = 0; i < num; i++) {
- TCHAR str[MAX_DPATH];
- TCHAR key[100];
- if (fitem[i].type != 1)
- continue;
- if (!_tcscmp (fitem[i].value, fitem[i].path))
- _tcscpy (str, fitem[i].value);
- else
- _stprintf (str, _T("%s \"%s\""), fitem[i].value, fitem[i].path);
- _stprintf (key, _T("PATH_ALL_%02d"), idx + 1);
- idx++;
- regsetstr (fkey, key, str);
- xfree (fitem[i].value);
- xfree (fitem[i].path);
- }
- while (idx < MAXFAVORITES) {
- TCHAR key[100];
- _stprintf (key, _T("PATH_ALL_%02d"), idx + 1);
- regdelete (fkey, key);
- idx++;
- }
- regclosetree (fkey);
- }
- static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid);
- static int addfavoritepath (HWND hDlg, int num, struct favitems *fitem)
- {
- TCHAR name[MAX_DPATH];
- const GUID favoriteguid =
- { 0xed6e5ad9, 0xc0aa, 0x42fb, { 0x83, 0x3, 0x37, 0x41, 0x77, 0xb4, 0x6f, 0x18 } };
- if (num >= MAXFAVORITES)
- return 0;
- if (!stored_path[0])
- GetModuleFileName (NULL, stored_path, MAX_DPATH);
- while (stored_path[0]) {
- DWORD v = GetFileAttributes (stored_path);
- TCHAR *s;
- if (v == INVALID_FILE_ATTRIBUTES)
- break;
- if (v & FILE_ATTRIBUTE_DIRECTORY)
- break;
- s = _tcsrchr (stored_path, '\\');
- if (!s)
- s = _tcsrchr (stored_path, '/');
- if (!s) {
- stored_path[0] = 0;
- break;
- }
- s[0] = 0;
- }
- if (!DirectorySelection (hDlg, &favoriteguid, stored_path))
- return 0;
- _tcscpy (name, stored_path);
- if (askinputcustom (hDlg, name, sizeof name / sizeof (TCHAR), IDS_SB_FAVORITENAME)) {
- fitem[num].value = my_strdup (name);
- fitem[num].path = my_strdup (stored_path);
- fitem[num].type = 1;
- num++;
- writefavoritepaths (num, fitem);
- }
- return 1;
- }
- static void removefavoritepath (int idx, int num, struct favitems *fitem)
- {
- int i;
- xfree (fitem[idx].value);
- xfree (fitem[idx].path);
- fitem[idx].value = fitem[idx].path = NULL;
- for (i = idx; i < num - 1; i++) {
- fitem[i].value = fitem[i + 1].value;
- fitem[i].path = fitem[i + 1].path;
- }
- num--;
- writefavoritepaths (num, fitem);
- }
- static void addeditmenu (HMENU menu, struct favitems *fitem)
- {
- int i;
- HMENU emenu = CreatePopupMenu ();
- TCHAR newpath[MAX_DPATH];
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof mii;
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- mii.fState = MFS_ENABLED;
- InsertMenuItem (menu, -1, TRUE, &mii);
- mii.fMask = MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.dwTypeData = _T("Add New");
- mii.cch = _tcslen (mii.dwTypeData);
- mii.wID = 1000;
- InsertMenuItem (emenu, -1, TRUE, &mii);
- i = 0;
- while (fitem[i].type) {
- if (fitem[i].type == 1) {
- mii.fMask = MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.wID = 1001 + i;
- _stprintf (newpath, _T("Remove '%s'"), fitem[i].value);
- mii.dwTypeData = newpath;
- mii.cch = _tcslen (mii.dwTypeData);
- InsertMenuItem (emenu, -1, TRUE, &mii);
- }
- i++;
- }
- mii.fMask = MIIM_STRING | MIIM_SUBMENU;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.dwTypeData = _T("Edit");
- mii.cch = _tcslen (mii.dwTypeData);
- mii.hSubMenu = emenu;
- InsertMenuItem (menu, -1, TRUE, &mii);
- }
- static int popupmenu (HWND hwnd, struct favitems *items, int morefiles)
- {
- int i, item, got;
- HMENU menu;
- POINT pt;
- menu = CreatePopupMenu ();
- got = 0;
- i = 0;
- while (items[i].type) {
- if (items[i].type >= 2) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof mii;
- mii.fMask = MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.wID = items[i].type == 2 ? 1 + i : 990 - 3 + items[i].type;
- mii.dwTypeData = items[i].value;
- mii.cch = _tcslen (mii.dwTypeData);
- InsertMenuItem (menu, -1, TRUE, &mii);
- got = 1;
- }
- i++;
- }
- if (morefiles < 0) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof mii;
- mii.fMask = MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.wID = 999;
- mii.dwTypeData = _T("[Directory scan]");
- mii.cch = _tcslen (mii.dwTypeData);
- InsertMenuItem (menu, -1, TRUE, &mii);
- got = 1;
- }
- if (got) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof mii;
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- mii.fState = MFS_ENABLED;
- InsertMenuItem (menu, -1, TRUE, &mii);
- }
- i = 0;
- while (items[i].type) {
- if (items[i].type == 1) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof mii;
- mii.fMask = MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
- mii.fState = MFS_ENABLED;
- mii.wID = 1 + i;
- mii.dwTypeData = items[i].value;
- mii.cch = _tcslen (mii.dwTypeData);
- InsertMenuItem (menu, -1, TRUE, &mii);
- }
- i++;
- }
- addeditmenu (menu, items);
- GetCursorPos (&pt);
- item = TrackPopupMenu (menu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD,
- pt.x, pt.y, 0, hwnd, NULL);
- PostMessage (hwnd, WM_NULL, 0, 0);
- DestroyMenu (menu);
- return item;
- }
- static void favitemsort (struct favitems *fitem, int start, int end)
- {
- for (int i = start; i < end; i++) {
- for (int j = i + 1; j < end; j++) {
- if (_tcscmp (fitem[i].value, fitem[j].value) > 0) {
- struct favitems tmp;
- memcpy (&tmp, &fitem[i], sizeof tmp);
- memcpy (&fitem[i], &fitem[j], sizeof tmp);
- memcpy (&fitem[j], &tmp, sizeof tmp);
- }
- }
- }
- }
- static int getdeepfavdiskimage (TCHAR *imgpath, struct favitems *fitem, int idx)
- {
- TCHAR path[MAX_DPATH], mask[MAX_DPATH];
- TCHAR *p;
- struct my_opendir_s *myd = NULL;
- int previdx = idx;
- if (!imgpath[0])
- return idx;
- _tcscpy (path, imgpath);
- mask[0] = 0;
- for (;;) {
- p = _tcsrchr (path, '\\');
- if (!p)
- p = _tcsrchr (path, '/');
- if (!p)
- break;
- if (!mask[0])
- _tcscpy (mask, p + 1);
- p[0] = 0;
- if (my_existsdir (path))
- break;
- }
- static TCHAR notallowed[] = _T("[]()_-#!{}=.,");
- for (int i = 0; i < _tcslen (notallowed); i++) {
- for (;;) {
- p = _tcsrchr (mask, notallowed[i]);
- if (!p)
- break;
- if (p - mask < 6)
- break;
- p[0] = 0;
- }
- }
- while (mask[_tcslen (mask) - 1] == ' ')
- mask[_tcslen (mask) - 1] = 0;
- _tcscat (mask, _T("*.*"));
- myd = my_opendir (path, mask);
- int cnt = 0;
- while (myd && cnt < 30) {
- TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
- if (!my_readdir (myd, tmp))
- break;
- _tcscpy (tmp2, path);
- _tcscat (tmp2, _T("\\"));
- _tcscat (tmp2, tmp);
- fitem[idx].value = my_strdup (tmp2);
- fitem[idx].path = NULL;
- fitem[idx].type = 2;
- idx++;
- cnt++;
- }
- my_closedir (myd);
- favitemsort (fitem, previdx, idx);
- fitem[idx].type = 0;
- return idx;
- }
- static int getfavdiskimage (TCHAR *imgpath, struct favitems *fitem, int idx)
- {
- int i;
- TCHAR name[MAX_DPATH];
- _tcscpy (name, imgpath);
- int previdx = idx;
- for (;;) {
- if (!disk_prevnext_name (name, 1))
- break;
- for (i = previdx; i < idx; i++) {
- if (!_tcsicmp (fitem[i].value, name))
- break;
- }
- if (i < idx)
- break;
- fitem[idx].value = my_strdup (name);
- fitem[idx].path = NULL;
- fitem[idx].type = 2;
- idx++;
- if (!_tcscmp (name, imgpath))
- break;
- }
- favitemsort (fitem, previdx, idx);
- fitem[idx].type = 0;
- return idx;
- }
- static TCHAR *favoritepopup (HWND hwnd, int drive)
- {
- UAEREG *fkey;
- int idx, idx2;
- struct favitems fitem[MAXFAVORITESPACE + 1];
- int ret, i, num;
- int srcdrive, dstdrive;
- int morefiles = 0;
- srcdrive = dstdrive = drive;
- for (;;) {
- fkey = regcreatetree (NULL, _T("FavoritePaths"));
- if (fkey == NULL)
- return NULL;
- idx = 0;
- num = 0;
- for (;;) {
- TCHAR *p;
- int size, size2;
- TCHAR tmp[1000], tmp2[1000];
- size = sizeof (tmp) / sizeof (TCHAR);
- size2 = sizeof (tmp2) / sizeof (TCHAR);
- if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
- break;
- p = _tcsrchr (tmp, '_');
- if (p) {
- idx2 = _tstol (p + 1);
- if (idx2 > 0 && idx2 < MAXFAVORITES) {
- TCHAR *p2 = _tcschr (tmp2, '"');
- TCHAR *str, *fname;
- idx2--;
- if (p2) {
- fname = my_strdup (p2 + 1);
- do {
- *p2-- = 0;
- } while (p2 > tmp2 && *p2 == ' ');
- p2 = _tcschr (fname, '"');
- if (p2)
- *p2 = 0;
- str = my_strdup (tmp2);
- } else {
- str = my_strdup (tmp2);
- fname = my_strdup (tmp2);
- }
- fitem[idx2].path = fname;
- fitem[idx2].value = str;
- fitem[idx2].type = 1;
- }
- }
- idx++;
- }
- regclosetree (fkey);
- favitemsort (fitem, 0, idx);
- fitem[idx].type = 0;
- if (srcdrive >= 0 && srcdrive <= 4) {
- if (!morefiles) {
- for (i = 0; i < 4; i++) {
- if (workprefs.floppyslots[i].df[0] && srcdrive != i) {
- TCHAR tmp[100];
- _stprintf (tmp, _T("[DF%c:]"), i + '0');
- fitem[idx].value = my_strdup (tmp);
- fitem[idx].path = my_strdup (workprefs.floppyslots[i].df);
- fitem[idx].type = 3 + i;
- idx++;
- fitem[idx].type = 0;
- }
- }
- }
- if (workprefs.floppyslots[srcdrive].df[0]) {
- if (morefiles > 0) {
- idx = getdeepfavdiskimage (workprefs.floppyslots[srcdrive].df, fitem, idx);
- } else {
- idx = getfavdiskimage (workprefs.floppyslots[srcdrive].df, fitem, idx);
- morefiles = -1;
- }
- }
- }
- ret = popupmenu (hwnd, fitem, morefiles);
- if (ret == 0)
- break;
- if (ret <= idx) {
- if (fitem[ret - 1].type == 2) {
- _tcscpy (workprefs.floppyslots[dstdrive].df, fitem[ret - 1].value);
- disk_insert (dstdrive, workprefs.floppyslots[dstdrive].df);
- ret = 0;
- }
- break;
- }
- if (ret >= 990 && ret <= 993) {
- srcdrive = ret - 990;
- } else if (ret == 999) {
- morefiles = 1;
- } else if (ret == 1000) {
- if (!addfavoritepath (hwnd, idx, fitem)) {
- ret = 0;
- break;
- }
- } else if (ret > 1000) {
- removefavoritepath (ret - 1001, idx, fitem);
- }
- }
- for (i = 0; i < idx; i++) {
- xfree (fitem[i].value);
- if (i != ret - 1)
- xfree (fitem[i].path);
- }
- if (ret == 0)
- return NULL;
- return fitem[ret - 1].path;
- }
- static TCHAR *favoritepopup (HWND hwnd)
- {
- return favoritepopup (hwnd, -1);
- }
- /* base Drag'n'Drop code borrowed from http://www.codeproject.com/listctrl/jianghong.asp */
- // NOTE (TW):
- // ListView_CreateDragImage has been broken at least since Windows Vista?
- static int bDragging = 0;
- static HIMAGELIST hDragImageList;
- static int DragHeight;
- static int drag_start (HWND hWnd, HWND hListView, LPARAM lParam)
- {
- POINT pt;
- int bFirst, iPos;
- POINT offset;
- offset.x = 0;
- offset.y = 0;
- pt = ((NM_LISTVIEW*)((LPNMHDR)lParam))->ptAction;
- ClientToScreen(hListView, &pt);
- // Ok, now we create a drag-image for all selected items
- bFirst = TRUE;
- iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
- while (iPos != -1) {
- if (bFirst) {
- int width, height;
- RECT rc2;
- GetClientRect(hListView, &rc2);
- if (!os_vista) {
- IMAGEINFO imf;
- POINT p;
- // For the first selected item,
- // we simply create a single-line drag image
- hDragImageList = ListView_CreateDragImage(hListView, iPos, &p);
- ImageList_GetImageInfo(hDragImageList, 0, &imf);
- width = imf.rcImage.right;
- height = imf.rcImage.bottom;
- } else {
- // ListView_CreateDragImage replacement hack follows..
- RECT rc;
- // Get Rectangle of selected ListView Item
- ListView_GetItemRect(hListView, iPos, &rc, LVIR_BOUNDS);
- if (rc.left < 0)
- rc.left = 0;
- if (rc.bottom < 0)
- rc.bottom = 0;
- width = rc.right - rc.left;
- height = rc.bottom - rc.top;
- if (width <= 0 || height <= 0)
- return 0;
- // Image becomes blank bar if visible part
- // is smaller than complete width of item.
- if (width > rc2.right - rc2.left)
- width = rc2.right - rc2.left;
- if (height > rc2.bottom - rc2.top)
- height = rc2.bottom - rc2.top;
- // Create HBITMAP of selected ListView Item
- HDC hDC = GetDC(hListView);
- if (hDC) {
- HDC hMemDC = CreateCompatibleDC(hDC);
- if (hMemDC) {
- HBITMAP hBMP = CreateCompatibleBitmap(hDC, width, height);
- if (hBMP) {
- HGDIOBJ o = SelectObject(hMemDC, hBMP);
- BitBlt(hMemDC, 0, 0, width, height, hDC, rc.left, rc.top, SRCCOPY);
- SelectObject(hMemDC, o);
- }
- // Create ImageList, add HBITMAP to ImageList.
- hDragImageList = ImageList_Create(width, height, ILC_COLOR24, 1, 1);
- if (hBMP && hDragImageList) {
- ImageList_Add(hDragImageList, hBMP, NULL);
- DeleteObject(hBMP);
- }
- DeleteDC(hMemDC);
- }
- ReleaseDC(hListView, hDC);
- }
- }
- offset.x = rc2.left;
- offset.y = rc2.top;
- ClientToScreen(hListView, &offset);
-
- offset.x = pt.x - offset.x;
- offset.y = height;
- DragHeight = height;
- bFirst = FALSE;
- } else {
- #if 0
- IMAGEINFO imf;
- HIMAGELIST hOneImageList, hTempImageList;
- // For the rest selected items,
- // we create a single-line drag image, then
- // append it to the bottom of the complete drag image
- hOneImageList = ListView_CreateDragImage(hListView, iPos, &p);
- hTempImageList = ImageList_Merge(hDragImageList, 0, hOneImageList, 0, 0, iHeight);
- ImageList_Destroy(hDragImageList);
- ImageList_Destroy(hOneImageList);
- hDragImageList = hTempImageList;
- ImageList_GetImageInfo(hDragImageList, 0, &imf);
- iHeight = imf.rcImage.bottom;
- #endif
- }
- iPos = ListView_GetNextItem(hListView, iPos, LVNI_SELECTED);
- }
- if (!hDragImageList)
- return 0;
- // Now we can initialize then start the drag action
- ImageList_BeginDrag(hDragImageList, 0, offset.x, offset.y);
- ImageList_DragEnter(NULL, pt.x, pt.y);
- bDragging = TRUE;
- // Don't forget to capture the mouse
- SetCapture (hWnd);
- return 1;
- }
- static int drag_end (HWND hWnd, HWND hListView, LPARAM lParam, int **draggeditems)
- {
- int iPos, cnt;
- LVHITTESTINFO lvhti;
- LVITEM lvi;
- *draggeditems = NULL;
- if (!bDragging)
- return -1;
- // End the drag-and-drop process
- bDragging = FALSE;
- ImageList_DragLeave(hListView);
- ImageList_EndDrag();
- ImageList_Destroy(hDragImageList);
- ReleaseCapture();
- // Determine the dropped item
- lvhti.pt.x = LOWORD(lParam);
- lvhti.pt.y = HIWORD(lParam);
- lvhti.pt.y -= DragHeight / 2;
- ClientToScreen(hWnd, &lvhti.pt);
- ScreenToClient(hListView, &lvhti.pt);
- ListView_HitTest(hListView, &lvhti);
- // Out of the ListView?
- if (lvhti.iItem == -1)
- return -1;
- // Not in an item?
- if ((lvhti.flags & LVHT_ONITEMLABEL) == 0 && (lvhti.flags & LVHT_ONITEMSTATEICON) == 0)
- return -1;
- // Dropped item is selected?
- lvi.iItem = lvhti.iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_STATE;
- lvi.stateMask = LVIS_SELECTED;
- ListView_GetItem(hListView, &lvi);
- if (lvi.state & LVIS_SELECTED)
- return -1;
- // Rearrange the items
- iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
- cnt = 0;
- while (iPos != -1) {
- iPos = ListView_GetNextItem(hListView, iPos, LVNI_SELECTED);
- cnt++;
- }
- if (cnt == 0)
- return -1;
- *draggeditems = xmalloc (int, cnt + 1);
- iPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
- cnt = 0;
- while (iPos != -1) {
- (*draggeditems)[cnt++] = iPos;
- iPos = ListView_GetNextItem(hListView, iPos, LVNI_SELECTED);
- }
- (*draggeditems)[cnt] = -1;
- return lvhti.iItem;
- }
- static int drag_move (HWND hWnd, LPARAM lParam)
- {
- POINT p;
- if (!bDragging)
- return 0;
- p.x = LOWORD(lParam);
- p.y = HIWORD(lParam);
- ClientToScreen(hWnd, &p);
- ImageList_DragMove(p.x, p.y);
- return 1;
- }
- static HWND cachedlist = NULL;
- static const TCHAR *memsize_names[] = {
- /* 0 */ _T("none"),
- /* 1 */ _T("64 KB"),
- /* 2 */ _T("128 KB"),
- /* 3 */ _T("256 KB"),
- /* 4 */ _T("512 KB"),
- /* 5 */ _T("1 MB"),
- /* 6 */ _T("2 MB"),
- /* 7 */ _T("4 MB"),
- /* 8 */ _T("8 MB"),
- /* 9 */ _T("16 MB"),
- /* 10*/ _T("32 MB"),
- /* 11*/ _T("64 MB"),
- /* 12*/ _T("128 MB"),
- /* 13*/ _T("256 MB"),
- /* 14*/ _T("512 MB"),
- /* 15*/ _T("1 GB"),
- /* 16*/ _T("1.5MB"),
- /* 17*/ _T("1.8MB"),
- /* 18*/ _T("2 GB"),
- /* 19*/ _T("384 MB"),
- /* 20*/ _T("768 MB"),
- /* 21*/ _T("1.5 GB"),
- /* 22*/ _T("2.5 GB"),
- /* 23*/ _T("3 GB")
- };
- static const unsigned long memsizes[] = {
- /* 0 */ 0,
- /* 1 */ 0x00010000, /* 64K */
- /* 2 */ 0x00020000, /* 128K */
- /* 3 */ 0x00040000, /* 256K */
- /* 4 */ 0x00080000, /* 512K */
- /* 5 */ 0x00100000, /* 1M */
- /* 6 */ 0x00200000, /* 2M */
- /* 7 */ 0x00400000, /* 4M */
- /* 8 */ 0x00800000, /* 8M */
- /* 9 */ 0x01000000, /* 16M */
- /* 10*/ 0x02000000, /* 32M */
- /* 11*/ 0x04000000, /* 64M */
- /* 12*/ 0x08000000, //128M
- /* 13*/ 0x10000000, //256M
- /* 14*/ 0x20000000, //512M
- /* 15*/ 0x40000000, //1GB
- /* 16*/ 0x00180000, //1.5MB
- /* 17*/ 0x001C0000, //1.8MB
- /* 18*/ 0x80000000, //2GB
- /* 19*/ 0x18000000, //384M
- /* 20*/ 0x30000000, //768M
- /* 21*/ 0x60000000, //1.5GB
- /* 22*/ 0xA8000000, //2.5GB
- /* 23*/ 0xC0000000, //3GB
- };
- static const int msi_chip[] = { 3, 4, 5, 16, 6, 7, 8 };
- static const int msi_bogo[] = { 0, 4, 5, 16, 17 };
- static const int msi_fast[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- static const int msi_z3fast[] = { 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- static const int msi_z3chip[] = { 0, 9, 10, 11, 12, 13, 19, 14, 20, 15 };
- static const int msi_gfx[] = { 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- static const int msi_cpuboard[] = { 0, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
- static const int msi_mb[] = { 0, 5, 6, 7, 8, 9, 10, 11, 12 };
- #define MIN_CHIP_MEM 0
- #define MAX_CHIP_MEM 6
- #define MIN_FAST_MEM 0
- #define MAX_FAST_MEM 8
- #define MIN_SLOW_MEM 0
- #define MAX_SLOW_MEM 4
- #define MIN_Z3_MEM 0
- #define MAX_Z3_MEM 11
- #define MAX_Z3_CHIPMEM 9
- #define MIN_P96_MEM 0
- #define MAX_P96_MEM_Z3 ((max_z3fastmem >> 20) < 512 ? 8 : ((max_z3fastmem >> 20) < 1024 ? 9 : ((max_z3fastmem >> 20) < 2048) ? 10 : 11))
- #define MAX_P96_MEM_Z2 4
- #define MIN_MB_MEM 0
- #define MAX_MBL_MEM 7
- #define MAX_MBH_MEM 8
- #define MIN_CB_MEM 0
- #define MAX_CB_MEM_Z2 4
- #define MAX_CB_MEM_16M 5
- #define MAX_CB_MEM_32M 6
- #define MAX_CB_MEM_64M 7
- #define MAX_CB_MEM_128M 8
- #define MAX_CB_MEM_256M 9
- #define MIN_M68K_PRIORITY 1
- #define MAX_M68K_PRIORITY 16
- #define MIN_CACHE_SIZE 0
- #define MAX_CACHE_SIZE 5
- #define MIN_REFRESH_RATE 1
- #define MAX_REFRESH_RATE 10
- #define MIN_SOUND_MEM 0
- #define MAX_SOUND_MEM 10
- struct romscandata {
- UAEREG *fkey;
- int got;
- };
- static struct romdata *scan_single_rom_2 (struct zfile *f)
- {
- uae_u8 buffer[20] = { 0 };
- uae_u8 *rombuf;
- int cl = 0, size;
- struct romdata *rd = 0;
- zfile_fseek (f, 0, SEEK_END);
- size = zfile_ftell (f);
- zfile_fseek (f, 0, SEEK_SET);
- if (size > 524288 * 2) {/* don't skip KICK disks or 1M ROMs */
- write_log (_T("'%s': too big %d, ignored\n"), zfile_getname(f), size);
- return 0;
- }
- zfile_fread (buffer, 1, 11, f);
- if (!memcmp (buffer, "KICK", 4)) {
- zfile_fseek (f, 512, SEEK_SET);
- if (size > 262144)
- size = 262144;
- } else if (!memcmp (buffer, "AMIROMTYPE1", 11)) {
- cl = 1;
- size -= 11;
- } else {
- zfile_fseek (f, 0, SEEK_SET);
- }
- rombuf = xcalloc (uae_u8, size);
- if (!rombuf)
- return 0;
- zfile_fread (rombuf, 1, size, f);
- if (cl > 0) {
- decode_cloanto_rom_do (rombuf, size, size);
- cl = 0;
- }
- if (!cl) {
- rd = getromdatabydata (rombuf, size);
- if (!rd && (size & 65535) == 0) {
- /* check byteswap */
- int i;
- for (i = 0; i < size; i+=2) {
- uae_u8 b = rombuf[i];
- rombuf[i] = rombuf[i + 1];
- rombuf[i + 1] = b;
- }
- rd = getromdatabydata (rombuf, size);
- }
- }
- if (!rd) {
- const TCHAR *name = my_getfilepart(zfile_getname(f));
- rd = getfrombydefaultname(name, size);
- }
- if (!rd) {
- write_log (_T("!: Name='%s':%d\nCRC32=%08X SHA1=%s\n"),
- zfile_getname (f), size, get_crc32 (rombuf, size), get_sha1_txt (rombuf, size));
- } else {
- TCHAR tmp[MAX_DPATH];
- getromname (rd, tmp);
- write_log (_T("*: %s:%d = %s\nCRC32=%08X SHA1=%s\n"),
- zfile_getname (f), size, tmp, get_crc32 (rombuf, size), get_sha1_txt (rombuf, size));
- }
- xfree (rombuf);
- return rd;
- }
- static struct romdata *scan_single_rom (const TCHAR *path)
- {
- struct zfile *z;
- TCHAR tmp[MAX_DPATH];
- struct romdata *rd;
- _tcscpy (tmp, path);
- rd = scan_arcadia_rom (tmp, 0);
- if (rd)
- return rd;
- rd = getromdatabypath (path);
- if (rd && rd->crc32 == 0xffffffff)
- return rd;
- z = zfile_fopen (path, _T("rb"), ZFD_NORMAL);
- if (!z)
- return 0;
- return scan_single_rom_2 (z);
- }
- static void abspathtorelative (TCHAR *name)
- {
- if (!_tcsncmp (start_path_exe, name, _tcslen (start_path_exe)))
- memmove (name, name + _tcslen (start_path_exe), (_tcslen (name) - _tcslen (start_path_exe) + 1) * sizeof (TCHAR));
- }
- static int extpri(const TCHAR *p, int size)
- {
- const TCHAR *s = _tcsrchr(p, '.');
- if (s == NULL)
- return 80;
- // if archive: lowest priority
- if (!my_existsfile(p))
- return 100;
- int pri = 10;
- // prefer matching size
- struct mystat ms;
- if (my_stat(p, &ms)) {
- if (ms.size == size) {
- pri--;
- }
- }
- return pri;
- }
- static int addrom (UAEREG *fkey, struct romdata *rd, const TCHAR *name)
- {
- TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH], tmp3[MAX_DPATH];
- TCHAR pathname[MAX_DPATH];
- _stprintf (tmp1, _T("ROM_%03d"), rd->id);
- if (rd->group) {
- TCHAR *p = tmp1 + _tcslen (tmp1);
- _stprintf (p, _T("_%02d_%02d"), rd->group >> 16, rd->group & 65535);
- }
- getromname (rd, tmp2);
- pathname[0] = 0;
- if (name) {
- _tcscpy (pathname, name);
- if (getregmode ())
- abspathtorelative (pathname);
- }
- if (rd->crc32 == 0xffffffff) {
- if (rd->configname)
- _stprintf (tmp2, _T(":%s"), rd->configname);
- else
- _stprintf (tmp2, _T(":ROM_%03d"), rd->id);
- }
- int size = sizeof tmp3 / sizeof(TCHAR);
- if (regquerystr(fkey, tmp1, tmp3, &size)) {
- TCHAR *s = _tcschr(tmp3, '\"');
- if (s && _tcslen(s) > 1) {
- TCHAR *s2 = s + 1;
- s = _tcschr(s2, '\"');
- if (s)
- *s = 0;
- int pri1 = extpri(s2, rd->size);
- int pri2 = extpri(pathname, rd->size);
- if (pri2 >= pri1)
- return 1;
- }
- }
- if (pathname[0]) {
- _tcscat(tmp2, _T(" / \""));
- _tcscat(tmp2, pathname);
- _tcscat(tmp2, _T("\""));
- }
- if (!regsetstr (fkey, tmp1, tmp2))
- return 0;
- return 1;
- }
- static int isromext (const TCHAR *path, bool deepscan)
- {
- const TCHAR *ext;
- int i;
- if (!path)
- return 0;
- ext = _tcsrchr (path, '.');
- if (!ext)
- return 0;
- ext++;
- if (!_tcsicmp (ext, _T("rom")) || !_tcsicmp (ext, _T("bin")) || !_tcsicmp (ext, _T("adf")) || !_tcsicmp (ext, _T("key"))
- || !_tcsicmp (ext, _T("a500")) || !_tcsicmp (ext, _T("a1200")) || !_tcsicmp (ext, _T("a4000")) || !_tcsicmp (ext, _T("cd32")))
- return 1;
- if (_tcslen (ext) >= 2 && toupper(ext[0]) == 'U' && isdigit (ext[1]))
- return 1;
- if (!deepscan)
- return 0;
- for (i = 0; uae_archive_extensions[i]; i++) {
- if (!_tcsicmp (ext, uae_archive_extensions[i]))
- return 1;
- }
- return 0;
- }
- static bool infoboxdialogstate;
- static HWND infoboxhwnd;
- static INT_PTR CALLBACK InfoBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- if (dialog_inhibit)
- return 0;
- switch(msg)
- {
- case WM_DESTROY:
- PostQuitMessage (0);
- infoboxdialogstate = false;
- return TRUE;
- case WM_CLOSE:
- DestroyWindow (hDlg);
- infoboxdialogstate = false;
- return TRUE;
- case WM_INITDIALOG:
- {
- HWND owner = GetParent (hDlg);
- if (!owner) {
- owner = GetDesktopWindow ();
- RECT ownerrc, merc;
- GetWindowRect (owner, &ownerrc);
- GetWindowRect (hDlg, &merc);
- SetWindowPos (hDlg, NULL,
- ownerrc.left + ((ownerrc.right - ownerrc.left) - (merc.right - merc.left)) /2,
- ownerrc.top + ((ownerrc.bottom - ownerrc.top) - (merc.bottom - merc.top)) / 2,
- 0, 0,
- SWP_NOSIZE);
- }
- return TRUE;
- }
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDCANCEL:
- infoboxdialogstate = false;
- DestroyWindow (hDlg);
- return TRUE;
- }
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static bool scan_rom_hook (const TCHAR *name, int line)
- {
- MSG msg;
- if (!infoboxhwnd)
- return true;
- if (name != NULL) {
- const TCHAR *s = NULL;
- if (line == 2) {
- s = _tcsrchr (name, '/');
- if (!s)
- s = _tcsrchr (name, '\\');
- if (s)
- s++;
- }
- SetWindowText (GetDlgItem (infoboxhwnd, line == 1 ? IDC_INFOBOX_TEXT1 : (line == 2 ? IDC_INFOBOX_TEXT2 : IDC_INFOBOX_TEXT3)), s ? s : name);
- }
- while (PeekMessage (&msg, infoboxhwnd, 0, 0, PM_REMOVE)) {
- if (!IsDialogMessage (infoboxhwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- }
- return infoboxdialogstate;
- }
- static int scan_rom_2 (struct zfile *f, void *vrsd)
- {
- struct romscandata *rsd = (struct romscandata*)vrsd;
- const TCHAR *path = zfile_getname(f);
- const TCHAR *romkey = _T("rom.key");
- struct romdata *rd;
- scan_rom_hook (NULL, 0);
- if (!isromext (path, true))
- return 0;
- rd = scan_single_rom_2 (f);
- if (rd) {
- TCHAR name[MAX_DPATH];
- getromname (rd, name);
- scan_rom_hook (name, 3);
- addrom (rsd->fkey, rd, path);
- if (rd->type & ROMTYPE_KEY)
- addkeyfile (path);
- rsd->got = 1;
- } else if (_tcslen (path) > _tcslen (romkey) && !_tcsicmp (path + _tcslen (path) - _tcslen (romkey), romkey)) {
- addkeyfile (path);
- }
- return 0;
- }
- static int scan_rom (const TCHAR *path, UAEREG *fkey, bool deepscan)
- {
- struct romscandata rsd = { fkey, 0 };
- struct romdata *rd;
- int cnt = 0;
- if (!isromext (path, deepscan)) {
- //write_log("ROMSCAN: skipping file '%s', unknown extension\n", path);
- return 0;
- }
- scan_rom_hook (path, 2);
- for (;;) {
- TCHAR tmp[MAX_DPATH];
- _tcscpy (tmp, path);
- rd = scan_arcadia_rom (tmp, cnt++);
- if (rd) {
- if (!addrom (fkey, rd, tmp))
- return 1;
- continue;
- }
- break;
- }
- zfile_zopen (path, scan_rom_2, (void*)&rsd);
- return rsd.got;
- }
- static int listrom (const int *roms)
- {
- int i;
- i = 0;
- while (roms[i] >= 0) {
- struct romdata *rd = getromdatabyid (roms[i]);
- if (rd && romlist_get (rd))
- return 1;
- i++;
- }
- return 0;
- }
- static void show_rom_list (void)
- {
- TCHAR *p;
- TCHAR *p1, *p2;
- const int *rp;
- bool first = true;
- const int romtable[] = {
- 5, 4, -1, -1, // A500 1.2
- 6, 32, -1, -1, // A500 1.3
- 7, -1, -1, // A500+
- 8, 9, 10, -1, -1, // A600
- 23, 24, -1, -1, // A1000
- 11, 31, 15, -1, -1, // A1200
- 59, 71, 61, -1, -1, // A3000
- 16, 46, 31, 13, 12, -1, -1, // A4000
- 17, -1, -1, // A4000T
- 18, -1, 19, -1, -1, // CD32
- 20, 21, 22, -1, 6, 32, -1, -1, // CDTV
- 9, 10, -1, 107, 108, -1, -1, // CDTV-CR
- 49, 50, 75, 51, 76, 77, -1, 5, 4, -1, -2, // ARCADIA
- 18, -1, 19, -1, 74, 23, -1, -1, // CD32 FMV
- 69, 67, 70, 115, -1, -1, // nordic power
- 65, 68, -1, -1, // x-power
- 62, 60, -1, -1, // action cartridge
- 116, -1, -1, // pro access
- 52, 25, -1, -1, // ar 1
- 26, 27, 28, -1, -1, // ar 2
- 29, 30, -1, -1, // ar 3
- 47, -1, -1, // action replay 1200
- 0, 0, 0
- };
- p1 = _T("A500 Boot ROM 1.2\0A500 Boot ROM 1.3\0A500+\0A600\0A1000\0A1200\0A3000\0A4000\0A4000T\0")
- _T("CD32\0CDTV\0CDTV-CR\0Arcadia Multi Select\0")
- _T("CD32 Full Motion Video\0")
- _T("Nordic Power\0X-Power Professional 500\0Action Cartridge Super IV Professional\0")
- _T("Pro Access\0")
- _T("Action Replay MK I\0Action Replay MK II\0Action Replay MK III\0")
- _T("Action Replay 1200\0")
- _T("\0");
- p = xmalloc (TCHAR, 100000);
- if (!p)
- return;
- WIN32GUI_LoadUIString (IDS_ROMSCANEND, p, 100);
- _tcscat (p, _T("\n\n"));
- rp = romtable;
- while(rp[0]) {
- int ok = 1;
- p2 = p1 + _tcslen (p1) + 1;
- while (*rp >= 0) {
- if (ok) {
- ok = 0;
- if (listrom (rp))
- ok = 1;
- }
- while(*rp++ >= 0);
- }
- if (ok) {
- if (!first)
- _tcscat (p, _T(", "));
- first = false;
- _tcscat (p, p1);
- }
- if (*rp == -2) {
- _tcscat(p, _T("\n\n"));
- first = true;
- }
- rp++;
- p1 = p2;
- }
- pre_gui_message (p);
- free (p);
- }
- static int scan_roms_2 (UAEREG *fkey, const TCHAR *path, bool deepscan, int level)
- {
- TCHAR buf[MAX_DPATH];
- WIN32_FIND_DATA find_data;
- HANDLE handle;
- int ret;
- if (!path)
- return 0;
- write_log (_T("ROM scan directory '%s'\n"), path);
- _tcscpy (buf, path);
- _tcscat (buf, _T("*.*"));
- ret = 0;
- handle = FindFirstFile (buf, &find_data);
- if (handle == INVALID_HANDLE_VALUE)
- return 0;
- scan_rom_hook (path, 1);
- for (;;) {
- TCHAR tmppath[MAX_DPATH];
- _tcscpy (tmppath, path);
- _tcscat (tmppath, find_data.cFileName);
- if (!(find_data.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY |FILE_ATTRIBUTE_SYSTEM)) && find_data.nFileSizeLow < 10000000) {
- if (scan_rom (tmppath, fkey, deepscan))
- ret = 1;
- } else if (deepscan && (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- if (recursiveromscan < 0 || recursiveromscan > level) {
- if (find_data.cFileName[0] != '.') {
- _tcscat(tmppath, _T("\\"));
- scan_roms_2(fkey, tmppath, deepscan, level + 1);
- }
- }
- }
- if (!scan_rom_hook (NULL, 0) || FindNextFile (handle, &find_data) == 0) {
- FindClose (handle);
- break;
- }
- }
- return ret;
- }
- #define MAX_ROM_PATHS 10
- static int scan_roms_3 (UAEREG *fkey, TCHAR **paths, const TCHAR *path)
- {
- int i, ret;
- TCHAR pathp[MAX_DPATH];
- bool deepscan = true;
- ret = 0;
- scan_rom_hook (NULL, 0);
- pathp[0] = 0;
- GetFullPathName (path, MAX_DPATH, pathp, NULL);
- if (!pathp[0])
- return ret;
- if (_tcsicmp (pathp, start_path_exe) == 0)
- deepscan = false; // do not scan root dir archives
- for (i = 0; i < MAX_ROM_PATHS; i++) {
- if (paths[i] && !_tcsicmp (paths[i], pathp))
- return ret;
- }
- ret = scan_roms_2 (fkey, pathp, deepscan, 0);
- for (i = 0; i < MAX_ROM_PATHS; i++) {
- if (!paths[i]) {
- paths[i] = my_strdup(pathp);
- break;
- }
- }
- return ret;
- }
- extern int get_rom_path (TCHAR *out, pathtype mode);
- int scan_roms (HWND hDlg, int show)
- {
- TCHAR path[MAX_DPATH];
- static int recursive;
- int id, i, ret, keys, cnt;
- UAEREG *fkey, *fkey2;
- TCHAR *paths[MAX_ROM_PATHS];
- MSG msg;
- if (recursive)
- return 0;
- recursive++;
- ret = 0;
- regdeletetree (NULL, _T("DetectedROMs"));
- fkey = regcreatetree (NULL, _T("DetectedROMs"));
- if (fkey == NULL)
- goto end;
- infoboxdialogstate = true;
- infoboxhwnd = NULL;
- if (!rp_isactive ()) {
- HWND hwnd = CreateDialog (hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDD_INFOBOX), hDlg, InfoBoxDialogProc);
- if (!hwnd)
- goto end;
- infoboxhwnd = hwnd;
- }
- cnt = 0;
- for (i = 0; i < MAX_ROM_PATHS; i++)
- paths[i] = NULL;
- scan_rom_hook (NULL, 0);
- while (scan_rom_hook (NULL, 0)) {
- keys = get_keyring ();
- fetch_path (_T("KickstartPath"), path, sizeof path / sizeof (TCHAR));
- cnt += scan_roms_3 (fkey, paths, path);
- if (1) {
- static pathtype pt[] = { PATH_TYPE_DEFAULT, PATH_TYPE_WINUAE, PATH_TYPE_NEWWINUAE, PATH_TYPE_NEWAF, PATH_TYPE_AMIGAFOREVERDATA, PATH_TYPE_END };
- for (i = 0; pt[i] != PATH_TYPE_END; i++) {
- ret = get_rom_path (path, pt[i]);
- if (ret < 0)
- break;
- cnt += scan_roms_3 (fkey, paths, path);
- }
- if (get_keyring() > keys) { /* more keys detected in previous scan? */
- write_log (_T("ROM scan: more keys found, restarting..\n"));
- for (i = 0; i < MAX_ROM_PATHS; i++) {
- xfree (paths[i]);
- paths[i] = NULL;
- }
- continue;
- }
- }
- break;
- }
- if (cnt == 0)
- scan_roms_3 (fkey, paths, workprefs.path_rom.path[0]);
- for (i = 0; i < MAX_ROM_PATHS; i++)
- xfree (paths[i]);
- fkey2 = regcreatetree (NULL, _T("DetectedROMS"));
- if (fkey2) {
- id = 1;
- for (;;) {
- struct romdata *rd = getromdatabyid (id);
- if (!rd)
- break;
- if (rd->crc32 == 0xffffffff)
- addrom (fkey, rd, NULL);
- id++;
- }
- regclosetree (fkey2);
- }
- end:
- if (infoboxhwnd) {
- HWND hwnd = infoboxhwnd;
- infoboxhwnd = NULL;
- DestroyWindow (hwnd);
- while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- }
- read_rom_list ();
- if (show)
- show_rom_list ();
- regclosetree (fkey);
- recursive--;
- return ret;
- }
- static void box_art_check(struct uae_prefs *p, const TCHAR *config)
- {
- TCHAR tmp1[MAX_DPATH];
- if (cfgfile_detect_art(p, tmp1)) {
- show_box_art(tmp1, config);
- } else {
- show_box_art(NULL, NULL);
- }
- }
- struct ConfigStruct {
- TCHAR Name[MAX_DPATH];
- TCHAR Path[MAX_DPATH];
- TCHAR Fullpath[MAX_DPATH];
- TCHAR HostLink[MAX_DPATH];
- TCHAR HardwareLink[MAX_DPATH];
- TCHAR Description[CFG_DESCRIPTION_LENGTH];
- TCHAR Artpath[MAX_DPATH];
- TCHAR Category[CFG_DESCRIPTION_LENGTH];
- TCHAR Tags[CFG_DESCRIPTION_LENGTH];
- int Type, Directory;
- struct ConfigStruct *Parent, *Child;
- int host, hardware;
- HTREEITEM item;
- FILETIME t;
- };
- struct CategoryStruct
- {
- TCHAR category[CFG_DESCRIPTION_LENGTH];
- };
- static const TCHAR *configreg[] = { _T("ConfigFile"), _T("ConfigFileHardware"), _T("ConfigFileHost") };
- static const TCHAR *configregfolder[] = { _T("ConfigFileFolder"), _T("ConfigFileHardwareFolder"), _T("ConfigFileHostFolder") };
- static const TCHAR *configregsearch[] = { _T("ConfigFileSearch"), _T("ConfigFileHardwareSearch"), _T("ConfigFileHostSearch") };
- static const TCHAR *configreg2[] = { _T(""), _T("ConfigFileHardware_Auto"), _T("ConfigFileHost_Auto") };
- static struct ConfigStruct **configstore;
- static int configstoresize, configstoreallocated, configtype, configtypepanel;
- static struct CategoryStruct **categorystore;
- static int categorystoresize, categorystoreallocated;
- static struct ConfigStruct *getconfigstorefrompath (TCHAR *path, TCHAR *out, int type)
- {
- int i;
- for (i = 0; i < configstoresize; i++) {
- if (((configstore[i]->Type == 0 || configstore[i]->Type == 3) && type == 0) || (configstore[i]->Type == type)) {
- TCHAR path2[MAX_DPATH];
- _tcscpy (path2, configstore[i]->Path);
- _tcsncat (path2, configstore[i]->Name, MAX_DPATH - _tcslen(path2));
- if (!_tcscmp (path, path2)) {
- _tcscpy (out, configstore[i]->Fullpath);
- _tcsncat (out, configstore[i]->Name, MAX_DPATH - _tcslen(out));
- return configstore[i];
- }
- }
- }
- return 0;
- }
- void target_multipath_modified(struct uae_prefs *p)
- {
- if (p != &workprefs)
- return;
- memcpy(&currprefs.path_hardfile, &p->path_hardfile, sizeof(struct multipath));
- memcpy(&currprefs.path_floppy, &p->path_floppy, sizeof(struct multipath));
- memcpy(&currprefs.path_cd, &p->path_cd, sizeof(struct multipath));
- memcpy(&currprefs.path_rom, &p->path_rom, sizeof(struct multipath));
- }
- static bool cfgfile_can_write(HWND hDlg, const TCHAR *path)
- {
- for (;;) {
- int v = my_readonlyfile(path);
- if (v <= 0)
- return true;
- TCHAR szMessage[MAX_DPATH], msg[MAX_DPATH], szTitle[MAX_DPATH];
- WIN32GUI_LoadUIString(IDS_READONLYCONFIRMATION, szMessage, MAX_DPATH);
- _stprintf(msg, szMessage, path);
- WIN32GUI_LoadUIString(IDS_ERRORTITLE, szTitle, MAX_DPATH);
- if (MessageBox(hDlg, msg, szTitle, MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
- DWORD flags = GetFileAttributesSafe(path);
- if (!(flags & FILE_ATTRIBUTE_READONLY)) {
- return true;
- }
- flags &= ~FILE_ATTRIBUTE_READONLY;
- SetFileAttributesSafe(path, flags);
- continue;
- }
- break;
- }
- return false;
- }
- int target_cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int type, int isdefault)
- {
- int v, i, type2;
- int ct, ct2, size;
- TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
- TCHAR fname[MAX_DPATH], cname[MAX_DPATH];
- error_log(NULL);
- _tcscpy (fname, filename);
- cname[0] = 0;
- if (!zfile_exists (fname)) {
- fetch_configurationpath (fname, sizeof (fname) / sizeof (TCHAR));
- if (_tcsncmp (fname, filename, _tcslen (fname)))
- _tcscat (fname, filename);
- else
- _tcscpy (fname, filename);
- }
- if (!isdefault)
- qs_override = 1;
- if (type < 0) {
- type = 0;
- cfgfile_get_description(NULL, fname, NULL, NULL, NULL, NULL, NULL, &type);
- if (!isdefault) {
- const TCHAR *p = _tcsrchr(fname, '\\');
- if (!p)
- p = _tcsrchr(fname, '/');
- if (p)
- _tcscpy(cname, p + 1);
- }
- }
- if (type == 0 || type == 1) {
- discard_prefs (p, 0);
- }
- type2 = type;
- if (type == 0 || type == 3) {
- default_prefs (p, true, type);
- write_log(_T("config reset\n"));
- #if 0
- if (isdefault == 0) {
- fetch_configurationpath (tmp1, sizeof (tmp1) / sizeof (TCHAR));
- _tcscat (tmp1, OPTIONSFILENAME);
- cfgfile_load (p, tmp1, NULL, 0, 0);
- }
- #endif
- }
- ct2 = 0;
- regqueryint (NULL, _T("ConfigFile_NoAuto"), &ct2);
- v = cfgfile_load (p, fname, &type2, ct2, isdefault ? 0 : 1);
- if (!v)
- return v;
- if (type > 0)
- return v;
- if (cname[0])
- _tcscpy(config_filename, cname);
- box_art_check(p, fname);
- for (i = 1; i <= 2; i++) {
- if (type != i) {
- size = sizeof (ct);
- ct = 0;
- regqueryint (NULL, configreg2[i], &ct);
- if (ct && ((i == 1 && p->config_hardware_path[0] == 0) || (i == 2 && p->config_host_path[0] == 0) || ct2)) {
- size = sizeof (tmp1) / sizeof (TCHAR);
- regquerystr (NULL, configreg[i], tmp1, &size);
- fetch_path (_T("ConfigurationPath"), tmp2, sizeof (tmp2) / sizeof (TCHAR));
- _tcscat (tmp2, tmp1);
- v = i;
- cfgfile_load (p, tmp2, &v, 1, 0);
- }
- }
- }
- cfgfile_get_shader_config(p, 0);
- v = 1;
- return v;
- }
- static int gui_width, gui_height;
- int gui_fullscreen;
- static RECT gui_fullscreen_rect;
- static bool gui_resize_enabled;
- static bool gui_resize_allowed;
- // Internal panel max size: 396, 318
- static int mm = 0;
- static void m(int monid)
- {
- struct monconfig *gmw = &workprefs.gfx_monitor[monid];
- struct monconfig *gmc = &currprefs.gfx_monitor[monid];
- struct monconfig *gmh = &changed_prefs.gfx_monitor[monid];
- write_log (_T("%d:0: %dx%d %dx%d %dx%d\n"), mm, gmc->gfx_size.width, gmc->gfx_size.height,
- gmw->gfx_size.width, gmw->gfx_size.height, gmh->gfx_size.width, gmh->gfx_size.height);
- write_log (_T("%d:1: %dx%d %dx%d %dx%d\n"), mm, gmc->gfx_size_fs.width, gmc->gfx_size_fs.height,
- gmw->gfx_size_fs.width, gmw->gfx_size_fs.height, gmh->gfx_size_fs.width, gmh->gfx_size_fs.height);
- mm++;
- }
- static void flipgui(int opengui)
- {
- D3D_guimode(0, opengui);
- if (full_property_sheet)
- return;
- if (opengui) {
- DirectDraw_FlipToGDISurface();
- } else {
- if (quit_program)
- return;
- full_redraw_all();
- }
- }
- static int GetSettings (int all_options, HWND hwnd);
- /* if drive is -1, show the full GUI, otherwise file-requester for DF[drive] */
- void gui_display (int shortcut)
- {
- struct AmigaMonitor *mon = &AMonitors[0];
- struct picasso96_state_struct *state = &picasso96_state[0];
- struct monconfig *gm = &currprefs.gfx_monitor[0];
- static int here;
- int w, h;
- if (here)
- return;
- here++;
- gui_active++;
- if (isfullscreen() > 0 && currprefs.gfx_api != 1)
- screenshot_prepare(getfocusedmonitor());
- flipgui(1);
- if (setpaused (7)) {
- inputdevice_unacquire ();
- wait_keyrelease();
- clearallkeys ();
- setmouseactive(0, 0);
- }
- w = h = -1;
- if (!WIN32GFX_IsPicassoScreen(mon) && currprefs.gfx_apmode[0].gfx_fullscreen && (gm->gfx_size.width < gui_width || gm->gfx_size.height < gui_height)) {
- w = gm->gfx_size.width;
- h = gm->gfx_size.height;
- }
- if (WIN32GFX_IsPicassoScreen(mon) && currprefs.gfx_apmode[1].gfx_fullscreen && (state->Width < gui_width || state->Height < gui_height)) {
- w = gm->gfx_size.width;
- h = gm->gfx_size.height;
- }
- mon->manual_painting_needed++; /* So that WM_PAINT will refresh the display */
- flush_log ();
- if (shortcut == -1) {
- int ret;
- ret = GetSettings(0, mon->hAmigaWnd);
- if (!ret) {
- savestate_state = 0;
- }
- } else if (shortcut >= 0 && shortcut < 4) {
- DiskSelection(mon->hAmigaWnd, IDC_DF0 + shortcut, 0, &changed_prefs, NULL, NULL);
- } else if (shortcut == 5) {
- if (DiskSelection(mon->hAmigaWnd, IDC_DOSAVESTATE, 9, &changed_prefs, NULL, NULL))
- save_state (savestate_fname, _T("Description!"));
- } else if (shortcut == 4) {
- if (DiskSelection(mon->hAmigaWnd, IDC_DOLOADSTATE, 10, &changed_prefs, NULL, NULL))
- savestate_state = STATE_DORESTORE;
- } else if (shortcut == 6) {
- DiskSelection(mon->hAmigaWnd, IDC_CD_SELECT, 17, &changed_prefs, NULL, NULL);
- }
- mon->manual_painting_needed--; /* So that WM_PAINT doesn't need to use custom refreshing */
- reset_sound ();
- inputdevice_copyconfig (&changed_prefs, &currprefs);
- inputdevice_config_change_test ();
- clearallkeys ();
- flipgui(0);
- if (resumepaused (7)) {
- inputdevice_acquire (TRUE);
- setmouseactive(0, 1);
- }
- fpscounter_reset ();
- screenshot_free ();
- write_disk_history ();
- gui_active--;
- here--;
- }
- static void prefs_to_gui(struct uae_prefs *p)
- {
- int st = savestate_state;
- default_prefs(&workprefs, false, 0);
- copy_prefs(p, &workprefs);
- /* filesys hack */
- workprefs.mountitems = currprefs.mountitems;
- memcpy (&workprefs.mountconfig, &currprefs.mountconfig, MOUNT_CONFIG_SIZE * sizeof (struct uaedev_config_info));
- updatewinfsmode(0, &workprefs);
- if (workprefs.statefile[0])
- savestate_state = st;
- }
- static void gui_to_prefs(void)
- {
- // Always copy our prefs to changed_prefs
- copy_prefs(&workprefs, &changed_prefs);
- if (quit_program == -UAE_RESET_HARD) {
- // copy all if hard reset
- copy_prefs(&workprefs, &currprefs);
- memory_hardreset(2);
- }
- // filesys hack
- currprefs.mountitems = changed_prefs.mountitems;
- memcpy (&currprefs.mountconfig, &changed_prefs.mountconfig, MOUNT_CONFIG_SIZE * sizeof (struct uaedev_config_info));
- fixup_prefs (&changed_prefs, true);
- updatewinfsmode(0, &changed_prefs);
- }
- static int iscd (int n)
- {
- if (quickstart_cd && n == 1 && currentpage == QUICKSTART_ID)
- return 1;
- return 0;
- }
- static const GUID diskselectionguids[] = {
- { 0x4fa8fa15, 0xc209, 0x4112, { 0x94, 0x7b, 0xc6, 0x00, 0x8e, 0x1f, 0xa3, 0x29 } },
- { 0x32073f09, 0x752d, 0x4783, { 0x84, 0x6c, 0xaa, 0x66, 0x48, 0x84, 0x14, 0x45 } },
- { 0x8047f7ea, 0x8a42, 0x4695, { 0x94, 0x52, 0xf5, 0x0d, 0xb8, 0x43, 0x00, 0x58 } },
- { 0x2412c4e7, 0xf608, 0x4333, { 0x83, 0xd2, 0xa1, 0x2f, 0xdf, 0x66, 0xac, 0xe5 } },
- { 0xe3741dff, 0x11f2, 0x445f, { 0x94, 0xb0, 0xa3, 0xe7, 0x58, 0xe2, 0xcb, 0xb5 } },
- { 0x2056d641, 0xba13, 0x4312, { 0xaa, 0x75, 0xc5, 0xeb, 0x52, 0xa8, 0x1c, 0xe3 } },
- { 0x05aa5db2, 0x470b, 0x4725, { 0x96, 0x03, 0xee, 0x61, 0x30, 0xfc, 0x54, 0x99 } },
- { 0x68366188, 0xa6d4, 0x4278, { 0xb7, 0x55, 0x6a, 0xb8, 0x17, 0xa6, 0x71, 0xd9 } },
- { 0xe990bee1, 0xd7cc, 0x4768, { 0xaf, 0x34, 0xef, 0x39, 0x87, 0x48, 0x09, 0x50 } },
- { 0x12c53317, 0xd99c, 0x4494, { 0x8d, 0x81, 0x00, 0x6d, 0x8c, 0x62, 0x7d, 0x83 } }
- };
- static void getfilter (int num, const TCHAR *name, int *filter, TCHAR *fname)
- {
- _tcscpy (fname, name);
- _tcscat (fname, _T("_Filter"));
- regqueryint (NULL, fname, &filter[num]);
- }
- static void setfilter (int num, int *filter, const TCHAR *fname)
- {
- if (fname == NULL || fname[0] == 0)
- return;
- regsetint (NULL, fname, filter[num]);
- }
- static UINT_PTR CALLBACK ofnhook (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- struct AmigaMonitor *mon = &AMonitors[0];
- HWND hWnd;
- RECT windowRect;
- int width, height, w2, h2, x, y;
- struct MultiDisplay *md;
- NMHDR *nmhdr;
- if (message == WM_NOTIFY) {
- nmhdr = (LPNMHDR)lParam;
- if (nmhdr->code == CDN_INITDONE) {
- write_log (_T("OFNHOOK CDN_INITDONE\n"));
- PostMessage (hDlg, WM_USER + 1, 0, 0);
- // OFN_ENABLESIZING enabled: SetWindowPos() only works once here...
- }
- return FALSE;
- } else if (message != WM_USER + 1) {
- return FALSE;
- }
- write_log (_T("OFNHOOK POST\n"));
- hWnd = GetParent (hDlg);
- md = getdisplay(&currprefs, mon->monitor_id);
- if (!md)
- return FALSE;
- w2 = WIN32GFX_GetWidth(mon);
- h2 = WIN32GFX_GetHeight(mon);
- write_log (_T("MOVEWINDOW %dx%d %dx%d (%dx%d)\n"), md->rect.left, md->rect.top, md->rect.right, md->rect.bottom, w2, h2);
- windowRect.left = windowRect.right = windowRect.top = windowRect.bottom = -1;
- GetWindowRect (hWnd, &windowRect);
- width = windowRect.right - windowRect.left;
- height = windowRect.bottom - windowRect.top;
- write_log (_T("%dx%d %dx%d\n"), windowRect.left, windowRect.top, windowRect.right, windowRect.bottom);
- if (width < 800)
- width = 800;
- if (height < 600)
- height = 600;
- if (width > w2)
- width = w2;
- if (height > h2)
- height = h2;
- x = md->rect.left + (w2 - width) / 2;
- y = md->rect.top + (h2 - height) / 2;
- write_log (_T("X=%d Y=%d W=%d H=%d\n"), x, y, width, height);
- SetWindowPos (hWnd, NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
- return FALSE;
- }
- static void eject_cd (void)
- {
- workprefs.cdslots[0].name[0] = 0;
- if (full_property_sheet)
- workprefs.cdslots[0].type = SCSI_UNIT_DEFAULT;
- quickstart_cddrive[0] = 0;
- workprefs.cdslots[0].inuse = false;
- if (full_property_sheet) {
- quickstart_cdtype = 0;
- } else {
- if (quickstart_cdtype > 0) {
- quickstart_cdtype = 1;
- workprefs.cdslots[0].inuse = true;
- }
- }
- }
- void gui_infotextbox(HWND hDlg, const TCHAR *text)
- {
- stringboxdialogactive = 1;
- HWND hwnd = CustomCreateDialog (IDD_DISKINFO, hDlg ? hDlg : hGUIWnd, StringBoxDialogProc);
- if (hwnd == NULL)
- return;
- HFONT font = CreateFont (getscaledfontsize(-1), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
- if (font)
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
- while (stringboxdialogactive == 1) {
- MSG msg;
- int ret;
- WaitMessage ();
- while ((ret = GetMessage (&msg, NULL, 0, 0))) {
- if (ret == -1)
- break;
- if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- }
- if (stringboxdialogactive == -1)
- break;
- }
- if (font) {
- DeleteObject(font);
- }
- }
- static void infofloppy (HWND hDlg, int n)
- {
- struct diskinfo di;
- TCHAR tmp2[MAX_DPATH], tmp1[MAX_DPATH], tmp3[MAX_DPATH];
- TCHAR text[20000];
- DISK_examine_image (&workprefs, n, &di, true, tmp3);
- DISK_validate_filename(&workprefs, workprefs.floppyslots[n].df, n, tmp1, 0, NULL, NULL, NULL);
- text[0] = 0;
- if (tmp3[0]) {
- _tcscpy(text, tmp3);
- _tcscat(text, _T("\r\n\r\n"));
- }
- tmp2[0] = 0;
- if (tmp1[0]) {
- _stprintf(tmp2, _T("'%s'\r\n"), tmp1);
- }
- _stprintf (tmp2 + _tcslen(tmp2), _T("Disk readable: %s\r\n"), di.unreadable ? _T("No") : _T("Yes"));
- if (di.image_crc_value) {
- _stprintf(tmp2 + _tcslen(tmp2), _T("Disk CRC32: %08X\r\n"), di.imagecrc32);
- }
- _stprintf(tmp2 + _tcslen(tmp2),
- _T("Boot block CRC32: %08X\r\nBoot block checksum valid: %s\r\nBoot block type: %s\r\n"),
- di.bootblockcrc32,
- di.bb_crc_valid ? _T("Yes") : _T("No"),
- di.bootblocktype == 0 ? _T("Custom") : (di.bootblocktype == 1 ? _T("Standard 1.x") : _T("Standard 2.x+"))
- );
- _tcscat(text, tmp2);
- if (di.diskname[0]) {
- _stprintf (tmp2,
- _T("Label: '%s'\r\n"), di.diskname);
- _tcscat (text, tmp2);
- }
- _tcscat (text, _T("\r\n"));
- if (di.bootblockinfo[0]) {
- _tcscat(text, _T("Amiga Bootblock Reader database detected:\r\n"));
- _tcscat(text, _T("Name: '"));
- _tcscat(text, di.bootblockinfo);
- _tcscat(text, _T("'"));
- _tcscat(text, _T("\r\n"));
- if (di.bootblockclass[0]) {
- _tcscat(text, _T("Class: '"));
- _tcscat(text, di.bootblockclass);
- _tcscat(text, _T("'"));
- _tcscat(text, _T("\r\n"));
- }
- _tcscat(text, _T("\r\n"));
- }
- int w = 32;
- for (int i = 0; i < 1024; i += w) {
- for (int j = 0; j < w; j++) {
- uae_u8 b = di.bootblock[i + j];
- _stprintf (tmp2 + j * 2, _T("%02X"), b);
- if (b >= 32 && b < 127)
- tmp2[w * 2 + 1 + j] = (TCHAR)b;
- else
- tmp2[w * 2 + 1 + j] = '.';
- }
- tmp2[w * 2] = ' ';
- tmp2[w * 2 + 1 + w] = 0;
- _tcscat (text, tmp2);
- _tcscat (text, _T("\r\n"));
- }
- stringboxdialogactive = 1;
- HWND hwnd = CustomCreateDialog (IDD_DISKINFO, hDlg, StringBoxDialogProc);
- if (hwnd == NULL)
- return;
- HFONT font = CreateFont (getscaledfontsize(-1), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console"));
- if (font)
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE);
- SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text);
- while (stringboxdialogactive == 1) {
- MSG msg;
- int ret;
- WaitMessage ();
- while ((ret = GetMessage (&msg, NULL, 0, 0))) {
- if (ret == -1)
- break;
- if (!IsWindow (hwnd) || !IsDialogMessage (hwnd, &msg)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- }
- if (stringboxdialogactive == -1)
- break;
- }
- DeleteObject (font);
- }
- static void ejectfloppy (int n)
- {
- if (iscd (n)) {
- eject_cd ();
- } else {
- workprefs.floppyslots[n].df[0] = 0;
- // no disk in drive when GUI was entered
- // make sure possibly disks inserted after GUI was entered
- // are removed.
- if (changed_prefs.floppyslots[n].df[0] == 0)
- disk_insert(n, _T(""));
- }
- }
- static void selectcd (struct uae_prefs *prefs, HWND hDlg, int num, int id, const TCHAR *full_path)
- {
- SetDlgItemText (hDlg, id, full_path);
- if (quickstart_cddrive[0])
- eject_cd ();
- _tcscpy (prefs->cdslots[0].name, full_path);
- fullpath (prefs->cdslots[0].name, sizeof prefs->cdslots[0].name / sizeof (TCHAR));
- DISK_history_add (prefs->cdslots[0].name, -1, HISTORY_CD, 0);
- }
- static void selectdisk (struct uae_prefs *prefs, HWND hDlg, int num, int id, const TCHAR *full_path)
- {
- if (iscd (num)) {
- selectcd (prefs, hDlg, num, id, full_path);
- return;
- }
- SetDlgItemText (hDlg, id, full_path);
- _tcscpy(prefs->floppyslots[num].df, full_path);
- fullpath (prefs->floppyslots[num].df, sizeof prefs->floppyslots[num].df / sizeof (TCHAR));
- DISK_history_add (prefs->floppyslots[num].df, -1, HISTORY_FLOPPY, 0);
- }
- static void selectgenlock(struct uae_prefs *prefs, HWND hDlg, int id, const TCHAR *full_path)
- {
- SetDlgItemText(hDlg, id, full_path);
- if (workprefs.genlock_image == 3) {
- _tcscpy(prefs->genlock_image_file, full_path);
- fullpath(prefs->genlock_image_file, sizeof prefs->genlock_image_file / sizeof(TCHAR));
- DISK_history_add(prefs->genlock_image_file, -1, HISTORY_GENLOCK_IMAGE, 0);
- } else if (workprefs.genlock_image == 4 || workprefs.genlock_image >= 6) {
- _tcscpy(prefs->genlock_video_file, full_path);
- fullpath(prefs->genlock_video_file, sizeof prefs->genlock_video_file / sizeof(TCHAR));
- DISK_history_add(prefs->genlock_video_file, -1, HISTORY_GENLOCK_VIDEO, 0);
- }
- }
- static void getcreatefloppytype(HWND hDlg, drive_type *atype, int *hd)
- {
- *atype = DRV_NONE;
- *hd = -1;
- int type = SendDlgItemMessage(hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L);
- switch (type)
- {
- case 0:
- *atype = DRV_35_DD;
- break;
- case 1:
- *atype = DRV_35_HD;
- break;
- case 2:
- *atype = DRV_PC_35_ONLY_80;
- break;
- case 3:
- *atype = DRV_PC_35_ONLY_80;
- *hd = 1;
- break;
- case 4:
- *atype = DRV_PC_525_ONLY_40;
- break;
- }
- }
- static void setdpath (const TCHAR *name, const TCHAR *path)
- {
- TCHAR tmp[MAX_DPATH];
- _tcscpy (tmp, path);
- fullpath (tmp, sizeof tmp / sizeof (TCHAR));
- regsetstr (NULL, name, tmp);
- }
- // Common routine for popping up a file-requester
- // flag - 0 for floppy loading, 1 for floppy creation, 2 for loading hdf, 3 for saving hdf
- // flag - 4 for loading .uae config-files, 5 for saving .uae config-files
- // flag = 6 for loading .rom files, 7 for loading .key files
- // flag = 8 for loading configurations
- // flag = 9 for saving snapshots
- // flag = 10 for loading snapshots
- // flag = 11 for selecting flash files
- // flag = 12 for loading anything
- // flag = 13 for selecting path
- // flag = 14 for loading filesystem
- // flag = 15 for loading input
- // flag = 16 for recording input
- // flag = 17 for CD image
- // flag = 18 for Tape image
- // flag = 20 for genlock image
- // flag = 21 for genlock video
- // flag = 22 for floppy replacement (missing statefile)
- // fags = 23 for hdf geometry (load)
- // fags = 24 for hdf geometry (save)
- int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *infilename, TCHAR *path_out, int *multi)
- {
- static int previousfilter[32];
- TCHAR filtername[MAX_DPATH] = _T("");
- OPENFILENAME openFileName;
- TCHAR full_path[MAX_DPATH] = _T("");
- TCHAR full_path2[MAX_DPATH];
- TCHAR file_name[MAX_DPATH] = _T("");
- TCHAR init_path[MAX_DPATH] = _T("");
- BOOL result = FALSE;
- TCHAR* amiga_path = NULL, * initialdir = NULL;
- const TCHAR *defext = NULL;
- TCHAR *p, *nextp;
- int all = 1;
- int next;
- int nosavepath = 0;
- const GUID *guid = NULL;
- TCHAR szTitle[MAX_DPATH] = { 0 };
- TCHAR szFormat[MAX_DPATH];
- TCHAR szFilter[MAX_DPATH] = { 0 };
- memset (&openFileName, 0, sizeof (OPENFILENAME));
- if (path_out && path_out[0]) {
- _tcscpy (init_path, path_out);
- nosavepath = 1;
- } else {
- _tcsncpy (init_path, start_path_data, MAX_DPATH);
- switch (flag)
- {
- case 0:
- case 1:
- case 22:
- getfilter (flag, _T("FloppyPath"), previousfilter, filtername);
- fetch_path (_T("FloppyPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[0];
- break;
- case 2:
- case 3:
- case 23:
- case 24:
- getfilter (flag, _T("hdfPath"), previousfilter, filtername);
- fetch_path (_T("hdfPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[1];
- break;
- case 6:
- case 7:
- case 11:
- getfilter (flag, _T("KickstartPath"), previousfilter, filtername);
- fetch_path (_T("KickstartPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[2];
- break;
- case 4:
- case 5:
- case 8:
- getfilter (flag, _T("ConfigurationPath"), previousfilter, filtername);
- fetch_path (_T("ConfigurationPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[3];
- break;
- case 9:
- case 10:
- {
- int ok = 0;
- if (savestate_fname[0]) {
- _tcscpy (init_path, savestate_fname);
- for (;;) {
- TCHAR *p;
- if (my_existsdir (init_path)) {
- ok = 1;
- break;
- }
- p = _tcsrchr (init_path, '\\');
- if (!p)
- p = _tcsrchr (init_path, '/');
- if (!p)
- break;
- *p = 0;
- }
- }
- if (!ok) {
- getfilter (flag, _T("StatefilePath"), previousfilter, filtername);
- fetch_path (_T("StatefilePath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- }
- guid = &diskselectionguids[4];
- }
- break;
- case 15:
- case 16:
- getfilter (flag, _T("InputPath"), previousfilter, filtername);
- fetch_path (_T("InputPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[5];
- break;
- case 17:
- getfilter (flag, _T("CDPath"), previousfilter, filtername);
- fetch_path (_T("CDPath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[6];
- break;
- case 18:
- getfilter (flag, _T("TapePath"), previousfilter, filtername);
- fetch_path (_T("TapePath"), init_path, sizeof (init_path) / sizeof (TCHAR));
- guid = &diskselectionguids[7];
- break;
- case 20:
- fetch_path(_T("GenlockImagePath"), init_path, sizeof(init_path) / sizeof(TCHAR));
- guid = &diskselectionguids[8];
- break;
- case 21:
- fetch_path(_T("GenlockVideoPath"), init_path, sizeof(init_path) / sizeof(TCHAR));
- guid = &diskselectionguids[9];
- break;
- }
- }
- if (infilename)
- _tcscpy(full_path, infilename);
- szFilter[0] = 0;
- szFilter[1] = 0;
- switch (flag) {
- case 0:
- WIN32GUI_LoadUIString (IDS_SELECTADF, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING));
- defext = _T("adf");
- break;
- case 22:
- _tcscpy(szTitle, prefs->floppyslots[wParam - IDC_DF0].df);
- WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING));
- defext = _T("adf");
- break;
- case 1:
- WIN32GUI_LoadUIString (IDS_CHOOSEBLANK, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), _T("(*.adf)\0*.adf\0"), 15 * sizeof (TCHAR));
- defext = _T("adf");
- break;
- case 2:
- case 3:
- WIN32GUI_LoadUIString (IDS_SELECTHDF, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_HDF, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), HDF_FORMAT_STRING, sizeof (HDF_FORMAT_STRING));
- defext = _T("hdf");
- break;
- case 4:
- case 5:
- WIN32GUI_LoadUIString (IDS_SELECTUAE, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_UAE, szFormat, MAX_DPATH );
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), _T("(*.uae)\0*.uae\0"), 15 * sizeof (TCHAR));
- defext = _T("uae");
- break;
- case 6:
- WIN32GUI_LoadUIString (IDS_SELECTROM, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_ROM, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING));
- defext = _T("rom");
- break;
- case 7:
- WIN32GUI_LoadUIString (IDS_SELECTKEY, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_KEY, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), _T("(*.key)\0*.key\0"), 15 * sizeof (TCHAR));
- defext = _T("key");
- break;
- case 15:
- case 16:
- WIN32GUI_LoadUIString (flag == 15 ? IDS_RESTOREINP : IDS_SAVEINP, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_INP, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), INP_FORMAT_STRING, sizeof (INP_FORMAT_STRING));
- defext = _T("inp");
- break;
- case 9:
- case 10:
- WIN32GUI_LoadUIString (flag == 10 ? IDS_RESTOREUSS : IDS_SAVEUSS, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_USS, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- if (flag == 10) {
- memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE));
- all = 1;
- } else {
- TCHAR tmp[MAX_DPATH];
- memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_SAVE, sizeof (USS_FORMAT_STRING_SAVE));
- p = szFilter;
- while (p[0] != 0 || p[1] !=0 ) p++;
- p++;
- WIN32GUI_LoadUIString (IDS_STATEFILE_UNCOMPRESSED, tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcscat (p, tmp);
- _tcscat (p, _T(" (*.uss)"));
- p += _tcslen (p) + 1;
- _tcscpy (p, _T("*.uss"));
- p += _tcslen (p) + 1;
- WIN32GUI_LoadUIString (IDS_STATEFILE_RAMDUMP, tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcscat (p, tmp);
- _tcscat (p, _T(" (*.dat)"));
- p += _tcslen (p) + 1;
- _tcscpy (p, _T("*.dat"));
- p += _tcslen (p) + 1;
- WIN32GUI_LoadUIString (IDS_STATEFILE_WAVE, tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcscat (p, tmp);
- _tcscat (p, _T(" (*.wav)"));
- p += _tcslen (p) + 1;
- _tcscpy (p, _T("*.wav"));
- p += _tcslen (p) + 1;
- *p = 0;
- all = 0;
- }
- defext = _T("uss");
- break;
- case 11:
- case 19:
- WIN32GUI_LoadUIString (IDS_SELECTFLASH, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_FLASH, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), _T("(*.nvr)\0*.nvr\0"), 15 * sizeof (TCHAR));
- defext = _T("nvr");
- break;
- case 8:
- default:
- WIN32GUI_LoadUIString (IDS_SELECTINFO, szTitle, MAX_DPATH);
- break;
- case 12:
- WIN32GUI_LoadUIString (IDS_SELECTFS, szTitle, MAX_DPATH);
- initialdir = path_out;
- break;
- case 13:
- WIN32GUI_LoadUIString (IDS_SELECTINFO, szTitle, MAX_DPATH);
- initialdir = path_out;
- break;
- case 14:
- _tcscpy (szTitle, _T("Select supported archive file"));
- _stprintf (szFilter, _T("%s (%s)"), _T("Archive"), ARCHIVE_STRING);
- _tcscpy (szFilter + _tcslen (szFilter) + 1, ARCHIVE_STRING);
- initialdir = path_out;
- break;
- case 17:
- WIN32GUI_LoadUIString (IDS_SELECTCD, szTitle, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_CD, szFormat, MAX_DPATH);
- _stprintf (szFilter, _T("%s "), szFormat);
- memcpy (szFilter + _tcslen (szFilter), CD_FORMAT_STRING, sizeof (CD_FORMAT_STRING) + sizeof (TCHAR));
- defext = _T("cue");
- break;
- case 18:
- WIN32GUI_LoadUIString (IDS_SELECTTAPE, szTitle, MAX_DPATH);
- break;
- case 20:
- _tcscpy(szTitle, _T("Select genlock image"));
- break;
- case 21:
- _tcscpy(szTitle, _T("Select genlock video"));
- break;
- case 23:
- case 24:
- _tcscpy(szTitle, _T("Select geometry file"));
- _stprintf (szFilter, _T("%s "), _T("Geometry files"));
- memcpy (szFilter + _tcslen (szFilter), GEO_FORMAT_STRING, sizeof (GEO_FORMAT_STRING) + sizeof (TCHAR));
- defext = _T("geo");
- break;
- break;
- }
- if (all) {
- p = szFilter;
- while (p[0] != 0 || p[1] !=0) p++;
- p++;
- _tcscpy (p, _T("All files (*.*)"));
- p += _tcslen (p) + 1;
- _tcscpy (p, _T("*.*"));
- p += _tcslen (p) + 1;
- *p = 0;
- }
- openFileName.lStructSize = sizeof (OPENFILENAME);
- openFileName.hwndOwner = hDlg;
- openFileName.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST |
- OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_ENABLESIZING | (isfullscreen () > 0 ? OFN_ENABLEHOOK : 0);
- openFileName.lpstrFilter = szFilter;
- openFileName.lpstrDefExt = defext;
- openFileName.nFilterIndex = previousfilter[flag];
- openFileName.lpstrFile = full_path;
- openFileName.nMaxFile = MAX_DPATH;
- openFileName.lpstrFileTitle = file_name;
- openFileName.nMaxFileTitle = MAX_DPATH;
- openFileName.lpfnHook = ofnhook;
- if (initialdir)
- openFileName.lpstrInitialDir = initialdir;
- else
- openFileName.lpstrInitialDir = init_path;
- openFileName.lpstrTitle = szTitle;
- if (multi)
- openFileName.Flags |= OFN_ALLOWMULTISELECT;
- if (flag == 1 || flag == 3 || flag == 5 || flag == 9 || flag == 16 || flag == 24) {
- openFileName.Flags &= ~OFN_FILEMUSTEXIST;
- if (!(result = GetSaveFileName_2 (hDlg, &openFileName, guid)))
- write_log (_T("GetSaveFileNameX() failed, err=%d.\n"), GetLastError ());
- } else {
- if (flag == 11 || flag == 19) {
- openFileName.Flags &= ~OFN_FILEMUSTEXIST;
- }
- if (!(result = GetOpenFileName_2 (hDlg, &openFileName, guid)))
- write_log (_T("GetOpenFileNameX() failed, err=%d.\n"), GetLastError ());
- }
- if (result) {
- previousfilter[flag] = openFileName.nFilterIndex;
- setfilter (flag, previousfilter, filtername);
- }
- memcpy (full_path2, full_path, sizeof full_path);
- memcpy (stored_path, full_path, sizeof stored_path);
- next = 0;
- nextp = full_path2 + openFileName.nFileOffset;
- if (path_out) {
- if (multi) {
- while (nextp[0])
- nextp += _tcslen (nextp) + 1;
- memcpy (path_out, full_path2, (nextp - full_path2 + 1) * sizeof (TCHAR));
- } else {
- _tcscpy (path_out, full_path2);
- }
- }
- nextp = full_path2 + openFileName.nFileOffset;
- if (nextp[_tcslen (nextp) + 1] == 0)
- multi = 0;
- while (result && next >= 0)
- {
- next = -1;
- if (multi) {
- if (nextp[0] == 0)
- break;
- _stprintf (full_path, _T("%s\\%s"), full_path2, nextp);
- nextp += _tcslen (nextp) + 1;
- }
- switch (wParam)
- {
- case IDC_PATH_NAME:
- case IDC_PATH_FILESYS:
- if (flag == 8) {
- if(_tcsstr (full_path, _T("Configurations\\"))) {
- _tcscpy (full_path, init_path);
- _tcscat (full_path, file_name);
- }
- }
- SetDlgItemText (hDlg, wParam, full_path);
- break;
- case IDC_GENLOCKFILESELECT:
- selectgenlock(prefs, hDlg, IDC_GENLOCKFILE, full_path);
- break;
- case IDC_PATH_GEOMETRY:
- SetDlgItemText (hDlg, wParam, full_path);
- break;
- case IDC_CD_SELECT:
- selectcd (prefs, hDlg, 0, IDC_CD_TEXT, full_path);
- break;
- case IDC_DF0:
- case IDC_DF0QQ:
- selectdisk (prefs, hDlg, 0, IDC_DF0TEXT, full_path);
- next = IDC_DF1;
- break;
- case IDC_DF1:
- case IDC_DF1QQ:
- selectdisk (prefs, hDlg, 1, IDC_DF1TEXT, full_path);
- next = IDC_DF2;
- break;
- case IDC_DF2:
- selectdisk (prefs, hDlg, 2, IDC_DF2TEXT, full_path);
- next = IDC_DF3;
- break;
- case IDC_DF3:
- selectdisk (prefs, hDlg, 3, IDC_DF3TEXT, full_path);
- break;
- case IDC_DOSAVESTATE:
- savestate_initsave (full_path, openFileName.nFilterIndex, FALSE, true);
- break;
- case IDC_DOLOADSTATE:
- savestate_initsave (full_path, openFileName.nFilterIndex, FALSE, false);
- break;
- case IDC_CREATE:
- {
- drive_type atype = DRV_NONE;
- int hd = -1;
- TCHAR disk_name[32];
- disk_name[0] = 0; disk_name[31] = 0;
- GetDlgItemText (hDlg, IDC_CREATE_NAME, disk_name, 30);
- getcreatefloppytype(hDlg, &atype, &hd);
- if (disk_creatediskfile (&workprefs, full_path, 0, atype, hd, disk_name, ischecked (hDlg, IDC_FLOPPY_FFS), ischecked (hDlg, IDC_FLOPPY_BOOTABLE), NULL)) {
- fullpath (full_path, sizeof full_path / sizeof (TCHAR));
- DISK_history_add (full_path, -1, HISTORY_FLOPPY, 0);
- }
- }
- break;
- case IDC_CREATE_RAW:
- {
- drive_type atype = DRV_NONE;
- int hd = -1;
- TCHAR disk_name[32];
- disk_name[0] = 0; disk_name[31] = 0;
- GetDlgItemText(hDlg, IDC_CREATE_NAME, disk_name, 30);
- getcreatefloppytype(hDlg, &atype, &hd);
- if (disk_creatediskfile(&workprefs, full_path, 1, atype, hd, disk_name, ischecked(hDlg, IDC_FLOPPY_FFS), ischecked(hDlg, IDC_FLOPPY_BOOTABLE), NULL)) {
- fullpath(full_path, sizeof full_path / sizeof(TCHAR));
- DISK_history_add(full_path, -1, HISTORY_FLOPPY, 0);
- }
- }
- break;
- case IDC_LOAD:
- if (target_cfgfile_load (&workprefs, full_path, CONFIG_TYPE_DEFAULT, 0) == 0) {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH);
- pre_gui_message (szMessage);
- } else {
- SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, workprefs.description);
- SetDlgItemText (hDlg, IDC_EDITNAME, full_path);
- }
- break;
- case IDC_SAVE:
- if (cfgfile_can_write(hDlg, full_path)) {
- SetDlgItemText(hDlg, IDC_EDITNAME, full_path);
- cfgfile_save(&workprefs, full_path, 0);
- }
- break;
- case IDC_ROMFILE:
- _tcscpy (workprefs.romfile, full_path);
- fullpath (workprefs.romfile, MAX_DPATH);
- read_kickstart_version(&workprefs);
- break;
- case IDC_ROMFILE2:
- _tcscpy (workprefs.romextfile, full_path);
- fullpath (workprefs.romextfile, MAX_DPATH);
- break;
- case IDC_CUSTOMROMFILE:
- {
- int v = SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_GETCURSEL, 0, 0);
- if (v >= 0 && v < MAX_ROM_BOARDS) {
- struct romboard *rb = &workprefs.romboards[v];
- _tcscpy(rb->lf.loadfile, full_path);
- fullpath(rb->lf.loadfile, MAX_DPATH);
- if (rb->start_address) {
- struct zfile *zf = zfile_fopen(rb->lf.loadfile, _T("rb"));
- if (zf) {
- rb->end_address = rb->start_address + zfile_size(zf);
- rb->end_address = ((rb->end_address + 65535) & ~65535) - 1;
- rb->size = rb->end_address - rb->start_address + 1;
- zfile_fclose(zf);
- }
- }
- }
- break;
- }
- case IDC_FLASHFILE:
- _tcscpy (workprefs.flashfile, full_path);
- fullpath(workprefs.flashfile, MAX_DPATH);
- break;
- case IDC_RTCFILE:
- _tcscpy (workprefs.rtcfile, full_path);
- fullpath(workprefs.rtcfile, MAX_DPATH);
- break;
- case IDC_CARTFILE:
- _tcscpy (workprefs.cartfile, full_path);
- fullpath (workprefs.cartfile, MAX_DPATH);
- break;
- case IDC_SCSIROMFILE:
- {
- int val = gui_get_string_cursor(scsiromselect_table, hDlg, IDC_SCSIROMSELECT);
- if (val != CB_ERR) {
- int index;
- struct boardromconfig *brc;
- brc = get_device_rom_new(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- _tcscpy (brc->roms[index].romfile, full_path);
- fullpath (brc->roms[index].romfile, MAX_DPATH);
- }
- break;
- }
- case IDC_CPUBOARDROMFILE:
- {
- int index;
- struct boardromconfig *brc = get_device_rom_new(&workprefs, ROMTYPE_CPUBOARD, 0, &index);
- _tcscpy(brc->roms[index].romfile, full_path);
- fullpath(brc->roms[index].romfile, MAX_DPATH);
- break;
- }
- case IDC_STATEREC_PLAY:
- case IDC_STATEREC_RECORD:
- case IDC_STATEREC_SAVE:
- _tcscpy (workprefs.inprecfile, full_path);
- _tcscpy (workprefs.inprecfile, full_path);
- break;
- }
- if (!nosavepath || 1) {
- if (flag == 0 || flag == 1 || flag == 22) {
- amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath (_T("FloppyPath"), openFileName.lpstrFile);
- }
- } else if (flag == 2 || flag == 3 || flag == 23) {
- amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath (_T("hdfPath"), openFileName.lpstrFile);
- }
- } else if (flag == 17) {
- amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath (_T("CDPath"), openFileName.lpstrFile);
- }
- } else if (flag == 18) {
- amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath (_T("TapePath"), openFileName.lpstrFile);
- }
- } else if (flag == 20) {
- amiga_path = _tcsstr(openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath(_T("GenlockImagePath"), openFileName.lpstrFile);
- }
- } else if (flag == 21) {
- amiga_path = _tcsstr(openFileName.lpstrFile, openFileName.lpstrFileTitle);
- if (amiga_path && amiga_path != openFileName.lpstrFile) {
- *amiga_path = 0;
- setdpath(_T("GenlockVideoPath"), openFileName.lpstrFile);
- }
- }
- }
- if (!multi)
- next = -1;
- if (next >= 0)
- wParam = next;
- }
- return result;
- }
- int DiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *file_in, TCHAR *path_out)
- {
- return DiskSelection_2 (hDlg, wParam, flag, prefs, file_in, path_out, NULL);
- }
- int MultiDiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *path_out)
- {
- int multi = 0;
- return DiskSelection_2 (hDlg, wParam, flag, prefs, NULL, path_out, &multi);
- }
- static int loopmulti (const TCHAR *s, TCHAR *out)
- {
- static int index;
- if (!out) {
- index = _tcslen (s) + 1;
- return 1;
- }
- if (index < 0)
- return 0;
- if (!s[index]) {
- if (s[_tcslen (s) + 1] == 0) {
- _tcscpy (out, s);
- index = -1;
- return 1;
- }
- return 0;
- }
- _stprintf (out, _T("%s\\%s"), s, s + index);
- index += _tcslen (s + index) + 1;
- return 1;
- }
- static BOOL CreateHardFile (HWND hDlg, uae_s64 hfsize, const TCHAR *dostype, TCHAR *newpath, TCHAR *outpath)
- {
- HANDLE hf;
- int i = 0;
- BOOL result = FALSE;
- LONG highword = 0;
- DWORD ret, written;
- TCHAR init_path[MAX_DPATH] = _T("");
- uae_u32 dt;
- uae_u8 b;
- int sparse, dynamic;
- outpath[0] = 0;
- sparse = 0;
- dynamic = 0;
- dt = 0;
- if (ischecked (hDlg, IDC_HF_SPARSE))
- sparse = 1;
- if (ischecked (hDlg, IDC_HF_DYNAMIC)) {
- dynamic = 1;
- sparse = 0;
- }
- if (!DiskSelection (hDlg, IDC_PATH_NAME, 3, &workprefs, NULL, newpath))
- return FALSE;
- GetDlgItemText (hDlg, IDC_PATH_NAME, init_path, MAX_DPATH);
- if (*init_path && hfsize) {
- if (dynamic) {
- if (!_stscanf (dostype, _T("%x"), &dt))
- dt = 0;
- if (_tcslen (init_path) > 4 && !_tcsicmp (init_path + _tcslen (init_path) - 4, _T(".hdf")))
- _tcscpy (init_path + _tcslen (init_path) - 4, _T(".vhd"));
- result = vhd_create (init_path, hfsize, dt);
- } else {
- SetCursor (LoadCursor (NULL, IDC_WAIT));
- if ((hf = CreateFile (init_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
- if (sparse) {
- DWORD ret;
- DeviceIoControl (hf, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &ret, NULL);
- }
- if (hfsize >= 0x80000000) {
- highword = (DWORD)(hfsize >> 32);
- ret = SetFilePointer (hf, (DWORD)hfsize, &highword, FILE_BEGIN);
- } else {
- ret = SetFilePointer (hf, (DWORD)hfsize, NULL, FILE_BEGIN);
- }
- if (ret == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
- write_log (_T("SetFilePointer() failure for %s to posn %ud\n"), init_path, hfsize);
- else
- result = SetEndOfFile (hf);
- SetFilePointer (hf, 0, NULL, FILE_BEGIN);
- b = 0;
- WriteFile (hf, &b, 1, &written, NULL);
- WriteFile (hf, &b, 1, &written, NULL);
- WriteFile (hf, &b, 1, &written, NULL);
- WriteFile (hf, &b, 1, &written, NULL);
- if (_stscanf (dostype, _T("%x"), &dt) > 0) {
- SetFilePointer (hf, 0, NULL, FILE_BEGIN);
- b = dt >> 24;
- WriteFile (hf, &b, 1, &written, NULL);
- b = dt >> 16;
- WriteFile (hf, &b, 1, &written, NULL);
- b = dt >> 8;
- WriteFile (hf, &b, 1, &written, NULL);
- b = dt >> 0;
- WriteFile (hf, &b, 1, &written, NULL);
- }
- CloseHandle (hf);
- } else {
- write_log (_T("CreateFile() failed to create %s\n"), init_path);
- }
- SetCursor (LoadCursor (NULL, IDC_ARROW));
- }
- }
- if (!result) {
- TCHAR szMessage[MAX_DPATH];
- TCHAR szTitle[MAX_DPATH];
- WIN32GUI_LoadUIString (IDS_FAILEDHARDFILECREATION, szMessage, MAX_DPATH);
- WIN32GUI_LoadUIString (IDS_CREATIONERROR, szTitle, MAX_DPATH);
- MessageBox (hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
- } else {
- _tcscpy (outpath, init_path);
- }
- return result;
- }
- static uae_s64 CalculateHardfileSize(HWND hDlg)
- {
- uae_s64 mbytes = 0;
- TCHAR tmp[100];
- tmp[0] = 0;
- GetDlgItemText(hDlg, IDC_HF_SIZE, tmp, sizeof tmp / sizeof(TCHAR));
- for (int i = 0; i < _tcslen(tmp); i++) {
- if (tmp[i] == ',')
- tmp[i] = '.';
- }
- double v = _tstof(tmp);
- mbytes = (uae_s64)(v * 1024 * 1024);
- mbytes &= ~511;
- if (mbytes <= 0)
- mbytes = 0;
- return mbytes;
- }
- static const TCHAR *nth[] = {
- _T(""), _T("second "), _T("third "), _T("fourth "), _T("fifth "), _T("sixth "), _T("seventh "), _T("eighth "), _T("ninth "), _T("tenth ")
- };
- static void setguititle (HWND phwnd)
- {
- static TCHAR title[200];
- TCHAR title2[1000];
- TCHAR *name;
- static HWND hwnd;
- if (phwnd)
- hwnd = phwnd;
- if (hwnd && !title[0]) {
- GetWindowText (hwnd, title, sizeof title / sizeof (TCHAR));
- if (_tcslen (WINUAEBETA) > 0) {
- _tcscat (title, BetaStr);
- if (_tcslen (WINUAEEXTRA) > 0) {
- _tcscat (title, _T(" "));
- _tcscat (title, WINUAEEXTRA);
- }
- }
- }
- title2[0] = 0;
- name = workprefs.config_window_title;
- if (name && _tcslen (name) > 0) {
- _tcscat (title2, name);
- _tcscat (title2, _T(" - "));
- }
- if (!title2[0]) {
- name = config_filename;
- if (name && _tcslen (name) > 0) {
- _tcscat (title2, _T("["));
- _tcscat (title2, name);
- if (_tcslen(title2) > 4 && !_tcsicmp(title2 + _tcslen(title2) - 4, _T(".uae")))
- title2[_tcslen(title2) - 4] = 0;
- _tcscat (title2, _T("] - "));
- }
- }
- _tcscat (title2, title);
- SetWindowText (hwnd, title2);
- }
- static void GetConfigPath (TCHAR *path, struct ConfigStruct *parent, int noroot)
- {
- if (parent == NULL) {
- path[0] = 0;
- if (!noroot) {
- fetch_path (_T("ConfigurationPath"), path, MAX_DPATH);
- }
- return;
- }
- if (parent) {
- GetConfigPath (path, parent->Parent, noroot);
- _tcsncat (path, parent->Name, MAX_DPATH - _tcslen(path));
- _tcsncat (path, _T("\\"), MAX_DPATH - _tcslen(path));
- }
- }
- void FreeConfigStruct (struct ConfigStruct *config)
- {
- xfree (config);
- }
- struct ConfigStruct *AllocConfigStruct (void)
- {
- struct ConfigStruct *config;
- config = xcalloc (struct ConfigStruct, 1);
- return config;
- }
- static void FreeConfigStore (void)
- {
- for (int i = 0; i < configstoresize; i++) {
- FreeConfigStruct(configstore[i]);
- }
- xfree(configstore);
- configstoresize = configstoreallocated = 0;
- configstore = NULL;
- for (int i = 0; i < categorystoresize; i++) {
- xfree(categorystore[i]);
- }
- xfree(categorystore);
- categorystoresize = 0;
- categorystore = NULL;
- }
- static void sortcategories(void)
- {
- for (int i = 0; i < categorystoresize; i++) {
- for (int j = i + 1; j < categorystoresize; j++) {
- struct CategoryStruct *s1 = categorystore[i];
- struct CategoryStruct *s2 = categorystore[j];
- if (_tcsicmp(s1->category, s2->category) > 0) {
- struct CategoryStruct *s = categorystore[i];
- categorystore[i] = categorystore[j];
- categorystore[j] = s;
- }
- }
- }
- }
- static void addtocategories(const TCHAR *category)
- {
- if (!category[0])
- return;
- bool found = false;
- for (int j = 0; j < categorystoresize; j++) {
- struct CategoryStruct *s = categorystore[j];
- if (!_tcsicmp(category, s->category)) {
- found = true;
- break;
- }
- }
- if (!found) {
- if (categorystore == NULL || categorystoresize == categorystoreallocated) {
- categorystoreallocated += 100;
- categorystore = xrealloc(struct CategoryStruct*, categorystore, categorystoreallocated);
- }
- struct CategoryStruct *s = categorystore[categorystoresize++] = xcalloc(struct CategoryStruct, 1);
- _tcscpy(s->category, category);
- }
- }
- static void getconfigcache (TCHAR *dst, const TCHAR *path)
- {
- _tcscpy (dst, path);
- _tcsncat (dst, _T("configuration.cache"), MAX_DPATH - _tcslen(dst));
- }
- static void deleteconfigcache(void)
- {
- TCHAR path[MAX_DPATH], path2[MAX_DPATH];
- GetConfigPath(path, NULL, FALSE);
- if (!path[0])
- return;
- getconfigcache(path2, path);
- _wunlink(path2);
- }
- static TCHAR *fgetsx (TCHAR *dst, FILE *f)
- {
- TCHAR *s2;
- dst[0] = 0;
- s2 = fgetws (dst, MAX_DPATH, f);
- if (!s2)
- return NULL;
- if (_tcslen (dst) == 0)
- return dst;
- if (dst[_tcslen (dst) - 1] == '\n')
- dst[_tcslen (dst) - 1] = 0;
- if (dst[_tcslen (dst) - 1] == '\r')
- dst[_tcslen (dst) - 1] = 0;
- return dst;
- }
- static const TCHAR configcachever[] = _T("WinUAE Configuration.Cache");
- static void setconfighosthard (struct ConfigStruct *config)
- {
- if (!config->Directory)
- return;
- if (!_tcsicmp (config->Name, CONFIG_HOST))
- config->host = 1;
- if (!_tcsicmp (config->Name, CONFIG_HARDWARE))
- config->hardware = 1;
- }
- static void flushconfigcache (const TCHAR *cachepath)
- {
- FILE *zcache;
- zcache = _tfopen (cachepath, _T("r"));
- if (zcache == NULL)
- return;
- fclose (zcache);
- bool hidden = my_isfilehidden (cachepath);
- my_setfilehidden (cachepath, false);
- zcache = _tfopen (cachepath, _T("w+, ccs=UTF-8"));
- if (zcache)
- fclose (zcache);
- my_setfilehidden (cachepath, hidden);
- write_log (_T("'%s' flushed\n"), cachepath);
- }
- static struct ConfigStruct *readconfigcache (const TCHAR *path)
- {
- FILE *zcache;
- TCHAR cachepath[MAX_DPATH];
- TCHAR buf[MAX_DPATH];
- TCHAR rootpath[MAX_DPATH];
- TCHAR path2[MAX_DPATH], tmp[MAX_DPATH];
- struct ConfigStruct *cs, *first;
- int err;
- int filelines, dirlines, headlines, dirmode, lines;
- TCHAR dirsep = '\\';
- FILETIME t;
- SYSTEMTIME st;
- ULARGE_INTEGER t1, stt, dirtt;
- HANDLE h;
- WIN32_FIND_DATA ffd;
- #if CONFIGCACHE == 0
- return NULL;
- #endif
- err = 0;
- first = NULL;
- getconfigcache (cachepath, path);
- zcache = my_opentext (cachepath);
- if (!zcache)
- return NULL;
- if (!configurationcache) {
- fclose (zcache);
- _wunlink (cachepath);
- return NULL;
- }
- fgetsx (buf, zcache);
- if (feof (zcache))
- goto end;
- if (_tcscmp (buf, configcachever))
- goto end;
- GetFullPathName (path, sizeof path2 / sizeof (TCHAR), path2, NULL);
- _tcscpy (rootpath, path2);
- if (path2[_tcslen (path2) - 1] == '\\' || path2[_tcslen (path2) -1] == '/')
- path2[_tcslen (path2) - 1] = 0;
- h = FindFirstFile (path2, &ffd);
- if (h == INVALID_HANDLE_VALUE)
- goto end;
- FindClose (h);
- memcpy (&dirtt, &ffd.ftLastWriteTime, sizeof (ULARGE_INTEGER));
- fgetsx (buf, zcache);
- headlines = _tstol (buf);
- fgetsx (buf, zcache);
- headlines--;
- dirlines = _tstol (buf);
- fgetsx (buf, zcache);
- headlines--;
- filelines = _tstol (buf);
- fgetsx (buf, zcache);
- t1.QuadPart = _tstoi64 (buf);
- headlines--;
- GetSystemTime (&st);
- SystemTimeToFileTime (&st, &t);
- memcpy (&stt, &t, sizeof (ULARGE_INTEGER));
- if (headlines < 0 || dirlines < 3 || filelines < 3 ||
- t1.QuadPart == 0 || t1.QuadPart > stt.QuadPart || dirtt.QuadPart > t1.QuadPart)
- goto end;
- while (headlines-- > 0)
- fgetsx (buf, zcache);
- fgetsx (buf, zcache);
- if (buf[0] != ';')
- goto end;
- while (fgetsx (buf, zcache)) {
- TCHAR c;
- TCHAR dirpath[MAX_DPATH];
- dirmode = 0;
- if (_tcslen (buf) > 0) {
- c = buf[_tcslen (buf) - 1];
- if (c == '/' || c == '\\') {
- dirmode = 1;
- dirsep = c;
- }
- }
- _tcscpy (dirpath, buf);
- if (dirmode) {
- lines = dirlines;
- } else {
- TCHAR *p;
- lines = filelines;
- p = _tcsrchr (dirpath, dirsep);
- if (p)
- p[0] = 0;
- else
- dirpath[0] = 0;
- }
- lines--;
- cs = AllocConfigStruct ();
- if (configstore == NULL || configstoreallocated == configstoresize) {
- configstoreallocated += 100;
- configstore = xrealloc(struct ConfigStruct*, configstore, configstoreallocated);
- }
- configstore[configstoresize++] = cs;
- if (!first)
- first = cs;
- cs->Directory = dirmode;
- _tcscpy (tmp, path);
- _tcscat (tmp, dirpath);
- _tcscpy (cs->Fullpath, tmp);
- _tcscpy (cs->Path, dirpath);
- fgetsx (tmp, zcache);
- lines--;
- t1.QuadPart = _tstoi64 (tmp);
- if (t1.QuadPart > stt.QuadPart)
- goto end;
- fgetsx (cs->Name, zcache);
- lines--;
- fgetsx (cs->Description, zcache);
- lines--;
- _tcscpy (tmp, cs->Path);
- if (_tcslen (tmp) > 0) {
- TCHAR *p = tmp;
- if (tmp[_tcslen (tmp) - 1] == dirsep) {
- tmp[_tcslen (tmp) - 1] = 0;
- p = _tcsrchr (tmp, dirsep);
- if (p)
- p[1] = 0;
- } else {
- tmp[_tcslen (tmp) + 1] = 0;
- tmp[_tcslen (tmp)] = dirsep;
- }
- if (p) {
- int i;
- for (i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs2 = configstore[i];
- if (cs2 != cs && !_tcscmp (cs2->Path, tmp) && cs2->Directory) {
- cs->Parent = cs2;
- if (!cs2->Child)
- cs2->Child = cs;
- cs->host = cs2->host;
- cs->hardware = cs2->hardware;
- }
- }
- }
- }
- if (_tcslen (cs->Path) > 0 && !dirmode) {
- _tcscat (cs->Path, _T("\\"));
- _tcscat (cs->Fullpath, _T("\\"));
- }
- if (!dirmode) {
- fgetsx (cs->HardwareLink, zcache);
- lines--;
- fgetsx (cs->HostLink, zcache);
- lines--;
- fgetsx (buf, zcache);
- lines--;
- cs->Type = _tstol (buf);
- if (lines > 0) {
- fgetsx(cs->Artpath, zcache);
- lines--;
- }
- if (lines > 0) {
- fgetsx(cs->Category, zcache);
- addtocategories(cs->Category);
- lines--;
- }
- if (lines > 0) {
- fgetsx(cs->Tags, zcache);
- lines--;
- }
- }
- setconfighosthard (cs);
- if (lines < 0)
- goto end;
- while (lines-- > 0)
- fgetsx (tmp, zcache);
- fgetsx (tmp, zcache);
- if (tmp[0] != ';')
- goto end;
- }
- end:
- if (!feof (zcache))
- err = 1;
- fclose (zcache);
- if (err || first == NULL) {
- write_log (_T("'%s' load failed\n"), cachepath);
- flushconfigcache (cachepath);
- FreeConfigStore ();
- return NULL;
- } else {
- write_log (_T("'%s' loaded successfully\n"), cachepath);
- }
- return first;
- }
- static void writeconfigcacheentry (FILE *zcache, const TCHAR *relpath, struct ConfigStruct *cs)
- {
- TCHAR path2[MAX_DPATH];
- TCHAR lf = 10;
- TCHAR el[] = _T(";\n");
- TCHAR *p;
- ULARGE_INTEGER li;
- GetFullPathName (cs->Fullpath, sizeof path2 / sizeof (TCHAR), path2, NULL);
- if (_tcslen (path2) < _tcslen (relpath))
- return;
- if (_tcsncmp (path2, relpath, _tcslen (relpath)))
- return;
- p = path2 + _tcslen (relpath);
- if (!cs->Directory)
- _tcscat (p, cs->Name);
- fwrite (p, _tcslen (p), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- memcpy (&li, &cs->t, sizeof (ULARGE_INTEGER));
- _stprintf (path2, _T("%I64u"), li.QuadPart);
- fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- fwrite (cs->Name, _tcslen (cs->Name), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- fwrite (cs->Description, _tcslen (cs->Description), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- if (!cs->Directory) {
- fwrite (cs->HardwareLink, _tcslen (cs->HardwareLink), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- fwrite (cs->HostLink, _tcslen (cs->HostLink), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- _stprintf (path2, _T("%d"), cs->Type);
- fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- fwrite(cs->Artpath, _tcslen(cs->Artpath), sizeof(TCHAR), zcache);
- fwrite(&lf, 1, sizeof(TCHAR), zcache);
- fwrite(cs->Category, _tcslen(cs->Category), sizeof(TCHAR), zcache);
- fwrite(&lf, 1, sizeof(TCHAR), zcache);
- fwrite(cs->Tags, _tcslen(cs->Tags), sizeof(TCHAR), zcache);
- fwrite(&lf, 1, sizeof(TCHAR), zcache);
- }
- fwrite (el, _tcslen (el), sizeof (TCHAR), zcache);
- }
- static void writeconfigcacherec (FILE *zcache, const TCHAR *relpath, struct ConfigStruct *cs)
- {
- if (!cs->Directory)
- return;
- writeconfigcacheentry (zcache, relpath, cs);
- for (int i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs2 = configstore[i];
- if (cs2->Parent == cs)
- writeconfigcacherec (zcache, relpath, cs2);
- }
- }
- static void writeconfigcache (const TCHAR *path)
- {
- TCHAR lf = 10;
- FILE *zcache;
- TCHAR cachepath[MAX_DPATH];
- TCHAR path2[MAX_DPATH];
- FILETIME t;
- ULARGE_INTEGER ul;
- SYSTEMTIME st;
- if (!configurationcache)
- return;
- getconfigcache (cachepath, path);
- bool hidden = my_isfilehidden (cachepath);
- my_setfilehidden (cachepath, false);
- zcache = _tfopen (cachepath, _T("w, ccs=UTF-8"));
- if (!zcache)
- return;
- t.dwHighDateTime = t.dwLowDateTime = 0;
- GetSystemTime (&st);
- SystemTimeToFileTime (&st, &t);
- fwrite (configcachever, _tcslen (configcachever), sizeof (TCHAR), zcache);
- fwrite (&lf, 1, sizeof (TCHAR), zcache);
- ul.HighPart = t.dwHighDateTime;
- ul.LowPart = t.dwLowDateTime;
- _stprintf (path2, _T("3\n4\n10\n%I64u\n;\n"), ul.QuadPart);
- fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
- GetFullPathName (path, sizeof path2 / sizeof (TCHAR), path2, NULL);
- for (int i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs = configstore[i];
- if (cs->Directory && cs->Parent == NULL)
- writeconfigcacherec (zcache, path2, cs);
- }
- for (int i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs = configstore[i];
- if (!cs->Directory)
- writeconfigcacheentry (zcache, path2, cs);
- }
- fclose (zcache);
- my_setfilehidden (cachepath, hidden);
- write_log (_T("'%s' created\n"), cachepath);
- }
- static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level, int flushcache)
- {
- DWORD num_bytes = 0;
- TCHAR path[MAX_DPATH];
- TCHAR path2[MAX_DPATH];
- TCHAR shortpath[MAX_DPATH];
- WIN32_FIND_DATA find_data;
- struct ConfigStruct *config, *first;
- HANDLE handle;
- if (*level == 0)
- FreeConfigStore ();
- first = NULL;
- GetConfigPath (path, configparent, FALSE);
- GetConfigPath (shortpath, configparent, TRUE);
- _tcscpy (path2, path);
- _tcsncat (path2, _T("*.*"), MAX_DPATH - _tcslen(path2));
- if (*level == 0) {
- if (flushcache) {
- TCHAR cachepath[MAX_DPATH];
- getconfigcache (cachepath, path);
- flushconfigcache (cachepath);
- }
- first = readconfigcache (path);
- sortcategories();
- if (first)
- return first;
- }
- handle = FindFirstFile (path2, &find_data);
- if (handle == INVALID_HANDLE_VALUE) {
- #ifndef SINGLEFILE
- // Either the directory has no .CFG files, or doesn't exist.
- // Create the directory, even if it already exists. No harm, and don't check return codes, because
- // we may be doing this on a read-only media like CD-ROM.
- if (configparent == NULL) {
- GetConfigPath (path, NULL, FALSE);
- CreateDirectory (path, NULL);
- }
- #endif
- return NULL;
- }
- for (;;) {
- config = NULL;
- if (_tcscmp (find_data.cFileName, _T(".")) && _tcscmp (find_data.cFileName, _T(".."))) {
- int ok = 0;
- config = AllocConfigStruct ();
- _tcscpy (config->Path, shortpath);
- _tcscpy (config->Fullpath, path);
- memcpy (&config->t, &find_data.ftLastWriteTime, sizeof (FILETIME));
- if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && usedirs) {
- if ((*level) < 2) {
- struct ConfigStruct *child;
- _tcscpy (config->Name, find_data.cFileName);
- _tcscpy (config->Path, shortpath);
- _tcscat (config->Path, config->Name);
- _tcscat (config->Path, _T("\\"));
- _tcscpy (config->Fullpath, path);
- _tcscat (config->Fullpath, config->Name);
- _tcscat (config->Fullpath, _T("\\"));
- config->Directory = 1;
- (*level)++;
- config->Parent = configparent;
- setconfighosthard (config);
- child = GetConfigs (config, usedirs, level, FALSE);
- (*level)--;
- if (child)
- config->Child = child;
- ok = 1;
- }
- } else if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- TCHAR path3[MAX_DPATH];
- if (_tcslen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + _tcslen (find_data.cFileName) - 4, _T(".uae"))) {
- _tcscpy (path3, path);
- _tcsncat (path3, find_data.cFileName, MAX_DPATH - _tcslen(path3));
- config->Artpath[0] = 0;
- struct uae_prefs *p = cfgfile_open(path3, &config->Type);
- if (p) {
- cfgfile_get_description(p, NULL, config->Description, config->Category, config->Tags, config->HostLink, config->HardwareLink, NULL);
- _tcscpy(config->Name, find_data.cFileName);
- if (artcache) {
- cfgfile_detect_art(p, config->Artpath);
- }
- addtocategories(config->Category);
- cfgfile_close(p);
- ok = 1;
- }
- }
- }
- if (!ok) {
- FreeConfigStruct (config);
- config = NULL;
- }
- }
- if (config) {
- if (configparent) {
- config->host = configparent->host;
- config->hardware = configparent->hardware;
- }
- config->Parent = configparent;
- if (configstore == NULL || configstoreallocated == configstoresize) {
- configstoreallocated += 100;
- configstore = xrealloc(struct ConfigStruct*, configstore, configstoreallocated);
- }
- configstore[configstoresize++] = config;
- if (first == NULL)
- first = config;
- }
- if (FindNextFile (handle, &find_data) == 0) {
- FindClose(handle);
- break;
- }
- }
- if (*level == 0 && CONFIGCACHE)
- writeconfigcache (path);
- sortcategories();
- return first;
- }
- static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig, int flushcache)
- {
- int level;
- TCHAR path[MAX_DPATH], name[MAX_DPATH];
- struct ConfigStruct *cs;
- if (oldconfig) {
- _tcscpy (path, oldconfig->Path);
- _tcscpy (name, oldconfig->Name);
- }
- level = 0;
- GetConfigs (NULL, 1, &level, flushcache);
- if (oldconfig) {
- for (int i = 0; i < configstoresize; i++) {
- cs = configstore[i];
- if (!cs->Directory && !_tcscmp (path, cs->Path) && !_tcscmp (name, cs->Name))
- return cs;
- }
- }
- return 0;
- }
- static TCHAR *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *config, TCHAR *newpath)
- {
- TCHAR name[MAX_DPATH], desc[MAX_DPATH];
- TCHAR path[MAX_DPATH];
- static TCHAR full_path[MAX_DPATH];
- int ok = 1;
- bool absolutepath = false;
- full_path[0] = 0;
- name[0] = 0;
- desc[0] = 0;
- config_pathfilename[0] = 0;
- GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH);
- if ((name[0] == '\\' && name[1] == '\\') || (_istalpha(name[0]) && name[1] == ':'))
- absolutepath = true;
- _tcscpy (config_filename, name);
- if (flag == CONFIG_SAVE_FULL || flag == CONFIG_SAVE) {
- if (_tcslen (name) < 4 || strcasecmp (name + _tcslen (name) - 4, _T(".uae"))) {
- _tcscat (name, _T(".uae"));
- SetDlgItemText (hDlg, IDC_EDITNAME, name);
- }
- if (config && !absolutepath)
- _tcscpy (config->Name, name);
- }
- GetDlgItemText (hDlg, IDC_EDITDESCRIPTION, desc, MAX_DPATH);
- if (config) {
- _tcscpy (path, config->Fullpath);
- _tcscat(config_pathfilename, config->Path);
- _tcscat(config_pathfilename, config->Name);
- _tcsncat(path, name, MAX_DPATH - _tcslen(path));
- } else {
- if (absolutepath) {
- _tcscpy(path, name);
- } else {
- fetch_configurationpath(path, sizeof(path) / sizeof(TCHAR));
- _tcsncat(path, name, MAX_DPATH - _tcslen(path));
- }
- TCHAR fname[MAX_DPATH];
- getfilepart(fname, sizeof fname / sizeof(TCHAR), name);
- SetDlgItemText(hDlg, IDC_EDITNAME, fname);
- }
- _tcscpy (full_path, path);
- if (!config_pathfilename[0]) {
- _tcscat(config_pathfilename, full_path);
- }
- switch (flag)
- {
- case CONFIG_SAVE_FULL:
- ok = DiskSelection(hDlg, IDC_SAVE, 5, &workprefs, NULL, newpath);
- GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH);
- _tcscpy(config_filename, name);
- _tcscpy(config_pathfilename, name);
- break;
- case CONFIG_LOAD_FULL:
- if ((ok = DiskSelection(hDlg, IDC_LOAD, 4, &workprefs, NULL, newpath))) {
- EnableWindow(GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]);
- GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH);
- _tcscpy(config_filename, name);
- _tcscpy(config_pathfilename, name);
- }
- break;
- case CONFIG_SAVE:
- if (_tcslen (name) == 0 || _tcscmp (name, _T(".uae")) == 0) {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString(IDS_MUSTENTERNAME, szMessage, MAX_DPATH);
- pre_gui_message (szMessage);
- } else if (cfgfile_can_write(hDlg, path)) {
- _tcscpy (workprefs.description, desc);
- cfgfile_save (&workprefs, path, configtypepanel);
- }
- break;
- case CONFIG_LOAD:
- if (_tcslen (name) == 0) {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString (IDS_MUSTSELECTCONFIG, szMessage, MAX_DPATH);
- pre_gui_message (szMessage);
- } else {
- if (target_cfgfile_load (&workprefs, path, configtypepanel, 0) == 0) {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH);
- pre_gui_message (szMessage);
- config_filename[0] = 0;
- ok = 0;
- } else {
- ew (hDlg, IDC_VIEWINFO, workprefs.info[0]);
- }
- }
- break;
- case CONFIG_DELETE:
- {
- TCHAR szMessage[MAX_DPATH];
- TCHAR szTitle[MAX_DPATH];
- TCHAR msg[MAX_DPATH];
- WIN32GUI_LoadUIString(IDS_DELETECONFIGTITLE, szTitle, MAX_DPATH);
- ok = 0;
- if (name[0] == 0) {
- if (config && config->Fullpath[0]) {
- // directory selected
- bool allowdelete = false;
- TCHAR fp[MAX_DPATH];
- _tcscpy(fp, config->Fullpath);
- _tcscat(fp, _T("*"));
- WIN32_FIND_DATA fd;
- HANDLE h = FindFirstFile(fp, &fd);
- if (h != INVALID_HANDLE_VALUE) {
- allowdelete = true;
- for (;;) {
- if (fd.cFileName[0] != '.' || !(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- allowdelete = false;
- }
- if (!FindNextFile(h, &fd))
- break;
- }
- FindClose(h);
- }
- if (allowdelete) {
- WIN32GUI_LoadUIString(IDS_DELETECONFIGDIRCONFIRMATION, szMessage, MAX_DPATH);
- TCHAR fp[MAX_DPATH];
- _tcscpy(fp, config->Fullpath);
- fp[_tcslen(fp) - 1] = 0;
- _stprintf(msg, szMessage, fp);
- if (MessageBox(hDlg, msg, szTitle,
- MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
- if (RemoveDirectory(fp)) {
- write_log(_T("deleted config directory '%s'\n"), fp);
- config_filename[0] = 0;
- ok = 1;
- }
- }
- } else {
- WIN32GUI_LoadUIString(IDS_DELETECONFIGDIRNOTEMPTY, szMessage, MAX_DPATH);
- MessageBox(hDlg, szMessage, szTitle, MB_OK | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND);
- }
- } else {
- TCHAR szMessage[MAX_DPATH];
- WIN32GUI_LoadUIString(IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH);
- pre_gui_message(szMessage);
- }
- } else {
- // config file selected
- WIN32GUI_LoadUIString(IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_DPATH);
- _stprintf(msg, szMessage, name);
- if (MessageBox(hDlg, msg, szTitle,
- MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
- cfgfile_backup(path);
- if (DeleteFile(path)) {
- write_log(_T("deleted config '%s'\n"), path);
- config_filename[0] = 0;
- ok = 1;
- } else {
- write_log(_T("deleted config '%s' returned %x\n"), path, GetLastError());
- if (!my_existsfile(path)) {
- write_log(_T("deleted config '%s'\n"), path);
- config_filename[0] = 0;
- ok = 1;
- }
- }
- }
- }
- config_pathfilename[0] = 0;
- }
- break;
- }
- setguititle (NULL);
- return ok ? full_path : NULL;
- }
- static int disk_in_drive (int entry)
- {
- int i;
- for (i = 0; i < 4; i++) {
- if (_tcslen (workprefs.dfxlist[entry]) > 0 && !_tcscmp (workprefs.dfxlist[entry], workprefs.floppyslots[i].df))
- return i;
- }
- return -1;
- }
- static int disk_swap (int entry, int mode)
- {
- int drv, i, drvs[4] = { -1, -1, -1, -1 };
- for (i = 0; i < MAX_SPARE_DRIVES; i++) {
- drv = disk_in_drive (i);
- if (drv >= 0)
- drvs[drv] = i;
- }
- if ((drv = disk_in_drive (entry)) >= 0) {
- if (mode < 0) {
- workprefs.floppyslots[drv].df[0] = 0;
- return 1;
- }
- if (_tcscmp (workprefs.floppyslots[drv].df, currprefs.floppyslots[drv].df)) {
- _tcscpy (workprefs.floppyslots[drv].df, currprefs.floppyslots[drv].df);
- disk_insert (drv, workprefs.floppyslots[drv].df);
- } else {
- workprefs.floppyslots[drv].df[0] = 0;
- }
- if (drvs[0] < 0 || drvs[1] < 0 || drvs[2] < 0 || drvs[3] < 0) {
- drv++;
- while (drv < 4 && drvs[drv] >= 0)
- drv++;
- if (drv < 4 && workprefs.floppyslots[drv].dfxtype >= 0) {
- _tcscpy (workprefs.floppyslots[drv].df, workprefs.dfxlist[entry]);
- disk_insert (drv, workprefs.floppyslots[drv].df);
- }
- }
- return 1;
- }
- for (i = 0; i < 4; i++) {
- if (drvs[i] < 0 && workprefs.floppyslots[i].dfxtype >= 0) {
- _tcscpy (workprefs.floppyslots[i].df, workprefs.dfxlist[entry]);
- disk_insert (i, workprefs.floppyslots[i].df);
- return 1;
- }
- }
- _tcscpy (workprefs.floppyslots[0].df, workprefs.dfxlist[entry]);
- disk_insert (0, workprefs.floppyslots[0].df);
- return 1;
- }
- static int input_selected_device = -1;
- static int input_selected_widget, input_total_devices;
- static int input_selected_event, input_selected_sub_num;
- static int input_copy_from;
- struct remapcustoms_s
- {
- uae_u64 flags;
- uae_u64 mask;
- const TCHAR *name;
- };
- static struct remapcustoms_s remapcustoms[] =
- {
- { 0, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
- NULL },
- { IDEV_MAPPED_AUTOFIRE_SET, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
- NULL },
- { IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
- NULL },
- { IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_INVERTTOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
- NULL },
- { NULL }
- };
- static void getqualifiername (TCHAR *p, uae_u64 mask)
- {
- *p = 0;
- if (mask == IDEV_MAPPED_QUALIFIER_SPECIAL) {
- _tcscpy (p, _T("*"));
- } else if (mask == (IDEV_MAPPED_QUALIFIER_SPECIAL << 1)) {
- _tcscpy (p, _T("* [R]"));
- } else if (mask == IDEV_MAPPED_QUALIFIER_SHIFT) {
- _tcscpy (p, _T("Shift"));
- } else if (mask == (IDEV_MAPPED_QUALIFIER_SHIFT << 1)) {
- _tcscpy (p, _T("Shift [R]"));
- } else if (mask == IDEV_MAPPED_QUALIFIER_CONTROL) {
- _tcscpy (p, _T("Ctrl"));
- } else if (mask == (IDEV_MAPPED_QUALIFIER_CONTROL << 1)) {
- _tcscpy (p, _T("Ctrl [R]"));
- } else if (mask == IDEV_MAPPED_QUALIFIER_ALT) {
- _tcscpy (p, _T("Alt"));
- } else if (mask == (IDEV_MAPPED_QUALIFIER_ALT << 1)) {
- _tcscpy (p, _T("Alt [R]"));
- } else if (mask == IDEV_MAPPED_QUALIFIER_WIN) {
- _tcscpy (p, _T("Win"));
- } else if (mask == (IDEV_MAPPED_QUALIFIER_WIN << 1)) {
- _tcscpy (p, _T("Win [R]"));
- } else {
- int j;
- uae_u64 i;
- for (i = IDEV_MAPPED_QUALIFIER1, j = 0; i <= (IDEV_MAPPED_QUALIFIER8 << 1); i <<= 1, j++) {
- if (i == mask) {
- _stprintf (p, _T("%d%s"), j / 2 + 1, (j & 1) ? _T(" [R]") : _T(""));
- }
- }
- }
- }
- static int input_get_lv_index(HWND list, int index)
- {
- LVFINDINFO plvfi = { 0 };
- plvfi.flags = LVFI_PARAM;
- plvfi.lParam = index;
- return ListView_FindItem(list, -1, &plvfi);
- }
- static void set_lventry_input (HWND list, int index)
- {
- int i, sub, port;
- TCHAR name[256];
- TCHAR custom[MAX_DPATH];
- TCHAR af[32], toggle[32], invert[32];
- uae_u64 flags;
- int itemindex = input_get_lv_index(list, index);
- inputdevice_get_mapping (input_selected_device, index, &flags, &port, name, custom, input_selected_sub_num);
- if (flags & IDEV_MAPPED_AUTOFIRE_SET) {
- if (flags & IDEV_MAPPED_INVERTTOGGLE)
- WIN32GUI_LoadUIString (IDS_ON, af, sizeof af / sizeof (TCHAR));
- else
- WIN32GUI_LoadUIString (IDS_YES, af, sizeof af / sizeof (TCHAR));
- } else if (flags & IDEV_MAPPED_AUTOFIRE_POSSIBLE) {
- WIN32GUI_LoadUIString (IDS_NO, af, sizeof af / sizeof (TCHAR));
- } else {
- _tcscpy (af, _T("-"));
- }
- if (flags & IDEV_MAPPED_TOGGLE) {
- WIN32GUI_LoadUIString (IDS_YES, toggle, sizeof toggle / sizeof (TCHAR));
- inputdevice_get_mapping(input_selected_device, index, &flags, &port, name, custom, input_selected_sub_num);
- } else if (flags & IDEV_MAPPED_AUTOFIRE_POSSIBLE)
- WIN32GUI_LoadUIString (IDS_NO, toggle, sizeof toggle / sizeof (TCHAR));
- else
- _tcscpy (toggle, _T("-"));
- if (port > 0) {
- TCHAR tmp[256];
- _tcscpy (tmp, name);
- _stprintf (name, _T("[PORT%d] %s"), port, tmp);
- }
- _tcscpy (invert, _T("-"));
- if (flags & IDEV_MAPPED_INVERT)
- WIN32GUI_LoadUIString (IDS_YES, invert, sizeof invert / sizeof (TCHAR));
- if (flags & IDEV_MAPPED_SET_ONOFF) {
- _tcscat (name, _T(" ("));
- TCHAR val[32];
- if ((flags & (IDEV_MAPPED_SET_ONOFF_VAL1 | IDEV_MAPPED_SET_ONOFF_VAL2)) == (IDEV_MAPPED_SET_ONOFF_VAL1 | IDEV_MAPPED_SET_ONOFF_VAL2)) {
- _tcscpy(val, _T("onoff"));
- } else if (flags & IDEV_MAPPED_SET_ONOFF_VAL2) {
- _tcscpy(val, _T("press"));
- } else if (flags & IDEV_MAPPED_SET_ONOFF_VAL1) {
- WIN32GUI_LoadUIString (IDS_ON, val, sizeof val / sizeof (TCHAR));
- } else {
- WIN32GUI_LoadUIString (IDS_OFF, val, sizeof val / sizeof (TCHAR));
- }
- _tcscat (name, val);
- _tcscat (name, _T(")"));
- }
-
- ListView_SetItemText (list, itemindex, 1, custom[0] ? custom : name);
- ListView_SetItemText (list, itemindex, 2, af);
- ListView_SetItemText (list, itemindex, 3, toggle);
- ListView_SetItemText (list, itemindex, 4, invert);
- _tcscpy (name, _T("-"));
- if (flags & IDEV_MAPPED_QUALIFIER_MASK) {
- TCHAR *p;
- p = name;
- for (i = 0; i < MAX_INPUT_QUALIFIERS * 2; i++) {
- uae_u64 mask = IDEV_MAPPED_QUALIFIER1 << i;
- if (flags & mask) {
- if (p != name)
- *p++ = ',';
- getqualifiername (p, mask);
- p += _tcslen (p);
- }
- }
- }
- ListView_SetItemText (list, itemindex, 5, name);
- sub = 0;
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
- if (inputdevice_get_mapping (input_selected_device, index, &flags, NULL, name, custom, i) || custom[0])
- sub++;
- }
- _stprintf (name, _T("%d"), sub);
- ListView_SetItemText (list, itemindex, 6, name);
- }
- static void update_listview_input (HWND hDlg)
- {
- int i;
- if (!input_total_devices)
- return;
- for (i = 0; i < inputdevice_get_widget_num(input_selected_device); i++) {
- set_lventry_input(GetDlgItem(hDlg, IDC_INPUTLIST), i);
- }
- }
- static int inputmap_port = -1, inputmap_port_remap = -1;
- static int inputmap_groupindex[MAX_COMPA_INPUTLIST + 1];
- static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum,
- int *inputmap_portp, int *inputmap_indexp,
- int state, int *inputmap_itemindexp, int deleteindex, uae_u64 flags_or, uae_u64 flags_and, uae_u64 *inputmap_flagsp)
- {
- int cntitem, cntgroup, portnum;
- int mode;
- const int *axistable;
- bool found2 = false;
- for (portnum = 0; portnum < 4; portnum++) {
- if (list)
- portnum = inputmap_port;
- cntitem = 1;
- cntgroup = 1;
- int events[MAX_COMPA_INPUTLIST];
- if (inputdevice_get_compatibility_input (&workprefs, portnum, &mode, events, &axistable) > 0) {
- int evtnum;
- for (int i = 0; (evtnum = events[i]) >= 0; i++) {
- const struct inputevent *evt = inputdevice_get_eventinfo (evtnum);
- LV_ITEM lvstruct = { 0 };
- int devnum;
- int status;
- TCHAR name[256];
- const int *atp = axistable;
- int atpidx;
- int item;
- bool found = false;
- uae_u64 flags;
- if (list) {
- LVGROUP group = { 0 };
- group.cbSize = sizeof (LVGROUP);
- group.mask = LVGF_HEADER | LVGF_GROUPID;
- group.pszHeader = (TCHAR*)evt->name;
- group.iGroupId = cntgroup;
- ListView_InsertGroup (list, -1, &group);
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID;
- lvstruct.lParam = 0;
- lvstruct.iSubItem = 0;
- lvstruct.iGroupId = cntgroup;
- if (inputmap_itemindexp) {
- inputmap_itemindexp[cntgroup - 1] = -1;
- inputmap_itemindexp[cntgroup - 1 + 1] = -1;
- }
- }
- atpidx = 0;
- while (*atp >= 0) {
- if (*atp == evtnum) {
- atp++;
- atpidx = 2;
- break;
- }
- if (atp[1] == evtnum || atp[2] == evtnum) {
- atpidx = 1;
- break;
- }
- atp += 3;
- }
- while (atpidx >= 0) {
- devnum = 0;
- while ((status = inputdevice_get_device_status (devnum)) >= 0) {
- if ((1 || status)) {
- for (int j = 0; j < inputdevice_get_widget_num (devnum); j++) {
- for (int sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
- int port;
- int evtnum2 = inputdevice_get_mapping (devnum, j, &flags, &port, name, NULL, sub);
- if (evtnum2 == evtnum) {
- if (port - 1 != portnum)
- continue;
- if (cntitem - 1 == deleteindex) {
- if (!flags_or && !flags_and && !inputmap_flagsp) {
- inputdevice_set_mapping (devnum, j, NULL, NULL, 0, 0, sub);
- deleteindex = -1;
- found = true;
- continue;
- } else {
- if (flags_or || flags_and) {
- flags &= ~flags_and;
- flags |= flags_or;
- inputdevice_set_mapping(devnum, j, name, NULL, flags, port, sub);
- } else {
- *inputmap_flagsp = flags;
- }
- found = true;
- found2 = true;
- }
- }
- if (list) {
- inputdevice_get_widget_type (devnum, j, name, false);
- TCHAR target[MAX_DPATH];
- _tcscpy (target, name);
- _tcscat (target, _T(", "));
- _tcscat (target, inputdevice_get_device_name2 (devnum));
- if (flags & IDEV_MAPPED_AUTOFIRE_SET) {
- _tcscat(target, _T(" ["));
- if (flags & IDEV_MAPPED_TOGGLE)
- _tcscat(target, remapcustoms[2].name);
- else if (flags & IDEV_MAPPED_INVERTTOGGLE)
- _tcscat(target, remapcustoms[3].name);
- else
- _tcscat(target, remapcustoms[1].name);
- _tcscat(target, _T("]"));
- }
- lvstruct.pszText = target;
- lvstruct.iItem = cntgroup * 256 + cntitem;
- item = ListView_InsertItem(list, &lvstruct);
- if (inputmap_itemindexp && inputmap_itemindexp[cntgroup - 1] < 0)
- inputmap_itemindexp[cntgroup - 1] = item;
- } else if (currentdevnum == devnum && currentwidgetnum == j) {
- if (inputmap_portp)
- *inputmap_portp = portnum;
- if (inputmap_indexp)
- *inputmap_indexp = cntitem - 1;
- found2 = true;
- if (state < 0)
- return 1;
- state = -1;
- }
- cntitem++;
- found = true;
- }
- }
- }
- }
- devnum++;
- }
- evtnum = *atp++;
- atpidx--;
- }
- if (!found) {
- if (list) {
- lvstruct.pszText = _T("");
- lvstruct.iItem = cntgroup * 256 + cntitem;
- lvstruct.lParam = cntgroup;
- item = ListView_InsertItem (list, &lvstruct);
- if (inputmap_itemindexp && inputmap_itemindexp[cntgroup - 1] < 0)
- inputmap_itemindexp[cntgroup - 1] = item;
- }
- cntitem++;
- }
- cntgroup++;
- }
- }
- if (list)
- break;
- }
- if (found2)
- return 1;
- return 0;
- }
- static void update_listview_inputmap (HWND hDlg, int deleteindex)
- {
- HWND list = GetDlgItem (hDlg, IDC_INPUTMAPLIST);
- ListView_EnableGroupView (list, TRUE);
- inputmap_handle (list, -1, -1, NULL, NULL, 0, inputmap_groupindex, deleteindex, 0, 0, NULL);
- }
- static int clicked_entry = -1;
- #define LOADSAVE_COLUMNS 2
- #define INPUT_COLUMNS 7
- #define HARDDISK_COLUMNS 8
- #define DISK_COLUMNS 3
- #define MISC2_COLUMNS 2
- #define INPUTMAP_COLUMNS 1
- #define MISC1_COLUMNS 1
- #define MAX_COLUMN_HEADING_WIDTH 20
- #define CD_COLUMNS 3
- #define BOARD_COLUMNS 5
- #define LV_LOADSAVE 1
- #define LV_HARDDISK 2
- #define LV_INPUT 3
- #define LV_DISK 4
- #define LV_MISC2 5
- #define LV_INPUTMAP 6
- #define LV_MISC1 7
- #define LV_CD 8
- #define LV_BOARD 9
- #define LV_MAX 10
- static int lv_oldidx[LV_MAX];
- static int lv_old_type = -1;
- static int listview_num_columns;
- struct miscentry
- {
- int type;
- int canactive;
- const TCHAR *name;
- bool *b;
- int *i;
- int ival, imask;
- };
- static bool win32_middle_mouse_obsolete;
- static const struct miscentry misclist[] = {
- { 0, 1, _T("Untrap = middle button"), &win32_middle_mouse_obsolete },
- { 0, 0, _T("Show GUI on startup"), &workprefs.start_gui },
- { 0, 1, _T("Use CTRL-F11 to quit"), &workprefs.win32_ctrl_F11_is_quit },
- { 0, 1, _T("Don't show taskbar button"), &workprefs.win32_notaskbarbutton },
- { 0, 1, _T("Don't show notification icon"), &workprefs.win32_nonotificationicon },
- { 0, 1, _T("Emulator window always on top"), &workprefs.win32_main_alwaysontop },
- { 0, 1, _T("GUI window always on top"), &workprefs.win32_gui_alwaysontop },
- { 0, 1, _T("Disable screensaver"), &workprefs.win32_powersavedisabled },
- { 0, 0, _T("Synchronize clock"), &workprefs.tod_hack },
- { 0, 1, _T("One second reboot pause"), &workprefs.reset_delay },
- { 0, 1, _T("Faster RTG"), &workprefs.picasso96_nocustom },
- { 0, 0, _T("Clipboard sharing"), &workprefs.clipboard_sharing },
- { 0, 1, _T("Allow native code"), &workprefs.native_code },
- { 0, 1, _T("Native on-screen display"), NULL, &workprefs.leds_on_screen, STATUSLINE_CHIPSET, STATUSLINE_CHIPSET },
- { 0, 1, _T("RTG on-screen display"), NULL, &workprefs.leds_on_screen, STATUSLINE_RTG, STATUSLINE_RTG },
- { 0, 0, _T("Create winuaelog.txt log"), &workprefs.win32_logfile },
- { 0, 1, _T("Log illegal memory accesses"), &workprefs.illegal_mem },
- { 0, 0, _T("Blank unused displays"), &workprefs.win32_blankmonitors },
- { 0, 0, _T("Start mouse uncaptured"), &workprefs.win32_start_uncaptured },
- { 0, 0, _T("Start minimized"), &workprefs.win32_start_minimized },
- { 0, 1, _T("Minimize when focus is lost"), &workprefs.win32_minimize_inactive },
- { 0, 1, _T("100/120Hz VSync black frame insertion"), &workprefs.lightboost_strobo },
- { 0, 0, _T("Master floppy write protection"), &workprefs.floppy_read_only },
- { 0, 0, _T("Master harddrive write protection"), &workprefs.harddrive_read_only },
- { 0, 0, _T("Hide all UAE autoconfig boards"), &workprefs.uae_hide_autoconfig },
- { 0, 1, _T("Right Control = Right Windows key"), &workprefs.right_control_is_right_win_key },
- { 0, 0, _T("Windows shutdown/logoff notification"), &workprefs.win32_shutdown_notification },
- { 0, 1, _T("Warn when attempting to close window"), &workprefs.win32_warn_exit },
- { 0, 1, _T("Power led dims when audio filter is disabled"), NULL, &workprefs.power_led_dim, 128, 255 },
- { 0, 1, _T("Automatically capture mouse when window is activated"), &workprefs.win32_capture_always },
- { 0, 0, _T("Debug memory space"), &workprefs.debug_mem },
- { 0, 1, _T("Force hard reset if CPU halted"), &workprefs.crash_auto_reset },
- { 0, 0, NULL }
- };
- static void harddisktype (TCHAR *s, struct uaedev_config_info *ci)
- {
- switch (ci->type)
- {
- case UAEDEV_CD:
- _tcscpy (s, _T("CD"));
- break;
- case UAEDEV_TAPE:
- _tcscpy (s, _T("TAPE"));
- break;
- case UAEDEV_HDF:
- _tcscpy (s, _T("HDF"));
- break;
- default:
- _tcscpy (s, _T("n/a"));
- break;
- }
- }
- #define MAX_LISTVIEW_COLUMNS 16
- static int listview_id;
- static int listview_type;
- static int listview_columns;
- static int listview_sortdir, listview_sortcolumn;
- static int listview_column_widths[MAX_LISTVIEW_COLUMNS];
- struct lvsort
- {
- TCHAR **names;
- int max;
- int sortcolumn;
- int sortdir;
- };
- static int CALLBACK lvsortcompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
- {
- struct lvsort *lvs = (struct lvsort*)lParamSort;
- if (lParam1 >= lvs->max || lParam2 >= lvs->max)
- return -1;
- TCHAR *s1, *s2;
- if (lvs->sortdir) {
- s2 = lvs->names[lParam1];
- s1 = lvs->names[lParam2];
- } else {
- s1 = lvs->names[lParam1];
- s2 = lvs->names[lParam2];
- }
- return _tcsicmp(s1, s2);
- }
- static void SortListView(HWND list, int sortcolumn, int dir)
- {
- int cnt;
- struct lvsort lvs;
- TCHAR **names;
- TCHAR buf[256];
- cnt = ListView_GetItemCount(list);
- names = xmalloc(TCHAR*, cnt);
- for (int i = 0; i < cnt; i++) {
- LVITEM item = { 0 };
- item.iItem = i;
- item.iSubItem = sortcolumn;
- item.mask = LVIF_TEXT;
- item.pszText = buf;
- item.cchTextMax = sizeof(buf) / sizeof(TCHAR);
- ListView_GetItem(list, &item);
- names[i] = my_strdup(item.pszText);
- }
- lvs.sortcolumn = sortcolumn;
- lvs.max = cnt;
- lvs.sortdir = dir;
- lvs.names = names;
- ListView_SortItemsEx(list, lvsortcompare, &lvs);
- for (int i = 0; i < cnt; i++) {
- xfree(names[i]);
- }
- xfree(names);
- ListView_SetSelectedColumn(list, sortcolumn);
- }
- static void SaveListView(HWND hDlg, bool force)
- {
- HWND list;
- TCHAR name[200];
- TCHAR data[256];
- int columns[100];
- int sortcolumn;
- UAEREG *fkey;
- if (listview_id <= 0)
- return;
- list = GetDlgItem(hDlg, listview_id);
- if (!list)
- return;
- fkey = regcreatetree(NULL, _T("ListViews"));
- if (!fkey)
- return;
- _stprintf(name, _T("LV_%d"), listview_type);
- if (!force) {
- bool modified = false;
- for (int i = 0; i < listview_num_columns; i++) {
- int w = ListView_GetColumnWidth(list, i);
- if (listview_column_widths[i] != w) {
- modified = true;
- }
- }
- if (!regexists(fkey, name) && !modified)
- return;
- }
- _tcscpy(data, _T("1,"));
- ListView_GetColumnOrderArray(list, listview_columns, columns);
- sortcolumn = ListView_GetSelectedColumn(list);
- for (int i = 0; i < listview_columns; i++) {
- int w = ListView_GetColumnWidth(list, i);
- if (i > 0)
- _tcscat(data, _T(","));
- _stprintf(data + _tcslen(data), _T("%d:%d"), columns[i], w);
- if (sortcolumn == columns[i]) {
- _tcscat(data, listview_sortdir ? _T(":D") : _T(":A"));
- }
- }
- regsetstr(fkey, name, data);
- regclosetree(fkey);
- }
- static bool LoadListView(HWND list)
- {
- TCHAR name[200];
- TCHAR data[256];
- int columns[100], columnorders[100];
- int size;
- UAEREG *fkey;
- bool err = true;
- int sortindex = 0;
- listview_sortcolumn = -1;
- fkey = regcreatetree(NULL, _T("ListViews"));
- if (!fkey)
- return false;
- _stprintf(name, _T("LV_%d"), listview_type);
- size = sizeof(data) / sizeof(TCHAR) - 1;
- if (regquerystr(fkey, name, data, &size)) {
- _tcscat(data, _T(","));
- TCHAR *p1 = data;
- int idx = -1;
- for (;;) {
- TCHAR *p2 = _tcschr(p1, ',');
- if (!p2) {
- if (idx == listview_columns)
- err = false;
- break;
- }
- *p2++ = 0;
- int v = _tstol(p1);
- if (idx < 0) {
- if (v != 1) {
- break;
- }
- } else {
- TCHAR *p3 = _tcschr(p1, ':');
- if (!p3)
- break;
- *p3++ = 0;
- if (v < 0 || v >= listview_columns)
- break;
- int w = _tstol(p3);
- if (w < 1 || w >= 4096)
- break;
- columnorders[idx] = v;
- columns[idx] = w;
- p3 = _tcschr(p3, ':');
- if (p3) {
- p3++;
- if (*p3 == 'A') {
- sortindex = 1 + v;
- } else if (*p3 == 'D') {
- sortindex = -1 - v;
- }
- }
- }
- idx++;
- if (idx > listview_columns) {
- break;
- }
- p1 = p2;
- }
- if (!err) {
- for (int i = 0; i < listview_columns; i++) {
- ListView_SetColumnWidth(list, i, columns[i]);
- }
- if (columnorders) {
- ListView_SetColumnOrderArray(list, listview_columns, columnorders);
- }
- if (sortindex && listview_sortdir >= 0) {
- SortListView(list, abs(sortindex) - 1, sortindex < 0);
- listview_sortdir = sortindex < 0;
- }
- }
- }
- regclosetree(fkey);
- return !err;
- }
- static void ColumnClickListView(HWND hDlg, NM_LISTVIEW *lv)
- {
- LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lv;
- HWND list = pnmv->hdr.hwndFrom;
- int column = pnmv->iSubItem;
- int sortcolumn = ListView_GetSelectedColumn(list);
- if (sortcolumn < 0 || sortcolumn != listview_sortcolumn || listview_sortdir < 0) {
- listview_sortdir = 0;
- } else {
- listview_sortdir++;
- }
- listview_sortcolumn = column;
- if (listview_sortdir > 1) {
- listview_sortdir = -1;
- ListView_SetSelectedColumn(list, -1);
- InitializeListView(hDlg);
- } else {
- SortListView(list, column, listview_sortdir);
- SaveListView(hDlg, true);
- }
- }
- static void ResetListViews(void)
- {
- UAEREG *fkey = regcreatetree(NULL, _T("ListViews"));
- if (!fkey)
- return;
- for (int i = 0; i < LV_MAX; i++) {
- TCHAR name[256];
- _stprintf(name, _T("LV_%d"), i);
- regdelete(fkey, name);
- }
- regclosetree(fkey);
- }
- static void InitializeListView (HWND hDlg)
- {
- int lv_type;
- HWND list;
- LV_ITEM lvstruct;
- LV_COLUMN lvcolumn;
- RECT rect;
- TCHAR column_heading[HARDDISK_COLUMNS][MAX_COLUMN_HEADING_WIDTH];
- TCHAR blocksize_str[6] = _T("");
- TCHAR readwrite_str[10] = _T("");
- TCHAR size_str[32] = _T("");
- TCHAR volname_str[MAX_DPATH] = _T("");
- TCHAR devname_str[MAX_DPATH] = _T("");
- TCHAR bootpri_str[6] = _T("");
- int width = 0;
- int items = 0, result = 0, i, j, entry = 0, temp = 0;
- TCHAR tmp[10], tmp2[MAX_DPATH];
- int listview_column_width[HARDDISK_COLUMNS];
- DWORD extraflags = 0;
- int listpadding;
- int dpi = getdpiforwindow(hDlg);
- if (cachedlist) {
- if (lv_old_type >= 0) {
- lv_oldidx[lv_old_type] = ListView_GetTopIndex (cachedlist);
- lv_oldidx[lv_old_type] += ListView_GetCountPerPage (cachedlist) - 1;
- }
- cachedlist = NULL;
- }
- if (hDlg == pages[BOARD_ID]) {
- listview_id = IDC_BOARDLIST;
- listview_num_columns = BOARD_COLUMNS;;
- lv_type = LV_BOARD;
- _tcscpy(column_heading[0], _T("Type"));
- _tcscpy(column_heading[1], _T("Name"));
- _tcscpy(column_heading[2], _T("Start"));
- _tcscpy(column_heading[3], _T("Size"));
- _tcscpy(column_heading[4], _T("ID"));
- } else if (hDlg == pages[HARDDISK_ID]) {
- listview_id = IDC_VOLUMELIST;
- listview_num_columns = HARDDISK_COLUMNS;
- lv_type = LV_HARDDISK;
- _tcscpy (column_heading[0], _T("*"));
- WIN32GUI_LoadUIString (IDS_DEVICE, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_VOLUME, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_PATH, column_heading[3], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_RW, column_heading[4], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_BLOCKSIZE, column_heading[5], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_HFDSIZE, column_heading[6], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_BOOTPRI, column_heading[7], MAX_COLUMN_HEADING_WIDTH);
- } else if (hDlg == pages[INPUT_ID]) {
- listview_id = IDC_INPUTLIST;
- listview_num_columns = INPUT_COLUMNS;
- lv_type = LV_INPUT;
- WIN32GUI_LoadUIString (IDS_INPUTHOSTWIDGET, column_heading[0], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_INPUTAMIGAEVENT, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_INPUTAUTOFIRE, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_INPUTTOGGLE, column_heading[3], MAX_COLUMN_HEADING_WIDTH);
- _tcscpy (column_heading[4], _T("Invert"));
- WIN32GUI_LoadUIString (IDS_INPUTQUALIFIER, column_heading[5], MAX_COLUMN_HEADING_WIDTH);
- _tcscpy (column_heading[6], _T("#"));
- } else if (hDlg == pages[INPUTMAP_ID]) {
- listview_id = IDC_INPUTMAPLIST;
- listview_num_columns = INPUTMAP_COLUMNS;
- lv_type = LV_INPUTMAP;
- column_heading[0][0] = 0;
- } else if (hDlg == pages[MISC2_ID]) {
- listview_id = IDC_ASSOCIATELIST;
- listview_num_columns = MISC2_COLUMNS;
- lv_type = LV_MISC2;
- _tcscpy (column_heading[0], _T("Extension"));
- _tcscpy (column_heading[1], _T(""));
- } else if (hDlg == pages[MISC1_ID]) {
- listview_id = IDC_MISCLIST;
- listview_num_columns = MISC1_COLUMNS;
- lv_type = LV_MISC1;
- column_heading[0][0] = 0;
- extraflags = LVS_EX_CHECKBOXES;
- } else if (hDlg == pages[DISK_ID]) {
- listview_id = IDC_DISK;
- listview_num_columns = DISK_COLUMNS;
- lv_type = LV_DISK;
- _tcscpy (column_heading[0], _T("#"));
- WIN32GUI_LoadUIString (IDS_DISK_IMAGENAME, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_DISK_DRIVENAME, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
- } else {
- // CD dialog
- listview_id = IDC_CDLIST;
- listview_num_columns = CD_COLUMNS;
- lv_type = LV_CD;
- _tcscpy (column_heading[0], _T("*"));
- WIN32GUI_LoadUIString (IDS_DEVICE, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
- WIN32GUI_LoadUIString (IDS_PATH, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
- }
- list = GetDlgItem(hDlg, listview_id);
- listview_type = lv_type;
- listview_columns = listview_num_columns;
- SetWindowRedraw(list, FALSE);
- scalaresource_listview_font_info(&listpadding);
- listpadding *= 2;
- int flags = LVS_EX_DOUBLEBUFFER | extraflags | LVS_EX_HEADERDRAGDROP;
- if (lv_type != LV_MISC1)
- flags |= LVS_EX_ONECLICKACTIVATE | LVS_EX_UNDERLINEHOT | LVS_EX_FULLROWSELECT;
- ListView_SetExtendedListViewStyleEx (list, flags , flags);
- ListView_RemoveAllGroups (list);
- ListView_DeleteAllItems (list);
- cachedlist = list;
- for(i = 0; i < listview_num_columns; i++)
- listview_column_width[i] = MulDiv(ListView_GetStringWidth(list, column_heading[i]), dpi, 72) + listpadding;
- // If there are no columns, then insert some
- lvcolumn.mask = LVCF_WIDTH;
- if (ListView_GetColumn (list, 1, &lvcolumn) == FALSE) {
- for(i = 0; i < listview_num_columns; i++) {
- lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
- lvcolumn.iSubItem = i;
- lvcolumn.fmt = LVCFMT_LEFT;
- lvcolumn.pszText = column_heading[i];
- lvcolumn.cx = listview_column_width[i];
- ListView_InsertColumn (list, i, &lvcolumn);
- }
- }
- if (lv_type == LV_BOARD) {
- listview_column_width[1] = MulDiv(200, dpi, 72);
- listview_column_width[2] = MulDiv(90, dpi, 72);
- listview_column_width[3] = MulDiv(90, dpi, 72);
- listview_column_width[4] = MulDiv(90, dpi, 72);
- i = 0;
- if (full_property_sheet)
- expansion_generate_autoconfig_info(&workprefs);
- uaecptr highest_expamem = 0;
- for (;;) {
- TCHAR tmp[200];
- struct autoconfig_info *aci = expansion_get_autoconfig_data(full_property_sheet ? &workprefs : &currprefs, i);
- if (aci) {
- if (aci->zorro == 3 && aci->size != 0 && aci->start + aci->size > highest_expamem)
- highest_expamem = aci->start + aci->size;
- }
- if (!aci && highest_expamem <= Z3BASE_UAE)
- break;
- if (aci && aci->zorro >= 1 && aci->zorro <= 3)
- _stprintf(tmp, _T("Z%d"), aci->zorro);
- else
- _tcscpy(tmp, _T("-"));
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = tmp;
- lvstruct.lParam = 0;
- if (aci) {
- // movable
- if (expansion_can_move(&workprefs, i))
- lvstruct.lParam |= 1;
- // outside or crosses 2G "border"
- if (aci->zorro == 3 && aci->start + aci->size > 0x80000000 || aci->start + aci->size < aci->start)
- lvstruct.lParam |= 2;
- // outside or crosses 4G "border"
- if (aci->zorro == 3 && aci->start == 0xffffffff)
- lvstruct.lParam |= 4;
- if (!full_property_sheet && (aci->zorro == 2 || aci->zorro == 3) && aci->addrbank && (aci->addrbank->flags & ABFLAG_RAM) && aci->addrbank->reserved_size) {
- // failed to allocate
- if (aci->addrbank->allocated_size == 0)
- lvstruct.lParam |= 8;
- // outside of JIT direct range
- else if (canbang && (aci->addrbank->flags & ABFLAG_ALLOCINDIRECT))
- lvstruct.lParam |= 16;
- }
- if (aci->rc && aci->ert && (aci->ert->deviceflags & EXPANSIONTYPE_PCMCIA) && !aci->rc->inserted) {
- lvstruct.lParam |= 2;
- }
- }
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem(list, &lvstruct);
- tmp[0] = 0;
- TCHAR *s = tmp;
- if (aci && aci->parent_of_previous) {
- _tcscat(s, _T(" - "));
- }
- if (aci && (aci->parent_address_space || aci->parent_romtype) && !aci->parent_of_previous)
- _tcscat(s, _T("? "));
- if (aci)
- _tcscat(s, aci->name);
- ListView_SetItemText(list, result, 1, tmp);
- if (aci) {
- if (aci->start != 0xffffffff)
- _stprintf(tmp, _T("0x%08x"), aci->start);
- else
- _tcscpy(tmp, _T("-"));
- ListView_SetItemText(list, result, 2, tmp);
- if (aci->size != 0)
- _stprintf(tmp, _T("0x%08x"), aci->size);
- else
- _tcscpy(tmp, _T("-"));
- ListView_SetItemText(list, result, 3, tmp);
- if (aci->autoconfig_bytes[0] != 0xff)
- _stprintf(tmp, _T("0x%04x/0x%02x"),
- (aci->autoconfig_bytes[4] << 8) | aci->autoconfig_bytes[5], aci->autoconfig_bytes[1]);
- else
- _tcscpy(tmp, _T("-"));
- ListView_SetItemText(list, result, 4, tmp);
- } else {
- _stprintf(tmp, _T("0x%08x"), highest_expamem);
- ListView_SetItemText(list, result, 2, tmp);
- }
- i++;
- if (!aci)
- break;
- }
- } else if (lv_type == LV_MISC2) {
- listview_column_width[0] = MulDiv(180, dpi, 72);
- listview_column_width[1] = MulDiv(10, dpi, 72);
- for (i = 0; exts[i].ext; i++) {
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = exts[i].ext;
- lvstruct.lParam = 0;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- ListView_SetItemText (list, result, 1, exts[i].enabled ? _T("*") : _T(""));
- }
- } else if (lv_type == LV_INPUT) {
- for (i = 0; input_total_devices && i < inputdevice_get_widget_num (input_selected_device); i++) {
- TCHAR name[100];
- inputdevice_get_widget_type (input_selected_device, i, name, true);
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = name;
- lvstruct.lParam = i;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- width = MulDiv(ListView_GetStringWidth (list, lvstruct.pszText), dpi, 72) + listpadding;
- if (width > listview_column_width[0])
- listview_column_width[0] = width;
- entry++;
- }
- listview_column_width[1] = MulDiv(260, dpi, 72);
- listview_column_width[2] = MulDiv(65, dpi, 72);
- listview_column_width[3] = MulDiv(65, dpi, 72);
- listview_column_width[4] = MulDiv(65, dpi, 72);
- listview_column_width[5] = MulDiv(65, dpi, 72);
- listview_column_width[6] = MulDiv(30, dpi, 72);
- update_listview_input (hDlg);
- } else if (lv_type == LV_INPUTMAP) {
- listview_column_width[0] = MulDiv(400, dpi, 72);
- update_listview_inputmap (hDlg, -1);
- } else if (lv_type == LV_MISC1) {
- int itemids[] = { IDS_MISCLISTITEMS1, IDS_MISCLISTITEMS2, IDS_MISCLISTITEMS3, IDS_MISCLISTITEMS4 , -1 };
- int itemoffset = 0;
- int itemcnt = 0;
- listview_column_width[0] = MulDiv(150, dpi, 72);
- for (i = 0; misclist[i].name; i++) {
- TCHAR tmpentry[MAX_DPATH], itemname[MAX_DPATH];
- const struct miscentry *me = &misclist[i];
- int type = me->type;
- bool checked = false;
- win32_middle_mouse_obsolete = (workprefs.input_mouse_untrap & MOUSEUNTRAP_MIDDLEBUTTON) != 0;
- if (me->b) {
- checked = *me->b;
- } else if (me->i) {
- checked = ((*me->i) & me->imask) != 0;
- }
- _tcscpy (itemname, me->name);
- for (;;) {
- if (itemids[itemcnt] < 0)
- break;
- WIN32GUI_LoadUIString (itemids[itemcnt], tmpentry, sizeof tmpentry / sizeof (TCHAR));
- TCHAR *p = tmpentry;
- for (int j = 0; j < itemoffset; j++) {
- p = _tcschr (p, '\n');
- if (!p || p[1] == 0) {
- p = NULL;
- itemoffset = 0;
- itemcnt++;
- break;
- }
- p++;
- }
- if (!p)
- continue;
- TCHAR *p2 = _tcschr (p, '\n');
- if (p2) {
- *p2 = 0;
- _tcscpy (itemname, p);
- }
- itemoffset++;
- break;
- }
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = itemname;
- lvstruct.lParam = 0;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- ListView_SetItemState (list, i, INDEXTOSTATEIMAGEMASK(type ? 0 : (checked ? 2 : 1)), LVIS_STATEIMAGEMASK);
- width = MulDiv(ListView_GetStringWidth(list, lvstruct.pszText), dpi, 72) + listpadding;
- if (width > listview_column_width[0])
- listview_column_width[0] = width;
- entry++;
- }
- } else if (lv_type == LV_DISK) {
- for (i = 0; i < MAX_SPARE_DRIVES; i++) {
- int drv;
- _stprintf (tmp, _T("%d"), i + 1);
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = tmp;
- lvstruct.lParam = 0;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- _tcscpy (tmp2, workprefs.dfxlist[i]);
- j = _tcslen (tmp2) - 1;
- if (j < 0)
- j = 0;
- while (j > 0) {
- if ((tmp2[j - 1] == '\\' || tmp2[j - 1] == '/')) {
- if (!(j >= 5 && (tmp2[j - 5] == '.' || tmp2[j - 4] == '.')))
- break;
- }
- j--;
- }
- ListView_SetItemText (list, result, 1, tmp2 + j);
- drv = disk_in_drive (i);
- tmp[0] = 0;
- if (drv >= 0)
- _stprintf (tmp, _T("DF%d:"), drv);
- ListView_SetItemText (list, result, 2, tmp);
- width = MulDiv(ListView_GetStringWidth(list, lvstruct.pszText), dpi, 72) + listpadding;
- if (width > listview_column_width[0])
- listview_column_width[0] = width;
- entry++;
- }
- listview_column_width[0] = MulDiv(30, dpi, 72);
- listview_column_width[1] = MulDiv(336, dpi, 72);
- listview_column_width[2] = MulDiv(50, dpi, 72);
- } else if (lv_type == LV_CD) {
- listview_column_width[2] = MulDiv(450, dpi, 72);
- for (i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
- TCHAR tmp[10];
- struct device_info di = { 0 };
- struct cdslot *cds = &workprefs.cdslots[i];
-
- if (cds->inuse)
- blkdev_get_info (&workprefs, i, &di);
- _stprintf (tmp, _T("%d"), i);
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = cds->inuse ? (di.media_inserted ? _T("*") : _T("E")) : _T("-");
- lvstruct.lParam = 0;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- ListView_SetItemText(list, result, 1, tmp);
- ListView_SetItemText(list, result, 2, cds->name);
- width = MulDiv(ListView_GetStringWidth(list, cds->name), dpi, 72) + listpadding;
- if (width > listview_column_width[2])
- listview_column_width[2] = width;
- break;
- }
- } else if (lv_type == LV_HARDDISK) {
- #ifdef FILESYS
- listview_column_width[1] = MulDiv(80, dpi, 72);
- for (i = 0; i < workprefs.mountitems; i++)
- {
- struct uaedev_config_data *uci = &workprefs.mountconfig[i];
- struct uaedev_config_info *ci = &uci->ci;
- int nosize = 0, type, ctype;
- struct mountedinfo mi;
- TCHAR *rootdir, *rootdirp;
- type = get_filesys_unitconfig (&workprefs, i, &mi);
- if (type < 0) {
- type = ci->type == UAEDEV_HDF || ci->type == UAEDEV_CD || ci->type == UAEDEV_TAPE ? FILESYS_HARDFILE : FILESYS_VIRTUAL;
- nosize = 1;
- }
- if (mi.size < 0)
- nosize = 1;
- rootdir = my_strdup (mi.rootdir);
- rootdirp = rootdir;
- if (!_tcsncmp (rootdirp, _T("HD_"), 3))
- rootdirp += 3;
- if (rootdirp[0] == ':') {
- rootdirp++;
- TCHAR *p = _tcschr (rootdirp, ':');
- if (p)
- *p = 0;
- }
- if (nosize)
- _tcscpy (size_str, _T("n/a"));
- else if (mi.size >= 1024 * 1024 * 1024)
- _stprintf (size_str, _T("%.1fG"), ((double)(uae_u32)(mi.size / (1024 * 1024))) / 1024.0);
- else if (mi.size < 10 * 1024 * 1024)
- _stprintf (size_str, _T("%lldK"), mi.size / 1024);
- else
- _stprintf (size_str, _T("%.1fM"), ((double)(uae_u32)(mi.size / (1024))) / 1024.0);
- ctype = ci->controller_type;
- if (ctype >= HD_CONTROLLER_TYPE_IDE_FIRST && ctype <= HD_CONTROLLER_TYPE_IDE_LAST) {
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- const TCHAR *idedevs[] = {
- _T("IDE:%d"),
- _T("A600/A1200/A4000:%d"),
- };
- _stprintf (blocksize_str, _T("%d"), ci->blocksize);
- if (ert) {
- if (ci->controller_type_unit == 0)
- _stprintf (devname_str, _T("%s:%d"), ert->friendlyname, ci->controller_unit);
- else
- _stprintf (devname_str, _T("%s:%d/%d"), ert->friendlyname, ci->controller_unit, ci->controller_type_unit + 1);
- } else {
- _stprintf (devname_str, idedevs[ctype - HD_CONTROLLER_TYPE_IDE_FIRST], ci->controller_unit);
- }
- harddisktype (volname_str, ci);
- _tcscpy (bootpri_str, _T("n/a"));
- } else if (ctype >= HD_CONTROLLER_TYPE_SCSI_FIRST && ctype <= HD_CONTROLLER_TYPE_SCSI_LAST) {
- TCHAR sid[8];
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- const TCHAR *scsidevs[] = {
- _T("SCSI:%s"),
- _T("A3000:%s"),
- _T("A4000T:%s"),
- _T("CDTV:%s"),
- };
- if (ci->controller_unit == 8 && ert && !_tcscmp(ert->name, _T("a2091")))
- _tcscpy(sid, _T("XT"));
- else if (ci->controller_unit == 8 && ert && !_tcscmp(ert->name, _T("a2090a")))
- _tcscpy(sid, _T("ST-506"));
- else
- _stprintf(sid, _T("%d"), ci->controller_unit);
- _stprintf (blocksize_str, _T("%d"), ci->blocksize);
- if (ert) {
- if (ci->controller_type_unit == 0)
- _stprintf (devname_str, _T("%s:%s"), ert->friendlyname, sid);
- else
- _stprintf (devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
- } else {
- _stprintf (devname_str, scsidevs[ctype - HD_CONTROLLER_TYPE_SCSI_FIRST], sid);
- }
- harddisktype (volname_str, ci);
- _tcscpy (bootpri_str, _T("n/a"));
- } else if (ctype >= HD_CONTROLLER_TYPE_CUSTOM_FIRST && ctype <= HD_CONTROLLER_TYPE_CUSTOM_LAST) {
- TCHAR sid[8];
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- _stprintf(sid, _T("%d"), ci->controller_unit);
- if (ert) {
- if (ci->controller_type_unit == 0)
- _stprintf(devname_str, _T("%s:%s"), ert->friendlyname, sid);
- else
- _stprintf(devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
- } else {
- _stprintf(devname_str, _T("PCMCIA"));
- }
- harddisktype(volname_str, ci);
- _tcscpy(bootpri_str, _T("n/a"));
- } else if (type == FILESYS_HARDFILE) {
- _stprintf (blocksize_str, _T("%d"), ci->blocksize);
- _tcscpy (devname_str, ci->devname);
- _tcscpy (volname_str, _T("n/a"));
- _stprintf (bootpri_str, _T("%d"), ci->bootpri);
- } else if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE || ci->controller_type != HD_CONTROLLER_TYPE_UAE) {
- _stprintf (blocksize_str, _T("%d"), ci->blocksize);
- _stprintf (devname_str, _T("UAE:%d"), ci->controller_unit);
- _tcscpy (volname_str, _T("n/a"));
- _tcscpy (bootpri_str, _T("n/a"));
- } else if (type == FILESYS_TAPE) {
- _stprintf (blocksize_str, _T("%d"), ci->blocksize);
- _tcscpy (devname_str, _T("UAE"));
- harddisktype (volname_str, ci);
- _tcscpy (bootpri_str, _T("n/a"));
- } else {
- _tcscpy (blocksize_str, _T("n/a"));
- _tcscpy (devname_str, ci->devname);
- _tcscpy (volname_str, ci->volname);
- _tcscpy (size_str, _T("n/a"));
- _stprintf (bootpri_str, _T("%d"), ci->bootpri);
- }
- if (!mi.ismedia) {
- _tcscpy (blocksize_str, _T("n/a"));
- _tcscpy (size_str, _T("n/a"));
- }
- if (rootdirp[0] == 0) {
- xfree (rootdir);
- rootdir = my_strdup (_T("-"));
- rootdirp = rootdir;
- }
- WIN32GUI_LoadUIString (ci->readonly ? IDS_NO : IDS_YES, readwrite_str, sizeof (readwrite_str) / sizeof (TCHAR));
- lvstruct.mask = LVIF_TEXT | LVIF_PARAM;
- lvstruct.pszText = mi.ismedia == false ? _T("E") : (nosize && mi.size >= 0 ? _T("X") : (mi.ismounted ? _T("*") : _T(" ")));
- if (mi.error == -1)
- lvstruct.pszText = _T("?");
- else if (mi.error == -2)
- lvstruct.pszText = _T("!");
- if (ci->controller_type != HD_CONTROLLER_TYPE_UAE && mi.ismedia)
- lvstruct.pszText = _T(" ");
- lvstruct.lParam = 0;
- lvstruct.iItem = i;
- lvstruct.iSubItem = 0;
- result = ListView_InsertItem (list, &lvstruct);
- if (result != -1) {
- listview_column_width[0] = MulDiv(20, dpi, 72);
- ListView_SetItemText(list, result, 1, devname_str);
- width = MulDiv(ListView_GetStringWidth(list, devname_str), dpi, 72) + listpadding;
- if(width > listview_column_width[1])
- listview_column_width[1] = width;
- ListView_SetItemText(list, result, 2, volname_str);
- width = MulDiv(ListView_GetStringWidth(list, volname_str), dpi, 72) + listpadding;
- if(width > listview_column_width[2])
- listview_column_width[2] = width;
- listview_column_width[3] = 150;
- ListView_SetItemText(list, result, 3, rootdirp);
- width = MulDiv(ListView_GetStringWidth(list, rootdirp), dpi, 72) + listpadding;
- if(width > listview_column_width[3])
- listview_column_width[3] = width;
- ListView_SetItemText(list, result, 4, readwrite_str);
- width = MulDiv(ListView_GetStringWidth(list, readwrite_str), dpi, 72) + listpadding;
- if(width > listview_column_width[4])
- listview_column_width[4] = width;
- ListView_SetItemText(list, result, 5, blocksize_str);
- width = MulDiv(ListView_GetStringWidth(list, blocksize_str), dpi, 72) + listpadding;
- if(width > listview_column_width[5])
- listview_column_width[5] = width;
- ListView_SetItemText(list, result, 6, size_str);
- width = MulDiv(ListView_GetStringWidth(list, size_str), dpi, 72) + listpadding;
- if(width > listview_column_width[6])
- listview_column_width[6] = width;
- ListView_SetItemText(list, result, 7, bootpri_str);
- width = MulDiv(ListView_GetStringWidth(list, bootpri_str), dpi, 72) + listpadding;
- if(width > listview_column_width[7] )
- listview_column_width[7] = width;
- }
- xfree (rootdir);
- }
- #endif
- }
- if (result != -1) {
- if (GetWindowRect(list, &rect)) {
- ScreenToClient(hDlg, (LPPOINT)&rect);
- ScreenToClient(hDlg, (LPPOINT)&rect.right);
- if (listview_num_columns == 2) {
- if ((temp = rect.right - rect.left - listview_column_width[0] - MulDiv(30, dpi, 72)) > listview_column_width[1])
- listview_column_width[1] = temp;
- } else if (listview_num_columns == 1) {
- listview_column_width[0] = rect.right - rect.left - MulDiv(30, dpi, 72);
- }
- }
- for (i = 0; i < listview_num_columns; i++) {
- listview_column_widths[i] = listview_column_width[i];
- }
- if (!LoadListView(list)) {
- // Adjust our column widths so that we can see the contents...
- for (i = 0; i < listview_num_columns; i++) {
- int w = ListView_GetColumnWidth(list, i);
- if (w < listview_column_width[i])
- ListView_SetColumnWidth(list, i, listview_column_width[i]);
- }
- }
- // Redraw the items in the list...
- items = ListView_GetItemCount (list);
- ListView_RedrawItems (list, 0, items);
- }
- if (lv_oldidx[lv_type] >= 0) {
- int idx = lv_oldidx[lv_type];
- if (idx >= ListView_GetItemCount (list))
- idx = ListView_GetItemCount (list) - 1;
- if (idx >= 0)
- ListView_EnsureVisible (list, idx, FALSE);
- }
- lv_old_type = lv_type;
- SetWindowRedraw(list, TRUE);
- RedrawWindow(list, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
- }
- static int listview_find_selected(HWND list, bool paramIndex)
- {
- int i, items;
- items = ListView_GetItemCount (list);
- for (i = 0; i < items; i++) {
- if (ListView_GetItemState(list, i, LVIS_SELECTED) == LVIS_SELECTED) {
- if (paramIndex) {
- LVITEM pitem = { 0 };
- pitem.mask = LVIF_PARAM;
- pitem.iItem = i;
- ListView_GetItem(list, &pitem);
- return pitem.lParam;
- }
- return i;
- }
- }
- return -1;
- }
- static int listview_entry_from_click (HWND list, int *column, bool paramIndex)
- {
- POINT point;
- POINTS p;
- DWORD pos = GetMessagePos ();
- int items, entry;
- p = MAKEPOINTS (pos);
- point.x = p.x;
- point.y = p.y;
- ScreenToClient (list, &point);
- entry = ListView_GetTopIndex (list);
- items = entry + ListView_GetCountPerPage (list);
- if (items > ListView_GetItemCount (list))
- items = ListView_GetItemCount (list);
- while (entry <= items) {
- RECT rect;
- /* Get the bounding rectangle of an item. If the mouse
- * location is within the bounding rectangle of the item,
- * you know you have found the item that was being clicked. */
- if (ListView_GetItemRect (list, entry, &rect, LVIR_BOUNDS)) {
- if (PtInRect (&rect, point)) {
- POINT ppt;
- int x;
- UINT flag = LVIS_SELECTED | LVIS_FOCUSED;
- ListView_GetItemPosition (list, entry, &ppt);
- x = ppt.x;
- ListView_SetItemState (list, entry, flag, flag);
- for (int i = 0; i < listview_num_columns && column; i++) {
- int cw = ListView_GetColumnWidth (list, i);
- if (x < point.x && x + cw > point.x) {
- *column = i;
- break;
- }
- x += cw;
- }
- if (paramIndex) {
- LVITEM pitem = { 0 };
- pitem.mask = LVIF_PARAM;
- pitem.iItem = entry;
- ListView_GetItem(list, &pitem);
- return pitem.lParam;
- }
- return entry;
- }
- }
- entry++;
- }
- return -1;
- }
- static void getconfigfolderregistry(void)
- {
- int cfsize;
- config_folder[0] = 0;
- cfsize = sizeof(config_folder) / sizeof(TCHAR);
- regquerystr(NULL, configregfolder[configtypepanel], config_folder, &cfsize);
- config_search[0] = 0;
- cfsize = sizeof(config_search) / sizeof(TCHAR);
- regquerystr(NULL, configregsearch[configtypepanel], config_search, &cfsize);
- }
- static void ConfigToRegistry(struct ConfigStruct *config, int type)
- {
- if (config) {
- TCHAR path[MAX_DPATH];
- _tcscpy(path, config->Path);
- _tcsncat(path, config->Name, MAX_DPATH - _tcslen(path));
- regsetstr(NULL, configreg[type], path);
- }
- regsetstr(NULL, configregfolder[type], config_folder);
- regsetstr(NULL, configregsearch[type], config_search);
- }
- static void ConfigToRegistry2(DWORD ct, int type, DWORD noauto)
- {
- if (type > 0)
- regsetint(NULL, configreg2[type], ct);
- if (noauto == 0 || noauto == 1)
- regsetint(NULL, _T("ConfigFile_NoAuto"), noauto);
- }
- static void checkautoload(HWND hDlg, struct ConfigStruct *config)
- {
- int ct = 0;
- if (configtypepanel > 0)
- regqueryint(NULL, configreg2[configtypepanel], &ct);
- if (!config || config->Directory) {
- ct = 0;
- ConfigToRegistry2(ct, configtypepanel, -1);
- }
- CheckDlgButton(hDlg, IDC_CONFIGAUTO, ct ? BST_CHECKED : BST_UNCHECKED);
- ew(hDlg, IDC_CONFIGAUTO, configtypepanel > 0 && config && !config->Directory ? TRUE : FALSE);
- regqueryint(NULL, _T("ConfigFile_NoAuto"), &ct);
- CheckDlgButton(hDlg, IDC_CONFIGNOLINK, ct ? BST_CHECKED : BST_UNCHECKED);
- }
- static struct ConfigStruct *InfoSettingsProcConfig;
- static INT_PTR CALLBACK InfoSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- recursive++;
- SendDlgItemMessage(hDlg, IDC_CONFIGLINK, CB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage(hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)_T(""));
- int idx1 = 1;
- int idx2 = 0;
- for (int j = 0; j < 2; j++) {
- for (int i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs = configstore[i];
- if ((j == 0 && cs->Type == CONFIG_TYPE_HOST) || (j == 1 && cs->Type == CONFIG_TYPE_HARDWARE)) {
- TCHAR tmp2[MAX_DPATH];
- _tcscpy(tmp2, cs->Path);
- _tcsncat(tmp2, cs->Name, MAX_DPATH - _tcslen(tmp2));
- SendDlgItemMessage(hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)tmp2);
- TCHAR *p1 = workprefs.config_host_path;
- if (_tcslen(p1) > _tcslen(tmp2)) {
- p1 += _tcslen(p1) - _tcslen(tmp2);
- }
- TCHAR *p2 = workprefs.config_host_path;
- if (_tcslen(p2) > _tcslen(tmp2)) {
- p2 += _tcslen(p2) - _tcslen(tmp2);
- }
- if (!_tcsicmp(tmp2, p1) || !_tcsicmp(tmp2, p2))
- idx2 = idx1;
- idx1++;
- }
- }
- }
- SendDlgItemMessage(hDlg, IDC_CONFIGLINK, CB_SETCURSEL, idx2, 0);
- checkautoload(hDlg, InfoSettingsProcConfig);
- EnableWindow(GetDlgItem(hDlg, IDC_CONFIGAUTO), configtypepanel > 0);
- EnableWindow(GetDlgItem(hDlg, IDC_CONFIGLINK), configtypepanel == 0);
- EnableWindow(GetDlgItem(hDlg, IDC_CONFIGNOLINK), configtypepanel == 0);
- SetDlgItemText(hDlg, IDC_PATH_NAME, workprefs.info);
- SetDlgItemText(hDlg, IDC_CONFIGCATEGORY, workprefs.category);
- SetDlgItemText(hDlg, IDC_CONFIGTAGS, workprefs.tags);
- recursive--;
- return TRUE;
- }
- case WM_COMMAND:
- if (recursive)
- break;
- recursive++;
- switch (LOWORD(wParam))
- {
- case IDC_SELECTOR:
- DiskSelection(hDlg, IDC_PATH_NAME, 8, &workprefs, NULL, NULL);
- break;
- case IDOK:
- EndDialog(hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog(hDlg, 0);
- break;
- case IDC_CONFIGAUTO:
- if (configtypepanel > 0) {
- int ct = ischecked(hDlg, IDC_CONFIGAUTO) ? 1 : 0;
- ConfigToRegistry2(ct, configtypepanel, -1);
- }
- break;
- case IDC_CONFIGNOLINK:
- if (configtypepanel == 0) {
- int ct = ischecked(hDlg, IDC_CONFIGNOLINK) ? 1 : 0;
- ConfigToRegistry2(-1, -1, ct);
- }
- break;
- case IDC_CONFIGLINK:
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- TCHAR tmp[MAX_DPATH];
- tmp[0] = 0;
- getcbn(hDlg, IDC_CONFIGLINK, tmp, sizeof(tmp) / sizeof(TCHAR));
- _tcscpy(workprefs.config_host_path, tmp);
- }
- break;
- }
- GetDlgItemText(hDlg, IDC_PATH_NAME, workprefs.info, sizeof workprefs.info / sizeof(TCHAR));
- GetDlgItemText(hDlg, IDC_CONFIGCATEGORY, workprefs.category, sizeof workprefs.category / sizeof(TCHAR));
- GetDlgItemText(hDlg, IDC_CONFIGTAGS, workprefs.tags, sizeof workprefs.tags / sizeof(TCHAR));
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static int addConfigFolder(HWND hDlg, const TCHAR *s, bool directory)
- {
- TCHAR tmp[MAX_DPATH];
- if (directory) {
- _tcscpy(tmp, s);
- } else {
- _stprintf(tmp, _T("[%s]"), s);
- }
- int idx = SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_ADDSTRING, 0, (LPARAM)tmp);
- if (!_tcscmp(tmp, config_folder))
- SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_SETCURSEL, idx, 0);
- return idx;
- }
- static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, const TCHAR *name, const TCHAR *desc, const TCHAR *path, int isdir, int expand, HTREEITEM parent)
- {
- TVINSERTSTRUCT is;
- HWND TVhDlg;
- TCHAR s[MAX_DPATH] = _T("");
- TCHAR file_name[MAX_DPATH] = _T(""), file_path[MAX_DPATH] = _T("");
- GetDlgItemText (hDlg, IDC_EDITNAME, file_name, MAX_DPATH);
- GetDlgItemText (hDlg, IDC_EDITPATH, file_path, MAX_DPATH);
- TVhDlg = GetDlgItem (hDlg, IDC_CONFIGTREE);
- memset (&is, 0, sizeof (is));
- is.hInsertAfter = isdir < 0 ? TVI_ROOT : TVI_SORT;
- is.hParent = parent;
- is.itemex.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- if (name && path && !_tcscmp (file_name, name) && !_tcscmp (file_path, path)) {
- is.itemex.state |= TVIS_SELECTED;
- is.itemex.stateMask |= TVIS_SELECTED;
- }
- if (isdir) {
- _tcscat (s, _T(" "));
- is.itemex.state |= TVIS_BOLD;
- is.itemex.stateMask |= TVIS_BOLD;
- }
- if (expand) {
- is.itemex.state |= TVIS_EXPANDED;
- is.itemex.stateMask |= TVIS_EXPANDED;
- }
- _tcscat (s, name);
- if (_tcslen (s) > 4 && !_tcsicmp (s + _tcslen (s) - 4, _T(".uae")))
- s[_tcslen (s) - 4] = 0;
- if (desc && _tcslen (desc) > 0) {
- _tcscat (s, _T(" ("));
- _tcscat (s, desc);
- _tcscat (s, _T(")"));
- }
- is.itemex.pszText = s;
- is.itemex.iImage = is.itemex.iSelectedImage = isdir > 0 ? 0 : (isdir < 0) ? 2 : 1;
- is.itemex.lParam = (LPARAM)config;
- return TreeView_InsertItem (TVhDlg, &is);
- }
- static bool configsearchmatch(const TCHAR *str, int searchlen)
- {
- if (!str[0])
- return false;
- int strlen = _tcslen(str);
- if (strlen >= searchlen) {
- for (int i = 0; i <= strlen - searchlen; i++) {
- if (!_tcsnicmp(config_search, str + i, searchlen)) {
- return true;
- }
- }
- }
- return false;
- }
- static bool configsearch(struct ConfigStruct *config)
- {
- int searchlen = _tcslen(config_search);
- for (int j = 0; j < 3; j++) {
- TCHAR *str = NULL;
- switch (j)
- {
- case 0:
- str = config->Name;
- if (configsearchmatch(str, searchlen))
- return true;
- break;
- case 1:
- str = config->Description;
- if (configsearchmatch(str, searchlen))
- return true;
- break;
- case 2:
- {
- TCHAR tag[CFG_DESCRIPTION_LENGTH + 1] = { 0 };
- if (config->Tags[0]) {
- _tcscpy(tag, config->Tags);
- TCHAR *p = tag;
- for (;;) {
- TCHAR *p2 = p;
- while (*p2 != ',' && *p2 != ' ' && *p2 != 0)
- p2++;
- *p2++ = 0;
- if (configsearchmatch(p, searchlen))
- return true;
- if (*p2 == 0)
- break;
- p = p2;
- }
- }
- }
- break;
- }
- }
- return false;
- }
- static int LoadConfigTreeView (HWND hDlg, int idx, HTREEITEM parent)
- {
- struct ConfigStruct *cparent, *config;
- int cnt = 0;
- if (configstoresize == 0)
- return cnt;
- if (idx < 0) {
- idx = 0;
- for (;;) {
- config = configstore[idx];
- if (config->Parent == NULL)
- break;
- idx++;
- if (idx >= configstoresize)
- return cnt;
- }
- }
- cparent = configstore[idx]->Parent;
- idx = 0;
- while (idx < configstoresize) {
- config = configstore[idx];
- if ((configtypepanel == 1 && !config->hardware) || (configtypepanel == 2 && !config->host) || (configtypepanel == 0 && (config->host || config->hardware))) {
- idx++;
- continue;
- }
- if (config->Parent == cparent) {
- bool visible = false;
- int cfgflen = _tcslen(config_folder);
- if (config_folder[0] == 0) {
- visible = true;
- } else if (config_folder[0] == '[' && config_folder[cfgflen - 1] == ']') {
- visible = false;
- if (cfgflen - 2 == _tcslen(config->Category) && !_tcsnicmp(config->Category, config_folder + 1, cfgflen - 2)) {
- visible = true;
- }
- } else if (!_tcsncmp(config_folder, config->Path, _tcslen(config_folder))) {
- visible = true;
- }
- if (config_search[0] && visible && !config->Directory) {
- visible = configsearch(config);
- }
- if (visible) {
- if (config->Directory) {
- int stridx = -1;
- bool expand = config->hardware || config->host;
- if (config_folder[0]) {
- expand = true;
- }
- stridx = addConfigFolder(hDlg, config->Path, true);
- HTREEITEM par = AddConfigNode(hDlg, config, config->Name, NULL, config->Path, 1, expand, parent);
- int idx2 = 0;
- for (;;) {
- if (configstore[idx2] == config->Child) {
- config->item = par;
- if (LoadConfigTreeView(hDlg, idx2, par) == 0) {
- if (!config->hardware && !config->host && !config->Directory) {
- TreeView_DeleteItem(GetDlgItem(hDlg, IDC_CONFIGTREE), par);
- if (stridx >= 0)
- SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_DELETESTRING, stridx, 0);
- }
- }
- break;
- }
- idx2++;
- if (idx2 >= configstoresize)
- break;
- }
- } else if (!config->Directory) {
- if (((config->Type == 0 || config->Type == 3) && configtype == 0) || (config->Type == configtype)) {
- config->item = AddConfigNode(hDlg, config, config->Name, config->Description, config->Path, 0, 0, parent);
- cnt++;
- }
- }
- } else {
- if (config->Directory) {
- addConfigFolder(hDlg, config->Path, true);
- int idx2 = 0;
- for (;;) {
- if (configstore[idx2] == config->Child) {
- LoadConfigTreeView(hDlg, idx2, parent);
- break;
- }
- idx2++;
- if (idx2 >= configstoresize)
- break;
- }
- }
- }
- }
- idx++;
- }
- return cnt;
- }
- static void InitializeConfig (HWND hDlg, struct ConfigStruct *config)
- {
- addhistorymenu(hDlg, config == NULL ? _T("") : config->Name, IDC_EDITNAME, HISTORY_CONFIGFILE, false, -1);
- if (config == NULL) {
- SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, _T(""));
- } else {
- SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, config->Description);
- }
- if (config && config->Artpath[0]) {
- show_box_art(config->Artpath, config->Name);
- } else {
- show_box_art(NULL, NULL);
- }
- }
- static void DeleteConfigTree (HWND hDlg)
- {
- HWND TVhDlg = GetDlgItem(hDlg, IDC_CONFIGTREE);
- for (int i = 0; i < configstoresize; i++) {
- configstore[i]->item = NULL;
- }
- TreeView_DeleteAllItems (TVhDlg);
- }
- static HTREEITEM InitializeConfigTreeView (HWND hDlg)
- {
- HIMAGELIST himl = ImageList_Create (16, 16, ILC_COLOR8 | ILC_MASK, 3, 0);
- HWND TVhDlg = GetDlgItem(hDlg, IDC_CONFIGTREE);
- HTREEITEM parent;
- TCHAR path[MAX_DPATH];
- if (himl) {
- HICON icon;
- icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_FOLDER));
- ImageList_AddIcon (himl, icon);
- icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_FILE));
- ImageList_AddIcon (himl, icon);
- icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_ROOT));
- ImageList_AddIcon (himl, icon);
- TreeView_SetImageList (TVhDlg, himl, TVSIL_NORMAL);
- }
- SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_ADDSTRING, 0, (LPARAM)_T(""));
- for (int i = 0; i < categorystoresize; i++) {
- struct CategoryStruct *c = categorystore[i];
- addConfigFolder(hDlg, c->category, false);
- }
- DeleteConfigTree (hDlg);
- GetConfigPath (path, NULL, FALSE);
- parent = AddConfigNode (hDlg, NULL, path, NULL, NULL, 0, 1, NULL);
- LoadConfigTreeView (hDlg, -1, parent);
- ew(hDlg, IDC_CONFIGFOLDER, SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_GETCOUNT, 0, 0L) > 1);
- return parent;
- }
- static struct ConfigStruct *fixloadconfig (HWND hDlg, struct ConfigStruct *config)
- {
- int i;
- if (config && configtypepanel == 0 && (config->host || config->hardware))
- return NULL;
- if ((!config && configtypepanel) || (config && (configtypepanel == 2 && !config->host) || (configtypepanel == 1 && !config->hardware))) {
- for (i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs = configstore[i];
- if (cs->Directory && ((configtypepanel == 1 && cs->hardware) || (configtypepanel == 2 && cs->host))) {
- config = cs;
- SetDlgItemText (hDlg, IDC_EDITPATH, config->Path);
- break;
- }
- }
- }
- return config;
- }
- static struct ConfigStruct *initloadsave (HWND hDlg, struct ConfigStruct *config, bool init)
- {
- HTREEITEM root;
- TCHAR name_buf[MAX_DPATH];
- int dwRFPsize = sizeof(name_buf) / sizeof(TCHAR);
- TCHAR path[MAX_DPATH];
- HWND lv = GetDlgItem(hDlg, IDC_CONFIGTREE);
- SetWindowRedraw(lv, FALSE);
- EnableWindow (GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]);
- root = InitializeConfigTreeView (hDlg);
- if (regquerystr (NULL, configreg[configtypepanel], name_buf, &dwRFPsize)) {
- if (init) {
- if (_tcsicmp(name_buf, _T("default.uae")))
- target_cfgfile_load (&workprefs, name_buf, CONFIG_TYPE_DEFAULT, 0);
- }
- struct ConfigStruct *config2 = getconfigstorefrompath (name_buf, path, configtypepanel);
- if (config2)
- config = config2;
- }
- config = fixloadconfig (hDlg, config);
- SetWindowRedraw(lv, TRUE);
- RedrawWindow(lv, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
- if (config && config->item)
- TreeView_SelectItem (GetDlgItem(hDlg, IDC_CONFIGTREE), config->item);
- else
- TreeView_SelectItem (GetDlgItem(hDlg, IDC_CONFIGTREE), root);
- return config;
- }
- static struct ConfigStruct *refreshconfiglist(HWND hDlg, struct ConfigStruct *config)
- {
- struct ConfigStruct *cs = initloadsave(hDlg, config, false);
- return cs;
- }
- static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **configp, TCHAR **pcfgfile, TCHAR *newpath)
- {
- struct ConfigStruct *config = *configp;
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- switch (LOWORD(wParam))
- {
- case IDC_CONFIGFOLDER:
- {
- int idx = SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_GETCURSEL, 0, 0L);
- if (idx >= 0) {
- SendDlgItemMessage(hDlg, IDC_CONFIGFOLDER, CB_GETLBTEXT, (WPARAM)idx, (LPARAM)config_folder);
- if (_tcslen(config_folder) > 0 && config_folder[_tcslen(config_folder) - 1] != ']' && config_folder[_tcslen(config_folder) - 1] != '\\')
- _tcscat(config_folder, _T("\\"));
- ConfigToRegistry(config, configtypepanel);
- config = refreshconfiglist(hDlg, config);
- }
- break;
- }
- case IDC_EDITNAME:
- {
- TCHAR cfg[MAX_DPATH];
- if (getcomboboxtext(hDlg, IDC_EDITNAME, cfg, sizeof cfg / sizeof(TCHAR))) {
- config = NULL;
- for (int i = 0; i < configstoresize; i++) {
- struct ConfigStruct *cs = configstore[i];
- TCHAR path[MAX_DPATH];
- _tcscpy(path, cs->Path);
- _tcscat(path, cs->Name);
- if (!_tcsicmp(path, cfg)) {
- config = cs;
- TreeView_SelectItem(GetDlgItem(hDlg, IDC_CONFIGTREE), cs->item);
- break;
- }
- }
- }
- }
- break;
- }
- }
- if (HIWORD(wParam) == EN_CHANGE) {
- switch (LOWORD(wParam))
- {
- case IDC_CONFIGSEARCH:
- {
- GetDlgItemText(hDlg, IDC_CONFIGSEARCH, config_search, MAX_DPATH);
- config = refreshconfiglist(hDlg, config);
- break;
- }
- }
- }
- switch (LOWORD (wParam))
- {
- case IDC_CONFIGSEARCHCLEAR:
- if (config_search[0]) {
- config_search[0] = 0;
- SetDlgItemText(hDlg, IDC_CONFIGSEARCH, _T(""));
- ConfigToRegistry(config, configtypepanel);
- config = refreshconfiglist(hDlg, config);
- }
- break;
- case IDC_SAVE:
- if (HandleConfiguration (hDlg, CONFIG_SAVE_FULL, config, newpath)) {
- DeleteConfigTree (hDlg);
- config = CreateConfigStore (config, TRUE);
- ConfigToRegistry (config, configtypepanel);
- config = initloadsave (hDlg, config, false);
- InitializeConfig (hDlg, config);
- }
- break;
- case IDC_QUICKSAVE:
- if (HandleConfiguration (hDlg, CONFIG_SAVE, config, NULL)) {
- DeleteConfigTree (hDlg);
- config = CreateConfigStore (config, TRUE);
- ConfigToRegistry (config, configtypepanel);
- config = initloadsave (hDlg, config, false);
- InitializeConfig (hDlg, config);
- }
- break;
- case IDC_QUICKLOAD:
- *pcfgfile = HandleConfiguration (hDlg, CONFIG_LOAD, config, NULL);
- if (*pcfgfile) {
- ConfigToRegistry (config, configtypepanel);
- InitializeConfig (hDlg, config);
- if (full_property_sheet) {
- inputdevice_updateconfig (NULL, &workprefs);
- } else {
- uae_restart (-1, *pcfgfile);
- exit_gui(1);
- }
- }
- break;
- case IDC_LOAD:
- *pcfgfile = HandleConfiguration (hDlg, CONFIG_LOAD_FULL, config, newpath);
- if (*pcfgfile) {
- ConfigToRegistry (config, configtypepanel);
- InitializeConfig (hDlg, config);
- if (full_property_sheet) {
- inputdevice_updateconfig (NULL, &workprefs);
- } else {
- uae_restart (-1, *pcfgfile);
- exit_gui(1);
- }
- }
- break;
- case IDC_DELETE:
- if (HandleConfiguration (hDlg, CONFIG_DELETE, config, NULL)) {
- DeleteConfigTree (hDlg);
- config = CreateConfigStore (config, TRUE);
- config = initloadsave (hDlg, config, false);
- InitializeConfig (hDlg, config);
- }
- break;
- case IDC_VIEWINFO:
- if (workprefs.info[0]) {
- TCHAR name_buf[MAX_DPATH];
- if (_tcsstr (workprefs.info, _T("Configurations\\")))
- _stprintf (name_buf, _T("%s\\%s"), start_path_data, workprefs.info);
- else
- _tcscpy (name_buf, workprefs.info);
- ShellExecute (NULL, NULL, name_buf, NULL, NULL, SW_SHOWNORMAL);
- }
- break;
- case IDC_SETINFO:
- InfoSettingsProcConfig = config;
- if (CustomDialogBox(IDD_SETINFO, hDlg, InfoSettingsProc))
- EnableWindow( GetDlgItem( hDlg, IDC_VIEWINFO ), workprefs.info[0] );
- break;
- }
- *configp = config;
- }
- static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- TCHAR *cfgfile = NULL;
- static int recursive;
- static struct ConfigStruct *config;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- recursive++;
- if (!configstore) {
- DeleteConfigTree(hDlg);
- CreateConfigStore(NULL, FALSE);
- config = NULL;
- }
- getconfigfolderregistry();
- pages[LOADSAVE_ID] = hDlg;
- currentpage = LOADSAVE_ID;
- SetDlgItemText(hDlg, IDC_EDITPATH, _T(""));
- SetDlgItemText(hDlg, IDC_EDITDESCRIPTION, workprefs.description);
- SetDlgItemText(hDlg, IDC_CONFIGSEARCH, config_search);
- config = initloadsave(hDlg, config, firstautoloadconfig);
- firstautoloadconfig = false;
- recursive--;
- return TRUE;
- }
- case WM_DESTROY:
- ConfigToRegistry(NULL, configtypepanel);
- break;
- case WM_USER + 1:
- if (config) {
- if (config->Artpath[0]) {
- show_box_art(config->Artpath, config->Name);
- } else {
- show_box_art(NULL, NULL);
- }
- }
- break;
- case WM_CONTEXTMENU:
- {
- int id = GetDlgCtrlID ((HWND)wParam);
- if (id == IDC_SAVE || id == IDC_LOAD) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- loadsavecommands (hDlg, id, &config, &cfgfile, s);
- xfree (s);
- }
- }
- break;
- }
- case WM_COMMAND:
- {
- recursive++;
- loadsavecommands (hDlg, wParam, &config, &cfgfile, NULL);
- recursive++;
- break;
- }
- case WM_NOTIFY:
- {
- LPNMHDR nm = (LPNMHDR)lParam;
- if (nm->hwndFrom == GetDlgItem (hDlg, IDC_CONFIGTREE)) {
- switch (nm->code)
- {
- case NM_DBLCLK:
- {
- HTREEITEM ht = TreeView_GetSelection (GetDlgItem (hDlg, IDC_CONFIGTREE));
- if (ht != NULL) {
- TVITEMEX pitem;
- memset (&pitem, 0, sizeof (pitem));
- pitem.mask = TVIF_HANDLE | TVIF_PARAM;
- pitem.hItem = ht;
- if (TreeView_GetItem (GetDlgItem(hDlg, IDC_CONFIGTREE), &pitem)) {
- struct ConfigStruct *config = (struct ConfigStruct*)pitem.lParam;
- if (config && !config->Directory) {
- cfgfile = HandleConfiguration (hDlg, CONFIG_LOAD, config, NULL);
- if (cfgfile) {
- ConfigToRegistry (config, configtypepanel);
- if (!full_property_sheet)
- uae_restart (0, cfgfile);
- exit_gui (1);
- }
- }
- }
- }
- return TRUE;
- }
- break;
- case TVN_SELCHANGING:
- return FALSE;
- case TVN_SELCHANGED:
- {
- LPNMTREEVIEW tv = (LPNMTREEVIEW)lParam;
- struct ConfigStruct *c = (struct ConfigStruct*)tv->itemNew.lParam;
- if (c) {
- config = c;
- if (!config->Directory) {
- InitializeConfig (hDlg, config);
- } else {
- InitializeConfig (hDlg, NULL);
- }
- SetDlgItemText (hDlg, IDC_EDITPATH, config->Path);
- }
- if (configtypepanel > 0) {
- if (c && !c->Directory) {
- ConfigToRegistry (config, configtypepanel);
- InitializeConfig (hDlg, config);
- }
- checkautoload (hDlg, c);
- }
- return TRUE;
- }
- break;
- }
- }
- break;
- }
- }
- return FALSE;
- }
- #define MAX_CONTRIBUTORS_LENGTH 2048
- static INT_PTR CALLBACK ErrorLogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- CHARFORMAT CharFormat;
- TCHAR *err;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_COMMAND:
- if (wParam == IDOK) {
- EndDialog (hDlg, 1);
- return TRUE;
- } else if (wParam == IDC_ERRORLOGCLEAR) {
- error_log (NULL);
- EndDialog (hDlg, 1);
- return TRUE;
- }
- break;
- case WM_INITDIALOG:
- err = get_error_log ();
- if (err == NULL)
- return FALSE;
- CharFormat.cbSize = sizeof (CharFormat);
- SetDlgItemText (hDlg, IDC_ERRORLOGMESSAGE, err);
- SendDlgItemMessage (hDlg, IDC_ERRORLOGMESSAGE, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
- CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
- CharFormat.yHeight = 8 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
- _tcscpy (CharFormat.szFaceName, os_vista ? _T("Segoe UI") : _T("Tahoma"));
- SendDlgItemMessage (hDlg, IDC_ERRORLOGMESSAGE, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
- return TRUE;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- CHARFORMAT CharFormat;
- TCHAR szContributors1[MAX_CONTRIBUTORS_LENGTH];
- TCHAR szContributors2[MAX_CONTRIBUTORS_LENGTH];
- TCHAR szContributors[MAX_CONTRIBUTORS_LENGTH * 2];
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_COMMAND:
- if (wParam == ID_OK) {
- EndDialog (hDlg, 1);
- return TRUE;
- }
- break;
- case WM_INITDIALOG:
- CharFormat.cbSize = sizeof (CharFormat);
- WIN32GUI_LoadUIString(IDS_CONTRIBUTORS1, szContributors1, MAX_CONTRIBUTORS_LENGTH);
- WIN32GUI_LoadUIString(IDS_CONTRIBUTORS2, szContributors2, MAX_CONTRIBUTORS_LENGTH);
- _stprintf (szContributors, _T("%s%s"), szContributors1, szContributors2);
- SetDlgItemText (hDlg, IDC_CONTRIBUTORS, szContributors );
- SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
- CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
- CharFormat.yHeight = 8 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
- _tcscpy (CharFormat.szFaceName, os_vista ? _T("Segoe UI") : _T("Tahoma"));
- SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
- return TRUE;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static void DisplayContributors (HWND hDlg)
- {
- CustomDialogBox (IDD_CONTRIBUTORS, hDlg, ContributorsProc);
- }
- typedef struct url_info
- {
- int id;
- BOOL state;
- const TCHAR *display;
- const TCHAR *url;
- } urlinfo;
- static urlinfo urls[] =
- {
- {IDC_CLOANTOHOME, FALSE, _T("Cloanto's Amiga Forever"), _T("https://www.amigaforever.com/")},
- {IDC_AMIGAHOME, FALSE, _T("Amiga Corporation"), _T("https://amiga.com/")},
- // {IDC_PICASSOHOME, FALSE, _T("Picasso96 Home Page"), _T("http://www.picasso96.cogito.de/")},
- // {IDC_UAEHOME, FALSE, _T("UAE Home Page"), _T("http://www.amigaemulator.org/")},
- {IDC_WINUAEHOME, FALSE, _T("WinUAE Home Page"), _T("http://www.winuae.net/")},
- // {IDC_AIABHOME, FALSE, _T("AIAB"), _T("http://www.amigainabox.co.uk/")},
- // {IDC_THEROOTS, FALSE, _T("Back To The Roots"), _T("http://back2roots.abime.net/")},
- {IDC_ABIME, FALSE, _T("abime.net"), _T("http://www.abime.net/")},
- {IDC_CAPS, FALSE, _T("SPS"), _T("http://www.softpres.org/")},
- {IDC_AMIGASYS, FALSE, _T("AmigaSYS"), _T("http://www.amigasys.com/")},
- {IDC_AMIKIT, FALSE, _T("AmiKit"), _T("http://amikit.amiga.sk/")},
- { -1, FALSE, NULL, NULL }
- };
- static void SetupRichText(HWND hDlg, urlinfo *url)
- {
- CHARFORMAT CharFormat;
- CharFormat.cbSize = sizeof (CharFormat);
- SetDlgItemText (hDlg, url->id, url->display);
- SendDlgItemMessage (hDlg, url->id, EM_GETCHARFORMAT, 0, (LPARAM)&CharFormat);
- CharFormat.dwMask |= CFM_UNDERLINE | CFM_SIZE | CFM_FACE | CFM_COLOR;
- CharFormat.dwEffects = url->state ? CFE_UNDERLINE : 0;
- CharFormat.yHeight = 10 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
- CharFormat.crTextColor = GetSysColor (COLOR_ACTIVECAPTION);
- _tcscpy (CharFormat.szFaceName, os_vista ? _T("Segoe UI") : _T("Tahoma"));
- SendDlgItemMessage (hDlg, url->id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CharFormat);
- SendDlgItemMessage (hDlg, url->id, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
- }
- static void url_handler (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int last_rectangle = -1;
- int i;
- BOOL found = FALSE;
- HCURSOR m_hCursor = NULL;
- POINT point;
- point.x = LOWORD (lParam);
- point.y = HIWORD (lParam);
- for (i = 0; urls[i].id >= 0; i++)
- {
- RECT rect;
- GetWindowRect (GetDlgItem(hDlg, urls[i].id), &rect);
- ScreenToClient (hDlg, (POINT*)&rect);
- ScreenToClient (hDlg, (POINT*)&rect.right);
- if (PtInRect (&rect, point))
- {
- if(msg == WM_LBUTTONDOWN)
- {
- ShellExecute (NULL, NULL, urls[i].url , NULL, NULL, SW_SHOWNORMAL);
- SetCursor (LoadCursor(NULL, MAKEINTRESOURCE (IDC_ARROW)));
- }
- else
- {
- if(i != last_rectangle)
- {
- // try and load the system hand (Win2000+)
- m_hCursor = LoadCursor (NULL, MAKEINTRESOURCE (IDC_HAND) );
- if (!m_hCursor)
- {
- // retry with our fallback hand
- m_hCursor = LoadCursor (hInst, MAKEINTRESOURCE (IDC_MYHAND) );
- }
- SetCursor (m_hCursor);
- urls[i].state = TRUE;
- SetupRichText (hDlg, &urls[i]);
- if(last_rectangle != -1)
- {
- urls[last_rectangle].state = FALSE;
- SetupRichText (hDlg, &urls[last_rectangle]);
- }
- }
- }
- last_rectangle = i;
- found = TRUE;
- break;
- }
- }
- if(!found && last_rectangle >= 0)
- {
- SetCursor (LoadCursor (NULL, MAKEINTRESOURCE (IDC_ARROW)));
- urls[last_rectangle].state = FALSE;
- SetupRichText (hDlg, &urls[last_rectangle]);
- last_rectangle = -1;
- }
- }
- static void setac (HWND hDlg, int id)
- {
- SHAutoComplete (GetDlgItem (hDlg, id), SHACF_FILESYSTEM | SHACF_AUTOAPPEND_FORCE_ON | SHACF_AUTOSUGGEST_FORCE_ON | SHACF_USETAB);
- }
- static void setautocomplete (HWND hDlg, int id)
- {
- HWND item = FindWindowEx (GetDlgItem (hDlg, id), NULL, _T("Edit"), NULL);
- if (item)
- SHAutoComplete (item, SHACF_FILESYSTEM | SHACF_AUTOAPPEND_FORCE_ON | SHACF_AUTOSUGGEST_FORCE_ON | SHACF_USETAB);
- }
- static void setmultiautocomplete (HWND hDlg, int *ids)
- {
- int i;
- for (i = 0; ids[i] >= 0; i++)
- setautocomplete (hDlg, ids[i]);
- }
- static void wsetpath (HWND hDlg, const TCHAR *name, DWORD d, const TCHAR *def)
- {
- TCHAR tmp[MAX_DPATH];
- _tcscpy (tmp, def);
- fetch_path (name, tmp, sizeof (tmp) / sizeof (TCHAR));
- SetDlgItemText (hDlg, d, tmp);
- }
- static void values_to_pathsdialog (HWND hDlg)
- {
- wsetpath (hDlg, _T("KickstartPath"), IDC_PATHS_ROM, _T("Roms"));
- wsetpath (hDlg, _T("ConfigurationPath"), IDC_PATHS_CONFIG, _T("Configurations"));
- wsetpath (hDlg, _T("ScreenshotPath"), IDC_PATHS_SCREENSHOT, _T("ScreenShots"));
- wsetpath (hDlg, _T("StatefilePath"), IDC_PATHS_SAVESTATE, _T("Savestates"));
- wsetpath (hDlg, _T("SaveimagePath"), IDC_PATHS_SAVEIMAGE, _T("SaveImages"));
- wsetpath (hDlg, _T("VideoPath"), IDC_PATHS_AVIOUTPUT, _T("Videos"));
- wsetpath (hDlg, _T("RipperPath"), IDC_PATHS_RIP, _T(".\\"));
- }
- static const TCHAR *pathnames[] = {
- _T("KickstartPath"),
- _T("ConfigurationPath"),
- _T("ScreenshotPath"),
- _T("StatefilePath"),
- _T("SaveimagePath"),
- _T("VideoPath"),
- _T("RipperPath"),
- _T("LuaPath"),
- _T("InputPath"),
- NULL
- };
- static void rewritepaths(void)
- {
- for(int i = 0; pathnames[i]; i++) {
- TCHAR tmp[MAX_DPATH];
- fetch_path(pathnames[i], tmp, sizeof(tmp) / sizeof TCHAR);
- set_path(pathnames[i], tmp);
- }
- }
- static void resetregistry (void)
- {
- regdeletetree(NULL, _T("DetectedROMs"));
- regdelete(NULL, _T("QuickStartMode"));
- regdelete(NULL, _T("ConfigFile"));
- regdelete(NULL, _T("ConfigFileHardware"));
- regdelete(NULL, _T("ConfigFileHost"));
- regdelete(NULL, _T("ConfigFileHardware_Auto"));
- regdelete(NULL, _T("ConfigFileHost_Auto"));
- regdelete(NULL, _T("ConfigurationPath"));
- regdelete(NULL, _T("SaveimagePath"));
- regdelete(NULL, _T("ScreenshotPath"));
- regdelete(NULL, _T("StatefilePath"));
- regdelete(NULL, _T("VideoPath"));
- regdelete(NULL, _T("RipperPath"));
- regdelete(NULL, _T("QuickStartModel"));
- regdelete(NULL, _T("QuickStartConfiguration"));
- regdelete(NULL, _T("QuickStartCompatibility"));
- regdelete(NULL, _T("QuickStartHostConfig"));
- regdelete(NULL, _T("RecursiveROMScan"));
- regdelete(NULL, _T("ConfigurationCache"));
- regdelete(NULL, _T("ArtCache"));
- regdelete(NULL, _T("SaveImageOriginalPath"));
- regdelete(NULL, _T("RelativePaths"));
- regdelete(NULL, _T("DirectDraw_Secondary"));
- regdelete(NULL, _T("ShownsupportedModes"));
- regdelete(NULL, _T("ArtImageCount"));
- regdelete(NULL, _T("ArtImageWidth"));
- }
- #include "zip.h"
- static void copylog (const TCHAR *name, const TCHAR *path, FILE *f)
- {
- FILE *s;
- s = my_opentext (path);
- if (s) {
- fputws (_T("\n"), f);
- fputws (name, f);
- fputws (_T(":\n"), f);
- fputws (_T("\n"), f);
- for (;;) {
- TCHAR buf[MAX_DPATH];
- if (!fgetws (buf, sizeof buf / sizeof (TCHAR), s))
- break;
- fputws (buf, f);
- }
- fclose (s);
- }
- }
- static void saveconfig (FILE *f)
- {
- int len;
- uae_u8 *s;
-
- s = save_configuration (&len, true);
- if (!s)
- return;
- TCHAR *c = utf8u ((char*)s);
- fputws (c, f);
- xfree (c);
- xfree (s);
- }
- static void zipdate(zip_fileinfo *zi)
- {
- SYSTEMTIME st;
- FILETIME ft;
- WORD dosdate, dostime;
- memset(zi, 0, sizeof zip_fileinfo);
- GetLocalTime (&st);
- SystemTimeToFileTime (&st, &ft);
- FileTimeToDosDateTime(&ft, &dosdate, &dostime);
- zi->dosDate = (dosdate << 16) | dostime;
- }
- static void ziplog(const char *name, const TCHAR *path, zipFile zf)
- {
- zip_fileinfo zi;
- FILE *s;
-
- s = my_opentext (path);
- if (s) {
- zipdate(&zi);
- if (zipOpenNewFileInZip(zf, name, &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION) == ZIP_OK) {
- for (;;) {
- TCHAR buf[MAX_DPATH];
- if (!fgetws (buf, sizeof buf / sizeof (TCHAR), s))
- break;
- zipWriteInFileInZip(zf, buf, _tcslen(buf) * sizeof TCHAR);
- }
- zipCloseFileInZip(zf);
- }
- fclose(s);
- }
- }
- static void zipconfig(const char *name, zipFile zf)
- {
- int len;
- uae_u8 *s;
- zip_fileinfo zi;
-
- s = save_configuration (&len, true);
- if (!s)
- return;
- zipdate(&zi);
- if (zipOpenNewFileInZip(zf, name, &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION) == ZIP_OK) {
- zipWriteInFileInZip(zf, s, len);
- zipCloseFileInZip(zf);
- }
- xfree(s);
- }
- static void savelog (HWND hDlg, int all)
- {
- TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
- TCHAR name[MAX_DPATH];
- tmp[0] = 0;
- _stprintf(name, _T("winuae%s_%s_%d.%d.%d.%s"),
- #ifdef _WIN64
- _T("64"),
- #else
- _T(""),
- #endif
- all ? _T("debug") : _T("config"),
- UAEMAJOR, UAEMINOR, UAESUBREV,
- all ? _T("zip") : _T("txt"));
- if (all) {
- OPENFILENAME openFileName = { 0 };
- flush_log ();
- _tcscpy(tmp, name);
- _tcscpy(tmp2, tmp);
- openFileName.lStructSize = sizeof (OPENFILENAME);
- openFileName.hwndOwner = hDlg;
- openFileName.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT |
- OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_ENABLESIZING;
- openFileName.lpstrFile = tmp;
- openFileName.lpstrFileTitle = tmp2;
- openFileName.nMaxFile = MAX_DPATH;
- openFileName.nMaxFileTitle = MAX_DPATH;
- openFileName.lpstrDefExt = _T("zip");
- // {8F1A2703-9FE0-468A-BBD7-D2336FD693E8}
- static const GUID logdialogguid = { 0x8f1a2703, 0x9fe0, 0x468a, { 0xbb, 0xd7, 0xd2, 0x33, 0x6f, 0xd6, 0x93, 0xe8 } };
- if (GetSaveFileName_2 (hDlg, &openFileName, &logdialogguid)) {
- zipFile zf = zipOpen(openFileName.lpstrFile, 0);
- if (zf) {
- ziplog("winuaebootlog.txt", bootlogpath, zf);
- ziplog("winuaelog.txt", logpath, zf);
- zipconfig("config.uae", zf);
- }
- zipClose(zf, NULL);
- }
- } else {
- if (GetTempPath (MAX_DPATH, tmp) <= 0)
- return;
- _tcscat(tmp, name);
- FILE *f = _tfopen (tmp, _T("wt, ccs=UTF-8"));
- saveconfig (f);
- fclose (f);
- ShellExecute (NULL, _T("open"), tmp, NULL, NULL, SW_SHOWNORMAL);
- }
- #if 0
- if (all) {
- f = _tfopen (tmp, _T("wt, ccs=UTF-8"));
- copylog (_T("winuaebootlog"), bootlogpath, f);
- copylog (_T("winuaelog"), logpath, f);
- fputws (_T("\n"), f);
- fputws (_T("configuration:\n"), f);
- fputws (_T("\n"), f);
- saveconfig (f);
- fclose (f);
- } else {
- _tcscat (tmp, _T("winuae_config.txt"));
- f = _tfopen (tmp, _T("wt, ccs=UTF-8"));
- saveconfig (f);
- fclose (f);
- }
- #endif
- }
- pathtype path_type;
- static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- const GUID pathsguid = { 0x5674338c, 0x7a0b, 0x4565, { 0xbf, 0x75, 0x62, 0x8c, 0x80, 0x4a, 0xef, 0xf7 } };
- void create_afnewdir(int);
- static int recursive;
- static pathtype ptypes[10];
- static int numtypes;
- int val, selpath = 0;
- TCHAR tmp[MAX_DPATH];
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- recursive++;
- pages[PATHS_ID] = hDlg;
- setac (hDlg, IDC_PATHS_ROM);
- setac (hDlg, IDC_PATHS_CONFIG);
- setac (hDlg, IDC_PATHS_SCREENSHOT);
- setac (hDlg, IDC_PATHS_SAVESTATE);
- setac (hDlg, IDC_PATHS_SAVEIMAGE);
- setac (hDlg, IDC_PATHS_AVIOUTPUT);
- setac (hDlg, IDC_PATHS_RIP);
- CheckDlgButton(hDlg, IDC_PATHS_RECURSIVEROMS, recursiveromscan);
- CheckDlgButton(hDlg, IDC_PATHS_CONFIGCACHE, configurationcache);
- CheckDlgButton(hDlg, IDC_PATHS_ARTCACHE, artcache);
- CheckDlgButton(hDlg, IDC_PATHS_SAVEIMAGEORIGINALPATH, saveimageoriginalpath);
- CheckDlgButton(hDlg, IDC_PATHS_RELATIVE, relativepaths);
- CheckDlgButton(hDlg, IDC_REGISTRYMODE, getregmode() != NULL);
- currentpage = PATHS_ID;
- ShowWindow (GetDlgItem (hDlg, IDC_RESETREGISTRY), FALSE);
- numtypes = 0;
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_RESETCONTENT, 0, 0L);
- if (af_path_2005 & 1) {
- WIN32GUI_LoadUIString (IDS_DEFAULT_AF, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
- if (path_type == PATH_TYPE_NEWAF)
- selpath = numtypes;
- ptypes[numtypes++] = PATH_TYPE_NEWAF;
- }
- if (start_path_new1[0]) {
- WIN32GUI_LoadUIString (IDS_DEFAULT_NEWWINUAE, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
- if (path_type == PATH_TYPE_NEWWINUAE)
- selpath = numtypes;
- ptypes[numtypes++] = PATH_TYPE_NEWWINUAE;
- }
- if ((af_path_2005 & 3) == 2) {
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("AmigaForeverData"));
- if (path_type == PATH_TYPE_AMIGAFOREVERDATA)
- selpath = numtypes;
- ptypes[numtypes++] = PATH_TYPE_AMIGAFOREVERDATA;
- }
- WIN32GUI_LoadUIString (IDS_DEFAULT_WINUAE, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
- if (path_type == PATH_TYPE_WINUAE || path_type == PATH_TYPE_DEFAULT)
- selpath = numtypes;
- ptypes[numtypes++] = PATH_TYPE_WINUAE;
- SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_SETCURSEL, selpath, 0);
- EnableWindow (GetDlgItem (hDlg, IDC_PATHS_DEFAULTTYPE), numtypes > 0 ? TRUE : FALSE);
- SetWindowText (GetDlgItem (hDlg, IDC_LOGPATH), bootlogpath);
- SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_ADDSTRING, 0, (LPARAM)_T("winuaebootlog.txt"));
- SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_ADDSTRING, 0, (LPARAM)_T("winuaelog.txt"));
- WIN32GUI_LoadUIString (IDS_CURRENT_CONFIGURATION, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_SETCURSEL, 0, 0);
- CheckDlgButton (hDlg, IDC_LOGENABLE, winuaelog_temporary_enable || (full_property_sheet == 0 && currprefs.win32_logfile));
- ew (hDlg, IDC_LOGENABLE, winuaelog_temporary_enable == false && full_property_sheet);
- extern int consoleopen;
- if (consoleopen || !full_property_sheet) {
- CheckDlgButton (hDlg, IDC_LOGENABLE2, consoleopen ? TRUE : FALSE);
- ew (hDlg, IDC_LOGENABLE2, FALSE);
- }
- values_to_pathsdialog (hDlg);
- recursive--;
- return TRUE;
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) {
- switch (LOWORD (wParam))
- {
- case IDC_LOGSELECT:
- val = SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_GETCURSEL, 0, 0L);
- if (val == 0) {
- SetWindowText (GetDlgItem (hDlg, IDC_LOGPATH), bootlogpath);
- ew (hDlg, IDC_LOGOPEN, bootlogpath[0]);
- } else if (val == 1) {
- SetWindowText (GetDlgItem (hDlg, IDC_LOGPATH), logpath);
- ew (hDlg, IDC_LOGOPEN, logpath[0]);
- } else if (val == 2) {
- SetWindowText (GetDlgItem (hDlg, IDC_LOGPATH), _T("Configuration"));
- ew (hDlg, IDC_LOGOPEN, TRUE);
- }
- break;
- }
- } else {
- switch (LOWORD (wParam))
- {
- case IDC_REGISTRYMODE:
- bool switchreginimode(void);
- switchreginimode();
- CheckDlgButton(hDlg, IDC_REGISTRYMODE, getregmode() != NULL);
- break;
- case IDC_LOGSAVE:
- savelog (hDlg, 1);
- break;
- case IDC_LOGENABLE:
- winuaelog_temporary_enable = ischecked (hDlg, IDC_LOGENABLE);
- break;
- case IDC_LOGENABLE2:
- extern int console_logging;
- console_logging = 1;
- break;
- case IDC_LOGOPEN:
- flush_log ();
- val = SendDlgItemMessage (hDlg, IDC_LOGSELECT, CB_GETCURSEL, 0, 0L);
- if (val == 0) {
- if (bootlogpath[0])
- ShellExecute (NULL, _T("open"), bootlogpath, NULL, NULL, SW_SHOWNORMAL);
- } else if (val == 1) {
- if (logpath[0])
- ShellExecute (NULL, _T("open"), logpath, NULL, NULL, SW_SHOWNORMAL);
- } else if (val == 2) {
- savelog (hDlg, 0);
- }
- break;
- case IDC_PATHS_ROMS:
- fetch_path (_T("KickstartPath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- load_keyring (&workprefs, NULL);
- set_path (_T("KickstartPath"), tmp);
- if (!scan_roms (hDlg, 1))
- gui_message_id (IDS_ROMSCANNOROMS);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_ROM:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_ROM), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("KickstartPath"), tmp);
- break;
- case IDC_PATHS_CONFIGS:
- fetch_path (_T("ConfigurationPath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("ConfigurationPath"), tmp);
- values_to_pathsdialog (hDlg);
- FreeConfigStore ();
- }
- break;
- case IDC_PATHS_CONFIG:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_CONFIG), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("ConfigurationPath"), tmp);
- FreeConfigStore ();
- break;
- case IDC_PATHS_SCREENSHOTS:
- fetch_path (_T("ScreenshotPath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("ScreenshotPath"), tmp);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_SCREENSHOT:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SCREENSHOT), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("ScreenshotPath"), tmp);
- break;
- case IDC_PATHS_SAVESTATES:
- fetch_path (_T("StatefilePath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("StatefilePath"), tmp);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_SAVESTATE:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVESTATE), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("StatefilePath"), tmp);
- break;
- case IDC_PATHS_SAVEIMAGES:
- fetch_path (_T("SaveimagePath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("SaveimagePath"), tmp);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_SAVEIMAGE:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVEIMAGE), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("SaveimagePath"), tmp);
- break;
- case IDC_PATHS_AVIOUTPUTS:
- fetch_path (_T("VideoPath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("VideoPath"), tmp);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_RIPS:
- fetch_path (_T("RipperPath"), tmp, sizeof (tmp) / sizeof (TCHAR));
- if (DirectorySelection (hDlg, &pathsguid, tmp)) {
- set_path (_T("RipperPath"), tmp);
- values_to_pathsdialog (hDlg);
- }
- break;
- case IDC_PATHS_AVIOUTPUT:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_AVIOUTPUT), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("VideoPath"), tmp);
- break;
- case IDC_PATHS_RIP:
- GetWindowText (GetDlgItem (hDlg, IDC_PATHS_RIP), tmp, sizeof (tmp) / sizeof (TCHAR));
- set_path (_T("RipperPath"), tmp);
- break;
- case IDC_PATHS_DEFAULT:
- val = SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_GETCURSEL, 0, 0L);
- if (val != CB_ERR && val >= 0 && val < numtypes) {
- val = ptypes[val];
- if (val == PATH_TYPE_WINUAE) {
- _tcscpy (start_path_data, start_path_exe);
- path_type = PATH_TYPE_WINUAE;
- } else if (val == PATH_TYPE_NEWWINUAE && start_path_new1[0]) {
- _tcscpy (start_path_data, start_path_new1);
- path_type = PATH_TYPE_NEWWINUAE;
- create_afnewdir(0);
- } else if (val == PATH_TYPE_NEWAF && start_path_new1[0]) {
- path_type = PATH_TYPE_NEWAF;
- create_afnewdir(0);
- _tcscpy (start_path_data, start_path_new1);
- } else if (val == PATH_TYPE_AMIGAFOREVERDATA && start_path_new2[0]) {
- path_type = PATH_TYPE_AMIGAFOREVERDATA;
- _tcscpy (start_path_data, start_path_new1);
- }
- SetCurrentDirectory (start_path_data);
- setpathmode (path_type);
- set_path (_T("KickstartPath"), NULL, path_type);
- set_path (_T("ConfigurationPath"), NULL, path_type);
- set_path (_T("ScreenshotPath"), NULL, path_type);
- set_path (_T("StatefilePath"), NULL, path_type);
- set_path (_T("SaveimagePath"), NULL, path_type);
- set_path (_T("VideoPath"), NULL, path_type);
- set_path (_T("RipperPath"), NULL, path_type);
- set_path (_T("InputPath"), NULL, path_type);
- values_to_pathsdialog (hDlg);
- FreeConfigStore ();
- }
- break;
- case IDC_ROM_RESCAN:
- scan_roms (hDlg, 1);
- break;
- case IDC_RESETREGISTRY:
- resetregistry ();
- break;
- case IDC_RESETDISKHISTORY:
- reset_disk_history ();
- break;
- case IDC_PATHS_RECURSIVEROMS:
- recursiveromscan = ischecked (hDlg, IDC_PATHS_RECURSIVEROMS) ? 2 : 0;
- regsetint (NULL, _T("RecursiveROMScan"), recursiveromscan);
- break;
- case IDC_PATHS_CONFIGCACHE:
- configurationcache = ischecked(hDlg, IDC_PATHS_CONFIGCACHE) ? 1 : 0;
- regsetint(NULL, _T("ConfigurationCache"), configurationcache);
- deleteconfigcache();
- break;
- case IDC_PATHS_ARTCACHE:
- artcache = ischecked(hDlg, IDC_PATHS_ARTCACHE) ? 1 : 0;
- regsetint(NULL, _T("ArtCache"), artcache);
- deleteconfigcache();
- break;
- case IDC_PATHS_SAVEIMAGEORIGINALPATH:
- saveimageoriginalpath = ischecked (hDlg, IDC_PATHS_SAVEIMAGEORIGINALPATH) ? 1 : 0;
- regsetint (NULL, _T("SaveImageOriginalPath"), saveimageoriginalpath);
- break;
- case IDC_PATHS_RELATIVE:
- relativepaths = ischecked (hDlg, IDC_PATHS_RELATIVE) ? 1 : 0;
- regsetint (NULL, _T("RelativePaths"), relativepaths);
- rewritepaths();
- break;
- }
- }
- recursive--;
- }
- return FALSE;
- }
- struct amigamodels {
- int compalevels;
- int id;
- int resetlevels[6];
- };
- static struct amigamodels amodels[] = {
- { 4, IDS_QS_MODEL_A500, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 500"
- { 4, IDS_QS_MODEL_A500P, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 500+"
- { 4, IDS_QS_MODEL_A600, { 0, 0, 1, 0, 0, 0 } }, // "Amiga 600"
- { 4, IDS_QS_MODEL_A1000, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 1000"
- { 5, IDS_QS_MODEL_A1200, { 0, 1, 2, 3, 4, 5 } }, // "Amiga 1200"
- { 2, IDS_QS_MODEL_A3000, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 3000"
- { 1, IDS_QS_MODEL_A4000, { 0, 0, 1, 0, 0, 0 } }, // "Amiga 4000"
- { 0, }, //{ 1, IDS_QS_MODEL_A4000T }, // "Amiga 4000T"
- { 4, IDS_QS_MODEL_CD32, { 0, 0, 1, 0, 0, 0 } }, // "CD32"
- { 4, IDS_QS_MODEL_CDTV, { 0, 0, 1, 0, 0, 0 } }, // "CDTV"
- { 4, IDS_QS_MODEL_ARCADIA, { 0, 0, 0, 0, 0, 0 } }, // "Arcadia"
- { 1, IDS_QS_MODEL_MACROSYSTEM, { 0, 0, 0, 0, 0, 0 } },
- { 1, IDS_QS_MODEL_UAE, { 0, 0, 0, 0, 0, 0 } }, // "Expanded UAE example configuration"
- { -1 }
- };
- static void enable_for_quickstart (HWND hDlg)
- {
- int v = quickstart_ok && quickstart_ok_floppy ? TRUE : FALSE;
- ew (guiDlg, IDC_RESETAMIGA, !full_property_sheet ? TRUE : FALSE);
- ShowWindow (GetDlgItem (hDlg, IDC_QUICKSTART_SETCONFIG), quickstart ? SW_HIDE : SW_SHOW);
- }
- static void load_quickstart (HWND hDlg, int romcheck)
- {
- ew (guiDlg, IDC_RESETAMIGA, FALSE);
- workprefs.nr_floppies = quickstart_floppy;
- quickstart_ok = built_in_prefs (&workprefs, quickstart_model, quickstart_conf, quickstart_compa, romcheck);
- workprefs.ntscmode = quickstart_ntsc != 0;
- quickstart_cd = workprefs.floppyslots[1].dfxtype == DRV_NONE && (quickstart_model == 8 || quickstart_model == 9);
- // DF0: HD->DD
- if (quickstart_model <= 4) {
- if (quickstart_floppytype[0] == 1) {
- quickstart_floppytype[0] = 0;
- }
- }
- for (int i = 0; i < 2; i++) {
- if (i < quickstart_floppy) {
- workprefs.floppyslots[i].dfxtype = quickstart_floppytype[i];
- workprefs.floppyslots[i].dfxsubtype = quickstart_floppysubtype[i];
- _tcscpy(workprefs.floppyslots[i].dfxsubtypeid, quickstart_floppysubtypeid[i]);
- } else {
- workprefs.floppyslots[i].dfxtype = DRV_NONE;
- workprefs.floppyslots[i].dfxsubtype = 0;
- workprefs.floppyslots[i].dfxsubtypeid[0] = 0;
- }
- }
- floppybridge_init(&workprefs);
- enable_for_quickstart (hDlg);
- addfloppytype (hDlg, 0);
- addfloppytype (hDlg, 1);
- addfloppyhistory (hDlg);
- config_filename[0] = 0;
- setguititle (NULL);
- }
- static void quickstarthost (HWND hDlg, TCHAR *name)
- {
- int type = CONFIG_TYPE_HOST;
- TCHAR tmp[MAX_DPATH];
- if (getconfigstorefrompath (name, tmp, CONFIG_TYPE_HOST)) {
- if (cfgfile_load (&workprefs, tmp, &type, 1, 0))
- workprefs.start_gui = 1;
- }
- }
- static void init_quickstartdlg_tooltip (HWND hDlg, TCHAR *tt)
- {
- TOOLINFO ti;
- ti.cbSize = sizeof (TOOLINFO);
- ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
- ti.hwnd = hDlg;
- ti.hinst = hInst;
- ti.uId = (UINT_PTR)GetDlgItem (hDlg, IDC_QUICKSTART_CONFIGURATION);
- ti.lpszText = tt;
- SendMessage (ToolTipHWND, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
- if (!tt)
- return;
- SendMessage (ToolTipHWND, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
- }
- static void init_quickstartdlg (HWND hDlg)
- {
- static int firsttime;
- int i, j, idx, idx2, qssize, total;
- TCHAR tmp1[2 * MAX_DPATH], tmp2[MAX_DPATH], hostconf[MAX_DPATH];
- TCHAR *p1, *p2;
- firstautoloadconfig = false;
- qssize = sizeof (tmp1) / sizeof (TCHAR);
- regquerystr (NULL, _T("QuickStartHostConfig"), hostconf, &qssize);
- if (firsttime == 0 && workprefs.start_gui) {
- int size;
- regqueryint(NULL, _T("QuickStartModel"), &quickstart_model);
- regqueryint(NULL, _T("QuickStartConfiguration"), &quickstart_conf);
- quickstart_model_confstore[quickstart_model] = quickstart_conf;
- regqueryint(NULL, _T("QuickStartCompatibility"), &quickstart_compa);
- regqueryint(NULL, _T("QuickStartFloppies"), &quickstart_floppy);
- regqueryint(NULL, _T("QuickStartDF0Type"), &quickstart_floppytype[0]);
- regqueryint(NULL, _T("QuickStartDF1Type"), &quickstart_floppytype[1]);
- regqueryint(NULL, _T("QuickStartDF0SubType"), &quickstart_floppysubtype[0]);
- regqueryint(NULL, _T("QuickStartDF1SubType"), &quickstart_floppysubtype[1]);
- size = 30;
- regquerystr(NULL, _T("QuickStartDF0SubTypeID"), quickstart_floppysubtypeid[0], &size);
- size = 30;
- regquerystr(NULL, _T("QuickStartDF1SubTypeID"), quickstart_floppysubtypeid[1], &size);
- regqueryint(NULL, _T("QuickStartCDType"), &quickstart_cdtype);
- size = sizeof quickstart_cddrive / sizeof (TCHAR);
- regquerystr(NULL, _T("QuickStartCDDrive"), quickstart_cddrive, &size);
- regqueryint(NULL, _T("QuickStartNTSC"), &quickstart_ntsc);
- if (quickstart) {
- workprefs.floppyslots[0].df[0] = 0;
- workprefs.floppyslots[1].df[0] = 0;
- workprefs.floppyslots[2].df[0] = 0;
- workprefs.floppyslots[3].df[0] = 0;
- workprefs.cdslots[0].name[0] = 0;
- workprefs.cdslots[0].inuse = quickstart_cdtype > 0;
- load_quickstart (hDlg, 1);
- quickstarthost (hDlg, hostconf);
- }
- }
- firsttime = 1;
- CheckDlgButton (hDlg, IDC_QUICKSTARTMODE, quickstart);
- CheckDlgButton (hDlg, IDC_NTSC, quickstart_ntsc != 0);
- WIN32GUI_LoadUIString (IDS_QS_MODELS, tmp1, sizeof (tmp1) / sizeof (TCHAR));
- _tcscat (tmp1, _T("\n"));
- p1 = tmp1;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_RESETCONTENT, 0, 0L);
- idx = idx2 = 0;
- i = 0;
- while (amodels[i].compalevels >= 0) {
- if (amodels[i].compalevels > 0) {
- p2 = _tcschr (p1, '\n');
- if (p2 && _tcslen (p2) > 0) {
- *p2++ = 0;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- }
- if (i == quickstart_model)
- idx2 = idx;
- idx++;
- }
- i++;
- }
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_SETCURSEL, idx2, 0);
- total = 0;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_RESETCONTENT, 0, 0L);
- if (amodels[quickstart_model].id == IDS_QS_MODEL_ARCADIA) {
- struct romlist **rl = getarcadiaroms ();
- for (i = 0; rl[i]; i++) {
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_ADDSTRING, 0, (LPARAM)rl[i]->rd->name);
- total++;
- }
- xfree (rl);
- } else {
- WIN32GUI_LoadUIString (amodels[quickstart_model].id, tmp1, sizeof (tmp1) / sizeof (TCHAR));
- _tcscat (tmp1, _T("\n"));
- p1 = tmp1;
- init_quickstartdlg_tooltip (hDlg, 0);
- total = 0;
- for (;;) {
- p2 = _tcschr (p1, '\n');
- if (!p2)
- break;
- *p2++= 0;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- p2 = _tcschr (p1, '\n');
- if (!p2)
- break;
- *p2++= 0;
- if (quickstart_conf == total && _tcslen (p1) > 0)
- init_quickstartdlg_tooltip (hDlg, p1);
- p1 = p2;
- total++;
- }
- }
- if (quickstart_conf >= total)
- quickstart_conf = 0;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_SETCURSEL, quickstart_conf, 0);
- if (quickstart_compa >= amodels[quickstart_model].compalevels)
- quickstart_compa = 1;
- if (quickstart_compa >= amodels[quickstart_model].compalevels)
- quickstart_compa = 0;
- i = amodels[quickstart_model].compalevels;
- ew (hDlg, IDC_QUICKSTART_COMPATIBILITY, i > 1);
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, TBM_SETRANGE, TRUE, MAKELONG (0, i > 1 ? i - 1 : 1));
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_COMPATIBILITY, TBM_SETPOS, TRUE, quickstart_compa);
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_RESETCONTENT, 0, 0L);
- WIN32GUI_LoadUIString (IDS_DEFAULT_HOST, tmp1, sizeof (tmp1) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp1);
- idx = 0;
- j = 1;
- for (i = 0; i < configstoresize; i++) {
- if (configstore[i]->Type == CONFIG_TYPE_HOST) {
- _tcscpy (tmp2, configstore[i]->Path);
- _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH - _tcslen(tmp2));
- if (!_tcscmp (tmp2, hostconf))
- idx = j;
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp2);
- j++;
- }
- }
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_SETCURSEL, idx, 0);
- regsetint (NULL, _T("QuickStartModel"), quickstart_model);
- regsetint (NULL, _T("QuickStartConfiguration"), quickstart_conf);
- regsetint (NULL, _T("QuickStartCompatibility"), quickstart_compa);
- }
- static void floppytooltip (HWND hDlg, int num, uae_u32 crc32);
- static void testimage (HWND hDlg, int num)
- {
- int ret;
- int reload = 0;
- struct diskinfo di;
- int messageid = -1;
- TCHAR tmp[MAX_DPATH];
- floppytooltip (hDlg, num, 0);
- quickstart_ok_floppy = 0;
- if (workprefs.floppyslots[0].dfxtype < 0) {
- quickstart_ok_floppy = 1;
- return;
- }
- if (!workprefs.floppyslots[num].df[0])
- return;
- floppybridge_init(&workprefs);
- ret = DISK_examine_image (&workprefs, num, &di, false, NULL);
- if (!ret)
- return;
- floppytooltip (hDlg, num, di.imagecrc32);
- if (num > 0)
- return;
- if (!full_property_sheet)
- return;
- switch (ret)
- {
- case 10:
- quickstart_ok_floppy = 1;
- break;
- case 11:
- quickstart_ok_floppy = 1;
- if (quickstart_model != 1 && quickstart_model != 2 && quickstart_model != 4 &&
- quickstart_model != 5 && quickstart_model != 6 && quickstart_model != 8 && quickstart_model != 11) {
- quickstart_model = 4;
- messageid = IDS_IMGCHK_KS2;
- reload = 1;
- }
- break;
- case 12:
- quickstart_ok_floppy = 1;
- if (quickstart_model != 4 && quickstart_model != 8 && quickstart_model != 11) {
- quickstart_model = 4;
- messageid = IDS_IMGCHK_KS3;
- reload = 1;
- }
- break;
- case 4:
- messageid = IDS_IMGCHK_BOOTBLOCKNO;
- break;
- case 3:
- messageid = IDS_IMGCHK_BOOTBLOCKCRCERROR;
- break;
- case 2:
- messageid = IDS_IMGCHK_DAMAGED;
- break;
- }
- if (messageid > 0) {
- WIN32GUI_LoadUIString (messageid, tmp, sizeof (tmp) / sizeof (TCHAR));
- gui_message (tmp);
- }
- if (reload && quickstart) {
- load_quickstart (hDlg, 1);
- init_quickstartdlg (hDlg);
- }
- }
- static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
- static int diskselectmenu (HWND hDlg, WPARAM wParam);
- static void addallfloppies (HWND hDlg);
- #define BUTTONSPERFLOPPY 9
- static const int floppybuttons[][BUTTONSPERFLOPPY] = {
- { IDC_DF0TEXT,IDC_DF0,IDC_EJECT0,IDC_DF0TYPE,IDC_DF0WP,-1,IDC_SAVEIMAGE0,IDC_DF0ENABLE, IDC_INFO0 },
- { IDC_DF1TEXT,IDC_DF1,IDC_EJECT1,IDC_DF1TYPE,IDC_DF1WP,-1,IDC_SAVEIMAGE1,IDC_DF1ENABLE, IDC_INFO1 },
- { IDC_DF2TEXT,IDC_DF2,IDC_EJECT2,IDC_DF2TYPE,IDC_DF2WP,-1,IDC_SAVEIMAGE2,IDC_DF2ENABLE, IDC_INFO2 },
- { IDC_DF3TEXT,IDC_DF3,IDC_EJECT3,IDC_DF3TYPE,IDC_DF3WP,-1,IDC_SAVEIMAGE3,IDC_DF3ENABLE, IDC_INFO3 }
- };
- static const int floppybuttonsq[][BUTTONSPERFLOPPY] = {
- { IDC_DF0TEXTQ,IDC_DF0QQ,IDC_EJECT0Q,IDC_DF0TYPE,IDC_DF0WPQ,IDC_DF0WPTEXTQ,-1,IDC_DF0QENABLE, IDC_INFO0Q },
- { IDC_DF1TEXTQ,IDC_DF1QQ,IDC_EJECT1Q,IDC_DF1TYPE,IDC_DF1WPQ,IDC_DF1WPTEXTQ,-1,IDC_DF1QENABLE, IDC_INFO1Q },
- { -1,-1,-1,-1,-1,-1,-1,-1 },
- { -1,-1,-1,-1,-1,-1,-1,-1 }
- };
- static int fromdfxtype(int num, int dfx, int subtype)
- {
- if (currentpage == QUICKSTART_ID) {
- switch (dfx)
- {
- case DRV_35_DD:
- return 0;
- case DRV_35_HD:
- return 1;
- }
- if (dfx == DRV_FB) {
- return 2 + subtype;
- }
- return -1;
- }
- switch (dfx)
- {
- case DRV_35_DD:
- return 0;
- case DRV_35_HD:
- return 1;
- case DRV_525_SD:
- return 2;
- case DRV_525_DD:
- return 3;
- case DRV_35_DD_ESCOM:
- return 4;
- }
- if (num < 2) {
- if (dfx == DRV_FB) {
- return 5 + subtype;
- }
- } else {
- switch (dfx)
- {
- case DRV_PC_525_ONLY_40:
- return 5;
- case DRV_PC_525_40_80:
- return 6;
- case DRV_PC_35_ONLY_80:
- return 7;
- }
- if (dfx == DRV_FB) {
- return 8 + subtype;
- }
- }
- return -1;
- }
- static int todfxtype(int num, int dfx, int *subtype)
- {
- *subtype = 0;
- if (currentpage == QUICKSTART_ID) {
- switch (dfx)
- {
- case 0:
- return DRV_35_DD;
- case 1:
- return DRV_35_HD;
- }
- if (dfx >= 2) {
- *subtype = dfx - 2;
- return DRV_FB;
- }
- return -1;
- }
- switch (dfx)
- {
- case 0:
- return DRV_35_DD;
- case 1:
- return DRV_35_HD;
- case 2:
- return DRV_525_SD;
- case 3:
- return DRV_525_DD;
- case 4:
- return DRV_35_DD_ESCOM;
- }
- if (num < 2) {
- if (dfx >= 5) {
- *subtype = dfx - 5;
- return DRV_FB;
- }
- } else {
- switch (dfx)
- {
- case 5:
- return DRV_PC_525_ONLY_40;
- case 6:
- return DRV_PC_525_40_80;
- case 7:
- return DRV_PC_35_ONLY_80;
- }
- if (dfx >= 8) {
- *subtype = dfx - 8;
- return DRV_FB;
- }
- }
- return -1;
- }
- static void setfloppytexts (HWND hDlg, int qs)
- {
- SetDlgItemText (hDlg, IDC_DF0TEXT, workprefs.floppyslots[0].df);
- SetDlgItemText (hDlg, IDC_DF1TEXT, workprefs.floppyslots[1].df);
- SetDlgItemText (hDlg, IDC_DF2TEXT, workprefs.floppyslots[2].df);
- SetDlgItemText (hDlg, IDC_DF3TEXT, workprefs.floppyslots[3].df);
- SetDlgItemText (hDlg, IDC_DF0TEXTQ, workprefs.floppyslots[0].df);
- SetDlgItemText (hDlg, IDC_DF1TEXTQ, workprefs.floppyslots[1].df);
- if (!qs)
- addallfloppies (hDlg);
- }
- static void updatefloppytypes(HWND hDlg)
- {
- TCHAR ft35dd[20], ft35hd[20], ft525sd[20], ft35ddescom[20];
- bool qs = currentpage == QUICKSTART_ID;
- WIN32GUI_LoadUIString(IDS_FLOPPYTYPE35DD, ft35dd, sizeof ft35dd / sizeof(TCHAR));
- WIN32GUI_LoadUIString(IDS_FLOPPYTYPE35HD, ft35hd, sizeof ft35hd / sizeof(TCHAR));
- WIN32GUI_LoadUIString(IDS_FLOPPYTYPE525SD, ft525sd, sizeof ft525sd / sizeof(TCHAR));
- WIN32GUI_LoadUIString(IDS_FLOPPYTYPE35DDESCOM, ft35ddescom, sizeof ft35ddescom / sizeof(TCHAR));
- for (int i = 0; i < (qs ? 2 : 4); i++) {
- int f_type;
- if (qs) {
- f_type = floppybuttonsq[i][3];
- } else {
- f_type = floppybuttons[i][3];
- }
- SendDlgItemMessage(hDlg, f_type, CB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)ft35dd);
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)ft35hd);
- if (!qs) {
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)ft525sd);
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)_T("5.25\" (80)"));
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)ft35ddescom);
- if (i >= 2) {
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)_T("Bridgeboard 5.25\" 40"));
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)_T("Bridgeboard 5.25\" 80"));
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)_T("Bridgeboard 3.5\" 80"));
- }
- }
- if (floppybridge_available) {
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)_T("Configure FloppyBridge"));
- for (int j = 0; j < bridgeprofiles.size(); j++) {
- FloppyBridgeAPI::FloppyBridgeProfileInformation fbpi = bridgeprofiles.at(j);
- TCHAR tmp[256];
- if (_tcslen(fbpi.name) < sizeof(tmp) - 10) {
- _stprintf(tmp, _T("FB: %s"), fbpi.name);
- SendDlgItemMessage(hDlg, f_type, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- }
- }
- int nn;
- if (qs) {
- nn = fromdfxtype(i, quickstart_floppytype[i], quickstart_floppysubtype[i]);
- } else {
- nn = fromdfxtype(i, workprefs.floppyslots[i].dfxtype, workprefs.floppyslots[i].dfxsubtype);
- }
- SendDlgItemMessage(hDlg, f_type, CB_SETCURSEL, nn, 0L);
- }
- }
- static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive;
- int ret = FALSE, i;
- TCHAR tmp[MAX_DPATH];
- static TCHAR df0[MAX_DPATH];
- static TCHAR df1[MAX_DPATH];
- static int dfxtype[2] = { -1, -1 };
- static int doinit;
- LRESULT val;
- if (dialog_inhibit)
- return 0;
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- int ids[] = { IDC_DF0TEXTQ, IDC_DF1TEXTQ, -1 };
- pages[QUICKSTART_ID] = hDlg;
- currentpage = QUICKSTART_ID;
- enable_for_quickstart (hDlg);
- setfloppytexts (hDlg, true);
- floppybridge_init(&workprefs);
- setmultiautocomplete (hDlg, ids);
- doinit = 1;
- break;
- }
- case WM_NULL:
- if (recursive > 0)
- break;
- recursive++;
- if (doinit) {
- addfloppytype (hDlg, 0);
- addfloppytype (hDlg, 1);
- addfloppyhistory (hDlg);
- init_quickstartdlg (hDlg);
- updatefloppytypes(hDlg);
- }
- doinit = 0;
- recursive--;
- break;
- case WM_CONTEXTMENU:
- if (recursive > 0)
- break;
- recursive++;
- diskselectmenu (hDlg, wParam);
- setfloppytexts (hDlg, true);
- recursive--;
- break;
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) {
- switch (LOWORD (wParam))
- {
- case IDC_CD0Q_TYPE:
- val = SendDlgItemMessage (hDlg, IDC_CD0Q_TYPE, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR) {
- quickstart_cdtype = val;
- if (full_property_sheet)
- workprefs.cdslots[0].type = SCSI_UNIT_DEFAULT;
- if (quickstart_cdtype >= 2) {
- int len = sizeof quickstart_cddrive / sizeof (TCHAR);
- quickstart_cdtype = 2;
- SendDlgItemMessage (hDlg, IDC_CD0Q_TYPE, WM_GETTEXT, (WPARAM)len, (LPARAM)quickstart_cddrive);
- _tcscpy (workprefs.cdslots[0].name, quickstart_cddrive);
- } else {
- eject_cd ();
- quickstart_cdtype = val;
- }
- workprefs.cdslots[0].inuse = quickstart_cdtype > 0;
- addfloppytype (hDlg, 1);
- addfloppyhistory (hDlg);
- }
- break;
- case IDC_QUICKSTART_MODEL:
- val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_GETCURSEL, 0, 0L);
- if (val != CB_ERR) {
- i = 0;
- while (amodels[i].compalevels >= 0) {
- if (amodels[i].compalevels > 0)
- val--;
- if (val < 0)
- break;
- i++;
- }
- if (i != quickstart_model) {
- quickstart_model = i;
- quickstart_conf = quickstart_model_confstore[quickstart_model];
- init_quickstartdlg (hDlg);
- if (quickstart)
- load_quickstart (hDlg, 1);
- if (quickstart && !full_property_sheet)
- qs_request_reset |= 4;
- }
- }
- break;
- case IDC_QUICKSTART_CONFIGURATION:
- val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_GETCURSEL, 0, 0L);
- if (val != CB_ERR && val != quickstart_conf) {
- int rslevel = amodels[quickstart_model].resetlevels[quickstart_conf];
- quickstart_conf = val;
- if (!full_property_sheet && amodels[quickstart_model].resetlevels[quickstart_conf] != rslevel) {
- qs_request_reset |= 4;
- }
- quickstart_model_confstore[quickstart_model] = quickstart_conf;
- init_quickstartdlg (hDlg);
- if (quickstart)
- load_quickstart (hDlg, 1);
- if (quickstart && !full_property_sheet)
- qs_request_reset |= 2;
- }
- break;
- case IDC_QUICKSTART_HOSTCONFIG:
- val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR) {
- SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp);
- regsetstr (NULL, _T("QuickStartHostConfig"), tmp);
- quickstarthost (hDlg, tmp);
- if (val == 0 && quickstart)
- load_quickstart (hDlg, 0);
- }
- break;
- }
- } else {
- switch (LOWORD (wParam))
- {
- case IDC_NTSC:
- quickstart_ntsc = ischecked (hDlg, IDC_NTSC);
- regsetint (NULL, _T("QuickStartNTSC"), quickstart_ntsc);
- if (quickstart) {
- init_quickstartdlg (hDlg);
- load_quickstart (hDlg, 0);
- }
- break;
- case IDC_QUICKSTARTMODE:
- quickstart = ischecked (hDlg, IDC_QUICKSTARTMODE);
- regsetint (NULL, _T("QuickStartMode"), quickstart);
- quickstart_cd = 0;
- if (quickstart) {
- init_quickstartdlg (hDlg);
- load_quickstart (hDlg, 0);
- }
- enable_for_quickstart (hDlg);
- break;
- }
- }
- switch (LOWORD (wParam))
- {
- case IDC_DF0TEXTQ:
- case IDC_DF0WPQ:
- case IDC_EJECT0Q:
- case IDC_DF0QQ:
- case IDC_DF1TEXTQ:
- case IDC_DF1WPQ:
- case IDC_EJECT1Q:
- case IDC_DF1QQ:
- case IDC_DF0QENABLE:
- case IDC_DF1QENABLE:
- case IDC_INFO0Q:
- case IDC_INFO1Q:
- case IDC_DF0TYPE:
- case IDC_DF1TYPE:
- if (currentpage == QUICKSTART_ID)
- ret = FloppyDlgProc (hDlg, msg, wParam, lParam);
- break;
- case IDC_QUICKSTART_SETCONFIG:
- load_quickstart (hDlg, 1);
- break;
- }
- recursive--;
- case WM_HSCROLL:
- if (recursive > 0)
- break;
- recursive++;
- if ((HWND)lParam == GetDlgItem (hDlg, IDC_QUICKSTART_COMPATIBILITY)) {
- val = SendMessage ((HWND)lParam, TBM_GETPOS, 0, 0);
- if (val >= 0 && val != quickstart_compa) {
- quickstart_compa = val;
- init_quickstartdlg (hDlg);
- if (quickstart)
- load_quickstart (hDlg, 0);
- }
- }
- recursive--;
- break;
- }
- if (recursive == 0 && quickstart) {
- recursive++;
- if (_tcscmp (workprefs.floppyslots[0].df, df0) || workprefs.floppyslots[0].dfxtype != dfxtype[0]) {
- _tcscpy (df0, workprefs.floppyslots[0].df);
- dfxtype[0] = workprefs.floppyslots[0].dfxtype;
- testimage (hDlg, 0);
- enable_for_quickstart (hDlg);
- }
- if (_tcscmp (workprefs.floppyslots[1].df, df1) || workprefs.floppyslots[1].dfxtype != dfxtype[1]) {
- _tcscpy (df1, workprefs.floppyslots[1].df);
- dfxtype[1] = workprefs.floppyslots[1].dfxtype;
- testimage (hDlg, 1);
- }
- recursive--;
- }
- return ret;
- }
- static void init_aboutdlg (HWND hDlg)
- {
- CHARFORMAT CharFormat;
- int i;
- CharFormat.cbSize = sizeof (CharFormat);
- SetDlgItemText (hDlg, IDC_RICHEDIT1, _T("WinUAE"));
- SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
- CharFormat.dwMask |= CFM_BOLD | CFM_SIZE | CFM_FACE;
- CharFormat.dwEffects = CFE_BOLD;
- CharFormat.yHeight = 24 * 20; /* height in twips, where a twip is 1/20th of a point */
- _tcscpy (CharFormat.szFaceName, os_vista ? _T("Segoe UI") : _T("Tahoma"));
- SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
- SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
- SetDlgItemText (hDlg, IDC_RICHEDIT2, VersionStr );
- SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
- CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
- CharFormat.yHeight = 12 * 20;
- _tcscpy (CharFormat.szFaceName, os_vista ? _T("Segoe UI") : _T("Tahoma"));
- SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
- SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
- for(i = 0; urls[i].id >= 0; i++)
- SetupRichText (hDlg, &urls[i]);
- }
- static INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- if (dialog_inhibit)
- return 0;
- switch( msg )
- {
- case WM_INITDIALOG:
- pages[ABOUT_ID] = hDlg;
- currentpage = ABOUT_ID;
- init_aboutdlg (hDlg);
- break;
- case WM_COMMAND:
- if (wParam == IDC_CONTRIBUTORS)
- DisplayContributors (hDlg);
- break;
- case WM_SETCURSOR:
- return TRUE;
- break;
- case WM_LBUTTONDOWN:
- case WM_MOUSEMOVE:
- url_handler (hDlg, msg, wParam, lParam);
- break;
- }
- return FALSE;
- }
- static void enable_for_displaydlg (HWND hDlg)
- {
- int rtg = ((!workprefs.address_space_24 || gfxboard_get_configtype(&workprefs.rtgboards[0]) == 2) && workprefs.rtgboards[0].rtgmem_size) || workprefs.rtgboards[0].rtgmem_type >= GFXBOARD_HARDWARE;
- #ifndef PICASSO96
- rtg = FALSE;
- #endif
- ew(hDlg, IDC_SCREENMODE_RTG, rtg);
- ew(hDlg, IDC_SCREENMODE_RTG2, rtg);
- ew(hDlg, IDC_XCENTER, TRUE);
- ew(hDlg, IDC_YCENTER, TRUE);
- ew(hDlg, IDC_FRAMERATE, !workprefs.cpu_memory_cycle_exact);
- ew(hDlg, IDC_LORES, !workprefs.gfx_autoresolution);
- ew(hDlg, IDC_OVERSCANMODE, TRUE);
- ew(hDlg, IDC_AUTORESOLUTIONVGA, workprefs.gfx_resolution >= RES_HIRES && workprefs.gfx_vresolution >= VRES_DOUBLE);
- if (workprefs.gfx_resolution < RES_HIRES || workprefs.gfx_vresolution < VRES_DOUBLE) {
- workprefs.gfx_autoresolution_vga = false;
- CheckDlgButton (hDlg, IDC_AUTORESOLUTIONVGA, workprefs.gfx_autoresolution_vga);
- }
- bool isdouble = workprefs.gfx_vresolution > 0;
- ew (hDlg, IDC_LM_NORMAL, !workprefs.gfx_autoresolution);
- ew (hDlg, IDC_LM_DOUBLED, !workprefs.gfx_autoresolution);
- ew (hDlg, IDC_LM_SCANLINES, !workprefs.gfx_autoresolution);
- ew (hDlg, IDC_LM_PDOUBLED2, !workprefs.gfx_autoresolution);
- ew (hDlg, IDC_LM_PDOUBLED3, !workprefs.gfx_autoresolution);
- ew (hDlg, IDC_LM_INORMAL, !workprefs.gfx_autoresolution && !isdouble);
- ew (hDlg, IDC_LM_IDOUBLED, !workprefs.gfx_autoresolution && isdouble);
- ew (hDlg, IDC_LM_IDOUBLED2, !workprefs.gfx_autoresolution && isdouble);
- ew (hDlg, IDC_LM_IDOUBLED3, !workprefs.gfx_autoresolution && isdouble);
- if (workprefs.gfx_apmode[0].gfx_vsyncmode == 1 || workprefs.gfx_apmode[0].gfx_vsyncmode == 2) {
- hide(hDlg, IDC_SCREENMODE_NATIVE3, FALSE);
- ew(hDlg, IDC_SCREENMODE_NATIVE3, TRUE);
- } else {
- ew(hDlg, IDC_SCREENMODE_NATIVE3, FALSE);
- hide(hDlg, IDC_SCREENMODE_NATIVE3, TRUE);
- }
- #if WINUAEPUBLICBETA
- hide(hDlg, IDC_DISPLAY_VARSYNC, FALSE);
- #endif
- }
- static void enable_for_chipsetdlg (HWND hDlg)
- {
- int enable = workprefs.cpu_memory_cycle_exact ? FALSE : TRUE;
- #if !defined (CPUEMU_13)
- ew (hDlg, IDC_CYCLEEXACT, FALSE);
- #else
- ew (hDlg, IDC_CYCLEEXACTMEMORY, workprefs.cpu_model >= 68020);
- #endif
- if (workprefs.immediate_blits && workprefs.waiting_blits) {
- workprefs.waiting_blits = 0;
- CheckDlgButton (hDlg, IDC_BLITWAIT, FALSE);
- }
- ew(hDlg, IDC_BLITIMM, !workprefs.cpu_cycle_exact);
- ew(hDlg, IDC_GENLOCKMODE, workprefs.genlock ? TRUE : FALSE);
- ew(hDlg, IDC_GENLOCKMIX, workprefs.genlock ? TRUE : FALSE);
- ew(hDlg, IDC_GENLOCK_ALPHA, workprefs.genlock ? TRUE : FALSE);
- ew(hDlg, IDC_GENLOCK_KEEP_ASPECT, workprefs.genlock ? TRUE : FALSE);
- ew(hDlg, IDC_GENLOCKFILE, workprefs.genlock && (workprefs.genlock_image >= 6 || (workprefs.genlock_image >= 3 && workprefs.genlock_image < 5)) ? TRUE : FALSE);
- ew(hDlg, IDC_GENLOCKFILESELECT, workprefs.genlock && (workprefs.genlock_image >= 6 || (workprefs.genlock_image >= 3 && workprefs.genlock_image < 5)) ? TRUE : FALSE);
- ew(hDlg, IDC_MONITOREMU_MON, workprefs.monitoremu != 0);
- }
- static const int fakerefreshrates[] = { 50, 60, 100, 120, 0 };
- struct storedrefreshrate
- {
- int rate, type;
- };
- static struct storedrefreshrate storedrefreshrates[MAX_REFRESH_RATES + 4 + 1];
- static void init_frequency_combo (HWND hDlg, int dmode)
- {
- int i, j, freq;
- TCHAR hz[20], hz2[20], txt[100];
- LRESULT index;
- struct MultiDisplay *md = getdisplay(&workprefs, 0);
- i = 0; index = 0;
- while (dmode >= 0 && (freq = md->DisplayModes[dmode].refresh[i]) > 0 && index < MAX_REFRESH_RATES) {
- storedrefreshrates[index].rate = freq;
- storedrefreshrates[index++].type = md->DisplayModes[dmode].refreshtype[i];
- i++;
- }
- if (workprefs.gfx_apmode[0].gfx_vsyncmode == 0 && workprefs.gfx_apmode[0].gfx_vsync) {
- i = 0;
- while ((freq = fakerefreshrates[i]) > 0 && index < MAX_REFRESH_RATES) {
- for (j = 0; j < index; j++) {
- if (storedrefreshrates[j].rate == freq)
- break;
- }
- if (j == index) {
- storedrefreshrates[index].rate = -freq;
- storedrefreshrates[index++].type = 0;
- }
- i++;
- }
- }
- storedrefreshrates[index].rate = 0;
- for (i = 0; i < index; i++) {
- for (j = i + 1; j < index; j++) {
- if (abs (storedrefreshrates[i].rate) >= abs (storedrefreshrates[j].rate)) {
- struct storedrefreshrate srr;
- memcpy (&srr, &storedrefreshrates[i], sizeof (struct storedrefreshrate));
- memcpy (&storedrefreshrates[i], &storedrefreshrates[j], sizeof (struct storedrefreshrate));
- memcpy (&storedrefreshrates[j], &srr, sizeof (struct storedrefreshrate));
- }
- }
- }
- hz[0] = hz2[0] = 0;
- SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_ADDSTRING, 0, (LPARAM)txt);
- for (i = 0; i < index; i++) {
- bool lace = (storedrefreshrates[i].type & REFRESH_RATE_LACE) != 0;
- freq = storedrefreshrates[i].rate;
- if (freq < 0) {
- freq = -freq;
- _stprintf (hz, _T("(%dHz)"), freq);
- } else {
- _stprintf (hz, _T("%dHz"), freq);
- }
- if (freq == 50 || freq == 100 || (freq * 2 == 50 && lace))
- _tcscat (hz, _T(" PAL"));
- if (freq == 60 || freq == 120 || (freq * 2 == 60 && lace))
- _tcscat (hz, _T(" NTSC"));
- if (lace) {
- TCHAR tmp[10];
- _stprintf (tmp, _T(" (%di)"), freq * 2);
- _tcscat (hz, tmp);
- }
- if (storedrefreshrates[i].type & REFRESH_RATE_RAW)
- _tcscat (hz, _T(" (*)"));
- if (abs (workprefs.gfx_apmode[0].gfx_refreshrate) == freq)
- _tcscpy (hz2, hz);
- SendDlgItemMessage (hDlg, IDC_REFRESHRATE, CB_ADDSTRING, 0, (LPARAM)hz);
- }
- index = CB_ERR;
- if (hz2[0] >= 0)
- index = SendDlgItemMessage (hDlg, IDC_REFRESHRATE, CB_SELECTSTRING, 0, (LPARAM)hz2);
- if (index == CB_ERR) {
- WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_SELECTSTRING, i, (LPARAM)txt);
- workprefs.gfx_apmode[0].gfx_refreshrate = 0;
- }
- }
- #define MAX_FRAMERATE_LENGTH 40
- #define MAX_NTH_LENGTH 20
- static int display_mode_index (uae_u32 x, uae_u32 y, uae_u32 d)
- {
- int i, j;
- struct MultiDisplay *md = getdisplay(&workprefs, 0);
- j = 0;
- for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
- if (md->DisplayModes[i].res.width == x &&
- md->DisplayModes[i].res.height == y &&
- md->DisplayModes[i].depth == d)
- break;
- j++;
- }
- if (x == 0 && y == 0) {
- j = 0;
- for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
- if (md->DisplayModes[i].res.width == md->rect.right - md->rect.left &&
- md->DisplayModes[i].res.height == md->rect.bottom - md->rect.top &&
- md->DisplayModes[i].depth == d)
- break;
- j++;
- }
- }
- if(md->DisplayModes[i].depth < 0)
- j = -1;
- return j;
- }
- static int da_mode_selected, da_mode_multiplier;
- static int *getp_da (HWND hDlg)
- {
- int vmin = -200;
- int vmax = 200;
- da_mode_multiplier = 10;
- int *p = 0;
- switch (da_mode_selected)
- {
- case 0:
- p = &workprefs.gfx_luminance;
- break;
- case 1:
- p = &workprefs.gfx_contrast;
- break;
- case 2:
- p = &workprefs.gfx_gamma;
- break;
- case 3:
- p = &workprefs.gfx_gamma_ch[0];
- break;
- case 4:
- p = &workprefs.gfx_gamma_ch[1];
- break;
- case 5:
- p = &workprefs.gfx_gamma_ch[2];
- break;
- case 6:
- p = &workprefs.gfx_threebitcolors;
- vmin = 0;
- vmax = 3;
- da_mode_multiplier = 1;
- break;
- }
- if (*p < vmin * da_mode_multiplier)
- *p = vmin * da_mode_multiplier;
- if (*p > vmax * da_mode_multiplier)
- *p = vmax * da_mode_multiplier;
- SendDlgItemMessage(hDlg, IDC_DA_SLIDER, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage(hDlg, IDC_DA_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(vmin, vmax));
- return p;
- }
- static void set_da (HWND hDlg)
- {
- int *p = getp_da (hDlg);
- if (!p)
- return;
- TCHAR buf[10];
- SendDlgItemMessage (hDlg, IDC_DA_SLIDER, TBM_SETPOS, TRUE, (*p) / da_mode_multiplier);
- _stprintf(buf, _T("%.1f"), (double)((*p) / (double)da_mode_multiplier));
- SetDlgItemText (hDlg, IDC_DA_TEXT, buf);
- }
- static void update_da (HWND hDlg)
- {
- currprefs.gfx_gamma = workprefs.gfx_gamma;
- currprefs.gfx_gamma_ch[0] = workprefs.gfx_gamma_ch[0];
- currprefs.gfx_gamma_ch[1] = workprefs.gfx_gamma_ch[1];
- currprefs.gfx_gamma_ch[2] = workprefs.gfx_gamma_ch[2];
- currprefs.gfx_luminance = workprefs.gfx_luminance;
- currprefs.gfx_contrast = workprefs.gfx_contrast;
- currprefs.gfx_threebitcolors = workprefs.gfx_threebitcolors;
- set_da (hDlg);
- init_colors(0);
- init_custom();
- updatedisplayarea(-1);
- }
- static void handle_da (HWND hDlg)
- {
- int *p;
- int v;
- p = getp_da (hDlg);
- if (!p)
- return;
- v = SendDlgItemMessage (hDlg, IDC_DA_SLIDER, TBM_GETPOS, 0, 0) * da_mode_multiplier;
- if (v == *p)
- return;
- *p = v;
- update_da (hDlg);
- }
- void init_da (HWND hDlg)
- {
- int *p;
- TCHAR tmp[MAX_DPATH], *p1, *p2;
- WIN32GUI_LoadUIString(IDS_DISPLAY_ATTRIBUTES, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_RESETCONTENT, 0, 0);
- _tcscat (tmp, _T("\n"));
- p1 = tmp;
- for (;;) {
- p2 = _tcschr (p1, '\n');
- if (p2 && _tcslen (p2) > 0) {
- *p2++ = 0;
- SendDlgItemMessage (hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- } else
- break;
- }
- if (da_mode_selected == CB_ERR)
- da_mode_selected = 0;
- SendDlgItemMessage (hDlg, IDC_DA_MODE, CB_SETCURSEL, da_mode_selected, 0);
- p = getp_da (hDlg);
- if (p)
- set_da (hDlg);
- }
- static int gui_display_depths[3];
- static void init_display_mode (HWND hDlg)
- {
- int d, d2, index;
- int i, cnt;
- struct MultiDisplay *md = getdisplay(&workprefs, 0);
- struct monconfig *gm = &workprefs.gfx_monitor[0];
- switch (workprefs.color_mode)
- {
- case 2:
- d = 16;
- break;
- case 5:
- default:
- d = 32;
- break;
- }
- if (workprefs.gfx_apmode[0].gfx_fullscreen) {
- d2 = d;
- if ((index = WIN32GFX_AdjustScreenmode (md, &gm->gfx_size_fs.width, &gm->gfx_size_fs.height, &d2)) >= 0) {
- switch (d2)
- {
- case 15:
- case 16:
- workprefs.color_mode = 2;
- d = 2;
- break;
- case 32:
- default:
- workprefs.color_mode = 5;
- d = 4;
- break;
- }
- }
- } else {
- d = d / 8;
- }
- if (gm->gfx_size_fs.special == WH_NATIVE) {
- int cnt = (int)SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_GETCOUNT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_SETCURSEL, cnt - 1, 0);
- index = display_mode_index (gm->gfx_size_fs.width, gm->gfx_size_fs.height, d);
- } else {
- index = display_mode_index (gm->gfx_size_fs.width, gm->gfx_size_fs.height, d);
- if (index >= 0)
- SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_SETCURSEL, md->DisplayModes[index].residx, 0);
- gm->gfx_size_fs.special = 0;
- }
- SendDlgItemMessage(hDlg, IDC_RESOLUTIONDEPTH, CB_RESETCONTENT, 0, 0);
- cnt = 0;
- gui_display_depths[0] = gui_display_depths[1] = gui_display_depths[2] = -1;
- if (index >= 0) {
- for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
- if (md->DisplayModes[i].depth > 1 && md->DisplayModes[i].residx == md->DisplayModes[index].residx) {
- TCHAR tmp[64];
- _stprintf (tmp, _T("%d"), md->DisplayModes[i].depth * 8);
- SendDlgItemMessage(hDlg, IDC_RESOLUTIONDEPTH, CB_ADDSTRING, 0, (LPARAM)tmp);
- if (md->DisplayModes[i].depth == d)
- SendDlgItemMessage (hDlg, IDC_RESOLUTIONDEPTH, CB_SETCURSEL, cnt, 0);
- gui_display_depths[cnt] = md->DisplayModes[i].depth;
- cnt++;
- }
- }
- }
- init_frequency_combo (hDlg, index);
- }
- #if 0
- static int display_toselect (int fs, int vsync, int p96)
- {
- if (p96)
- return fs * 2 + (vsync ? 1 : 0);
- if (fs == 2)
- return 4;
- if (!vsync)
- return fs;
- if (fs == 1 && vsync == 1)
- return 2;
- if (fs == 1 && vsync == 2)
- return 3;
- return fs;
- }
- static void display_fromselect (int val, int *fs, int *vsync, int p96)
- {
- int ofs = *fs;
- if (val == CB_ERR)
- return;
- *fs = 0;
- *vsync = 0;
- if (p96) {
- *fs = val / 2;
- *vsync = val & 1;
- if (*fs == 2 && *fs != ofs) {
- workprefs.win32_rtgscaleifsmall = 1;
- workprefs.win32_rtgmatchdepth = 0;
- }
- return;
- }
- switch (val)
- {
- case 0:
- *fs = 0;
- break;
- case 1:
- *fs = 1;
- break;
- case 2:
- *fs = 1;
- *vsync = 1;
- break;
- case 3:
- *fs = 1;
- *vsync = 2;
- break;
- case 4:
- *fs = 2;
- if (workprefs.gfx_filter == 0 && *fs != ofs && !workprefs.gfx_api) {
- workprefs.gfx_filter = 1;
- workprefs.gfx_filter_horiz_zoom = 0;
- workprefs.gfx_filter_vert_zoom = 0;
- workprefs.gfx_filter_horiz_zoom_mult = 0;
- workprefs.gfx_filter_vert_zoom_mult = 0;
- workprefs.gfx_filter_aspect = -1;
- workprefs.gfx_filter_horiz_offset = 0;
- workprefs.gfx_filter_vert_offset = 0;
- workprefs.gfx_filter_keep_aspect = 0;
- }
- break;
- }
- }
- #endif
- #define MAX_GUI_DISPLAY_SECTIONS 30
- static void values_to_displaydlg (HWND hDlg)
- {
- TCHAR buffer[MAX_DPATH];
- int rates[MAX_CHIPSET_REFRESH_TOTAL];
- int v;
- double d;
- init_display_mode (hDlg);
- SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_monitor[0].gfx_size_win.width, FALSE);
- SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_monitor[0].gfx_size_win.height, FALSE);
- SendDlgItemMessage(hDlg, IDC_RATE2BOX, CB_RESETCONTENT, 0, 0);
- v = 0;
- struct chipset_refresh *selectcr = full_property_sheet ? (workprefs.ntscmode ? &workprefs.cr[CHIPSET_REFRESH_NTSC] : &workprefs.cr[CHIPSET_REFRESH_PAL]) : get_chipset_refresh (&workprefs) ;
- for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
- struct chipset_refresh *cr = &workprefs.cr[i];
- if (cr->rate > 0) {
- _tcscpy (buffer, cr->label);
- if (!buffer[0])
- _stprintf (buffer, _T(":%d"), i);
- SendDlgItemMessage(hDlg, IDC_RATE2BOX, CB_ADDSTRING, 0, (LPARAM)buffer);
- d = workprefs.chipset_refreshrate;
- if (abs (d) < 1)
- d = currprefs.ntscmode ? 60.0 : 50.0;
- if (selectcr && selectcr->index == cr->index)
- workprefs.cr_selected = i;
- rates[i] = v;
- v++;
- }
- }
- if (workprefs.cr_selected < 0 || workprefs.cr[workprefs.cr_selected].rate <= 0)
- workprefs.cr_selected = CHIPSET_REFRESH_PAL;
- selectcr = &workprefs.cr[workprefs.cr_selected];
- SendDlgItemMessage(hDlg, IDC_RATE2BOX, CB_SETCURSEL, rates[workprefs.cr_selected], 0);
- SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_SETPOS, TRUE, (LPARAM)(selectcr->rate + 0.5));
- _stprintf (buffer, _T("%.6f"), selectcr->locked || full_property_sheet ? selectcr->rate : workprefs.chipset_refreshrate);
- SetDlgItemText (hDlg, IDC_RATE2TEXT, buffer);
- CheckDlgButton (hDlg, IDC_RATE2ENABLE, selectcr->locked);
- ew (hDlg, IDC_RATE2TEXT, selectcr->locked != 0);
- ew (hDlg, IDC_FRAMERATE2, selectcr->locked != 0);
- v = workprefs.cpu_memory_cycle_exact ? 1 : workprefs.gfx_framerate;
- SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPOS, TRUE, (int)v);
- CheckRadioButton (hDlg, IDC_LM_NORMAL, IDC_LM_PDOUBLED3, IDC_LM_NORMAL + (workprefs.gfx_vresolution ? 1 : 0) + workprefs.gfx_pscanlines);
- CheckRadioButton (hDlg, IDC_LM_INORMAL, IDC_LM_IDOUBLED3, IDC_LM_INORMAL + (workprefs.gfx_iscanlines ? workprefs.gfx_iscanlines + 1 : (workprefs.gfx_vresolution ? 1 : 0)));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE3, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC_NONE, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC2, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC2_AUTOSWITCH, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC_AUTOSWITCH, buffer, sizeof buffer / sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_ADDSTRING, 0, (LPARAM)buffer);
- for (int i = 1; i < MAX_GUI_DISPLAY_SECTIONS; i++) {
- _stprintf(buffer, _T("%d"), i);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE3, CB_ADDSTRING, 0, (LPARAM)buffer);
- }
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_SETCURSEL, workprefs.gfx_apmode[0].gfx_fullscreen, 0);
- v = workprefs.gfx_apmode[0].gfx_vsync;
- if (v < 0)
- v = 5;
- else if (v > 0) {
- v = v + (workprefs.gfx_apmode[0].gfx_vsyncmode || !v ? 0 : 2);
- }
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE2, CB_SETCURSEL, v, 0);
- if (workprefs.gfx_display_sections - 1 < MAX_GUI_DISPLAY_SECTIONS)
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE3, CB_SETCURSEL, workprefs.gfx_display_sections - 1, 0);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- #if 0
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC_AUTOSWITCH, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_ADDSTRING, 0, (LPARAM)buffer);
- #endif
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC2, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_ADDSTRING, 0, (LPARAM)buffer);
- #if 0
- WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC2_AUTOSWITCH, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_ADDSTRING, 0, (LPARAM)buffer);
- #endif
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_SETCURSEL,
- workprefs.gfx_apmode[1].gfx_fullscreen, 0);
- v = workprefs.gfx_apmode[1].gfx_vsync;
- if (v < 0)
- v = 2;
- else if (v > 0)
- v = 1;
- SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG2, CB_SETCURSEL, v, 0);
- SendDlgItemMessage(hDlg, IDC_LORES, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString(IDS_RES_LORES, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_RES_HIRES, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_RES_SUPERHIRES, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)buffer);
- SendDlgItemMessage (hDlg, IDC_LORES, CB_SETCURSEL, workprefs.gfx_resolution, 0);
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("TV (narrow)"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("TV (standard"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("TV (wide)"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("Overscan"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("Overscan+"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_ADDSTRING, 0, (LPARAM)_T("Extreme"));
- SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_SETCURSEL, workprefs.gfx_overscanmode, 0);
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString(IDS_DISABLED, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_ALWAYS_ON, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_ADDSTRING, 0, (LPARAM)buffer);
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_ADDSTRING, 0, (LPARAM)_T("10%"));
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_ADDSTRING, 0, (LPARAM)_T("33%"));
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_ADDSTRING, 0, (LPARAM)_T("66%"));
- if (workprefs.gfx_autoresolution == 0)
- SendDlgItemMessage (hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 0, 0);
- else if (workprefs.gfx_autoresolution == 1)
- SendDlgItemMessage (hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 1, 0);
- else if (workprefs.gfx_autoresolution <= 10)
- SendDlgItemMessage (hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 2, 0);
- else if (workprefs.gfx_autoresolution <= 33)
- SendDlgItemMessage (hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 3, 0);
- else if (workprefs.gfx_autoresolution <= 99)
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 4, 0);
- else
- SendDlgItemMessage(hDlg, IDC_AUTORESOLUTIONSELECT, CB_SETCURSEL, 5, 0);
- CheckDlgButton(hDlg, IDC_AUTORESOLUTIONVGA, workprefs.gfx_autoresolution_vga);
- CheckDlgButton(hDlg, IDC_BLACKER_THAN_BLACK, workprefs.gfx_blackerthanblack);
- CheckDlgButton(hDlg, IDC_LORES_SMOOTHED, workprefs.gfx_lores_mode);
- CheckDlgButton(hDlg, IDC_FLICKERFIXER, workprefs.gfx_scandoubler);
- CheckDlgButton(hDlg, IDC_GRAYSCALE, workprefs.gfx_grayscale);
- CheckDlgButton (hDlg, IDC_XCENTER, workprefs.gfx_xcenter);
- CheckDlgButton (hDlg, IDC_YCENTER, workprefs.gfx_ycenter);
- SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_RESETCONTENT, 0, 0);
- #if 0
- WIN32GUI_LoadUIString(IDS_BUFFER_SINGLE, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer);
- #endif
- WIN32GUI_LoadUIString(IDS_BUFFER_DOUBLE, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer);
- WIN32GUI_LoadUIString(IDS_BUFFER_TRIPLE, buffer, sizeof buffer / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer);
- SendDlgItemMessage (hDlg, IDC_DISPLAY_BUFFERCNT, CB_SETCURSEL, workprefs.gfx_apmode[0].gfx_backbuffers - 1, 0);
- CheckDlgButton(hDlg, IDC_DISPLAY_VARSYNC, workprefs.gfx_variable_sync != 0);
- CheckDlgButton(hDlg, IDC_DISPLAY_RESIZE, workprefs.gfx_windowed_resize != 0);
- init_da (hDlg);
- }
- static void init_resolution_combo (HWND hDlg)
- {
- int i, idx;
- TCHAR tmp[MAX_DPATH];
- struct MultiDisplay *md = getdisplay(&workprefs, 0);
- idx = -1;
- SendDlgItemMessage(hDlg, IDC_RESOLUTION, CB_RESETCONTENT, 0, 0);
- for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
- if (md->DisplayModes[i].depth > 1 && md->DisplayModes[i].residx != idx) {
- _stprintf (tmp, _T("%dx%d%s"), md->DisplayModes[i].res.width, md->DisplayModes[i].res.height, md->DisplayModes[i].lace ? _T("i") : _T(""));
- if (md->DisplayModes[i].rawmode)
- _tcscat (tmp, _T(" (*)"));
- SendDlgItemMessage(hDlg, IDC_RESOLUTION, CB_ADDSTRING, 0, (LPARAM)tmp);
- idx = md->DisplayModes[i].residx;
- }
- }
- WIN32GUI_LoadUIString (IDS_DISPLAYMODE_NATIVE, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_RESOLUTION, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- static void init_displays_combo (HWND hDlg, bool rtg)
- {
- const TCHAR *adapter = _T("");
- struct MultiDisplay *md = Displays;
- int cnt = 0, cnt2 = 0;
- int displaynum;
- int idx = 0;
- int id = rtg ? IDC_RTG_DISPLAYSELECT : IDC_DISPLAYSELECT;
- displaynum = workprefs.gfx_apmode[rtg ? APMODE_RTG : APMODE_NATIVE].gfx_display - 1;
- SendDlgItemMessage (hDlg, id, CB_RESETCONTENT, 0, 0);
- if (displaynum < 0)
- displaynum = 0;
- while (md->monitorname) {
- if (_tcscmp (md->adapterkey, adapter) != 0) {
- SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)md->adaptername);
- adapter = md->adapterkey;
- cnt++;
- }
- TCHAR buf[MAX_DPATH];
- _stprintf (buf, _T(" %s"), md->fullname);
- SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)buf);
- if (displaynum == cnt2)
- idx = cnt;
- md++;
- cnt2++;
- cnt++;
- }
- SendDlgItemMessage (hDlg, id, CB_SETCURSEL, idx, 0);
- }
- static bool get_displays_combo (HWND hDlg, bool rtg)
- {
- struct MultiDisplay *md = Displays;
- LRESULT posn;
- const TCHAR *adapter = _T("");
- int cnt = 0, cnt2 = 0;
- int displaynum;
- int id = rtg ? IDC_RTG_DISPLAYSELECT : IDC_DISPLAYSELECT;
- posn = SendDlgItemMessage (hDlg, id, CB_GETCURSEL, 0, 0);
- if (posn == CB_ERR)
- return false;
- displaynum = workprefs.gfx_apmode[rtg ? APMODE_RTG : APMODE_NATIVE].gfx_display - 1;
- if (displaynum < 0)
- displaynum = 0;
- while (md->monitorname) {
- int foundnum = -1;
- if (_tcscmp (md->adapterkey, adapter) != 0) {
- adapter = md->adapterkey;
- if (posn == cnt)
- foundnum = cnt2;
- cnt++;
- }
- if (posn == cnt)
- foundnum = cnt2;
- if (foundnum >= 0) {
- if (foundnum == displaynum)
- return false;
- workprefs.gfx_apmode[rtg ? APMODE_RTG : APMODE_NATIVE].gfx_display = foundnum + 1;
- init_displays_combo (hDlg, rtg);
- return true;
- }
- cnt++;
- cnt2++;
- md++;
- }
- return false;
- }
- static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- BOOL success = FALSE;
- int i;
- struct monconfig *gm = &workprefs.gfx_monitor[0];
- int gfx_width = gm->gfx_size_win.width;
- int gfx_height = gm->gfx_size_win.height;
- LRESULT posn;
- TCHAR tmp[200];
- workprefs.gfx_apmode[0].gfx_fullscreen = SendDlgItemMessage (hDlg, IDC_SCREENMODE_NATIVE, CB_GETCURSEL, 0, 0);
- workprefs.gfx_lores_mode = ischecked (hDlg, IDC_LORES_SMOOTHED);
- workprefs.gfx_scandoubler = ischecked (hDlg, IDC_FLICKERFIXER);
- workprefs.gfx_blackerthanblack = ischecked (hDlg, IDC_BLACKER_THAN_BLACK);
- workprefs.gfx_autoresolution_vga = ischecked(hDlg, IDC_AUTORESOLUTIONVGA);
- workprefs.gfx_grayscale = ischecked(hDlg, IDC_GRAYSCALE);
- int vres = workprefs.gfx_vresolution;
- int viscan = workprefs.gfx_iscanlines;
- int vpscan = workprefs.gfx_pscanlines;
-
- workprefs.gfx_vresolution = (ischecked (hDlg, IDC_LM_DOUBLED) || ischecked (hDlg, IDC_LM_SCANLINES) || ischecked (hDlg, IDC_LM_PDOUBLED2) || ischecked (hDlg, IDC_LM_PDOUBLED3)) ? VRES_DOUBLE : VRES_NONDOUBLE;
- workprefs.gfx_iscanlines = 0;
- workprefs.gfx_pscanlines = 0;
- if (workprefs.gfx_vresolution >= VRES_DOUBLE) {
- if (ischecked (hDlg, IDC_LM_IDOUBLED2))
- workprefs.gfx_iscanlines = 1;
- if (ischecked (hDlg, IDC_LM_IDOUBLED3))
- workprefs.gfx_iscanlines = 2;
- if (ischecked (hDlg, IDC_LM_SCANLINES))
- workprefs.gfx_pscanlines = 1;
- if (ischecked (hDlg, IDC_LM_PDOUBLED2))
- workprefs.gfx_pscanlines = 2;
- if (ischecked (hDlg, IDC_LM_PDOUBLED3))
- workprefs.gfx_pscanlines = 3;
- }
- if (vres != workprefs.gfx_vresolution || viscan != workprefs.gfx_iscanlines || vpscan != workprefs.gfx_pscanlines) {
- CheckRadioButton (hDlg, IDC_LM_NORMAL, IDC_LM_PDOUBLED3, IDC_LM_NORMAL + (workprefs.gfx_vresolution ? 1 : 0) + workprefs.gfx_pscanlines);
- CheckRadioButton (hDlg, IDC_LM_INORMAL, IDC_LM_IDOUBLED3, IDC_LM_INORMAL + (workprefs.gfx_iscanlines ? workprefs.gfx_iscanlines + 1: (workprefs.gfx_vresolution ? 1 : 0)));
- }
- workprefs.gfx_apmode[0].gfx_backbuffers = SendDlgItemMessage (hDlg, IDC_DISPLAY_BUFFERCNT, CB_GETCURSEL, 0, 0) + 1;
- workprefs.gfx_framerate = SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_GETPOS, 0, 0);
- i = SendDlgItemMessage (hDlg, IDC_SCREENMODE_NATIVE2, CB_GETCURSEL, 0, 0);
- int oldvsmode = workprefs.gfx_apmode[0].gfx_vsyncmode;
- int oldvs = workprefs.gfx_apmode[0].gfx_vsync;
- workprefs.gfx_apmode[0].gfx_vsync = 0;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 0;
- if (i == 1) {
- workprefs.gfx_apmode[0].gfx_vsync = 1;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 1;
- } else if (i == 2) {
- workprefs.gfx_apmode[0].gfx_vsync = 2;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 1;
- } else if (i == 3) {
- workprefs.gfx_apmode[0].gfx_vsync = 1;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 0;
- } else if (i == 4) {
- workprefs.gfx_apmode[0].gfx_vsync = 2;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 0;
- } else if (i == 5) {
- workprefs.gfx_apmode[0].gfx_vsync = -1;
- workprefs.gfx_apmode[0].gfx_vsyncmode = 0;
- }
- i = SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE3, CB_GETCURSEL, 0, 0);
- if (i >= 0 && i < 100)
- workprefs.gfx_display_sections = i + 1;
- workprefs.gfx_apmode[1].gfx_fullscreen = SendDlgItemMessage (hDlg, IDC_SCREENMODE_RTG, CB_GETCURSEL, 0, 0);
- i = SendDlgItemMessage (hDlg, IDC_SCREENMODE_RTG2, CB_GETCURSEL, 0, 0);
- workprefs.gfx_apmode[1].gfx_vsync = 0;
- workprefs.gfx_apmode[1].gfx_vsyncmode = 0;
- if (i == 1) {
- workprefs.gfx_apmode[1].gfx_vsync = 1;
- workprefs.gfx_apmode[1].gfx_vsyncmode = 1;
- } else if (i == 2) {
- workprefs.gfx_apmode[1].gfx_vsync = -1;
- workprefs.gfx_apmode[1].gfx_vsyncmode = 0;
- }
-
- bool updaterate = false, updateslider = false;
- TCHAR label[16];
- label[0] = 0;
- SendDlgItemMessage (hDlg, IDC_RATE2BOX, WM_GETTEXT, sizeof label / sizeof (TCHAR), (LPARAM)label);
- struct chipset_refresh *cr;
- for (i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
- cr = &workprefs.cr[i];
- if (!_tcscmp (label, cr->label) || (cr->label[0] == 0 && label[0] == ':' &&_tstol (label + 1) == i)) {
- if (workprefs.cr_selected != i) {
- workprefs.cr_selected = i;
- updaterate = true;
- updateslider = true;
- CheckDlgButton (hDlg, IDC_RATE2ENABLE, cr->locked);
- ew (hDlg, IDC_FRAMERATE2, cr->locked != 0);
- ew (hDlg, IDC_RATE2TEXT, cr->locked != 0);
- } else {
- cr->locked = ischecked (hDlg, IDC_RATE2ENABLE) != 0;
- if (cr->locked) {
- cr->inuse = true;
- } else {
- // deactivate if plain uncustomized PAL or NTSC
- if (!cr->commands[0] && !cr->filterprofile[0] && cr->resolution == 7 &&
- cr->horiz < 0 && cr->vert < 0 && cr->lace < 0 && cr->vsync < 0 && cr->framelength < 0 &&
- (cr == &workprefs.cr[CHIPSET_REFRESH_PAL] || cr == &workprefs.cr[CHIPSET_REFRESH_NTSC])) {
- cr->inuse = false;
- }
- }
- }
- break;
- }
- }
- if (cr->locked) {
- if (msg == WM_HSCROLL) {
- i = SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_GETPOS, 0, 0);
- if (i != (int)cr->rate)
- cr->rate = (double)i;
- updaterate = true;
- } else if (LOWORD (wParam) == IDC_RATE2TEXT && HIWORD (wParam) == EN_KILLFOCUS) {
- if (GetDlgItemText(hDlg, IDC_RATE2TEXT, tmp, sizeof tmp / sizeof (TCHAR))) {
- cr->rate = _tstof (tmp);
- updaterate = true;
- updateslider = true;
- }
- }
- } else if (i == CHIPSET_REFRESH_PAL) {
- cr->rate = 50.0;
- } else if (i == CHIPSET_REFRESH_NTSC) {
- cr->rate = 60.0;
- }
- if (cr->rate > 0 && cr->rate < 1) {
- cr->rate = currprefs.ntscmode ? 60.0 : 50.0;
- updaterate = true;
- }
- if (cr->rate > 300) {
- cr->rate = currprefs.ntscmode ? 60.0 : 50.0;
- updaterate = true;
- }
- if (updaterate) {
- TCHAR buffer[20];
- _stprintf (buffer, _T("%.6f"), cr->rate);
- SetDlgItemText (hDlg, IDC_RATE2TEXT, buffer);
- }
- if (updateslider) {
- SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_SETPOS, TRUE, (LPARAM)cr->rate);
- }
- workprefs.gfx_xcenter = ischecked (hDlg, IDC_XCENTER) ? 2 : 0; /* Smart centering */
- workprefs.gfx_ycenter = ischecked (hDlg, IDC_YCENTER) ? 2 : 0; /* Smart centering */
- workprefs.gfx_variable_sync = ischecked(hDlg, IDC_DISPLAY_VARSYNC) ? 1 : 0;
- workprefs.gfx_windowed_resize = ischecked(hDlg, IDC_DISPLAY_RESIZE);
- LRESULT posn1 = SendDlgItemMessage (hDlg, IDC_AUTORESOLUTIONSELECT, CB_GETCURSEL, 0, 0);
- if (posn1 != CB_ERR) {
- if (posn1 == 0)
- workprefs.gfx_autoresolution = 0;
- else if (posn1 == 1)
- workprefs.gfx_autoresolution = 1;
- else if (posn1 == 2)
- workprefs.gfx_autoresolution = 10;
- else if (posn1 == 3)
- workprefs.gfx_autoresolution = 33;
- else if (posn1 == 4)
- workprefs.gfx_autoresolution = 66;
- else
- workprefs.gfx_autoresolution = 100;
- }
- int dmode = -1;
- bool native = false;
- struct MultiDisplay *md = getdisplay(&workprefs, 0);
- posn1 = SendDlgItemMessage (hDlg, IDC_RESOLUTION, CB_GETCURSEL, 0, 0);
- LRESULT posn2 = SendDlgItemMessage (hDlg, IDC_RESOLUTIONDEPTH, CB_GETCURSEL, 0, 0);
- if (posn1 != CB_ERR) {
- if (posn2 == CB_ERR)
- posn2 = 0;
- workprefs.gfx_monitor[0].gfx_size_fs.special = 0;
- for (dmode = 0; md->DisplayModes[dmode].depth >= 0; dmode++) {
- if (md->DisplayModes[dmode].residx == posn1)
- break;
- }
- if (md->DisplayModes[dmode].depth <= 0) {
- for (dmode = 0; md->DisplayModes[dmode].depth >= 0; dmode++) {
- if (md->DisplayModes[dmode].res.width == md->rect.right - md->rect.left &&
- md->DisplayModes[dmode].res.height == md->rect.bottom - md->rect.top &&
- md->DisplayModes[dmode].depth == gui_display_depths[posn2])
- {
- workprefs.gfx_monitor[0].gfx_size_fs.special = WH_NATIVE;
- break;
- }
- }
- if (md->DisplayModes[dmode].depth <= 0)
- dmode = -1;
- } else {
- i = dmode;
- while (md->DisplayModes[dmode].residx == posn1) {
- if (md->DisplayModes[dmode].depth == gui_display_depths[posn2])
- break;
- dmode++;
- }
- if (md->DisplayModes[dmode].residx != posn1)
- dmode = i;
- }
- }
- if (oldvsmode != workprefs.gfx_apmode[0].gfx_vsyncmode || oldvs != workprefs.gfx_apmode[0].gfx_vsync)
- init_frequency_combo (hDlg, dmode);
- if (msg == WM_COMMAND && HIWORD (wParam) == CBN_SELCHANGE)
- {
- if (LOWORD (wParam) == IDC_DISPLAYSELECT) {
- get_displays_combo (hDlg, false);
- init_resolution_combo (hDlg);
- init_display_mode (hDlg);
- return;
- } else if (LOWORD(wParam) == IDC_LORES) {
- posn = SendDlgItemMessage(hDlg, IDC_LORES, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR)
- workprefs.gfx_resolution = posn;
- } else if (LOWORD(wParam) == IDC_OVERSCANMODE) {
- posn = SendDlgItemMessage(hDlg, IDC_OVERSCANMODE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR)
- workprefs.gfx_overscanmode = posn;
- } else if ((LOWORD (wParam) == IDC_RESOLUTION || LOWORD(wParam) == IDC_RESOLUTIONDEPTH) && dmode >= 0) {
- workprefs.gfx_monitor[0].gfx_size_fs.width = md->DisplayModes[dmode].res.width;
- workprefs.gfx_monitor[0].gfx_size_fs.height = md->DisplayModes[dmode].res.height;
- switch(md->DisplayModes[dmode].depth)
- {
- case 2:
- workprefs.color_mode = 2;
- break;
- case 3:
- case 4:
- workprefs.color_mode = 5;
- break;
- default:
- workprefs.color_mode = 0;
- break;
- }
- /* Set the Int boxes */
- SetDlgItemInt (hDlg, IDC_XSIZE, workprefs.gfx_monitor[0].gfx_size_win.width, FALSE);
- SetDlgItemInt (hDlg, IDC_YSIZE, workprefs.gfx_monitor[0].gfx_size_win.height, FALSE);
- init_display_mode (hDlg);
- } else if (LOWORD (wParam) == IDC_REFRESHRATE && dmode >= 0) {
- LRESULT posn1;
- posn1 = SendDlgItemMessage (hDlg, IDC_REFRESHRATE, CB_GETCURSEL, 0, 0);
- if (posn1 == CB_ERR)
- return;
- if (posn1 == 0) {
- workprefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate = 0;
- workprefs.gfx_apmode[APMODE_NATIVE].gfx_interlaced = dmode >= 0 && md->DisplayModes[dmode].lace;
- } else {
- posn1--;
- workprefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate = storedrefreshrates[posn1].rate;
- workprefs.gfx_apmode[APMODE_NATIVE].gfx_interlaced = (storedrefreshrates[posn1].type & REFRESH_RATE_LACE) != 0;
- }
- values_to_displaydlg (hDlg);
- } else if (LOWORD (wParam) == IDC_DA_MODE) {
- da_mode_selected = SendDlgItemMessage (hDlg, IDC_DA_MODE, CB_GETCURSEL, 0, 0);
- init_da (hDlg);
- handle_da (hDlg);
- }
- }
- updatewinfsmode(0, &workprefs);
- }
- static int hw3d_changed;
- static INT_PTR CALLBACK DisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- pages[DISPLAY_ID] = hDlg;
- currentpage = DISPLAY_ID;
- SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETRANGE, TRUE, MAKELONG (MIN_REFRESH_RATE, MAX_REFRESH_RATE));
- SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_SETRANGE, TRUE, MAKELONG (1, 99));
- recursive++;
- init_displays_combo (hDlg, false);
- init_resolution_combo (hDlg);
- init_da (hDlg);
- recursive--;
- case WM_USER:
- recursive++;
- values_to_displaydlg (hDlg);
- enable_for_displaydlg (hDlg);
- recursive--;
- break;
- case WM_HSCROLL:
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- switch(LOWORD(wParam))
- {
- case IDC_DA_RESET:
- {
- int *p;
- da_mode_selected = SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_GETCURSEL, 0, 0);
- p = getp_da(hDlg);
- if (p)
- *p = 0;
- init_da(hDlg);
- update_da(hDlg);
- }
- break;
- case IDC_XSIZE:
- {
- BOOL success;
- struct monconfig *gm = &workprefs.gfx_monitor[0];
- gm->gfx_size_win.width = GetDlgItemInt(hDlg, IDC_XSIZE, &success, FALSE);
- if (!success)
- gm->gfx_size_win.width = 800;
- }
- break;
- case IDC_YSIZE:
- {
- BOOL success;
- struct monconfig *gm = &workprefs.gfx_monitor[0];
- gm->gfx_size_win.height = GetDlgItemInt(hDlg, IDC_YSIZE, &success, FALSE);
- if (!success)
- gm->gfx_size_win.height = 600;
- }
- break;
- default:
- handle_da (hDlg);
- values_from_displaydlg (hDlg, msg, wParam, lParam);
- enable_for_displaydlg (hDlg);
- if (LOWORD (wParam) == IDC_RATE2ENABLE || LOWORD(wParam) == IDC_SCREENMODE_NATIVE3 || LOWORD(wParam) == IDC_SCREENMODE_NATIVE2 || LOWORD(wParam) == IDC_SCREENMODE_NATIVE) {
- values_to_displaydlg (hDlg);
- }
- }
- recursive--;
- break;
- }
- if (hw3d_changed && recursive == 0) {
- recursive++;
- enable_for_displaydlg (hDlg);
- values_to_displaydlg (hDlg);
- hw3d_changed = 0;
- recursive--;
- }
- return FALSE;
- }
- static void values_to_chipsetdlg (HWND hDlg)
- {
- TCHAR Nth[MAX_NTH_LENGTH];
- TCHAR *blah[1] = { Nth };
- TCHAR *string = NULL;
- switch(workprefs.chipset_mask)
- {
- case 0:
- CheckRadioButton(hDlg, IDC_OCS, IDC_AGA, IDC_OCS + 0);
- break;
- case CSMASK_ECS_AGNUS:
- CheckRadioButton(hDlg, IDC_OCS, IDC_AGA, IDC_OCS + 1);
- break;
- case CSMASK_ECS_DENISE:
- CheckRadioButton(hDlg, IDC_OCS, IDC_AGA, IDC_OCS + 2);
- break;
- case CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE:
- CheckRadioButton(hDlg, IDC_OCS, IDC_AGA, IDC_OCS + 3);
- break;
- case CSMASK_AGA:
- case CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA:
- CheckRadioButton(hDlg, IDC_OCS, IDC_AGA, IDC_OCS + 4);
- break;
- }
- CheckDlgButton(hDlg, IDC_NTSC, workprefs.ntscmode);
- CheckDlgButton(hDlg, IDC_GENLOCK, workprefs.genlock);
- CheckDlgButton(hDlg, IDC_BLITIMM, workprefs.immediate_blits);
- CheckDlgButton(hDlg, IDC_BLITWAIT, workprefs.waiting_blits);
- CheckDlgButton(hDlg, IDC_KEYBOARD_CONNECTED, workprefs.keyboard_connected);
- CheckDlgButton(hDlg, IDC_SUBPIXEL, workprefs.chipset_hr);
- CheckRadioButton(hDlg, IDC_COLLISION0, IDC_COLLISION3, IDC_COLLISION0 + workprefs.collision_level);
- CheckDlgButton(hDlg, IDC_CYCLEEXACT, workprefs.cpu_cycle_exact);
- CheckDlgButton(hDlg, IDC_CYCLEEXACTMEMORY, workprefs.cpu_memory_cycle_exact);
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_SETCURSEL, workprefs.cs_compatible, 0);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_SETCURSEL, workprefs.monitoremu, 0);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_SETCURSEL, workprefs.monitoremu_mon, 0);
- SendDlgItemMessage(hDlg, IDC_GENLOCKMODE, CB_SETCURSEL, workprefs.genlock_image, 0);
- SendDlgItemMessage(hDlg, IDC_GENLOCKMIX, CB_SETCURSEL, workprefs.genlock_mix / 25, 0);
- CheckDlgButton(hDlg, IDC_GENLOCK_ALPHA, workprefs.genlock_alpha);
- CheckDlgButton(hDlg, IDC_GENLOCK_KEEP_ASPECT, workprefs.genlock_aspect);
- }
- static int cs_compatible = CP_GENERIC;
- static void values_from_chipsetdlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- BOOL success = FALSE;
- int nn;
- bool n1, n2;
- int id = LOWORD(wParam);
- workprefs.genlock = ischecked (hDlg, IDC_GENLOCK);
- workprefs.genlock_alpha = ischecked(hDlg, IDC_GENLOCK_ALPHA);
- workprefs.genlock_aspect = ischecked(hDlg, IDC_GENLOCK_KEEP_ASPECT);
- workprefs.immediate_blits = ischecked (hDlg, IDC_BLITIMM);
- workprefs.waiting_blits = ischecked (hDlg, IDC_BLITWAIT) ? 1 : 0;
- workprefs.chipset_hr = ischecked(hDlg, IDC_SUBPIXEL);
- workprefs.keyboard_connected = ischecked(hDlg, IDC_KEYBOARD_CONNECTED) ? 1 : 0;
- n2 = ischecked (hDlg, IDC_CYCLEEXACTMEMORY);
- n1 = ischecked (hDlg, IDC_CYCLEEXACT);
- if (workprefs.cpu_cycle_exact != n1 || workprefs.cpu_memory_cycle_exact != n2) {
- if (id == IDC_CYCLEEXACTMEMORY) {
- if (n2) {
- // n2: f -> t
- if (workprefs.cpu_model < 68020) {
- n1 = true;
- CheckDlgButton (hDlg, IDC_CYCLEEXACT, n1);
- }
- } else {
- // n2: t -> f
- n1 = false;
- CheckDlgButton (hDlg, IDC_CYCLEEXACT, n1);
- }
- } else if (id == IDC_CYCLEEXACT) {
- if (n1) {
- // n1: f -> t
- n2 = true;
- CheckDlgButton (hDlg, IDC_CYCLEEXACTMEMORY, n2);
- } else {
- // n1: t -> f
- if (workprefs.cpu_model < 68020) {
- n2 = false;
- CheckDlgButton (hDlg, IDC_CYCLEEXACTMEMORY, n2);
- }
- }
- }
- workprefs.cpu_cycle_exact = n1;
- workprefs.cpu_memory_cycle_exact = workprefs.blitter_cycle_exact = n2;
- if (n2) {
- if (workprefs.cpu_model == 68000)
- workprefs.cpu_compatible = 1;
- if (workprefs.cpu_model <= 68030)
- workprefs.m68k_speed = 0;
- if (workprefs.immediate_blits) {
- workprefs.immediate_blits = false;
- CheckDlgButton (hDlg, IDC_BLITIMM, FALSE);
- }
- workprefs.gfx_framerate = 1;
- workprefs.cachesize = 0;
- }
- }
- workprefs.collision_level = ischecked (hDlg, IDC_COLLISION0) ? 0
- : ischecked (hDlg, IDC_COLLISION1) ? 1
- : ischecked (hDlg, IDC_COLLISION2) ? 2 : 3;
- workprefs.chipset_mask = ischecked (hDlg, IDC_OCS) ? 0
- : ischecked (hDlg, IDC_ECS_AGNUS) ? CSMASK_ECS_AGNUS
- : ischecked (hDlg, IDC_ECS_DENISE) ? CSMASK_ECS_DENISE
- : ischecked (hDlg, IDC_ECS) ? CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE
- : CSMASK_AGA | CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
- n1 = ischecked (hDlg, IDC_NTSC);
- if (workprefs.ntscmode != n1) {
- workprefs.ntscmode = n1;
- }
- nn = SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_GETCURSEL, 0, 0);
- if (nn != CB_ERR) {
- workprefs.cs_compatible = nn;
- cs_compatible = nn;
- built_in_chipset_prefs (&workprefs);
- }
- nn = SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_GETCURSEL, 0, 0);
- if (nn != CB_ERR)
- workprefs.monitoremu = nn;
- nn = SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_GETCURSEL, 0, 0);
- if (nn != CB_ERR)
- workprefs.monitoremu_mon = nn;
- nn = SendDlgItemMessage(hDlg, IDC_GENLOCKMODE, CB_GETCURSEL, 0, 0);
- if (nn != CB_ERR && nn != workprefs.genlock_image) {
- workprefs.genlock_image = nn;
- if (workprefs.genlock_image == 3) {
- SendDlgItemMessage(hDlg, IDC_GENLOCKFILE, WM_SETTEXT, 0, (LPARAM)workprefs.genlock_image_file);
- } else if (workprefs.genlock_image == 4) {
- SendDlgItemMessage(hDlg, IDC_GENLOCKFILE, WM_SETTEXT, 0, (LPARAM)workprefs.genlock_video_file);
- }
- }
- nn = SendDlgItemMessage(hDlg, IDC_GENLOCKMIX, CB_GETCURSEL, 0, 0);
- if (nn != CB_ERR) {
- workprefs.genlock_mix = nn * 25;
- if (workprefs.genlock_mix >= 250)
- workprefs.genlock_mix = 255;
- }
- }
- static void setgenlock(HWND hDlg)
- {
- setautocomplete(hDlg, IDC_GENLOCKFILE);
- if (workprefs.genlock_image == 3) {
- addhistorymenu(hDlg, workprefs.genlock_image_file, IDC_GENLOCKFILE, HISTORY_GENLOCK_IMAGE, true, -1);
- } else if (workprefs.genlock_image == 4 || workprefs.genlock_image >= 6) {
- addhistorymenu(hDlg, workprefs.genlock_video_file, IDC_GENLOCKFILE, HISTORY_GENLOCK_VIDEO, true, -1);
- }
- }
- static INT_PTR CALLBACK ChipsetDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- TCHAR buffer[MAX_DPATH], tmp[MAX_DPATH];
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- {
- pages[CHIPSET_ID] = hDlg;
- currentpage = CHIPSET_ID;
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("Custom"));
- WIN32GUI_LoadUIString(IDS_GENERIC, buffer, sizeof buffer / sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)buffer);
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("CDTV"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("CDTV-CR"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("CD32"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A500"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A500+"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A600"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A1000"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A1200"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A2000"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A3000"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A3000T"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A4000"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("A4000T"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("Velvet"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("Casablanca"));
- SendDlgItemMessage(hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)_T("DraCo"));
- SendDlgItemMessage(hDlg, IDC_GENLOCKMODE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_GENLOCKMODE, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- WIN32GUI_LoadUIString(IDS_GENLOCK_OPTIONS, tmp, sizeof tmp / sizeof(TCHAR));
- TCHAR *p1 = tmp;
- for (;;) {
- TCHAR *p2 = _tcschr(p1, '\n');
- if (p2 && _tcslen(p2) > 0) {
- *p2++ = 0;
- SendDlgItemMessage(hDlg, IDC_GENLOCKMODE, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- } else
- break;
- }
- SendDlgItemMessage(hDlg, IDC_GENLOCKMIX, CB_RESETCONTENT, 0, 0);
- for (int i = 0; i <= 10; i++) {
- _stprintf(buffer, _T("%d%%"), (10 - i) * 10);
- SendDlgItemMessage(hDlg, IDC_GENLOCKMIX, CB_ADDSTRING, 0, (LPARAM)buffer);
- }
- SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- WIN32GUI_LoadUIString(IDS_AUTODETECT, buffer, sizeof buffer / sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_ADDSTRING, 0, (LPARAM)buffer);
- for (int i = 0; specialmonitorfriendlynames[i]; i++) {
- _stprintf(buffer, _T("%s (%s)"), specialmonitorfriendlynames[i], specialmonitormanufacturernames[i]);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU, CB_ADDSTRING, 0, (LPARAM)buffer);
- }
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_RESETCONTENT, 0, 0);
- for (int i = 0; i < MAX_AMIGAMONITORS; i++) {
- _stprintf(buffer, _T("%d"), i + 1);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_ADDSTRING, 0, (LPARAM)buffer);
- }
- #ifndef AGA
- ew(hDlg, IDC_AGA, FALSE);
- #endif
- setgenlock(hDlg);
- }
- case WM_USER:
- recursive++;
- values_to_chipsetdlg (hDlg);
- enable_for_chipsetdlg (hDlg);
- recursive--;
- break;
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_GENLOCKFILE:
- {
- TCHAR *p = workprefs.genlock_image == 3 ? workprefs.genlock_image_file : workprefs.genlock_video_file;
- getcomboboxtext(hDlg, IDC_GENLOCKFILE, p, MAX_DPATH);
- parsefilepath(p, MAX_DPATH);
- addhistorymenu(hDlg, p, IDC_GENLOCKFILE, workprefs.genlock_image == 3 ? HISTORY_GENLOCK_IMAGE : HISTORY_GENLOCK_VIDEO, true, -1);
- break;
- }
- }
- }
- switch (LOWORD(wParam))
- {
- case IDC_GENLOCKFILESELECT:
- {
- TCHAR path[MAX_DPATH];
- path[0] = 0;
- DiskSelection(hDlg, IDC_GENLOCKFILESELECT, workprefs.genlock_image == 3 ? 20 : 21, &workprefs, NULL, path);
- break;
- }
- case IDC_BLITWAIT:
- if (workprefs.immediate_blits) {
- workprefs.immediate_blits = false;
- CheckDlgButton (hDlg, IDC_BLITIMM, FALSE);
- }
- break;
- case IDC_BLITIMM:
- if (workprefs.waiting_blits) {
- workprefs.waiting_blits = false;
- CheckDlgButton (hDlg, IDC_BLITWAIT, FALSE);
- }
- break;
- }
- values_from_chipsetdlg(hDlg, msg, wParam, lParam);
- enable_for_chipsetdlg(hDlg);
- recursive--;
- break;
- case WM_HSCROLL:
- if (recursive > 0)
- break;
- recursive++;
- values_from_chipsetdlg (hDlg, msg, wParam, lParam);
- enable_for_chipsetdlg( hDlg );
- recursive--;
- break;
- }
- return FALSE;
- }
- static void values_to_chipsetdlg2 (HWND hDlg)
- {
- TCHAR txt[32];
- uae_u32 rev;
- switch(workprefs.cs_ciaatod)
- {
- case 0:
- CheckRadioButton(hDlg, IDC_CS_CIAA_TOD1, IDC_CS_CIAA_TOD3, IDC_CS_CIAA_TOD1);
- break;
- case 1:
- CheckRadioButton(hDlg, IDC_CS_CIAA_TOD1, IDC_CS_CIAA_TOD3, IDC_CS_CIAA_TOD2);
- break;
- case 2:
- CheckRadioButton(hDlg, IDC_CS_CIAA_TOD1, IDC_CS_CIAA_TOD3, IDC_CS_CIAA_TOD3);
- break;
- }
- switch(workprefs.cs_rtc)
- {
- case 0:
- CheckRadioButton(hDlg, IDC_CS_RTC1, IDC_CS_RTC4, IDC_CS_RTC1);
- break;
- case 1:
- CheckRadioButton(hDlg, IDC_CS_RTC1, IDC_CS_RTC4, IDC_CS_RTC2);
- break;
- case 2:
- CheckRadioButton(hDlg, IDC_CS_RTC1, IDC_CS_RTC4, IDC_CS_RTC3);
- break;
- case 3:
- CheckRadioButton(hDlg, IDC_CS_RTC1, IDC_CS_RTC4, IDC_CS_RTC4);
- break;
- }
- CheckDlgButton(hDlg, IDC_CS_COMPATIBLE, workprefs.cs_compatible != 0);
- CheckDlgButton(hDlg, IDC_CS_RESETWARNING, workprefs.cs_resetwarning);
- CheckDlgButton(hDlg, IDC_CS_NOEHB, workprefs.cs_denisenoehb);
- CheckDlgButton(hDlg, IDC_CS_DIPAGNUS, workprefs.cs_dipagnus);
- CheckDlgButton(hDlg, IDC_CS_KSMIRROR_E0, workprefs.cs_ksmirror_e0);
- CheckDlgButton(hDlg, IDC_CS_KSMIRROR_A8, workprefs.cs_ksmirror_a8);
- CheckDlgButton(hDlg, IDC_CS_CIAOVERLAY, workprefs.cs_ciaoverlay);
- CheckDlgButton(hDlg, IDC_CS_DF0IDHW, workprefs.cs_df0idhw);
- CheckDlgButton(hDlg, IDC_CS_CD32CD, workprefs.cs_cd32cd);
- CheckDlgButton(hDlg, IDC_CS_CD32C2P, workprefs.cs_cd32c2p);
- CheckDlgButton(hDlg, IDC_CS_CD32NVRAM, workprefs.cs_cd32nvram);
- CheckDlgButton(hDlg, IDC_CS_CDTVCD, workprefs.cs_cdtvcd);
- CheckDlgButton(hDlg, IDC_CS_CDTVCR, workprefs.cs_cdtvcr);
- CheckDlgButton(hDlg, IDC_CS_CDTVRAM, workprefs.cs_cdtvram);
- CheckDlgButton(hDlg, IDC_CS_A1000RAM, workprefs.cs_a1000ram);
- CheckDlgButton(hDlg, IDC_CS_RAMSEY, workprefs.cs_ramseyrev >= 0);
- CheckDlgButton(hDlg, IDC_CS_FATGARY, workprefs.cs_fatgaryrev >= 0);
- CheckDlgButton(hDlg, IDC_CS_AGNUS, workprefs.cs_agnusrev >= 0);
- CheckDlgButton(hDlg, IDC_CS_DENISE, workprefs.cs_deniserev >= 0);
- CheckDlgButton(hDlg, IDC_CS_DMAC, workprefs.cs_mbdmac & 1);
- CheckDlgButton(hDlg, IDC_CS_DMAC2, workprefs.cs_mbdmac & 2);
- CheckDlgButton(hDlg, IDC_CS_PCMCIA, workprefs.cs_pcmcia);
- CheckDlgButton(hDlg, IDC_CS_SLOWISFAST, workprefs.cs_slowmemisfast);
- CheckDlgButton(hDlg, IDC_CS_CIATODBUG, workprefs.cs_ciatodbug);
- CheckDlgButton(hDlg, IDC_CS_Z3AUTOCONFIG, workprefs.cs_z3autoconfig);
- CheckDlgButton(hDlg, IDC_CS_IDE1, workprefs.cs_ide > 0 && (workprefs.cs_ide & 1));
- CheckDlgButton(hDlg, IDC_CS_IDE2, workprefs.cs_ide > 0 && (workprefs.cs_ide & 2));
- CheckDlgButton(hDlg, IDC_CS_1MCHIPJUMPER, workprefs.cs_1mchipjumper || workprefs.chipmem.size >= 0x100000);
- CheckDlgButton(hDlg, IDC_CS_BYTECUSTOMWRITEBUG, workprefs.cs_bytecustomwritebug);
- CheckDlgButton(hDlg, IDC_CS_COMPOSITECOLOR, workprefs.cs_color_burst);
- CheckDlgButton(hDlg, IDC_CS_TOSHIBAGARY, workprefs.cs_toshibagary);
- CheckDlgButton(hDlg, IDC_CS_ROMISSLOW, workprefs.cs_romisslow);
- CheckDlgButton(hDlg, IDC_CS_CIA, workprefs.cs_ciatype[0]);
- SendDlgItemMessage(hDlg, IDC_CS_UNMAPPED, CB_SETCURSEL, workprefs.cs_unmapped_space, 0);
- txt[0] = 0;
- _stprintf (txt, _T("%d"), workprefs.cs_rtc_adjust);
- SetDlgItemText(hDlg, IDC_CS_RTCADJUST, txt);
- txt[0] = 0;
- if (workprefs.cs_fatgaryrev >= 0)
- _stprintf (txt, _T("%02X"), workprefs.cs_fatgaryrev);
- SetDlgItemText(hDlg, IDC_CS_FATGARYREV, txt);
- txt[0] = 0;
- if (workprefs.cs_ramseyrev >= 0)
- _stprintf (txt, _T("%02X"), workprefs.cs_ramseyrev);
- SetDlgItemText(hDlg, IDC_CS_RAMSEYREV, txt);
- txt[0] = 0;
- if (workprefs.cs_agnusrev >= 0) {
- rev = workprefs.cs_agnusrev;
- _stprintf (txt, _T("%02X"), rev);
- } else if (workprefs.cs_compatible) {
- rev = 0;
- if (workprefs.ntscmode)
- rev |= 0x10;
- rev |= (workprefs.chipset_mask & CSMASK_AGA) ? 0x23 : 0;
- rev |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x20 : 0;
- if (workprefs.chipmem.size > 1024 * 1024 && (workprefs.chipset_mask & CSMASK_ECS_AGNUS))
- rev |= 0x21;
- _stprintf (txt, _T("%02X"), rev);
- }
- SetDlgItemText(hDlg, IDC_CS_AGNUSREV, txt);
- txt[0] = 0;
- if (workprefs.cs_deniserev >= 0) {
- rev = workprefs.cs_deniserev;
- _stprintf (txt, _T("%01.1X"), rev);
- } else if (workprefs.cs_compatible) {
- rev = 0xf;
- if (workprefs.chipset_mask & CSMASK_ECS_DENISE)
- rev = 0xc;
- if (workprefs.chipset_mask & CSMASK_AGA)
- rev = 0x8;
- _stprintf (txt, _T("%01.1X"), rev);
- }
- SetDlgItemText(hDlg, IDC_CS_DENISEREV, txt);
- }
- static void values_from_chipsetdlg2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- TCHAR txt[32], *p;
- int v;
- if (!!workprefs.cs_compatible != ischecked(hDlg, IDC_CS_COMPATIBLE)) {
- if (ischecked(hDlg, IDC_CS_COMPATIBLE)) {
- if (!cs_compatible)
- cs_compatible = CP_GENERIC;
- workprefs.cs_compatible = cs_compatible;
- } else {
- workprefs.cs_compatible = 0;
- }
- built_in_chipset_prefs(&workprefs);
- values_to_chipsetdlg2(hDlg);
- }
- workprefs.cs_resetwarning = ischecked (hDlg, IDC_CS_RESETWARNING);
- workprefs.cs_ciatodbug = ischecked (hDlg, IDC_CS_CIATODBUG);
- workprefs.cs_denisenoehb = ischecked (hDlg, IDC_CS_NOEHB);
- workprefs.cs_dipagnus = ischecked (hDlg, IDC_CS_DIPAGNUS);
- workprefs.cs_agnusbltbusybug = workprefs.cs_dipagnus;
- workprefs.cs_ksmirror_e0 = ischecked (hDlg, IDC_CS_KSMIRROR_E0);
- workprefs.cs_ksmirror_a8 = ischecked (hDlg, IDC_CS_KSMIRROR_A8);
- workprefs.cs_ciaoverlay = ischecked (hDlg, IDC_CS_CIAOVERLAY);
- workprefs.cs_df0idhw = ischecked (hDlg, IDC_CS_DF0IDHW);
- workprefs.cs_cd32cd = ischecked (hDlg, IDC_CS_CD32CD);
- workprefs.cs_cd32c2p = ischecked (hDlg, IDC_CS_CD32C2P);
- workprefs.cs_cd32nvram = ischecked (hDlg, IDC_CS_CD32NVRAM);
- workprefs.cs_cdtvcd = ischecked (hDlg, IDC_CS_CDTVCD);
- workprefs.cs_cdtvcr = ischecked (hDlg, IDC_CS_CDTVCR);
- workprefs.cs_cdtvram = ischecked (hDlg, IDC_CS_CDTVRAM);
- workprefs.cs_a1000ram = ischecked (hDlg, IDC_CS_A1000RAM);
- workprefs.cs_ramseyrev = ischecked (hDlg, IDC_CS_RAMSEY) ? 0x0f : -1;
- workprefs.cs_fatgaryrev = ischecked (hDlg, IDC_CS_FATGARY) ? 0x00 : -1;
- workprefs.cs_mbdmac = ischecked (hDlg, IDC_CS_DMAC) ? 1 : 0;
- workprefs.cs_mbdmac |= ischecked (hDlg, IDC_CS_DMAC2) ? 2 : 0;
- workprefs.cs_pcmcia = ischecked (hDlg, IDC_CS_PCMCIA) ? 1 : 0;
- workprefs.cs_slowmemisfast = ischecked (hDlg, IDC_CS_SLOWISFAST) ? 1 : 0;
- workprefs.cs_z3autoconfig = ischecked (hDlg, IDC_CS_Z3AUTOCONFIG) ? 1 : 0;
- workprefs.cs_ide = ischecked (hDlg, IDC_CS_IDE1) ? 1 : (ischecked (hDlg, IDC_CS_IDE2) ? 2 : 0);
- workprefs.cs_ciaatod = ischecked (hDlg, IDC_CS_CIAA_TOD1) ? 0
- : (ischecked (hDlg, IDC_CS_CIAA_TOD2) ? 1 : 2);
- workprefs.cs_rtc = ischecked (hDlg, IDC_CS_RTC1) ? 0
- : ischecked (hDlg, IDC_CS_RTC2) ? 1 : ischecked (hDlg, IDC_CS_RTC3) ? 2 : 3;
- workprefs.cs_1mchipjumper = ischecked(hDlg, IDC_CS_1MCHIPJUMPER);
- workprefs.cs_bytecustomwritebug = ischecked(hDlg, IDC_CS_BYTECUSTOMWRITEBUG);
- workprefs.cs_color_burst = ischecked(hDlg, IDC_CS_COMPOSITECOLOR);
- workprefs.cs_toshibagary = ischecked(hDlg, IDC_CS_TOSHIBAGARY);
- workprefs.cs_romisslow = ischecked(hDlg, IDC_CS_ROMISSLOW);
- workprefs.cs_ciatype[0] = workprefs.cs_ciatype[1] = ischecked(hDlg, IDC_CS_CIA);
- LRESULT val = SendDlgItemMessage(hDlg, IDC_CS_UNMAPPED, CB_GETCURSEL, 0, 0L);
- if (val != CB_ERR)
- workprefs.cs_unmapped_space = val;
- cfgfile_compatibility_romtype(&workprefs);
- if (workprefs.cs_rtc) {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_CS_RTCADJUST, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- workprefs.cs_rtc_adjust = _tstol(txt);
- }
- if (workprefs.cs_fatgaryrev >= 0) {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_CS_FATGARYREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- v = _tcstol (txt, &p, 16);
- if (v >= 0 && v <= 255)
- workprefs.cs_fatgaryrev = v;
- }
- if (workprefs.cs_ramseyrev >= 0) {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_CS_RAMSEYREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- v = _tcstol (txt, &p, 16);
- if (v >= 0 && v <= 255)
- workprefs.cs_ramseyrev = v;
- }
- if (workprefs.cs_agnusrev >= 0) {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_CS_AGNUSREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- v = _tcstol (txt, &p, 16);
- if (v >= 0 && v <= 255)
- workprefs.cs_agnusrev = v;
- }
- if (workprefs.cs_deniserev >= 0) {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_CS_DENISEREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- v = _tcstol (txt, &p, 16);
- if (v >= 0 && v <= 15)
- workprefs.cs_deniserev = v;
- }
- }
- static void enable_for_chipsetdlg2 (HWND hDlg)
- {
- int e = workprefs.cs_compatible ? FALSE : TRUE;
- ew(hDlg, IDC_CS_FATGARY, e);
- ew(hDlg, IDC_CS_RAMSEY, e);
- ew(hDlg, IDC_CS_AGNUS, e);
- ew(hDlg, IDC_CS_DENISE, e);
- ew(hDlg, IDC_CS_FATGARYREV, e);
- ew(hDlg, IDC_CS_RAMSEYREV, e);
- ew(hDlg, IDC_CS_AGNUSREV, e);
- ew(hDlg, IDC_CS_DENISEREV, e);
- ew(hDlg, IDC_CS_IDE1, e);
- ew(hDlg, IDC_CS_IDE2, e);
- ew(hDlg, IDC_CS_DMAC, e);
- ew(hDlg, IDC_CS_DMAC2, e);
- ew(hDlg, IDC_CS_PCMCIA, e);
- ew(hDlg, IDC_CS_SLOWISFAST, e);
- ew(hDlg, IDC_CS_CD32CD, e);
- ew(hDlg, IDC_CS_CD32NVRAM, e);
- ew(hDlg, IDC_CS_CD32C2P, e);
- ew(hDlg, IDC_CS_CDTVCD, e);
- ew(hDlg, IDC_CS_CDTVCR, e);
- ew(hDlg, IDC_CS_CDTVRAM, e);
- ew(hDlg, IDC_CS_RESETWARNING, e);
- ew(hDlg, IDC_CS_CIATODBUG, e);
- ew(hDlg, IDC_CS_NOEHB, e);
- ew(hDlg, IDC_CS_DIPAGNUS, e);
- ew(hDlg, IDC_CS_Z3AUTOCONFIG, e);
- ew(hDlg, IDC_CS_KSMIRROR_E0, e);
- ew(hDlg, IDC_CS_KSMIRROR_A8, e);
- ew(hDlg, IDC_CS_CIAOVERLAY, e);
- ew(hDlg, IDC_CS_A1000RAM, e);
- ew(hDlg, IDC_CS_DF0IDHW, e);
- ew(hDlg, IDC_CS_CIAA_TOD1, e);
- ew(hDlg, IDC_CS_CIAA_TOD2, e);
- ew(hDlg, IDC_CS_CIAA_TOD3, e);
- ew(hDlg, IDC_CS_RTC1, e);
- ew(hDlg, IDC_CS_RTC2, e);
- ew(hDlg, IDC_CS_RTC3, e);
- ew(hDlg, IDC_CS_RTC4, e);
- ew(hDlg, IDC_CS_RTCADJUST, e);
- ew(hDlg, IDC_CS_1MCHIPJUMPER, e && workprefs.chipmem.size < 0x100000);
- ew(hDlg, IDC_CS_BYTECUSTOMWRITEBUG, e);
- ew(hDlg, IDC_CS_COMPOSITECOLOR, e);
- ew(hDlg, IDC_CS_TOSHIBAGARY, e);
- ew(hDlg, IDC_CS_ROMISSLOW, e);
- ew(hDlg, IDC_CS_UNMAPPED, e);
- ew(hDlg, IDC_CS_CIA, e);
- }
- static INT_PTR CALLBACK ChipsetDlgProc2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- TCHAR tmp[MAX_DPATH];
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- {
- pages[CHIPSET2_ID] = hDlg;
- currentpage = CHIPSET2_ID;
- cs_compatible = workprefs.cs_compatible;
- SendDlgItemMessage(hDlg, IDC_CS_UNMAPPED, CB_RESETCONTENT, 0, 0L);
- WIN32GUI_LoadUIString(IDS_UNMAPPED_ADDRESS, tmp, sizeof tmp / sizeof(TCHAR));
- TCHAR *p1 = tmp;
- for (;;) {
- TCHAR *p2 = _tcschr(p1, '\n');
- if (p2 && _tcslen(p2) > 0) {
- *p2++ = 0;
- SendDlgItemMessage(hDlg, IDC_CS_UNMAPPED, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- } else
- break;
- }
- }
- case WM_USER:
- recursive++;
- values_to_chipsetdlg2 (hDlg);
- enable_for_chipsetdlg2 (hDlg);
- recursive--;
- break;
- case WM_HSCROLL:
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- values_from_chipsetdlg2 (hDlg, msg, wParam, lParam);
- enable_for_chipsetdlg2 (hDlg);
- recursive--;
- break;
- }
- return FALSE;
- }
- static int fastram_select;
- static uae_u32 *fastram_select_pointer;
- static const int *fastram_select_msi;
- static struct ramboard *fastram_select_ramboard;
- #define MAX_STANDARD_RAM_BOARDS 2
- static void enable_for_memorydlg (HWND hDlg)
- {
- int z3 = workprefs.address_space_24 == false;
- bool ac = fastram_select_ramboard && fastram_select_ramboard->autoconfig_inuse;
- bool manual = fastram_select_ramboard && fastram_select_ramboard->manual_config;
- bool size = fastram_select_ramboard && fastram_select_ramboard->size != 0;
- #ifndef AUTOCONFIG
- z3 = FALSE;
- fast = FALSE;
- #endif
- ew (hDlg, IDC_Z3TEXT, z3);
- ew (hDlg, IDC_Z3FASTRAM, z3);
- ew (hDlg, IDC_Z3FASTMEM, z3);
- ew (hDlg, IDC_Z3CHIPRAM, z3);
- ew (hDlg, IDC_Z3CHIPMEM, z3);
- ew (hDlg, IDC_FASTMEM, true);
- ew (hDlg, IDC_FASTRAM, true);
- ew (hDlg, IDC_Z3MAPPING, z3);
- ew (hDlg, IDC_FASTTEXT, true);
- bool isfast = fastram_select >= MAX_STANDARD_RAM_BOARDS && fastram_select < MAX_STANDARD_RAM_BOARDS + 2 * MAX_RAM_BOARDS && fastram_select_ramboard && fastram_select_ramboard->size;
- ew(hDlg, IDC_AUTOCONFIG_MANUFACTURER, isfast && !manual);
- ew(hDlg, IDC_AUTOCONFIG_PRODUCT, isfast && !manual);
- ew(hDlg, IDC_MEMORYBOARDSELECT, isfast);
- ew(hDlg, IDC_AUTOCONFIG_DATA, ac && size);
- ew(hDlg, IDC_FASTMEMAUTOCONFIGUSE, isfast);
- ew(hDlg, IDC_FASTMEMNOAUTOCONFIG, isfast);
- ew(hDlg, IDC_FASTMEMDMA, true);
- ew(hDlg, IDC_FASTMEMFORCE16, true);
- ew(hDlg, IDC_MEMORYRAM, true);
- ew(hDlg, IDC_MEMORYMEM, true);
- ew(hDlg, IDC_RAM_ADDRESS, manual && size);
- ew(hDlg, IDC_RAM_ADDRESS2, manual && size);
- }
- static void setfastram_ramboard(HWND hDlg, int zram)
- {
- if (!fastram_select_ramboard)
- return;
- int idx = 1;
- for (int i = 0; memoryboards[i].name; i++) {
- const struct memoryboardtype *mbt = &memoryboards[i];
- if (mbt->z == zram) {
- if ((mbt->manufacturer == fastram_select_ramboard->manufacturer && mbt->product == fastram_select_ramboard->product) || (mbt->address && mbt->address == fastram_select_ramboard->start_address)) {
- SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_SETCURSEL, idx, 0);
- break;
- }
- idx++;
- }
- }
- }
- static int getmemsize(uae_u32 size, const int *msi)
- {
- int mem_size = 0;
- if (msi == msi_fast) {
- switch (size)
- {
- case 0x00000000: mem_size = 0; break;
- case 0x00010000: mem_size = 1; break;
- case 0x00020000: mem_size = 2; break;
- case 0x00040000: mem_size = 3; break;
- case 0x00080000: mem_size = 4; break;
- case 0x00100000: mem_size = 5; break;
- case 0x00200000: mem_size = 6; break;
- case 0x00400000: mem_size = 7; break;
- case 0x00800000: mem_size = 8; break;
- case 0x01000000: mem_size = 9; break;
- }
- } else if (msi == msi_chip) {
- switch (size)
- {
- case 0x00040000: mem_size = 0; break;
- case 0x00080000: mem_size = 1; break;
- case 0x00100000: mem_size = 2; break;
- case 0x00180000: mem_size = 3; break;
- case 0x00200000: mem_size = 4; break;
- case 0x00400000: mem_size = 5; break;
- case 0x00800000: mem_size = 6; break;
- }
- } else if (msi == msi_bogo) {
- switch (size)
- {
- case 0x00000000: mem_size = 0; break;
- case 0x00080000: mem_size = 1; break;
- case 0x00100000: mem_size = 2; break;
- case 0x00180000: mem_size = 3; break;
- case 0x001C0000: mem_size = 4; break;
- }
- } else if (msi == msi_z3chip) {
- switch (size)
- {
- case 0x00000000: mem_size = 0; break;
- case 0x01000000: mem_size = 1; break;
- case 0x02000000: mem_size = 2; break;
- case 0x04000000: mem_size = 3; break;
- case 0x08000000: mem_size = 4; break;
- case 0x10000000: mem_size = 5; break;
- case 0x18000000: mem_size = 6; break;
- case 0x20000000: mem_size = 7; break;
- case 0x30000000: mem_size = 8; break;
- case 0x40000000: mem_size = 9; break;
- }
- } else {
- if (size < 0x00100000)
- mem_size = 0;
- else if (size < 0x00200000)
- mem_size = 1;
- else if (size < 0x00400000)
- mem_size = 2;
- else if (size < 0x00800000)
- mem_size = 3;
- else if (size < 0x01000000)
- mem_size = 4;
- else if (size < 0x02000000)
- mem_size = 5;
- else if (size < 0x04000000)
- mem_size = 6;
- else if (size < 0x08000000)
- mem_size = 7;
- else if (size < 0x10000000)
- mem_size = 8;
- else if (size < 0x20000000)
- mem_size = 9;
- else if (size < 0x40000000)
- mem_size = 10;
- else // 1GB
- mem_size = 11;
- }
- return mem_size;
- }
- static void addadvancedram(HWND hDlg, struct ramboard *rb, const TCHAR *name, const int *msi)
- {
- TCHAR tmp[200];
- _tcscpy(tmp, name);
- if (rb->size) {
- int mem_size = getmemsize(rb->size, msi);
- _tcscat(tmp, _T(" ("));
- _tcscat(tmp, memsize_names[msi[mem_size]]);
- _tcscat(tmp, _T(")"));
- }
- SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- static void setfastram_selectmenu(HWND hDlg, int mode)
- {
- int min;
- int max;
- const int *msi;
- TCHAR tmp[200];
- int zram = 0;
- struct ramboard *fastram_select_ramboard_old = fastram_select_ramboard;
- fastram_select_ramboard = NULL;
- if (fastram_select == 0) {
- min = 0;
- max = MAX_CHIP_MEM;
- msi = msi_chip;
- fastram_select_pointer = &workprefs.chipmem.size;
- fastram_select_ramboard = &workprefs.chipmem;
- } else if (fastram_select == 1) {
- min = 0;
- max = MAX_SLOW_MEM;
- msi = msi_bogo;
- fastram_select_pointer = &workprefs.bogomem.size;
- fastram_select_ramboard = &workprefs.bogomem;
- } else if (fastram_select < MAX_STANDARD_RAM_BOARDS + MAX_RAM_BOARDS) {
- msi = msi_fast;
- min = MIN_FAST_MEM;
- max = MAX_FAST_MEM;
- fastram_select_ramboard = &workprefs.fastmem[fastram_select - MAX_STANDARD_RAM_BOARDS];
- fastram_select_pointer = &fastram_select_ramboard->size;
- zram = 2;
- } else if (fastram_select >= MAX_STANDARD_RAM_BOARDS + MAX_RAM_BOARDS && fastram_select < MAX_STANDARD_RAM_BOARDS + MAX_RAM_BOARDS * 2) {
- msi = msi_z3fast;
- min = MIN_Z3_MEM;
- max = MAX_Z3_MEM;
- fastram_select_ramboard = &workprefs.z3fastmem[fastram_select - (MAX_RAM_BOARDS + MAX_STANDARD_RAM_BOARDS)];
- fastram_select_pointer = &fastram_select_ramboard->size;
- zram = 3;
- } else if (fastram_select == MAX_STANDARD_RAM_BOARDS + 2 * MAX_RAM_BOARDS) {
- min = 0;
- max = MAX_CB_MEM_128M;
- msi = msi_cpuboard;
- fastram_select_pointer = &workprefs.mbresmem_high.size;
- fastram_select_ramboard = &workprefs.mbresmem_high;
- } else if (fastram_select == MAX_STANDARD_RAM_BOARDS + 2 * MAX_RAM_BOARDS + 1) {
- min = 0;
- max = MAX_CB_MEM_64M;
- msi = msi_cpuboard;
- fastram_select_pointer = &workprefs.mbresmem_low.size;
- fastram_select_ramboard = &workprefs.mbresmem_low;
- } else if (fastram_select == MAX_STANDARD_RAM_BOARDS + 2 * MAX_RAM_BOARDS + 2) {
- min = 0;
- max = MAX_Z3_CHIPMEM;
- msi = msi_z3chip;
- fastram_select_pointer = &workprefs.z3chipmem.size;
- fastram_select_ramboard = &workprefs.z3chipmem;
- } else {
- return;
- }
- fastram_select_msi = msi;
- uae_u32 v = *fastram_select_pointer;
- int mem_size = getmemsize(v, msi);
- SendDlgItemMessage(hDlg, IDC_MEMORYMEM, TBM_SETRANGE, TRUE, MAKELONG(min, max));
- SendDlgItemMessage(hDlg, IDC_MEMORYMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText(hDlg, IDC_MEMORYRAM, memsize_names[msi[mem_size]]);
- expansion_generate_autoconfig_info(&workprefs);
- struct ramboard *rb = fastram_select_ramboard;
- setchecked(hDlg, IDC_FASTMEMAUTOCONFIGUSE, rb && rb->autoconfig_inuse);
- setchecked(hDlg, IDC_FASTMEMNOAUTOCONFIG, rb && rb->manual_config);
- setchecked(hDlg, IDC_FASTMEMDMA, rb && rb->nodma == 0);
- setchecked(hDlg, IDC_FASTMEMFORCE16, rb && rb->force16bit != 0);
- if (rb) {
- if (rb->manual_config) {
- if (rb->end_address <= rb->start_address || rb->start_address + rb->size < rb->end_address)
- rb->end_address = rb->start_address + rb->size - 1;
- } else {
- rb->start_address = 0;
- rb->end_address = 0;
- }
- if (fastram_select_ramboard_old != fastram_select_ramboard || mode < 0) {
- if (zram) {
- ew(hDlg, IDC_MEMORYBOARDSELECT, TRUE);
- SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- for (int i = 0; memoryboards[i].name; i++) {
- const struct memoryboardtype *mbt = &memoryboards[i];
- if (mbt->z == zram) {
- _stprintf(tmp, _T("%s %s"), memoryboards[i].man, memoryboards[i].name);
- SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- }
- } else {
- SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_RESETCONTENT, 0, 0);
- ew(hDlg, IDC_MEMORYBOARDSELECT, FALSE);
- }
- }
- struct autoconfig_info* aci = NULL;
- if (fastram_select >= MAX_STANDARD_RAM_BOARDS && fastram_select < MAX_STANDARD_RAM_BOARDS + 2 * MAX_RAM_BOARDS) {
- aci = expansion_get_autoconfig_info(&workprefs, fastram_select < MAX_STANDARD_RAM_BOARDS + MAX_RAM_BOARDS ? ROMTYPE_RAMZ2 : ROMTYPE_RAMZ3, fastram_select % MAX_RAM_BOARDS);
- if (!rb->autoconfig_inuse) {
- if (aci) {
- memcpy(rb->autoconfig, aci->autoconfig_bytes, sizeof rb->autoconfig);
- }
- if (rb->manufacturer) {
- rb->autoconfig[1] = rb->product;
- rb->autoconfig[4] = (rb->manufacturer >> 8) & 0xff;
- rb->autoconfig[5] = rb->manufacturer & 0xff;
- } else {
- memset(rb->autoconfig, 0, sizeof rb->autoconfig);
- aci = expansion_get_autoconfig_info(&workprefs, fastram_select < MAX_RAM_BOARDS ? ROMTYPE_RAMZ2 : ROMTYPE_RAMZ3, fastram_select% MAX_RAM_BOARDS);
- if (aci) {
- memcpy(rb->autoconfig, aci->autoconfig_bytes, sizeof rb->autoconfig);
- }
- }
- }
- }
- if (mode != 3) {
- if (aci && !rb->manual_config) {
- _stprintf(tmp, _T("%08x"), aci->start);
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS, tmp);
- _stprintf(tmp, _T("%08x"), aci->start + aci->size - 1);
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS2, tmp);
- } else if (rb->manual_config) {
- _stprintf(tmp, _T("%08x"), rb->start_address);
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS, tmp);
- _stprintf(tmp, _T("%08x"), rb->end_address);
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS2, tmp);
- } else {
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS, _T(""));
- SetDlgItemText(hDlg, IDC_RAM_ADDRESS2, _T(""));
- }
- }
- if (mode == 1 && rb->autoconfig_inuse) {
- rb->autoconfig[1] = rb->product;
- rb->autoconfig[4] = (rb->manufacturer >> 8) & 0xff;
- rb->autoconfig[5] = rb->manufacturer & 0xff;
- }
- if (mode != 2) {
- tmp[0] = 0;
- TCHAR *p = tmp;
- for (int i = 0; i < 12; i++) {
- if (i > 0)
- _tcscat(p, _T("."));
- _stprintf(p + _tcslen(p), _T("%02x"), rb->autoconfig[i]);
- }
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_DATA, tmp);
- }
- if (rb->autoconfig_inuse) {
- rb->product = rb->autoconfig[1];
- rb->manufacturer = (rb->autoconfig[4] << 8) | rb->autoconfig[5];
- }
- if (mode != 1) {
- if (rb->manufacturer) {
- _stprintf(tmp, _T("%d"), rb->manufacturer);
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_MANUFACTURER, tmp);
- _stprintf(tmp, _T("%d"), rb->product);
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_PRODUCT, tmp);
- } else {
- rb->product = 0;
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_MANUFACTURER, _T(""));
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_PRODUCT, _T(""));
- }
- }
- setfastram_ramboard(hDlg, zram);
- } else {
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_MANUFACTURER, _T(""));
- SetDlgItemText(hDlg, IDC_AUTOCONFIG_PRODUCT, _T(""));
- }
- SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_RESETCONTENT, 0, 0);
- addadvancedram(hDlg, &workprefs.chipmem, _T("Chip RAM"), msi_chip);
- addadvancedram(hDlg, &workprefs.bogomem, _T("Slow RAM"), msi_bogo);
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- struct autoconfig_info *aci = expansion_get_autoconfig_info(&workprefs, ROMTYPE_RAMZ2, i);
- _stprintf(tmp, _T("Z2 Fast Ram #%d"), i + 1);
- if (workprefs.fastmem[i].size)
- _stprintf(tmp + _tcslen(tmp), _T(" [%dk]"), workprefs.fastmem[i].size / 1024);
- if (aci && aci->cst) {
- _stprintf(tmp + _tcslen(tmp), _T(" (%s)"), aci->cst->name);
- } else if (aci && aci->ert) {
- _stprintf(tmp + _tcslen(tmp), _T(" (%s)"), aci->ert->friendlyname);
- }
- SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- if (!workprefs.address_space_24) {
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- struct autoconfig_info *aci = expansion_get_autoconfig_info(&workprefs, ROMTYPE_RAMZ3, i);
- _stprintf(tmp, _T("Z3 Fast Ram #%d"), i + 1);
- if (workprefs.z3fastmem[i].size)
- _stprintf(tmp + _tcslen(tmp), _T(" [%dM]"), workprefs.z3fastmem[i].size / (1024 * 1024));
- if (aci && aci->cst) {
- _stprintf(tmp + _tcslen(tmp), _T(" (%s)"), aci->cst->name);
- } else if (aci && aci->ert) {
- _stprintf(tmp + _tcslen(tmp), _T(" (%s)"), aci->ert->friendlyname);
- }
- SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- addadvancedram(hDlg, &workprefs.mbresmem_high, _T("Processor Slot Fast RAM"), msi_mb);
- addadvancedram(hDlg, &workprefs.mbresmem_low, _T("Motherboard Fast RAM"), msi_mb);
- addadvancedram(hDlg, &workprefs.z3chipmem, _T("32-bit Chip RAM"), msi_z3chip);
- } else {
- if (fastram_select >= MAX_STANDARD_RAM_BOARDS + MAX_RAM_BOARDS)
- fastram_select = 0;
- }
- SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_SETCURSEL, fastram_select, 0);
- enable_for_memorydlg(hDlg);
- }
- extern uae_u32 natmem_reserved_size;
- static void setmax32bitram (HWND hDlg)
- {
- TCHAR tmp[256];
- uae_u32 size32 = 0, z3size_uae = 0, z3size_real = 0;
- z3size_uae = natmem_reserved_size >= expamem_z3_pointer_uae ? natmem_reserved_size - expamem_z3_pointer_uae : 0;
- z3size_real = natmem_reserved_size >= expamem_z3_pointer_real ? natmem_reserved_size - expamem_z3_pointer_real : 0;
- uae_u32 first = 0;
- int idx = 0;
- for (;;) {
- struct autoconfig_info *aci = expansion_get_autoconfig_data(&workprefs, idx);
- if (!aci)
- break;
- if (aci->start >= 0x10000000 && !first)
- first = aci->start;
- if (aci->start >= 0x10000000 && aci->start + aci->size > size32)
- size32 = aci->start + aci->size;
- idx++;
- }
- if (size32 >= first)
- size32 -= first;
- _stprintf (tmp, L"Configured 32-bit address space: %dM, reserved: %dM, Z3 available: %dM (UAE), %dM (Real)",
- size32 / (1024 * 1024), (natmem_reserved_size - 256 * 1024 * 1024) / (1024 * 1024), z3size_uae / (1024 * 1024), z3size_real / (1024 * 1024));
- SetDlgItemText (hDlg, IDC_MAX32RAM, tmp);
- }
- static void setcpuboardmemsize(HWND hDlg)
- {
- if (workprefs.cpuboardmem1.size > cpuboard_maxmemory(&workprefs))
- workprefs.cpuboardmem1.size = cpuboard_maxmemory(&workprefs);
- if (cpuboard_memorytype(&workprefs) == BOARD_MEMORY_Z2) {
- workprefs.fastmem[0].size = workprefs.cpuboardmem1.size;
- }
- if (cpuboard_memorytype(&workprefs) == BOARD_MEMORY_25BITMEM) {
- workprefs.mem25bit.size = workprefs.cpuboardmem1.size;
- }
- if (workprefs.cpuboard_type == 0) {
- workprefs.mem25bit.size = 0;
- }
- if (cpuboard_memorytype(&workprefs) == BOARD_MEMORY_HIGHMEM)
- workprefs.mbresmem_high.size = workprefs.cpuboardmem1.size;
- int maxmem = cpuboard_maxmemory(&workprefs);
- if (workprefs.cpuboardmem1.size > maxmem) {
- workprefs.cpuboardmem1.size = maxmem;
- }
- if (maxmem <= 8 * 1024 * 1024)
- SendDlgItemMessage (hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CB_MEM, MAX_CB_MEM_Z2));
- else if (maxmem <= 16 * 1024 * 1024)
- SendDlgItemMessage(hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG(MIN_CB_MEM, MAX_CB_MEM_16M));
- else if (maxmem <= 32 * 1024 * 1024)
- SendDlgItemMessage(hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG(MIN_CB_MEM, MAX_CB_MEM_32M));
- else if (maxmem <= 64 * 1024 * 1024)
- SendDlgItemMessage(hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG(MIN_CB_MEM, MAX_CB_MEM_64M));
- else if (maxmem <= 128 * 1024 * 1024)
- SendDlgItemMessage (hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CB_MEM, MAX_CB_MEM_128M));
- else
- SendDlgItemMessage (hDlg, IDC_CPUBOARDMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CB_MEM, MAX_CB_MEM_256M));
- int mem_size = 0;
- switch (workprefs.cpuboardmem1.size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00100000: mem_size = 1; break;
- case 0x00200000: mem_size = 2; break;
- case 0x00400000: mem_size = 3; break;
- case 0x00800000: mem_size = 4; break;
- case 0x01000000: mem_size = 5; break;
- case 0x02000000: mem_size = 6; break;
- case 0x04000000: mem_size = 7; break;
- case 0x08000000: mem_size = 8; break;
- case 0x10000000: mem_size = 9; break;
- }
- SendDlgItemMessage (hDlg, IDC_CPUBOARDMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_CPUBOARDRAM, memsize_names[msi_cpuboard[mem_size]]);
- SendDlgItemMessage (hDlg, IDC_CPUBOARD_TYPE, CB_SETCURSEL, workprefs.cpuboard_type, 0);
- SendDlgItemMessage (hDlg, IDC_CPUBOARD_SUBTYPE, CB_SETCURSEL, workprefs.cpuboard_subtype, 0);
- // for (int i = 0; cpuboard_settings_id[i] >= 0; i++) {
- // setchecked(hDlg, cpuboard_settings_id[i], (workprefs.cpuboard_settings & (1 << i)) != 0);
- // }
- }
- static int manybits (int v, int mask)
- {
- int i, cnt;
- cnt = 0;
- for (i = 0; i < 32; i++) {
- if (((1 << i) & mask) & v)
- cnt++;
- }
- if (cnt > 1)
- return 1;
- return 0;
- }
- static void values_to_memorydlg (HWND hDlg)
- {
- uae_u32 mem_size = 0;
- uae_u32 v;
- switch (workprefs.chipmem.size) {
- case 0x00040000: mem_size = 0; break;
- case 0x00080000: mem_size = 1; break;
- case 0x00100000: mem_size = 2; break;
- case 0x00180000: mem_size = 3; break;
- case 0x00200000: mem_size = 4; break;
- case 0x00400000: mem_size = 5; break;
- case 0x00800000: mem_size = 6; break;
- }
- SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_CHIPRAM, memsize_names[msi_chip[mem_size]]);
- mem_size = 0;
- switch (workprefs.fastmem[0].size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00010000: mem_size = 1; break;
- case 0x00020000: mem_size = 2; break;
- case 0x00040000: mem_size = 3; break;
- case 0x00080000: mem_size = 4; break;
- case 0x00100000: mem_size = 5; break;
- case 0x00200000: mem_size = 6; break;
- case 0x00400000: mem_size = 7; break;
- case 0x00800000: mem_size = 8; break;
- case 0x01000000: mem_size = 9; break;
- }
- SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_FASTRAM, memsize_names[msi_fast[mem_size]]);
- mem_size = 0;
- switch (workprefs.bogomem.size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00080000: mem_size = 1; break;
- case 0x00100000: mem_size = 2; break;
- case 0x00180000: mem_size = 3; break;
- case 0x001C0000: mem_size = 4; break;
- }
- SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_SLOWRAM, memsize_names[msi_bogo[mem_size]]);
- mem_size = 0;
- v = workprefs.z3fastmem[0].size;
- if (v < 0x00100000)
- mem_size = 0;
- else if (v < 0x00200000)
- mem_size = 1;
- else if (v < 0x00400000)
- mem_size = 2;
- else if (v < 0x00800000)
- mem_size = 3;
- else if (v < 0x01000000)
- mem_size = 4;
- else if (v < 0x02000000)
- mem_size = 5;
- else if (v < 0x04000000)
- mem_size = 6;
- else if (v < 0x08000000)
- mem_size = 7;
- else if (v < 0x10000000)
- mem_size = 8;
- else if (v < 0x20000000)
- mem_size = 9;
- else if (v < 0x40000000)
- mem_size = 10;
- else // 1GB
- mem_size = 11;
- SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_Z3FASTRAM, memsize_names[msi_z3fast[mem_size]]);
- mem_size = 0;
- v = workprefs.z3chipmem.size;
- if (v < 0x01000000)
- mem_size = 0;
- else if (v < 0x02000000)
- mem_size = 1;
- else if (v < 0x04000000)
- mem_size = 2;
- else if (v < 0x08000000)
- mem_size = 3;
- else if (v < 0x10000000)
- mem_size = 4;
- else if (v < 0x18000000)
- mem_size = 5;
- else if (v < 0x20000000)
- mem_size = 6;
- else if (v < 0x30000000)
- mem_size = 7;
- else if (v < 0x40000000)
- mem_size = 8;
- else
- mem_size = 9;
- SendDlgItemMessage (hDlg, IDC_Z3CHIPMEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_Z3CHIPRAM, memsize_names[msi_z3chip[mem_size]]);
- #if 0
- mem_size = 0;
- switch (workprefs.mbresmem_low_size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00100000: mem_size = 1; break;
- case 0x00200000: mem_size = 2; break;
- case 0x00400000: mem_size = 3; break;
- case 0x00800000: mem_size = 4; break;
- case 0x01000000: mem_size = 5; break;
- case 0x02000000: mem_size = 6; break;
- case 0x04000000: mem_size = 7; break;
- }
- SendDlgItemMessage (hDlg, IDC_MBMEM1, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_MBRAM1, memsize_names[msi_gfx[mem_size]]);
- mem_size = 0;
- switch (workprefs.mbresmem_high_size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00100000: mem_size = 1; break;
- case 0x00200000: mem_size = 2; break;
- case 0x00400000: mem_size = 3; break;
- case 0x00800000: mem_size = 4; break;
- case 0x01000000: mem_size = 5; break;
- case 0x02000000: mem_size = 6; break;
- case 0x04000000: mem_size = 7; break;
- case 0x08000000: mem_size = 8; break;
- }
- SendDlgItemMessage (hDlg, IDC_MBMEM2, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText (hDlg, IDC_MBRAM2, memsize_names[msi_gfx[mem_size]]);
- #endif
- setmax32bitram (hDlg);
- }
- static void fix_values_memorydlg (void)
- {
- if (workprefs.chipmem.size <= 0x200000)
- return;
- int total = 0;
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if (workprefs.fastmem[i].size > 262144)
- workprefs.fastmem[i].size = 262144;
- total += workprefs.fastmem[i].size;
- if (total > 262144) {
- workprefs.fastmem[i].size = 0;
- }
- }
- }
- static void addromfiles(UAEREG *fkey, HWND hDlg, DWORD d, const TCHAR *path, int type1, int type2)
- {
- int idx;
- TCHAR tmp[MAX_DPATH];
- TCHAR tmp2[MAX_DPATH];
- TCHAR seltmp[MAX_DPATH];
- struct romdata *rdx = NULL;
- SendDlgItemMessage(hDlg, d, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM) _T(""));
- if (path)
- rdx = scan_single_rom(path);
- idx = 0;
- seltmp[0] = 0;
- for (; fkey;) {
- int size = sizeof(tmp) / sizeof(TCHAR);
- int size2 = sizeof(tmp2) / sizeof(TCHAR);
- if (!regenumstr(fkey, idx, tmp, &size, tmp2, &size2))
- break;
- if (_tcslen(tmp) == 7 || _tcslen(tmp) == 13) {
- int group = 0;
- int subitem = 0;
- int idx2 = _tstol(tmp + 4);
- if (_tcslen(tmp) == 13) {
- group = _tstol(tmp + 8);
- subitem = _tstol(tmp + 11);
- }
- if (idx2 >= 0) {
- struct romdata *rd = getromdatabyidgroup(idx2, group, subitem);
- for (int i = 0; i < 2; i++) {
- int type = i ? type2 : type1;
- if (type) {
- if (rd && ((((rd->type & ROMTYPE_GROUP_MASK) & (type & ROMTYPE_GROUP_MASK)) && ((rd->type & ROMTYPE_SUB_MASK) == (type & ROMTYPE_SUB_MASK) || !(type & ROMTYPE_SUB_MASK))) ||
- (rd->type & type) == ROMTYPE_NONE || (rd->type & type) == ROMTYPE_NOT)) {
- getromname(rd, tmp);
- if (SendDlgItemMessage(hDlg, d, CB_FINDSTRING, (WPARAM) -1, (LPARAM) tmp) < 0)
- SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM) tmp);
- if (rd == rdx)
- _tcscpy(seltmp, tmp);
- break;
- }
- }
- }
- }
- }
- idx++;
- }
- if (seltmp[0])
- SendDlgItemMessage(hDlg, d, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) seltmp);
- else
- SetDlgItemText(hDlg, d, path);
- }
- static void getromfile(HWND hDlg, DWORD d, TCHAR *path, int size)
- {
- LRESULT val = SendDlgItemMessage(hDlg, d, CB_GETCURSEL, 0, 0L);
- if (val == CB_ERR) {
- SendDlgItemMessage(hDlg, d, WM_GETTEXT, (WPARAM) size, (LPARAM) path);
- }
- else {
- TCHAR tmp1[MAX_DPATH];
- struct romdata *rd;
- SendDlgItemMessage(hDlg, d, CB_GETLBTEXT, (WPARAM) val, (LPARAM) tmp1);
- path[0] = 0;
- rd = getromdatabyname(tmp1);
- if (rd) {
- struct romlist *rl = getromlistbyromdata(rd);
- if (rd->configname)
- _stprintf(path, _T(":%s"), rd->configname);
- else if (rl)
- _tcsncpy(path, rl->path, size);
- }
- }
- }
- struct expansionrom_gui
- {
- const struct expansionboardsettings *expansionrom_gui_ebs;
- int expansionrom_gui_item;
- DWORD expansionrom_gui_itemselector;
- DWORD expansionrom_gui_selector;
- DWORD expansionrom_gui_checkbox;
- DWORD expansionrom_gui_stringbox;
- int expansionrom_gui_settingsbits;
- int expansionrom_gui_settingsshift;
- int expansionrom_gui_settings;
- TCHAR expansionrom_gui_string[ROMCONFIG_CONFIGTEXT_LEN];
- };
- static struct expansionrom_gui expansion_gui_item;
- static struct expansionrom_gui accelerator_gui_item;
- static void reset_expansionrom_gui(HWND hDlg, struct expansionrom_gui *eg, DWORD itemselector, DWORD selector, DWORD checkbox, DWORD stringbox)
- {
- eg->expansionrom_gui_settings = NULL;
- eg->expansionrom_gui_ebs = NULL;
- eg->expansionrom_gui_string[0] = 0;
- hide(hDlg, itemselector, 1);
- hide(hDlg, selector, 1);
- hide(hDlg, checkbox, 1);
- hide(hDlg, stringbox, 1);
- }
- static void create_expansionrom_gui(HWND hDlg, struct expansionrom_gui *eg, const struct expansionboardsettings *ebs,
- int settings, const TCHAR *settingsstring,
- DWORD itemselector, DWORD selector, DWORD checkbox, DWORD stringbox)
- {
- bool reset = false;
- static int recursive;
- const struct expansionboardsettings *eb;
- if (eg->expansionrom_gui_ebs != ebs) {
- if (eg->expansionrom_gui_ebs)
- eg->expansionrom_gui_item = 0;
- reset = true;
- }
- eg->expansionrom_gui_ebs = ebs;
- eg->expansionrom_gui_itemselector = itemselector;
- eg->expansionrom_gui_selector = selector;
- eg->expansionrom_gui_checkbox = checkbox;
- eg->expansionrom_gui_stringbox = stringbox;
- eg->expansionrom_gui_settings = settings;
- if (settingsstring != eg->expansionrom_gui_string) {
- eg->expansionrom_gui_string[0] = 0;
- if (settingsstring)
- _tcscpy(eg->expansionrom_gui_string, settingsstring);
- }
- if (!ebs) {
- reset_expansionrom_gui(hDlg, eg, itemselector, selector, checkbox, stringbox);
- return;
- }
- if (recursive > 0)
- return;
- recursive++;
- retry:
- int item = eg->expansionrom_gui_item;
- hide(hDlg, itemselector, 0);
- int bitcnt = 0;
- for (int i = 0; i < item; i++) {
- const struct expansionboardsettings *eb = &ebs[i];
- if (eb->name == NULL) {
- eg->expansionrom_gui_item = 0;
- goto retry;
- }
- if (eb->type == EXPANSIONBOARD_STRING) {
- ;
- } else if (eb->type == EXPANSIONBOARD_MULTI) {
- const TCHAR *p = eb->configname;
- int itemcnt = -1;
- while (p[0]) {
- itemcnt++;
- p += _tcslen(p) + 1;
- }
- int bits = 1;
- for (int i = 0; i < 8; i++) {
- if ((1 << i) >= itemcnt) {
- bits = i;
- break;
- }
- }
- bitcnt += bits;
- } else {
- bitcnt++;
- }
- bitcnt += eb->bitshift;
- }
- if (reset) {
- SendDlgItemMessage(hDlg, itemselector, CB_RESETCONTENT, 0, 0);
- for (int i = 0; ebs[i].name; i++) {
- const struct expansionboardsettings *eb = &ebs[i];
- SendDlgItemMessage(hDlg, itemselector, CB_ADDSTRING, 0, (LPARAM)eb->name);
- }
- SendDlgItemMessage(hDlg, itemselector, CB_SETCURSEL, item, 0);
- }
- eb = &ebs[item];
- bitcnt += eb->bitshift;
- if (eb->type == EXPANSIONBOARD_STRING) {
- hide(hDlg, stringbox, 0);
- hide(hDlg, selector, 1);
- hide(hDlg, checkbox, 1);
- eg->expansionrom_gui_settingsbits = 0;
- SetDlgItemText(hDlg, stringbox, eg->expansionrom_gui_string);
- } else if (eb->type == EXPANSIONBOARD_MULTI) {
- SendDlgItemMessage(hDlg, selector, CB_RESETCONTENT, 0, 0);
- int itemcnt = -1;
- const TCHAR *p = eb->name;
- while (p[0]) {
- if (itemcnt >= 0) {
- SendDlgItemMessage(hDlg, selector, CB_ADDSTRING, 0, (LPARAM)p);
- }
- itemcnt++;
- p += _tcslen(p) + 1;
- }
- int bits = 1;
- for (int i = 0; i < 8; i++) {
- if ((1 << i) >= itemcnt) {
- bits = i;
- break;
- }
- }
- int value = settings;
- if (eb->invert)
- value ^= 0x7fffffff;
- value >>= bitcnt;
- value &= (1 << bits) - 1;
- SendDlgItemMessage(hDlg, selector, CB_SETCURSEL, value, 0);
- hide(hDlg, stringbox, 1);
- hide(hDlg, selector, 0);
- hide(hDlg, checkbox, 1);
- eg->expansionrom_gui_settingsbits = bits;
- } else {
- hide(hDlg, stringbox, 1);
- hide(hDlg, selector, 1);
- hide(hDlg, checkbox, 0);
- setchecked(hDlg, checkbox, ((settings >> bitcnt) ^ (eb->invert ? 1 : 0)) & 1);
- eg->expansionrom_gui_settingsbits = 1;
- }
- eg->expansionrom_gui_settingsshift = bitcnt;
- recursive--;
- }
- static void get_expansionrom_gui(HWND hDlg, struct expansionrom_gui *eg)
- {
- if (!eg->expansionrom_gui_ebs)
- return;
- int val;
- int settings = eg->expansionrom_gui_settings;
- val = SendDlgItemMessage(hDlg, eg->expansionrom_gui_itemselector, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR && val != eg->expansionrom_gui_item) {
- eg->expansionrom_gui_item = val;
- create_expansionrom_gui(hDlg, eg, eg->expansionrom_gui_ebs, eg->expansionrom_gui_settings, eg->expansionrom_gui_string,
- eg->expansionrom_gui_itemselector, eg->expansionrom_gui_selector, eg->expansionrom_gui_checkbox, eg->expansionrom_gui_stringbox);
- return;
- }
- const struct expansionboardsettings *eb = &eg->expansionrom_gui_ebs[eg->expansionrom_gui_item];
- if (eb->type == EXPANSIONBOARD_STRING) {
- GetDlgItemText(hDlg, eg->expansionrom_gui_stringbox, eg->expansionrom_gui_string, sizeof(eg->expansionrom_gui_string) / sizeof(TCHAR));
- } else if (eb->type == EXPANSIONBOARD_MULTI) {
- val = SendDlgItemMessage(hDlg, eg->expansionrom_gui_selector, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR) {
- int mask = (1 << eg->expansionrom_gui_settingsbits) - 1;
- settings &= ~(mask << eg->expansionrom_gui_settingsshift);
- settings |= val << eg->expansionrom_gui_settingsshift;
- if (eb->invert)
- settings ^= mask << eg->expansionrom_gui_settingsshift;
- }
- } else {
- settings &= ~(1 << eg->expansionrom_gui_settingsshift);
- if (ischecked(hDlg, eg->expansionrom_gui_checkbox)) {
- settings |= 1 << eg->expansionrom_gui_settingsshift;
- }
- if (eb->invert)
- settings ^= 1 << eg->expansionrom_gui_settingsshift;
- }
- eg->expansionrom_gui_settings = settings;
- }
- static struct netdriverdata *ndd[MAX_TOTAL_NET_DEVICES + 1];
- static int net_enumerated;
- struct netdriverdata **target_ethernet_enumerate(void)
- {
- if (net_enumerated)
- return ndd;
- ethernet_enumerate(ndd, 0);
- net_enumerated = 1;
- return ndd;
- }
- static const int scsiromselectedmask[] = {
- EXPANSIONTYPE_INTERNAL, EXPANSIONTYPE_SCSI, EXPANSIONTYPE_IDE, EXPANSIONTYPE_SASI, EXPANSIONTYPE_CUSTOM,
- EXPANSIONTYPE_PCI_BRIDGE, EXPANSIONTYPE_X86_BRIDGE, EXPANSIONTYPE_RTG,
- EXPANSIONTYPE_SOUND, EXPANSIONTYPE_NET, EXPANSIONTYPE_FLOPPY, EXPANSIONTYPE_X86_EXPANSION
- };
- static void init_expansion2(HWND hDlg, bool init)
- {
- static int first = -1;
- bool last = false;
- for (;;) {
- bool matched = false;
- int *idtab;
- int total = 0;
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECT, CB_RESETCONTENT, 0, 0);
- scsiromselect_table[0] = -1;
- for (int i = 0; expansionroms[i].name; i++) {
- total++;
- }
- idtab = xcalloc(int, total * 2);
- int idcnt = 0;
- for (int i = 0; expansionroms[i].name; i++) {
- if (expansionroms[i].romtype & ROMTYPE_CPUBOARD)
- continue;
- if (!(expansionroms[i].deviceflags & scsiromselectedmask[scsiromselectedcatnum]))
- continue;
- if (scsiromselectedcatnum == 0 && (expansionroms[i].deviceflags & (EXPANSIONTYPE_SASI | EXPANSIONTYPE_CUSTOM)))
- continue;
- if ((expansionroms[i].deviceflags & EXPANSIONTYPE_X86_EXPANSION) && scsiromselectedmask[scsiromselectedcatnum] != EXPANSIONTYPE_X86_EXPANSION)
- continue;
- int cnt = 0;
- for (int j = 0; j < MAX_DUPLICATE_EXPANSION_BOARDS; j++) {
- if (is_board_enabled(&workprefs, expansionroms[i].romtype, j)) {
- cnt++;
- }
- }
- if (i == scsiromselected)
- matched = true;
- if (cnt > 0) {
- if (first < 0)
- first = i;
- }
- idtab[idcnt++] = i;
- idtab[idcnt++] = cnt;
- }
- for (int j = 0; j < idcnt; j += 2) {
- TCHAR *nameval = NULL;
- TCHAR *cnameval = NULL;
- int ididx = -1;
- for (int i = 0; i < idcnt; i += 2) {
- TCHAR name[256], cname[256];
- int id = idtab[i];
- int cnt = idtab[i + 1];
- if (id < 0)
- continue;
- name[0] = 0;
- cname[0] = 0;
- if (cnt == 1)
- _tcscat(name, _T("* "));
- else if (cnt > 1)
- _stprintf(name + _tcslen(name), _T("[%d] "), cnt);
- _tcscat(name, expansionroms[id].friendlyname);
- _tcscat(cname, expansionroms[id].friendlyname);
- if (expansionroms[id].friendlymanufacturer) {
- _tcscat(name, _T(" ("));
- _tcscat(name, expansionroms[id].friendlymanufacturer);
- _tcscat(name, _T(")"));
- }
- if (!cnameval || _tcsicmp(cnameval, cname) > 0) {
- xfree(nameval);
- xfree(cnameval);
- nameval = my_strdup(name);
- cnameval = my_strdup(cname);
- ididx = i;
- }
- }
- gui_add_string(scsiromselect_table, hDlg, IDC_SCSIROMSELECT, idtab[ididx], nameval);
- idtab[ididx] = -1;
- xfree(nameval);
- xfree(cnameval);
- }
- xfree(idtab);
- if (scsiromselected > 0 && matched)
- break;
- int found = -1;
- for (int i = 0; expansionroms[i].name; i++) {
- int romtype = expansionroms[i].romtype;
- if (romtype & ROMTYPE_CPUBOARD)
- continue;
- if (!(expansionroms[i].deviceflags & scsiromselectedmask[scsiromselectedcatnum]))
- continue;
- if (scsiromselectedcatnum == 0 && (expansionroms[i].deviceflags & (EXPANSIONTYPE_SASI | EXPANSIONTYPE_CUSTOM)))
- continue;
- if (is_board_enabled(&workprefs, romtype, 0)) {
- if (found == -1)
- found = i;
- else
- found = -2;
- }
- }
- if (scsiromselected < 0 && found < 0)
- found = first;
- if (found > 0) {
- scsiromselected = found;
- break;
- }
- if (last || !init)
- break;
- scsiromselectedcatnum++;
- if (scsiromselectedcatnum > 5) {
- last = true;
- scsiromselectedcatnum = 0;
- scsiromselected = 0;
- }
- }
- if (scsiromselected > 0)
- gui_set_string_cursor(scsiromselect_table, hDlg, IDC_SCSIROMSELECT, scsiromselected);
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTCAT, CB_SETCURSEL, scsiromselectedcatnum, 0);
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_RESETCONTENT, 0, 0);
- int index;
- struct boardromconfig *brc = get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- const struct expansionromtype *ert = &expansionroms[scsiromselected];
- if (brc && ert && ert->id_jumper) {
- for (int i = 0; i < 8; i++) {
- TCHAR tmp[10];
- _stprintf(tmp, _T("%d"), i);
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- } else {
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_SETCURSEL, 0, 0);
- ew(hDlg, IDC_SCSIROMID, 0);
- }
- }
- static void values_to_expansion2dlg_sub(HWND hDlg)
- {
- SendDlgItemMessage(hDlg, IDC_CPUBOARDROMSUBSELECT, CB_RESETCONTENT, 0, 0);
- ew(hDlg, IDC_CPUBOARDROMSUBSELECT, false);
- SendDlgItemMessage(hDlg, IDC_SCSIROMSUBSELECT, CB_RESETCONTENT, 0, 0);
- const struct expansionromtype *er = &expansionroms[scsiromselected];
- const struct expansionsubromtype *srt = er->subtypes;
- int deviceflags = er->deviceflags;
- ew(hDlg, IDC_SCSIROMSUBSELECT, srt != NULL);
- while (srt && srt->name) {
- SendDlgItemMessage(hDlg, IDC_SCSIROMSUBSELECT, CB_ADDSTRING, 0, (LPARAM) srt->name);
- srt++;
- }
- int index;
- struct boardromconfig *brc = get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- if (brc && er->subtypes) {
- SendDlgItemMessage(hDlg, IDC_SCSIROMSUBSELECT, CB_SETCURSEL, brc->roms[index].subtype, 0);
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_SETCURSEL, brc->roms[index].device_id, 0);
- deviceflags |= er->subtypes[brc->roms[index].subtype].deviceflags;
- } else if (srt) {
- SendDlgItemMessage(hDlg, IDC_SCSIROMSUBSELECT, CB_SETCURSEL, 0, 0);
- SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_SETCURSEL, 0, 0);
- }
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_RESETCONTENT, 0, 0);
- if (deviceflags & EXPANSIONTYPE_CLOCKPORT) {
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- }
- for (int i = 0; i < MAX_AVAILABLE_DUPLICATE_EXPANSION_BOARDS; i++) {
- TCHAR tmp[10];
- _stprintf(tmp, _T("%d"), i + 1);
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_SETCURSEL, scsiromselectednum, 0);
- if ((er->zorro < 2 || er->singleonly) && !(deviceflags & EXPANSIONTYPE_CLOCKPORT)) {
- scsiromselectednum = 0;
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_SETCURSEL, 0, 0);
- }
- ew(hDlg, IDC_SCSIROMSELECTNUM, (er->zorro >= 2 && !er->singleonly) || (deviceflags & EXPANSIONTYPE_CLOCKPORT));
- hide(hDlg, IDC_SCSIROM24BITDMA, (deviceflags & EXPANSIONTYPE_DMA24) == 0);
- ew(hDlg, IDC_SCSIROM24BITDMA, (deviceflags & EXPANSIONTYPE_DMA24) != 0);
- }
- static void values_from_expansion2dlg(HWND hDlg)
- {
- int index;
- struct boardromconfig *brc;
- TCHAR tmp[MAX_DPATH];
- bool changed = false;
- bool isnew = false;
- int checked = ischecked(hDlg, IDC_SCSIROMSELECTED);
- getromfile(hDlg, IDC_SCSIROMFILE, tmp, MAX_DPATH / sizeof(TCHAR));
- if (tmp[0] || checked) {
- const struct expansionromtype *ert = &expansionroms[scsiromselected];
- if (!get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index))
- isnew = true;
- brc = get_device_rom_new(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- if (checked) {
- if (!brc->roms[index].romfile[0])
- changed = true;
- _tcscpy(brc->roms[index].romfile, _T(":ENABLED"));
- } else {
- changed = _tcscmp(tmp, brc->roms[index].romfile) != 0;
- getromfile(hDlg, IDC_SCSIROMFILE, brc->roms[index].romfile, MAX_DPATH / sizeof(TCHAR));
- }
- brc->roms[index].autoboot_disabled = ischecked(hDlg, IDC_SCSIROMFILEAUTOBOOT);
- brc->roms[index].inserted = ischecked(hDlg, IDC_SCSIROMFILEPCMCIA);
- brc->roms[index].dma24bit = ischecked(hDlg, IDC_SCSIROM24BITDMA);
- int v = SendDlgItemMessage(hDlg, IDC_SCSIROMID, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR && !isnew)
- brc->roms[index].device_id = v;
- const struct expansionboardsettings *cbs = ert->settings;
- if (cbs) {
- brc->roms[index].device_settings = expansion_gui_item.expansionrom_gui_settings;
- _tcscpy(brc->roms[index].configtext, expansion_gui_item.expansionrom_gui_string);
- }
- #if 0
- for (int i = 0; cbs[i].name; i++) {
- int id = expansion_settings_id[i];
- if (id < 0)
- break;
- brc->roms[index].device_settings &= ~(1 << i);
- if (ischecked(hDlg, id))
- brc->roms[index].device_settings |= 1 << i;
- }
- }
- #endif
- v = SendDlgItemMessage(hDlg, IDC_SCSIROMSUBSELECT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR)
- brc->roms[index].subtype = v;
- } else {
- brc = get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- if (brc && brc->roms[index].romfile[0])
- changed = true;
- clear_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, true);
- }
- if (changed) {
- // singleonly check and removal
- if (expansionroms[scsiromselected].singleonly) {
- if (get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index)) {
- for (int i = 0; i < MAX_EXPANSION_BOARDS; i++) {
- if (i != scsiromselectednum) {
- clear_device_rom(&workprefs, expansionroms[scsiromselected].romtype, i, true);
- }
- }
- }
- }
- init_expansion2(hDlg, false);
- values_to_expansion2dlg_sub(hDlg);
- }
- workprefs.cpuboard_settings = accelerator_gui_item.expansionrom_gui_settings;
- getromfile(hDlg, IDC_CPUBOARDROMFILE, tmp, sizeof(brc->roms[index].romfile) / sizeof(TCHAR));
- if (tmp[0]) {
- brc = get_device_rom_new(&workprefs, ROMTYPE_CPUBOARD, 0, &index);
- getromfile(hDlg, IDC_CPUBOARDROMFILE, brc->roms[index].romfile, sizeof(brc->roms[index].romfile) / sizeof(TCHAR));
- } else {
- clear_device_rom(&workprefs, ROMTYPE_CPUBOARD, 0, true);
- }
- }
- static void values_to_expansion2_expansion_roms(HWND hDlg, UAEREG *fkey)
- {
- int index;
- bool keyallocated = false;
- struct boardromconfig *brc;
- if (!fkey) {
- fkey = regcreatetree(NULL, _T("DetectedROMs"));
- keyallocated = true;
- }
- if (scsiromselected) {
- const struct expansionromtype *ert = &expansionroms[scsiromselected];
- int romtype = ert->romtype;
- int romtype_extra = ert->romtype_extra;
- int deviceflags = ert->deviceflags;
- brc = get_device_rom(&workprefs, romtype, scsiromselectednum, &index);
- if (brc && ert->subtypes) {
- const struct expansionsubromtype *esrt = &ert->subtypes[brc->roms[index].subtype];
- if (esrt->romtype) {
- romtype = esrt->romtype;
- romtype_extra = 0;
- }
- deviceflags |= esrt->deviceflags;
- }
- ew(hDlg, IDC_SCSIROMFILE, true);
- ew(hDlg, IDC_SCSIROMCHOOSER, true);
- hide(hDlg, IDC_SCSIROMFILEAUTOBOOT, 0);
- if (romtype & ROMTYPE_NOT) {
- hide(hDlg, IDC_SCSIROMCHOOSER, 1);
- hide(hDlg, IDC_SCSIROMFILE, 1);
- hide(hDlg, IDC_SCSIROMSELECTED, 0);
- setchecked(hDlg, IDC_SCSIROMSELECTED, brc && brc->roms[index].romfile[0] != 0);
- } else {
- hide(hDlg, IDC_SCSIROMCHOOSER, 0);
- hide(hDlg, IDC_SCSIROMFILE, 0);
- hide(hDlg, IDC_SCSIROMSELECTED, 1);
- setchecked(hDlg, IDC_SCSIROMSELECTED, false);
- addromfiles(fkey, hDlg, IDC_SCSIROMFILE, brc ? brc->roms[index].romfile : NULL, romtype, romtype_extra);
- setchecked(hDlg, IDC_SCSIROMFILEAUTOBOOT, brc && brc->roms[index].autoboot_disabled);
- }
- if (deviceflags & EXPANSIONTYPE_PCMCIA) {
- setchecked(hDlg, IDC_SCSIROMFILEPCMCIA, brc && brc->roms[index].inserted);
- hide(hDlg, IDC_SCSIROMFILEPCMCIA, 0);
- } else {
- hide(hDlg, IDC_SCSIROMFILEPCMCIA, 1);
- if (brc)
- brc->roms[index].inserted = false;
- }
- hide(hDlg, IDC_SCSIROM24BITDMA, (deviceflags & EXPANSIONTYPE_DMA24) == 0);
- ew(hDlg, IDC_SCSIROM24BITDMA, (deviceflags & EXPANSIONTYPE_DMA24) != 0);
- setchecked(hDlg, IDC_SCSIROM24BITDMA, brc && brc->roms[index].dma24bit);
- } else {
- hide(hDlg, IDC_SCSIROMCHOOSER, 0);
- hide(hDlg, IDC_SCSIROMFILE, 0);
- hide(hDlg, IDC_SCSIROMSELECTED, 1);
- hide(hDlg, IDC_SCSIROMFILEPCMCIA, 1);
- hide(hDlg, IDC_SCSIROMFILEAUTOBOOT, 1);
- setchecked(hDlg, IDC_SCSIROMSELECTED, false);
- setchecked(hDlg, IDC_SCSIROMFILEAUTOBOOT, false);
- setchecked(hDlg, IDC_SCSIROMFILEPCMCIA, false);
- SendDlgItemMessage(hDlg, IDC_SCSIROMFILE, CB_RESETCONTENT, 0, 0);
- ew(hDlg, IDC_SCSIROMFILE, false);
- ew(hDlg, IDC_SCSIROMCHOOSER, false);
- ew(hDlg, IDC_SCSIROM24BITDMA, 0);
- hide(hDlg, IDC_SCSIROM24BITDMA, 1);
- }
- if (keyallocated)
- regclosetree(fkey);
- }
- #if 0
- static void createautoconfiginfo(struct autoconfig_info *aci, TCHAR *buf)
- {
- TCHAR tmp2[200];
- if (aci->autoconfig[0] == 0xff) {
- buf[0] = 0;
- return;
- }
- if (aci->start != 0xffffffff)
- _stprintf(tmp2, _T("0x%08x-0x%08x"), aci->start, aci->start + aci->size - 1);
- else
- _tcscpy(tmp2, _T("--------"));
- _stprintf(buf, _T("%u/%u [0x%04x/0x%02x] %s "),
- (aci->autoconfig[4] << 8) | aci->autoconfig[5], aci->autoconfig[1],
- (aci->autoconfig[4] << 8) | aci->autoconfig[5], aci->autoconfig[1],
- tmp2
- );
- TCHAR *p = buf + _tcslen(buf);
- for (int i = 0; i < 12; i++) {
- if (i > 0)
- _tcscat(p, _T("."));
- _stprintf(p + _tcslen(p), _T("%02x"), aci->autoconfig[i]);
- }
- }
- #endif
- static void values_to_expansion2_expansion_settings(HWND hDlg, int mode)
- {
- int index;
- struct boardromconfig *brc;
- if (scsiromselected) {
- const struct expansionromtype *ert = &expansionroms[scsiromselected];
- brc = get_device_rom(&workprefs, expansionroms[scsiromselected].romtype, scsiromselectednum, &index);
- if (brc) {
- if (brc->roms[index].romfile[0])
- ew(hDlg, IDC_SCSIROMFILEAUTOBOOT, ert->autoboot_jumper);
- } else {
- ew(hDlg, IDC_SCSIROMFILEAUTOBOOT, FALSE);
- setchecked(hDlg, IDC_SCSIROMFILEAUTOBOOT, false);
- }
- ew(hDlg, IDC_SCSIROMID, ert->id_jumper);
- const struct expansionboardsettings *cbs = ert->settings;
- create_expansionrom_gui(hDlg, &expansion_gui_item, cbs,
- brc ? brc->roms[index].device_settings : 0,
- brc ? brc->roms[index].configtext : NULL,
- IDC_EXPANSIONBOARDITEMSELECTOR, IDC_EXPANSIONBOARDSELECTOR, IDC_EXPANSIONBOARDCHECKBOX, IDC_EXPANSIONBOARDSTRINGBOX);
- } else {
- reset_expansionrom_gui(hDlg, &expansion_gui_item,
- IDC_EXPANSIONBOARDITEMSELECTOR, IDC_EXPANSIONBOARDSELECTOR, IDC_EXPANSIONBOARDCHECKBOX, IDC_EXPANSIONBOARDSTRINGBOX);
- }
- #if 0
- for (int i = 0; expansion_settings_id[i] >= 0; i++) {
- hide(hDlg, expansion_settings_id[i], !(cbs && cbs[i].name));
- }
- int i = 0;
- if (cbs) {
- for (i = 0; cbs[i].name; i++) {
- int id = expansion_settings_id[i];
- if (id < 0)
- break;
- SetWindowText(GetDlgItem(hDlg, id), cbs[i].name);
- setchecked(hDlg, id, (brc && (brc->roms[index].device_settings & (1 << i))));
- }
- }
- while (expansion_settings_id[i] >= 0) {
- int id = expansion_settings_id[i];
- SetWindowText(GetDlgItem(hDlg, id), _T("-"));
- hide(hDlg, id, true);
- i++;
- }
- #endif
- }
- static void enable_for_expansion2dlg (HWND hDlg)
- {
- int z3 = true;
- int cw, en;
- en = !!full_property_sheet;
- cw = catweasel_detect ();
- ew(hDlg, IDC_CATWEASEL, cw && en);
- ew(hDlg, IDC_SOCKETS, en);
- ew(hDlg, IDC_SCSIDEVICE, en);
- ew(hDlg, IDC_CATWEASEL, en);
- ew(hDlg, IDC_SANA2, en);
- ew(hDlg, IDC_CS_CD32FMV, en);
- ew(hDlg, IDC_CPUBOARDROMFILE, workprefs.cpuboard_type != 0);
- ew(hDlg, IDC_CPUBOARDROMCHOOSER, workprefs.cpuboard_type != 0);
- ew(hDlg, IDC_CPUBOARDMEM, workprefs.cpuboard_type > 0);
- ew(hDlg, IDC_CPUBOARDRAM, workprefs.cpuboard_type > 0);
- ew(hDlg, IDC_CPUBOARD_SUBTYPE, workprefs.cpuboard_type);
- #if 0
- const struct expansionboardsettings *cbs = cpuboards[workprefs.cpuboard_type].subtypes[workprefs.cpuboard_subtype].settings;
- int i = 0;
- if (cbs) {
- while (cpuboard_settings_id[i] >= 0) {
- if (!cbs[i].name)
- break;
- hide(hDlg, cpuboard_settings_id[i], 0);
- i++;
- }
- }
- while (cpuboard_settings_id[i] >= 0) {
- hide(hDlg, cpuboard_settings_id[i], 1);
- i++;
- }
- #endif
- }
- static void values_to_expansion2dlg (HWND hDlg, int mode)
- {
- int cw;
- int index;
- struct boardromconfig *brc;
- CheckDlgButton(hDlg, IDC_SOCKETS, workprefs.socket_emu);
- CheckDlgButton(hDlg, IDC_CATWEASEL, workprefs.catweasel);
- CheckDlgButton(hDlg, IDC_SCSIDEVICE, workprefs.scsi == 1);
- CheckDlgButton(hDlg, IDC_SANA2, workprefs.sana2);
- CheckDlgButton(hDlg, IDC_CS_CD32FMV, workprefs.cs_cd32fmv);
- cw = catweasel_detect ();
- ew (hDlg, IDC_CATWEASEL, cw);
- if (!cw && workprefs.catweasel < 100)
- workprefs.catweasel = 0;
- UAEREG *fkey = regcreatetree(NULL, _T("DetectedROMs"));
- load_keyring(&workprefs, NULL);
- values_to_expansion2_expansion_roms(hDlg, fkey);
- values_to_expansion2_expansion_settings(hDlg, mode);
- if (workprefs.cpuboard_type) {
- const struct cpuboardsubtype *cst = &cpuboards[workprefs.cpuboard_type].subtypes[workprefs.cpuboard_subtype];
- brc = get_device_rom(&workprefs, ROMTYPE_CPUBOARD, 0, &index);
- addromfiles(fkey, hDlg, IDC_CPUBOARDROMFILE, brc ? brc->roms[index].romfile : NULL,
- cst->romtype, cst->romtype_extra);
- } else {
- SendDlgItemMessage(hDlg, IDC_CPUBOARDROMFILE, CB_RESETCONTENT, 0, 0);
- }
- regclosetree(fkey);
- gui_set_string_cursor(scsiromselect_table, hDlg, IDC_SCSIROMSELECT, scsiromselected);
- values_to_expansion2dlg_sub(hDlg);
- }
- static void updatecpuboardsubtypes(HWND hDlg)
- {
- SendDlgItemMessage(hDlg, IDC_CPUBOARD_SUBTYPE, CB_RESETCONTENT, 0, 0);
- for (int i = 0; cpuboards[workprefs.cpuboard_type].subtypes[i].name; i++) {
- SendDlgItemMessage(hDlg, IDC_CPUBOARD_SUBTYPE, CB_ADDSTRING, 0, (LPARAM) cpuboards[workprefs.cpuboard_type].subtypes[i].name);
- }
- const struct expansionboardsettings *cbs = cpuboards[workprefs.cpuboard_type].subtypes[workprefs.cpuboard_subtype].settings;
- create_expansionrom_gui(hDlg, &accelerator_gui_item, cbs, workprefs.cpuboard_settings, NULL,
- IDC_ACCELERATORBOARDITEMSELECTOR, IDC_ACCELERATORBOARDSELECTOR, IDC_ACCELERATORBOARDCHECKBOX, -1);
- #if 0
- int i = 0;
- if (cbs) {
- for (i = 0; cbs[i].name; i++) {
- int id = cpuboard_settings_id[i];
- if (id < 0)
- break;
- SetWindowText(GetDlgItem(hDlg, id), cbs[i].name);
- }
- }
- while (cpuboard_settings_id[i] >= 0) {
- int id = cpuboard_settings_id[i];
- SetWindowText(GetDlgItem(hDlg, id), _T("-"));
- i++;
- }
- #endif
- }
- static int gui_rtg_index;
- static void expansion2filebuttons(HWND hDlg, WPARAM wParam, TCHAR *path)
- {
- switch (LOWORD(wParam))
- {
- case IDC_SCSIROMCHOOSER:
- DiskSelection(hDlg, IDC_SCSIROMFILE, 6, &workprefs, NULL, path);
- values_to_expansion2dlg(hDlg, 1);
- break;
- case IDC_CPUBOARDROMCHOOSER:
- DiskSelection(hDlg, IDC_CPUBOARDROMFILE, 6, &workprefs, NULL, path);
- values_to_expansion2dlg(hDlg, 2);
- break;
- }
- }
- static INT_PTR CALLBACK Expansion2DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- int v, val;
- TCHAR tmp[MAX_DPATH];
- static int recursive = 0;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- recursive++;
- pages[EXPANSION2_ID] = hDlg;
- currentpage = EXPANSION2_ID;
- int ids[] = { IDC_SCSIROMFILE, IDC_CPUBOARDROMFILE, -1 };
- setmultiautocomplete(hDlg, ids);
- if (!net_enumerated) {
- target_ethernet_enumerate();
- for (int i = 0; ndd[i]; i++) {
- struct netdriverdata *n = ndd[i];
- if (!n->active)
- continue;
- if (n->type == UAENET_SLIRP) {
- WIN32GUI_LoadUIString(IDS_SLIRP, tmp, sizeof tmp / sizeof(TCHAR));
- n->desc = my_strdup(tmp);
- }
- else if (n->type == UAENET_SLIRP_INBOUND) {
- WIN32GUI_LoadUIString(IDS_SLIRP_INBOUND, tmp, sizeof tmp / sizeof(TCHAR));
- n->desc = my_strdup(tmp);
- }
- }
- ethernet_updateselection();
- net_enumerated = 1;
- }
- SendDlgItemMessage(hDlg, IDC_CPUBOARD_TYPE, CB_RESETCONTENT, 0, 0);
- for (int i = 0; cpuboards[i].name; i++) {
- SendDlgItemMessage(hDlg, IDC_CPUBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM) cpuboards[i].name);
- }
- WIN32GUI_LoadUIString(IDS_EXPANSION_CATEGORY, tmp, sizeof tmp / sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTCAT, CB_RESETCONTENT, 0, 0);
- _tcscat(tmp, _T("\n"));
- TCHAR *p1 = tmp;
- for (;;) {
- TCHAR *p2 = _tcschr(p1, '\n');
- if (p2 && _tcslen(p2) > 0) {
- *p2++ = 0;
- SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTCAT, CB_ADDSTRING, 0, (LPARAM)p1);
- p1 = p2;
- } else
- break;
- }
- reset_expansionrom_gui(hDlg, &expansion_gui_item, IDC_EXPANSIONBOARDITEMSELECTOR, IDC_EXPANSIONBOARDSELECTOR, IDC_EXPANSIONBOARDCHECKBOX, IDC_EXPANSIONBOARDSTRINGBOX);
- reset_expansionrom_gui(hDlg, &accelerator_gui_item, IDC_ACCELERATORBOARDITEMSELECTOR, IDC_ACCELERATORBOARDSELECTOR, IDC_ACCELERATORBOARDCHECKBOX, -1);
- hide(hDlg, IDC_SCSIROMSELECTED, 1);
- init_expansion2(hDlg, true);
- updatecpuboardsubtypes(hDlg);
- setcpuboardmemsize(hDlg);
- recursive--;
- }
- case WM_USER:
- recursive++;
- values_to_expansion2dlg(hDlg, 0);
- enable_for_expansion2dlg(hDlg);
- recursive--;
- break;
- case WM_COMMAND:
- {
- if (recursive > 0)
- break;
- recursive++;
- switch (LOWORD(wParam))
- {
- case IDC_EXPANSIONBOARDSTRINGBOX:
- get_expansionrom_gui(hDlg, &expansion_gui_item);
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_EXPANSIONBOARDCHECKBOX:
- get_expansionrom_gui(hDlg, &expansion_gui_item);
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_ACCELERATORBOARDCHECKBOX:
- get_expansionrom_gui(hDlg, &accelerator_gui_item);
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_SCSIROMFILEAUTOBOOT:
- case IDC_SCSIROMFILEPCMCIA:
- case IDC_SCSIROM24BITDMA:
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_SOCKETS:
- workprefs.socket_emu = ischecked(hDlg, IDC_SOCKETS);
- break;
- case IDC_SCSIDEVICE:
- workprefs.scsi = ischecked(hDlg, IDC_SCSIDEVICE);
- enable_for_expansion2dlg(hDlg);
- break;
- case IDC_SANA2:
- workprefs.sana2 = ischecked(hDlg, IDC_SANA2);
- break;
- case IDC_CATWEASEL:
- workprefs.catweasel = ischecked(hDlg, IDC_CATWEASEL) ? -1 : 0;
- cfgfile_compatibility_romtype(&workprefs);
- break;
- case IDC_CS_CD32FMV:
- workprefs.cs_cd32fmv = ischecked(hDlg, IDC_CS_CD32FMV) ? 1 : 0;
- cfgfile_compatibility_romtype(&workprefs);
- break;
- case IDC_SCSIROMSELECTED:
- values_from_expansion2dlg(hDlg);
- values_to_expansion2_expansion_settings(hDlg, 1);
- break;
- }
- expansion2filebuttons(hDlg, wParam, NULL);
- if (HIWORD(wParam) == CBN_SELENDOK || HIWORD(wParam) == CBN_KILLFOCUS || HIWORD(wParam) == CBN_EDITCHANGE) {
- switch (LOWORD(wParam))
- {
- case IDC_EXPANSIONBOARDITEMSELECTOR:
- case IDC_EXPANSIONBOARDSELECTOR:
- get_expansionrom_gui(hDlg, &expansion_gui_item);
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_ACCELERATORBOARDITEMSELECTOR:
- case IDC_ACCELERATORBOARDSELECTOR:
- get_expansionrom_gui(hDlg, &accelerator_gui_item);
- values_from_expansion2dlg(hDlg);
- break;
- case IDC_SCSIROMFILE:
- case IDC_SCSIROMID:
- values_from_expansion2dlg(hDlg);
- values_to_expansion2_expansion_settings(hDlg, 1);
- break;
- case IDC_CPUBOARDROMFILE:
- case IDC_CPUBOARDROMSUBSELECT:
- values_from_expansion2dlg(hDlg);
- values_to_expansion2_expansion_settings(hDlg, 2);
- break;
- case IDC_SCSIROMSUBSELECT:
- values_from_expansion2dlg(hDlg);
- values_to_expansion2_expansion_roms(hDlg, NULL);
- values_to_expansion2_expansion_settings(hDlg, 1);
- break;
- case IDC_SCSIROMSELECTCAT:
- val = SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTCAT, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR && val != scsiromselectedcatnum) {
- scsiromselectedcatnum = val;
- scsiromselected = 0;
- init_expansion2(hDlg, false);
- values_to_expansion2_expansion_roms(hDlg, NULL);
- values_to_expansion2_expansion_settings(hDlg, 1);
- values_to_expansion2dlg_sub(hDlg);
- }
- break;
- case IDC_SCSIROMSELECTNUM:
- case IDC_SCSIROMSELECT:
- val = SendDlgItemMessage(hDlg, IDC_SCSIROMSELECTNUM, CB_GETCURSEL, 0, 0);
- if (val != CB_ERR)
- scsiromselectednum = val;
- val = gui_get_string_cursor(scsiromselect_table, hDlg, IDC_SCSIROMSELECT);
- if (val != CB_ERR) {
- scsiromselected = val;
- values_to_expansion2_expansion_roms(hDlg, NULL);
- values_to_expansion2_expansion_settings(hDlg, 1);
- values_to_expansion2dlg_sub(hDlg);
- }
- break;
- case IDC_CPUBOARD_TYPE:
- v = SendDlgItemMessage(hDlg, IDC_CPUBOARD_TYPE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR && v != workprefs.cpuboard_type) {
- workprefs.cpuboard_type = v;
- workprefs.cpuboard_subtype = 0;
- workprefs.cpuboard_settings = 0;
- updatecpuboardsubtypes(hDlg);
- if (is_ppc_cpu(&workprefs)) {
- workprefs.ppc_mode = 2;
- } else if (workprefs.ppc_mode == 2) {
- workprefs.ppc_mode = 0;
- }
- cpuboard_set_cpu(&workprefs);
- setcpuboardmemsize(hDlg);
- enable_for_expansion2dlg(hDlg);
- values_to_expansion2dlg(hDlg, 2);
- }
- break;
- case IDC_CPUBOARD_SUBTYPE:
- v = SendDlgItemMessage(hDlg, IDC_CPUBOARD_SUBTYPE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR && v != workprefs.cpuboard_subtype) {
- workprefs.cpuboard_subtype = v;
- workprefs.cpuboard_settings = 0;
- updatecpuboardsubtypes(hDlg);
- if (is_ppc_cpu(&workprefs)) {
- workprefs.ppc_mode = 2;
- } else if (workprefs.ppc_mode == 2) {
- workprefs.ppc_mode = 0;
- }
- cpuboard_set_cpu(&workprefs);
- setcpuboardmemsize(hDlg);
- enable_for_expansion2dlg(hDlg);
- values_to_expansion2dlg(hDlg, 2);
- }
- break;
- }
- }
- #if 0
- for (int i = 0; cpuboard_settings_id[i] >= 0; i++) {
- workprefs.cpuboard_settings &= ~(1 << i);
- if (ischecked(hDlg, cpuboard_settings_id[i]))
- workprefs.cpuboard_settings |= 1 << i;
- }
- #endif
- recursive--;
- }
- break;
- case WM_HSCROLL:
- if (recursive > 0)
- break;
- recursive++;
- workprefs.cpuboardmem1.size = memsizes[msi_cpuboard[SendMessage(GetDlgItem(hDlg, IDC_CPUBOARDMEM), TBM_GETPOS, 0, 0)]];
- setcpuboardmemsize(hDlg);
- recursive--;
- break;
- }
- return FALSE;
- }
- static void enable_for_expansiondlg(HWND hDlg)
- {
- int z3 = true;
- int en;
- en = !!full_property_sheet;
- int rtg = workprefs.rtgboards[gui_rtg_index].rtgmem_size && full_property_sheet && workprefs.rtgboards[gui_rtg_index].rtgmem_type < GFXBOARD_HARDWARE;
- int rtg2 = workprefs.rtgboards[gui_rtg_index].rtgmem_size || workprefs.rtgboards[gui_rtg_index].rtgmem_type >= GFXBOARD_HARDWARE;
- int rtg3 = workprefs.rtgboards[gui_rtg_index].rtgmem_size && workprefs.rtgboards[gui_rtg_index].rtgmem_type < GFXBOARD_HARDWARE;
- int rtg4 = workprefs.rtgboards[gui_rtg_index].rtgmem_type < GFXBOARD_HARDWARE;
- int rtg5 = workprefs.rtgboards[gui_rtg_index].rtgmem_size && full_property_sheet;
- int rtg0 = rtg2;
- if (gui_rtg_index > 0) {
- rtg = false;
- rtg2 = false;
- rtg3 = false;
- }
- ew(hDlg, IDC_P96RAM, rtg0);
- ew(hDlg, IDC_P96MEM, rtg0);
- ew(hDlg, IDC_RTG_Z2Z3, z3);
- ew(hDlg, IDC_MONITOREMU_MON, rtg5);
- ew(hDlg, IDC_RTG_8BIT, rtg);
- ew(hDlg, IDC_RTG_16BIT, rtg);
- ew(hDlg, IDC_RTG_24BIT, rtg);
- ew(hDlg, IDC_RTG_32BIT, rtg);
- ew(hDlg, IDC_RTG_MATCH_DEPTH, rtg3);
- ew(hDlg, IDC_RTG_SCALE, rtg2);
- ew(hDlg, IDC_RTG_CENTER, rtg2);
- ew(hDlg, IDC_RTG_SCALE_ALLOW, rtg2);
- ew(hDlg, IDC_RTG_SCALE_ASPECTRATIO, rtg2);
- ew(hDlg, IDC_RTG_VBLANKRATE, rtg2);
- ew(hDlg, IDC_RTG_BUFFERCNT, rtg2);
- ew(hDlg, IDC_RTG_DISPLAYSELECT, rtg2);
- ew(hDlg, IDC_RTG_VBINTERRUPT, rtg3);
- ew(hDlg, IDC_RTG_THREAD, rtg3 && en);
- if (!workprefs.gfx_api) {
- workprefs.rtg_hardwaresprite = false;
- CheckDlgButton(hDlg, IDC_RTG_HWSPRITE, FALSE);
- }
- ew(hDlg, IDC_RTG_HWSPRITE, rtg3 && workprefs.gfx_api);
- }
- static void values_to_expansiondlg(HWND hDlg)
- {
- SendDlgItemMessage(hDlg, IDC_RTG_BUFFERCNT, CB_SETCURSEL, workprefs.gfx_apmode[1].gfx_backbuffers == 0 ? 0 : workprefs.gfx_apmode[1].gfx_backbuffers - 1, 0);
- int min_mem = MIN_P96_MEM;
- int max_mem = MAX_P96_MEM_Z3;
- struct rtgboardconfig *rbc = &workprefs.rtgboards[gui_rtg_index];
- if (gfxboard_get_configtype(rbc) == 2) {
- int v = rbc->rtgmem_size;
- max_mem = MAX_P96_MEM_Z2;
- rbc->rtgmem_size = 1024 * 1024;
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v > gfxboard_get_vram_max(rbc))
- v = gfxboard_get_vram_max(rbc);
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v < gfxboard_get_vram_min(rbc))
- v = gfxboard_get_vram_min(rbc);
- rbc->rtgmem_size = v;
- } else if (gfxboard_get_configtype(rbc) == 3) {
- int v = rbc->rtgmem_size;
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v > gfxboard_get_vram_max(rbc))
- v = gfxboard_get_vram_max(rbc);
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v < gfxboard_get_vram_min(rbc))
- v = gfxboard_get_vram_min(rbc);
- rbc->rtgmem_size = v;
- } else {
- int v = rbc->rtgmem_size;
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v > gfxboard_get_vram_max(rbc))
- v = gfxboard_get_vram_max(rbc);
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE && v < gfxboard_get_vram_min(rbc))
- v = gfxboard_get_vram_min(rbc);
- rbc->rtgmem_size = v;
- }
- if (rbc->rtgmem_type >= GFXBOARD_HARDWARE) {
- switch (gfxboard_get_vram_min(rbc)) {
- case 0x00100000: min_mem = 1; break;
- case 0x00200000: min_mem = 2; break;
- case 0x00400000: min_mem = 3; break;
- }
- switch (gfxboard_get_vram_max(rbc)) {
- case 0x00100000: max_mem = 1; break;
- case 0x00200000: max_mem = 2; break;
- case 0x00400000: max_mem = 3; break;
- }
- }
- SendDlgItemMessage(hDlg, IDC_P96MEM, TBM_SETRANGE, TRUE, MAKELONG(min_mem, max_mem));
- int mem_size = 0;
- switch (rbc->rtgmem_size) {
- case 0x00000000: mem_size = 0; break;
- case 0x00100000: mem_size = 1; break;
- case 0x00200000: mem_size = 2; break;
- case 0x00400000: mem_size = 3; break;
- case 0x00800000: mem_size = 4; break;
- case 0x01000000: mem_size = 5; break;
- case 0x02000000: mem_size = 6; break;
- case 0x04000000: mem_size = 7; break;
- case 0x08000000: mem_size = 8; break;
- case 0x10000000: mem_size = 9; break;
- case 0x20000000: mem_size = 10; break;
- case 0x40000000: mem_size = 11; break;
- }
- SendDlgItemMessage(hDlg, IDC_P96MEM, TBM_SETPOS, TRUE, mem_size);
- SetDlgItemText(hDlg, IDC_P96RAM, memsize_names[msi_gfx[mem_size]]);
- SendDlgItemMessage(hDlg, IDC_RTG_Z2Z3, CB_SETCURSEL, rbc->rtgmem_size == 0 ? 0 : gfxboard_get_index_from_id(rbc->rtgmem_type) + 1, 0);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_SETCURSEL, rbc->monitor_id, 0);
- SendDlgItemMessage(hDlg, IDC_RTG_NUM, CB_SETCURSEL, gui_rtg_index, 0);
- SendDlgItemMessage(hDlg, IDC_RTG_8BIT, CB_SETCURSEL, (workprefs.picasso96_modeflags & RGBFF_CLUT) ? 1 : 0, 0);
- SendDlgItemMessage(hDlg, IDC_RTG_16BIT, CB_SETCURSEL,
- (manybits(workprefs.picasso96_modeflags, RGBFF_R5G6B5PC | RGBFF_R5G6B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC)) ? 1 :
- (workprefs.picasso96_modeflags & RGBFF_R5G6B5PC) ? 2 :
- (workprefs.picasso96_modeflags & RGBFF_R5G5B5PC) ? 3 :
- (workprefs.picasso96_modeflags & RGBFF_R5G6B5) ? 4 :
- (workprefs.picasso96_modeflags & RGBFF_R5G5B5) ? 5 :
- (workprefs.picasso96_modeflags & RGBFF_B5G6R5PC) ? 6 :
- (workprefs.picasso96_modeflags & RGBFF_B5G5R5PC) ? 7 : 0, 0);
- SendDlgItemMessage(hDlg, IDC_RTG_24BIT, CB_SETCURSEL,
- (manybits(workprefs.picasso96_modeflags, RGBFF_R8G8B8 | RGBFF_B8G8R8)) ? 1 :
- (workprefs.picasso96_modeflags & RGBFF_R8G8B8) ? 2 :
- (workprefs.picasso96_modeflags & RGBFF_B8G8R8) ? 3 : 0, 0);
- SendDlgItemMessage(hDlg, IDC_RTG_32BIT, CB_SETCURSEL,
- (manybits(workprefs.picasso96_modeflags, RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8)) ? 1 :
- (workprefs.picasso96_modeflags & RGBFF_A8R8G8B8) ? 2 :
- (workprefs.picasso96_modeflags & RGBFF_A8B8G8R8) ? 3 :
- (workprefs.picasso96_modeflags & RGBFF_R8G8B8A8) ? 4 :
- (workprefs.picasso96_modeflags & RGBFF_B8G8R8A8) ? 5 : 0, 0);
- if (workprefs.win32_rtgvblankrate <= 0 ||
- workprefs.win32_rtgvblankrate == 50 ||
- workprefs.win32_rtgvblankrate == 60 ||
- workprefs.win32_rtgvblankrate == 70 ||
- workprefs.win32_rtgvblankrate == 75) {
- SendDlgItemMessage(hDlg, IDC_RTG_VBLANKRATE, CB_SETCURSEL,
- (workprefs.win32_rtgvblankrate == 0) ? 0 :
- (workprefs.win32_rtgvblankrate == -1) ? 1 :
- (workprefs.win32_rtgvblankrate == -2) ? 0 :
- (workprefs.win32_rtgvblankrate == 50) ? 2 :
- (workprefs.win32_rtgvblankrate == 60) ? 3 :
- (workprefs.win32_rtgvblankrate == 70) ? 4 :
- (workprefs.win32_rtgvblankrate == 75) ? 5 : 0, 0);
- } else {
- TCHAR tmp[10];
- _stprintf(tmp, _T("%d"), workprefs.win32_rtgvblankrate);
- SendDlgItemMessage(hDlg, IDC_RTG_VBLANKRATE, WM_SETTEXT, 0, (LPARAM) tmp);
- }
- CheckDlgButton(hDlg, IDC_RTG_SCALE, workprefs.gf[1].gfx_filter_autoscale == RTG_MODE_SCALE);
- CheckDlgButton(hDlg, IDC_RTG_CENTER, workprefs.gf[1].gfx_filter_autoscale == RTG_MODE_CENTER);
- CheckDlgButton(hDlg, IDC_RTG_SCALE_ALLOW, workprefs.win32_rtgallowscaling);
- CheckDlgButton(hDlg, IDC_RTG_MATCH_DEPTH, workprefs.win32_rtgmatchdepth);
- CheckDlgButton(hDlg, IDC_RTG_VBINTERRUPT, workprefs.rtg_hardwareinterrupt);
- CheckDlgButton(hDlg, IDC_RTG_HWSPRITE, workprefs.rtg_hardwaresprite);
- CheckDlgButton(hDlg, IDC_RTG_THREAD, workprefs.rtg_multithread);
- SendDlgItemMessage(hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_SETCURSEL,
- (workprefs.win32_rtgscaleaspectratio == 0) ? 0 :
- (workprefs.win32_rtgscaleaspectratio < 0) ? 1 :
- getaspectratioindex(workprefs.win32_rtgscaleaspectratio) + 2, 0);
- }
- static INT_PTR CALLBACK ExpansionDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- int v;
- TCHAR tmp[256];
- static int recursive = 0;
- static int enumerated;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- pages[EXPANSION_ID] = hDlg;
- currentpage = EXPANSION_ID;
- init_displays_combo (hDlg, true);
-
- SendDlgItemMessage(hDlg, IDC_RTG_NUM, CB_RESETCONTENT, 0, 0);
- for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- _stprintf(tmp, _T("%d"), i + 1);
- SendDlgItemMessage(hDlg, IDC_RTG_NUM, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_RESETCONTENT, 0, 0);
- for (int i = 0; i < MAX_AMIGAMONITORS; i++) {
- _stprintf(tmp, _T("%d"), i + 1);
- SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- SendDlgItemMessage (hDlg, IDC_RTG_Z2Z3, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_Z2Z3, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- v = 0;
- for (;;) {
- int index = gfxboard_get_id_from_index(v);
- if (index < 0)
- break;
- const TCHAR *n1 = gfxboard_get_name(index);
- const TCHAR *n2 = gfxboard_get_manufacturername(index);
- v++;
- _tcscpy(tmp, n1);
- if (n2) {
- _tcscat(tmp, _T(" ("));
- _tcscat(tmp, n2);
- _tcscat(tmp, _T(")"));
- }
- SendDlgItemMessage (hDlg, IDC_RTG_Z2Z3, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- WIN32GUI_LoadUIString(IDS_ALL, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)_T("(8bit)"));
- SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)_T("8-bit (*)"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("(15/16bit)"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("R5G6B5PC (*)"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("R5G5B5PC"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("R5G6B5"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("R5G5B5"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("B5G6R5PC"));
- SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)_T("B5G5R5PC"));
- SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)_T("(24bit)"));
- SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)_T("R8G8B8"));
- SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)_T("B8G8R8"));
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)_T("(32bit)"));
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)_T("A8R8G8B8"));
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)_T("A8B8G8R8"));
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)_T("R8G8B8A8"));
- SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)_T("B8G8R8A8 (*)"));
- SendDlgItemMessage (hDlg, IDC_P96MEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_P96_MEM, gfxboard_get_configtype(&workprefs.rtgboards[gui_rtg_index]) == 3 ? MAX_P96_MEM_Z3 : MAX_P96_MEM_Z2));
- SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)tmp);
- WIN32GUI_LoadUIString (IDS_AUTOMATIC, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)tmp);
- addaspectratios (hDlg, IDC_RTG_SCALE_ASPECTRATIO);
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("Chipset"));
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("Default"));
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("50"));
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("60"));
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("70"));
- SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)_T("75"));
- SendDlgItemMessage(hDlg, IDC_RTG_BUFFERCNT, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString(IDS_BUFFER_DOUBLE, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_RTG_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)tmp);
- WIN32GUI_LoadUIString(IDS_BUFFER_TRIPLE, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage(hDlg, IDC_RTG_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)tmp);
- case WM_USER:
- recursive++;
- values_to_expansiondlg (hDlg);
- enable_for_expansiondlg (hDlg);
- recursive--;
- break;
- case WM_HSCROLL:
- workprefs.rtgboards[gui_rtg_index].rtgmem_size = memsizes[msi_gfx[SendMessage (GetDlgItem (hDlg, IDC_P96MEM), TBM_GETPOS, 0, 0)]];
- values_to_expansiondlg(hDlg);
- enable_for_expansiondlg(hDlg);
- break;
- case WM_COMMAND:
- {
- if (recursive > 0)
- break;
- recursive++;
- switch (LOWORD (wParam))
- {
- case IDC_RTG_MATCH_DEPTH:
- workprefs.win32_rtgmatchdepth = ischecked (hDlg, IDC_RTG_MATCH_DEPTH);
- break;
- case IDC_RTG_SCALE:
- workprefs.gf[1].gfx_filter_autoscale = ischecked(hDlg, IDC_RTG_SCALE) ? RTG_MODE_SCALE : 0;
- setchecked (hDlg, IDC_RTG_CENTER, false);
- break;
- case IDC_RTG_CENTER:
- workprefs.gf[1].gfx_filter_autoscale = ischecked(hDlg, IDC_RTG_CENTER) ? RTG_MODE_CENTER : 0;
- setchecked (hDlg, IDC_RTG_SCALE, false);
- break;
- case IDC_RTG_SCALE_ALLOW:
- workprefs.win32_rtgallowscaling = ischecked (hDlg, IDC_RTG_SCALE_ALLOW);
- break;
- case IDC_RTG_VBINTERRUPT:
- workprefs.rtg_hardwareinterrupt = ischecked (hDlg, IDC_RTG_VBINTERRUPT);
- break;
- case IDC_RTG_HWSPRITE:
- workprefs.rtg_hardwaresprite = ischecked(hDlg, IDC_RTG_HWSPRITE);
- break;
- case IDC_RTG_THREAD:
- workprefs.rtg_multithread = ischecked(hDlg, IDC_RTG_THREAD);
- break;
- }
- if (HIWORD (wParam) == CBN_SELENDOK || HIWORD (wParam) == CBN_KILLFOCUS || HIWORD (wParam) == CBN_EDITCHANGE) {
- uae_u32 mask = workprefs.picasso96_modeflags;
- switch (LOWORD (wParam))
- {
- case IDC_RTG_DISPLAYSELECT:
- get_displays_combo (hDlg, true);
- break;
- case IDC_RTG_BUFFERCNT:
- v = SendDlgItemMessage (hDlg, IDC_RTG_BUFFERCNT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- v++;
- workprefs.gfx_apmode[1].gfx_backbuffers = v;
- }
- break;
- case IDC_RTG_SCALE_ASPECTRATIO:
- v = SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- if (v == 0)
- workprefs.win32_rtgscaleaspectratio = 0;
- else if (v == 1)
- workprefs.win32_rtgscaleaspectratio = -1;
- else if (v >= 2)
- workprefs.win32_rtgscaleaspectratio = getaspectratio (v - 2);
- }
- break;
- case IDC_RTG_NUM:
- v = SendDlgItemMessage(hDlg, IDC_RTG_NUM, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- gui_rtg_index = v;
- values_to_expansiondlg(hDlg);
- enable_for_expansiondlg(hDlg);
- }
- break;
- case IDC_MONITOREMU_MON:
- v = SendDlgItemMessage(hDlg, IDC_MONITOREMU_MON, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- workprefs.rtgboards[gui_rtg_index].monitor_id = v;
- values_to_expansiondlg(hDlg);
- }
- break;
- case IDC_RTG_Z2Z3:
- v = SendDlgItemMessage (hDlg, IDC_RTG_Z2Z3, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- if (v == 0) {
- workprefs.rtgboards[gui_rtg_index].rtgmem_type = 1;
- workprefs.rtgboards[gui_rtg_index].rtgmem_size = 0;
- } else {
- workprefs.rtgboards[gui_rtg_index].rtgmem_type = gfxboard_get_id_from_index(v - 1);
- if (workprefs.rtgboards[gui_rtg_index].rtgmem_size == 0)
- workprefs.rtgboards[gui_rtg_index].rtgmem_size = 4096 * 1024;
- }
- cfgfile_compatibility_rtg(&workprefs);
- enable_for_expansiondlg (hDlg);
- }
- break;
- case IDC_RTG_8BIT:
- v = SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- mask &= ~RGBFF_CLUT;
- if (v == 1)
- mask |= RGBFF_CLUT;
- }
- break;
- case IDC_RTG_16BIT:
- v = SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- mask &= ~(RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC);
- if (v == 1)
- mask |= RGBFF_R5G6B5PC | RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC;
- if (v == 2)
- mask |= RGBFF_R5G6B5PC;
- if (v == 3)
- mask |= RGBFF_R5G5B5PC;
- if (v == 4)
- mask |= RGBFF_R5G6B5;
- if (v == 5)
- mask |= RGBFF_R5G5B5;
- if (v == 6)
- mask |= RGBFF_B5G6R5PC;
- if (v == 7)
- mask |= RGBFF_B5G5R5PC;
- }
- break;
- case IDC_RTG_24BIT:
- v = SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- mask &= ~(RGBFF_R8G8B8 | RGBFF_B8G8R8);
- if (v == 1)
- mask |= RGBFF_R8G8B8 | RGBFF_B8G8R8;
- if (v == 2)
- mask |= RGBFF_R8G8B8;
- if (v == 3)
- mask |= RGBFF_B8G8R8;
- }
- break;
- case IDC_RTG_32BIT:
- v = SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- mask &= ~(RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8);
- if (v == 1)
- mask |= RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8;
- if (v == 2)
- mask |= RGBFF_A8R8G8B8;
- if (v == 3)
- mask |= RGBFF_A8B8G8R8;
- if (v == 4)
- mask |= RGBFF_R8G8B8A8;
- if (v == 5)
- mask |= RGBFF_B8G8R8A8;
- }
- break;
- case IDC_RTG_VBLANKRATE:
- tmp[0] = 0;
- v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- if (v == 0) {
- workprefs.win32_rtgvblankrate = 0;
- } else if (v == 1) {
- workprefs.win32_rtgvblankrate = -1;
- } else {
- v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_GETLBTEXT, (WPARAM)v, (LPARAM)tmp);
- }
- } else {
- v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, WM_GETTEXT, (WPARAM)sizeof tmp / sizeof (TCHAR), (LPARAM)tmp);
- }
- if (tmp[0])
- workprefs.win32_rtgvblankrate = _tstol (tmp);
- break;
- }
- workprefs.picasso96_modeflags = mask;
- values_to_expansiondlg (hDlg);
- }
- recursive--;
- }
- break;
- }
- return FALSE;
- }
- static LRESULT ProcesssBoardsDlgProcCustomDraw(LPARAM lParam)
- {
- }
- static void BoardsEnable(HWND hDlg, int selected)
- {
- bool move_up = expansion_can_move(&workprefs, selected);
- bool move_down = move_up;
- if (move_up) {
- if (expansion_autoconfig_move(&workprefs, selected, -1, true) < 0)
- move_up = false;
- }
- if (move_down) {
- if (expansion_autoconfig_move(&workprefs, selected, 1, true) < 0)
- move_down = false;
- }
- ew(hDlg, IDC_BOARDS_UP, move_up);
- ew(hDlg, IDC_BOARDS_DOWN, move_down);
- }
- static INT_PTR CALLBACK BoardsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- static int selected = -1;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- recursive++;
- pages[BOARD_ID] = hDlg;
- currentpage = BOARD_ID;
- setchecked(hDlg, IDC_AUTOCONFIGCUSTOMSORT, workprefs.autoconfig_custom_sort);
- ew(hDlg, IDC_BOARDLIST, workprefs.autoconfig_custom_sort != 0 && full_property_sheet);
- ew(hDlg, IDC_BOARDS_UP, FALSE);
- ew(hDlg, IDC_BOARDS_DOWN, FALSE);
- ew(hDlg, IDC_AUTOCONFIGCUSTOMSORT, full_property_sheet);
- InitializeListView(hDlg);
- recursive--;
- break;
- case WM_COMMAND:
- if (!recursive) {
- recursive++;
- switch (LOWORD(wParam))
- {
- case IDC_AUTOCONFIGCUSTOMSORT:
- workprefs.autoconfig_custom_sort = ischecked(hDlg, IDC_AUTOCONFIGCUSTOMSORT);
- expansion_set_autoconfig_sort(&workprefs);
- ew(hDlg, IDC_BOARDLIST, workprefs.autoconfig_custom_sort != 0);
- InitializeListView(hDlg);
- break;
- case IDC_BOARDS_UP:
- case IDC_BOARDS_DOWN:
- if (selected >= 0) {
- int newpos = expansion_autoconfig_move(&workprefs, selected, LOWORD(wParam) == IDC_BOARDS_UP ? -1 : 1, false);
- if (newpos >= 0) {
- selected = newpos;
- BoardsEnable(hDlg, selected);
- InitializeListView(hDlg);
- ListView_SetItemState(cachedlist, selected, LVIS_SELECTED, LVIS_SELECTED);
- }
- }
- break;
- }
- recursive--;
- }
- break;
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == IDC_BOARDLIST) {
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_CUSTOMDRAW:
- {
- LPNMLVCUSTOMDRAW lpNMLVCD = (LPNMLVCUSTOMDRAW)lParam;
- switch (lpNMLVCD->nmcd.dwDrawStage)
- {
- case CDDS_PREPAINT:
- case CDDS_ITEMPREPAINT:
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYSUBITEMDRAW);
- return TRUE;
- case CDDS_ITEMPREPAINT| CDDS_SUBITEM:
- {
- BOOL ret = FALSE;
- if (lpNMLVCD->nmcd.lItemlParam & 16) {
- lpNMLVCD->clrText = GetSysColor(COLOR_GRAYTEXT);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- ret = TRUE;
- }
- if (lpNMLVCD->nmcd.lItemlParam & 8) {
- lpNMLVCD->clrTextBk = RGB(0xaa, 0x00, 0x00);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- return TRUE;
- }
- if (lpNMLVCD->nmcd.lItemlParam & 4) {
- lpNMLVCD->clrTextBk = RGB(0xaa, 0xaa, 0x00);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- return TRUE;
- }
- if (lpNMLVCD->nmcd.lItemlParam & 2) {
- lpNMLVCD->clrTextBk = GetSysColor(COLOR_INACTIVECAPTION);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT);
- return TRUE;
- }
- return ret;
- }
- }
- }
- return CDRF_DODEFAULT;
- case NM_CLICK:
- {
- int column;
- NM_LISTVIEW *nmlistview = (NM_LISTVIEW *)lParam;
- HWND list = nmlistview->hdr.hwndFrom;
- int entry = listview_entry_from_click(list, &column, false);
- if (entry >= 0) {
- selected = entry;
- BoardsEnable(hDlg, selected);
- }
- }
- break;
- }
- }
- }
- return FALSE;
- }
- static const struct memoryboardtype* getmemoryboardselect(HWND hDlg)
- {
- int v = SendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_GETCURSEL, 0, 0L);
- if (v == CB_ERR)
- return NULL;
- int idx = 1;
- for (int i = 0; memoryboards[i].name; i++) {
- const struct memoryboardtype *mbt = &memoryboards[i];
- if ((fastram_select < MAX_RAM_BOARDS && mbt->z == 2) || (fastram_select >= MAX_RAM_BOARDS && mbt->z == 3)) {
- if (idx == v) {
- return mbt;
- }
- }
- idx++;
- }
- return NULL;
- }
- static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- TCHAR tmp[MAX_DPATH];
- static int recursive = 0;
- int v;
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- recursive++;
- pages[MEMORY_ID] = hDlg;
- currentpage = MEMORY_ID;
- SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CHIP_MEM, MAX_CHIP_MEM));
- SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_FAST_MEM, MAX_FAST_MEM));
- SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_SLOW_MEM, MAX_SLOW_MEM));
- SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_Z3_MEM, MAX_Z3_MEM));
- SendDlgItemMessage (hDlg, IDC_Z3CHIPMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_Z3_MEM, MAX_Z3_CHIPMEM));
- SendDlgItemMessage (hDlg, IDC_Z3MAPPING, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_AUTOMATIC, tmp, sizeof tmp / sizeof (TCHAR));
- _tcscat(tmp, _T(" (*)"));
- SendDlgItemMessage (hDlg, IDC_Z3MAPPING, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage(hDlg, IDC_Z3MAPPING, CB_ADDSTRING, 0, (LPARAM)_T("UAE (0x10000000)"));
- SendDlgItemMessage(hDlg, IDC_Z3MAPPING, CB_ADDSTRING, 0, (LPARAM)_T("Real (0x40000000)"));
- SendDlgItemMessage (hDlg, IDC_Z3MAPPING, CB_SETCURSEL, workprefs.z3_mapping_mode, 0);
- setfastram_selectmenu(hDlg, -1);
- recursive--;
- case WM_USER:
- recursive++;
- fix_values_memorydlg ();
- values_to_memorydlg (hDlg);
- enable_for_memorydlg (hDlg);
- recursive--;
- break;
- case WM_COMMAND:
- if (!recursive) {
- recursive++;
- switch (LOWORD(wParam))
- {
- case IDC_FASTMEMDMA:
- if (fastram_select_ramboard) {
- struct ramboard* rb = fastram_select_ramboard;
- rb->nodma = ischecked(hDlg, IDC_FASTMEMDMA) == 0;
- setfastram_selectmenu(hDlg, 0);
- }
- break;
- case IDC_FASTMEMFORCE16:
- if (fastram_select_ramboard) {
- struct ramboard* rb = fastram_select_ramboard;
- rb->force16bit = ischecked(hDlg, IDC_FASTMEMFORCE16) != 0;
- setfastram_selectmenu(hDlg, 0);
- }
- break;
- case IDC_FASTMEMAUTOCONFIGUSE:
- if (fastram_select_ramboard) {
- struct ramboard* rb = fastram_select_ramboard;
- rb->autoconfig_inuse = ischecked(hDlg, IDC_FASTMEMAUTOCONFIGUSE);
- rb->manual_config = false;
- setfastram_selectmenu(hDlg, 0);
- }
- break;
- case IDC_FASTMEMNOAUTOCONFIG:
- if (fastram_select_ramboard) {
- struct ramboard *rb = fastram_select_ramboard;
- rb->manual_config = ischecked(hDlg, IDC_FASTMEMNOAUTOCONFIG);
- rb->autoconfig_inuse = false;
- const struct memoryboardtype *mbt = getmemoryboardselect(hDlg);
- if (mbt && fastram_select_ramboard->manual_config && mbt->address) {
- fastram_select_ramboard->start_address = mbt->address;
- if (fastram_select_ramboard->end_address <= fastram_select_ramboard->start_address ||
- fastram_select_ramboard->end_address >= fastram_select_ramboard->start_address + fastram_select_ramboard->size)
- fastram_select_ramboard->end_address = mbt->address + fastram_select_ramboard->size - 1;
- }
- setfastram_selectmenu(hDlg, 0);
- }
- break;
- }
- if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) {
- switch (LOWORD (wParam))
- {
- case IDC_Z3MAPPING:
- v = SendDlgItemMessage (hDlg, IDC_Z3MAPPING, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- workprefs.z3_mapping_mode = v;
- }
- break;
- case IDC_MEMORYSELECT:
- v = SendDlgItemMessage(hDlg, IDC_MEMORYSELECT, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- fastram_select = v;
- setfastram_selectmenu(hDlg, 0);
- }
- break;
- case IDC_MEMORYBOARDSELECT:
- if (fastram_select_ramboard) {
- const struct memoryboardtype *mbt = getmemoryboardselect(hDlg);
- if (mbt) {
- if (mbt->manufacturer != 0xffff) {
- fastram_select_ramboard->manufacturer = mbt->manufacturer;
- fastram_select_ramboard->product = mbt->product;
- } else {
- fastram_select_ramboard->autoconfig_inuse = false;
- fastram_select_ramboard->manual_config = true;
- }
- if (fastram_select_ramboard->manual_config && mbt->address) {
- fastram_select_ramboard->start_address = mbt->address;
- fastram_select_ramboard->end_address = mbt->address + fastram_select_ramboard->size - 1;
- }
- setfastram_selectmenu(hDlg, 0);
- break;
- }
- }
- break;
- }
- } else if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_AUTOCONFIG_MANUFACTURER:
- case IDC_AUTOCONFIG_PRODUCT:
- if (fastram_select_ramboard) {
- GetDlgItemText(hDlg, IDC_AUTOCONFIG_MANUFACTURER, tmp, sizeof tmp / sizeof(TCHAR));
- fastram_select_ramboard->manufacturer = _tstol(tmp);
- GetDlgItemText(hDlg, IDC_AUTOCONFIG_PRODUCT, tmp, sizeof tmp / sizeof(TCHAR));
- fastram_select_ramboard->product = _tstol(tmp);
- setfastram_selectmenu(hDlg, 1);
- }
- break;
- case IDC_RAM_ADDRESS:
- case IDC_RAM_ADDRESS2:
- if (fastram_select_ramboard) {
- TCHAR *endptr;
- GetDlgItemText(hDlg, IDC_RAM_ADDRESS, tmp, sizeof tmp / sizeof(TCHAR));
- fastram_select_ramboard->start_address = _tcstoul(tmp, &endptr, 16);
- GetDlgItemText(hDlg, IDC_RAM_ADDRESS2, tmp, sizeof tmp / sizeof(TCHAR));
- fastram_select_ramboard->end_address = _tcstoul(tmp, &endptr, 16);
- setfastram_selectmenu(hDlg, HIWORD(wParam) == EN_KILLFOCUS ? 0 : 3);
- }
- break;
- case IDC_AUTOCONFIG_DATA:
- if (fastram_select_ramboard && fastram_select_ramboard->autoconfig_inuse) {
- struct ramboard *rb = fastram_select_ramboard;
- GetDlgItemText(hDlg, IDC_AUTOCONFIG_DATA, tmp, sizeof tmp / sizeof(TCHAR));
- memset(rb->autoconfig, 0, sizeof rb->autoconfig);
- for (int i = 0; i < sizeof rb->autoconfig; i++) {
- TCHAR *s2 = &tmp[i * 3];
- if (i + 1 < 12 && s2[2] != '.')
- break;
- TCHAR *endptr;
- tmp[2] = 0;
- rb->autoconfig[i] = (uae_u8)_tcstol(s2, &endptr, 16);
- }
- setfastram_selectmenu(hDlg, 2);
- }
- break;
- }
- }
- recursive--;
- }
- break;
- case WM_HSCROLL:
- {
- recursive++;
- bool change1 = false;
- uae_u32 v;
- v = memsizes[msi_chip[SendMessage (GetDlgItem (hDlg, IDC_CHIPMEM), TBM_GETPOS, 0, 0)]];
- if (v != workprefs.chipmem.size) {
- change1 = true;
- workprefs.chipmem.size = v;
- }
- v = memsizes[msi_bogo[SendMessage (GetDlgItem (hDlg, IDC_SLOWMEM), TBM_GETPOS, 0, 0)]];
- if (v != workprefs.bogomem.size) {
- change1 = true;
- workprefs.bogomem.size = v;
- }
- v = memsizes[msi_fast[SendMessage (GetDlgItem (hDlg, IDC_FASTMEM), TBM_GETPOS, 0, 0)]];
- if (v != workprefs.fastmem[0].size) {
- change1 = true;
- workprefs.fastmem[0].size = v;
- fastram_select = 0;
- setfastram_selectmenu(hDlg, 0);
- }
- v = memsizes[msi_z3fast[SendMessage (GetDlgItem (hDlg, IDC_Z3FASTMEM), TBM_GETPOS, 0, 0)]];
- if (v != workprefs.z3fastmem[0].size) {
- change1 = true;
- workprefs.z3fastmem[0].size = v;
- fastram_select = MAX_RAM_BOARDS;
- setfastram_selectmenu(hDlg, 0);
- }
- v = memsizes[msi_z3chip[SendMessage (GetDlgItem (hDlg, IDC_Z3CHIPMEM), TBM_GETPOS, 0, 0)]];
- if (v != workprefs.z3chipmem.size) {
- change1 = true;
- workprefs.z3chipmem.size = v;
- }
- if (!change1 && fastram_select_pointer) {
- v = memsizes[fastram_select_msi[SendMessage(GetDlgItem(hDlg, IDC_MEMORYMEM), TBM_GETPOS, 0, 0)]];
- if (*fastram_select_pointer != v) {
- *fastram_select_pointer = v;
- setfastram_selectmenu(hDlg, 0);
- values_to_memorydlg(hDlg);
- }
- }
- if (change1) {
- fix_values_memorydlg ();
- values_to_memorydlg (hDlg);
- setfastram_selectmenu(hDlg, 0);
- enable_for_memorydlg (hDlg);
- }
- recursive--;
- break;
- }
- }
- return FALSE;
- }
- static int customromselectnum;
- static void values_to_kickstartdlg(HWND hDlg)
- {
- UAEREG *fkey;
- fkey = regcreatetree(NULL, _T("DetectedROMs"));
- load_keyring(&workprefs, NULL);
- addromfiles(fkey, hDlg, IDC_ROMFILE, workprefs.romfile,
- ROMTYPE_KICK | ROMTYPE_KICKCD32, 0);
- addromfiles(fkey, hDlg, IDC_ROMFILE2, workprefs.romextfile,
- ROMTYPE_EXTCD32 | ROMTYPE_EXTCDTV | ROMTYPE_ARCADIABIOS | ROMTYPE_ALG, 0);
- addromfiles(fkey, hDlg, IDC_CARTFILE, workprefs.cartfile,
- ROMTYPE_FREEZER | ROMTYPE_ARCADIAGAME | ROMTYPE_CD32CART, 0);
- regclosetree(fkey);
- SetDlgItemText(hDlg, IDC_FLASHFILE, workprefs.flashfile);
- SetDlgItemText(hDlg, IDC_RTCFILE, workprefs.rtcfile);
- CheckDlgButton(hDlg, IDC_KICKSHIFTER, workprefs.kickshifter);
- CheckDlgButton(hDlg, IDC_MAPROM, workprefs.maprom);
- if (workprefs.boot_rom == 1) {
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_SETCURSEL, 0, 0);
- }
- else {
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_SETCURSEL, workprefs.uaeboard + 1, 0);
- }
- }
- static void values_to_kickstartdlg2(HWND hDlg)
- {
- int v = SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_GETCURSEL, 0, 0);
- if (v >= 0 && v < MAX_ROM_BOARDS) {
- customromselectnum = v;
- }
- SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_RESETCONTENT, 0, 0);
- for (int i = 0; i < MAX_ROM_BOARDS; i++) {
- TCHAR tmp[MAX_DPATH];
- struct romboard *rb = &workprefs.romboards[i];
- _stprintf(tmp, _T("ROM #%d"), i + 1);
- if (rb->size)
- _stprintf(tmp + _tcslen(tmp), _T(" %08x - %08x"), rb->start_address, rb->end_address - 1);
- SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- if (customromselectnum >= 0 && customromselectnum < MAX_ROM_BOARDS) {
- struct romboard *rb = &workprefs.romboards[customromselectnum];
- TCHAR tmp[100];
- _stprintf(tmp, _T("%08x"), rb->start_address);
- if (!rb->end_address && !rb->start_address) {
- tmp[0] = 0;
- }
- SetDlgItemText(hDlg, IDC_ROM_ADDRESS, tmp);
- _stprintf(tmp, _T("%08x"), rb->end_address);
- if (!rb->end_address && !rb->start_address) {
- tmp[0] = 0;
- }
- SetDlgItemText(hDlg, IDC_ROM_ADDRESS2, tmp);
- SetDlgItemText(hDlg, IDC_CUSTOMROMFILE, rb->lf.loadfile);
- SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_SETCURSEL, customromselectnum, 0);
- }
- }
- static void values_from_kickstartdlg(HWND hDlg)
- {
- getromfile(hDlg, IDC_ROMFILE, workprefs.romfile, sizeof(workprefs.romfile) / sizeof(TCHAR));
- getromfile(hDlg, IDC_ROMFILE2, workprefs.romextfile, sizeof(workprefs.romextfile) / sizeof(TCHAR));
- getromfile(hDlg, IDC_CARTFILE, workprefs.cartfile, sizeof(workprefs.cartfile) / sizeof(TCHAR));
- read_kickstart_version(&workprefs);
- int v = SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_GETCURSEL, 0, 0);
- if (v > 0) {
- workprefs.uaeboard = v - 1;
- workprefs.boot_rom = 0;
- } else {
- workprefs.uaeboard = 0;
- workprefs.boot_rom = 1; // disabled
- }
- }
- static void values_from_kickstartdlg2(HWND hDlg)
- {
- int v = SendDlgItemMessage(hDlg, IDC_CUSTOMROMSELECT, CB_GETCURSEL, 0, 0);
- if (v >= 0 && v < MAX_ROM_BOARDS) {
- struct romboard *rb = &workprefs.romboards[v];
- TCHAR tmp[100];
- TCHAR *endptr;
- GetDlgItemText(hDlg, IDC_ROM_ADDRESS, tmp, sizeof tmp / sizeof(TCHAR));
- rb->start_address =_tcstoul(tmp, &endptr, 16);
- rb->start_address &= ~65535;
- GetDlgItemText(hDlg, IDC_ROM_ADDRESS2, tmp, sizeof tmp / sizeof(TCHAR));
- rb->end_address = _tcstoul(tmp, &endptr, 16);
- rb->end_address = ((rb->end_address - 1) & ~65535) | 0xffff;
- rb->size = 0;
- if (rb->end_address > rb->start_address) {
- rb->size = (rb->end_address - rb->start_address + 65535) & ~65535;
- }
- }
- }
- static void init_kickstart (HWND hDlg)
- {
- ew (hDlg, IDC_MAPROM, workprefs.cpuboard_type == 0);
- #if !defined (CDTV) && !defined (CD32)
- ew (hDlg, IDC_FLASHFILE), FALSE);
- ew (hDlg, IDC_ROMFILE2), FALSE);
- #endif
- #if !defined (ACTION_REPLAY)
- ew (hDlg, IDC_CARTFILE), FALSE);
- #endif
- #if defined (UAE_MINI)
- ew (hDlg, IDC_KICKSHIFTER), FALSE);
- ew (hDlg, IDC_ROMCHOOSER2), FALSE);
- ew (hDlg, IDC_CARTCHOOSER), FALSE);
- ew (hDlg, IDC_FLASHCHOOSER), FALSE);
- #endif
- ew(hDlg, IDC_UAEBOARD_TYPE, full_property_sheet);
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("ROM disabled"));
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("Original UAE (FS + F0 ROM)"));
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("New UAE (64k + F0 ROM)"));
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("New UAE (128k, ROM, Direct)"));
- SendDlgItemMessage(hDlg, IDC_UAEBOARD_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("New UAE (128k, ROM, Indirect)"));
- if (!regexiststree(NULL, _T("DetectedROMs")))
- scan_roms (NULL, rp_isactive () ? 0 : 1);
- }
- static void kickstartfilebuttons (HWND hDlg, WPARAM wParam, TCHAR *path)
- {
- switch (LOWORD(wParam))
- {
- case IDC_KICKCHOOSER:
- DiskSelection(hDlg, IDC_ROMFILE, 6, &workprefs, NULL, path);
- values_to_kickstartdlg(hDlg);
- break;
- case IDC_ROMCHOOSER2:
- DiskSelection(hDlg, IDC_ROMFILE2, 6, &workprefs, NULL, path);
- values_to_kickstartdlg(hDlg);
- break;
- case IDC_CUSTOMROMCHOOSER:
- DiskSelection(hDlg, IDC_CUSTOMROMFILE, 6, &workprefs, NULL, path);
- values_to_kickstartdlg2(hDlg);
- break;
- case IDC_FLASHCHOOSER:
- DiskSelection(hDlg, IDC_FLASHFILE, 11, &workprefs, NULL, path);
- values_to_kickstartdlg(hDlg);
- break;
- case IDC_RTCCHOOSER:
- DiskSelection(hDlg, IDC_RTCFILE, 19, &workprefs, NULL, path);
- values_to_kickstartdlg(hDlg);
- break;
- case IDC_CARTCHOOSER:
- DiskSelection(hDlg, IDC_CARTFILE, 6, &workprefs, NULL, path);
- values_to_kickstartdlg(hDlg);
- break;
- }
- }
- static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive;
- TCHAR tmp[MAX_DPATH];
- if (dialog_inhibit)
- return 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- int ids[] = { IDC_ROMFILE, IDC_ROMFILE2, IDC_CARTFILE, -1 };
- pages[KICKSTART_ID] = hDlg;
- currentpage = KICKSTART_ID;
- init_kickstart (hDlg);
- values_to_kickstartdlg(hDlg);
- values_to_kickstartdlg2(hDlg);
- setmultiautocomplete (hDlg, ids);
- setac (hDlg, IDC_FLASHFILE);
- setac (hDlg, IDC_RTCFILE);
- return TRUE;
- }
- case WM_CONTEXTMENU:
- {
- int id = GetDlgCtrlID((HWND)wParam);
- if (id == IDC_KICKCHOOSER || id == IDC_ROMCHOOSER2
- || id == IDC_FLASHCHOOSER || id == IDC_CARTCHOOSER || id == IDC_RTCCHOOSER) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR newfile[MAX_DPATH];
- _tcscpy (newfile, s);
- kickstartfilebuttons (hDlg, id, newfile);
- xfree (s);
- }
- }
- break;
- }
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_ROMFILE:
- case IDC_ROMFILE2:
- case IDC_CARTFILE:
- case IDC_UAEBOARD_TYPE:
- values_from_kickstartdlg(hDlg);
- break;
- case IDC_CUSTOMROMSELECT:
- values_to_kickstartdlg2(hDlg);
- break;
- }
- } else if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_ROM_ADDRESS:
- case IDC_ROM_ADDRESS2:
- values_from_kickstartdlg2(hDlg);
- break;
- }
- }
- kickstartfilebuttons (hDlg, wParam, NULL);
- switch (LOWORD (wParam))
- {
- case IDC_FLASHFILE:
- GetWindowText (GetDlgItem (hDlg, IDC_FLASHFILE), tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcscpy (workprefs.flashfile, tmp);
- break;
- case IDC_RTCFILE:
- GetWindowText (GetDlgItem (hDlg, IDC_RTCFILE), tmp, sizeof (tmp) / sizeof (TCHAR));
- _tcscpy (workprefs.rtcfile, tmp);
- break;
- case IDC_KICKSHIFTER:
- workprefs.kickshifter = ischecked (hDlg, IDC_KICKSHIFTER);
- break;
- case IDC_MAPROM:
- workprefs.maprom = ischecked (hDlg, IDC_MAPROM) ? 0x0f000000 : 0;
- break;
- }
- recursive--;
- break;
- }
- return FALSE;
- }
- static void enable_for_miscdlg (HWND hDlg)
- {
- if (!full_property_sheet) {
- ew (hDlg, IDC_NOSPEED, TRUE);
- ew (hDlg, IDC_NOSPEEDPAUSE, TRUE);
- ew (hDlg, IDC_NOSOUND, TRUE);
- ew (hDlg, IDC_DOSAVESTATE, TRUE);
- ew (hDlg, IDC_SCSIMODE, FALSE);
- } else {
- #if !defined (SCSIEMU)
- EnableWindow (GetDlgItem(hDlg, IDC_SCSIMODE), TRUE);
- #endif
- ew (hDlg, IDC_DOSAVESTATE, FALSE);
- }
- ew (hDlg, IDC_ASSOCIATELIST, !rp_isactive ());
- ew (hDlg, IDC_ASSOCIATE_ON, !rp_isactive ());
- ew (hDlg, IDC_ASSOCIATE_OFF, !rp_isactive ());
- ew (hDlg, IDC_DXMODE_OPTIONS, workprefs.gfx_api == 2 || (full_property_sheet && workprefs.gfx_api == 0));
- bool paused = false;
- bool nosound = false;
- bool nojoy = (workprefs.win32_inactive_input & 4) == 0;
- ew (hDlg, IDC_ACTIVE_PAUSE, paused == false);
- ew (hDlg, IDC_ACTIVE_NOSOUND, nosound == false && paused == false);
- if (!paused) {
- paused = workprefs.win32_active_nocapture_pause;
- if (!nosound)
- nosound = workprefs.win32_active_nocapture_nosound;
- else
- workprefs.win32_active_nocapture_nosound = true;
- } else {
- workprefs.win32_active_nocapture_pause = workprefs.win32_active_nocapture_nosound = true;
- nosound = true;
- nojoy = true;
- }
- if (paused)
- CheckDlgButton (hDlg, IDC_INACTIVE_PAUSE, TRUE);
- if (nosound || paused)
- CheckDlgButton(hDlg, IDC_INACTIVE_NOSOUND, TRUE);
- if (paused || nojoy)
- CheckDlgButton(hDlg, IDC_INACTIVE_NOJOY, TRUE);
- ew(hDlg, IDC_INACTIVE_PAUSE, paused == false);
- ew(hDlg, IDC_INACTIVE_NOSOUND, nosound == false && paused == false);
- ew(hDlg, IDC_INACTIVE_NOJOY, paused == false);
- if (!paused) {
- paused = workprefs.win32_inactive_pause;
- if (!nosound)
- nosound = workprefs.win32_inactive_nosound;
- else
- workprefs.win32_inactive_nosound = true;
- if (!nojoy)
- nojoy = (workprefs.win32_inactive_input & 4) == 0;
- else
- workprefs.win32_inactive_input = 0;
- } else {
- workprefs.win32_inactive_pause = workprefs.win32_inactive_nosound = true;
- workprefs.win32_inactive_input = workprefs.win32_inactive_input = 0;
- nosound = true;
- nojoy = true;
- }
- if (paused)
- CheckDlgButton (hDlg, IDC_MINIMIZED_PAUSE, TRUE);
- if (nosound || paused)
- CheckDlgButton (hDlg, IDC_MINIMIZED_NOSOUND, TRUE);
- if (paused || nojoy)
- CheckDlgButton(hDlg, IDC_MINIMIZED_NOJOY, TRUE);
- ew(hDlg, IDC_MINIMIZED_PAUSE, paused == false);
- ew(hDlg, IDC_MINIMIZED_NOSOUND, nosound == false && paused == false);
- ew(hDlg, IDC_MINIMIZED_NOJOY, nojoy == false && paused == false);
- if (!paused) {
- paused = workprefs.win32_iconified_pause;
- if (!nosound)
- nosound = workprefs.win32_iconified_nosound;
- else
- workprefs.win32_iconified_nosound = true;
- } else {
- workprefs.win32_iconified_pause = workprefs.win32_iconified_nosound = true;
- workprefs.win32_iconified_input = workprefs.win32_iconified_input = 0;
- nosound = true;
- nojoy = true;
- }
- }
- static void misc_kbled (HWND hDlg, int v, int nv)
- {
- const TCHAR *defname = v == IDC_KBLED1 ? _T("(NumLock)") : v == IDC_KBLED2 ? _T("(CapsLock)") : _T("(ScrollLock)");
- SendDlgItemMessage (hDlg, v, CB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)defname);
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("POWER"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("DF0"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("DF1"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("DF2"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("DF3"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("HD"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("CD"));
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)_T("DF*"));
- SendDlgItemMessage (hDlg, v, CB_SETCURSEL, nv, 0);
- }
- static void misc_getkbled (HWND hDlg, int v, int n)
- {
- LRESULT nv = SendDlgItemMessage (hDlg, v, CB_GETCURSEL, 0, 0L);
- if (nv != CB_ERR) {
- workprefs.keyboard_leds[n] = nv;
- misc_kbled (hDlg, v, nv);
- }
- workprefs.keyboard_leds_in_use = (workprefs.keyboard_leds[0] | workprefs.keyboard_leds[1] | workprefs.keyboard_leds[2]) != 0;
- }
- static void misc_getpri (HWND hDlg, int v, int *n)
- {
- LRESULT nv = SendDlgItemMessage (hDlg, v, CB_GETCURSEL, 0, 0L);
- if (nv != CB_ERR)
- *n = nv;
- }
- static void misc_addpri (HWND hDlg, int v, int pri)
- {
- int i;
- DWORD opri = GetPriorityClass (GetCurrentProcess ());
- ew (hDlg, v, !(opri != IDLE_PRIORITY_CLASS && opri != NORMAL_PRIORITY_CLASS && opri != BELOW_NORMAL_PRIORITY_CLASS && opri != ABOVE_NORMAL_PRIORITY_CLASS));
- SendDlgItemMessage (hDlg, v, CB_RESETCONTENT, 0, 0L);
- i = 0;
- while (priorities[i].name) {
- SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)priorities[i].name);
- i++;
- }
- SendDlgItemMessage (hDlg, v, CB_SETCURSEL, pri, 0);
- }
- static void misc_scsi (HWND hDlg)
- {
- TCHAR tmp[MAX_DPATH];
- SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_SCSI_EMULATION, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)_T("SPTI"));
- SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)_T("SPTI + SCSI SCAN"));
- SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_SETCURSEL, workprefs.win32_uaescsimode, 0);
- }
- static void misc_lang (HWND hDlg)
- {
- int i, idx = 0, cnt = 0, lid;
- WORD langid = -1;
- TCHAR tmp[MAX_DPATH];
- if (regqueryint (NULL, _T("Language"), &lid))
- langid = (WORD)lid;
- WIN32GUI_LoadUIString (IDS_AUTODETECT, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)_T("English (built-in)"));
- if (langid == 0)
- idx = 1;
- cnt = 2;
- for (i = 0; langs[i].name; i++) {
- HMODULE hm = language_load (langs[i].id);
- if (hm) {
- FreeLibrary (hm);
- SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name);
- if (langs[i].id == langid)
- idx = cnt;
- cnt++;
- }
- }
- SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_SETCURSEL, idx, 0);
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_SELECT_MENU, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("200%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("190%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("180%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("170%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("160%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("150%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("140%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("130%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("120%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("110%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T("100%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T(" 90%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T(" 80%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T(" 70%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_ADDSTRING, 0, (LPARAM)_T(" 60%"));
- SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_SETCURSEL, 0, 0);
- }
- static void misc_setlang (int v)
- {
- int i;
- WORD langid = 0;
- v-=2;
- if (v >= 0) {
- for (i = 0; langs[i].name; i++) {
- HMODULE hm = language_load (langs[i].id);
- if (hm) {
- FreeLibrary(hm);
- if (v == 0) {
- langid = langs[i].id;
- break;
- }
- v--;
- }
- }
- }
- if (v == -2)
- langid = -1;
- regsetint (NULL, _T("Language"), langid);
- FreeLibrary(hUIDLL);
- hUIDLL = NULL;
- if (langid >= 0)
- hUIDLL = language_load(langid);
- restart_requested = 1;
- exit_gui(0);
- }
- static void misc_gui_font (HWND hDlg, int fonttype)
- {
- if (scaleresource_choosefont (hDlg, fonttype))
- gui_size_changed = 10;
- }
- static void values_to_miscdlg_dx(HWND hDlg)
- {
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_RESETCONTENT, 0, 0);
- if (workprefs.gfx_api == 0) {
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("NonLocalVRAM"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("DefaultRAM *"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("LocalVRAM"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("SystemRAM"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_SETCURSEL, ddforceram, 0);
- } else if (workprefs.gfx_api >= 2) {
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("Hardware D3D11"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_ADDSTRING, 0, (LPARAM)_T("Software D3D11"));
- SendDlgItemMessage(hDlg, IDC_DXMODE_OPTIONS, CB_SETCURSEL, workprefs.gfx_api_options, 0);
- }
- }
- static void values_to_miscdlg (HWND hDlg)
- {
- TCHAR tmp[MAX_DPATH];
- if (currentpage == MISC1_ID) {
- misc_kbled (hDlg, IDC_KBLED1, workprefs.keyboard_leds[0]);
- misc_kbled (hDlg, IDC_KBLED2, workprefs.keyboard_leds[1]);
- misc_kbled (hDlg, IDC_KBLED3, workprefs.keyboard_leds[2]);
- CheckDlgButton (hDlg, IDC_KBLED_USB, workprefs.win32_kbledmode);
- CheckDlgButton (hDlg, IDC_GUI_RESIZE, gui_resize_enabled);
- CheckDlgButton (hDlg, IDC_GUI_FULLSCREEN, gui_fullscreen > 0);
- ew (hDlg, IDC_GUI_RESIZE, gui_resize_allowed);
- misc_scsi (hDlg);
- misc_lang (hDlg);
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_ADDSTRING, 0, (LPARAM)_T("DirectDraw"));
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_ADDSTRING, 0, (LPARAM)_T("Direct3D 9"));
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_ADDSTRING, 0, (LPARAM)_T("Direct3D 11"));
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_ADDSTRING, 0, (LPARAM)_T("Direct3D 11 HDR (experimental)"));
- SendDlgItemMessage(hDlg, IDC_DXMODE, CB_SETCURSEL, workprefs.gfx_api, 0);
- values_to_miscdlg_dx(hDlg);
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_WSTYLE_BORDERLESS, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_ADDSTRING, 0, (LPARAM)tmp);
- WIN32GUI_LoadUIString (IDS_WSTYLE_MINIMAL, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_ADDSTRING, 0, (LPARAM)tmp);
- WIN32GUI_LoadUIString (IDS_WSTYLE_STANDARD, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_ADDSTRING, 0, (LPARAM)tmp);
- WIN32GUI_LoadUIString (IDS_WSTYLE_EXTENDED, tmp, sizeof tmp / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_SETCURSEL,
- workprefs.win32_borderless ? 0 : (workprefs.win32_statusbar + 1),
- 0);
- } else if (currentpage == MISC2_ID) {
- CheckDlgButton(hDlg, IDC_ACTIVE_PAUSE, workprefs.win32_active_nocapture_pause);
- CheckDlgButton(hDlg, IDC_ACTIVE_NOSOUND, workprefs.win32_active_nocapture_nosound || workprefs.win32_active_nocapture_pause);
- CheckDlgButton(hDlg, IDC_INACTIVE_PAUSE, workprefs.win32_inactive_pause);
- CheckDlgButton(hDlg, IDC_INACTIVE_NOSOUND, workprefs.win32_inactive_nosound || workprefs.win32_inactive_pause);
- CheckDlgButton(hDlg, IDC_INACTIVE_NOJOY, (workprefs.win32_inactive_input & 4) == 0 || workprefs.win32_inactive_pause);
- CheckDlgButton(hDlg, IDC_MINIMIZED_PAUSE, workprefs.win32_iconified_pause);
- CheckDlgButton(hDlg, IDC_MINIMIZED_NOSOUND, workprefs.win32_iconified_nosound || workprefs.win32_iconified_pause);
- CheckDlgButton(hDlg, IDC_MINIMIZED_NOJOY, (workprefs.win32_iconified_input & 4) == 0 || workprefs.win32_iconified_pause);
- misc_addpri(hDlg, IDC_ACTIVE_PRIORITY, workprefs.win32_active_capture_priority);
- misc_addpri(hDlg, IDC_INACTIVE_PRIORITY, workprefs.win32_inactive_priority);
- misc_addpri(hDlg, IDC_MINIMIZED_PRIORITY, workprefs.win32_iconified_priority);
- }
- }
- static void setstatefilename (HWND hDlg)
- {
- TCHAR *s = _tcsrchr (workprefs.statefile, '\\');
- if (s) {
- s++;
- } else {
- s = _tcsrchr (workprefs.statefile, '/');
- if (s)
- s++;
- }
- if (!s)
- s = workprefs.statefile;
- SetDlgItemText (hDlg, IDC_STATENAME, s);
- ew (hDlg, IDC_STATECLEAR, workprefs.statefile[0] != 0);
- setchecked (hDlg, IDC_STATECLEAR, workprefs.statefile[0] != 0);
- }
- static void setdefaultguisize(int skipdpi)
- {
- int dpi = skipdpi ? 96 : getdpiformonitor(NULL);
- gui_width = MulDiv(GUI_INTERNAL_WIDTH, dpi, 96);
- gui_height = MulDiv(GUI_INTERNAL_HEIGHT, dpi, 96);
- int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- if ((dpi > 96) && (gui_width > w || gui_height > h)) {
- gui_width = w;
- gui_height = h;
- }
- }
- static void saveguisize(void)
- {
- if (gui_fullscreen)
- return;
- if (full_property_sheet || isfullscreen() == 0) {
- regsetint(NULL, _T("GUISizeX"), gui_width);
- regsetint(NULL, _T("GUISizeY"), gui_height);
- } else if (isfullscreen() < 0) {
- regsetint(NULL, _T("GUISizeFWX"), gui_width);
- regsetint(NULL, _T("GUISizeFWY"), gui_height);
- } else if (isfullscreen() > 0) {
- regsetint(NULL, _T("GUISizeFSX"), gui_width);
- regsetint(NULL, _T("GUISizeFSY"), gui_height);
- }
- }
- static void getstoredguisize(void)
- {
- if (full_property_sheet || isfullscreen () == 0) {
- regqueryint(NULL, _T("GUISizeX"), &gui_width);
- regqueryint(NULL, _T("GUISizeY"), &gui_height);
- scaleresource_init(gui_fullscreen ? _T("GFS") : _T(""), gui_fullscreen);
- } else if (isfullscreen () < 0) {
- regqueryint(NULL, _T("GUISizeFWX"), &gui_width);
- regqueryint(NULL, _T("GUISizeFWY"), &gui_height);
- scaleresource_init(gui_fullscreen ? _T("FW_GFS") : _T("FW"), gui_fullscreen);
- } else if (isfullscreen () > 0) {
- regqueryint(NULL, _T("GUISizeFSX"), &gui_width);
- regqueryint(NULL, _T("GUISizeFSY"), &gui_height);
- scaleresource_init(gui_fullscreen ? _T("FS_GFS") : _T("FS"), gui_fullscreen);
- }
- }
- static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- int v, i;
- static int recursive;
- TCHAR tmp[MAX_DPATH];
- if (recursive)
- return FALSE;
- recursive++;
- switch (msg)
- {
- case WM_INITDIALOG:
- pages[currentpage] = hDlg;
- InitializeListView (hDlg);
- values_to_miscdlg (hDlg);
- enable_for_miscdlg (hDlg);
- addhistorymenu(hDlg, NULL, IDC_STATENAME, HISTORY_STATEFILE, true, -1);
- setstatefilename(hDlg);
- recursive--;
- return TRUE;
- case WM_USER:
- values_to_miscdlg (hDlg);
- enable_for_miscdlg (hDlg);
- recursive--;
- return TRUE;
- case WM_CONTEXTMENU:
- if (GetDlgCtrlID((HWND)wParam) == IDC_DOSAVESTATE) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR path[MAX_DPATH];
- _tcscpy (path, s);
- xfree (s);
- if (DiskSelection(hDlg, wParam, 9, &workprefs, NULL, path))
- save_state (savestate_fname, _T("Description!"));
- }
- } else if (GetDlgCtrlID((HWND)wParam) == IDC_DOLOADSTATE) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR path[MAX_DPATH];
- _tcscpy (path, s);
- xfree (s);
- if (DiskSelection(hDlg, wParam, 10, &workprefs, NULL, path))
- savestate_state = STATE_DORESTORE;
- }
- }
- break;
- case WM_NOTIFY:
- if (((LPNMHDR) lParam)->idFrom == IDC_ASSOCIATELIST) {
- int entry, col;
- HWND list;
- NM_LISTVIEW *nmlistview = (NM_LISTVIEW *)lParam;
- list = nmlistview->hdr.hwndFrom;
- if (nmlistview->hdr.code == NM_DBLCLK) {
- entry = listview_entry_from_click (list, &col, false);
- exts[entry].enabled = exts[entry].enabled ? 0 : 1;
- associate_file_extensions ();
- InitializeListView (hDlg);
- }
- } else if (((LPNMHDR) lParam)->idFrom == IDC_MISCLIST) {
- NM_LISTVIEW *nmlistview = (NM_LISTVIEW *)lParam;
- if (nmlistview->hdr.code == LVN_ITEMCHANGED) {
- int item = nmlistview->iItem;
- if (item >= 0) {
- const struct miscentry *me = &misclist[item];
- bool checked = (nmlistview->uNewState & LVIS_STATEIMAGEMASK) == 0x2000;
- if (me->b) {
- *me->b = checked;
- } else if (me->i) {
- *me->i &= ~me->imask;
- if (checked)
- *me->i |= me->ival & me->imask;
- }
- workprefs.input_mouse_untrap &= ~MOUSEUNTRAP_MIDDLEBUTTON;
- if (win32_middle_mouse_obsolete)
- workprefs.input_mouse_untrap |= MOUSEUNTRAP_MIDDLEBUTTON;
- }
- }
- }
- break;
- case WM_COMMAND:
- if (currentpage == MISC1_ID) {
- if (HIWORD (wParam) == CBN_SELENDOK || HIWORD (wParam) == CBN_KILLFOCUS || HIWORD (wParam) == CBN_EDITCHANGE) {
- switch (LOWORD (wParam))
- {
- case IDC_STATENAME:
- if (HIWORD(wParam) != CBN_EDITCHANGE && getcomboboxtext(hDlg, IDC_STATENAME, tmp, sizeof tmp / sizeof(TCHAR))) {
- if (tmp[0]) {
- parsefilepath(tmp, sizeof tmp / sizeof(TCHAR));
- if (_tcscmp(tmp, savestate_fname)) {
- _tcscpy(savestate_fname, tmp);
- savestate_state = STATE_DORESTORE;
- if (!my_existsfile(savestate_fname)) {
- TCHAR t[MAX_DPATH];
- _tcscpy(t, savestate_fname);
- _tcscat(savestate_fname, _T(".uss"));
- if (!my_existsfile(savestate_fname)) {
- fetch_statefilepath(savestate_fname, sizeof(t) / sizeof(MAX_DPATH));
- _tcscat(savestate_fname, t);
- if (!my_existsfile(savestate_fname)) {
- _tcscat(savestate_fname, _T(".uss"));
- if (!my_existsfile(savestate_fname)) {
- _tcscpy(savestate_fname, t);
- }
- }
- }
- }
- _tcscpy(workprefs.statefile, savestate_fname);
- setstatefilename(hDlg);
- }
- }
- }
- break;
- case IDC_KBLED1:
- misc_getkbled (hDlg, IDC_KBLED1, 0);
- break;
- case IDC_KBLED2:
- misc_getkbled (hDlg, IDC_KBLED2, 1);
- break;
- case IDC_KBLED3:
- misc_getkbled (hDlg, IDC_KBLED3, 2);
- break;
- case IDC_LANGUAGE:
- if (HIWORD (wParam) == CBN_SELENDOK) {
- v = SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR)
- misc_setlang (v);
- }
- break;
- case IDC_DXMODE:
- v = SendDlgItemMessage (hDlg, IDC_DXMODE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- workprefs.gfx_api = v;
- if (full_property_sheet)
- d3d_select(&workprefs);
- enable_for_miscdlg (hDlg);
- values_to_miscdlg_dx(hDlg);
- }
- break;
- case IDC_WINDOWEDMODE:
- v = SendDlgItemMessage (hDlg, IDC_WINDOWEDMODE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- workprefs.win32_borderless = 0;
- workprefs.win32_statusbar = 0;
- if (v == 0)
- workprefs.win32_borderless = 1;
- if (v > 0)
- workprefs.win32_statusbar = v - 1;
- }
- break;
- case IDC_DXMODE_OPTIONS:
- v = SendDlgItemMessage (hDlg, IDC_DXMODE_OPTIONS, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- if (workprefs.gfx_api >= 2) {
- workprefs.gfx_api_options = v;
- } else if (!workprefs.gfx_api) {
- ddforceram = v;
- regsetint(NULL, _T("DirectDraw_Secondary"), ddforceram);
- }
- }
- break;
- case IDC_SCSIMODE:
- v = SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR)
- workprefs.win32_uaescsimode = v;
- break;
- }
- }
- } else if (currentpage == MISC2_ID) {
- misc_getpri (hDlg, IDC_ACTIVE_PRIORITY, &workprefs.win32_active_capture_priority);
- misc_getpri (hDlg, IDC_INACTIVE_PRIORITY, &workprefs.win32_inactive_priority);
- misc_getpri (hDlg, IDC_MINIMIZED_PRIORITY, &workprefs.win32_iconified_priority);
- }
- switch(wParam)
- {
- case IDC_GUI_LVDEFAULT:
- ResetListViews();
- break;
- case IDC_GUI_DEFAULT:
- scaleresource_setdefaults(hDlg);
- v = SendDlgItemMessage (hDlg, IDC_GUI_SIZE, CB_GETCURSEL, 0, 0L);
- if (v != CB_ERR) {
- if (v == 0) {
- v = GUI_SCALE_DEFAULT;
- } else {
- v--;
- v = 200 - v * 10;
- }
- gui_width = (int)(GUI_INTERNAL_WIDTH * v / 100);
- gui_height = (int)(GUI_INTERNAL_HEIGHT * v / 100);
- int dpi = getdpiforwindow(hDlg);
- gui_width = MulDiv(gui_width, dpi, 96);
- gui_height = MulDiv(gui_height, dpi, 96);
- if (gui_width < MIN_GUI_INTERNAL_WIDTH || gui_height < MIN_GUI_INTERNAL_HEIGHT) {
- gui_width = MIN_GUI_INTERNAL_WIDTH;
- gui_height = MIN_GUI_INTERNAL_HEIGHT;
- }
- scaleresource_setsize(gui_width, gui_height, gui_fullscreen);
- gui_size_changed = 10;
- }
- break;
- case IDC_GUI_FONT:
- misc_gui_font (hDlg, 0);
- break;
- case IDC_GUI_RESIZE:
- gui_resize_enabled = ischecked (hDlg, IDC_GUI_RESIZE);
- gui_fullscreen = -1;
- gui_size_changed = 10;
- break;
- case IDC_GUI_FULLSCREEN:
- gui_fullscreen = ischecked (hDlg, IDC_GUI_FULLSCREEN);
- if (!gui_fullscreen) {
- gui_fullscreen = -1;
- getstoredguisize();
- }
- gui_size_changed = 10;
- break;
- case IDC_ASSOCIATE_ON:
- for (i = 0; exts[i].ext; i++)
- exts[i].enabled = 1;
- associate_file_extensions ();
- InitializeListView (hDlg);
- break;
- case IDC_ASSOCIATE_OFF:
- for (i = 0; exts[i].ext; i++)
- exts[i].enabled = 0;
- associate_file_extensions ();
- InitializeListView (hDlg);
- break;
- case IDC_STATECLEAR:
- savestate_initsave (NULL, 0, 0, false);
- _tcscpy (workprefs.statefile, savestate_fname);
- setstatefilename (hDlg);
- break;
- case IDC_DOSAVESTATE:
- workprefs.statefile[0] = 0;
- if (DiskSelection(hDlg, wParam, 9, &workprefs, NULL, NULL)) {
- save_state (savestate_fname, _T("Description!"));
- _tcscpy (workprefs.statefile, savestate_fname);
- }
- setstatefilename (hDlg);
- break;
- case IDC_DOLOADSTATE:
- if (DiskSelection(hDlg, wParam, 10, &workprefs, NULL, NULL))
- savestate_state = STATE_DORESTORE;
- _tcscpy (workprefs.statefile, savestate_fname);
- setstatefilename (hDlg);
- break;
- case IDC_INACTIVE_NOJOY:
- if (!ischecked(hDlg, IDC_INACTIVE_NOJOY))
- CheckDlgButton(hDlg, IDC_INACTIVE_PAUSE, BST_UNCHECKED);
- case IDC_INACTIVE_NOSOUND:
- if (!ischecked(hDlg, IDC_INACTIVE_NOSOUND))
- CheckDlgButton(hDlg, IDC_INACTIVE_PAUSE, BST_UNCHECKED);
- case IDC_INACTIVE_PAUSE:
- workprefs.win32_inactive_pause = ischecked (hDlg, IDC_INACTIVE_PAUSE);
- if (workprefs.win32_inactive_pause) {
- CheckDlgButton(hDlg, IDC_INACTIVE_NOSOUND, BST_CHECKED);
- CheckDlgButton(hDlg, IDC_INACTIVE_NOJOY, BST_CHECKED);
- }
- workprefs.win32_inactive_nosound = ischecked(hDlg, IDC_INACTIVE_NOSOUND);
- workprefs.win32_inactive_input = ischecked(hDlg, IDC_INACTIVE_NOJOY) ? 0 : 4;
- enable_for_miscdlg(hDlg);
- break;
- case IDC_ACTIVE_NOSOUND:
- if (!ischecked (hDlg, IDC_ACTIVE_NOSOUND))
- CheckDlgButton (hDlg, IDC_ACTIVE_PAUSE, BST_UNCHECKED);
- case IDC_ACTIVE_PAUSE:
- workprefs.win32_active_nocapture_pause = ischecked (hDlg, IDC_ACTIVE_PAUSE);
- if (workprefs.win32_active_nocapture_pause)
- CheckDlgButton (hDlg, IDC_ACTIVE_NOSOUND, BST_CHECKED);
- workprefs.win32_active_nocapture_nosound = ischecked (hDlg, IDC_ACTIVE_NOSOUND);
- enable_for_miscdlg (hDlg);
- break;
- case IDC_MINIMIZED_NOJOY:
- if (!ischecked(hDlg, IDC_MINIMIZED_NOJOY))
- CheckDlgButton(hDlg, IDC_MINIMIZED_PAUSE, BST_UNCHECKED);
- case IDC_MINIMIZED_NOSOUND:
- if (!ischecked(hDlg, IDC_MINIMIZED_NOSOUND))
- CheckDlgButton(hDlg, IDC_MINIMIZED_PAUSE, BST_UNCHECKED);
- case IDC_MINIMIZED_PAUSE:
- workprefs.win32_iconified_pause = ischecked (hDlg, IDC_MINIMIZED_PAUSE);
- if (workprefs.win32_iconified_pause) {
- CheckDlgButton(hDlg, IDC_MINIMIZED_NOSOUND, BST_CHECKED);
- CheckDlgButton(hDlg, IDC_MINIMIZED_NOJOY, BST_CHECKED);
- }
- workprefs.win32_iconified_nosound = ischecked(hDlg, IDC_MINIMIZED_NOSOUND);
- workprefs.win32_iconified_input = ischecked(hDlg, IDC_MINIMIZED_NOJOY) ? 0 : 4;
- enable_for_miscdlg(hDlg);
- break;
- case IDC_KBLED_USB:
- workprefs.win32_kbledmode = ischecked (hDlg, IDC_KBLED_USB) ? 1 : 0;
- break;
- }
- recursive--;
- return TRUE;
- }
- recursive--;
- return FALSE;
- }
- static INT_PTR CALLBACK MiscDlgProc1 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- currentpage = MISC1_ID;
- return MiscDlgProc (hDlg, msg, wParam, lParam);
- }
- static INT_PTR CALLBACK MiscDlgProc2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- currentpage = MISC2_ID;
- return MiscDlgProc (hDlg, msg, wParam, lParam);
- }
- static const int cpu_ids[] = { IDC_CPU0, IDC_CPU1, IDC_CPU2, IDC_CPU3, IDC_CPU4, IDC_CPU5 };
- static const int fpu_ids[] = { IDC_FPU0, IDC_FPU1, IDC_FPU2, IDC_FPU3 };
- static const int trust_ids[] = { IDC_TRUST0, IDC_TRUST1, IDC_TRUST1, IDC_TRUST1 };
- static void enable_for_cpudlg (HWND hDlg)
- {
- BOOL enable = FALSE, jitenable = FALSE;
- BOOL cpu_based_enable = FALSE;
- ew(hDlg, IDC_SPEED, !workprefs.cpu_cycle_exact);
- ew(hDlg, IDC_COMPATIBLE24, workprefs.cpu_model <= 68030);
- //ew(hDlg, IDC_CS_HOST, !workprefs.cpu_cycle_exact);
- //ew(hDlg, IDC_CS_68000, !workprefs.cpu_cycle_exact);
- //ew(hDlg, IDC_CS_ADJUSTABLE, !workprefs.cpu_cycle_exact);
- ew(hDlg, IDC_CPUIDLE, workprefs.m68k_speed != 0 ? TRUE : FALSE);
- ew(hDlg, IDC_PPC_CPUIDLE, workprefs.ppc_mode != 0);
- ew(hDlg, IDC_SPEED_x86, is_x86_cpu(&workprefs));
- ew(hDlg, IDC_CPUTEXT_x86, is_x86_cpu(&workprefs));
- #if !defined(CPUEMU_0) || defined(CPUEMU_68000_ONLY)
- ew(hDlg, IDC_CPU1, FALSE);
- ew(hDlg, IDC_CPU2, FALSE);
- ew(hDlg, IDC_CPU3, FALSE);
- ew(hDlg, IDC_CPU4, FALSE);
- ew(hDlg, IDC_CPU5, FALSE);
- #endif
- cpu_based_enable = workprefs.cpu_model >= 68020 && workprefs.address_space_24 == 0;
- jitenable = cpu_based_enable && !workprefs.mmu_model;
- #ifndef JIT
- jitenable = FALSE;
- #endif
- enable = jitenable && workprefs.cachesize;
- ew(hDlg, IDC_FPU_MODE, workprefs.fpu_model != 0);
- ew(hDlg, IDC_TRUST0, enable);
- ew(hDlg, IDC_TRUST1, enable);
- ew(hDlg, IDC_HARDFLUSH, enable);
- ew(hDlg, IDC_CONSTJUMP, enable);
- ew(hDlg, IDC_JITFPU, enable);
- ew(hDlg, IDC_JITCRASH, enable);
- ew(hDlg, IDC_NOFLAGS, enable);
- ew(hDlg, IDC_CS_CACHE_TEXT, enable);
- ew(hDlg, IDC_CACHE, enable);
- ew(hDlg, IDC_JITENABLE, jitenable);
- ew(hDlg, IDC_COMPATIBLE, !workprefs.cpu_memory_cycle_exact && !(workprefs.cachesize && workprefs.cpu_model >= 68040));
- ew(hDlg, IDC_COMPATIBLE_FPU, workprefs.fpu_model > 0);
- ew(hDlg, IDC_FPU_UNIMPLEMENTED, workprefs.fpu_model && !workprefs.cachesize);
- ew(hDlg, IDC_CPU_UNIMPLEMENTED, workprefs.cpu_model == 68060 && !workprefs.cachesize);
- #if 0
- ew(hDlg, IDC_CPU_MULTIPLIER, workprefs.cpu_cycle_exact);
- #endif
- ew(hDlg, IDC_CPU_FREQUENCY, (workprefs.cpu_cycle_exact || workprefs.cpu_compatible) && workprefs.m68k_speed >= 0);
- ew(hDlg, IDC_CPU_FREQUENCY2, workprefs.cpu_cycle_exact && !workprefs.cpu_clock_multiplier && workprefs.m68k_speed >= 0);
- ew(hDlg, IDC_FPU1, workprefs.cpu_model < 68040 && (workprefs.cpu_model >= 68020 || !workprefs.cpu_compatible));
- ew(hDlg, IDC_FPU2, workprefs.cpu_model < 68040 && (workprefs.cpu_model >= 68020 || !workprefs.cpu_compatible));
- ew(hDlg, IDC_FPU3, workprefs.cpu_model >= 68040);
- ew(hDlg, IDC_MMUENABLEEC, workprefs.cpu_model >= 68030 && workprefs.cachesize == 0);
- ew(hDlg, IDC_MMUENABLE, workprefs.cpu_model >= 68030 && workprefs.cachesize == 0);
- ew(hDlg, IDC_CPUDATACACHE, workprefs.cpu_model >= 68030 && workprefs.cachesize == 0 && workprefs.cpu_compatible);
- ew(hDlg, IDC_CPU_PPC, workprefs.cpu_model >= 68040 && (workprefs.ppc_mode == 1 || (workprefs.ppc_mode == 0 && !is_ppc_cpu(&workprefs))));
- SendDlgItemMessage(hDlg, IDC_SPEED, TBM_SETRANGE, TRUE, workprefs.m68k_speed < 0 || (workprefs.cpu_memory_cycle_exact && !workprefs.cpu_cycle_exact) ? MAKELONG(-9, 0) : MAKELONG(-9, 50));
- SendDlgItemMessage(hDlg, IDC_SPEED, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage(hDlg, IDC_SPEED_x86, TBM_SETRANGE, TRUE, MAKELONG(0, 1000));
- SendDlgItemMessage(hDlg, IDC_SPEED_x86, TBM_SETPAGESIZE, 0, 10);
- }
- static double getcpufreq (int m)
- {
- double f;
- f = workprefs.ntscmode ? 28636360.0 : 28375160.0;
- return f * (m >> 8) / 8.0;
- }
- static void values_to_cpudlg(HWND hDlg, WPARAM wParam)
- {
- TCHAR buffer[8] = _T("");
- int cpu;
- SendDlgItemMessage(hDlg, IDC_SPEED_x86, TBM_SETPOS, TRUE, (int)(workprefs.x86_speed_throttle / 100));
- _stprintf(buffer, _T("%+d%%"), (int)(workprefs.x86_speed_throttle / 10));
- SetDlgItemText(hDlg, IDC_CPUTEXT_x86, buffer);
- SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, (int)(workprefs.m68k_speed_throttle / 100));
- _stprintf (buffer, _T("%+d%%"), (int)(workprefs.m68k_speed_throttle / 10));
- SetDlgItemText (hDlg, IDC_CPUTEXT, buffer);
- CheckDlgButton (hDlg, IDC_COMPATIBLE, workprefs.cpu_compatible);
- CheckDlgButton (hDlg, IDC_COMPATIBLE24, workprefs.address_space_24);
- CheckDlgButton (hDlg, IDC_CPUDATACACHE, workprefs.cpu_data_cache);
- CheckDlgButton (hDlg, IDC_COMPATIBLE_FPU, workprefs.fpu_strict);
- CheckDlgButton (hDlg, IDC_FPU_UNIMPLEMENTED, !workprefs.fpu_no_unimplemented || workprefs.cachesize);
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_SETCURSEL, workprefs.fpu_mode < 0 ? 1 : (workprefs.fpu_mode > 0 ? 2 : 0), 0);
- CheckDlgButton (hDlg, IDC_CPU_UNIMPLEMENTED, !workprefs.int_no_unimplemented || workprefs.cachesize);
- SendDlgItemMessage (hDlg, IDC_CPUIDLE, TBM_SETPOS, TRUE, workprefs.cpu_idle == 0 ? 0 : 12 - workprefs.cpu_idle / 15);
- _stprintf(buffer, _T("%d%%"), (workprefs.cpu_idle == 0 ? 0 : 12 - workprefs.cpu_idle / 15) * 10);
- SetDlgItemText(hDlg, IDC_CPUIDLETEXT, buffer);
- SendDlgItemMessage (hDlg, IDC_PPC_CPUIDLE, TBM_SETPOS, TRUE, workprefs.ppc_cpu_idle);
- cpu = (workprefs.cpu_model - 68000) / 10;
- if (cpu >= 5)
- cpu--;
- CheckRadioButton (hDlg, IDC_CPU0, IDC_CPU5, cpu_ids[cpu]);
- CheckRadioButton (hDlg, IDC_FPU0, IDC_FPU3, fpu_ids[workprefs.fpu_model == 0 ? 0 : (workprefs.fpu_model == 68881 ? 1 : (workprefs.fpu_model == 68882 ? 2 : 3))]);
- if (workprefs.m68k_speed < 0)
- CheckRadioButton(hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_HOST);
- else if (workprefs.m68k_speed >= 0)
- CheckRadioButton(hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_68000);
- CheckRadioButton (hDlg, IDC_TRUST0, IDC_TRUST1, trust_ids[workprefs.comptrustbyte]);
- int idx = 0;
- for (int i = 0; i < MAX_CACHE_SIZE; i++) {
- if (workprefs.cachesize >= (1024 << i) && workprefs.cachesize < (1024 << i) * 2) {
- idx = i + 1;
- break;
- }
- }
- SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETPOS, TRUE, idx);
- _stprintf (buffer, _T("%d MB"), workprefs.cachesize / 1024 );
- SetDlgItemText (hDlg, IDC_CACHETEXT, buffer);
- CheckDlgButton(hDlg, IDC_JITCRASH, workprefs.comp_catchfault);
- CheckDlgButton(hDlg, IDC_NOFLAGS, workprefs.compnf);
- CheckDlgButton(hDlg, IDC_JITFPU, workprefs.compfpu);
- CheckDlgButton(hDlg, IDC_HARDFLUSH, workprefs.comp_hardflush);
- CheckDlgButton(hDlg, IDC_CONSTJUMP, workprefs.comp_constjump);
- CheckDlgButton(hDlg, IDC_JITENABLE, workprefs.cachesize > 0);
- bool mmu = ((workprefs.cpu_model == 68060 && workprefs.mmu_model == 68060) ||
- (workprefs.cpu_model == 68040 && workprefs.mmu_model == 68040) ||
- (workprefs.cpu_model == 68030 && workprefs.mmu_model == 68030)) &&
- workprefs.cachesize == 0;
- CheckRadioButton (hDlg, IDC_MMUENABLEOFF, IDC_MMUENABLE, mmu == 0 ? IDC_MMUENABLEOFF : (mmu && workprefs.mmu_ec) ? IDC_MMUENABLEEC : IDC_MMUENABLE);
- CheckDlgButton(hDlg, IDC_CPU_PPC, workprefs.ppc_mode || is_ppc_cpu(&workprefs));
- }
- static void values_from_cpudlg(HWND hDlg, WPARAM wParam)
- {
- int newcpu, oldcpu, newfpu, newtrust, oldcache, jitena, idx;
- static int cachesize_prev, trust_prev;
- workprefs.cpu_compatible = workprefs.cpu_memory_cycle_exact | (ischecked (hDlg, IDC_COMPATIBLE) ? 1 : 0);
- workprefs.fpu_strict = ischecked (hDlg, IDC_COMPATIBLE_FPU) ? 1 : 0;
- workprefs.fpu_no_unimplemented = ischecked (hDlg, IDC_FPU_UNIMPLEMENTED) ? 0 : 1;
- workprefs.int_no_unimplemented = ischecked (hDlg, IDC_CPU_UNIMPLEMENTED) ? 0 : 1;
- workprefs.address_space_24 = ischecked (hDlg, IDC_COMPATIBLE24) ? 1 : 0;
- workprefs.m68k_speed = ischecked (hDlg, IDC_CS_HOST) ? -1 : 0;
- workprefs.m68k_speed_throttle = SendMessage (GetDlgItem (hDlg, IDC_SPEED), TBM_GETPOS, 0, 0) * 100;
- if (workprefs.m68k_speed_throttle > 0 && workprefs.m68k_speed < 0)
- workprefs.m68k_speed_throttle = 0;
- workprefs.x86_speed_throttle = SendMessage(GetDlgItem(hDlg, IDC_SPEED_x86), TBM_GETPOS, 0, 0) * 100;
- idx = SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_GETCURSEL, 0, 0);
- if (idx == 0)
- workprefs.fpu_mode = 0;
- if (idx == 1)
- workprefs.fpu_mode = -1;
- if (idx == 2)
- workprefs.fpu_mode = 1;
- newcpu = ischecked (hDlg, IDC_CPU0) ? 68000
- : ischecked (hDlg, IDC_CPU1) ? 68010
- : ischecked (hDlg, IDC_CPU2) ? 68020
- : ischecked (hDlg, IDC_CPU3) ? 68030
- : ischecked (hDlg, IDC_CPU4) ? 68040
- : ischecked (hDlg, IDC_CPU5) ? 68060 : 0;
- newfpu = ischecked (hDlg, IDC_FPU0) ? 0
- : ischecked (hDlg, IDC_FPU1) ? 1
- : ischecked (hDlg, IDC_FPU2) ? 2
- : ischecked (hDlg, IDC_FPU3) ? 3 : 0;
- /* When switching away from 68000, disable 24 bit addressing. */
- oldcpu = workprefs.cpu_model;
- if (workprefs.cpu_model != newcpu && newcpu <= 68010)
- newfpu = 0;
- workprefs.cpu_model = newcpu;
- workprefs.mmu_model = 0;
- workprefs.mmu_ec = false;
- workprefs.cpu_data_cache = false;
- switch(newcpu)
- {
- case 68000:
- case 68010:
- workprefs.fpu_model = newfpu == 0 ? 0 : (newfpu == 2 ? 68882 : 68881);
- if (workprefs.cpu_compatible || workprefs.cpu_memory_cycle_exact)
- workprefs.fpu_model = 0;
- if (newcpu != oldcpu)
- workprefs.address_space_24 = 1;
- break;
- case 68020:
- workprefs.fpu_model = newfpu == 0 ? 0 : (newfpu == 2 ? 68882 : 68881);
- break;
- case 68030:
- if (newcpu != oldcpu)
- workprefs.address_space_24 = 0;
- workprefs.fpu_model = newfpu == 0 ? 0 : (newfpu == 2 ? 68882 : 68881);
- workprefs.mmu_ec = ischecked(hDlg, IDC_MMUENABLEEC);
- workprefs.mmu_model = workprefs.mmu_ec || ischecked (hDlg, IDC_MMUENABLE) ? 68030 : 0;
- if (workprefs.cpu_compatible)
- workprefs.cpu_data_cache = ischecked (hDlg, IDC_CPUDATACACHE);
- break;
- case 68040:
- workprefs.fpu_model = newfpu ? 68040 : 0;
- workprefs.address_space_24 = 0;
- if (workprefs.fpu_model)
- workprefs.fpu_model = 68040;
- workprefs.mmu_ec = ischecked(hDlg, IDC_MMUENABLEEC);
- workprefs.mmu_model = workprefs.mmu_ec || ischecked (hDlg, IDC_MMUENABLE) ? 68040 : 0;
- if (workprefs.cpu_compatible)
- workprefs.cpu_data_cache = ischecked (hDlg, IDC_CPUDATACACHE);
- break;
- case 68060:
- workprefs.fpu_model = newfpu ? 68060 : 0;
- workprefs.address_space_24 = 0;
- workprefs.mmu_ec = ischecked(hDlg, IDC_MMUENABLEEC);
- workprefs.mmu_model = workprefs.mmu_ec || ischecked (hDlg, IDC_MMUENABLE) ? 68060 : 0;
- if (workprefs.cpu_compatible)
- workprefs.cpu_data_cache = ischecked (hDlg, IDC_CPUDATACACHE);
- break;
- }
- if (newcpu != oldcpu && workprefs.cpu_compatible) {
- int idx = 0;
- if (newcpu <= 68010) {
- workprefs.cpu_clock_multiplier = 2 * 256;
- idx = 1;
- } else if (newcpu == 68020) {
- workprefs.cpu_clock_multiplier = 4 * 256;
- idx = 2;
- } else {
- workprefs.cpu_clock_multiplier = 8 * 256;
- idx = 3;
- }
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY, CB_SETCURSEL, idx, 0);
- }
- newtrust = ischecked (hDlg, IDC_TRUST0) ? 0 : 1;
- workprefs.comptrustbyte = newtrust;
- workprefs.comptrustword = newtrust;
- workprefs.comptrustlong = newtrust;
- workprefs.comptrustnaddr= newtrust;
- workprefs.comp_catchfault = ischecked(hDlg, IDC_JITCRASH);
- workprefs.compnf = ischecked(hDlg, IDC_NOFLAGS);
- workprefs.compfpu = ischecked(hDlg, IDC_JITFPU);
- workprefs.comp_hardflush = ischecked(hDlg, IDC_HARDFLUSH);
- workprefs.comp_constjump = ischecked(hDlg, IDC_CONSTJUMP);
- #ifdef JIT
- oldcache = workprefs.cachesize;
- jitena = (ischecked (hDlg, IDC_JITENABLE) ? 1 : 0) && !workprefs.address_space_24 && workprefs.cpu_model >= 68020;
- idx = SendMessage (GetDlgItem (hDlg, IDC_CACHE), TBM_GETPOS, 0, 0);
- workprefs.cachesize = 1024 << idx;
- if (workprefs.cachesize <= 1024)
- workprefs.cachesize = 0;
- else
- workprefs.cachesize /= 2;
- if (!jitena) {
- cachesize_prev = workprefs.cachesize;
- trust_prev = workprefs.comptrustbyte;
- workprefs.cachesize = 0;
- } else if (jitena && !oldcache) {
- workprefs.cachesize = MAX_JIT_CACHE;
- workprefs.cpu_cycle_exact = false;
- workprefs.cpu_memory_cycle_exact = false;
- if (!cachesize_prev)
- trust_prev = 0;
- if (cachesize_prev) {
- workprefs.cachesize = cachesize_prev;
- }
- workprefs.comptrustbyte = trust_prev;
- workprefs.comptrustword = trust_prev;
- workprefs.comptrustlong = trust_prev;
- workprefs.comptrustnaddr = trust_prev;
- if (workprefs.fpu_mode > 0) {
- workprefs.compfpu = false;
- setchecked(hDlg, IDC_JITFPU, false);
- }
- }
- if (!workprefs.cachesize) {
- setchecked (hDlg, IDC_JITENABLE, false);
- }
- if (workprefs.cachesize && workprefs.compfpu && workprefs.fpu_mode > 0) {
- workprefs.fpu_mode = 0;
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_SETCURSEL, 0, 0);
- }
- if (oldcache == 0 && workprefs.cachesize > 0) {
- canbang = 1;
- }
- if (workprefs.cachesize && workprefs.cpu_model >= 68040) {
- workprefs.cpu_compatible = false;
- }
- #endif
- if (ischecked(hDlg, IDC_CPU_PPC)) {
- if (workprefs.ppc_mode == 0)
- workprefs.ppc_mode = 1;
- if (workprefs.ppc_mode == 1 && workprefs.cpu_model < 68040)
- workprefs.ppc_mode = 0;
- } else if (!ischecked(hDlg, IDC_CPU_PPC) && workprefs.ppc_mode == 1) {
- workprefs.ppc_mode = 0;
- }
- workprefs.cpu_idle = SendMessage (GetDlgItem (hDlg, IDC_CPUIDLE), TBM_GETPOS, 0, 0);
- if (workprefs.cpu_idle > 0)
- workprefs.cpu_idle = (12 - workprefs.cpu_idle) * 15;
- workprefs.ppc_cpu_idle = SendMessage (GetDlgItem (hDlg, IDC_PPC_CPUIDLE), TBM_GETPOS, 0, 0);
- if (pages[KICKSTART_ID])
- SendMessage (pages[KICKSTART_ID], WM_USER, 0, 0);
- if (pages[DISPLAY_ID])
- SendMessage (pages[DISPLAY_ID], WM_USER, 0, 0);
- if (pages[MEMORY_ID])
- SendMessage (pages[MEMORY_ID], WM_USER, 0, 0);
- idx = SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY, CB_GETCURSEL, 0, 0);
- if (idx != CB_ERR) {
- int m = workprefs.cpu_clock_multiplier;
- workprefs.cpu_frequency = 0;
- workprefs.cpu_clock_multiplier = 0;
- if (idx < 4) {
- workprefs.cpu_clock_multiplier = (1 << 8) << idx;
- if (workprefs.cpu_cycle_exact || workprefs.cpu_compatible) {
- TCHAR txt[20];
- double f = getcpufreq(workprefs.cpu_clock_multiplier);
- _stprintf(txt, _T("%.6f"), f / 1000000.0);
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)txt);
- } else {
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)_T(""));
- }
- } else if (workprefs.cpu_cycle_exact) {
- TCHAR txt[20];
- txt[0] = 0;
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY2, WM_GETTEXT, (WPARAM)sizeof(txt) / sizeof(TCHAR), (LPARAM)txt);
- workprefs.cpu_clock_multiplier = 0;
- workprefs.cpu_frequency = (int)(_tstof(txt) * 1000000.0);
- if (workprefs.cpu_frequency < 1 * 1000000)
- workprefs.cpu_frequency = 0;
- if (workprefs.cpu_frequency >= 99 * 1000000)
- workprefs.cpu_frequency = 0;
- if (!workprefs.cpu_frequency) {
- workprefs.cpu_frequency = (int)(getcpufreq(m) * 1000000.0);
- }
- }
- }
- }
- static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- int idx;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- recursive++;
- pages[CPU_ID] = hDlg;
- currentpage = CPU_ID;
- SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETRANGE, TRUE, MAKELONG (MIN_CACHE_SIZE, MAX_CACHE_SIZE));
- SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_CPUIDLE, TBM_SETRANGE, TRUE, MAKELONG (0, 10));
- SendDlgItemMessage (hDlg, IDC_CPUIDLE, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_PPC_CPUIDLE, TBM_SETRANGE, TRUE, MAKELONG (0, 10));
- SendDlgItemMessage (hDlg, IDC_PPC_CPUIDLE, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("1x"));
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("2x (A500)"));
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("4x (A1200)"));
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("8x"));
- if (workprefs.cpu_cycle_exact) {
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY, CB_ADDSTRING, 0, (LPARAM)_T("Custom"));
- }
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_ADDSTRING, 0, (LPARAM)_T("Host (64-bit)"));
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_ADDSTRING, 0, (LPARAM)_T("Host (80-bit)"));
- SendDlgItemMessage(hDlg, IDC_FPU_MODE, CB_ADDSTRING, 0, (LPARAM)_T("Softfloat (80-bit)"));
- idx = 4;
- if (workprefs.cpu_clock_multiplier >= 1 << 8) {
- idx = 0;
- while (idx < 3) {
- if (workprefs.cpu_clock_multiplier <= (1 << 8) << idx)
- break;
- idx++;
- }
- } else if (workprefs.cpu_clock_multiplier == 0 && workprefs.cpu_frequency == 0 && workprefs.cpu_model <= 68010) {
- idx = 1; // A500
- } else if (workprefs.cpu_clock_multiplier == 0 && workprefs.cpu_frequency == 0 && workprefs.cpu_model >= 68020) {
- idx = 2; // A1200
- }
- if (!workprefs.cpu_cycle_exact) {
- workprefs.cpu_frequency = 0;
- if (!workprefs.cpu_clock_multiplier && (idx == 1 || idx == 2)) {
- workprefs.cpu_clock_multiplier = (1 << idx) << 8;
- }
- } else {
- if (!workprefs.cpu_frequency && (idx == 1 || idx == 2)) {
- workprefs.cpu_clock_multiplier = (1 << idx) << 8;
- }
- }
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY, CB_SETCURSEL, idx, 0);
- if (!workprefs.cpu_clock_multiplier) {
- TCHAR txt[20];
- _stprintf (txt, _T("%.6f"), workprefs.cpu_frequency / 1000000.0);
- SendDlgItemMessage (hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)txt);
- } else {
- TCHAR txt[20];
- double f = getcpufreq(workprefs.cpu_clock_multiplier);
- _stprintf(txt, _T("%.6f"), f / 1000000.0);
- SendDlgItemMessage(hDlg, IDC_CPU_FREQUENCY2, WM_SETTEXT, 0, (LPARAM)txt);
- }
- recursive--;
- case WM_USER:
- recursive++;
- enable_for_cpudlg (hDlg);
- values_to_cpudlg (hDlg, wParam);
- recursive--;
- return TRUE;
- case WM_COMMAND:
- if (recursive > 0)
- break;
- if (currentpage == CPU_ID) {
- recursive++;
- values_from_cpudlg(hDlg, wParam);
- enable_for_cpudlg(hDlg);
- values_to_cpudlg(hDlg, wParam);
- recursive--;
- }
- break;
- case WM_HSCROLL:
- if (currentpage == CPU_ID) {
- recursive++;
- values_from_cpudlg(hDlg, wParam);
- enable_for_cpudlg(hDlg);
- values_to_cpudlg(hDlg, wParam);
- recursive--;
- }
- break;
- }
- return FALSE;
- }
- static void enable_for_sounddlg (HWND hDlg)
- {
- int numdevs;
- numdevs = enumerate_sound_devices ();
- if (numdevs == 0)
- ew (hDlg, IDC_SOUNDCARDLIST, FALSE);
- else
- ew (hDlg, IDC_SOUNDCARDLIST, workprefs.produce_sound);
- ew (hDlg, IDC_FREQUENCY, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDFREQ, workprefs.produce_sound ? TRUE : FALSE);
- ew (hDlg, IDC_SOUNDSTEREO, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDINTERPOLATION, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDVOLUME, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDVOLUME2, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDVOLUMEEXT, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDVOLUMEEXT2, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDSTEREOSEP, workprefs.sound_stereo > 0 && workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDSTEREOMIX, workprefs.sound_stereo > 0 && workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDBUFFERMEM, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDBUFFERRAM, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDADJUST, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDADJUSTNUM, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDBUFFERTEXT, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVE, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVESELECT, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVEVOLUME, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVEVOLUME2, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVEVOLUMEX, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDDRIVEVOLUMEX2, workprefs.produce_sound);
- ew (hDlg, IDC_AUDIOSYNC, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDFILTER, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDSWAP, workprefs.produce_sound);
- ew (hDlg, IDC_SOUNDCALIBRATE, workprefs.produce_sound && full_property_sheet);
- }
- static int exact_log2 (int v)
- {
- int l = 0;
- while ((v >>= 1) != 0)
- l++;
- return l;
- }
- static TCHAR *drivesounds;
- static void sound_loaddrivesamples (void)
- {
- WIN32_FIND_DATA fd;
- HANDLE h;
- TCHAR *p;
- int len = 0;
- TCHAR dirname[1024];
- free (drivesounds);
- p = drivesounds = 0;
- get_plugin_path (dirname, sizeof dirname / sizeof (TCHAR), _T("floppysounds"));
- _tcscat (dirname, _T("*.wav"));
- h = FindFirstFile (dirname, &fd);
- if (h == INVALID_HANDLE_VALUE)
- return;
- for (;;) {
- if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- TCHAR *name = fd.cFileName;
- if (_tcslen (name) > _tcslen (DS_NAME_CLICK) + 4 && !_tcsncmp (name, DS_NAME_CLICK, _tcslen (DS_NAME_CLICK))) {
- if (p - drivesounds < 1000) {
- TCHAR *oldp = p;
- len += 2000;
- drivesounds = p = xrealloc (TCHAR, drivesounds, len);
- if (oldp) {
- do {
- p = p + _tcslen (p) + 1;
- } while (p[0]);
- }
- }
- _tcscpy (p, name + _tcslen (DS_NAME_CLICK));
- p[_tcslen (name + _tcslen (DS_NAME_CLICK)) - 4] = 0;
- p += _tcslen (p);
- *p++ = 0;
- *p = 0;
- }
- }
- if (!FindNextFile (h, &fd))
- break;
- }
- FindClose (h);
- }
- extern int soundpercent;
- static const int sndbufsizes[] = { 1024, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 32768, 65536, -1 };
- static int *volumeselection, volumeselectionindex;
- static int sounddrivesel;
- static int getsoundbufsizeindex (int size)
- {
- int idx;
- if (size < sndbufsizes[0])
- return 0;
- for (idx = 0; sndbufsizes[idx] < size && sndbufsizes[idx + 1] >= 0 ; idx++);
- return idx + 1;
- }
- static void update_soundgui (HWND hDlg)
- {
- int bufsize;
- TCHAR txt[20];
- bufsize = getsoundbufsizeindex (workprefs.sound_maxbsiz);
- if (bufsize <= 0) {
- _tcscpy(txt, _T("Min"));
- } else {
- _stprintf (txt, _T("%d"), bufsize);
- }
- SetDlgItemText (hDlg, IDC_SOUNDBUFFERMEM, txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.sound_volume_master);
- _stprintf (txt, _T("%d%%"), 100 - workprefs.sound_volume_master);
- SetDlgItemText (hDlg, IDC_SOUNDVOLUME2, txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPOS, TRUE, 100 - (*volumeselection));
- _stprintf (txt, _T("%d%%"), 100 - (*volumeselection));
- SetDlgItemText (hDlg, IDC_SOUNDVOLUMEEXT2, txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.dfxclickvolume_empty[sounddrivesel]);
- _stprintf (txt, _T("%d%%"), 100 - workprefs.dfxclickvolume_empty[sounddrivesel]);
- SetDlgItemText (hDlg, IDC_SOUNDDRIVEVOLUME2, txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUMEX, TBM_SETPOS, TRUE, 100 - workprefs.dfxclickvolume_disk[sounddrivesel]);
- _stprintf (txt, _T("%d%%"), 100 - workprefs.dfxclickvolume_disk[sounddrivesel]);
- SetDlgItemText (hDlg, IDC_SOUNDDRIVEVOLUMEX2, txt);
- }
- static int soundfreqs[] = { 11025, 15000, 22050, 32000, 44100, 48000, 0 };
- static int sounddrivers[] = { IDC_SOUND_DS, IDC_SOUND_WASAPI, IDC_SOUND_OPENAL, IDC_SOUND_PORTAUDIO, 0 };
- static void values_to_sounddlg (HWND hDlg)
- {
- int which_button;
- int sound_freq = workprefs.sound_freq;
- int produce_sound = workprefs.produce_sound;
- int stereo = workprefs.sound_stereo;
- TCHAR txt[100], txt2[100], *p;
- int i, selected;
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_SOUND_FILTER_OFF, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED_E, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_AGA, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_A500, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
- i = 0;
- switch (workprefs.sound_filter)
- {
- case 0:
- i = 0;
- break;
- case 1:
- i = workprefs.sound_filter_type ? 2 : 1;
- break;
- case 2:
- i = workprefs.sound_filter_type ? 4 : 3;
- break;
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_SETCURSEL, i, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_SOUND_MONO, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_STEREO, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_STEREO2, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_4CHANNEL, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_CLONED51, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_51, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_SETCURSEL, workprefs.sound_stereo, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- WIN32GUI_LoadUIString (IDS_SOUND_SWAP_PAULA, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_SWAP_AHI, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_SOUND_SWAP_BOTH, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_SETCURSEL,
- workprefs.sound_stereo_swap_paula + workprefs.sound_stereo_swap_ahi * 2, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_RESETCONTENT, 0, 0);
- for (i = 10; i >= 0; i--) {
- _stprintf (txt, _T("%d%%"), i * 10);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_ADDSTRING, 0, (LPARAM)txt);
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_SETCURSEL, 10 - workprefs.sound_stereo_separation, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_ADDSTRING, 0, (LPARAM)_T("-"));
- for (i = 0; i < 10; i++) {
- _stprintf (txt, _T("%d"), i + 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_ADDSTRING, 0, (LPARAM)txt);
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_SETCURSEL,
- workprefs.sound_mixed_stereo_delay > 0 ? workprefs.sound_mixed_stereo_delay : 0, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_DISABLED, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)txt);
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)_T("Anti"));
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)_T("Sinc"));
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)_T("RH"));
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)_T("Crux"));
- SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_SETCURSEL, workprefs.sound_interpol, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_RESETCONTENT, 0, 0);
- i = 0;
- selected = -1;
- while (soundfreqs[i]) {
- _stprintf (txt, _T("%d"), soundfreqs[i]);
- SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_ADDSTRING, 0, (LPARAM)txt);
- i++;
- }
- _stprintf (txt, _T("%d"), workprefs.sound_freq);
- SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_SETTEXT, 0, (LPARAM)txt);
- switch (workprefs.produce_sound)
- {
- case 0: which_button = IDC_SOUND0; break;
- case 1: which_button = IDC_SOUND1; break;
- case 2: case 3: which_button = IDC_SOUND2; break;
- }
- CheckRadioButton (hDlg, IDC_SOUND0, IDC_SOUND2, which_button);
- CheckDlgButton (hDlg, IDC_SOUND_AUTO, workprefs.sound_auto);
- CheckDlgButton(hDlg, IDC_SOUND_CDPAULAMIX, workprefs.sound_cdaudio);
- CheckDlgButton(hDlg, IDC_SOUND_VOLCNT, workprefs.sound_volcnt);
- if (workprefs.sound_maxbsiz < SOUND_BUFFER_MULTIPLIER)
- workprefs.sound_maxbsiz = 0;
- SendDlgItemMessage (hDlg, IDC_SOUNDBUFFERRAM, TBM_SETPOS, TRUE, getsoundbufsizeindex (workprefs.sound_maxbsiz));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPOS, TRUE, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_SETCURSEL, workprefs.win32_soundcard, 0);
- sounddrivesel = SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_GETCURSEL, 0, 0);
- if (sounddrivesel < 0)
- sounddrivesel = 0;
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_RESETCONTENT, 0, 0);
- for (i = 0; i < 4; i++) {
- _stprintf (txt, _T("DF%d:"), i);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_ADDSTRING, 0, (LPARAM)txt);
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_SETCURSEL, sounddrivesel, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_DRIVESOUND_NONE, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt);
- WIN32GUI_LoadUIString (IDS_DRIVESOUND_DEFAULT_A500, txt, sizeof (txt) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt);
- driveclick_fdrawcmd_detect ();
- if (driveclick_pcdrivemask) {
- for (i = 0; i < 2; i++) {
- WIN32GUI_LoadUIString (IDS_DRIVESOUND_PC_FLOPPY, txt, sizeof (txt) / sizeof (TCHAR));
- _stprintf (txt2, txt, 'A' + i);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt2);
- }
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_SETCURSEL, 0, 0);
- p = drivesounds;
- if (p) {
- while (p[0]) {
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)p);
- p += _tcslen (p) + 1;
- }
- }
- if (workprefs.floppyslots[sounddrivesel].dfxclick < 0) {
- p = drivesounds;
- i = DS_BUILD_IN_SOUNDS + (driveclick_pcdrivemask ? 2 : 0) + 1;
- while (p && p[0]) {
- if (!_tcsicmp (p, workprefs.floppyslots[sounddrivesel].dfxclickexternal)) {
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_SETCURSEL, i, 0);
- break;
- }
- i++;
- p += _tcslen (p) + 1;
- }
- } else {
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_SETCURSEL, workprefs.floppyslots[sounddrivesel].dfxclick, 0);
- }
- update_soundgui (hDlg);
- }
- static void values_from_sounddlg (HWND hDlg)
- {
- TCHAR txt[10];
- LRESULT idx;
- int soundcard, i;
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_GETCURSEL, 0, 0);
- if (idx >= 0) {
- workprefs.sound_freq = soundfreqs[idx];
- } else {
- txt[0] = 0;
- SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
- workprefs.sound_freq = _tstol (txt);
- }
- if (workprefs.sound_freq < 8000)
- workprefs.sound_freq = 8000;
- if (workprefs.sound_freq > 768000)
- workprefs.sound_freq = 768000;
- workprefs.produce_sound = (ischecked (hDlg, IDC_SOUND0) ? 0
- : ischecked (hDlg, IDC_SOUND1) ? 1 : 3);
- workprefs.sound_auto = ischecked (hDlg, IDC_SOUND_AUTO);
- workprefs.sound_cdaudio = ischecked(hDlg, IDC_SOUND_CDPAULAMIX);
- workprefs.sound_volcnt = ischecked(hDlg, IDC_SOUND_VOLCNT);
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_GETCURSEL, 0, 0);
- if (idx != CB_ERR)
- workprefs.sound_stereo = idx;
- workprefs.sound_stereo_separation = 0;
- workprefs.sound_mixed_stereo_delay = 0;
- if (workprefs.sound_stereo > 0) {
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_GETCURSEL, 0, 0);
- if (idx != CB_ERR) {
- if (idx > 0)
- workprefs.sound_mixed_stereo_delay = -1;
- workprefs.sound_stereo_separation = 10 - idx;
- }
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_GETCURSEL, 0, 0);
- if (idx != CB_ERR && idx > 0)
- workprefs.sound_mixed_stereo_delay = idx;
- }
- workprefs.sound_interpol = SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_GETCURSEL, 0, 0);
- soundcard = SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_GETCURSEL, 0, 0L);
- if (soundcard != workprefs.win32_soundcard && soundcard != CB_ERR) {
- workprefs.win32_soundcard = soundcard;
- update_soundgui (hDlg);
- }
- switch (SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_GETCURSEL, 0, 0))
- {
- case 0:
- workprefs.sound_filter = FILTER_SOUND_OFF;
- break;
- case 1:
- workprefs.sound_filter = FILTER_SOUND_EMUL;
- workprefs.sound_filter_type = 0;
- break;
- case 2:
- workprefs.sound_filter = FILTER_SOUND_EMUL;
- workprefs.sound_filter_type = 1;
- break;
- case 3:
- workprefs.sound_filter = FILTER_SOUND_ON;
- workprefs.sound_filter_type = 0;
- break;
- case 4:
- workprefs.sound_filter = FILTER_SOUND_ON;
- workprefs.sound_filter_type = 1;
- break;
- }
- workprefs.sound_stereo_swap_paula = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 1) ? 1 : 0;
- workprefs.sound_stereo_swap_ahi = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 2) ? 1 : 0;
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_GETCURSEL, 0, 0);
- if (idx != volumeselectionindex) {
- volumeselectionindex = idx;
- if (volumeselectionindex < 0 || volumeselectionindex > 4)
- volumeselectionindex = 0;
- if (volumeselectionindex == 1)
- volumeselection = &workprefs.sound_volume_cd;
- else if (volumeselectionindex == 2)
- volumeselection = &workprefs.sound_volume_board;
- else if (volumeselectionindex == 3)
- volumeselection = &workprefs.sound_volume_midi;
- else if (volumeselectionindex == 4)
- volumeselection = &workprefs.sound_volume_genlock;
- else
- volumeselection = &workprefs.sound_volume_paula;
- update_soundgui (hDlg);
- }
- for (i = 0; sounddrivers[i]; i++) {
- int old = sounddrivermask;
- sounddrivermask &= ~(1 << i);
- if (ischecked (hDlg, sounddrivers[i]))
- sounddrivermask |= 1 << i;
- if (old != sounddrivermask)
- regsetint (NULL, _T("SoundDriverMask"), sounddrivermask);
- }
- idx = SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_GETCURSEL, 0, 0);
- if (idx != CB_ERR && idx >= 0) {
- LRESULT res = SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_GETCURSEL, 0, 0);
- if (res != CB_ERR && res >= 0) {
- int xtra = driveclick_pcdrivemask ? 2 : 0;
- if (res > DS_BUILD_IN_SOUNDS + xtra) {
- int j = res - (DS_BUILD_IN_SOUNDS + xtra + 1);
- TCHAR *p = drivesounds;
- while (j-- > 0)
- p += _tcslen (p) + 1;
- workprefs.floppyslots[idx].dfxclick = -1;
- _tcscpy (workprefs.floppyslots[idx].dfxclickexternal, p);
- } else {
- workprefs.floppyslots[idx].dfxclick = res;
- workprefs.floppyslots[idx].dfxclickexternal[0] = 0;
- }
- }
- }
- }
- static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- int numdevs;
- int card, i;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- {
- recursive++;
- sound_loaddrivesamples ();
- SendDlgItemMessage (hDlg, IDC_SOUNDBUFFERRAM, TBM_SETRANGE, TRUE, MAKELONG (MIN_SOUND_MEM, MAX_SOUND_MEM));
- SendDlgItemMessage (hDlg, IDC_SOUNDBUFFERRAM, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUMEX, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
- SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUMEX, TBM_SETPAGESIZE, 0, 1);
- SendDlgItemMessage (hDlg, IDC_SOUNDADJUST, TBM_SETRANGE, TRUE, MAKELONG (-100, +30));
- SendDlgItemMessage (hDlg, IDC_SOUNDADJUST, TBM_SETPAGESIZE, 0, 1);
- for (i = 0; i < sounddrivers[i]; i++) {
- CheckDlgButton (hDlg, sounddrivers[i], (sounddrivermask & (1 << i)) ? TRUE : FALSE);
- }
- if (!volumeselection) {
- volumeselection = &workprefs.sound_volume_paula;
- volumeselectionindex = 0;
- }
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("Paula"));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("CD"));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("AHI"));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("MIDI"));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("Genlock"));
- SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_SETCURSEL, volumeselectionindex, 0);
- SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_RESETCONTENT, 0, 0L);
- numdevs = enumerate_sound_devices ();
- for (card = 0; card < numdevs; card++) {
- TCHAR tmp[MAX_DPATH];
- int type = sound_devices[card]->type;
- _stprintf (tmp, _T("%s: %s"),
- type == SOUND_DEVICE_XAUDIO2 ? _T("XAudio2") : (type == SOUND_DEVICE_DS ? _T("DSOUND") : (type == SOUND_DEVICE_AL ? _T("OpenAL") : (type == SOUND_DEVICE_PA ? _T("PortAudio") : (type == SOUND_DEVICE_WASAPI ? _T("WASAPI") : _T("WASAPI EX"))))),
- sound_devices[card]->name);
- SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- if (numdevs == 0)
- workprefs.produce_sound = 0; /* No sound card in system, enable_for_sounddlg will accommodate this */
- pages[SOUND_ID] = hDlg;
- currentpage = SOUND_ID;
- update_soundgui (hDlg);
- recursive--;
- }
- case WM_USER:
- recursive++;
- values_to_sounddlg (hDlg);
- enable_for_sounddlg (hDlg);
- recursive--;
- return TRUE;
- case WM_COMMAND:
- if (recursive > 0)
- break;
- recursive++;
- if(LOWORD (wParam) == IDC_SOUNDDRIVE) {
- values_to_sounddlg (hDlg);
- }
- values_from_sounddlg (hDlg);
- enable_for_sounddlg (hDlg);
- recursive--;
- break;
- case WM_HSCROLL:
- if ((HWND)lParam == GetDlgItem (hDlg, IDC_SOUNDBUFFERRAM)) {
- int v = SendMessage (GetDlgItem (hDlg, IDC_SOUNDBUFFERRAM), TBM_GETPOS, 0, 0);
- if (v >= 0) {
- if (v == 0)
- workprefs.sound_maxbsiz = 0;
- else
- workprefs.sound_maxbsiz = sndbufsizes[v - 1];
- }
- }
- workprefs.sound_volume_master = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUME), TBM_GETPOS, 0, 0);
- (*volumeselection) = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUMEEXT), TBM_GETPOS, 0, 0);
- workprefs.dfxclickvolume_empty[sounddrivesel] = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDDRIVEVOLUME), TBM_GETPOS, 0, 0);
- workprefs.dfxclickvolume_disk[sounddrivesel] = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDDRIVEVOLUMEX), TBM_GETPOS, 0, 0);
- update_soundgui (hDlg);
- break;
- }
- return FALSE;
- }
- #ifdef FILESYS
- struct cddlg_vals
- {
- struct uaedev_config_info ci;
- };
- struct tapedlg_vals
- {
- struct uaedev_config_info ci;
- };
- struct fsvdlg_vals
- {
- struct uaedev_config_info ci;
- int rdb;
- };
- struct hfdlg_vals
- {
- struct uaedev_config_info ci;
- bool original;
- uae_u64 size;
- uae_u32 dostype;
- int forcedcylinders;
- bool rdb;
- };
- static struct cddlg_vals current_cddlg;
- static struct tapedlg_vals current_tapedlg;
- static struct fsvdlg_vals current_fsvdlg;
- static struct hfdlg_vals current_hfdlg;
- static int archivehd;
- static void hardfile_testrdb (struct hfdlg_vals *hdf)
- {
- uae_u8 id[512];
- int i;
- struct hardfiledata hfd;
- memset (id, 0, sizeof id);
- memset (&hfd, 0, sizeof hfd);
- hfd.ci.readonly = true;
- hfd.ci.blocksize = 512;
- if (hdf_open (&hfd, current_hfdlg.ci.rootdir) > 0) {
- for (i = 0; i < 16; i++) {
- hdf_read_rdb (&hfd, id, i * 512, 512);
- if (i == 0 && !memcmp (id + 2, "CIS", 3)) {
- hdf->ci.controller_type = HD_CONTROLLER_TYPE_CUSTOM_FIRST;
- hdf->ci.controller_type_unit = 0;
- break;
- }
- bool babe = id[0] == 0xBA && id[1] == 0xBE; // A2090
- if (!memcmp (id, "RDSK\0\0\0", 7) || !memcmp (id, "CDSK\0\0\0", 7) || !memcmp (id, "DRKS\0\0", 6) ||
- (id[0] == 0x53 && id[1] == 0x10 && id[2] == 0x9b && id[3] == 0x13 && id[4] == 0 && id[5] == 0) || babe) {
- // RDSK or ADIDE "encoded" RDSK
- int blocksize = 512;
- if (!babe)
- blocksize = (id[16] << 24) | (id[17] << 16) | (id[18] << 8) | (id[19] << 0);
- hdf->ci.cyls = hdf->ci.highcyl = hdf->forcedcylinders = 0;
- hdf->ci.sectors = 0;
- hdf->ci.surfaces = 0;
- hdf->ci.reserved = 0;
- hdf->ci.filesys[0] = 0;
- hdf->ci.bootpri = 0;
- hdf->ci.devname[0] = 0;
- if (blocksize >= 512)
- hdf->ci.blocksize = blocksize;
- break;
- }
- }
- hdf_close (&hfd);
- }
- }
- static void default_fsvdlg (struct fsvdlg_vals *f)
- {
- memset (f, 0, sizeof (struct fsvdlg_vals));
- f->ci.type = UAEDEV_DIR;
- }
- static void default_tapedlg (struct tapedlg_vals *f)
- {
- memset (f, 0, sizeof (struct tapedlg_vals));
- f->ci.type = UAEDEV_TAPE;
- }
- static void default_hfdlg (struct hfdlg_vals *f, bool rdb)
- {
- int ctrl = f->ci.controller_type;
- int unit = f->ci.controller_unit;
- memset (f, 0, sizeof (struct hfdlg_vals));
- uci_set_defaults (&f->ci, rdb);
- f->original = true;
- f->ci.type = UAEDEV_HDF;
- f->ci.controller_type = ctrl;
- f->ci.controller_unit = unit;
- f->ci.unit_feature_level = 1;
- }
- static void default_rdb_hfdlg (struct hfdlg_vals *f, const TCHAR *filename)
- {
- default_hfdlg (f, true);
- _tcscpy (current_hfdlg.ci.rootdir, filename);
- hardfile_testrdb (f);
- }
- static void volumeselectfile (HWND hDlg, int setout)
- {
- TCHAR directory_path[MAX_DPATH];
- _tcscpy (directory_path, current_fsvdlg.ci.rootdir);
- if (directory_path[0] == 0) {
- int out = sizeof directory_path / sizeof (TCHAR);
- regquerystr (NULL, _T("FilesystemFilePath"), directory_path, &out);
- }
- if (DiskSelection (hDlg, 0, 14, &workprefs, NULL, directory_path)) {
- TCHAR *s = filesys_createvolname (NULL, directory_path, NULL, _T("Harddrive"));
- SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
- SetDlgItemText (hDlg, IDC_VOLUME_NAME, s);
- xfree (s);
- CheckDlgButton (hDlg, IDC_FS_RW, FALSE);
- ew (hDlg, IDC_FS_RW, FALSE);
- archivehd = 1;
- TCHAR *p = _tcsrchr (directory_path, '\\');
- if (p) {
- TCHAR t = p[1];
- p[1] = 0;
- regsetstr (NULL, _T("FilesystemFilePath"), directory_path);
- p[1] = t;
- }
- if (setout)
- _tcscpy (current_fsvdlg.ci.rootdir, directory_path);
- }
- }
- static void volumeselectdir (HWND hDlg, int newdir, int setout)
- {
- const GUID volumeguid = { 0x1df05121, 0xcc08, 0x46ea, { 0x80, 0x3f, 0x98, 0x3c, 0x54, 0x88, 0x53, 0x76 } };
- TCHAR szTitle[MAX_DPATH];
- TCHAR directory_path[MAX_DPATH];
- _tcscpy (directory_path, current_fsvdlg.ci.rootdir);
- if (!newdir) {
- if (directory_path[0] == 0) {
- int out = sizeof directory_path / sizeof (TCHAR);
- regquerystr (NULL, _T("FilesystemDirectoryPath"), directory_path, &out);
- }
- WIN32GUI_LoadUIString (IDS_SELECTFILESYSROOT, szTitle, MAX_DPATH);
- if (DirectorySelection (hDlg, &volumeguid, directory_path)) {
- newdir = 1;
- DISK_history_add (directory_path, -1, HISTORY_DIR, 1);
- regsetstr (NULL, _T("FilesystemDirectoryPath"), directory_path);
- }
- }
- if (newdir) {
- SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
- ew (hDlg, IDC_FS_RW, TRUE);
- archivehd = 0;
- if (setout)
- _tcscpy(current_fsvdlg.ci.rootdir, directory_path);
- }
- }
- static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- {
- archivehd = -1;
- if (my_existsfile (current_fsvdlg.ci.rootdir))
- archivehd = 1;
- else if (my_existsdir (current_fsvdlg.ci.rootdir))
- archivehd = 0;
- recursive++;
- setautocomplete (hDlg, IDC_PATH_NAME);
- addhistorymenu(hDlg, current_fsvdlg.ci.rootdir, IDC_PATH_NAME, HISTORY_DIR, false, -1);
- SetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.ci.volname);
- SetDlgItemText (hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.ci.devname);
- SetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, current_fsvdlg.ci.bootpri, TRUE);
- if (archivehd > 0)
- current_fsvdlg.ci.readonly = true;
- CheckDlgButton (hDlg, IDC_FS_RW, !current_fsvdlg.ci.readonly);
- CheckDlgButton (hDlg, IDC_FS_AUTOBOOT, ISAUTOBOOT(¤t_fsvdlg.ci));
- ew (hDlg, IDC_FS_RW, archivehd <= 0);
- recursive--;
- }
- return TRUE;
- case WM_CONTEXTMENU:
- if (GetDlgCtrlID ((HWND)wParam) == IDC_FS_SELECT_FILE) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- _tcscpy (current_fsvdlg.ci.rootdir, s);
- xfree (s);
- volumeselectfile (hDlg, 0);
- }
- } else if (GetDlgCtrlID ((HWND)wParam) == IDC_FS_SELECT_DIR) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- _tcscpy (current_fsvdlg.ci.rootdir, s);
- xfree (s);
- volumeselectdir (hDlg, 1, 0);
- }
- }
- break;
- case WM_COMMAND:
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_PATH_NAME:
- getcomboboxtext(hDlg, IDC_PATH_NAME, current_fsvdlg.ci.rootdir, sizeof current_fsvdlg.ci.rootdir / sizeof(TCHAR));
- break;
- }
- }
- if (HIWORD(wParam) == EN_UPDATE || HIWORD(wParam) == EN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_VOLUME_NAME:
- GetDlgItemText(hDlg, IDC_VOLUME_NAME, current_fsvdlg.ci.volname, sizeof current_fsvdlg.ci.volname / sizeof(TCHAR));
- break;
- case IDC_VOLUME_DEVICE:
- GetDlgItemText(hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.ci.devname, sizeof current_fsvdlg.ci.devname / sizeof(TCHAR));
- break;
- }
- }
- if (recursive)
- break;
- recursive++;
- if (HIWORD (wParam) == BN_CLICKED) {
- switch (LOWORD (wParam))
- {
- case IDC_FS_SELECT_EJECT:
- SetDlgItemText (hDlg, IDC_PATH_NAME, _T(""));
- SetDlgItemText (hDlg, IDC_VOLUME_NAME, _T(""));
- current_fsvdlg.ci.rootdir[0] = 0;
- current_fsvdlg.ci.volname[0] = 0;
- CheckDlgButton (hDlg, IDC_FS_RW, TRUE);
- ew (hDlg, IDC_FS_RW, TRUE);
- archivehd = -1;
- break;
- case IDC_FS_SELECT_FILE:
- volumeselectfile (hDlg, 1);
- break;
- case IDC_FS_SELECT_DIR:
- volumeselectdir (hDlg, 0, 1);
- break;
- case IDOK:
- EndDialog (hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog (hDlg, 0);
- break;
- }
- }
- current_fsvdlg.ci.readonly = !ischecked (hDlg, IDC_FS_RW);
- current_fsvdlg.ci.bootpri = GetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, NULL, TRUE);
- if(LOWORD (wParam) == IDC_FS_AUTOBOOT) {
- if (!ischecked (hDlg, IDC_FS_AUTOBOOT)) {
- current_fsvdlg.ci.bootpri = BOOTPRI_NOAUTOBOOT;
- } else {
- current_fsvdlg.ci.bootpri = 0;
- }
- SetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, current_fsvdlg.ci.bootpri, TRUE);
- }
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- STATIC_INLINE bool is_hdf_rdb (void)
- {
- return current_hfdlg.ci.sectors == 0 && current_hfdlg.ci.surfaces == 0 && current_hfdlg.ci.reserved == 0;
- }
- static int hdmenutable[256];
- static void sethardfilegeo(HWND hDlg)
- {
- if (current_hfdlg.ci.geometry[0]) {
- current_hfdlg.ci.physical_geometry = true;
- setchecked(hDlg, IDC_HDF_PHYSGEOMETRY, TRUE);
- ew(hDlg, IDC_HDF_PHYSGEOMETRY, FALSE);
- get_hd_geometry(¤t_hfdlg.ci);
- } else if (current_hfdlg.ci.chs) {
- current_hfdlg.ci.physical_geometry = true;
- setchecked(hDlg, IDC_HDF_PHYSGEOMETRY, TRUE);
- ew(hDlg, IDC_HDF_PHYSGEOMETRY, FALSE);
- ew(hDlg, IDC_SECTORS, FALSE);
- ew(hDlg, IDC_SECTORS, FALSE);
- ew(hDlg, IDC_RESERVED, FALSE);
- ew(hDlg, IDC_BLOCKSIZE, FALSE);
- } else {
- ew (hDlg, IDC_HDF_PHYSGEOMETRY, TRUE);
- }
- }
- static void sethardfiletypes(HWND hDlg)
- {
- bool ide = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_IDE_LAST;
- bool scsi = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST;
- ew(hDlg, IDC_HDF_CONTROLLER_TYPE, ide);
- ew(hDlg, IDC_HDF_FEATURE_LEVEL, ide || scsi);
- if (!ide) {
- current_hfdlg.ci.controller_media_type = 0;
- }
- if (current_hfdlg.ci.controller_media_type && current_hfdlg.ci.unit_feature_level == 0)
- current_hfdlg.ci.unit_feature_level = 1;
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_TYPE, CB_SETCURSEL, current_hfdlg.ci.controller_media_type, 0);
- SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_SETCURSEL, current_hfdlg.ci.unit_feature_level, 0);
- }
- static void sethd(HWND hDlg)
- {
- bool rdb = is_hdf_rdb ();
- bool physgeo = (rdb && ischecked(hDlg, IDC_HDF_PHYSGEOMETRY)) || current_hfdlg.ci.chs;
- bool enablegeo = (!rdb || (physgeo && current_hfdlg.ci.geometry[0] == 0)) && !current_hfdlg.ci.chs;
- const struct expansionromtype *ert = get_unit_expansion_rom(current_hfdlg.ci.controller_type);
- if (ert && current_hfdlg.ci.controller_unit >= 8) {
- if (!_tcscmp(ert->name, _T("a2091"))) {
- current_hfdlg.ci.unit_feature_level = HD_LEVEL_SASI_CHS;
- } else if (!_tcscmp(ert->name, _T("a2090a"))) {
- current_hfdlg.ci.unit_feature_level = HD_LEVEL_SCSI_1;
- }
- }
- if (!physgeo)
- current_hfdlg.ci.physical_geometry = false;
- ew(hDlg, IDC_SECTORS, enablegeo);
- ew(hDlg, IDC_HEADS, enablegeo);
- ew(hDlg, IDC_RESERVED, enablegeo);
- ew(hDlg, IDC_BLOCKSIZE, enablegeo);
- }
- static void setharddrive(HWND hDlg)
- {
- sethardfilegeo(hDlg);
- sethd(hDlg);
- ew(hDlg,IDC_BLOCKSIZE, FALSE);
- SetDlgItemInt (hDlg, IDC_SECTORS, current_hfdlg.ci.psecs, FALSE);
- SetDlgItemInt (hDlg, IDC_HEADS, current_hfdlg.ci.pheads, FALSE);
- SetDlgItemInt (hDlg, IDC_RESERVED, current_hfdlg.ci.pcyls, FALSE);
- SetDlgItemInt (hDlg, IDC_BLOCKSIZE, current_hfdlg.ci.blocksize, FALSE);
- sethardfiletypes(hDlg);
- }
- static void sethardfile (HWND hDlg)
- {
- sethardfilegeo(hDlg);
- bool ide = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_IDE_LAST;
- bool scsi = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST;
- bool rdb = is_hdf_rdb ();
- bool physgeo = rdb && ischecked(hDlg, IDC_HDF_PHYSGEOMETRY);
- bool disables = !rdb || (rdb && current_hfdlg.ci.controller_type == HD_CONTROLLER_TYPE_UAE);
- sethd(hDlg);
- if (!disables)
- current_hfdlg.ci.bootpri = 0;
- SetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.ci.rootdir);
- SetDlgItemText (hDlg, IDC_PATH_FILESYS, current_hfdlg.ci.filesys);
- SetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, current_hfdlg.ci.devname);
- SetDlgItemInt (hDlg, IDC_SECTORS, rdb ? current_hfdlg.ci.psecs : current_hfdlg.ci.sectors, FALSE);
- SetDlgItemInt (hDlg, IDC_HEADS, rdb ? current_hfdlg.ci.pheads : current_hfdlg.ci.surfaces, FALSE);
- SetDlgItemInt (hDlg, IDC_RESERVED, rdb ? current_hfdlg.ci.pcyls : current_hfdlg.ci.reserved, FALSE);
- SetDlgItemInt (hDlg, IDC_BLOCKSIZE, current_hfdlg.ci.blocksize, FALSE);
- SetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, current_hfdlg.ci.bootpri, TRUE);
- CheckDlgButton (hDlg, IDC_HDF_RW, !current_hfdlg.ci.readonly);
- CheckDlgButton (hDlg, IDC_HDF_AUTOBOOT, ISAUTOBOOT(¤t_hfdlg.ci));
- CheckDlgButton (hDlg, IDC_HDF_DONOTMOUNT, !ISAUTOMOUNT(¤t_hfdlg.ci));
- ew (hDlg, IDC_HDF_RDB, !rdb);
- ew (hDlg, IDC_HDF_AUTOBOOT, disables);
- ew (hDlg, IDC_HDF_DONOTMOUNT, disables);
- hide (hDlg, IDC_HDF_AUTOBOOT, !disables);
- hide (hDlg, IDC_HDF_DONOTMOUNT, !disables);
- hide (hDlg, IDC_HARDFILE_BOOTPRI, !disables);
- hide (hDlg, IDC_HARDFILE_BOOTPRI_TEXT, !disables);
- hide (hDlg, IDC_HDF_PHYSGEOMETRY, !rdb);
- if (!rdb)
- setchecked(hDlg, IDC_HDF_PHYSGEOMETRY, false);
- hide(hDlg, IDC_RESERVED_TEXT, rdb);
- hide(hDlg, IDC_CYLINDERS_TEXT, !rdb);
- gui_set_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER, current_hfdlg.ci.controller_type + current_hfdlg.ci.controller_type_unit * HD_CONTROLLER_NEXT_UNIT);
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_hfdlg.ci.controller_unit, 0);
- sethardfiletypes(hDlg);
- }
- static void addhdcontroller(HWND hDlg, const struct expansionromtype *erc, int *hdmenutable, int firstid, int flags)
- {
- TCHAR name[MAX_DPATH];
- name[0] = 0;
- if (erc->friendlymanufacturer && _tcsicmp(erc->friendlymanufacturer, erc->friendlyname)) {
- _tcscat(name, erc->friendlymanufacturer);
- _tcscat(name, _T(" "));
- }
- _tcscat(name, erc->friendlyname);
- if (workprefs.cpuboard_type && erc->romtype == ROMTYPE_CPUBOARD) {
- const struct cpuboardsubtype *cbt = &cpuboards[workprefs.cpuboard_type].subtypes[workprefs.cpuboard_subtype];
- if (!(cbt->deviceflags & flags))
- return;
- _tcscat(name, _T(" ("));
- _tcscat(name, cbt->name);
- _tcscat(name, _T(")"));
- }
- if (get_boardromconfig(&workprefs, erc->romtype, NULL) || get_boardromconfig(&workprefs, erc->romtype_extra, NULL)) {
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, firstid, name);
- for (int j = 1; j < MAX_DUPLICATE_EXPANSION_BOARDS; j++) {
- if (is_board_enabled(&workprefs, erc->romtype, j)) {
- TCHAR tmp[MAX_DPATH];
- _stprintf(tmp, _T("%s [%d]"), name, j + 1);
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, firstid + j * HD_CONTROLLER_NEXT_UNIT, tmp);
- }
- }
- }
- }
- static void inithdcontroller (HWND hDlg, int ctype, int ctype_unit, int devtype, bool media)
- {
- hdmenutable[0] = -1;
-
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER, CB_RESETCONTENT, 0, 0);
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, HD_CONTROLLER_TYPE_UAE, _T("UAE (uaehf.device)"));
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, 0, _T(""));
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, HD_CONTROLLER_TYPE_IDE_AUTO, _T("IDE (Auto)"));
- for (int i = 0; expansionroms[i].name; i++) {
- const struct expansionromtype *erc = &expansionroms[i];
- if (erc->deviceflags & EXPANSIONTYPE_IDE) {
- addhdcontroller(hDlg, erc, hdmenutable, HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST + i, EXPANSIONTYPE_IDE);
- }
- }
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, 0, _T(""));
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, HD_CONTROLLER_TYPE_SCSI_AUTO, _T("SCSI (Auto)"));
- for (int i = 0; expansionroms[i].name; i++) {
- const struct expansionromtype *erc = &expansionroms[i];
- if (erc->deviceflags & EXPANSIONTYPE_SCSI) {
- addhdcontroller(hDlg, erc, hdmenutable, HD_CONTROLLER_TYPE_SCSI_EXPANSION_FIRST + i, EXPANSIONTYPE_SCSI);
- }
- }
- #if 0
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, 0, _T(""));
- for (int i = 0; expansionroms[i].name; i++) {
- const struct expansionromtype *erc = &expansionroms[i];
- if ((erc->romtype & ROMTYPE_MASK) == ROMTYPE_MB_PCMCIA) {
- addhdcontroller(hDlg, erc, hdmenutable, HD_CONTROLLER_TYPE_CUSTOM_FIRST + i, 0);
- ctype_unit = 0;
- }
- }
- #endif
- gui_add_string(hdmenutable, hDlg, IDC_HDF_CONTROLLER, 0, _T(""));
- for (int i = 0; expansionroms[i].name; i++) {
- const struct expansionromtype *erc = &expansionroms[i];
- if (erc->deviceflags & EXPANSIONTYPE_CUSTOMDISK) {
- addhdcontroller(hDlg, erc, hdmenutable, HD_CONTROLLER_TYPE_CUSTOM_FIRST + i, EXPANSIONTYPE_CUSTOMDISK);
- break;
- }
- }
- gui_set_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER, ctype + ctype_unit * HD_CONTROLLER_NEXT_UNIT);
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_RESETCONTENT, 0, 0);
- if (ctype >= HD_CONTROLLER_TYPE_IDE_FIRST && ctype <= HD_CONTROLLER_TYPE_IDE_LAST) {
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- int ports = 2 + (ert ? ert->extrahdports : 0);
- for (int i = 0; i < ports; i += 2) {
- TCHAR tmp[100];
- _stprintf(tmp, _T("%d"), i + 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- _stprintf(tmp, _T("%d"), i + 1);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- if (media)
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, TRUE);
- } else if (ctype >= HD_CONTROLLER_TYPE_SCSI_FIRST && ctype <= HD_CONTROLLER_TYPE_SCSI_LAST) {
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("0"));
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("1"));
- if (!ert || !(ert->deviceflags & (EXPANSIONTYPE_SASI | EXPANSIONTYPE_CUSTOM)) ) {
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("2"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("3"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("4"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("5"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("6"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("7"));
- if (devtype == UAEDEV_HDF && ert && !_tcscmp(ert->name, _T("a2091")))
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("XT"));
- if (devtype == UAEDEV_HDF && ert && !_tcscmp(ert->name, _T("a2090a"))) {
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("ST-506 #1"));
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)_T("ST-506 #2"));
- }
- }
- if (media)
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, TRUE);
- } else if (ctype >= HD_CONTROLLER_TYPE_CUSTOM_FIRST && ctype <= HD_CONTROLLER_TYPE_CUSTOM_LAST) {
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, FALSE);
- } else if (ctype == HD_CONTROLLER_TYPE_UAE) {
- for (int i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
- TCHAR tmp[100];
- _stprintf(tmp, _T("%d"), i);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_ADDSTRING, 0, (LPARAM)tmp);
- }
- if (media)
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, TRUE);
- } else {
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, FALSE);
- }
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_TYPE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("HD"));
- SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("CF"));
- SendDlgItemMessage (hDlg, IDC_HDF_FEATURE_LEVEL, CB_RESETCONTENT, 0, 0);
- if (ctype >= HD_CONTROLLER_TYPE_IDE_FIRST && ctype <= HD_CONTROLLER_TYPE_IDE_LAST) {
- SendDlgItemMessage (hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("ATA-1"));
- SendDlgItemMessage (hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("ATA-2+"));
- SendDlgItemMessage (hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("ATA-2+ Strict"));
- } else if (ctype >= HD_CONTROLLER_TYPE_SCSI_FIRST && ctype <= HD_CONTROLLER_TYPE_SCSI_LAST) {
- const struct expansionromtype *ert = get_unit_expansion_rom(ctype);
- SendDlgItemMessage (hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("SCSI-1"));
- SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("SCSI-2"));
- if (ert && (ert->deviceflags & (EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_CUSTOM_SECONDARY | EXPANSIONTYPE_SASI))) {
- SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("SASI"));
- SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_ADDSTRING, 0, (LPARAM)_T("SASI CHS"));
- }
- }
- }
- static void inithardfile (HWND hDlg, bool media)
- {
- TCHAR tmp[MAX_DPATH];
- ew (hDlg, IDC_HF_DOSTYPE, FALSE);
- ew (hDlg, IDC_HF_CREATE, FALSE);
- inithdcontroller (hDlg, current_hfdlg.ci.controller_type, current_hfdlg.ci.controller_type_unit, UAEDEV_HDF, media);
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_RESETCONTENT, 0, 0);
- WIN32GUI_LoadUIString (IDS_HF_FS_CUSTOM, tmp, sizeof (tmp) / sizeof (TCHAR));
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("RDB/OFS/FFS"));
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("PFS3"));
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("PDS3"));
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)_T("SFS"));
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
- SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_SETCURSEL, 0, 0);
- }
- static void sethfdostype (HWND hDlg, int idx)
- {
- switch (idx)
- {
- case 1:
- SetDlgItemText (hDlg, IDC_HF_DOSTYPE, _T("0x50465300"));
- break;
- case 2:
- SetDlgItemText (hDlg, IDC_HF_DOSTYPE, _T("0x50445300"));
- break;
- case 3:
- SetDlgItemText (hDlg, IDC_HF_DOSTYPE, _T("0x53465300"));
- break;
- default:
- SetDlgItemText (hDlg, IDC_HF_DOSTYPE, _T(""));
- break;
- }
- }
- static void updatehdfinfo(HWND hDlg, bool force, bool defaults, bool realdrive)
- {
- uae_u8 id[512] = { 0 };
- uae_u64 bsize;
- uae_u32 blocks, cyls, i;
- TCHAR tmp[200], tmp2[200];
- TCHAR idtmp[17];
- bool phys = is_hdf_rdb();
- bsize = 0;
- if (force) {
- bool open = false;
- bool gotrdb = false;
- int blocksize = 512;
- struct hardfiledata hfd;
- memset (id, 0, sizeof id);
- memset (&hfd, 0, sizeof hfd);
- hfd.ci.readonly = true;
- hfd.ci.blocksize = blocksize;
- current_hfdlg.size = 0;
- current_hfdlg.dostype = 0;
- if (hdf_open (&hfd, current_hfdlg.ci.rootdir) > 0) {
- open = true;
- for (i = 0; i < 16; i++) {
- hdf_read (&hfd, id, i * 512, 512);
- bsize = hfd.virtsize;
- current_hfdlg.size = hfd.virtsize;
- if (!memcmp (id, "RDSK", 4) || !memcmp (id, "CDSK", 4)) {
- blocksize = (id[16] << 24) | (id[17] << 16) | (id[18] << 8) | (id[19] << 0);
- gotrdb = true;
- break;
- }
- }
- if (i == 16) {
- hdf_read (&hfd, id, 0, 512);
- current_hfdlg.dostype = (id[0] << 24) | (id[1] << 16) | (id[2] << 8) | (id[3] << 0);
- }
- }
- if (defaults) {
- if (blocksize > 512) {
- hfd.ci.blocksize = blocksize;
- }
- }
- if (hfd.ci.chs) {
- current_hfdlg.ci.physical_geometry = true;
- current_hfdlg.ci.chs = true;
- current_hfdlg.ci.pcyls = hfd.ci.pcyls;
- current_hfdlg.ci.pheads = hfd.ci.pheads;
- current_hfdlg.ci.psecs = hfd.ci.psecs;
- }
- if (!current_hfdlg.ci.physical_geometry) {
- if (current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_IDE_LAST) {
- getchspgeometry (bsize, ¤t_hfdlg.ci.pcyls, ¤t_hfdlg.ci.pheads, ¤t_hfdlg.ci.psecs, true);
- } else {
- getchspgeometry (bsize, ¤t_hfdlg.ci.pcyls, ¤t_hfdlg.ci.pheads, ¤t_hfdlg.ci.psecs, false);
- }
- if (defaults && !gotrdb && !realdrive) {
- gethdfgeometry(bsize, ¤t_hfdlg.ci);
- phys = false;
- }
- } else {
- current_hfdlg.forcedcylinders = current_hfdlg.ci.pcyls;
- }
- if (hDlg && (hfd.identity[0] || hfd.identity[1])) {
- TCHAR ident[256];
- int i;
- for (i = 0; i < 11; i++) {
- _stprintf(ident + i * 5, _T("%02X%02X."), hfd.identity[i * 2 + 1], hfd.identity[i * 2 + 0]);
- }
- ident[i * 5 - 1] = 0;
- SetDlgItemText(hDlg, IDC_HDFINFO3, ident);
- }
- hdf_close (&hfd);
- }
- if (current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_IDE_LAST) {
- if (current_hfdlg.ci.unit_feature_level == HD_LEVEL_ATA_1 && bsize >= 4 * (uae_u64)0x40000000)
- current_hfdlg.ci.unit_feature_level = HD_LEVEL_ATA_2;
- }
- cyls = phys ? current_hfdlg.ci.pcyls : current_hfdlg.forcedcylinders;
- int heads = phys ? current_hfdlg.ci.pheads : current_hfdlg.ci.surfaces;
- int secs = phys ? current_hfdlg.ci.psecs : current_hfdlg.ci.sectors;
- if (!cyls && current_hfdlg.ci.blocksize && secs && heads) {
- cyls = bsize / ((uae_u64)current_hfdlg.ci.blocksize * secs * heads);
- }
- blocks = cyls * (secs * heads);
- if (!blocks && current_hfdlg.ci.blocksize)
- blocks = bsize / current_hfdlg.ci.blocksize;
- if (current_hfdlg.ci.max_lba)
- blocks = current_hfdlg.ci.max_lba;
- for (i = 0; i < sizeof (idtmp) / sizeof (TCHAR) - 1; i++) {
- TCHAR c = id[i];
- if (c < 32 || c > 126)
- c = '.';
- idtmp[i] = c;
- idtmp[i + 1] = 0;
- }
- tmp[0] = 0;
- if (bsize) {
- _stprintf (tmp2, _T(" %s [%02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X]"), idtmp,
- id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
- id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
- if (!blocks) {
- _stprintf (tmp, _T("%uMB"), (unsigned int)(bsize / (1024 * 1024)));
- } else if (blocks && !cyls) {
- _stprintf (tmp, _T("%u blocks, %.1fMB"),
- blocks,
- (double)bsize / (1024.0 * 1024.0));
- } else {
- _stprintf (tmp, _T("%u/%u/%u, %u/%u blocks, %.1fMB/%.1fMB"),
- cyls, heads, secs,
- blocks, (int)(bsize / current_hfdlg.ci.blocksize),
- (double)blocks * 1.0 * current_hfdlg.ci.blocksize / (1024.0 * 1024.0),
- (double)bsize / (1024.0 * 1024.0));
- if ((uae_u64)cyls * heads * secs > bsize / current_hfdlg.ci.blocksize) {
- _tcscat (tmp2, _T(" [Geometry larger than drive!]"));
- } else if (cyls > 65535) {
- _tcscat (tmp2, _T(" [Too many cyls]"));
- }
- }
- if (hDlg != NULL) {
- SetDlgItemText(hDlg, IDC_HDFINFO, tmp);
- SetDlgItemText(hDlg, IDC_HDFINFO2, tmp2);
- }
- }
- }
- static void hardfileselecthdf (HWND hDlg, TCHAR *newpath, bool ask, bool newhd)
- {
- if (ask) {
- DiskSelection (hDlg, IDC_PATH_NAME, 2, &workprefs, NULL, newpath);
- GetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.ci.rootdir, sizeof current_hfdlg.ci.rootdir / sizeof (TCHAR));
- DISK_history_add(current_hfdlg.ci.rootdir, -1, HISTORY_HDF, 1);
- }
- fullpath (current_hfdlg.ci.rootdir, sizeof current_hfdlg.ci.rootdir / sizeof (TCHAR));
- if (newhd) {
- // Set RDB mode if IDE or SCSI
- if (current_hfdlg.ci.controller_type > 0) {
- current_hfdlg.ci.sectors = current_hfdlg.ci.reserved = current_hfdlg.ci.surfaces = 0;
- }
- }
- inithardfile (hDlg, true);
- hardfile_testrdb (¤t_hfdlg);
- updatehdfinfo (hDlg, true, true, false);
- get_hd_geometry (¤t_hfdlg.ci);
- updatehdfinfo (hDlg, false, false, false);
- sethardfile (hDlg);
- }
- static void hardfilecreatehdf (HWND hDlg, TCHAR *newpath)
- {
- TCHAR hdfpath[MAX_DPATH];
- LRESULT res;
- uae_s64 setting = CalculateHardfileSize (hDlg);
- TCHAR dostype[16];
- GetDlgItemText (hDlg, IDC_HF_DOSTYPE, dostype, sizeof (dostype) / sizeof (TCHAR));
- res = SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_GETCURSEL, 0, 0);
- if (res == 0)
- dostype[0] = 0;
- if (CreateHardFile (hDlg, setting, dostype, newpath, hdfpath)) {
- if (!current_hfdlg.ci.rootdir[0]) {
- fullpath (hdfpath, sizeof hdfpath / sizeof (TCHAR));
- _tcscpy (current_hfdlg.ci.rootdir, hdfpath);
- }
- }
- sethardfile (hDlg);
- }
- static INT_PTR CALLBACK TapeDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- int posn, readonly;
- TCHAR tmp[MAX_DPATH];
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- recursive++;
- inithdcontroller(hDlg, current_tapedlg.ci.controller_type, current_tapedlg.ci.controller_type_unit, UAEDEV_TAPE, current_tapedlg.ci.rootdir[0] != 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_tapedlg.ci.controller_unit, 0);
- setautocomplete (hDlg, IDC_PATH_NAME);
- addhistorymenu(hDlg, current_tapedlg.ci.rootdir, IDC_PATH_NAME, HISTORY_TAPE, false, -1);
- readonly = !tape_can_write(current_tapedlg.ci.rootdir);
- CheckDlgButton (hDlg, IDC_TAPE_RW, current_tapedlg.ci.readonly == 0 && !readonly);
- ew (hDlg, IDC_TAPE_RW, !readonly);
- recursive--;
- customDlgType = IDD_TAPEDRIVE;
- customDlg = hDlg;
- return TRUE;
- case WM_COMMAND:
- if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) {
- switch (LOWORD (wParam))
- {
- case IDC_PATH_NAME:
- if (getcomboboxtext(hDlg, IDC_PATH_NAME, tmp, sizeof tmp / sizeof(TCHAR))) {
- if (_tcscmp (tmp, current_tapedlg.ci.rootdir)) {
- _tcscpy (current_tapedlg.ci.rootdir, tmp);
- readonly = !tape_can_write(current_tapedlg.ci.rootdir);
- ew (hDlg, IDC_TAPE_RW, !readonly);
- if (readonly)
- CheckDlgButton (hDlg, IDC_TAPE_RW, FALSE);
- }
- }
- break;
- case IDC_HDF_CONTROLLER:
- posn = gui_get_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER);
- if (posn != CB_ERR) {
- current_tapedlg.ci.controller_type = posn % HD_CONTROLLER_NEXT_UNIT;
- current_tapedlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
- inithdcontroller(hDlg, current_tapedlg.ci.controller_type, current_tapedlg.ci.controller_type_unit, UAEDEV_TAPE, current_tapedlg.ci.rootdir);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_tapedlg.ci.controller_unit, 0);
- }
- break;
- case IDC_HDF_CONTROLLER_UNIT:
- posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_tapedlg.ci.controller_unit = posn;
- }
- break;
- }
- }
- if (recursive)
- break;
- recursive++;
- switch (LOWORD (wParam))
- {
- case IDC_TAPE_EJECT:
- current_tapedlg.ci.rootdir[0] = 0;
- SetDlgItemText(hDlg, IDC_PATH_NAME, current_tapedlg.ci.rootdir);
- break;
- case IDC_TAPE_SELECT_FILE:
- DiskSelection (hDlg, IDC_PATH_NAME, 18, &workprefs, NULL, NULL);
- GetDlgItemText (hDlg, IDC_PATH_NAME, current_tapedlg.ci.rootdir, sizeof current_tapedlg.ci.rootdir / sizeof (TCHAR));
- DISK_history_add(current_tapedlg.ci.rootdir, -1, HISTORY_TAPE, 1);
- fullpath (current_tapedlg.ci.rootdir, sizeof current_tapedlg.ci.rootdir / sizeof (TCHAR));
- readonly = !tape_can_write(current_tapedlg.ci.rootdir);
- ew (hDlg, IDC_TAPE_RW, !readonly);
- if (readonly)
- CheckDlgButton (hDlg, IDC_TAPE_RW, FALSE);
- break;
- case IDC_TAPE_SELECT_DIR:
- {
- const GUID volumeguid = { 0xb95772a5, 0x8444, 0x48d8, { 0xab, 0x9a, 0xef, 0x3c, 0x62, 0x11, 0x3a, 0x37 } };
- TCHAR directory_path[MAX_DPATH];
- _tcscpy (directory_path, current_tapedlg.ci.rootdir);
- if (directory_path[0] == 0) {
- int out = sizeof directory_path / sizeof (TCHAR);
- regquerystr (NULL, _T("TapeDirectoryPath"), directory_path, &out);
- }
- if (DirectorySelection (hDlg, &volumeguid, directory_path)) {
- regsetstr (NULL, _T("TapeDirectoryPath"), directory_path);
- SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
- }
- _tcscpy (current_tapedlg.ci.rootdir, directory_path);
- DISK_history_add(current_tapedlg.ci.rootdir, -1, HISTORY_TAPE, 1);
- readonly = !tape_can_write(current_tapedlg.ci.rootdir);
- ew (hDlg, IDC_TAPE_RW, !readonly);
- if (readonly)
- CheckDlgButton (hDlg, IDC_TAPE_RW, FALSE);
- break;
- }
- case IDOK:
- EndDialog (hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog (hDlg, 0);
- break;
- }
- current_tapedlg.ci.readonly = !ischecked (hDlg, IDC_TAPE_RW);
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static INT_PTR CALLBACK CDDriveSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- int posn;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- recursive++;
- if (current_cddlg.ci.controller_type == HD_CONTROLLER_TYPE_UAE)
- current_cddlg.ci.controller_type = (is_board_enabled(&workprefs, ROMTYPE_A2091, 0) ||
- is_board_enabled(&workprefs, ROMTYPE_GVPS2, 0) || is_board_enabled(&workprefs, ROMTYPE_A4091, 0) ||
- (workprefs.cs_mbdmac & 3)) ? HD_CONTROLLER_TYPE_SCSI_AUTO : HD_CONTROLLER_TYPE_IDE_AUTO;
- inithdcontroller(hDlg, current_cddlg.ci.controller_type, current_cddlg.ci.controller_type_unit, UAEDEV_CD, current_cddlg.ci.rootdir[0] != 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_cddlg.ci.controller_unit, 0);
- InitializeListView (hDlg);
- recursive--;
- customDlgType = IDD_CDDRIVE;
- customDlg = hDlg;
- return TRUE;
- case WM_NOTIFY:
- if (((LPNMHDR) lParam)->idFrom == IDC_CDLIST) {
- NM_LISTVIEW *nmlistview = (NM_LISTVIEW *)lParam;
- if (nmlistview->hdr.code == NM_DBLCLK)
- EndDialog (hDlg, 1);
- }
- break;
- case WM_COMMAND:
- if (recursive)
- break;
- recursive++;
- switch (LOWORD (wParam))
- {
- case IDOK:
- EndDialog (hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog (hDlg, 0);
- break;
- case IDC_HDF_CONTROLLER:
- posn = gui_get_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER);
- if (posn != CB_ERR) {
- current_cddlg.ci.controller_type = posn % HD_CONTROLLER_NEXT_UNIT;
- current_cddlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
- inithdcontroller(hDlg, current_cddlg.ci.controller_type, current_cddlg.ci.controller_type_unit, UAEDEV_CD, current_cddlg.ci.rootdir[0] != 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_cddlg.ci.controller_unit, 0);
- }
- break;
- case IDC_HDF_CONTROLLER_UNIT:
- posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_cddlg.ci.controller_unit = posn;
- }
- break;
- }
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static void set_phys_cyls(HWND hDlg)
- {
- if (ischecked(hDlg, IDC_HDF_PHYSGEOMETRY)) {
- int v = (current_hfdlg.ci.pheads * current_hfdlg.ci.psecs * current_hfdlg.ci.blocksize);
- current_hfdlg.ci.pcyls = v ? current_hfdlg.size / v : 0;
- current_hfdlg.ci.physical_geometry = true;
- SetDlgItemInt (hDlg, IDC_RESERVED, current_hfdlg.ci.pcyls, FALSE);
- }
- }
- static void restore_hd_geom(struct uaedev_config_info *dst, struct uaedev_config_info *src)
- {
- _tcscpy(dst->filesys, src->filesys);
- _tcscpy(dst->devname, src->devname);
- dst->controller_type = src->controller_type;
- dst->controller_type_unit = src->controller_type_unit;
- dst->controller_unit = src->controller_unit;
- dst->controller_media_type = src->controller_media_type;
- dst->unit_feature_level = src->unit_feature_level;
- dst->bootpri = src->bootpri;
- dst->readonly = src->readonly;
- dst->physical_geometry = src->physical_geometry;
- if (src->physical_geometry) {
- dst->cyls = dst->sectors = dst->surfaces = dst->reserved = 0;
- dst->pcyls = src->pcyls;
- dst->pheads = src->pheads;
- dst->psecs = src->psecs;
- }
- }
- static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- LRESULT res, posn;
- TCHAR tmp[MAX_DPATH];
- int v;
- int *p;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_DROPFILES:
- dragdrop (hDlg, (HDROP)wParam, &changed_prefs, -2);
- return FALSE;
- case WM_INITDIALOG:
- recursive++;
- setchecked(hDlg, IDC_HDF_PHYSGEOMETRY, current_hfdlg.ci.physical_geometry);
- setautocomplete (hDlg, IDC_PATH_NAME);
- setautocomplete (hDlg, IDC_PATH_FILESYS);
- setautocomplete (hDlg, IDC_PATH_GEOMETRY);
- addhistorymenu(hDlg, current_hfdlg.ci.geometry, IDC_PATH_GEOMETRY, HISTORY_GEO, false, -1);
- inithardfile (hDlg, current_hfdlg.ci.rootdir[0] != 0);
- addhistorymenu(hDlg, current_hfdlg.ci.rootdir, IDC_PATH_NAME, HISTORY_HDF, false, -1);
- addhistorymenu(hDlg, current_hfdlg.ci.filesys, IDC_PATH_FILESYS, HISTORY_FS, false, -1);
- updatehdfinfo (hDlg, true, false, false);
- sethardfile (hDlg);
- sethfdostype (hDlg, 0);
- setac (hDlg, IDC_PATH_NAME);
- recursive--;
- customDlgType = IDD_HARDFILE;
- customDlg = hDlg;
- return TRUE;
- case WM_CONTEXTMENU:
- if (GetDlgCtrlID ((HWND)wParam) == IDC_SELECTOR) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR path[MAX_DPATH];
- _tcscpy (path, s);
- xfree (s);
- hardfileselecthdf (hDlg, path, true, false);
- }
- } else if (GetDlgCtrlID ((HWND)wParam) == IDC_FILESYS_SELECTOR) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR path[MAX_DPATH];
- _tcscpy (path, s);
- xfree (s);
- DiskSelection (hDlg, IDC_PATH_FILESYS, 12, &workprefs, NULL, path);
- }
- } else if (GetDlgCtrlID ((HWND)wParam) == IDC_HF_CREATE) {
- TCHAR *s = favoritepopup (hDlg);
- if (s) {
- TCHAR path[MAX_DPATH];
- _tcscpy (path, s);
- xfree (s);
- hardfilecreatehdf (hDlg, path);
- }
- }
- break;
- case WM_COMMAND:
- if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS) {
- switch (LOWORD (wParam)) {
- case IDC_PATH_GEOMETRY:
- getcomboboxtext(hDlg, IDC_PATH_GEOMETRY, current_hfdlg.ci.geometry, sizeof current_hfdlg.ci.geometry / sizeof(TCHAR));
- if (HIWORD (wParam) == CBN_KILLFOCUS) {
- addhistorymenu(hDlg, current_hfdlg.ci.geometry, IDC_PATH_GEOMETRY, HISTORY_GEO, false, -1);
- sethardfile(hDlg);
- updatehdfinfo (hDlg, true, false, false);
- }
- break;
- case IDC_PATH_NAME:
- if (getcomboboxtext(hDlg, IDC_PATH_NAME, tmp, sizeof tmp / sizeof(TCHAR))) {
- if (_tcscmp (tmp, current_hfdlg.ci.rootdir)) {
- _tcscpy (current_hfdlg.ci.rootdir, tmp);
- recursive++;
- hardfileselecthdf (hDlg, NULL, false, false);
- recursive--;
- }
- }
- if (HIWORD (wParam) == CBN_KILLFOCUS) {
- addhistorymenu(hDlg, current_hfdlg.ci.rootdir, IDC_PATH_NAME, HISTORY_HDF, false, -1);
- }
- break;
- case IDC_PATH_FILESYS:
- getcomboboxtext(hDlg, IDC_PATH_FILESYS, current_hfdlg.ci.filesys, sizeof current_hfdlg.ci.filesys / sizeof(TCHAR));
- if (HIWORD(wParam) == CBN_KILLFOCUS) {
- addhistorymenu(hDlg, current_hfdlg.ci.filesys, IDC_PATH_FILESYS, HISTORY_FS, false, -1);
- }
- break;
- }
- }
- if (recursive)
- break;
- recursive++;
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- switch (LOWORD(wParam))
- {
- case IDC_HDF_CONTROLLER:
- posn = gui_get_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER);
- if (posn != CB_ERR) {
- current_hfdlg.ci.controller_type = posn % HD_CONTROLLER_NEXT_UNIT;
- current_hfdlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
- inithdcontroller(hDlg, current_hfdlg.ci.controller_type, current_hfdlg.ci.controller_type_unit, UAEDEV_HDF, current_hfdlg.ci.rootdir[0] != 0);
- sethardfile(hDlg);
- }
- break;
- case IDC_HDF_CONTROLLER_UNIT:
- posn = SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.controller_unit = posn;
- sethardfile(hDlg);
- }
- break;
- case IDC_HDF_CONTROLLER_TYPE:
- posn = SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_TYPE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.controller_media_type = posn;
- sethardfile(hDlg);
- }
- break;
- case IDC_HDF_FEATURE_LEVEL:
- posn = SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.unit_feature_level = posn;
- sethardfile(hDlg);
- }
- break;
- }
- }
- switch (LOWORD (wParam)) {
- case IDC_HF_SIZE:
- ew (hDlg, IDC_HF_CREATE, CalculateHardfileSize (hDlg) > 0);
- break;
- case IDC_HF_TYPE:
- res = SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_GETCURSEL, 0, 0);
- sethfdostype (hDlg, (int)res);
- ew (hDlg, IDC_HF_DOSTYPE, res >= 4);
- break;
- case IDC_HF_CREATE:
- {
- struct uaedev_config_info citmp;
- memcpy(&citmp, ¤t_hfdlg.ci, sizeof citmp);
- default_hfdlg (¤t_hfdlg, false);
- restore_hd_geom(¤t_hfdlg.ci, &citmp);
- hardfilecreatehdf (hDlg, NULL);
- }
- break;
- case IDC_SELECTOR:
- {
- bool newhd = current_hfdlg.ci.rootdir[0] == 0;
- struct uaedev_config_info citmp;
- memcpy(&citmp, ¤t_hfdlg.ci, sizeof citmp);
- default_hfdlg (¤t_hfdlg, false);
- restore_hd_geom(¤t_hfdlg.ci, &citmp);
- hardfileselecthdf (hDlg, NULL, true, newhd);
- }
- break;
- case IDC_FILESYS_SELECTOR:
- DiskSelection (hDlg, IDC_PATH_FILESYS, 12, &workprefs, NULL, NULL);
- getcomboboxtext(hDlg, IDC_PATH_FILESYS, current_hfdlg.ci.filesys, sizeof current_hfdlg.ci.filesys / sizeof(TCHAR));
- DISK_history_add(current_hfdlg.ci.filesys, -1, HISTORY_FS, 1);
- break;
- case IDOK:
- EndDialog (hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog (hDlg, 0);
- break;
- case IDC_HDF_PHYSGEOMETRY:
- current_hfdlg.ci.physical_geometry = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY);
- updatehdfinfo(hDlg, true, false, false);
- sethardfile(hDlg);
- break;
- case IDC_HDF_RW:
- current_hfdlg.ci.readonly = !ischecked (hDlg, IDC_HDF_RW);
- break;
- case IDC_HDF_AUTOBOOT:
- if (ischecked (hDlg, IDC_HDF_AUTOBOOT)) {
- current_hfdlg.ci.bootpri = 0;
- setchecked (hDlg, IDC_HDF_DONOTMOUNT, false);
- } else {
- current_hfdlg.ci.bootpri = BOOTPRI_NOAUTOBOOT;
- }
- SetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, current_hfdlg.ci.bootpri, TRUE);
- break;
- case IDC_HDF_DONOTMOUNT:
- if (ischecked (hDlg, IDC_HDF_DONOTMOUNT)) {
- current_hfdlg.ci.bootpri = BOOTPRI_NOAUTOMOUNT;
- setchecked (hDlg, IDC_HDF_AUTOBOOT, false);
- } else {
- current_hfdlg.ci.bootpri = BOOTPRI_NOAUTOBOOT;
- setchecked (hDlg, IDC_HDF_AUTOBOOT, true);
- }
- SetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, current_hfdlg.ci.bootpri, TRUE);
- break;
- case IDC_HDF_RDB:
- SetDlgItemText (hDlg, IDC_PATH_FILESYS, _T(""));
- SetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, _T(""));
- current_hfdlg.ci.sectors = current_hfdlg.ci.reserved = current_hfdlg.ci.surfaces = 0;
- current_hfdlg.ci.bootpri = 0;
- sethardfile (hDlg);
- break;
- case IDC_PATH_GEOMETRY_SELECTOR:
- if (DiskSelection (hDlg, IDC_PATH_GEOMETRY, 23, &workprefs, NULL, current_hfdlg.ci.geometry)) {
- DISK_history_add(current_hfdlg.ci.geometry, -1, HISTORY_GEO, 1);
- sethardfile(hDlg);
- updatehdfinfo (hDlg, true, false, false);
- }
- break;
- case IDC_SECTORS:
- p = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY) ? ¤t_hfdlg.ci.psecs : ¤t_hfdlg.ci.sectors;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_SECTORS, NULL, FALSE);
- if (v != *p) {
- set_phys_cyls(hDlg);
- updatehdfinfo (hDlg, true, false, false);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- case IDC_RESERVED:
- p = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY) ? ¤t_hfdlg.ci.pcyls : ¤t_hfdlg.ci.reserved;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_RESERVED, NULL, FALSE);
- if (v != *p) {
- if (ischecked(hDlg, IDC_HDF_PHYSGEOMETRY)) {
- current_hfdlg.ci.physical_geometry = true;
- }
- updatehdfinfo (hDlg, true, false, false);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- case IDC_HEADS:
- p = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY) ? ¤t_hfdlg.ci.pheads : ¤t_hfdlg.ci.surfaces;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_HEADS, NULL, FALSE);
- if (v != *p) {
- set_phys_cyls(hDlg);
- updatehdfinfo (hDlg, true, false, false);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- case IDC_BLOCKSIZE:
- v = current_hfdlg.ci.blocksize;
- current_hfdlg.ci.blocksize = GetDlgItemInt (hDlg, IDC_BLOCKSIZE, NULL, FALSE);
- if (v != current_hfdlg.ci.blocksize)
- updatehdfinfo (hDlg, true, false, false);
- break;
- case IDC_HARDFILE_BOOTPRI:
- current_hfdlg.ci.bootpri = GetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, NULL, TRUE);
- if (current_hfdlg.ci.bootpri < -127)
- current_hfdlg.ci.bootpri = -127;
- if (current_hfdlg.ci.bootpri > 127)
- current_hfdlg.ci.bootpri = 127;
- break;
- case IDC_HARDFILE_DEVICE:
- GetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, current_hfdlg.ci.devname, sizeof current_hfdlg.ci.devname / sizeof (TCHAR));
- break;
- }
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- extern int harddrive_to_hdf (HWND, struct uae_prefs*, int);
- static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int recursive = 0;
- int v, i;
- int *p;
- LRESULT posn;
- static int oposn;
- if (dialog_inhibit)
- return 0;
- switch (msg) {
- case WM_INITDIALOG:
- {
- int index;
- oposn = -1;
- hdf_init_target ();
- recursive++;
- setautocomplete (hDlg, IDC_PATH_GEOMETRY);
- addhistorymenu(hDlg, current_hfdlg.ci.geometry, IDC_PATH_GEOMETRY, HISTORY_GEO, false, -1);
- setchecked(hDlg, IDC_HDF_PHYSGEOMETRY, current_hfdlg.ci.physical_geometry);
- setharddrive(hDlg);
- inithdcontroller(hDlg, current_hfdlg.ci.controller_type, current_hfdlg.ci.controller_type_unit, UAEDEV_HDF, current_hfdlg.ci.rootdir[0] != 0);
- CheckDlgButton (hDlg, IDC_HDF_RW, !current_hfdlg.ci.readonly);
- CheckDlgButton(hDlg, IDC_HDF_LOCK, current_hfdlg.ci.lock);
- CheckDlgButton(hDlg, IDC_HDF_IDENTITY, current_hfdlg.ci.loadidentity);
- SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_RESETCONTENT, 0, 0);
- ew (hDlg, IDC_HARDDRIVE_IMAGE, FALSE);
- index = -1;
- for (i = 0; i < hdf_getnumharddrives (); i++) {
- SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_ADDSTRING, 0, (LPARAM)hdf_getnameharddrive (i, 1, NULL, NULL, NULL));
- TCHAR *name1 = hdf_getnameharddrive (i, 4, NULL, NULL, NULL);
- TCHAR *name2 = hdf_getnameharddrive (i, 2, NULL, NULL, NULL);
- TCHAR *name3 = hdf_getnameharddrive (i, 0, NULL, NULL, NULL);
- if (!_tcscmp (current_hfdlg.ci.rootdir, name1) || !_tcscmp (current_hfdlg.ci.rootdir, name2) || !_tcscmp (current_hfdlg.ci.rootdir, name3))
- index = i;
- }
- if (index >= 0) {
- SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_SETCURSEL, index, 0);
- gui_set_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER, current_hfdlg.ci.controller_type + current_hfdlg.ci.controller_type_unit * HD_CONTROLLER_NEXT_UNIT);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_hfdlg.ci.controller_unit, 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_TYPE, CB_SETCURSEL, current_hfdlg.ci.controller_media_type, 0);
- SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_SETCURSEL, current_hfdlg.ci.unit_feature_level, 0);
- }
- recursive--;
- return TRUE;
- }
- case WM_COMMAND:
- if (recursive)
- break;
- recursive++;
- if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_KILLFOCUS) {
- switch (LOWORD(wParam)) {
- case IDC_PATH_GEOMETRY:
- getcomboboxtext(hDlg, IDC_PATH_GEOMETRY, current_hfdlg.ci.geometry, sizeof current_hfdlg.ci.geometry / sizeof(TCHAR));
- if (HIWORD (wParam) == CBN_KILLFOCUS) {
- addhistorymenu(hDlg, current_hfdlg.ci.geometry, IDC_PATH_GEOMETRY, HISTORY_GEO, false, -1);
- setharddrive(hDlg);
- updatehdfinfo (hDlg, true, false, true);
- }
- break;
- }
- }
- if (HIWORD (wParam) == BN_CLICKED) {
- switch (LOWORD (wParam)) {
- case IDOK:
- EndDialog (hDlg, 1);
- break;
- case IDCANCEL:
- EndDialog (hDlg, 0);
- break;
- case IDC_HDF_PHYSGEOMETRY:
- current_hfdlg.ci.physical_geometry = ischecked(hDlg, IDC_HDF_PHYSGEOMETRY);
- updatehdfinfo(hDlg, true, false, true);
- setharddrive(hDlg);
- break;
- case IDC_HARDDRIVE_ID:
- if (oposn >= 0) {
- void hd_get_meta(HWND hDlg, int idx, TCHAR*);
- hd_get_meta(hDlg, oposn, current_hfdlg.ci.geometry);
- setharddrive(hDlg);
- }
- break;
- case IDC_HARDDRIVE_IMAGE:
- posn = SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR)
- harddrive_to_hdf (hDlg, &workprefs, posn);
- break;
- case IDC_HDF_RW:
- posn = SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- int dang = 1;
- hdf_getnameharddrive (posn, 1, NULL, &dang, NULL);
- current_hfdlg.ci.readonly = (ischecked (hDlg, IDC_HDF_RW) && !dang) ? false : true;
- }
- break;
- case IDC_HDF_LOCK:
- posn = SendDlgItemMessage(hDlg, IDC_HARDDRIVE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- int dang = 1;
- hdf_getnameharddrive(posn, 1, NULL, &dang, NULL);
- current_hfdlg.ci.lock = ischecked(hDlg, IDC_HDF_LOCK);
- }
- break;
- case IDC_HDF_IDENTITY:
- posn = SendDlgItemMessage(hDlg, IDC_HDF_IDENTITY, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.loadidentity = ischecked(hDlg, IDC_HDF_IDENTITY);
- }
- break;
- }
- }
- switch(LOWORD(wParam))
- {
- case IDC_HARDDRIVE:
- posn = SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_GETCURSEL, 0, 0);
- if (oposn != posn && posn != CB_ERR) {
- oposn = posn;
- if (posn >= 0) {
- BOOL ena;
- uae_u32 flags;
- int dang = 1;
- hdf_getnameharddrive (posn, 1, NULL, &dang, &flags);
- _tcscpy (current_hfdlg.ci.rootdir, hdf_getnameharddrive (posn, 4, NULL, &dang, NULL));
- ena = dang >= 0;
- ew(hDlg, IDC_HARDDRIVE_IMAGE, ena);
- ew(hDlg, IDC_HARDDRIVE_ID, ena);
- ew(hDlg, IDC_HDF_LOCK, ena);
- ew(hDlg, IDOK, ena);
- ew(hDlg, IDC_HDF_RW, !dang);
- ew(hDlg, IDC_HDF_FEATURE_LEVEL, ena);
- ew(hDlg, IDC_HDF_CONTROLLER, ena);
- ew(hDlg, IDC_HDF_CONTROLLER_UNIT, ena);
- ew(hDlg, IDC_HDF_CONTROLLER_TYPE, ena);
- ew(hDlg, IDC_PATH_GEOMETRY, ena);
- ew(hDlg, IDC_PATH_GEOMETRY_SELECTOR, ena);
- ew(hDlg, IDC_HDF_PHYSGEOMETRY, ena && current_hfdlg.ci.geometry[0] == 0);
- if (dang)
- current_hfdlg.ci.readonly = true;
- current_hfdlg.ci.blocksize = 512;
- current_hfdlg.forcedcylinders = 0;
- current_hfdlg.ci.cyls = current_hfdlg.ci.highcyl = current_hfdlg.ci.sectors = current_hfdlg.ci.surfaces = 0;
- SetDlgItemText(hDlg, IDC_HDFINFO, _T(""));
- SetDlgItemText(hDlg, IDC_HDFINFO2, _T(""));
- SetDlgItemText(hDlg, IDC_HDFINFO3, _T(""));
- updatehdfinfo (hDlg, true, current_hfdlg.ci.geometry[0] ? false : true, true);
- hdf_getnameharddrive(posn, 1, NULL, &dang, &flags);
- ew(hDlg, IDC_HDF_IDENTITY, ena && (flags & 1));
- if (!(flags & 1))
- current_hfdlg.ci.loadidentity = false;
- gui_set_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER, current_hfdlg.ci.controller_type + current_hfdlg.ci.controller_type_unit * MAX_DUPLICATE_EXPANSION_BOARDS);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_hfdlg.ci.controller_unit, 0);
- CheckDlgButton(hDlg, IDC_HDF_RW, !current_hfdlg.ci.readonly);
- _tcscpy (current_hfdlg.ci.rootdir, hdf_getnameharddrive ((int)posn, 4, ¤t_hfdlg.ci.blocksize, NULL, NULL));
- setharddrive(hDlg);
- }
- }
- break;
- case IDC_HDF_CONTROLLER:
- posn = gui_get_string_cursor(hdmenutable, hDlg, IDC_HDF_CONTROLLER);
- if (posn != CB_ERR && current_hfdlg.ci.controller_type != posn) {
- current_hfdlg.ci.controller_type = posn % HD_CONTROLLER_NEXT_UNIT;
- current_hfdlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
- current_hfdlg.forcedcylinders = 0;
- current_hfdlg.ci.cyls = current_hfdlg.ci.highcyl = current_hfdlg.ci.sectors = current_hfdlg.ci.surfaces = 0;
- SetDlgItemText(hDlg, IDC_HDFINFO, _T(""));
- SetDlgItemText(hDlg, IDC_HDFINFO2, _T(""));
- SetDlgItemText(hDlg, IDC_HDFINFO3, _T(""));
- updatehdfinfo (hDlg, true, true, true);
- inithdcontroller(hDlg, current_hfdlg.ci.controller_type, current_hfdlg.ci.controller_type_unit, UAEDEV_HDF, current_hfdlg.ci.rootdir[0] != 0);
- SendDlgItemMessage(hDlg, IDC_HDF_CONTROLLER_UNIT, CB_SETCURSEL, current_hfdlg.ci.controller_unit, 0);
- sethardfiletypes(hDlg);
- }
- break;
- case IDC_HDF_CONTROLLER_UNIT:
- posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_UNIT, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.controller_unit = posn;
- }
- break;
- case IDC_HDF_CONTROLLER_TYPE:
- posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER_TYPE, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.controller_media_type = posn;
- }
- break;
- case IDC_HDF_FEATURE_LEVEL:
- posn = SendDlgItemMessage(hDlg, IDC_HDF_FEATURE_LEVEL, CB_GETCURSEL, 0, 0);
- if (posn != CB_ERR) {
- current_hfdlg.ci.unit_feature_level = posn;
- }
- break;
- case IDC_PATH_GEOMETRY_SELECTOR:
- if (DiskSelection (hDlg, IDC_PATH_GEOMETRY, 23, &workprefs, NULL, current_hfdlg.ci.geometry)) {
- getcomboboxtext(hDlg, IDC_PATH_GEOMETRY, current_hfdlg.ci.geometry, sizeof current_hfdlg.ci.geometry / sizeof(TCHAR));
- DISK_history_add(current_hfdlg.ci.geometry, -1, HISTORY_GEO, 1);
- setharddrive(hDlg);
- updatehdfinfo (hDlg, true, false, true);
- }
- break;
- case IDC_SECTORS:
- p = ¤t_hfdlg.ci.psecs;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_SECTORS, NULL, FALSE);
- if (v != *p) {
- set_phys_cyls(hDlg);
- updatehdfinfo (hDlg, true, false, true);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- case IDC_RESERVED:
- p = ¤t_hfdlg.ci.pcyls;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_RESERVED, NULL, FALSE);
- if (v != *p) {
- if (ischecked(hDlg, IDC_HDF_PHYSGEOMETRY)) {
- current_hfdlg.ci.physical_geometry = true;
- }
- updatehdfinfo (hDlg, true, false, true);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- case IDC_HEADS:
- p = ¤t_hfdlg.ci.pheads;
- v = *p;
- *p = GetDlgItemInt (hDlg, IDC_HEADS, NULL, FALSE);
- if (v != *p) {
- set_phys_cyls(hDlg);
- updatehdfinfo (hDlg, true, false, true);
- ew (hDlg, IDC_HDF_RDB, !is_hdf_rdb ());
- }
- break;
- }
- recursive--;
- break;
- }
- commonproc(hDlg, msg, wParam, lParam);
- return FALSE;
- }
- static void new_filesys (HWND hDlg, int entry)
- {
- struct uaedev_config_data *uci;
- struct uaedev_config_info ci;
- memcpy (&ci, ¤t_fsvdlg.ci, sizeof (struct uaedev_config_info));
- uci = add_filesys_config (&workprefs, entry, &ci);
- if (uci) {
- if (uci->ci.rootdir[0])
- filesys_media_change (uci->ci.rootdir, 1, uci);
- else if (uci->configoffset >= 0)
- filesys_eject (uci->configoffset);
- }
- }
- static void new_cddrive (HWND hDlg, int entry)
- {
- struct uaedev_config_info ci = { 0 };
- ci.device_emu_unit = 0;
- ci.controller_type = current_cddlg.ci.controller_type;
- ci.controller_unit = current_cddlg.ci.controller_unit;
- ci.type = UAEDEV_CD;
- ci.readonly = true;
- ci.blocksize = 2048;
- add_filesys_config (&workprefs, entry, &ci);
- }
- static void new_tapedrive (HWND hDlg, int entry)
- {
- struct uaedev_config_data *uci;
- struct uaedev_config_info ci = { 0 };
- ci.controller_type = current_tapedlg.ci.controller_type;
- ci.controller_unit = current_tapedlg.ci.controller_unit;
- ci.readonly = current_tapedlg.ci.readonly;
- _tcscpy (ci.rootdir, current_tapedlg.ci.rootdir);
- ci.type = UAEDEV_TAPE;
- ci.blocksize = 512;
- uci = add_filesys_config (&workprefs, entry, &ci);
- if (uci && uci->unitnum >= 0) {
- tape_media_change (uci->unitnum, &ci);
- }
- }
- static void new_hardfile (HWND hDlg, int entry)
- {
- struct uaedev_config_data *uci;
- struct uaedev_config_info ci;
- memcpy (&ci, ¤t_hfdlg.ci, sizeof (struct uaedev_config_info));
- uci = add_filesys_config (&workprefs, entry, &ci);
- if (uci) {
- struct hardfiledata *hfd = get_hardfile_data (uci->configoffset);
- if (hfd)
- hardfile_media_change (hfd, &ci, true, false);
- pcmcia_disk_reinsert(&workprefs, &uci->ci, false);
- }
- }
- static void new_harddrive (HWND hDlg, int entry)
- {
- struct uaedev_config_data *uci;
- uci = add_filesys_config (&workprefs, entry, ¤t_hfdlg.ci);
- if (uci) {
- struct hardfiledata *hfd = get_hardfile_data (uci->configoffset);
- if (hfd)
- hardfile_media_change (hfd, ¤t_hfdlg.ci, true, false);
- pcmcia_disk_reinsert(&workprefs, &uci->ci, false);
- }
- }
- static void harddisk_remove (HWND hDlg)
- {
- int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST), false);
- if (entry < 0)
- return;
- kill_filesys_unitconfig (&workprefs, entry);
- }
- static void harddisk_move (HWND hDlg, int up)
- {
- int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST), false);
- if (entry < 0)
- return;
- move_filesys_unitconfig (&workprefs, entry, up ? entry - 1 : entry + 1);
- }
- static void harddisk_edit (HWND hDlg)
- {
- int entry = listview_find_selected (GetDlgItem (hDlg, IDC_VOLUMELIST), false);
- int type;
- struct uaedev_config_data *uci;
- struct mountedinfo mi;
- if (entry < 0 || entry >= workprefs.mountitems)
- return;
- uci = &workprefs.mountconfig[entry];
- type = get_filesys_unitconfig (&workprefs, entry, &mi);
- if (type < 0)
- type = uci->ci.type == UAEDEV_HDF ? FILESYS_HARDFILE : FILESYS_VIRTUAL;
- if (uci->ci.type == UAEDEV_CD) {
- memcpy (¤t_cddlg.ci, uci, sizeof (struct uaedev_config_info));
- if (CustomDialogBox (IDD_CDDRIVE, hDlg, CDDriveSettingsProc)) {
- new_cddrive (hDlg, entry);
- }
- } else if (uci->ci.type == UAEDEV_TAPE) {
- memcpy (¤t_tapedlg.ci, uci, sizeof (struct uaedev_config_info));
- if (CustomDialogBox (IDD_TAPEDRIVE, hDlg, TapeDriveSettingsProc)) {
- new_tapedrive (hDlg, entry);
- }
- }
- else if(type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB)
- {
- current_hfdlg.forcedcylinders = uci->ci.highcyl;
- memcpy (¤t_hfdlg.ci, uci, sizeof (struct uaedev_config_info));
- if (CustomDialogBox (IDD_HARDFILE, hDlg, HardfileSettingsProc)) {
- new_hardfile (hDlg, entry);
- }
- }
- else if (type == FILESYS_HARDDRIVE) /* harddisk */
- {
- memcpy (¤t_hfdlg.ci, uci, sizeof (struct uaedev_config_info));
- if (CustomDialogBox (IDD_HARDDRIVE, hDlg, HarddriveSettingsProc)) {
- new_harddrive (hDlg, entry);
- }
- }
- else /* Filesystem */
- {
- memcpy (¤t_fsvdlg.ci, uci, sizeof (struct uaedev_config_info));
- archivehd = -1;
- if (CustomDialogBox (IDD_FILESYS, hDlg, VolumeSettingsProc)) {
- new_filesys (hDlg, entry);
- }
- }
- }
- static ACCEL HarddiskAccel[] = {
- { FVIRTKEY|FSHIFT, VK_UP, IDC_UP }, { FVIRTKEY|FSHIFT, VK_DOWN, IDC_DOWN },
- { FVIRTKEY, VK_RETURN, IDC_EDIT }, { FVIRTKEY, VK_DELETE, IDC_REMOVE },
- { 0, 0, 0 }
- };
- static void hilitehd (HWND hDlg)
- {
- int total = ListView_GetItemCount (cachedlist);
- if (total <= 0) {
- ew (hDlg, IDC_EDIT, FALSE);
- ew (hDlg, IDC_REMOVE, FALSE);
- return;
- }
- if (clicked_entry < 0)
- clicked_entry = 0;
- if (clicked_entry >= total)
- clicked_entry = total;
- ListView_SetItemState (cachedlist, clicked_entry, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- ew (hDlg, IDC_EDIT, TRUE);
- ew (hDlg, IDC_REMOVE, TRUE);
- }
- static int harddiskdlg_button (HWND hDlg, WPARAM wParam)
- {
- int button = LOWORD (wParam);
- switch (button) {
- case IDC_CD_SELECT:
- DiskSelection (hDlg, wParam, 17, &workprefs, NULL, NULL);
- quickstart_cdtype = 1;
- workprefs.cdslots[0].inuse = true;
- addcdtype (hDlg, IDC_CD_TYPE);
- InitializeListView (hDlg);
- hilitehd (hDlg);
- break;
- case IDC_CD_EJECT:
- eject_cd ();
- SetDlgItemText (hDlg, IDC_CD_TEXT, _T(""));
- addcdtype (hDlg, IDC_CD_TYPE);
- InitializeListView (hDlg);
- hilitehd (hDlg);
- break;
- case IDC_NEW_FS:
- default_fsvdlg (¤t_fsvdlg);
- archivehd = 0;
- if (CustomDialogBox (IDD_FILESYS, hDlg, VolumeSettingsProc))
- new_filesys (hDlg, -1);
- return 1;
- case IDC_NEW_FSARCH:
- archivehd = 1;
- default_fsvdlg (¤t_fsvdlg);
- if (CustomDialogBox (IDD_FILESYS, hDlg, VolumeSettingsProc))
- new_filesys (hDlg, -1);
- return 1;
- case IDC_NEW_HF:
- default_hfdlg (¤t_hfdlg, false);
- if (CustomDialogBox (IDD_HARDFILE, hDlg, HardfileSettingsProc))
- new_hardfile (hDlg, -1);
- return 1;
- case IDC_NEW_CD:
- if (CustomDialogBox (IDD_CDDRIVE, hDlg, CDDriveSettingsProc))
- new_cddrive (hDlg, -1);
- return 1;
- case IDC_NEW_TAPE:
- default_tapedlg (¤t_tapedlg);
- if (CustomDialogBox (IDD_TAPEDRIVE, hDlg, TapeDriveSettingsProc))
- new_tapedrive (hDlg, -1);
- return 1;
- case IDC_NEW_HD:
- default_hfdlg (¤t_hfdlg, true);
- current_hfdlg.ci.type = UAEDEV_HDF;
- if (hdf_init_target () == 0) {
- TCHAR tmp[MAX_DPATH];
- WIN32GUI_LoadUIString (IDS_NOHARDDRIVES, tmp, sizeof (tmp) / sizeof (TCHAR));
- gui