From af6cead246a1301d57308dcf264af36d40a313b4 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Mon, 13 Jan 2020 17:11:54 -0300 Subject: [PATCH 1/3] Convert existing MessageBox calls to TaskDialog --- src/win/win_dialog.c | 46 ++++++++++++++++++++++------------------ src/win/win_ui.c | 50 +++++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 729be881e..a17d96953 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -43,34 +43,36 @@ int ui_msgbox(int flags, void *arg) { WCHAR temp[512]; - DWORD fl = 0; + WCHAR *icon = NULL; + TASKDIALOG_COMMON_BUTTON_FLAGS buttons = TDCBF_OK_BUTTON; WCHAR *str = NULL; - WCHAR *cap = NULL; + WCHAR *instr = NULL; + int res = 0; switch(flags & 0x1f) { case MBX_INFO: /* just an informational message */ - fl = (MB_OK | MB_ICONINFORMATION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + icon = TD_INFORMATION_ICON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_ERROR: /* error message */ if (flags & MBX_FATAL) { - fl = (MB_OK | MB_ICONERROR); - cap = plat_get_string(IDS_2050); /* "Fatal Error"*/ + icon = TD_ERROR_ICON; + instr = plat_get_string(IDS_2050); /* "Fatal Error"*/ } else { - fl = (MB_OK | MB_ICONWARNING); - cap = plat_get_string(IDS_2049); /* "Error" */ + icon = TD_WARNING_ICON; + instr = plat_get_string(IDS_2049); /* "Error" */ } break; case MBX_QUESTION: /* question */ - fl = (MB_YESNOCANCEL | MB_ICONQUESTION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_QUESTION_YN: /* question */ - fl = (MB_YESNO | MB_ICONQUESTION); - cap = plat_get_string(IDS_STRINGS); /* "86Box" */ + buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; + instr = plat_get_string(IDS_STRINGS); /* "86Box" */ break; } @@ -99,17 +101,21 @@ ui_msgbox(int flags, void *arg) } /* At any rate, we do have a valid (wide) string now. */ - fl = MessageBox(hwndMain, /* our main window */ - str, /* error message etc */ - cap, /* window caption */ - fl); + TaskDialog(hwndMain, /* our main window */ + NULL, /* no icon resource */ + plat_get_string(IDS_STRINGS), /* window caption */ + instr, /* main instruction */ + str, /* error message */ + buttons, + icon, + &res); /* pointer to result */ /* Convert return values to generic ones. */ - if (fl == IDNO) fl = 1; - else if (fl == IDCANCEL) fl = -1; - else fl = 0; + if (res == IDNO) res = 1; + else if (res == IDCANCEL) res = -1; + else res = 0; - return(fl); + return(res); } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 4e99eebb4..71f89a83b 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -836,10 +836,14 @@ ui_init(int nCmdShow) if (settings_only) { if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - MessageBox(hwnd, - plat_get_string(IDS_2056), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2056), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(6); } @@ -926,10 +930,14 @@ ui_init(int nCmdShow) ridev.dwFlags = RIDEV_NOHOTKEYS; ridev.hwndTarget = NULL; /* current focus window */ if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) { - MessageBox(hwndMain, - plat_get_string(IDS_2114), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2114), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(4); } keyboard_getkeymap(); @@ -940,10 +948,14 @@ ui_init(int nCmdShow) /* Load the accelerator table */ haccel = LoadAccelerators(hinstance, ACCEL_NAME); if (haccel == NULL) { - MessageBox(hwndMain, - plat_get_string(IDS_2113), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2113), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(3); } @@ -973,19 +985,27 @@ ui_init(int nCmdShow) /* All done, fire up the actual emulated machine. */ if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - MessageBox(hwnd, - plat_get_string(IDS_2056), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2056), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(6); } /* Initialize the configured Video API. */ if (! plat_setvid(vid_api)) { - MessageBox(hwnd, - plat_get_string(IDS_2095), + TaskDialog(hwnd, + NULL, + plat_get_string(IDS_STRINGS), plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); + plat_get_string(IDS_2095), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + NULL); return(5); } From 2b6258139ebef470777b67016543e5c13dff0351 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Tue, 24 Mar 2020 19:13:58 -0300 Subject: [PATCH 2/3] Revert "Convert existing MessageBox calls to TaskDialog" This reverts commit af6cead246a1301d57308dcf264af36d40a313b4. --- src/win/win_dialog.c | 46 ++++++++++++++++++---------------------- src/win/win_ui.c | 50 +++++++++++++------------------------------- 2 files changed, 35 insertions(+), 61 deletions(-) diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 1fca7cfd1..5d867f67f 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -43,36 +43,34 @@ int ui_msgbox(int flags, void *arg) { WCHAR temp[512]; - WCHAR *icon = NULL; - TASKDIALOG_COMMON_BUTTON_FLAGS buttons = TDCBF_OK_BUTTON; + DWORD fl = 0; WCHAR *str = NULL; - WCHAR *instr = NULL; - int res = 0; + WCHAR *cap = NULL; switch(flags & 0x1f) { case MBX_INFO: /* just an informational message */ - icon = TD_INFORMATION_ICON; - instr = plat_get_string(IDS_STRINGS); /* "86Box" */ + fl = (MB_OK | MB_ICONINFORMATION); + cap = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_ERROR: /* error message */ if (flags & MBX_FATAL) { - icon = TD_ERROR_ICON; - instr = plat_get_string(IDS_2050); /* "Fatal Error"*/ + fl = (MB_OK | MB_ICONERROR); + cap = plat_get_string(IDS_2050); /* "Fatal Error"*/ } else { - icon = TD_WARNING_ICON; - instr = plat_get_string(IDS_2049); /* "Error" */ + fl = (MB_OK | MB_ICONWARNING); + cap = plat_get_string(IDS_2049); /* "Error" */ } break; case MBX_QUESTION: /* question */ - buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON; - instr = plat_get_string(IDS_STRINGS); /* "86Box" */ + fl = (MB_YESNOCANCEL | MB_ICONQUESTION); + cap = plat_get_string(IDS_STRINGS); /* "86Box" */ break; case MBX_QUESTION_YN: /* question */ - buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; - instr = plat_get_string(IDS_STRINGS); /* "86Box" */ + fl = (MB_YESNO | MB_ICONQUESTION); + cap = plat_get_string(IDS_STRINGS); /* "86Box" */ break; } @@ -101,21 +99,17 @@ ui_msgbox(int flags, void *arg) } /* At any rate, we do have a valid (wide) string now. */ - TaskDialog(hwndMain, /* our main window */ - NULL, /* no icon resource */ - plat_get_string(IDS_STRINGS), /* window caption */ - instr, /* main instruction */ - str, /* error message */ - buttons, - icon, - &res); /* pointer to result */ + fl = MessageBox(hwndMain, /* our main window */ + str, /* error message etc */ + cap, /* window caption */ + fl); /* Convert return values to generic ones. */ - if (res == IDNO) res = 1; - else if (res == IDCANCEL) res = -1; - else res = 0; + if (fl == IDNO) fl = 1; + else if (fl == IDCANCEL) fl = -1; + else fl = 0; - return(res); + return(fl); } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index df7a549c7..cfe5d37fb 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -843,14 +843,10 @@ ui_init(int nCmdShow) if (settings_only) { if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - TaskDialog(hwnd, - NULL, - plat_get_string(IDS_STRINGS), - plat_get_string(IDS_2050), + MessageBox(hwnd, plat_get_string(IDS_2056), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - NULL); + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); return(6); } @@ -937,14 +933,10 @@ ui_init(int nCmdShow) ridev.dwFlags = RIDEV_NOHOTKEYS; ridev.hwndTarget = NULL; /* current focus window */ if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) { - TaskDialog(hwnd, - NULL, - plat_get_string(IDS_STRINGS), - plat_get_string(IDS_2050), + MessageBox(hwndMain, plat_get_string(IDS_2114), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - NULL); + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); return(4); } keyboard_getkeymap(); @@ -955,14 +947,10 @@ ui_init(int nCmdShow) /* Load the accelerator table */ haccel = LoadAccelerators(hinstance, ACCEL_NAME); if (haccel == NULL) { - TaskDialog(hwnd, - NULL, - plat_get_string(IDS_STRINGS), - plat_get_string(IDS_2050), + MessageBox(hwndMain, plat_get_string(IDS_2113), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - NULL); + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); return(3); } @@ -992,27 +980,19 @@ ui_init(int nCmdShow) /* All done, fire up the actual emulated machine. */ if (! pc_init_modules()) { /* Dang, no ROMs found at all! */ - TaskDialog(hwnd, - NULL, - plat_get_string(IDS_STRINGS), - plat_get_string(IDS_2050), + MessageBox(hwnd, plat_get_string(IDS_2056), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - NULL); + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); return(6); } /* Initialize the configured Video API. */ if (! plat_setvid(vid_api)) { - TaskDialog(hwnd, - NULL, - plat_get_string(IDS_STRINGS), - plat_get_string(IDS_2050), + MessageBox(hwnd, plat_get_string(IDS_2095), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - NULL); + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); return(5); } From 18688a74cdac697766442871ad5a4697b6b6b926 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Tue, 24 Mar 2020 19:53:09 -0300 Subject: [PATCH 3/3] Hardware monitor voltage reading improvements --- src/hwm.h | 6 +++--- src/hwm_w83781d.c | 2 +- src/machine/m_at_socket8.c | 20 ++++++++++---------- src/postcard.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/hwm.h b/src/hwm.h index c5d482fb7..23d9014a5 100644 --- a/src/hwm.h +++ b/src/hwm.h @@ -17,13 +17,13 @@ # define EMU_HWM_H -#define VDIV(v, r1, r2) (((v) * (r2)) / ((r1) + (r2))) +#define RESISTOR_DIVIDER(v, r1, r2) (((v) * (r2)) / ((r1) + (r2))) typedef struct _hwm_values_ { uint16_t fans[4]; - uint8_t temperatures[4]; - uint8_t voltages[8]; + uint8_t temperatures[4]; + uint16_t voltages[8]; } hwm_values_t; diff --git a/src/hwm_w83781d.c b/src/hwm_w83781d.c index 1f6b3ab26..5cb6bbef5 100644 --- a/src/hwm_w83781d.c +++ b/src/hwm_w83781d.c @@ -380,7 +380,7 @@ w83781d_reset(w83781d_t *dev, uint8_t initialization) /* WARNING: Array elements are register - 0x20. */ uint8_t i; for (i = 0; i <= 6; i++) - dev->regs[i] = dev->values->voltages[i]; + dev->regs[i] = (dev->values->voltages[i] / 16); dev->regs[0x07] = dev->values->temperatures[0]; for (i = 0; i <= 2; i++) dev->regs[0x08 + i] = W83781D_RPM_TO_REG(dev->values->fans[i], 2); diff --git a/src/machine/m_at_socket8.c b/src/machine/m_at_socket8.c index d6f590d7b..dcac383a6 100644 --- a/src/machine/m_at_socket8.c +++ b/src/machine/m_at_socket8.c @@ -178,19 +178,19 @@ machine_at_p2bls_init(const machine_t *model) 0, /* unused */ 27, /* CPU */ 0 - }, { /* voltages (divisors other than 16 = unclear how that number was achieved) */ - 2050 / 16, /* VCORE (2.05V by default) */ - 0, /* unused */ - 3300 / 16, /* +3.3V */ - 5000 / 27, /* +5V */ - VDIV(12000, 28, 10) / 16, /* +12V (with 28K/10K resistor divider suggested in the W83781D datasheet) */ - 12000 / 55, /* -12V */ - 5000 / 24, /* -5V */ - 0 + }, { /* voltages */ + 2050, /* VCORE (2.05V by default) */ + 0, /* unused */ + 3300, /* +3.3V */ + RESISTOR_DIVIDER(5000, 11, 16), /* +5V (divider values bruteforced) */ + RESISTOR_DIVIDER(12000, 28, 10), /* +12V (28K/10K divider suggested in the W83781D datasheet) */ + RESISTOR_DIVIDER(12000, 853, 347), /* -12V (divider values bruteforced) */ + RESISTOR_DIVIDER(5000, 1, 2), /* -5V (divider values bruteforced) */ + 0 } }; if (model->cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type == CPU_PENTIUM2) - machine_hwm.voltages[0] = 2800 / 16; /* set higher VCORE (2.8V) for Klamath */ + machine_hwm.voltages[0] = 2800; /* set higher VCORE (2.8V) for Klamath */ hwm_set_values(machine_hwm); device_add(&as99127f_device); diff --git a/src/postcard.h b/src/postcard.h index 4bfc912f5..f8213c25c 100644 --- a/src/postcard.h +++ b/src/postcard.h @@ -32,4 +32,4 @@ extern const device_t postcard_device; #endif -#endif /*BUGGER_H*/ +#endif /*POSTCARD_H*/