2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
2012-11-02 14:31:59 +04:00
|
|
|
// Copyright (C) 2003-2012 The Bochs Project
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2008-10-21 17:45:03 +04:00
|
|
|
#include "win32dialog.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2008-12-18 18:37:25 +03:00
|
|
|
#if BX_USE_TEXTCONFIG && defined(WIN32) && (BX_WITH_WIN32 || BX_WITH_SDL)
|
2004-01-29 21:50:33 +03:00
|
|
|
|
2008-10-21 17:45:03 +04:00
|
|
|
#include "bochs.h"
|
2010-02-26 17:18:19 +03:00
|
|
|
#include "param_names.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
#include "win32res.h"
|
2009-03-10 22:33:03 +03:00
|
|
|
#include "win32paramdlg.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2004-02-05 23:02:53 +03:00
|
|
|
const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
|
2006-11-12 13:07:18 +03:00
|
|
|
#if BX_DEBUGGER
|
2008-12-27 15:06:39 +03:00
|
|
|
extern char *debug_cmd;
|
|
|
|
extern bx_bool debug_cmd_ready;
|
2009-01-09 17:53:38 +03:00
|
|
|
extern bx_bool vgaw_refresh;
|
2006-11-12 13:07:18 +03:00
|
|
|
#endif
|
2005-10-22 15:00:00 +04:00
|
|
|
|
2007-12-03 23:50:24 +03:00
|
|
|
char *backslashes(char *s)
|
|
|
|
{
|
|
|
|
if (s != NULL) {
|
|
|
|
while (*s != 0) {
|
|
|
|
if (*s == '/') *s = '\\';
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
HWND GetBochsWindow()
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
2006-11-12 13:07:18 +03:00
|
|
|
hwnd = FindWindow("Bochs for Windows", NULL);
|
2003-05-22 00:33:24 +04:00
|
|
|
if (hwnd == NULL) {
|
|
|
|
hwnd = GetForegroundWindow();
|
|
|
|
}
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2003-09-01 21:47:57 +04:00
|
|
|
BOOL CreateImage(HWND hDlg, int sectors, const char *filename)
|
|
|
|
{
|
|
|
|
if (sectors < 1) {
|
|
|
|
MessageBox(hDlg, "The disk size is invalid.", "Invalid size", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (lstrlen(filename) < 1) {
|
|
|
|
MessageBox(hDlg, "You must type a file name for the new disk image.", "Bad filename", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
int ret = SIM->create_disk_image (filename, sectors, 0);
|
|
|
|
if (ret == -1) { // already exists
|
|
|
|
int answer = MessageBox(hDlg, "File exists. Do you want to overwrite it?",
|
|
|
|
"File exists", MB_YESNO);
|
|
|
|
if (answer == IDYES)
|
|
|
|
ret = SIM->create_disk_image (filename, sectors, 1);
|
2008-02-06 01:57:43 +03:00
|
|
|
else
|
2003-09-01 21:47:57 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ret == -2) {
|
|
|
|
MessageBox(hDlg, "I could not create the disk image. Check for permission problems or available disk space.", "Failed", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-29 22:52:46 +04:00
|
|
|
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
if (uMsg == BFFM_INITIALIZED) {
|
|
|
|
GetCurrentDirectory(MAX_PATH, path);
|
|
|
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)path);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-06 18:05:08 +03:00
|
|
|
#ifndef BIF_NEWDIALOGSTYLE
|
|
|
|
#define BIF_NEWDIALOGSTYLE 0
|
|
|
|
#endif
|
|
|
|
|
2006-04-09 17:55:55 +04:00
|
|
|
int BrowseDir(const char *Title, char *result)
|
|
|
|
{
|
|
|
|
BROWSEINFO browseInfo;
|
|
|
|
LPITEMIDLIST ItemIDList;
|
2006-08-30 00:10:27 +04:00
|
|
|
int r = -1;
|
2006-04-09 17:55:55 +04:00
|
|
|
|
|
|
|
memset(&browseInfo,0,sizeof(BROWSEINFO));
|
2009-03-24 19:28:03 +03:00
|
|
|
browseInfo.hwndOwner = GetBochsWindow();
|
2006-04-09 17:55:55 +04:00
|
|
|
browseInfo.pszDisplayName = result;
|
|
|
|
browseInfo.lpszTitle = (LPCSTR)Title;
|
|
|
|
browseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
|
2006-05-29 22:52:46 +04:00
|
|
|
browseInfo.lpfn = BrowseCallbackProc;
|
2006-04-09 17:55:55 +04:00
|
|
|
ItemIDList = SHBrowseForFolder(&browseInfo);
|
|
|
|
if (ItemIDList != NULL) {
|
|
|
|
*result = 0;
|
|
|
|
if (SHGetPathFromIDList(ItemIDList, result)) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (result[0]) r = 0;
|
2006-04-09 17:55:55 +04:00
|
|
|
}
|
|
|
|
// free memory used
|
|
|
|
IMalloc * imalloc = 0;
|
|
|
|
if (SUCCEEDED(SHGetMalloc(&imalloc))) {
|
|
|
|
imalloc->Free(ItemIDList);
|
|
|
|
imalloc->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
BxEvent *event;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
event = (BxEvent*)lParam;
|
|
|
|
level = event->u.logmsg.level;
|
|
|
|
SetWindowText(hDlg, SIM->get_log_level_name(level));
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKDEV), event->u.logmsg.prefix);
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
|
|
|
|
#endif
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
|
|
|
|
SetFocus(GetDlgItem(hDlg, IDASKLIST));
|
|
|
|
return FALSE;
|
|
|
|
case WM_CLOSE:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_GETCURSEL, 0, 0));
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-22 00:33:24 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_param_string_c *param;
|
2006-05-30 02:33:38 +04:00
|
|
|
char buffer[512];
|
|
|
|
const char *title;
|
2003-05-25 22:34:03 +04:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
param = (bx_param_string_c *)lParam;
|
2006-02-28 18:48:59 +03:00
|
|
|
title = param->get_label();
|
|
|
|
if ((title == NULL) || (strlen(title) == 0)) {
|
|
|
|
title = param->get_name();
|
|
|
|
}
|
|
|
|
SetWindowText(hDlg, title);
|
2003-05-25 22:34:03 +04:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDSTRING), param->getptr());
|
2005-10-22 15:00:00 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTRING), EM_SETLIMITTEXT, param->get_maxsize(), 0);
|
|
|
|
return TRUE;
|
2003-05-25 22:34:03 +04:00
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
2005-10-22 15:00:00 +04:00
|
|
|
GetDlgItemText(hDlg, IDSTRING, buffer, param->get_maxsize() + 1);
|
2003-05-25 22:34:03 +04:00
|
|
|
param->set(buffer);
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-25 22:34:03 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-07-16 01:02:05 +04:00
|
|
|
static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_param_filename_c *param;
|
2010-07-03 09:34:27 +04:00
|
|
|
static bx_param_bool_c *status, *readonly;
|
2005-11-20 20:22:44 +03:00
|
|
|
static bx_param_enum_c *devtype;
|
|
|
|
static bx_param_enum_c *mediatype;
|
2012-11-02 14:31:59 +04:00
|
|
|
bx_list_c *list;
|
2003-09-01 21:47:57 +04:00
|
|
|
char mesg[MAX_PATH];
|
2003-07-16 01:02:05 +04:00
|
|
|
char path[MAX_PATH];
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *title;
|
2005-11-20 20:22:44 +03:00
|
|
|
int i, cap;
|
2003-07-16 01:02:05 +04:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
param = (bx_param_filename_c *)lParam;
|
2012-11-02 14:31:59 +04:00
|
|
|
list = (bx_list_c *)param->get_parent();
|
|
|
|
status = SIM->get_param_bool("status", list);
|
|
|
|
readonly = SIM->get_param_bool("readonly", list);
|
|
|
|
devtype = SIM->get_param_enum("devtype", list);
|
|
|
|
mediatype = SIM->get_param_enum("type", list);
|
2005-11-20 20:22:44 +03:00
|
|
|
cap = devtype->get() - (int)devtype->get_min();
|
2009-03-23 22:05:16 +03:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDDEVTYPE), floppy_devtype_names[cap]);
|
2006-12-17 11:17:28 +03:00
|
|
|
i = 0;
|
|
|
|
while (floppy_type_names[i] != NULL) {
|
2005-11-20 20:22:44 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_ADDSTRING, 0, (LPARAM)floppy_type_names[i]);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SETITEMDATA, i, (LPARAM)(mediatype->get_min() + i));
|
2006-12-17 21:14:59 +03:00
|
|
|
i++;
|
2005-11-20 20:22:44 +03:00
|
|
|
}
|
|
|
|
cap = mediatype->get() - (int)mediatype->get_min();
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SETCURSEL, cap, 0);
|
2009-03-25 21:33:43 +03:00
|
|
|
if (status->get()) {
|
2003-07-16 01:02:05 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
2010-07-03 09:34:27 +04:00
|
|
|
if (readonly->get()) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDREADONLY), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
2009-03-26 20:57:20 +03:00
|
|
|
lstrcpy(path, param->getptr());
|
2003-08-30 21:13:06 +04:00
|
|
|
title = param->get_label();
|
|
|
|
if (!title) title = param->get_name();
|
|
|
|
SetWindowText(hDlg, title);
|
2009-03-26 20:57:20 +03:00
|
|
|
if (lstrlen(path) && lstrcmp(path, "none")) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDPATH), path);
|
2003-07-16 01:02:05 +04:00
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, -1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDBROWSE:
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2009-03-26 20:57:20 +03:00
|
|
|
if (AskFilename(hDlg, param, path) > 0) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDPATH), path);
|
2003-07-16 01:02:05 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
|
2005-11-27 17:15:11 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SELECTSTRING, (WPARAM)-1, (LPARAM)"auto");
|
2005-11-26 01:44:18 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCREATE), FALSE);
|
2003-07-16 01:02:05 +04:00
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
case IDOK:
|
2009-03-25 21:33:43 +03:00
|
|
|
status->set(0);
|
2003-07-16 01:02:05 +04:00
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2005-11-20 20:22:44 +03:00
|
|
|
if (lstrlen(path) == 0) {
|
2003-07-16 01:02:05 +04:00
|
|
|
lstrcpy(path, "none");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lstrcpy(path, "none");
|
|
|
|
}
|
2010-07-03 09:34:27 +04:00
|
|
|
readonly->set(SendMessage(GetDlgItem(hDlg, IDREADONLY), BM_GETCHECK, 0, 0) == BST_CHECKED);
|
2003-07-16 01:02:05 +04:00
|
|
|
param->set(path);
|
2005-11-20 20:22:44 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
cap = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETITEMDATA, i, 0);
|
|
|
|
mediatype->set(cap);
|
|
|
|
if (lstrcmp(path, "none")) {
|
2009-03-25 21:33:43 +03:00
|
|
|
status->set(1);
|
2005-11-20 20:22:44 +03:00
|
|
|
}
|
2003-07-16 01:02:05 +04:00
|
|
|
EndDialog(hDlg, 1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, -1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2005-11-20 20:22:44 +03:00
|
|
|
case IDMEDIATYPE:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCREATE), (floppy_type_n_sectors[i] > 0));
|
|
|
|
}
|
|
|
|
break;
|
2003-09-01 21:47:57 +04:00
|
|
|
case IDCREATE:
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2007-12-03 23:50:24 +03:00
|
|
|
backslashes(path);
|
2005-11-20 20:22:44 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
if (CreateImage(hDlg, floppy_type_n_sectors[i], path)) {
|
|
|
|
wsprintf(mesg, "Created a %s disk image called %s", floppy_type_names[i], path);
|
2003-09-01 21:47:57 +04:00
|
|
|
MessageBox(hDlg, mesg, "Image created", MB_OK);
|
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
void SetStandardLogOptions(HWND hDlg)
|
2004-02-01 22:22:41 +03:00
|
|
|
{
|
2004-02-05 23:02:53 +03:00
|
|
|
int level, idx;
|
2004-02-01 22:22:41 +03:00
|
|
|
int defchoice[5];
|
|
|
|
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-05 23:02:53 +03:00
|
|
|
int mod = 0;
|
2004-02-01 22:22:41 +03:00
|
|
|
int first = SIM->get_log_action (mod, level);
|
|
|
|
BOOL consensus = true;
|
|
|
|
// now compare all others to first. If all match, then use "first" as
|
|
|
|
// the initial value.
|
2004-02-05 23:02:53 +03:00
|
|
|
for (mod=1; mod<SIM->get_n_log_modules(); mod++) {
|
2004-02-01 22:22:41 +03:00
|
|
|
if (first != SIM->get_log_action (mod, level)) {
|
|
|
|
consensus = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consensus)
|
|
|
|
defchoice[level] = first;
|
|
|
|
else
|
|
|
|
defchoice[level] = 4;
|
|
|
|
}
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-01 22:22:41 +03:00
|
|
|
idx = 0;
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
2004-02-01 22:22:41 +03:00
|
|
|
for (int action=0; action<5; action++) {
|
2012-10-06 01:36:49 +04:00
|
|
|
// the exclude expression allows some choices not being available if they
|
|
|
|
// don't make any sense. For example, it would be stupid to ignore a panic.
|
|
|
|
if (!BX_LOG_OPTS_EXCLUDE(level, action)) {
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
2004-02-01 22:22:41 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == defchoice[level]) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-05 23:02:53 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
void SetAdvancedLogOptions(HWND hDlg)
|
2004-02-05 23:02:53 +03:00
|
|
|
{
|
|
|
|
int idx, level, mod;
|
|
|
|
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-05 23:02:53 +03:00
|
|
|
idx = 0;
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
|
|
|
for (int action=0; action<4; action++) {
|
2012-10-06 01:36:49 +04:00
|
|
|
// exclude some action / level combinations (see above)
|
|
|
|
if (!BX_LOG_OPTS_EXCLUDE(level, action)) {
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == SIM->get_log_action (mod, level)) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
2004-02-04 01:40:33 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-01 22:22:41 +03:00
|
|
|
}
|
|
|
|
|
2012-04-03 01:30:37 +04:00
|
|
|
void InitLogOptionsDialog(HWND hDlg, BOOL advanced)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
|
|
|
int idx, mod;
|
2012-02-21 23:50:56 +04:00
|
|
|
char name[32];
|
2009-03-22 12:40:18 +03:00
|
|
|
|
|
|
|
for (mod=0; mod<SIM->get_n_log_modules(); mod++) {
|
2012-02-21 23:50:56 +04:00
|
|
|
if (lstrcmp(SIM->get_logfn_name(mod), "?")) {
|
|
|
|
lstrcpyn(name, SIM->get_logfn_name(mod), 32);
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_ADDSTRING, 0, (LPARAM)name);
|
2009-03-22 12:40:18 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETITEMDATA, idx, mod);
|
|
|
|
}
|
|
|
|
}
|
2012-04-03 01:30:37 +04:00
|
|
|
if (advanced) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDADVLOGOPT), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
} else {
|
|
|
|
SetStandardLogOptions(hDlg);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyLogOptions(HWND hDlg, BOOL advanced)
|
|
|
|
{
|
|
|
|
int idx, level, mod, value;
|
|
|
|
|
|
|
|
if (advanced) {
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2009-03-22 12:40:18 +03:00
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
2012-04-06 17:15:27 +04:00
|
|
|
SIM->set_log_action(mod, level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
} else {
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2009-03-22 12:40:18 +03:00
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
|
|
|
if (value < 4) {
|
|
|
|
// set new default
|
2011-10-01 11:24:18 +04:00
|
|
|
SIM->set_default_log_action(level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
// apply that action to all modules (devices)
|
2011-10-01 11:24:18 +04:00
|
|
|
SIM->set_log_action(-1, level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), TRUE);
|
|
|
|
}
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
static BOOL CALLBACK LogOptDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
|
|
|
static BOOL advanced;
|
|
|
|
static BOOL changed;
|
|
|
|
long noticode;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2012-04-03 01:30:37 +04:00
|
|
|
advanced = (BOOL)lParam;
|
2012-04-06 17:15:27 +04:00
|
|
|
SIM->apply_log_actions_by_device(); // settings from bochsrc
|
2012-04-03 01:30:37 +04:00
|
|
|
InitLogOptionsDialog(hDlg, advanced);
|
2009-03-22 12:40:18 +03:00
|
|
|
changed = FALSE;
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), FALSE);
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
|
|
|
case CBN_SELCHANGE: /* LBN_SELCHANGE is the same value */
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDDEVLIST:
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
break;
|
|
|
|
case IDLOGEVT1:
|
|
|
|
case IDLOGEVT2:
|
|
|
|
case IDLOGEVT3:
|
|
|
|
case IDLOGEVT4:
|
|
|
|
case IDLOGEVT5:
|
|
|
|
if (!changed) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), FALSE);
|
|
|
|
if (advanced) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
|
|
|
changed = TRUE;
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDADVLOGOPT:
|
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDADVLOGOPT), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
advanced = TRUE;
|
|
|
|
} else {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, (WPARAM)-1, 0);
|
|
|
|
SetStandardLogOptions(hDlg);
|
|
|
|
advanced = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDAPPLY:
|
|
|
|
ApplyLogOptions(hDlg, advanced);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), FALSE);
|
2009-04-08 00:18:14 +04:00
|
|
|
changed = FALSE;
|
2009-03-22 12:40:18 +03:00
|
|
|
break;
|
|
|
|
case IDOK:
|
2009-04-08 00:18:14 +04:00
|
|
|
if (changed) {
|
|
|
|
ApplyLogOptions(hDlg, advanced);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-04-03 01:30:37 +04:00
|
|
|
void LogOptionsDialog(HWND hwnd, bx_bool runtime)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
2012-04-03 01:30:37 +04:00
|
|
|
DialogBoxParam(NULL, MAKEINTRESOURCE(LOGOPT_DLG), hwnd, (DLGPROC)LogOptDlgProc, (LPARAM)runtime);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
|
2012-02-17 21:23:57 +04:00
|
|
|
static BOOL CALLBACK PluginCtrlDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int count, i;
|
|
|
|
long code;
|
|
|
|
bx_list_c *plugin_ctrl;
|
|
|
|
char plugname[20], message[80];
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
plugin_ctrl = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL);
|
|
|
|
count = plugin_ctrl->get_size();
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_ADDSTRING, 0, (LPARAM)plugin_ctrl->get(i)->get_name());
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = HIWORD(wParam);
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDPLUGLIST:
|
|
|
|
if (code == LBN_SELCHANGE) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDEDIT:
|
|
|
|
if (code == EN_CHANGE) {
|
|
|
|
i = GetWindowTextLength(GetDlgItem(hDlg, IDEDIT));
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), i > 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDLOAD:
|
|
|
|
GetDlgItemText(hDlg, IDEDIT, plugname, 18);
|
|
|
|
if (SIM->opt_plugin_ctrl(plugname, 1)) {
|
|
|
|
wsprintf(message, "Plugin '%s' loaded", plugname);
|
|
|
|
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_ADDSTRING, 0, (LPARAM)plugname);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDUNLOAD:
|
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_GETTEXT, i, (LPARAM)plugname);
|
|
|
|
if (SIM->opt_plugin_ctrl(plugname, 0)) {
|
|
|
|
wsprintf(message, "Plugin '%s' unloaded", plugname);
|
|
|
|
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_DELETESTRING, i, 0);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginCtrlDialog(HWND hwnd)
|
|
|
|
{
|
|
|
|
DialogBox(NULL, MAKEINTRESOURCE(PLUGIN_CTRL_DLG), hwnd, (DLGPROC)PluginCtrlDlgProc);
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
typedef struct {
|
|
|
|
const char *label;
|
|
|
|
const char *param;
|
|
|
|
} edit_opts_t;
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
edit_opts_t start_options[] = {
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Plugin Control", "#plugins"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Logfile", "log"},
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Log Options", "#logopts"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"CPU", "cpu"},
|
2011-02-25 19:27:01 +03:00
|
|
|
#if BX_CPU_LEVEL >= 4
|
2010-02-26 01:04:31 +03:00
|
|
|
{"CPUID", "cpuid"},
|
2011-02-25 19:27:01 +03:00
|
|
|
#endif
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Memory", "memory"},
|
|
|
|
{"Clock & CMOS", "clock_cmos"},
|
|
|
|
{"PCI", "pci"},
|
|
|
|
{"Display & Interface", "display"},
|
|
|
|
{"Keyboard & Mouse", "keyboard_mouse"},
|
|
|
|
{"Disk & Boot", BXPN_MENU_DISK_WIN32},
|
|
|
|
{"Serial / Parallel / USB", "ports"},
|
|
|
|
{"Network card", "network"},
|
2011-03-12 20:37:26 +03:00
|
|
|
{"Sound card", "sound"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Other", "misc"},
|
|
|
|
#if BX_PLUGINS
|
|
|
|
{"User-defined Options", "user"},
|
|
|
|
#endif
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
edit_opts_t runtime_options[] = {
|
|
|
|
{"CD-ROM", BXPN_MENU_RUNTIME_CDROM},
|
|
|
|
{"USB", BXPN_MENU_RUNTIME_USB},
|
|
|
|
{"Misc", BXPN_MENU_RUNTIME_MISC},
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Log Options", "#logopts"},
|
2009-03-30 00:48:17 +04:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
static BOOL CALLBACK MainMenuDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
2009-03-30 00:48:17 +04:00
|
|
|
static bx_bool runtime;
|
2009-03-30 23:34:22 +04:00
|
|
|
int choice, code, i;
|
2009-03-22 12:40:18 +03:00
|
|
|
bx_param_filename_c *rcfile;
|
|
|
|
char path[BX_PATHNAME_LEN];
|
2009-03-30 00:48:17 +04:00
|
|
|
const char *pname;
|
2009-03-22 12:40:18 +03:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2009-03-30 00:48:17 +04:00
|
|
|
runtime = (bx_bool)lParam;
|
2009-03-22 12:40:18 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDEDITCFG), FALSE);
|
2009-03-30 00:48:17 +04:00
|
|
|
if (runtime) {
|
|
|
|
SetWindowText(hDlg, "Bochs Runtime Menu");
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDREADRC), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDRESETCFG), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDRESTORE), FALSE);
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDOK), "&Continue");
|
|
|
|
i = 0;
|
|
|
|
while (runtime_options[i].label != NULL) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_ADDSTRING, 0, (LPARAM)runtime_options[i].label);
|
|
|
|
i++;
|
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
choice = IDOK;
|
2009-03-30 00:48:17 +04:00
|
|
|
} else {
|
|
|
|
i = 0;
|
|
|
|
while (start_options[i].label != NULL) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_ADDSTRING, 0, (LPARAM)start_options[i].label);
|
|
|
|
i++;
|
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
if (SIM->get_param_enum(BXPN_BOCHS_START)->get() == BX_LOAD_START) {
|
|
|
|
choice = IDREADRC;
|
|
|
|
} else {
|
|
|
|
choice = IDOK;
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
SetFocus(GetDlgItem(hDlg, choice));
|
2009-03-30 00:48:17 +04:00
|
|
|
return FALSE;
|
2009-03-22 12:40:18 +03:00
|
|
|
case WM_CLOSE:
|
2012-03-29 21:05:44 +04:00
|
|
|
if (runtime) {
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
} else {
|
|
|
|
bx_user_quit = 1;
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = HIWORD(wParam);
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDREADRC:
|
|
|
|
rcfile = new bx_param_filename_c(NULL, "rcfile", "Load Bochs Config File",
|
|
|
|
"", "bochsrc.bxrc", BX_PATHNAME_LEN);
|
|
|
|
rcfile->set_extension("bxrc");
|
2009-03-29 04:21:10 +04:00
|
|
|
if (AskFilename(hDlg, rcfile, NULL) > 0) {
|
2009-03-22 12:40:18 +03:00
|
|
|
SIM->reset_all_param();
|
|
|
|
SIM->read_rc(rcfile->getptr());
|
|
|
|
}
|
|
|
|
delete rcfile;
|
|
|
|
break;
|
|
|
|
case IDWRITERC:
|
|
|
|
rcfile = new bx_param_filename_c(NULL, "rcfile", "Save Bochs Config File",
|
|
|
|
"", "bochsrc.bxrc", BX_PATHNAME_LEN);
|
|
|
|
rcfile->set_extension("bxrc");
|
|
|
|
rcfile->set_options(rcfile->SAVE_FILE_DIALOG);
|
2009-03-29 04:21:10 +04:00
|
|
|
if (AskFilename(hDlg, rcfile, NULL) > 0) {
|
2009-03-22 12:40:18 +03:00
|
|
|
SIM->write_rc(rcfile->getptr(), 1);
|
|
|
|
}
|
|
|
|
delete rcfile;
|
|
|
|
break;
|
|
|
|
case IDEDITBOX:
|
|
|
|
if ((code == LBN_SELCHANGE) ||
|
|
|
|
(code == LBN_DBLCLK)) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDEDITCFG), TRUE);
|
|
|
|
}
|
|
|
|
if (code != LBN_DBLCLK) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDEDITCFG:
|
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_GETCURSEL, 0, 0);
|
2009-03-30 00:48:17 +04:00
|
|
|
if (runtime) {
|
|
|
|
pname = runtime_options[i].param;
|
2009-03-22 12:40:18 +03:00
|
|
|
} else {
|
2009-03-30 00:48:17 +04:00
|
|
|
pname = start_options[i].param;
|
|
|
|
}
|
2012-02-17 21:23:57 +04:00
|
|
|
if (pname[0] != '#') {
|
2009-03-30 23:34:22 +04:00
|
|
|
if (((bx_list_c*)SIM->get_param(pname))->get_size() > 0) {
|
|
|
|
win32ParamDialog(hDlg, pname);
|
|
|
|
} else {
|
|
|
|
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
|
|
|
|
}
|
2009-03-30 00:48:17 +04:00
|
|
|
} else {
|
2012-02-17 21:23:57 +04:00
|
|
|
if (!lstrcmp(pname, "#logopts")) {
|
2012-04-03 01:30:37 +04:00
|
|
|
LogOptionsDialog(hDlg, runtime);
|
2012-02-17 21:23:57 +04:00
|
|
|
} else if (!lstrcmp(pname, "#plugins")) {
|
|
|
|
PluginCtrlDialog(hDlg);
|
|
|
|
} else {
|
|
|
|
MessageBox(hDlg, "Unknown keyword", "Warning", MB_ICONEXCLAMATION);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDRESETCFG:
|
|
|
|
if (MessageBox(hDlg, "Reset all options back to their factory defaults ?",
|
|
|
|
"Reset Configuration", MB_ICONEXCLAMATION | MB_YESNO) == IDYES) {
|
|
|
|
SIM->reset_all_param();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDRESTORE:
|
|
|
|
path[0] = 0;
|
|
|
|
if (BrowseDir("Restore Bochs state from...", path) >= 0) {
|
|
|
|
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(1);
|
|
|
|
SIM->get_param_string(BXPN_RESTORE_PATH)->set(path);
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDOK:
|
2011-06-11 23:38:52 +04:00
|
|
|
if (runtime) {
|
|
|
|
SIM->update_runtime_options();
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2012-03-29 21:05:44 +04:00
|
|
|
if (runtime) {
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDQUIT:
|
2009-03-24 19:28:03 +03:00
|
|
|
bx_user_quit = 1;
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
void LogAskDialog(BxEvent *event)
|
|
|
|
{
|
|
|
|
event->retcode = DialogBoxParam(NULL, MAKEINTRESOURCE(ASK_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)LogAskProc, (LPARAM)event);
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
int AskString(bx_param_string_c *param)
|
|
|
|
{
|
|
|
|
return DialogBoxParam(NULL, MAKEINTRESOURCE(STRING_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)StringParamProc, (LPARAM)param);
|
|
|
|
}
|
|
|
|
|
2003-07-16 01:02:05 +04:00
|
|
|
int FloppyDialog(bx_param_filename_c *param)
|
|
|
|
{
|
|
|
|
return DialogBoxParam(NULL, MAKEINTRESOURCE(FLOPPY_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)FloppyDlgProc, (LPARAM)param);
|
|
|
|
}
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
int MainMenuDialog(HWND hwnd, bx_bool runtime)
|
2004-02-01 04:40:14 +03:00
|
|
|
{
|
2009-03-30 00:48:17 +04:00
|
|
|
return DialogBoxParam(NULL, MAKEINTRESOURCE(MAINMENU_DLG), hwnd,
|
|
|
|
(DLGPROC)MainMenuDlgProc, (LPARAM)runtime);
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
|
2005-10-22 15:00:00 +04:00
|
|
|
BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
|
|
|
{
|
2006-12-17 21:14:59 +03:00
|
|
|
int opts;
|
2005-10-22 15:00:00 +04:00
|
|
|
bx_param_c *param;
|
|
|
|
bx_param_string_c *sparam;
|
2009-03-22 23:18:17 +03:00
|
|
|
char pname[BX_PATHNAME_LEN];
|
2005-10-22 15:00:00 +04:00
|
|
|
|
|
|
|
event->retcode = -1;
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case BX_SYNC_EVT_LOG_ASK:
|
|
|
|
LogAskDialog(event);
|
|
|
|
return event;
|
2009-01-12 22:15:35 +03:00
|
|
|
#if BX_DEBUGGER && BX_DEBUGGER_GUI
|
2006-11-12 13:07:18 +03:00
|
|
|
case BX_SYNC_EVT_GET_DBG_COMMAND:
|
|
|
|
{
|
2009-01-09 17:53:38 +03:00
|
|
|
// sim is at a "break" -- internal debugger is ready for a command
|
2006-11-17 19:50:39 +03:00
|
|
|
debug_cmd = new char[512];
|
|
|
|
debug_cmd_ready = FALSE;
|
2009-01-09 17:53:38 +03:00
|
|
|
HitBreak();
|
|
|
|
while (debug_cmd_ready == FALSE && bx_user_quit == 0)
|
|
|
|
{
|
|
|
|
if (vgaw_refresh != FALSE) // is the GUI frontend requesting a VGAW refresh?
|
2009-01-19 23:37:40 +03:00
|
|
|
SIM->refresh_vga();
|
2009-01-09 17:53:38 +03:00
|
|
|
vgaw_refresh = FALSE;
|
2006-11-17 19:50:39 +03:00
|
|
|
Sleep(10);
|
|
|
|
}
|
2009-01-09 17:53:38 +03:00
|
|
|
if (bx_user_quit != 0)
|
|
|
|
BX_EXIT(0);
|
2006-11-17 19:50:39 +03:00
|
|
|
event->u.debugcmd.command = debug_cmd;
|
2006-11-12 13:07:18 +03:00
|
|
|
event->retcode = 1;
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
case BX_ASYNC_EVT_DBG_MSG:
|
2009-02-08 21:52:06 +03:00
|
|
|
ParseIDText (event->u.logmsg.msg);
|
2006-11-12 13:07:18 +03:00
|
|
|
return event;
|
|
|
|
#endif
|
2005-10-22 15:00:00 +04:00
|
|
|
case BX_SYNC_EVT_ASK_PARAM:
|
|
|
|
param = event->u.param.param;
|
|
|
|
if (param->get_type() == BXT_PARAM_STRING) {
|
|
|
|
sparam = (bx_param_string_c *)param;
|
2009-03-16 00:16:17 +03:00
|
|
|
opts = sparam->get_options();
|
2005-10-22 15:00:00 +04:00
|
|
|
if (opts & sparam->IS_FILENAME) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (opts & sparam->SELECT_FOLDER_DLG) {
|
|
|
|
event->retcode = BrowseDir(sparam->get_label(), sparam->getptr());
|
|
|
|
} else if (param->get_parent() == NULL) {
|
2009-03-26 20:57:20 +03:00
|
|
|
event->retcode = AskFilename(GetBochsWindow(), (bx_param_filename_c *)sparam, NULL);
|
2005-10-22 15:00:00 +04:00
|
|
|
} else {
|
|
|
|
event->retcode = FloppyDialog((bx_param_filename_c *)sparam);
|
|
|
|
}
|
|
|
|
return event;
|
|
|
|
} else {
|
|
|
|
event->retcode = AskString(sparam);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
} else if (param->get_type() == BXT_LIST) {
|
2009-03-22 23:18:17 +03:00
|
|
|
SIM->get_first_cdrom()->get_param_path(pname, BX_PATHNAME_LEN);
|
|
|
|
event->retcode = win32ParamDialog(GetBochsWindow(), pname);
|
2005-10-22 15:00:00 +04:00
|
|
|
return event;
|
2006-06-01 00:12:43 +04:00
|
|
|
} else if (param->get_type() == BXT_PARAM_BOOL) {
|
|
|
|
UINT flag = MB_YESNO | MB_SETFOREGROUND;
|
|
|
|
if (((bx_param_bool_c *)param)->get() == 0) {
|
|
|
|
flag |= MB_DEFBUTTON2;
|
|
|
|
}
|
|
|
|
((bx_param_bool_c *)param)->set(MessageBox(GetActiveWindow(), param->get_description(), param->get_label(), flag) == IDYES);
|
|
|
|
event->retcode = 0;
|
|
|
|
return event;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
2009-03-24 19:28:03 +03:00
|
|
|
event->retcode = 0;
|
2005-10-22 15:00:00 +04:00
|
|
|
// fall into default case
|
|
|
|
default:
|
2009-03-24 19:28:03 +03:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int win32_ci_callback(void *userdata, ci_command_t command)
|
|
|
|
{
|
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case CI_START:
|
|
|
|
SIM->set_notify_callback(win32_notify_callback, NULL);
|
|
|
|
if (SIM->get_param_enum(BXPN_BOCHS_START)->get() == BX_QUICK_START) {
|
|
|
|
SIM->begin_simulation(bx_startup_flags.argc, bx_startup_flags.argv);
|
|
|
|
// we don't expect it to return, but if it does, quit
|
|
|
|
SIM->quit_sim(1);
|
|
|
|
} else {
|
2009-03-30 00:48:17 +04:00
|
|
|
if (MainMenuDialog(GetActiveWindow(), 0) == 1) {
|
|
|
|
SIM->begin_simulation(bx_startup_flags.argc, bx_startup_flags.argv);
|
|
|
|
}
|
|
|
|
SIM->quit_sim(1);
|
2009-03-24 19:28:03 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CI_RUNTIME_CONFIG:
|
2009-03-30 00:48:17 +04:00
|
|
|
if (MainMenuDialog(GetBochsWindow(), 1) < 0) {
|
2009-03-24 19:28:03 +03:00
|
|
|
bx_user_quit = 1;
|
|
|
|
#if !BX_DEBUGGER
|
|
|
|
bx_atexit();
|
|
|
|
SIM->quit_sim(1);
|
|
|
|
#else
|
|
|
|
bx_dbg_exit(1);
|
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CI_SHUTDOWN:
|
|
|
|
break;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
2009-03-24 19:28:03 +03:00
|
|
|
return 0;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
|
2009-03-24 19:28:03 +03:00
|
|
|
int init_win32_config_interface()
|
2005-10-22 15:00:00 +04:00
|
|
|
{
|
2009-03-24 19:28:03 +03:00
|
|
|
SIM->register_configuration_interface("win32config", win32_ci_callback, NULL);
|
|
|
|
return 0; // success
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
|
2004-01-29 21:50:33 +03:00
|
|
|
#endif // BX_USE_TEXTCONFIG && defined(WIN32)
|