summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules')
-rw-r--r--src/osd/modules/debugger/debug_module.h8
-rw-r--r--src/osd/modules/debugger/debuggdbstub.cpp63
-rw-r--r--src/osd/modules/debugger/debugimgui.cpp20
-rw-r--r--src/osd/modules/debugger/debugqt.cpp362
-rw-r--r--src/osd/modules/debugger/debugwin.cpp169
-rw-r--r--src/osd/modules/debugger/none.cpp5
-rw-r--r--src/osd/modules/debugger/osx/debugconsole.mm32
-rw-r--r--src/osd/modules/debugger/osx/debugosx.h35
-rw-r--r--src/osd/modules/debugger/osx/debugview.mm49
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.h13
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.mm22
-rw-r--r--src/osd/modules/debugger/osx/deviceinfoviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/devicesviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/disassemblyview.mm4
-rw-r--r--src/osd/modules/debugger/osx/disassemblyviewer.mm8
-rw-r--r--src/osd/modules/debugger/osx/errorlogviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/memoryview.mm18
-rw-r--r--src/osd/modules/debugger/osx/memoryviewer.mm6
-rw-r--r--src/osd/modules/debugger/osx/pointsviewer.mm6
-rw-r--r--src/osd/modules/debugger/qt/breakpointswindow.cpp55
-rw-r--r--src/osd/modules/debugger/qt/breakpointswindow.h11
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.cpp88
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.h12
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.cpp18
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.h8
-rw-r--r--src/osd/modules/debugger/qt/deviceinformationwindow.cpp40
-rw-r--r--src/osd/modules/debugger/qt/deviceinformationwindow.h14
-rw-r--r--src/osd/modules/debugger/qt/deviceswindow.cpp28
-rw-r--r--src/osd/modules/debugger/qt/deviceswindow.h10
-rw-r--r--src/osd/modules/debugger/qt/logwindow.cpp29
-rw-r--r--src/osd/modules/debugger/qt/logwindow.h12
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.cpp94
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.h22
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.cpp291
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.h14
-rw-r--r--src/osd/modules/debugger/qt/windowqt.cpp54
-rw-r--r--src/osd/modules/debugger/qt/windowqt.h28
-rw-r--r--src/osd/modules/debugger/win/consolewininfo.cpp145
-rw-r--r--src/osd/modules/debugger/win/consolewininfo.h7
-rw-r--r--src/osd/modules/debugger/win/debugbaseinfo.cpp4
-rw-r--r--src/osd/modules/debugger/win/debugbaseinfo.h6
-rw-r--r--src/osd/modules/debugger/win/debugviewinfo.cpp93
-rw-r--r--src/osd/modules/debugger/win/debugviewinfo.h10
-rw-r--r--src/osd/modules/debugger/win/debugwin.h11
-rw-r--r--src/osd/modules/debugger/win/debugwininfo.cpp118
-rw-r--r--src/osd/modules/debugger/win/debugwininfo.h22
-rw-r--r--src/osd/modules/debugger/win/disasmbasewininfo.cpp28
-rw-r--r--src/osd/modules/debugger/win/disasmbasewininfo.h6
-rw-r--r--src/osd/modules/debugger/win/disasmviewinfo.cpp32
-rw-r--r--src/osd/modules/debugger/win/disasmviewinfo.h8
-rw-r--r--src/osd/modules/debugger/win/disasmwininfo.cpp38
-rw-r--r--src/osd/modules/debugger/win/disasmwininfo.h9
-rw-r--r--src/osd/modules/debugger/win/editwininfo.cpp6
-rw-r--r--src/osd/modules/debugger/win/editwininfo.h6
-rw-r--r--src/osd/modules/debugger/win/logviewinfo.cpp6
-rw-r--r--src/osd/modules/debugger/win/logviewinfo.h4
-rw-r--r--src/osd/modules/debugger/win/logwininfo.cpp15
-rw-r--r--src/osd/modules/debugger/win/logwininfo.h7
-rw-r--r--src/osd/modules/debugger/win/memoryviewinfo.cpp40
-rw-r--r--src/osd/modules/debugger/win/memoryviewinfo.h8
-rw-r--r--src/osd/modules/debugger/win/memorywininfo.cpp40
-rw-r--r--src/osd/modules/debugger/win/memorywininfo.h8
-rw-r--r--src/osd/modules/debugger/win/pointswininfo.cpp49
-rw-r--r--src/osd/modules/debugger/win/pointswininfo.h8
-rw-r--r--src/osd/modules/debugger/win/uimetrics.cpp93
-rw-r--r--src/osd/modules/debugger/win/uimetrics.h41
-rw-r--r--src/osd/modules/debugger/xmlconfig.cpp50
-rw-r--r--src/osd/modules/debugger/xmlconfig.h68
-rw-r--r--src/osd/modules/diagnostics/diagnostics_win32.cpp3
-rw-r--r--src/osd/modules/file/winfile.cpp88
-rw-r--r--src/osd/modules/file/winfile.h2
-rw-r--r--src/osd/modules/file/winptty.cpp10
-rw-r--r--src/osd/modules/font/font_dwrite.cpp14
-rw-r--r--src/osd/modules/font/font_sdl.cpp4
-rw-r--r--src/osd/modules/font/font_windows.cpp2
-rw-r--r--src/osd/modules/input/input_sdl.cpp17
-rw-r--r--src/osd/modules/input/input_sdlcommon.cpp34
-rw-r--r--src/osd/modules/input/input_windows.cpp20
-rw-r--r--src/osd/modules/lib/osdlib.h30
-rw-r--r--src/osd/modules/lib/osdlib_macosx.cpp83
-rw-r--r--src/osd/modules/lib/osdlib_unix.cpp48
-rw-r--r--src/osd/modules/lib/osdlib_win32.cpp81
-rw-r--r--src/osd/modules/lib/osdobj_common.cpp3
-rw-r--r--src/osd/modules/midi/portmidi.cpp5
-rw-r--r--src/osd/modules/netdev/pcap.cpp1
-rw-r--r--src/osd/modules/netdev/taptun.cpp1
-rw-r--r--src/osd/modules/render/bgfx/statereader.cpp1
87 files changed, 2035 insertions, 1052 deletions
diff --git a/src/osd/modules/debugger/debug_module.h b/src/osd/modules/debugger/debug_module.h
index fb659a1b312..9e3d85f9fe8 100644
--- a/src/osd/modules/debugger/debug_module.h
+++ b/src/osd/modules/debugger/debug_module.h
@@ -5,8 +5,10 @@
*
*/
-#ifndef DEBUG_MODULE_H_
-#define DEBUG_MODULE_H_
+#ifndef MAME_OSD_DEBUGGER_DEBUG_MODULE_H
+#define MAME_OSD_DEBUGGER_DEBUG_MODULE_H
+
+#pragma once
#include "osdepend.h"
#include "modules/osdmodule.h"
@@ -30,4 +32,4 @@ public:
-#endif /* DEBUG_MODULE_H_ */
+#endif // MAME_OSD_DEBUGGER_DEBUG_MODULE_H
diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp
index eaeb1df4cca..3b7b828d176 100644
--- a/src/osd/modules/debugger/debuggdbstub.cpp
+++ b/src/osd/modules/debugger/debuggdbstub.cpp
@@ -7,18 +7,24 @@
//============================================================
#include "emu.h"
+#include "debug_module.h"
+
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include "debug/points.h"
#include "debug/textbuf.h"
-#include "debug_module.h"
#include "debugger.h"
-#include "fileio.h"
+
#include "modules/lib/osdobj_common.h"
#include "modules/osdmodule.h"
+#include "fileio.h"
+
#include <cinttypes>
+
+namespace {
+
//-------------------------------------------------------------------------
#define MAX_PACKET_SIZE 16384
@@ -411,7 +417,7 @@ static const std::map<std::string, const gdb_register_map &> gdb_register_maps =
{ "m68000", gdb_register_map_m68000 },
{ "z80", gdb_register_map_z80 },
{ "m6502", gdb_register_map_m6502 },
- { "n2a03", gdb_register_map_m6502 },
+ { "rp2a03", gdb_register_map_m6502 },
{ "m6809", gdb_register_map_m6809 },
{ "score7", gdb_register_map_score7 },
};
@@ -495,6 +501,7 @@ public:
cmd_reply handle_P(const char *buf);
cmd_reply handle_q(const char *buf);
cmd_reply handle_s(const char *buf);
+ cmd_reply handle_T(const char *buf);
cmd_reply handle_z(const char *buf);
cmd_reply handle_Z(const char *buf);
@@ -644,7 +651,7 @@ void debug_gdbstub::wait_for_debugger(device_t &device, bool firststop)
if ( firststop && !m_initialized )
{
// find the "main" CPU, which is the first CPU (gdbstub doesn't have any notion of switching CPUs)
- m_maincpu = device_type_enumerator<cpu_device>(m_machine->root_device()).first();
+ m_maincpu = device_interface_enumerator<cpu_device>(m_machine->root_device()).first();
if (!m_maincpu)
fatalerror("gdbstub: cannot find any CPUs\n");
@@ -1101,6 +1108,17 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_s(const char *buf)
}
//-------------------------------------------------------------------------
+// Find out if the thread XX is alive.
+debug_gdbstub::cmd_reply debug_gdbstub::handle_T(const char *buf)
+{
+ if ( is_thread_id_ok(buf) )
+ return REPLY_OK;
+
+ // thread is dead
+ return REPLY_ENN;
+}
+
+//-------------------------------------------------------------------------
static bool remove_breakpoint(device_debug *debug, uint64_t address, int /*kind*/)
{
const debug_breakpoint *bp = debug->breakpoint_find(address);
@@ -1199,15 +1217,15 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_Z(const char *buf)
return REPLY_OK;
case 2:
// write watchpoint
- debug->watchpoint_set(*m_address_space, read_or_write::WRITE, offset, kind, nullptr, nullptr);
+ debug->watchpoint_set(*m_address_space, read_or_write::WRITE, offset, kind);
return REPLY_OK;
case 3:
// read watchpoint
- debug->watchpoint_set(*m_address_space, read_or_write::READ, offset, kind, nullptr, nullptr);
+ debug->watchpoint_set(*m_address_space, read_or_write::READ, offset, kind);
return REPLY_OK;
case 4:
// access watchpoint
- debug->watchpoint_set(*m_address_space, read_or_write::READWRITE, offset, kind, nullptr, nullptr);
+ debug->watchpoint_set(*m_address_space, read_or_write::READWRITE, offset, kind);
return REPLY_OK;
}
@@ -1270,6 +1288,7 @@ void debug_gdbstub::handle_packet()
case 'P': reply = handle_P(buf); break;
case 'q': reply = handle_q(buf); break;
case 's': reply = handle_s(buf); break;
+ case 'T': reply = handle_T(buf); break;
case 'z': reply = handle_z(buf); break;
case 'Z': reply = handle_Z(buf); break;
}
@@ -1282,22 +1301,6 @@ void debug_gdbstub::handle_packet()
}
//-------------------------------------------------------------------------
-#define BYTESWAP_64(x) ((((x) << 56) & 0xFF00000000000000) \
- | (((x) << 40) & 0x00FF000000000000) \
- | (((x) << 24) & 0x0000FF0000000000) \
- | (((x) << 8) & 0x000000FF00000000) \
- | (((x) >> 8) & 0x00000000FF000000) \
- | (((x) >> 24) & 0x0000000000FF0000) \
- | (((x) >> 40) & 0x000000000000FF00) \
- | (((x) >> 56) & 0x00000000000000FF))
-#define BYTESWAP_32(x) ((((x) << 24) & 0xFF000000) \
- | (((x) << 8) & 0x00FF0000) \
- | (((x) >> 8) & 0x0000FF00) \
- | (((x) >> 24) & 0x000000FF))
-#define BYTESWAP_16(x) ((((x) << 8) & 0xFF00) \
- | (((x) >> 8) & 0x00FF))
-
-//-------------------------------------------------------------------------
std::string debug_gdbstub::get_register_string(int gdb_regnum)
{
const gdb_register &reg = m_gdb_registers[gdb_regnum];
@@ -1310,9 +1313,9 @@ std::string debug_gdbstub::get_register_string(int gdb_regnum)
value &= (1ULL << reg.gdb_bitsize) - 1;
if ( !m_is_be )
{
- value = (reg.gdb_bitsize == 64) ? BYTESWAP_64(value)
- : (reg.gdb_bitsize == 32) ? BYTESWAP_32(value)
- : (reg.gdb_bitsize == 16) ? BYTESWAP_16(value)
+ value = (reg.gdb_bitsize == 64) ? swapendian_int64(value)
+ : (reg.gdb_bitsize == 32) ? swapendian_int32(value)
+ : (reg.gdb_bitsize == 16) ? swapendian_int16(value)
: value;
}
return string_format(fmt, value);
@@ -1331,9 +1334,9 @@ bool debug_gdbstub::parse_register_string(uint64_t *pvalue, const char *buf, int
return false;
if ( !m_is_be )
{
- value = (reg.gdb_bitsize == 64) ? BYTESWAP_64(value)
- : (reg.gdb_bitsize == 32) ? BYTESWAP_32(value)
- : (reg.gdb_bitsize == 16) ? BYTESWAP_16(value)
+ value = (reg.gdb_bitsize == 64) ? swapendian_int64(value)
+ : (reg.gdb_bitsize == 32) ? swapendian_int32(value)
+ : (reg.gdb_bitsize == 16) ? swapendian_int16(value)
: value;
}
*pvalue = value;
@@ -1430,5 +1433,7 @@ void debug_gdbstub::handle_character(char ch)
}
}
+} // anonymous namespace
+
//-------------------------------------------------------------------------
MODULE_DEFINITION(DEBUG_GDBSTUB, debug_gdbstub)
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp
index 944ed203b79..5f087f70a2e 100644
--- a/src/osd/modules/debugger/debugimgui.cpp
+++ b/src/osd/modules/debugger/debugimgui.cpp
@@ -3,9 +3,11 @@
// ImGui based debugger
#include "emu.h"
+#include "debug_module.h"
+
#include "imgui/imgui.h"
-#include "render.h"
-#include "uiinput.h"
+
+#include "imagedev/floppy.h"
#include "debug/debugvw.h"
#include "debug/dvdisasm.h"
@@ -14,14 +16,16 @@
#include "debug/dvwpoints.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "debugger.h"
+#include "render.h"
+#include "uiinput.h"
#include "config.h"
-#include "debugger.h"
#include "modules/lib/osdobj_common.h"
-#include "debug_module.h"
#include "modules/osdmodule.h"
#include "zippath.h"
-#include "imagedev/floppy.h"
+
+namespace {
class debug_area
{
@@ -1013,7 +1017,6 @@ void debug_imgui::refresh_filelist()
std::error_condition const err = util::zippath_directory::open(m_path,dir);
if(!err)
{
- int x = 0;
// add drives
for(std::string const &volume_name : osd_get_volume_names())
{
@@ -1022,7 +1025,6 @@ void debug_imgui::refresh_filelist()
temp.basename = volume_name;
temp.fullpath = volume_name;
m_filelist.emplace_back(std::move(temp));
- x++;
}
first = m_filelist.size();
const osd::directory::entry *dirent;
@@ -1393,7 +1395,6 @@ void debug_imgui::update()
//debug_area* view_ptr = view_list;
std::vector<debug_area*>::iterator view_ptr;
bool opened;
- int count = 0;
ImGui::PushStyleColor(ImGuiCol_WindowBg,ImVec4(1.0f,1.0f,1.0f,0.9f));
ImGui::PushStyleColor(ImGuiCol_Text,ImVec4(0.0f,0.0f,0.0f,1.0f));
ImGui::PushStyleColor(ImGuiCol_TextDisabled,ImVec4(0.0f,0.0f,1.0f,1.0f));
@@ -1438,7 +1439,6 @@ void debug_imgui::update()
break;
}
++view_ptr;
- count++;
}
// check for a closed window
if(to_delete != nullptr)
@@ -1567,4 +1567,6 @@ void debug_imgui::debugger_update()
}
}
+} // anonymous namespace
+
MODULE_DEFINITION(DEBUG_IMGUI, debug_imgui)
diff --git a/src/osd/modules/debugger/debugqt.cpp b/src/osd/modules/debugger/debugqt.cpp
index a48f419a6a3..c0dc5acb7d6 100644
--- a/src/osd/modules/debugger/debugqt.cpp
+++ b/src/osd/modules/debugger/debugqt.cpp
@@ -32,34 +32,60 @@
#include "qt/deviceswindow.h"
#include "qt/deviceinformationwindow.h"
+#include "util/xmlfile.h"
+
+
+#if defined(SDLMAME_UNIX) || defined(SDLMAME_WIN32)
+extern int sdl_entered_debugger;
+#elif defined(_WIN32)
+void winwindow_update_cursor_state(running_machine &machine);
+bool winwindow_qt_filter(void *message);
+#endif
+
+
+namespace {
+
class debug_qt : public osd_module, public debug_module
#if defined(_WIN32) && !defined(SDLMAME_WIN32)
, public QAbstractNativeEventFilter
#endif
{
public:
- debug_qt() : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), m_machine(nullptr)
+ debug_qt() :
+ osd_module(OSD_DEBUG_PROVIDER, "qt"),
+ debug_module(),
+ m_machine(nullptr),
+ m_mainwindow(nullptr)
{
}
virtual ~debug_qt() { }
virtual int init(const osd_options &options) { return 0; }
- virtual void exit() { }
+ virtual void exit();
virtual void init_debugger(running_machine &machine);
virtual void wait_for_debugger(device_t &device, bool firststop);
virtual void debugger_update();
#if defined(_WIN32) && !defined(SDLMAME_WIN32)
- virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE;
+ virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override
+ {
+ winwindow_qt_filter(message);
+ return false;
+ }
#endif
+
private:
+ void configuration_load(config_type which_type, config_level level, util::xml::data_node const *parentnode);
+ void configuration_save(config_type which_type, util::xml::data_node *parentnode);
+ void load_window_configurations(util::xml::data_node const &parentnode);
+
running_machine *m_machine;
+ osd::debugger::qt::MainWindow *m_mainwindow;
+ util::xml::file::ptr m_config;
};
-namespace {
-
//============================================================
// "Global" variables to make QT happy
//============================================================
@@ -68,178 +94,24 @@ int qtArgc = 1;
char qtArg0[] = "mame";
char *qtArgv[] = { qtArg0, nullptr };
-bool oneShot = true;
-MainWindow *mainQtWindow = nullptr;
//============================================================
-// XML configuration save/load
-//============================================================
-
-// Global variable used to feed the xml configuration callbacks
-std::vector<std::unique_ptr<WindowQtConfig> > xmlConfigurations;
-
-
-void xml_configuration_load(running_machine &machine, config_type cfg_type, config_level cfg_level, util::xml::data_node const *parentnode)
-{
- // We only care about system configuration files
- if ((cfg_type != config_type::SYSTEM) || !parentnode)
- return;
-
- xmlConfigurations.clear();
-
- // Configuration load
- util::xml::data_node const *wnode = nullptr;
- for (wnode = parentnode->get_child("window"); wnode; wnode = wnode->get_next_sibling("window"))
- {
- WindowQtConfig::WindowType type = (WindowQtConfig::WindowType)wnode->get_attribute_int("type", WindowQtConfig::WIN_TYPE_UNKNOWN);
- switch (type)
- {
- case WindowQtConfig::WIN_TYPE_MAIN: xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_MEMORY: xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>()); break;
- case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>()); break;
- default: continue;
- }
- xmlConfigurations.back()->recoverFromXmlNode(*wnode);
- }
-}
-
-
-void xml_configuration_save(running_machine &machine, config_type cfg_type, util::xml::data_node *parentnode)
-{
- // We only save system configuration
- if (cfg_type != config_type::SYSTEM)
- return;
-
- for (int i = 0; i < xmlConfigurations.size(); i++)
- {
- WindowQtConfig &config = *xmlConfigurations[i];
-
- // Create an xml node
- util::xml::data_node *const debugger_node = parentnode->add_child("window", nullptr);
-
- // Insert the appropriate information
- if (debugger_node)
- config.addToXmlDataNode(*debugger_node);
- }
-}
-
-
-void gather_save_configurations()
-{
- xmlConfigurations.clear();
-
- // Loop over all the open windows
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- {
- if (!widget->isVisible())
- continue;
-
- if (!widget->isWindow() || widget->windowType() != Qt::Window)
- continue;
-
- // Figure out its type
- if (dynamic_cast<MainWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>());
- else if (dynamic_cast<MemoryWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>());
- else if (dynamic_cast<DasmWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>());
- else if (dynamic_cast<LogWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>());
- else if (dynamic_cast<BreakpointsWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>());
- else if (dynamic_cast<DevicesWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>());
- else if (dynamic_cast<DeviceInformationWindow *>(widget))
- xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>());
-
- xmlConfigurations.back()->buildFromQWidget(widget);
- }
-}
-
-
-//============================================================
-// Utilities
+// Core functionality
//============================================================
-void load_and_clear_main_window_config(std::vector<std::unique_ptr<WindowQtConfig> > &configList)
-{
- for (int i = 0; i < configList.size(); i++)
- {
- WindowQtConfig &config = *configList[i];
- if (config.m_type == WindowQtConfig::WIN_TYPE_MAIN)
- {
- config.applyToQWidget(mainQtWindow);
- configList.erase(configList.begin() + i);
- break;
- }
- }
-}
-
-
-void setup_additional_startup_windows(running_machine &machine, std::vector<std::unique_ptr<WindowQtConfig> > &configList)
+void debug_qt::exit()
{
- for (int i = 0; i < configList.size(); i++)
+ // If you've done a hard reset, clear out existing widgets
+ if (m_mainwindow)
{
- WindowQtConfig &config = *configList[i];
-
- WindowQt *foo = nullptr;
- switch (config.m_type)
- {
- case WindowQtConfig::WIN_TYPE_MEMORY:
- foo = new MemoryWindow(machine); break;
- case WindowQtConfig::WIN_TYPE_DASM:
- foo = new DasmWindow(machine); break;
- case WindowQtConfig::WIN_TYPE_LOG:
- foo = new LogWindow(machine); break;
- case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
- foo = new BreakpointsWindow(machine); break;
- case WindowQtConfig::WIN_TYPE_DEVICES:
- foo = new DevicesWindow(machine); break;
- case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION:
- foo = new DeviceInformationWindow(machine); break;
- default:
- break;
- }
- config.applyToQWidget(foo);
- foo->show();
+ m_mainwindow->setExiting();
+ QApplication::closeAllWindows();
+ qApp->processEvents(QEventLoop::AllEvents, 1);
+ m_mainwindow = nullptr;
}
}
-void bring_main_window_to_front()
-{
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- {
- if (dynamic_cast<MainWindow *>(widget))
- {
- widget->activateWindow();
- widget->raise();
- }
- }
-}
-
-} // anonymous namespace
-
-
-//============================================================
-// Core functionality
-//============================================================
-
-#if defined(_WIN32) && !defined(SDLMAME_WIN32)
-bool winwindow_qt_filter(void *message);
-
-bool debug_qt::nativeEventFilter(const QByteArray &eventType, void *message, long *)
-{
- winwindow_qt_filter(message);
- return false;
-}
-#endif
-
void debug_qt::init_debugger(running_machine &machine)
{
if (!qApp)
@@ -250,23 +122,13 @@ void debug_qt::init_debugger(running_machine &machine)
QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
#endif
}
- else
- {
- // If you've done a hard reset, clear out existing widgets & get ready for re-init
- foreach (QWidget *widget, QApplication::topLevelWidgets())
- {
- if (!widget->isWindow() || widget->windowType() != Qt::Window)
- continue;
- delete widget;
- }
- oneShot = true;
- }
m_machine = &machine;
+
// Setup the configuration XML saving and loading
machine.configuration().config_register("debugger",
- configuration_manager::load_delegate(&xml_configuration_load, &machine),
- configuration_manager::save_delegate(&xml_configuration_save, &machine));
+ configuration_manager::load_delegate(&debug_qt::configuration_load, this),
+ configuration_manager::save_delegate(&debug_qt::configuration_save, this));
}
@@ -274,12 +136,6 @@ void debug_qt::init_debugger(running_machine &machine)
// Core functionality
//============================================================
-#if defined(SDLMAME_UNIX) || defined(SDLMAME_WIN32)
-extern int sdl_entered_debugger;
-#elif defined(_WIN32)
-void winwindow_update_cursor_state(running_machine &machine);
-#endif
-
void debug_qt::wait_for_debugger(device_t &device, bool firststop)
{
#if defined(SDLMAME_UNIX) || defined(SDLMAME_WIN32)
@@ -287,62 +143,57 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
#endif
// Dialog initialization
- if (oneShot)
+ if (!m_mainwindow)
{
- mainQtWindow = new MainWindow(*m_machine);
- load_and_clear_main_window_config(xmlConfigurations);
- setup_additional_startup_windows(*m_machine, xmlConfigurations);
- mainQtWindow->show();
- oneShot = false;
+ m_mainwindow = new osd::debugger::qt::MainWindow(*m_machine);
+ if (m_config)
+ {
+ load_window_configurations(*m_config->get_first_child());
+ m_config.reset();
+ }
+ m_mainwindow->show();
}
// Ensure all top level widgets are visible & bring main window to front
foreach (QWidget *widget, QApplication::topLevelWidgets())
{
- if (!widget->isWindow() || widget->windowType() != Qt::Window)
- continue;
- widget->show();
+ if (widget->isWindow() && (widget->windowType() == Qt::Window))
+ widget->show();
}
if (firststop)
- bring_main_window_to_front();
+ {
+ m_mainwindow->activateWindow();
+ m_mainwindow->raise();
+ }
// Set the main window to display the proper cpu
- mainQtWindow->setProcessor(&device);
+ m_mainwindow->setProcessor(&device);
// Run our own QT event loop
osd_sleep(osd_ticks_per_second() / 1000 * 50);
qApp->processEvents(QEventLoop::AllEvents, 1);
// Refresh everyone if requested
- if (mainQtWindow->wantsRefresh())
+ if (m_mainwindow->wantsRefresh())
{
QWidgetList allWidgets = qApp->allWidgets();
for (int i = 0; i < allWidgets.length(); i++)
allWidgets[i]->update();
- mainQtWindow->clearRefreshFlag();
+ m_mainwindow->clearRefreshFlag();
}
// Hide all top level widgets if requested
- if (mainQtWindow->wantsHide())
+ if (m_mainwindow->wantsHide())
{
foreach (QWidget *widget, QApplication::topLevelWidgets())
{
- if (!widget->isWindow() || widget->windowType() != Qt::Window)
- continue;
- widget->hide();
+ if (widget->isWindow() && (widget->windowType() == Qt::Window))
+ widget->hide();
}
- mainQtWindow->clearHideFlag();
+ m_mainwindow->clearHideFlag();
}
- // Exit if the machine has been instructed to do so (scheduled event == exit || hard_reset)
- if (m_machine->scheduled_event_pending())
- {
- // Keep a list of windows we want to save.
- // We need to do this here because by the time xml_configuration_save gets called
- // all the QT windows are already gone.
- gather_save_configurations();
- }
#if defined(_WIN32) && !defined(SDLMAME_WIN32)
winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger
#endif
@@ -358,6 +209,93 @@ void debug_qt::debugger_update()
qApp->processEvents(QEventLoop::AllEvents, 1);
}
+
+void debug_qt::configuration_load(config_type which_type, config_level level, util::xml::data_node const *parentnode)
+{
+ // We only care about system configuration files for now
+ if ((config_type::SYSTEM == which_type) && parentnode)
+ {
+ if (m_mainwindow)
+ {
+ load_window_configurations(*parentnode);
+ }
+ else
+ {
+ m_config = util::xml::file::create();
+ parentnode->copy_into(*m_config);
+ }
+ }
+}
+
+
+void debug_qt::configuration_save(config_type which_type, util::xml::data_node *parentnode)
+{
+ // We only save system configuration for now
+ if ((config_type::SYSTEM == which_type) && parentnode)
+ {
+ // Loop over all the open windows
+ for (QWidget *widget : QApplication::topLevelWidgets())
+ {
+ if (!widget->isWindow() || (widget->windowType() != Qt::Window))
+ continue;
+
+ osd::debugger::qt::WindowQt *const win = dynamic_cast<osd::debugger::qt::WindowQt *>(widget);
+ if (win)
+ win->saveConfiguration(*parentnode);
+ }
+ }
+}
+
+
+void debug_qt::load_window_configurations(util::xml::data_node const &parentnode)
+{
+ for (util::xml::data_node const *wnode = parentnode.get_child(osd::debugger::NODE_WINDOW); wnode; wnode = wnode->get_next_sibling(osd::debugger::NODE_WINDOW))
+ {
+ std::unique_ptr<osd::debugger::qt::WindowQtConfig> cfg;
+ osd::debugger::qt::WindowQt *win = nullptr;
+ switch (wnode->get_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, -1))
+ {
+ case osd::debugger::WINDOW_TYPE_CONSOLE:
+ cfg = std::make_unique<osd::debugger::qt::MainWindowQtConfig>();
+ break;
+ case osd::debugger::WINDOW_TYPE_MEMORY_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::MemoryWindowQtConfig>();
+ win = new osd::debugger::qt::MemoryWindow(*m_machine);
+ break;
+ case osd::debugger::WINDOW_TYPE_DISASSEMBLY_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::DasmWindowQtConfig>();
+ win = new osd::debugger::qt::DasmWindow(*m_machine);
+ break;
+ case osd::debugger::WINDOW_TYPE_ERROR_LOG_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::LogWindowQtConfig>();
+ win = new osd::debugger::qt::LogWindow(*m_machine);
+ break;
+ case osd::debugger::WINDOW_TYPE_POINTS_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::BreakpointsWindowQtConfig>();
+ win = new osd::debugger::qt::BreakpointsWindow(*m_machine);
+ break;
+ case osd::debugger::WINDOW_TYPE_DEVICES_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::DevicesWindowQtConfig>();
+ win = new osd::debugger::qt::DevicesWindow(*m_machine);
+ break;
+ case osd::debugger::WINDOW_TYPE_DEVICE_INFO_VIEWER:
+ cfg = std::make_unique<osd::debugger::qt::DeviceInformationWindowQtConfig>();
+ win = new osd::debugger::qt::DeviceInformationWindow(*m_machine);
+ break;
+ }
+ if (cfg)
+ {
+ cfg->recoverFromXmlNode(*wnode);
+ if (win)
+ cfg->applyToQWidget(win);
+ else if (osd::debugger::WINDOW_TYPE_CONSOLE == cfg->m_type)
+ cfg->applyToQWidget(m_mainwindow);
+ }
+ }
+}
+
+} // anonymous namespace
+
#else // USE_QTDEBUG
MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
diff --git a/src/osd/modules/debugger/debugwin.cpp b/src/osd/modules/debugger/debugwin.cpp
index 18bbc07dd70..365f5206e86 100644
--- a/src/osd/modules/debugger/debugwin.cpp
+++ b/src/osd/modules/debugger/debugwin.cpp
@@ -22,15 +22,23 @@
#include "win/pointswininfo.h"
#include "win/uimetrics.h"
+#include "config.h"
#include "debugger.h"
#include "debug/debugcpu.h"
+#include "util/xmlfile.h"
+
#include "window.h"
#include "../input/input_common.h"
#include "../input/input_windows.h"
-class debugger_windows : public osd_module, public debug_module, protected debugger_windows_interface
+namespace {
+
+class debugger_windows :
+ public osd_module,
+ public debug_module,
+ protected osd::debugger::win::debugger_windows_interface
{
public:
debugger_windows() :
@@ -40,7 +48,9 @@ public:
m_metrics(),
m_waiting_for_debugger(false),
m_window_list(),
- m_main_console(nullptr)
+ m_main_console(nullptr),
+ m_config(),
+ m_save_windows(true)
{
}
@@ -56,16 +66,19 @@ public:
protected:
virtual running_machine &machine() const override { return *m_machine; }
- virtual ui_metrics &metrics() const override { return *m_metrics; }
+ virtual osd::debugger::win::ui_metrics &metrics() const override { return *m_metrics; }
+ virtual void set_color_theme(int index) override;
+ virtual bool get_save_window_arrangement() const override { return m_save_windows; }
+ virtual void set_save_window_arrangement(bool save) override { m_save_windows = save; }
virtual bool const &waiting_for_debugger() const override { return m_waiting_for_debugger; }
virtual bool seq_pressed() const override;
- virtual void create_memory_window() override { create_window<memorywin_info>(); }
- virtual void create_disasm_window() override { create_window<disasmwin_info>(); }
- virtual void create_log_window() override { create_window<logwin_info>(); }
- virtual void create_points_window() override { create_window<pointswin_info>(); }
- virtual void remove_window(debugwin_info &info) override;
+ virtual void create_memory_window() override { create_window<osd::debugger::win::memorywin_info>(); }
+ virtual void create_disasm_window() override { create_window<osd::debugger::win::disasmwin_info>(); }
+ virtual void create_log_window() override { create_window<osd::debugger::win::logwin_info>(); }
+ virtual void create_points_window() override { create_window<osd::debugger::win::pointswin_info>(); }
+ virtual void remove_window(osd::debugger::win::debugwin_info &info) override;
virtual void show_all() override;
virtual void hide_all() override;
@@ -73,11 +86,19 @@ protected:
private:
template <typename T> T *create_window();
- running_machine *m_machine;
- std::unique_ptr<ui_metrics> m_metrics;
- bool m_waiting_for_debugger;
- std::vector<std::unique_ptr<debugwin_info>> m_window_list;
- consolewin_info *m_main_console;
+ void config_load(config_type cfgtype, config_level cfglevel, util::xml::data_node const *parentnode);
+ void config_save(config_type cfgtype, util::xml::data_node *parentnode);
+
+ void load_configuration(util::xml::data_node const &parentnode);
+
+ running_machine *m_machine;
+ std::unique_ptr<osd::debugger::win::ui_metrics> m_metrics;
+ bool m_waiting_for_debugger;
+ std::vector<std::unique_ptr<osd::debugger::win::debugwin_info> > m_window_list;
+ osd::debugger::win::consolewin_info *m_main_console;
+
+ util::xml::file::ptr m_config;
+ bool m_save_windows;
};
@@ -96,23 +117,33 @@ void debugger_windows::exit()
void debugger_windows::init_debugger(running_machine &machine)
{
m_machine = &machine;
- m_metrics = std::make_unique<ui_metrics>(downcast<osd_options &>(m_machine->options()));
+ m_metrics = std::make_unique<osd::debugger::win::ui_metrics>(downcast<osd_options &>(m_machine->options()));
+ machine.configuration().config_register(
+ "debugger",
+ configuration_manager::load_delegate(&debugger_windows::config_load, this),
+ configuration_manager::save_delegate(&debugger_windows::config_save, this));
}
void debugger_windows::wait_for_debugger(device_t &device, bool firststop)
{
// create a console window
- if (m_main_console == nullptr)
- m_main_console = create_window<consolewin_info>();
+ if (!m_main_console)
+ m_main_console = create_window<osd::debugger::win::consolewin_info>();
// update the views in the console to reflect the current CPU
- if (m_main_console != nullptr)
+ if (m_main_console)
m_main_console->set_cpu(device);
// when we are first stopped, adjust focus to us
- if (firststop && (m_main_console != nullptr))
+ if (firststop && m_main_console)
{
+ if (m_config)
+ {
+ for (util::xml::data_node const *node = m_config->get_first_child(); node; node = node->get_next_sibling())
+ load_configuration(*node);
+ m_config.reset();
+ }
m_main_console->set_foreground();
if (winwindow_has_focus())
m_main_console->set_default_focus();
@@ -171,6 +202,14 @@ void debugger_windows::debugger_update()
}
+void debugger_windows::set_color_theme(int index)
+{
+ m_metrics->set_color_theme(index);
+ for (auto const &window : m_window_list)
+ window->redraw();
+}
+
+
bool debugger_windows::seq_pressed() const
{
input_seq const &seq = m_machine->ioport().type_seq(IPT_UI_DEBUG_BREAK);
@@ -222,7 +261,7 @@ bool debugger_windows::seq_pressed() const
}
-void debugger_windows::remove_window(debugwin_info &info)
+void debugger_windows::remove_window(osd::debugger::win::debugwin_info &info)
{
for (auto it = m_window_list.begin(); it != m_window_list.end(); ++it)
if (it->get() == &info) {
@@ -247,21 +286,105 @@ void debugger_windows::hide_all()
}
-template <typename T> T *debugger_windows::create_window()
+template <typename T>
+T *debugger_windows::create_window()
{
// allocate memory
std::unique_ptr<T> info = std::make_unique<T>(static_cast<debugger_windows_interface &>(*this));
if (info->is_valid())
{
+ T &result(*info);
m_window_list.push_back(std::move(info));
- T *ptr = dynamic_cast<T*>(m_window_list.back().get());
- return ptr;
+ return &result;
}
return nullptr;
}
-#else /* not windows */
+void debugger_windows::config_load(config_type cfgtype, config_level cfglevel, util::xml::data_node const *parentnode)
+{
+ if (parentnode)
+ {
+ if (config_type::DEFAULT == cfgtype)
+ {
+ m_save_windows = 0 != parentnode->get_attribute_int(osd::debugger::ATTR_DEBUGGER_SAVE_WINDOWS, m_save_windows ? 1 : 0);
+ util::xml::data_node const *const colors = parentnode->get_child(osd::debugger::NODE_COLORS);
+ if (colors)
+ m_metrics->set_color_theme(colors->get_attribute_int(osd::debugger::ATTR_COLORS_THEME, m_metrics->get_color_theme()));
+ }
+ else if (config_type::SYSTEM == cfgtype)
+ {
+ if (m_main_console)
+ {
+ load_configuration(*parentnode);
+ }
+ else
+ {
+ if (!m_config)
+ m_config = util::xml::file::create();
+ parentnode->copy_into(*m_config);
+ }
+ }
+ }
+}
+
+
+void debugger_windows::config_save(config_type cfgtype, util::xml::data_node *parentnode)
+{
+ if (config_type::DEFAULT == cfgtype)
+ {
+ parentnode->set_attribute_int(osd::debugger::ATTR_DEBUGGER_SAVE_WINDOWS, m_save_windows ? 1 : 0);
+ util::xml::data_node *const colors = parentnode->add_child(osd::debugger::NODE_COLORS, nullptr);
+ if (colors)
+ colors->set_attribute_int(osd::debugger::ATTR_COLORS_THEME, m_metrics->get_color_theme());
+ }
+ else if (m_save_windows && (config_type::SYSTEM == cfgtype))
+ {
+ for (auto &info : m_window_list)
+ info->save_configuration(*parentnode);
+ }
+}
+
+
+void debugger_windows::load_configuration(util::xml::data_node const &parentnode)
+{
+ for (util::xml::data_node const *node = parentnode.get_child(osd::debugger::NODE_WINDOW); node; node = node->get_next_sibling(osd::debugger::NODE_WINDOW))
+ {
+ osd::debugger::win::debugwin_info *win = nullptr;
+ switch (node->get_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, -1))
+ {
+ case osd::debugger::WINDOW_TYPE_CONSOLE:
+ m_main_console->restore_configuration_from_node(*node);
+ break;
+ case osd::debugger::WINDOW_TYPE_MEMORY_VIEWER:
+ win = create_window<osd::debugger::win::memorywin_info>();
+ break;
+ case osd::debugger::WINDOW_TYPE_DISASSEMBLY_VIEWER:
+ win = create_window<osd::debugger::win::disasmwin_info>();
+ break;
+ case osd::debugger::WINDOW_TYPE_ERROR_LOG_VIEWER:
+ win = create_window<osd::debugger::win::logwin_info>();
+ break;
+ case osd::debugger::WINDOW_TYPE_POINTS_VIEWER:
+ win = create_window<osd::debugger::win::pointswin_info>();
+ break;
+ case osd::debugger::WINDOW_TYPE_DEVICES_VIEWER:
+ // not supported
+ break;
+ case osd::debugger::WINDOW_TYPE_DEVICE_INFO_VIEWER:
+ // not supported
+ break;
+ default:
+ break;
+ }
+ if (win)
+ win->restore_configuration_from_node(*node);
+ }
+}
+
+} // anonymous namespace
+
+#else // not Windows
MODULE_NOT_SUPPORTED(debugger_windows, OSD_DEBUG_PROVIDER, "windows")
#endif
diff --git a/src/osd/modules/debugger/none.cpp b/src/osd/modules/debugger/none.cpp
index ef23fe04089..29ccb7cfca1 100644
--- a/src/osd/modules/debugger/none.cpp
+++ b/src/osd/modules/debugger/none.cpp
@@ -14,6 +14,9 @@
#include "debug/debugcpu.h"
#include "debugger.h"
+
+namespace {
+
class debug_none : public osd_module, public debug_module
{
public:
@@ -50,4 +53,6 @@ void debug_none::debugger_update()
{
}
+} // anonymous namespace
+
MODULE_DEFINITION(DEBUG_NONE, debug_none)
diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm
index c1689a8b855..f6d01375403 100644
--- a/src/osd/modules/debugger/osx/debugconsole.mm
+++ b/src/osd/modules/debugger/osx/debugconsole.mm
@@ -380,30 +380,30 @@
- (void)loadConfiguration:(util::xml::data_node const *)parentnode {
util::xml::data_node const *node = nullptr;
- for (node = parentnode->get_child("window"); node; node = node->get_next_sibling("window"))
+ for (node = parentnode->get_child(osd::debugger::NODE_WINDOW); node; node = node->get_next_sibling(osd::debugger::NODE_WINDOW))
{
MAMEDebugWindowHandler *win = nil;
- switch (node->get_attribute_int("type", -1))
+ switch (node->get_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, -1))
{
- case MAME_DEBUGGER_WINDOW_TYPE_CONSOLE:
+ case osd::debugger::WINDOW_TYPE_CONSOLE:
[self restoreConfigurationFromNode:node];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_MEMORY_VIEWER:
+ case osd::debugger::WINDOW_TYPE_MEMORY_VIEWER:
win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_DISASSEMBLY_VIEWER:
+ case osd::debugger::WINDOW_TYPE_DISASSEMBLY_VIEWER:
win = [[MAMEDisassemblyViewer alloc] initWithMachine:*machine console:self];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_ERROR_LOG_VIEWER:
+ case osd::debugger::WINDOW_TYPE_ERROR_LOG_VIEWER:
win = [[MAMEErrorLogViewer alloc] initWithMachine:*machine console:self];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_POINTS_VIEWER:
+ case osd::debugger::WINDOW_TYPE_POINTS_VIEWER:
win = [[MAMEPointsViewer alloc] initWithMachine:*machine console:self];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_DEVICES_VIEWER:
+ case osd::debugger::WINDOW_TYPE_DEVICES_VIEWER:
win = [[MAMEDevicesViewer alloc] initWithMachine:*machine console:self];
break;
- case MAME_DEBUGGER_WINDOW_TYPE_DEVICE_INFO_VIEWER:
+ case osd::debugger::WINDOW_TYPE_DEVICE_INFO_VIEWER:
// FIXME: needs device info on init, make another variant
//win = [[MAMEDeviceInfoViewer alloc] initWithMachine:*machine console:self];
break;
@@ -423,15 +423,15 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_CONSOLE);
- util::xml::data_node *const splits = node->add_child("splits", nullptr);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_CONSOLE);
+ util::xml::data_node *const splits = node->add_child(osd::debugger::NODE_WINDOW_SPLITS, nullptr);
if (splits)
{
- splits->set_attribute_float("state",
+ splits->set_attribute_float(osd::debugger::ATTR_SPLITS_CONSOLE_STATE,
[regSplit isSubviewCollapsed:[[regSplit subviews] objectAtIndex:0]]
? 0.0
: NSMaxX([[[regSplit subviews] objectAtIndex:0] frame]));
- splits->set_attribute_float("disassembly",
+ splits->set_attribute_float(osd::debugger::ATTR_SPLITS_CONSOLE_DISASSEMBLY,
[dasmSplit isSubviewCollapsed:[[dasmSplit subviews] objectAtIndex:0]]
? 0.0
: NSMaxY([[[dasmSplit subviews] objectAtIndex:0] frame]));
@@ -442,12 +442,12 @@
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
- util::xml::data_node const *const splits = node->get_child("splits");
+ util::xml::data_node const *const splits = node->get_child(osd::debugger::NODE_WINDOW_SPLITS);
if (splits)
{
- [regSplit setPosition:splits->get_attribute_float("state", NSMaxX([[[regSplit subviews] objectAtIndex:0] frame]))
+ [regSplit setPosition:splits->get_attribute_float(osd::debugger::ATTR_SPLITS_CONSOLE_STATE, NSMaxX([[[regSplit subviews] objectAtIndex:0] frame]))
ofDividerAtIndex:0];
- [dasmSplit setPosition:splits->get_attribute_float("disassembly", NSMaxY([[[dasmSplit subviews] objectAtIndex:0] frame]))
+ [dasmSplit setPosition:splits->get_attribute_float(osd::debugger::ATTR_SPLITS_CONSOLE_DISASSEMBLY, NSMaxY([[[dasmSplit subviews] objectAtIndex:0] frame]))
ofDividerAtIndex:0];
}
[dasmView restoreConfigurationFromNode:node];
diff --git a/src/osd/modules/debugger/osx/debugosx.h b/src/osd/modules/debugger/osx/debugosx.h
index 9d48402c032..6e0a47089d9 100644
--- a/src/osd/modules/debugger/osx/debugosx.h
+++ b/src/osd/modules/debugger/osx/debugosx.h
@@ -6,8 +6,13 @@
//
//============================================================
-#ifndef __SDL_DEBUGOSX__
-#define __SDL_DEBUGOSX__
+#ifndef MAME_OSD_DEBUGGER_OSX_DEBUGOSX_H
+#define MAME_OSD_DEBUGGER_OSX_DEBUGOSX_H
+
+#pragma once
+
+#include "../xmlconfig.h"
+
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
@@ -20,30 +25,6 @@
// standard Cocoa headers
#import <Cocoa/Cocoa.h>
-// workarounds for 10.6 warnings
-#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
-
-@protocol NSWindowDelegate <NSObject>
-@end
-
-@protocol NSSplitViewDelegate <NSObject>
-@end
-
-@protocol NSControlTextEditingDelegate <NSObject>
-@end
-
-@protocol NSTextFieldDelegate <NSControlTextEditingDelegate>
-@end
-
-@protocol NSOutlineViewDataSource <NSObject>
-@end
-
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED < 1060
-
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED
-
#endif // __OBJC__
-#endif // __SDL_DEBUGOSX__
+#endif // MAME_OSD_DEBUGGER_OSX_DEBUGOSX_H
diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm
index 8853be80622..540fa41815d 100644
--- a/src/osd/modules/debugger/osx/debugview.mm
+++ b/src/osd/modules/debugger/osx/debugview.mm
@@ -51,6 +51,26 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
@implementation MAMEDebugView
+ (void)initialize {
+ // 10.15 and better get full adaptive Dark Mode support
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
+ DefaultForeground = [[NSColor textColor] retain];
+ ChangedForeground = [[NSColor systemRedColor] retain];
+ CommentForeground = [[NSColor systemGreenColor] retain];
+ // DCA_INVALID and DCA_DISABLED currently are not set by the core, so these 4 are unused
+ InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain];
+ DisabledChangedForeground = [[NSColor colorWithCalibratedRed:0.5 green:0.125 blue:0.125 alpha:1.0] retain];
+ DisabledInvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0] retain];
+ DisabledCommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.25 blue:0.0 alpha:1.0] retain];
+
+ DefaultBackground = [[NSColor textBackgroundColor] retain];
+ VisitedBackground = [[NSColor systemTealColor] retain];
+ AncillaryBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain];
+ SelectedBackground = [[NSColor selectedContentBackgroundColor] retain];
+ CurrentBackground = [[NSColor selectedControlColor] retain];
+ SelectedCurrentBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain];
+ InactiveSelectedBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain];
+ InactiveSelectedCurrentBackground = [[NSColor systemGrayColor] retain];
+#else
DefaultForeground = [[NSColor colorWithCalibratedWhite:0.0 alpha:1.0] retain];
ChangedForeground = [[NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:1.0] retain];
InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain];
@@ -67,6 +87,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
SelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0] retain];
InactiveSelectedBackground = [[NSColor colorWithCalibratedWhite:0.875 alpha:1.0] retain];
InactiveSelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0] retain];
+#endif
NonWhiteCharacters = [[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet] retain];
}
@@ -493,22 +514,22 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
if (view->cursor_supported())
{
- util::xml::data_node *const selection = node->add_child("selection", nullptr);
+ util::xml::data_node *const selection = node->add_child(osd::debugger::NODE_WINDOW_SELECTION, nullptr);
if (selection)
{
debug_view_xy const pos = view->cursor_position();
- selection->set_attribute_int("visible", view->cursor_visible() ? 1 : 0);
- selection->set_attribute_int("start_x", pos.x);
- selection->set_attribute_int("start_y", pos.y);
+ selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_VISIBLE, view->cursor_visible() ? 1 : 0);
+ selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_X, pos.x);
+ selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_Y, pos.y);
}
}
- util::xml::data_node *const scroll = node->add_child("scroll", nullptr);
+ util::xml::data_node *const scroll = node->add_child(osd::debugger::NODE_WINDOW_SCROLL, nullptr);
if (scroll)
{
NSRect const visible = [self visibleRect];
- scroll->set_attribute_float("position_x", visible.origin.x);
- scroll->set_attribute_float("position_y", visible.origin.y);
+ scroll->set_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_X, visible.origin.x);
+ scroll->set_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_Y, visible.origin.y);
}
}
@@ -516,23 +537,23 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
if (view->cursor_supported())
{
- util::xml::data_node const *const selection = node->get_child("selection");
+ util::xml::data_node const *const selection = node->get_child(osd::debugger::NODE_WINDOW_SELECTION);
if (selection)
{
debug_view_xy pos = view->cursor_position();
- view->set_cursor_visible(0 != selection->get_attribute_int("visible", view->cursor_visible() ? 1 : 0));
- pos.x = selection->get_attribute_int("start_x", pos.x);
- pos.y = selection->get_attribute_int("start_y", pos.y);
+ view->set_cursor_visible(0 != selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_VISIBLE, view->cursor_visible() ? 1 : 0));
+ pos.x = selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_X, pos.x);
+ pos.y = selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_Y, pos.y);
view->set_cursor_position(pos);
}
}
- util::xml::data_node const *const scroll = node->get_child("scroll");
+ util::xml::data_node const *const scroll = node->get_child(osd::debugger::NODE_WINDOW_SCROLL);
if (scroll)
{
NSRect visible = [self visibleRect];
- visible.origin.x = scroll->get_attribute_float("position_x", visible.origin.x);
- visible.origin.y = scroll->get_attribute_float("position_y", visible.origin.y);
+ visible.origin.x = scroll->get_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_X, visible.origin.x);
+ visible.origin.y = scroll->get_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_Y, visible.origin.y);
[self scrollRectToVisible:visible];
}
}
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h
index c48bbb031b2..00c7327f2ba 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.h
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.h
@@ -23,19 +23,6 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification;
extern NSString *const MAMESaveDebuggerConfigurationNotification;
-// for compatibility with the Qt debugger
-enum
-{
- MAME_DEBUGGER_WINDOW_TYPE_CONSOLE = 1,
- MAME_DEBUGGER_WINDOW_TYPE_MEMORY_VIEWER,
- MAME_DEBUGGER_WINDOW_TYPE_DISASSEMBLY_VIEWER,
- MAME_DEBUGGER_WINDOW_TYPE_ERROR_LOG_VIEWER,
- MAME_DEBUGGER_WINDOW_TYPE_POINTS_VIEWER,
- MAME_DEBUGGER_WINDOW_TYPE_DEVICES_VIEWER,
- MAME_DEBUGGER_WINDOW_TYPE_DEVICE_INFO_VIEWER
-};
-
-
@interface MAMEDebugWindowHandler : NSObject <NSWindowDelegate>
{
NSWindow *window;
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm
index ec79887e308..ebeb1711dc4 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.mm
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm
@@ -276,7 +276,7 @@ NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerCo
if (m == machine)
{
util::xml::data_node *parentnode = (util::xml::data_node *)[[[notification userInfo] objectForKey:@"MAMEDebugParentNode"] pointerValue];
- util::xml::data_node *node = parentnode->add_child("window", nullptr);
+ util::xml::data_node *node = parentnode->add_child(osd::debugger::NODE_WINDOW, nullptr);
if (node)
[self saveConfigurationToNode:node];
}
@@ -285,19 +285,19 @@ NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerCo
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
NSRect frame = [window frame];
- node->set_attribute_float("position_x", frame.origin.x);
- node->set_attribute_float("position_y", frame.origin.y);
- node->set_attribute_float("size_x", frame.size.width);
- node->set_attribute_float("size_y", frame.size.height);
+ node->set_attribute_float(osd::debugger::ATTR_WINDOW_POSITION_X, frame.origin.x);
+ node->set_attribute_float(osd::debugger::ATTR_WINDOW_POSITION_Y, frame.origin.y);
+ node->set_attribute_float(osd::debugger::ATTR_WINDOW_WIDTH, frame.size.width);
+ node->set_attribute_float(osd::debugger::ATTR_WINDOW_HEIGHT, frame.size.height);
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
NSRect frame = [window frame];
- frame.origin.x = node->get_attribute_float("position_x", frame.origin.x);
- frame.origin.y = node->get_attribute_float("position_y", frame.origin.y);
- frame.size.width = node->get_attribute_float("size_x", frame.size.width);
- frame.size.height = node->get_attribute_float("size_y", frame.size.height);
+ frame.origin.x = node->get_attribute_float(osd::debugger::ATTR_WINDOW_POSITION_X, frame.origin.x);
+ frame.origin.y = node->get_attribute_float(osd::debugger::ATTR_WINDOW_POSITION_Y, frame.origin.y);
+ frame.size.width = node->get_attribute_float(osd::debugger::ATTR_WINDOW_WIDTH, frame.size.width);
+ frame.size.height = node->get_attribute_float(osd::debugger::ATTR_WINDOW_HEIGHT, frame.size.height);
NSSize min = [window minSize];
frame.size.width = std::max(frame.size.width, min.width);
@@ -493,13 +493,13 @@ NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerCo
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->add_child("expression", [[self expression] UTF8String]);
+ node->add_child(osd::debugger::NODE_WINDOW_EXPRESSION, [[self expression] UTF8String]);
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
- util::xml::data_node const *const expr = node->get_child("expression");
+ util::xml::data_node const *const expr = node->get_child(osd::debugger::NODE_WINDOW_EXPRESSION);
if (expr && expr->get_value())
[self setExpression:[NSString stringWithUTF8String:expr->get_value()]];
}
diff --git a/src/osd/modules/debugger/osx/deviceinfoviewer.mm b/src/osd/modules/debugger/osx/deviceinfoviewer.mm
index 61fdd8c8613..e23110308ba 100644
--- a/src/osd/modules/debugger/osx/deviceinfoviewer.mm
+++ b/src/osd/modules/debugger/osx/deviceinfoviewer.mm
@@ -237,7 +237,7 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_DEVICE_INFO_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_DEVICE_INFO_VIEWER);
}
@end
diff --git a/src/osd/modules/debugger/osx/devicesviewer.mm b/src/osd/modules/debugger/osx/devicesviewer.mm
index 23dba724b9d..0ec4047ec63 100644
--- a/src/osd/modules/debugger/osx/devicesviewer.mm
+++ b/src/osd/modules/debugger/osx/devicesviewer.mm
@@ -185,7 +185,7 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_DEVICES_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_DEVICES_VIEWER);
}
diff --git a/src/osd/modules/debugger/osx/disassemblyview.mm b/src/osd/modules/debugger/osx/disassemblyview.mm
index 2e230c27e1c..0f703d8c7f1 100644
--- a/src/osd/modules/debugger/osx/disassemblyview.mm
+++ b/src/osd/modules/debugger/osx/disassemblyview.mm
@@ -274,14 +274,14 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
debug_view_disasm *const dasmView = downcast<debug_view_disasm *>(view);
- node->set_attribute_int("rightbar", dasmView->right_column());
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmView->right_column());
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
debug_view_disasm *const dasmView = downcast<debug_view_disasm *>(view);
- dasmView->set_right_column((disasm_right_column)node->get_attribute_int("rightbar", dasmView->right_column()));
+ dasmView->set_right_column((disasm_right_column)node->get_attribute_int(osd::debugger::ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmView->right_column()));
}
@end
diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm
index 1f286a6bfc4..97e23c9a0cd 100644
--- a/src/osd/modules/debugger/osx/disassemblyviewer.mm
+++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm
@@ -182,7 +182,7 @@
// if it doesn't exist, add a new one
if (bp == nullptr)
{
- uint32_t const bpnum = device.debug()->breakpoint_set(address, nullptr, nullptr);
+ uint32_t const bpnum = device.debug()->breakpoint_set(address);
machine->debugger().console().printf("Breakpoint %X set\n", bpnum);
}
else
@@ -232,15 +232,15 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_DISASSEMBLY_VIEWER);
- node->set_attribute_int("cpu", [dasmView selectedSubviewIndex]);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_DISASSEMBLY_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_DISASSEMBLY_CPU, [dasmView selectedSubviewIndex]);
[dasmView saveConfigurationToNode:node];
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
- int const region = node->get_attribute_int("cpu", [dasmView selectedSubviewIndex]);
+ int const region = node->get_attribute_int(osd::debugger::ATTR_WINDOW_DISASSEMBLY_CPU, [dasmView selectedSubviewIndex]);
[dasmView selectSubviewAtIndex:region];
[window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
[subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]];
diff --git a/src/osd/modules/debugger/osx/errorlogviewer.mm b/src/osd/modules/debugger/osx/errorlogviewer.mm
index 1fd12c9c9c1..3b1a58f485b 100644
--- a/src/osd/modules/debugger/osx/errorlogviewer.mm
+++ b/src/osd/modules/debugger/osx/errorlogviewer.mm
@@ -64,7 +64,7 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_ERROR_LOG_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_ERROR_LOG_VIEWER);
}
@end
diff --git a/src/osd/modules/debugger/osx/memoryview.mm b/src/osd/modules/debugger/osx/memoryview.mm
index 03055bd7daf..24521e81ba4 100644
--- a/src/osd/modules/debugger/osx/memoryview.mm
+++ b/src/osd/modules/debugger/osx/memoryview.mm
@@ -212,20 +212,22 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
debug_view_memory *const memView = downcast<debug_view_memory *>(view);
- node->set_attribute_int("reverse", memView->reverse() ? 1 : 0);
- node->set_attribute_int("addressmode", memView->physical() ? 1 : 0);
- node->set_attribute_int("dataformat", int(memView->get_data_format()));
- node->set_attribute_int("rowchunks", memView->chunks_per_row());
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, memView->reverse() ? 1 : 0);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ADDRESS_MODE, memView->physical() ? 1 : 0);
+ node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ADDRESS_RADIX, memView->address_radix());
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_DATA_FORMAT, int(memView->get_data_format()));
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ROW_CHUNKS, memView->chunks_per_row());
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
debug_view_memory *const memView = downcast<debug_view_memory *>(view);
- memView->set_reverse(0 != node->get_attribute_int("reverse", memView->reverse() ? 1 : 0));
- memView->set_physical(0 != node->get_attribute_int("addressmode", memView->physical() ? 1 : 0));
- memView->set_data_format(debug_view_memory::data_format(node->get_attribute_int("dataformat", int(memView->get_data_format()))));
- memView->set_chunks_per_row(node->get_attribute_int("rowchunks", memView->chunks_per_row()));
+ memView->set_reverse(0 != node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, memView->reverse() ? 1 : 0));
+ memView->set_physical(0 != node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ADDRESS_MODE, memView->physical() ? 1 : 0));
+ memView->set_address_radix(node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ADDRESS_RADIX, memView->address_radix()));
+ memView->set_data_format(debug_view_memory::data_format(node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_DATA_FORMAT, int(memView->get_data_format()))));
+ memView->set_chunks_per_row(node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_ROW_CHUNKS, memView->chunks_per_row()));
}
diff --git a/src/osd/modules/debugger/osx/memoryviewer.mm b/src/osd/modules/debugger/osx/memoryviewer.mm
index b1064aee69f..b9c38bbd4d2 100644
--- a/src/osd/modules/debugger/osx/memoryviewer.mm
+++ b/src/osd/modules/debugger/osx/memoryviewer.mm
@@ -178,15 +178,15 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_MEMORY_VIEWER);
- node->set_attribute_int("memoryregion", [memoryView selectedSubviewIndex]);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_MEMORY_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_REGION, [memoryView selectedSubviewIndex]);
[memoryView saveConfigurationToNode:node];
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
- int const region = node->get_attribute_int("memoryregion", [memoryView selectedSubviewIndex]);
+ int const region = node->get_attribute_int(osd::debugger::ATTR_WINDOW_MEMORY_REGION, [memoryView selectedSubviewIndex]);
[memoryView selectSubviewAtIndex:region];
[window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]];
[subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]];
diff --git a/src/osd/modules/debugger/osx/pointsviewer.mm b/src/osd/modules/debugger/osx/pointsviewer.mm
index 0399fb10d1b..215ad163087 100644
--- a/src/osd/modules/debugger/osx/pointsviewer.mm
+++ b/src/osd/modules/debugger/osx/pointsviewer.mm
@@ -172,14 +172,14 @@
- (void)saveConfigurationToNode:(util::xml::data_node *)node {
[super saveConfigurationToNode:node];
- node->set_attribute_int("type", MAME_DEBUGGER_WINDOW_TYPE_POINTS_VIEWER);
- node->set_attribute_int("bwtype", [tabs indexOfTabViewItem:[tabs selectedTabViewItem]]);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_TYPE, osd::debugger::WINDOW_TYPE_POINTS_VIEWER);
+ node->set_attribute_int(osd::debugger::ATTR_WINDOW_POINTS_TYPE, [tabs indexOfTabViewItem:[tabs selectedTabViewItem]]);
}
- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
[super restoreConfigurationFromNode:node];
- int const tab = node->get_attribute_int("bwtype", [tabs indexOfTabViewItem:[tabs selectedTabViewItem]]);
+ int const tab = node->get_attribute_int(osd::debugger::ATTR_WINDOW_POINTS_TYPE, [tabs indexOfTabViewItem:[tabs selectedTabViewItem]]);
if ((0 <= tab) && ([tabs numberOfTabViewItems] > tab))
{
[subviewButton selectItemAtIndex:tab];
diff --git a/src/osd/modules/debugger/qt/breakpointswindow.cpp b/src/osd/modules/debugger/qt/breakpointswindow.cpp
index 6af8fe7ba36..c108b2b94a3 100644
--- a/src/osd/modules/debugger/qt/breakpointswindow.cpp
+++ b/src/osd/modules/debugger/qt/breakpointswindow.cpp
@@ -6,6 +6,8 @@
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "util/xmlfile.h"
+
#include <QtWidgets/QActionGroup>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMenu>
@@ -13,6 +15,8 @@
#include <QtWidgets/QVBoxLayout>
+namespace osd::debugger::qt {
+
BreakpointsWindow::BreakpointsWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
@@ -79,6 +83,31 @@ BreakpointsWindow::~BreakpointsWindow()
}
+void BreakpointsWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_POINTS_VIEWER);
+ if (m_breakpointsView)
+ {
+ switch (m_breakpointsView->view()->type())
+ {
+ case DVT_BREAK_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 0);
+ break;
+ case DVT_WATCH_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 1);
+ break;
+ case DVT_REGISTER_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 2);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
void BreakpointsWindow::typeChanged(QAction* changedTo)
{
// Clean
@@ -112,21 +141,6 @@ void BreakpointsWindow::typeChanged(QAction* changedTo)
//=========================================================================
// BreakpointsWindowQtConfig
//=========================================================================
-void BreakpointsWindowQtConfig::buildFromQWidget(QWidget *widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
-
- QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup");
- if (typeGroup->checkedAction()->text() == "Breakpoints")
- m_bwType = 0;
- else if (typeGroup->checkedAction()->text() == "Watchpoints")
- m_bwType = 1;
- else if (typeGroup->checkedAction()->text() == "Registerpoints")
- m_bwType = 2;
-}
-
-
void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget)
{
WindowQtConfig::applyToQWidget(widget);
@@ -137,15 +151,10 @@ void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget)
}
-void BreakpointsWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
- node.set_attribute_int("bwtype", m_bwType);
-}
-
-
void BreakpointsWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
- m_bwType = node.get_attribute_int("bwtype", m_bwType);
+ m_bwType = node.get_attribute_int(ATTR_WINDOW_POINTS_TYPE, m_bwType);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/breakpointswindow.h b/src/osd/modules/debugger/qt/breakpointswindow.h
index fab5ea149e9..262d416ceff 100644
--- a/src/osd/modules/debugger/qt/breakpointswindow.h
+++ b/src/osd/modules/debugger/qt/breakpointswindow.h
@@ -7,6 +7,8 @@
#include "windowqt.h"
+namespace osd::debugger::qt {
+
//============================================================
// The Breakpoints Window.
//============================================================
@@ -18,6 +20,9 @@ public:
BreakpointsWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~BreakpointsWindow();
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
private slots:
void typeChanged(QAction *changedTo);
@@ -34,7 +39,7 @@ class BreakpointsWindowQtConfig : public WindowQtConfig
{
public:
BreakpointsWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_BREAK_POINTS),
+ WindowQtConfig(WINDOW_TYPE_POINTS_VIEWER),
m_bwType(0)
{
}
@@ -44,10 +49,10 @@ public:
// Settings
int m_bwType;
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
+
#endif // MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp
index 44ce8bac988..dd7677516eb 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.cpp
+++ b/src/osd/modules/debugger/qt/dasmwindow.cpp
@@ -8,6 +8,8 @@
#include "debug/dvdisasm.h"
#include "debug/points.h"
+#include "util/xmlfile.h"
+
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QAction>
@@ -15,6 +17,8 @@
#include <QtWidgets/QMenuBar>
+namespace osd::debugger::qt {
+
DasmWindow::DasmWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
@@ -49,7 +53,7 @@ DasmWindow::DasmWindow(running_machine &machine, QWidget *parent) :
connect(m_dasmView, &DebuggerView::updated, this, &DasmWindow::dasmViewUpdated);
// Force a recompute of the disassembly region
- downcast<debug_view_disasm *>(m_dasmView->view())->set_expression("curpc");
+ m_dasmView->view<debug_view_disasm>()->set_expression("curpc");
// Populate the combo box & set the proper CPU
populateComboBox();
@@ -90,6 +94,9 @@ DasmWindow::DasmWindow(running_machine &machine, QWidget *parent) :
QAction *rightActRaw = new QAction("Raw Opcodes", this);
QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
QAction *rightActComments = new QAction("Comments", this);
+ rightActRaw->setData(int(DASM_RIGHTCOL_RAW));
+ rightActEncrypted->setData(int(DASM_RIGHTCOL_ENCRYPTED));
+ rightActComments->setData(int(DASM_RIGHTCOL_COMMENTS));
rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true);
@@ -117,6 +124,19 @@ DasmWindow::~DasmWindow()
}
+void DasmWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_DISASSEMBLY_VIEWER);
+
+ debug_view_disasm &dasmview = *m_dasmView->view<debug_view_disasm>();
+ node.set_attribute_int(ATTR_WINDOW_DISASSEMBLY_CPU, m_dasmView->sourceIndex());
+ node.set_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmview.right_column());
+ node.add_child(NODE_WINDOW_EXPRESSION, dasmview.expression());
+}
+
+
void DasmWindow::cpuChanged(int index)
{
if (index < m_dasmView->view()->source_count())
@@ -130,7 +150,7 @@ void DasmWindow::cpuChanged(int index)
void DasmWindow::expressionSubmitted()
{
const QString expression = m_inputEdit->text();
- downcast<debug_view_disasm *>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data());
+ m_dasmView->view<debug_view_disasm>()->set_expression(expression.toLocal8Bit().data());
m_dasmView->viewport()->update();
}
@@ -139,7 +159,7 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
{
if (m_dasmView->view()->cursor_visible())
{
- offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
+ offs_t const address = m_dasmView->view<debug_view_disasm>()->selected_address();
device_t *const device = m_dasmView->view()->source()->device();
device_debug *const cpuinfo = device->debug();
@@ -149,7 +169,7 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
// If none exists, add a new one
if (!bp)
{
- int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
+ int32_t bpindex = cpuinfo->breakpoint_set(address);
m_machine.debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
@@ -170,7 +190,7 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo)
{
if (m_dasmView->view()->cursor_visible())
{
- offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
+ offs_t const address = m_dasmView->view<debug_view_disasm>()->selected_address();
device_t *const device = m_dasmView->view()->source()->device();
device_debug *const cpuinfo = device->debug();
@@ -194,7 +214,7 @@ void DasmWindow::runToCursor(bool changedTo)
{
if (m_dasmView->view()->cursor_visible())
{
- offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
+ offs_t const address = m_dasmView->view<debug_view_disasm>()->selected_address();
m_dasmView->view()->source()->device()->debug()->go(address);
}
}
@@ -202,19 +222,8 @@ void DasmWindow::runToCursor(bool changedTo)
void DasmWindow::rightBarChanged(QAction* changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmView->view());
- if (changedTo->text() == "Raw Opcodes")
- {
- dasmView->set_right_column(DASM_RIGHTCOL_RAW);
- }
- else if (changedTo->text() == "Encrypted Opcodes")
- {
- dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
- }
- else if (changedTo->text() == "Comments")
- {
- dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
- }
+ debug_view_disasm *const dasmView = m_dasmView->view<debug_view_disasm>();
+ dasmView->set_right_column(disasm_right_column(changedTo->data().toInt()));
m_dasmView->viewport()->update();
}
@@ -226,7 +235,7 @@ void DasmWindow::dasmViewUpdated()
bool breakpointEnabled = false;
if (haveCursor)
{
- offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
+ offs_t const address = m_dasmView->view<debug_view_disasm>()->selected_address();
device_t *const device = m_dasmView->view()->source()->device();
device_debug *const cpuinfo = device->debug();
@@ -279,21 +288,6 @@ void DasmWindow::setToCurrentCpu()
//=========================================================================
// DasmWindowQtConfig
//=========================================================================
-void DasmWindowQtConfig::buildFromQWidget(QWidget *widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- DasmWindow *window = dynamic_cast<DasmWindow *>(widget);
- QComboBox *cpu = window->findChild<QComboBox *>("cpu");
- m_cpu = cpu->currentIndex();
-
- QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
- if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
- m_rightBar = 0;
- else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
- m_rightBar = 1;
- else if (rightBarGroup->checkedAction()->text() == "Comments")
- m_rightBar = 2;
-}
void DasmWindowQtConfig::applyToQWidget(QWidget *widget)
{
@@ -302,20 +296,22 @@ void DasmWindowQtConfig::applyToQWidget(QWidget *widget)
QComboBox *cpu = window->findChild<QComboBox *>("cpu");
cpu->setCurrentIndex(m_cpu);
- QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
- rightBarGroup->actions()[m_rightBar]->trigger();
-}
-
-void DasmWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
- node.set_attribute_int("cpu", m_cpu);
- node.set_attribute_int("rightbar", m_rightBar);
+ QActionGroup *const rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
+ for (QAction *action : rightBarGroup->actions())
+ {
+ if (action->data().toInt() == m_rightBar)
+ {
+ action->trigger();
+ break;
+ }
+ }
}
void DasmWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
- m_cpu = node.get_attribute_int("cpu", m_cpu);
- m_rightBar = node.get_attribute_int("rightbar", m_rightBar);
+ m_cpu = node.get_attribute_int(ATTR_WINDOW_DISASSEMBLY_CPU, m_cpu);
+ m_rightBar = node.get_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, m_rightBar);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/dasmwindow.h b/src/osd/modules/debugger/qt/dasmwindow.h
index fc4ce11d731..fda4db188a3 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.h
+++ b/src/osd/modules/debugger/qt/dasmwindow.h
@@ -3,6 +3,8 @@
#ifndef MAME_DEBUGGER_QT_DASMWINDOW_H
#define MAME_DEBUGGER_QT_DASMWINDOW_H
+#pragma once
+
#include "debuggerview.h"
#include "windowqt.h"
@@ -10,6 +12,8 @@
#include <QtWidgets/QLineEdit>
+namespace osd::debugger::qt {
+
//============================================================
// The Disassembly Window.
//============================================================
@@ -21,6 +25,9 @@ public:
DasmWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~DasmWindow();
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
private slots:
void cpuChanged(int index);
void expressionSubmitted();
@@ -55,7 +62,7 @@ class DasmWindowQtConfig : public WindowQtConfig
{
public:
DasmWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_DASM),
+ WindowQtConfig(WINDOW_TYPE_DISASSEMBLY_VIEWER),
m_cpu(0),
m_rightBar(0)
{
@@ -67,11 +74,10 @@ public:
int m_cpu;
int m_rightBar;
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_DASMWINDOW_H
diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp
index a1c8bcf2aec..3d89670c3af 100644
--- a/src/osd/modules/debugger/qt/debuggerview.cpp
+++ b/src/osd/modules/debugger/qt/debuggerview.cpp
@@ -16,6 +16,9 @@
#define horizontalAdvance width
#endif
+
+namespace osd::debugger::qt {
+
DebuggerView::DebuggerView(
debug_view_type type,
running_machine &machine,
@@ -51,6 +54,19 @@ DebuggerView::~DebuggerView()
m_machine.debug_view().free_view(*m_view);
}
+
+int DebuggerView::sourceIndex() const
+{
+ if (m_view)
+ {
+ debug_view_source const *const source = m_view->source();
+ if (source)
+ return m_view->source_index(*source);
+ }
+ return -1;
+}
+
+
void DebuggerView::paintEvent(QPaintEvent *event)
{
// Tell the MAME debug view how much real estate is available
@@ -361,3 +377,5 @@ void DebuggerView::debuggerViewUpdate(debug_view &debugView, void *osdPrivate)
dView->update();
emit dView->updated();
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/debuggerview.h b/src/osd/modules/debugger/qt/debuggerview.h
index a38b3b11152..6a78ec7d672 100644
--- a/src/osd/modules/debugger/qt/debuggerview.h
+++ b/src/osd/modules/debugger/qt/debuggerview.h
@@ -3,12 +3,16 @@
#ifndef MAME_DEBUGGER_QT_DEBUGGERVIEW_H
#define MAME_DEBUGGER_QT_DEBUGGERVIEW_H
+#pragma once
+
#include "debug/debugvw.h"
#include <QtWidgets/QAbstractScrollArea>
#include <QtWidgets/QMenu>
+namespace osd::debugger::qt {
+
class DebuggerView : public QAbstractScrollArea
{
Q_OBJECT
@@ -22,6 +26,8 @@ public:
// Setters and accessors
void setPreferBottom(bool pb) { m_preferBottom = pb; }
debug_view *view() { return m_view; }
+ template <typename T> T *view() { return downcast<T *>(m_view); }
+ int sourceIndex() const;
signals:
void updated();
@@ -49,4 +55,6 @@ private:
bool m_preferBottom;
};
+} // namespace osd::debugger::qt
+
#endif // MAME_DEBUGGER_QT_DEBUGGERVIEW_H
diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
index 431a0df492a..83fad49e418 100644
--- a/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
+++ b/src/osd/modules/debugger/qt/deviceinformationwindow.cpp
@@ -1,12 +1,16 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
+#include "deviceinformationwindow.h"
+
+#include "util/xmlfile.h"
+
#include <QtWidgets/QFrame>
#include <QtWidgets/QLabel>
#include <QtWidgets/QVBoxLayout>
-#include "deviceinformationwindow.h"
+namespace osd::debugger::qt {
DeviceInformationWindow::DeviceInformationWindow(running_machine &machine, device_t *device, QWidget *parent) :
WindowQt(machine, nullptr),
@@ -27,6 +31,17 @@ DeviceInformationWindow::~DeviceInformationWindow()
{
}
+
+void DeviceInformationWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_DEVICE_INFO_VIEWER);
+
+ node.set_attribute(ATTR_WINDOW_DEVICE_TAG, m_device->tag());
+}
+
+
void DeviceInformationWindow::fill_device_information()
{
setWindowTitle(util::string_format("Debug: Device %s", m_device->tag()).c_str());
@@ -99,22 +114,10 @@ void DeviceInformationWindow::set_device(const char *tag)
fill_device_information();
}
-const char *DeviceInformationWindow::device_tag() const
-{
- return m_device->tag();
-}
-
//=========================================================================
// DeviceInformationWindowQtConfig
//=========================================================================
-void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget *widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- DeviceInformationWindow *window = dynamic_cast<DeviceInformationWindow *>(widget);
- m_device_tag = window->device_tag();
-}
-
void DeviceInformationWindowQtConfig::applyToQWidget(QWidget *widget)
{
@@ -124,15 +127,10 @@ void DeviceInformationWindowQtConfig::applyToQWidget(QWidget *widget)
}
-void DeviceInformationWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
- node.set_attribute("device-tag", m_device_tag.c_str());
-}
-
-
void DeviceInformationWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
- m_device_tag = node.get_attribute_string("device-tag", ":");
+ m_device_tag = node.get_attribute_string(ATTR_WINDOW_DEVICE_TAG, ":");
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.h b/src/osd/modules/debugger/qt/deviceinformationwindow.h
index c7bfa68527d..68ab910fe48 100644
--- a/src/osd/modules/debugger/qt/deviceinformationwindow.h
+++ b/src/osd/modules/debugger/qt/deviceinformationwindow.h
@@ -3,8 +3,13 @@
#ifndef MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
#define MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
+#pragma once
+
#include "windowqt.h"
+
+namespace osd::debugger::qt {
+
//============================================================
// The Device Information Window.
//============================================================
@@ -17,7 +22,9 @@ public:
virtual ~DeviceInformationWindow();
void set_device(const char *tag);
- const char *device_tag() const;
+
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
private:
device_t *m_device;
@@ -37,17 +44,16 @@ public:
std::string m_device_tag;
DeviceInformationWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_DEVICE_INFORMATION)
+ WindowQtConfig(WINDOW_TYPE_DEVICE_INFO_VIEWER)
{
}
~DeviceInformationWindowQtConfig() {}
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
diff --git a/src/osd/modules/debugger/qt/deviceswindow.cpp b/src/osd/modules/debugger/qt/deviceswindow.cpp
index 0e7a94ceb97..8d51ecccf01 100644
--- a/src/osd/modules/debugger/qt/deviceswindow.cpp
+++ b/src/osd/modules/debugger/qt/deviceswindow.cpp
@@ -2,8 +2,14 @@
// copyright-holders:Andrew Gardner
#include "emu.h"
#include "deviceswindow.h"
+
#include "deviceinformationwindow.h"
+#include "util/xmlfile.h"
+
+
+namespace osd::debugger::qt {
+
DevicesWindowModel::DevicesWindowModel(running_machine &machine, QObject *parent) :
m_machine(machine)
{
@@ -152,16 +158,18 @@ void DevicesWindow::activated(const QModelIndex &index)
}
+void DevicesWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_DEVICES_VIEWER);
+}
+
+
//=========================================================================
// DevicesWindowQtConfig
//=========================================================================
-void DevicesWindowQtConfig::buildFromQWidget(QWidget *widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- // DevicesWindow *window = dynamic_cast<DevicesWindow *>(widget);
-}
-
void DevicesWindowQtConfig::applyToQWidget(QWidget *widget)
{
@@ -170,13 +178,9 @@ void DevicesWindowQtConfig::applyToQWidget(QWidget *widget)
}
-void DevicesWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
-}
-
-
void DevicesWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/deviceswindow.h b/src/osd/modules/debugger/qt/deviceswindow.h
index 884ad87d421..8fe5b7a82c2 100644
--- a/src/osd/modules/debugger/qt/deviceswindow.h
+++ b/src/osd/modules/debugger/qt/deviceswindow.h
@@ -3,11 +3,15 @@
#ifndef MAME_DEBUGGER_QT_DEVICESWINDOW_H
#define MAME_DEBUGGER_QT_DEVICESWINDOW_H
+#pragma once
+
#include "windowqt.h"
#include <QtWidgets/QTreeView>
+namespace osd::debugger::qt {
+
//============================================================
// The model for the treeview
//============================================================
@@ -47,6 +51,9 @@ public slots:
void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
void activated(const QModelIndex &index);
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
private:
QTreeView *m_devices_view;
DevicesWindowModel m_devices_model;
@@ -63,7 +70,7 @@ class DevicesWindowQtConfig : public WindowQtConfig
{
public:
DevicesWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_DEVICES)
+ WindowQtConfig(WINDOW_TYPE_DEVICES_VIEWER)
{
}
@@ -75,5 +82,6 @@ public:
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_DEVICESWINDOW_H
diff --git a/src/osd/modules/debugger/qt/logwindow.cpp b/src/osd/modules/debugger/qt/logwindow.cpp
index 9649014fc6f..669d25081d6 100644
--- a/src/osd/modules/debugger/qt/logwindow.cpp
+++ b/src/osd/modules/debugger/qt/logwindow.cpp
@@ -1,14 +1,18 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QVBoxLayout>
-
#include "logwindow.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include "debug/dvdisasm.h"
+#include "util/xmlfile.h"
+
+#include <QtWidgets/QVBoxLayout>
+
+
+namespace osd::debugger::qt {
LogWindow::LogWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
@@ -44,28 +48,27 @@ LogWindow::~LogWindow()
}
-//=========================================================================
-// LogWindowQtConfig
-//=========================================================================
-void LogWindowQtConfig::buildFromQWidget(QWidget *widget)
+void LogWindow::saveConfigurationToNode(util::xml::data_node &node)
{
- WindowQtConfig::buildFromQWidget(widget);
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_ERROR_LOG_VIEWER);
}
+//=========================================================================
+// LogWindowQtConfig
+//=========================================================================
+
void LogWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
}
-void LogWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
-}
-
-
void LogWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/logwindow.h b/src/osd/modules/debugger/qt/logwindow.h
index 05d4d15514f..813add22749 100644
--- a/src/osd/modules/debugger/qt/logwindow.h
+++ b/src/osd/modules/debugger/qt/logwindow.h
@@ -3,10 +3,14 @@
#ifndef MAME_DEBUGGER_QT_LOGWINDOW_H
#define MAME_DEBUGGER_QT_LOGWINDOW_H
+#pragma once
+
#include "debuggerview.h"
#include "windowqt.h"
+namespace osd::debugger::qt {
+
//============================================================
// The Log Window.
//============================================================
@@ -18,6 +22,9 @@ public:
LogWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~LogWindow();
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
private:
// Widgets
DebuggerView *m_logView;
@@ -31,17 +38,16 @@ class LogWindowQtConfig : public WindowQtConfig
{
public:
LogWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_LOG)
+ WindowQtConfig(WINDOW_TYPE_ERROR_LOG_VIEWER)
{
}
~LogWindowQtConfig() {}
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_LOGWINDOW_H
diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp
index afea2e07919..a418a543ace 100644
--- a/src/osd/modules/debugger/qt/mainwindow.cpp
+++ b/src/osd/modules/debugger/qt/mainwindow.cpp
@@ -8,6 +8,8 @@
#include "debug/dvdisasm.h"
#include "debug/points.h"
+#include "util/xmlfile.h"
+
#include <QtGui/QCloseEvent>
#include <QtWidgets/QAction>
#include <QtWidgets/QDockWidget>
@@ -17,10 +19,13 @@
#include <QtWidgets/QScrollBar>
+namespace osd::debugger::qt {
+
MainWindow::MainWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr),
m_historyIndex(0),
- m_inputHistory()
+ m_inputHistory(),
+ m_exiting(false)
{
setGeometry(300, 300, 1000, 600);
@@ -68,6 +73,9 @@ MainWindow::MainWindow(running_machine &machine, QWidget *parent) :
QAction *rightActRaw = new QAction("Raw Opcodes", this);
QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
QAction *rightActComments = new QAction("Comments", this);
+ rightActRaw->setData(int(DASM_RIGHTCOL_RAW));
+ rightActEncrypted->setData(int(DASM_RIGHTCOL_ENCRYPTED));
+ rightActComments->setData(int(DASM_RIGHTCOL_COMMENTS));
rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true);
@@ -146,13 +154,27 @@ void MainWindow::setProcessor(device_t *processor)
}
+void MainWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_CONSOLE);
+
+ debug_view_disasm &dasmview = *m_dasmFrame->view()->view<debug_view_disasm>();
+ node.set_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmview.right_column());
+ node.set_attribute("qtwindowstate", saveState().toPercentEncoding().data());
+}
+
+
// Used to intercept the user clicking 'X' in the upper corner
void MainWindow::closeEvent(QCloseEvent *event)
{
- debugActQuit();
-
- // Insure the window doesn't disappear before we get a chance to save its parameters
- event->ignore();
+ if (!m_exiting)
+ {
+ // Don't actually close the window - it will be brought back on user break
+ debugActRunAndHide();
+ event->ignore();
+ }
}
@@ -205,10 +227,10 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
- debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ debug_view_disasm *const dasmView = m_dasmFrame->view()->view<debug_view_disasm>();
if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
- offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
+ offs_t const address = dasmView->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
// Find an existing breakpoint at this address
@@ -229,7 +251,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
- debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ debug_view_disasm *const dasmView = m_dasmFrame->view()->view<debug_view_disasm>();
if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = dasmView->selected_address();
@@ -252,10 +274,10 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
void MainWindow::runToCursor(bool changedTo)
{
- debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ debug_view_disasm *const dasmView = m_dasmFrame->view()->view<debug_view_disasm>();
if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
- offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
+ offs_t address = dasmView->selected_address();
std::string command = string_format("go 0x%X", address);
m_machine.debugger().console().execute_command(command, true);
}
@@ -264,15 +286,8 @@ void MainWindow::runToCursor(bool changedTo)
void MainWindow::rightBarChanged(QAction *changedTo)
{
- debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
-
- if (changedTo->text() == "Raw Opcodes")
- dasmView->set_right_column(DASM_RIGHTCOL_RAW);
- else if (changedTo->text() == "Encrypted Opcodes")
- dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
- else if (changedTo->text() == "Comments")
- dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
-
+ debug_view_disasm *const dasmView = m_dasmFrame->view()->view<debug_view_disasm>();
+ dasmView->set_right_column(disasm_right_column(changedTo->data().toInt()));
m_dasmFrame->view()->viewport()->update();
}
@@ -380,7 +395,7 @@ void MainWindow::unmountImage(bool changedTo)
void MainWindow::dasmViewUpdated()
{
- debug_view_disasm *const dasmView = downcast<debug_view_disasm *>(m_dasmFrame->view()->view());
+ debug_view_disasm *const dasmView = m_dasmFrame->view()->view<debug_view_disasm>();
bool const haveCursor = dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device());
bool haveBreakpoint = false;
bool breakpointEnabled = false;
@@ -469,38 +484,21 @@ void MainWindow::createImagesMenu()
//=========================================================================
// MainWindowQtConfig
//=========================================================================
-void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- MainWindow *window = dynamic_cast<MainWindow *>(widget);
- m_windowState = window->saveState();
-
- QActionGroup *rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
- if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
- m_rightBar = 0;
- else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
- m_rightBar = 1;
- else if (rightBarGroup->checkedAction()->text() == "Comments")
- m_rightBar = 2;
-}
-
-
void MainWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
MainWindow *window = dynamic_cast<MainWindow *>(widget);
window->restoreState(m_windowState);
- QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
- rightBarGroup->actions()[m_rightBar]->trigger();
-}
-
-
-void MainWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
- node.set_attribute_int("rightbar", m_rightBar);
- node.set_attribute("qtwindowstate", m_windowState.toPercentEncoding().data());
+ QActionGroup *const rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
+ for (QAction *action : rightBarGroup->actions())
+ {
+ if (action->data().toInt() == m_rightBar)
+ {
+ action->trigger();
+ break;
+ }
+ }
}
@@ -509,7 +507,7 @@ void MainWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
WindowQtConfig::recoverFromXmlNode(node);
const char* state = node.get_attribute_string("qtwindowstate", "");
m_windowState = QByteArray::fromPercentEncoding(state);
- m_rightBar = node.get_attribute_int("rightbar", m_rightBar);
+ m_rightBar = node.get_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, m_rightBar);
}
DasmDockWidget::~DasmDockWidget()
@@ -519,3 +517,5 @@ DasmDockWidget::~DasmDockWidget()
ProcessorDockWidget::~ProcessorDockWidget()
{
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/mainwindow.h b/src/osd/modules/debugger/qt/mainwindow.h
index 6c1e9baefcb..919c016704c 100644
--- a/src/osd/modules/debugger/qt/mainwindow.h
+++ b/src/osd/modules/debugger/qt/mainwindow.h
@@ -3,6 +3,8 @@
#ifndef MAME_DEBUGGER_QT_MAINWINDOW_H
#define MAME_DEBUGGER_QT_MAINWINDOW_H
+#pragma once
+
#include "debuggerview.h"
#include "windowqt.h"
@@ -15,6 +17,8 @@
#include <vector>
+namespace osd::debugger::qt {
+
class DasmDockWidget;
class ProcessorDockWidget;
@@ -32,8 +36,11 @@ public:
void setProcessor(device_t *processor);
+ void setExiting() { m_exiting = true; }
protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
// Used to intercept the user clicking 'X' in the upper corner
void closeEvent(QCloseEvent *event);
@@ -53,13 +60,15 @@ private slots:
void dasmViewUpdated();
- // Closing the main window actually exits the program
+ // Closing the main window hides the debugger and runs the emulated system
void debugActClose();
-
private:
void createImagesMenu();
+ void addToHistory(const QString& command);
+ void executeCommand(bool withClear);
+
// Widgets and docks
QLineEdit *m_inputEdit;
DebuggerView *m_consoleView;
@@ -74,8 +83,8 @@ private:
// Terminal history
int m_historyIndex;
std::vector<QString> m_inputHistory;
- void addToHistory(const QString& command);
- void executeCommand(bool withClear);
+
+ bool m_exiting;
};
@@ -157,7 +166,7 @@ class MainWindowQtConfig : public WindowQtConfig
{
public:
MainWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_MAIN),
+ WindowQtConfig(WINDOW_TYPE_CONSOLE),
m_rightBar(0),
m_windowState()
{}
@@ -168,11 +177,10 @@ public:
int m_rightBar;
QByteArray m_windowState;
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_MAINWINDOW_H
diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp
index 09d13c5d6d4..0aed1a750ce 100644
--- a/src/osd/modules/debugger/qt/memorywindow.cpp
+++ b/src/osd/modules/debugger/qt/memorywindow.cpp
@@ -7,6 +7,8 @@
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "util/xmlfile.h"
+
#include <QtGui/QClipboard>
#include <QtGui/QMouseEvent>
#include <QtWidgets/QActionGroup>
@@ -22,6 +24,9 @@
#define horizontalAdvance width
#endif
+
+namespace osd::debugger::qt {
+
MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr)
{
@@ -76,28 +81,28 @@ MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
// Create a data format group
QActionGroup *dataFormat = new QActionGroup(this);
dataFormat->setObjectName("dataformat");
- QAction *formatActOne = new QAction("1-byte hexadecimal", this);
- QAction *formatActTwo = new QAction("2-byte hexadecimal", this);
- QAction *formatActFour = new QAction("4-byte hexadecimal", this);
- QAction *formatActEight = new QAction("8-byte hexadecimal", this);
- QAction *formatActOneOctal = new QAction("1-byte octal", this);
- QAction *formatActTwoOctal = new QAction("2-byte octal", this);
- QAction *formatActFourOctal = new QAction("4-byte octal", this);
- QAction *formatActEightOctal = new QAction("8-byte octal", this);
- QAction *formatAct32bitFloat = new QAction("32 bit floating point", this);
- QAction *formatAct64bitFloat = new QAction("64 bit floating point", this);
- QAction *formatAct80bitFloat = new QAction("80 bit floating point", this);
- formatActOne->setObjectName("formatActOne");
- formatActTwo->setObjectName("formatActTwo");
- formatActFour->setObjectName("formatActFour");
- formatActEight->setObjectName("formatActEight");
- formatActOneOctal->setObjectName("formatActOneOctal");
- formatActTwoOctal->setObjectName("formatActTwoOctal");
- formatActFourOctal->setObjectName("formatActFourOctal");
- formatActEightOctal->setObjectName("formatActEightOctal");
- formatAct32bitFloat->setObjectName("formatAct32bitFloat");
- formatAct64bitFloat->setObjectName("formatAct64bitFloat");
- formatAct80bitFloat->setObjectName("formatAct80bitFloat");
+ QAction *formatActOne = new QAction("1-byte Chunks (Hex)", this);
+ QAction *formatActTwo = new QAction("2-byte Chunks (Hex)", this);
+ QAction *formatActFour = new QAction("4-byte Chunks (Hex)", this);
+ QAction *formatActEight = new QAction("8-byte Chunks (Hex)", this);
+ QAction *formatActOneOctal = new QAction("1-byte Chunks (Octal)", this);
+ QAction *formatActTwoOctal = new QAction("2-byte Chunks (Octal)", this);
+ QAction *formatActFourOctal = new QAction("4-byte Chunks (Octal)", this);
+ QAction *formatActEightOctal = new QAction("8-byte Chunks (Octal)", this);
+ QAction *formatAct32bitFloat = new QAction("32-bit Floating Point", this);
+ QAction *formatAct64bitFloat = new QAction("64-bit Floating Point", this);
+ QAction *formatAct80bitFloat = new QAction("80-bit Floating Point", this);
+ formatActOne->setData(int(debug_view_memory::data_format::HEX_8BIT));
+ formatActTwo->setData(int(debug_view_memory::data_format::HEX_16BIT));
+ formatActFour->setData(int(debug_view_memory::data_format::HEX_32BIT));
+ formatActEight->setData(int(debug_view_memory::data_format::HEX_64BIT));
+ formatActOneOctal->setData(int(debug_view_memory::data_format::OCTAL_8BIT));
+ formatActTwoOctal->setData(int(debug_view_memory::data_format::OCTAL_16BIT));
+ formatActFourOctal->setData(int(debug_view_memory::data_format::OCTAL_32BIT));
+ formatActEightOctal->setData(int(debug_view_memory::data_format::OCTAL_64BIT));
+ formatAct32bitFloat->setData(int(debug_view_memory::data_format::FLOAT_32BIT));
+ formatAct64bitFloat->setData(int(debug_view_memory::data_format::FLOAT_64BIT));
+ formatAct80bitFloat->setData(int(debug_view_memory::data_format::FLOAT_80BIT));
formatActOne->setCheckable(true);
formatActTwo->setCheckable(true);
formatActFour->setCheckable(true);
@@ -139,6 +144,8 @@ MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
addressGroup->setObjectName("addressgroup");
QAction *addressActLogical = new QAction("Logical Addresses", this);
QAction *addressActPhysical = new QAction("Physical Addresses", this);
+ addressActLogical->setData(false);
+ addressActPhysical->setData(true);
addressActLogical->setCheckable(true);
addressActPhysical->setCheckable(true);
addressActLogical->setActionGroup(addressGroup);
@@ -154,9 +161,9 @@ MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
QAction *radixActHexadecimal = new QAction("Hexadecimal Addresses", this);
QAction *radixActDecimal = new QAction("Decimal Addresses", this);
QAction *radixActOctal = new QAction("Octal Addresses", this);
- radixActHexadecimal->setObjectName("radixHexadecimal");
- radixActDecimal->setObjectName("radixDecimal");
- radixActOctal->setObjectName("radixOctal");
+ radixActHexadecimal->setData(16);
+ radixActDecimal->setData(10);
+ radixActOctal->setData(8);
radixActHexadecimal->setCheckable(true);
radixActDecimal->setCheckable(true);
radixActOctal->setCheckable(true);
@@ -212,6 +219,23 @@ MemoryWindow::~MemoryWindow()
}
+void MemoryWindow::saveConfigurationToNode(util::xml::data_node &node)
+{
+ WindowQt::saveConfigurationToNode(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_MEMORY_VIEWER);
+
+ debug_view_memory &memView = *m_memTable->view<debug_view_memory>();
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_REGION, m_memTable->sourceIndex());
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, memView.reverse() ? 1 : 0);
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_MODE, memView.physical() ? 1 : 0);
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_RADIX, memView.address_radix());
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_DATA_FORMAT, int(memView.get_data_format()));
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ROW_CHUNKS, memView.chunks_per_row());
+ node.add_child(NODE_WINDOW_EXPRESSION, memView.expression());
+}
+
+
void MemoryWindow::memoryRegionChanged(int index)
{
if (index < m_memTable->view()->source_count())
@@ -220,28 +244,26 @@ void MemoryWindow::memoryRegionChanged(int index)
m_memTable->viewport()->update();
// Update the data format radio buttons to the memory region's default
- debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
- switch (memView->get_data_format())
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
+
+ QActionGroup *const dataFormat = findChild<QActionGroup *>("dataformat");
+ for (QAction *action : dataFormat->actions())
{
- case debug_view_memory::data_format::HEX_8BIT: dataFormatMenuItem("formatActOne")->setChecked(true); break;
- case debug_view_memory::data_format::HEX_16BIT: dataFormatMenuItem("formatActTwo")->setChecked(true); break;
- case debug_view_memory::data_format::HEX_32BIT: dataFormatMenuItem("formatActFour")->setChecked(true); break;
- case debug_view_memory::data_format::HEX_64BIT: dataFormatMenuItem("formatActEight")->setChecked(true); break;
- case debug_view_memory::data_format::OCTAL_8BIT: dataFormatMenuItem("formatActOneOctal")->setChecked(true); break;
- case debug_view_memory::data_format::OCTAL_16BIT: dataFormatMenuItem("formatActTwoOctal")->setChecked(true); break;
- case debug_view_memory::data_format::OCTAL_32BIT: dataFormatMenuItem("formatActFourOctal")->setChecked(true); break;
- case debug_view_memory::data_format::OCTAL_64BIT: dataFormatMenuItem("formatActEightOctal")->setChecked(true); break;
- case debug_view_memory::data_format::FLOAT_32BIT: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break;
- case debug_view_memory::data_format::FLOAT_64BIT: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break;
- case debug_view_memory::data_format::FLOAT_80BIT: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break;
- default: break;
+ if (debug_view_memory::data_format(action->data().toInt()) == memView->get_data_format())
+ {
+ action->setChecked(true);
+ break;
+ }
}
- switch (memView->address_radix())
+
+ QActionGroup *radixGroup = findChild<QActionGroup*>("radixgroup");
+ for (QAction *action : radixGroup->actions())
{
- case 8: dataFormatMenuItem("radixOctal")->setChecked(true); break;
- case 10: dataFormatMenuItem("radixDecimal")->setChecked(true); break;
- case 16: dataFormatMenuItem("radixHexadecimal")->setChecked(true); break;
- default: break;
+ if (action->data().toInt() == memView->address_radix())
+ {
+ action->setChecked(true);
+ break;
+ }
}
}
}
@@ -250,7 +272,7 @@ void MemoryWindow::memoryRegionChanged(int index)
void MemoryWindow::expressionSubmitted()
{
const QString expression = m_inputEdit->text();
- downcast<debug_view_memory *>(m_memTable->view())->set_expression(expression.toLocal8Bit().data());
+ m_memTable->view<debug_view_memory>()->set_expression(expression.toLocal8Bit().data());
// Make the cursor pop
m_memTable->view()->set_cursor_visible(true);
@@ -267,66 +289,31 @@ void MemoryWindow::expressionSubmitted()
void MemoryWindow::formatChanged(QAction* changedTo)
{
- debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
-
- if (changedTo->text() == "1-byte hexadecimal")
- memView->set_data_format(debug_view_memory::data_format::HEX_8BIT);
- else if (changedTo->text() == "2-byte hexadecimal")
- memView->set_data_format(debug_view_memory::data_format::HEX_16BIT);
- else if (changedTo->text() == "4-byte hexadecimal")
- memView->set_data_format(debug_view_memory::data_format::HEX_32BIT);
- else if (changedTo->text() == "8-byte hexadecimal")
- memView->set_data_format(debug_view_memory::data_format::HEX_64BIT);
- else if (changedTo->text() == "1-byte octal")
- memView->set_data_format(debug_view_memory::data_format::OCTAL_8BIT);
- else if (changedTo->text() == "2-byte octal")
- memView->set_data_format(debug_view_memory::data_format::OCTAL_16BIT);
- else if (changedTo->text() == "4-byte octal")
- memView->set_data_format(debug_view_memory::data_format::OCTAL_32BIT);
- else if (changedTo->text() == "8-byte octal")
- memView->set_data_format(debug_view_memory::data_format::OCTAL_64BIT);
- else if (changedTo->text() == "32 bit floating point")
- memView->set_data_format(debug_view_memory::data_format::FLOAT_32BIT);
- else if (changedTo->text() == "64 bit floating point")
- memView->set_data_format(debug_view_memory::data_format::FLOAT_64BIT);
- else if (changedTo->text() == "80 bit floating point")
- memView->set_data_format(debug_view_memory::data_format::FLOAT_80BIT);
-
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
+ memView->set_data_format(debug_view_memory::data_format(changedTo->data().toInt()));
m_memTable->viewport()->update();
}
void MemoryWindow::addressChanged(QAction* changedTo)
{
- debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
-
- if (changedTo->text() == "Logical Addresses")
- memView->set_physical(false);
- else if (changedTo->text() == "Physical Addresses")
- memView->set_physical(true);
-
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
+ memView->set_physical(changedTo->data().toBool());
m_memTable->viewport()->update();
}
void MemoryWindow::radixChanged(QAction* changedTo)
{
- debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
-
- if (changedTo->text() == "Hexadecimal Addresses")
- memView->set_address_radix(16);
- else if (changedTo->text() == "Decimal Addresses")
- memView->set_address_radix(10);
- else if (changedTo->text() == "Octal Addresses")
- memView->set_address_radix(8);
-
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
+ memView->set_address_radix(changedTo->data().toInt());
m_memTable->viewport()->update();
}
void MemoryWindow::reverseChanged(bool changedTo)
{
- debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
memView->set_reverse(changedTo);
m_memTable->viewport()->update();
}
@@ -334,7 +321,7 @@ void MemoryWindow::reverseChanged(bool changedTo)
void MemoryWindow::increaseBytesPerLine(bool changedTo)
{
- debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
memView->set_chunks_per_row(memView->chunks_per_row() + 1);
m_memTable->viewport()->update();
}
@@ -342,7 +329,7 @@ void MemoryWindow::increaseBytesPerLine(bool changedTo)
void MemoryWindow::decreaseBytesPerLine(bool checked)
{
- debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
+ debug_view_memory *const memView = m_memTable->view<debug_view_memory>();
memView->set_chunks_per_row(memView->chunks_per_row() - 1);
m_memTable->viewport()->update();
}
@@ -374,25 +361,6 @@ void MemoryWindow::setToCurrentCpu()
}
-// I have a hard time storing QActions as class members. This is a substitute.
-QAction *MemoryWindow::dataFormatMenuItem(const QString& itemName)
-{
- QList<QMenu *> menus = menuBar()->findChildren<QMenu *>();
- for (int i = 0; i < menus.length(); i++)
- {
- if (menus[i]->title() != "&Options")
- continue;
- QList<QAction *> actions = menus[i]->actions();
- for (int j = 0; j < actions.length(); j++)
- {
- if (actions[j]->objectName() == itemName)
- return actions[j];
- }
- }
- return nullptr;
-}
-
-
//=========================================================================
// DebuggerMemView
//=========================================================================
@@ -402,7 +370,7 @@ void DebuggerMemView::addItemsToContextMenu(QMenu *menu)
if (view()->cursor_visible())
{
- debug_view_memory &memView = downcast<debug_view_memory &>(*view());
+ debug_view_memory &memView = *view<debug_view_memory>();
debug_view_memory_source const &source = downcast<debug_view_memory_source const &>(*memView.source());
address_space *const addressSpace = source.space();
if (addressSpace)
@@ -466,55 +434,6 @@ void DebuggerMemView::copyLastPc()
//=========================================================================
// MemoryWindowQtConfig
//=========================================================================
-void MemoryWindowQtConfig::buildFromQWidget(QWidget *widget)
-{
- WindowQtConfig::buildFromQWidget(widget);
- MemoryWindow *window = dynamic_cast<MemoryWindow *>(widget);
- QComboBox *memoryRegion = window->findChild<QComboBox*>("memoryregion");
- m_memoryRegion = memoryRegion->currentIndex();
-
- QAction *reverse = window->findChild<QAction *>("reverse");
- m_reverse = reverse->isChecked();
-
- QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
- if (addressGroup->checkedAction()->text() == "Logical Addresses")
- m_addressMode = 0;
- else if (addressGroup->checkedAction()->text() == "Physical Addresses")
- m_addressMode = 1;
-
- QActionGroup *radixGroup = window->findChild<QActionGroup*>("radixgroup");
- if (radixGroup->checkedAction()->text() == "Hexadecimal Addresses")
- m_addressRadix = 0;
- else if (radixGroup->checkedAction()->text() == "Decimal Addresses")
- m_addressRadix = 1;
- else if (radixGroup->checkedAction()->text() == "Octal Addresses")
- m_addressRadix = 2;
-
- QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
- if (dataFormat->checkedAction()->text() == "1-byte hexadecimal")
- m_dataFormat = 0;
- else if (dataFormat->checkedAction()->text() == "2-byte hexadecimal")
- m_dataFormat = 1;
- else if (dataFormat->checkedAction()->text() == "4-byte hexadecimal")
- m_dataFormat = 2;
- else if (dataFormat->checkedAction()->text() == "8-byte hexadecimal")
- m_dataFormat = 3;
- else if (dataFormat->checkedAction()->text() == "1-byte octal")
- m_dataFormat = 4;
- else if (dataFormat->checkedAction()->text() == "2-byte octal")
- m_dataFormat = 5;
- else if (dataFormat->checkedAction()->text() == "4-byte octal")
- m_dataFormat = 6;
- else if (dataFormat->checkedAction()->text() == "8-byte octal")
- m_dataFormat = 7;
- else if (dataFormat->checkedAction()->text() == "32 bit floating point")
- m_dataFormat = 8;
- else if (dataFormat->checkedAction()->text() == "64 bit floating point")
- m_dataFormat = 9;
- else if (dataFormat->checkedAction()->text() == "80 bit floating point")
- m_dataFormat = 10;
-}
-
void MemoryWindowQtConfig::applyToQWidget(QWidget *widget)
{
@@ -527,34 +446,46 @@ void MemoryWindowQtConfig::applyToQWidget(QWidget *widget)
if (m_reverse)
reverse->trigger();
- QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
- addressGroup->actions()[m_addressMode]->trigger();
-
- QActionGroup *radixGroup = window->findChild<QActionGroup*>("radixgroup");
- radixGroup->actions()[m_addressRadix]->trigger();
-
- QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
- dataFormat->actions()[m_dataFormat]->trigger();
-}
+ QActionGroup *const addressGroup = window->findChild<QActionGroup*>("addressgroup");
+ for (QAction *action : addressGroup->actions())
+ {
+ if (action->data().toBool() == m_addressMode)
+ {
+ action->trigger();
+ break;
+ }
+ }
+ QActionGroup *const radixGroup = window->findChild<QActionGroup*>("radixgroup");
+ for (QAction *action : radixGroup->actions())
+ {
+ if (action->data().toInt() == m_addressRadix)
+ {
+ action->trigger();
+ break;
+ }
+ }
-void MemoryWindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
-{
- WindowQtConfig::addToXmlDataNode(node);
- node.set_attribute_int("memoryregion", m_memoryRegion);
- node.set_attribute_int("reverse", m_reverse);
- node.set_attribute_int("addressmode", m_addressMode);
- node.set_attribute_int("addressradix", m_addressRadix);
- node.set_attribute_int("dataformat", m_dataFormat);
+ QActionGroup *const dataFormat = window->findChild<QActionGroup*>("dataformat");
+ for (QAction *action : dataFormat->actions())
+ {
+ if (action->data().toInt() == m_dataFormat)
+ {
+ action->trigger();
+ break;
+ }
+ }
}
void MemoryWindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
WindowQtConfig::recoverFromXmlNode(node);
- m_memoryRegion = node.get_attribute_int("memoryregion", m_memoryRegion);
- m_reverse = node.get_attribute_int("reverse", m_reverse);
- m_addressMode = node.get_attribute_int("addressmode", m_addressMode);
- m_addressRadix = node.get_attribute_int("addressradix", m_addressRadix);
- m_dataFormat = node.get_attribute_int("dataformat", m_dataFormat);
+ m_memoryRegion = node.get_attribute_int(ATTR_WINDOW_MEMORY_REGION, m_memoryRegion);
+ m_reverse = node.get_attribute_int(ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, m_reverse);
+ m_addressMode = node.get_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_MODE, m_addressMode);
+ m_addressRadix = node.get_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_RADIX, m_addressRadix);
+ m_dataFormat = node.get_attribute_int(ATTR_WINDOW_MEMORY_DATA_FORMAT, m_dataFormat);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/memorywindow.h b/src/osd/modules/debugger/qt/memorywindow.h
index 86193cc3edc..131afa3e027 100644
--- a/src/osd/modules/debugger/qt/memorywindow.h
+++ b/src/osd/modules/debugger/qt/memorywindow.h
@@ -3,12 +3,17 @@
#ifndef MAME_DEBUGGER_QT_MEMORYWINDOW_H
#define MAME_DEBUGGER_QT_MEMORYWINDOW_H
+#pragma once
+
#include "debuggerview.h"
#include "windowqt.h"
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLineEdit>
+
+namespace osd::debugger::qt {
+
class DebuggerMemView;
@@ -23,6 +28,9 @@ public:
MemoryWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~MemoryWindow();
+protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node) override;
+
private slots:
void memoryRegionChanged(int index);
void expressionSubmitted();
@@ -36,7 +44,6 @@ private slots:
private:
void populateComboBox();
void setToCurrentCpu();
- QAction *dataFormatMenuItem(const QString &itemName);
// Widgets
QLineEdit *m_inputEdit;
@@ -77,7 +84,7 @@ class MemoryWindowQtConfig : public WindowQtConfig
{
public:
MemoryWindowQtConfig() :
- WindowQtConfig(WIN_TYPE_MEMORY),
+ WindowQtConfig(WINDOW_TYPE_MEMORY_VIEWER),
m_reverse(0),
m_addressMode(0),
m_addressRadix(0),
@@ -95,11 +102,10 @@ public:
int m_dataFormat;
int m_memoryRegion;
- void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget *widget);
- void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_MEMORYWINDOW_H
diff --git a/src/osd/modules/debugger/qt/windowqt.cpp b/src/osd/modules/debugger/qt/windowqt.cpp
index 852d1f5449c..7538f1bc11f 100644
--- a/src/osd/modules/debugger/qt/windowqt.cpp
+++ b/src/osd/modules/debugger/qt/windowqt.cpp
@@ -12,9 +12,14 @@
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "util/xmlfile.h"
+
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
+
+namespace osd::debugger::qt {
+
bool WindowQt::s_refreshAll = false;
bool WindowQt::s_hideAll = false;
@@ -35,15 +40,15 @@ WindowQt::WindowQt(running_machine &machine, QWidget *parent) :
debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M"));
connect(debugActOpenMemory, &QAction::triggered, this, &WindowQt::debugActOpenMemory);
- QAction *debugActOpenDasm = new QAction("New &Dasm Window", this);
+ QAction *debugActOpenDasm = new QAction("New &Disassembly Window", this);
debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D"));
connect(debugActOpenDasm, &QAction::triggered, this, &WindowQt::debugActOpenDasm);
- QAction *debugActOpenLog = new QAction("New &Log Window", this);
+ QAction *debugActOpenLog = new QAction("New Error &Log Window", this);
debugActOpenLog->setShortcut(QKeySequence("Ctrl+L"));
connect(debugActOpenLog, &QAction::triggered, this, &WindowQt::debugActOpenLog);
- QAction *debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this);
+ QAction *debugActOpenPoints = new QAction("New (&Break|Watch)points Window", this);
debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B"));
connect(debugActOpenPoints, &QAction::triggered, this, &WindowQt::debugActOpenPoints);
@@ -241,39 +246,40 @@ void WindowQt::debugActQuit()
}
-//=========================================================================
-// WindowQtConfig
-//=========================================================================
-void WindowQtConfig::buildFromQWidget(QWidget *widget)
+void WindowQt::saveConfiguration(util::xml::data_node &parentnode)
{
- m_position.setX(widget->geometry().topLeft().x());
- m_position.setY(widget->geometry().topLeft().y());
- m_size.setX(widget->size().width());
- m_size.setY(widget->size().height());
+ util::xml::data_node *const node = parentnode.add_child(NODE_WINDOW, nullptr);
+ if (node)
+ saveConfigurationToNode(*node);
}
-void WindowQtConfig::applyToQWidget(QWidget *widget)
+void WindowQt::saveConfigurationToNode(util::xml::data_node &node)
{
- widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y());
+ node.set_attribute_int(ATTR_WINDOW_POSITION_X, geometry().topLeft().x());
+ node.set_attribute_int(ATTR_WINDOW_POSITION_Y, geometry().topLeft().y());
+ node.set_attribute_int(ATTR_WINDOW_WIDTH, size().width());
+ node.set_attribute_int(ATTR_WINDOW_HEIGHT, size().height());
}
-void WindowQtConfig::addToXmlDataNode(util::xml::data_node &node) const
+//=========================================================================
+// WindowQtConfig
+//=========================================================================
+
+void WindowQtConfig::applyToQWidget(QWidget *widget)
{
- node.set_attribute_int("type", m_type);
- node.set_attribute_int("position_x", m_position.x());
- node.set_attribute_int("position_y", m_position.y());
- node.set_attribute_int("size_x", m_size.x());
- node.set_attribute_int("size_y", m_size.y());
+ widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y());
}
void WindowQtConfig::recoverFromXmlNode(util::xml::data_node const &node)
{
- m_size.setX(node.get_attribute_int("size_x", m_size.x()));
- m_size.setY(node.get_attribute_int("size_y", m_size.y()));
- m_position.setX(node.get_attribute_int("position_x", m_position.x()));
- m_position.setY(node.get_attribute_int("position_y", m_position.y()));
- m_type = (WindowQtConfig::WindowType)node.get_attribute_int("type", m_type);
+ m_size.setX(node.get_attribute_int(ATTR_WINDOW_WIDTH, m_size.x()));
+ m_size.setY(node.get_attribute_int(ATTR_WINDOW_HEIGHT, m_size.y()));
+ m_position.setX(node.get_attribute_int(ATTR_WINDOW_POSITION_X, m_position.x()));
+ m_position.setY(node.get_attribute_int(ATTR_WINDOW_POSITION_Y, m_position.y()));
+ m_type = node.get_attribute_int(ATTR_WINDOW_TYPE, m_type);
}
+
+} // namespace osd::debugger::qt
diff --git a/src/osd/modules/debugger/qt/windowqt.h b/src/osd/modules/debugger/qt/windowqt.h
index 15cbe470f2f..ceea280e016 100644
--- a/src/osd/modules/debugger/qt/windowqt.h
+++ b/src/osd/modules/debugger/qt/windowqt.h
@@ -3,12 +3,15 @@
#ifndef MAME_DEBUGGER_QT_WINDOWQT_H
#define MAME_DEBUGGER_QT_WINDOWQT_H
-#include "config.h"
+#include "../xmlconfig.h"
+
#include "debugger.h"
#include <QtWidgets/QMainWindow>
+namespace osd::debugger::qt {
+
//============================================================
// The Qt window that everyone derives from.
//============================================================
@@ -29,6 +32,7 @@ public:
bool wantsHide() { return s_hideAll; }
void clearHideFlag() { s_hideAll = false; }
+ void saveConfiguration(util::xml::data_node &parentnode);
protected slots:
void debugActOpenMemory();
@@ -51,6 +55,8 @@ protected slots:
protected:
+ virtual void saveConfigurationToNode(util::xml::data_node &node);
+
running_machine &m_machine;
static bool s_refreshAll;
@@ -64,20 +70,7 @@ protected:
class WindowQtConfig
{
public:
- enum WindowType
- {
- WIN_TYPE_UNKNOWN,
- WIN_TYPE_MAIN,
- WIN_TYPE_MEMORY,
- WIN_TYPE_DASM,
- WIN_TYPE_LOG,
- WIN_TYPE_BREAK_POINTS,
- WIN_TYPE_DEVICES,
- WIN_TYPE_DEVICE_INFORMATION
- };
-
-public:
- WindowQtConfig(const WindowType& type=WIN_TYPE_UNKNOWN) :
+ WindowQtConfig(int type) :
m_type(type),
m_size(800, 600),
m_position(120, 120)
@@ -85,15 +78,14 @@ public:
virtual ~WindowQtConfig() {}
// Settings
- WindowType m_type;
+ int m_type;
QPoint m_size;
QPoint m_position;
- virtual void buildFromQWidget(QWidget *widget);
virtual void applyToQWidget(QWidget *widget);
- virtual void addToXmlDataNode(util::xml::data_node &node) const;
virtual void recoverFromXmlNode(util::xml::data_node const &node);
};
+} // namespace osd::debugger::qt
#endif // MAME_DEBUGGER_QT_WINDOWQT_H
diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp
index b2f12b69331..86635cd4153 100644
--- a/src/osd/modules/debugger/win/consolewininfo.cpp
+++ b/src/osd/modules/debugger/win/consolewininfo.cpp
@@ -12,6 +12,9 @@
#include "debugviewinfo.h"
#include "uimetrics.h"
+// devices
+#include "imagedev/cassette.h"
+
// emu
#include "debug/debugcon.h"
#include "debugger.h"
@@ -19,8 +22,8 @@
#include "softlist_dev.h"
#include "debug/debugcpu.h"
-// devices
-#include "imagedev/cassette.h"
+// util
+#include "util/xmlfile.h"
// osd/windows
#include "winutf8.h"
@@ -39,6 +42,8 @@
#include <wrl/client.h>
+namespace osd::debugger::win {
+
namespace {
class comdlg_filter_helper
@@ -209,7 +214,7 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
m_current_cpu(nullptr),
m_devices_menu(nullptr)
{
- if ((window() == nullptr) || (m_views[0] == nullptr))
+ if (!window() || !m_views[0])
goto cleanup;
// create the views
@@ -221,21 +226,30 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
goto cleanup;
{
- // Add image menu only if image devices exist
+ // add image menu only if image devices exist
image_interface_enumerator iter(machine().root_device());
if (iter.first() != nullptr)
{
m_devices_menu = CreatePopupMenu();
for (device_image_interface &img : iter)
{
- if (!img.user_loadable())
- continue;
- osd::text::tstring tc_buf = osd::text::to_tstring(string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[no image]"));
- AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf.c_str());
+ if (img.user_loadable())
+ {
+ osd::text::tstring tc_buf = osd::text::to_tstring(string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[no image]"));
+ AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf.c_str());
+ }
}
AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)m_devices_menu, TEXT("Media"));
}
+ // add the settings menu
+ HMENU const settingsmenu = CreatePopupMenu();
+ AppendMenu(settingsmenu, MF_ENABLED, ID_SAVE_WINDOWS, TEXT("Save Window Arrangement"));
+ AppendMenu(settingsmenu, MF_DISABLED | MF_SEPARATOR, 0, TEXT(""));
+ AppendMenu(settingsmenu, MF_ENABLED, ID_LIGHT_BACKGROUND, TEXT("Light Background"));
+ AppendMenu(settingsmenu, MF_ENABLED, ID_DARK_BACKGROUND, TEXT("Dark Background"));
+ AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)settingsmenu, TEXT("Settings"));
+
// get the work bounds
RECT work_bounds, bounds;
SystemParametersInfo(SPI_GETWORKAREA, 0, &work_bounds, 0);
@@ -346,7 +360,7 @@ void consolewin_info::update_menu()
{
disasmbasewin_info::update_menu();
- if (m_devices_menu != nullptr)
+ if (m_devices_menu)
{
// create the image menu
uint32_t cnt = 0;
@@ -432,70 +446,97 @@ void consolewin_info::update_menu()
cnt++;
}
}
+
+ HMENU const menu = GetMenu(window());
+ CheckMenuItem(menu, ID_SAVE_WINDOWS, MF_BYCOMMAND | (debugger().get_save_window_arrangement() ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(menu, ID_LIGHT_BACKGROUND, MF_BYCOMMAND | ((ui_metrics::THEME_LIGHT_BACKGROUND == metrics().get_color_theme()) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(menu, ID_DARK_BACKGROUND, MF_BYCOMMAND | ((ui_metrics::THEME_DARK_BACKGROUND == metrics().get_color_theme()) ? MF_CHECKED : MF_UNCHECKED));
}
bool consolewin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
- if ((HIWORD(wparam) == 0) && (LOWORD(wparam) >= ID_DEVICE_OPTIONS))
+ if (HIWORD(wparam) == 0)
{
- uint32_t const devid = (LOWORD(wparam) - ID_DEVICE_OPTIONS) / DEVOPTION_MAX;
- image_interface_enumerator iter(machine().root_device());
- device_image_interface *const img = iter.byindex(devid);
- if (img != nullptr)
+ if (LOWORD(wparam) >= ID_DEVICE_OPTIONS)
{
- switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX)
- {
- case DEVOPTION_ITEM:
- // TODO: this is supposed to show a software list item picker - it never worked properly
- return true;
- case DEVOPTION_OPEN :
- open_image_file(*img);
- return true;
- case DEVOPTION_CREATE:
- create_image_file(*img);
- return true;
- case DEVOPTION_CLOSE:
- img->unload();
- return true;
- }
- if (img->device().type() == CASSETTE)
+ uint32_t const devid = (LOWORD(wparam) - ID_DEVICE_OPTIONS) / DEVOPTION_MAX;
+ image_interface_enumerator iter(machine().root_device());
+ device_image_interface *const img = iter.byindex(devid);
+ if (img != nullptr)
{
- auto *const cassette = downcast<cassette_image_device *>(&img->device());
- bool s;
switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX)
{
- case DEVOPTION_CASSETTE_STOPPAUSE:
- cassette->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
+ case DEVOPTION_ITEM:
+ // TODO: this is supposed to show a software list item picker - it never worked properly
return true;
- case DEVOPTION_CASSETTE_PLAY:
- cassette->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
+ case DEVOPTION_OPEN :
+ open_image_file(*img);
return true;
- case DEVOPTION_CASSETTE_RECORD:
- cassette->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
+ case DEVOPTION_CREATE:
+ create_image_file(*img);
return true;
- case DEVOPTION_CASSETTE_REWIND:
- cassette->seek(0.0, SEEK_SET); // to start
+ case DEVOPTION_CLOSE:
+ img->unload();
return true;
- case DEVOPTION_CASSETTE_FASTFORWARD:
- cassette->seek(+300.0, SEEK_CUR); // 5 minutes forward or end, whichever comes first
- break;
- case DEVOPTION_CASSETTE_MOTOR:
- s =((cassette->get_state() & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED);
- cassette->change_state(s ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
- break;
- case DEVOPTION_CASSETTE_SOUND:
- s =((cassette->get_state() & CASSETTE_MASK_SPEAKER) == CASSETTE_SPEAKER_MUTED);
- cassette->change_state(s ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
- break;
+ }
+ if (img->device().type() == CASSETTE)
+ {
+ auto *const cassette = downcast<cassette_image_device *>(&img->device());
+ bool s;
+ switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX)
+ {
+ case DEVOPTION_CASSETTE_STOPPAUSE:
+ cassette->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
+ return true;
+ case DEVOPTION_CASSETTE_PLAY:
+ cassette->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
+ return true;
+ case DEVOPTION_CASSETTE_RECORD:
+ cassette->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
+ return true;
+ case DEVOPTION_CASSETTE_REWIND:
+ cassette->seek(0.0, SEEK_SET); // to start
+ return true;
+ case DEVOPTION_CASSETTE_FASTFORWARD:
+ cassette->seek(+300.0, SEEK_CUR); // 5 minutes forward or end, whichever comes first
+ return true;
+ case DEVOPTION_CASSETTE_MOTOR:
+ s = ((cassette->get_state() & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED);
+ cassette->change_state(s ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
+ return true;
+ case DEVOPTION_CASSETTE_SOUND:
+ s = ((cassette->get_state() & CASSETTE_MASK_SPEAKER) == CASSETTE_SPEAKER_MUTED);
+ cassette->change_state(s ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
+ return true;
+ }
}
}
}
+ else switch (LOWORD(wparam))
+ {
+ case ID_SAVE_WINDOWS:
+ debugger().set_save_window_arrangement(!debugger().get_save_window_arrangement());
+ return true;
+ case ID_LIGHT_BACKGROUND:
+ debugger().set_color_theme(ui_metrics::THEME_LIGHT_BACKGROUND);
+ return true;
+ case ID_DARK_BACKGROUND:
+ debugger().set_color_theme(ui_metrics::THEME_DARK_BACKGROUND);
+ return true;
+ }
}
return disasmbasewin_info::handle_command(wparam, lparam);
}
+void consolewin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ disasmbasewin_info::save_configuration_to_node(node);
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_CONSOLE);
+}
+
+
void consolewin_info::process_string(std::string const &string)
{
if (string.empty()) // an empty string is a single step
@@ -589,3 +630,5 @@ bool consolewin_info::get_softlist_info(device_image_interface &device)
return passes_tests;
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/consolewininfo.h b/src/osd/modules/debugger/win/consolewininfo.h
index 2d93895b64d..e79ba667a11 100644
--- a/src/osd/modules/debugger/win/consolewininfo.h
+++ b/src/osd/modules/debugger/win/consolewininfo.h
@@ -15,6 +15,8 @@
#include "disasmbasewininfo.h"
+namespace osd::debugger::win {
+
class consolewin_info : public disasmbasewin_info
{
public:
@@ -27,6 +29,7 @@ protected:
virtual void recompute_children() override;
virtual void update_menu() override;
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
private:
enum
@@ -52,8 +55,10 @@ private:
bool get_softlist_info(device_image_interface &img);
device_t *m_current_cpu;
- HMENU m_devices_menu;
+ HMENU m_devices_menu;
std::map<std::string,std::string> slmap;
};
+} // namespace osd::debugger::win
+
#endif // MAME_DEBUGGER_WIN_CONSOLEWININFO_H
diff --git a/src/osd/modules/debugger/win/debugbaseinfo.cpp b/src/osd/modules/debugger/win/debugbaseinfo.cpp
index 1be4f892da7..0de7331cbc8 100644
--- a/src/osd/modules/debugger/win/debugbaseinfo.cpp
+++ b/src/osd/modules/debugger/win/debugbaseinfo.cpp
@@ -10,6 +10,8 @@
#include "debugbaseinfo.h"
+namespace osd::debugger::win {
+
debugbase_info::debugbase_info(debugger_windows_interface &debugger) :
m_debugger(debugger),
m_machine(debugger.machine()),
@@ -60,3 +62,5 @@ void debugbase_info::smart_show_window(HWND wnd, bool show)
if (visible != show)
ShowWindow(wnd, show ? SW_SHOW : SW_HIDE);
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/debugbaseinfo.h b/src/osd/modules/debugger/win/debugbaseinfo.h
index 15f4b845e7c..da874a6b8fd 100644
--- a/src/osd/modules/debugger/win/debugbaseinfo.h
+++ b/src/osd/modules/debugger/win/debugbaseinfo.h
@@ -13,6 +13,8 @@
#include "debugwin.h"
+namespace osd::debugger::win {
+
class debugbase_info
{
protected:
@@ -35,4 +37,6 @@ private:
bool const &m_waiting_for_debugger;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_DEBUGBASEINFO_H
diff --git a/src/osd/modules/debugger/win/debugviewinfo.cpp b/src/osd/modules/debugger/win/debugviewinfo.cpp
index 6965d032dfa..8f3f05c16d2 100644
--- a/src/osd/modules/debugger/win/debugviewinfo.cpp
+++ b/src/osd/modules/debugger/win/debugviewinfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// debugview.c - Win32 debug window handling
+// debugviewinfo.cpp - Win32 debug window handling
//
//============================================================
@@ -12,9 +12,12 @@
#include "debugwininfo.h"
#include "uimetrics.h"
#include "debugger.h"
+
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "util/xmlfile.h"
+
#include "strconv.h"
#include "winutil.h"
@@ -22,6 +25,8 @@
#include <mmsystem.h>
+namespace osd::debugger::win {
+
// debugger view styles
#define DEBUG_VIEW_STYLE WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN
#define DEBUG_VIEW_STYLE_EX 0
@@ -180,6 +185,18 @@ void debugview_info::send_pagedown()
}
+int debugview_info::source_index() const
+{
+ if (m_view)
+ {
+ debug_view_source const *const source = m_view->source();
+ if (source)
+ return m_view->source_index(*source);
+ }
+ return -1;
+}
+
+
char const *debugview_info::source_name() const
{
if (m_view)
@@ -284,6 +301,56 @@ HWND debugview_info::create_source_combobox(HWND parent, LONG_PTR userdata)
}
+void debugview_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ if (m_view->cursor_supported())
+ {
+ util::xml::data_node const *const selection = node.get_child(NODE_WINDOW_SELECTION);
+ if (selection)
+ {
+ debug_view_xy pos = m_view->cursor_position();
+ m_view->set_cursor_visible(0 != selection->get_attribute_int(ATTR_SELECTION_CURSOR_VISIBLE, m_view->cursor_visible() ? 1 : 0));
+ selection->get_attribute_int(ATTR_SELECTION_CURSOR_X, pos.x);
+ selection->get_attribute_int(ATTR_SELECTION_CURSOR_Y, pos.y);
+ m_view->set_cursor_position(pos);
+ }
+ }
+
+ util::xml::data_node const *const scroll = node.get_child(NODE_WINDOW_SCROLL);
+ if (scroll)
+ {
+ debug_view_xy origin = m_view->visible_position();
+ origin.x = scroll->get_attribute_int(ATTR_SCROLL_ORIGIN_X, origin.x * metrics().debug_font_width()) / metrics().debug_font_width();
+ origin.y = scroll->get_attribute_int(ATTR_SCROLL_ORIGIN_Y, origin.y * metrics().debug_font_height()) / metrics().debug_font_height();
+ m_view->set_visible_position(origin);
+ }
+}
+
+
+void debugview_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ if (m_view->cursor_supported())
+ {
+ util::xml::data_node *const selection = node.add_child(NODE_WINDOW_SELECTION, nullptr);
+ if (selection)
+ {
+ debug_view_xy const pos = m_view->cursor_position();
+ selection->set_attribute_int(ATTR_SELECTION_CURSOR_VISIBLE, m_view->cursor_visible() ? 1 : 0);
+ selection->set_attribute_int(ATTR_SELECTION_CURSOR_X, pos.x);
+ selection->set_attribute_int(ATTR_SELECTION_CURSOR_Y, pos.y);
+ }
+ }
+
+ util::xml::data_node *const scroll = node.add_child(NODE_WINDOW_SCROLL, nullptr);
+ if (scroll)
+ {
+ debug_view_xy const origin = m_view->visible_position();
+ scroll->set_attribute_int(ATTR_SCROLL_ORIGIN_X, origin.x * metrics().debug_font_width());
+ scroll->set_attribute_int(ATTR_SCROLL_ORIGIN_Y, origin.y * metrics().debug_font_height());
+ }
+}
+
+
void debugview_info::add_items_to_context_menu(HMENU menu)
{
AppendMenu(menu, MF_ENABLED, ID_CONTEXT_COPY_VISIBLE, TEXT("Copy Visible"));
@@ -433,7 +500,7 @@ void debugview_info::draw_contents(HDC windc)
for (int iter = 0; iter < 2; iter++)
{
COLORREF fgcolor;
- COLORREF bgcolor = RGB(0xff,0xff,0xff);
+ COLORREF bgcolor = metrics().view_colors(DCA_NORMAL).second;
HBRUSH bgbrush = nullptr;
int last_attrib = -1;
TCHAR buffer[256];
@@ -457,20 +524,8 @@ void debugview_info::draw_contents(HDC windc)
{
COLORREF oldbg = bgcolor;
- // pick new background color
- bgcolor = RGB(0xff,0xff,0xff);
- if (viewdata[col].attrib & DCA_VISITED) bgcolor = RGB(0xc6, 0xe2, 0xff);
- if (viewdata[col].attrib & DCA_ANCILLARY) bgcolor = RGB(0xe0,0xe0,0xe0);
- if (viewdata[col].attrib & DCA_SELECTED) bgcolor = RGB(0xff,0x80,0x80);
- if (viewdata[col].attrib & DCA_CURRENT) bgcolor = RGB(0xff,0xff,0x00);
- if ((viewdata[col].attrib & DCA_SELECTED) && (viewdata[col].attrib & DCA_CURRENT)) bgcolor = RGB(0xff,0xc0,0x80);
-
- // pick new foreground color
- fgcolor = RGB(0x00,0x00,0x00);
- if (viewdata[col].attrib & DCA_CHANGED) fgcolor = RGB(0xff,0x00,0x00);
- if (viewdata[col].attrib & DCA_INVALID) fgcolor = RGB(0x00,0x00,0xff);
- if (viewdata[col].attrib & DCA_DISABLED) fgcolor = RGB((GetRValue(fgcolor) + GetRValue(bgcolor)) / 2, (GetGValue(fgcolor) + GetGValue(bgcolor)) / 2, (GetBValue(fgcolor) + GetBValue(bgcolor)) / 2);
- if (viewdata[col].attrib & DCA_COMMENT) fgcolor = RGB(0x00,0x80,0x00);
+ // pick new colors
+ std::tie(fgcolor, bgcolor) = metrics().view_colors(viewdata[col].attrib);
// flush any pending drawing
if (count > 0)
@@ -481,7 +536,7 @@ void debugview_info::draw_contents(HDC windc)
FillRect(dc, &bounds, bgbrush);
if (do_filldown)
{
- COLORREF const filldown = (last_attrib & DCA_ANCILLARY) ? RGB(0xe0,0xe0,0xe0) : RGB(0xff,0xff,0xff);
+ COLORREF const filldown = metrics().view_colors(last_attrib & DCA_ANCILLARY).second;
if (oldbg != filldown)
{
DeleteObject(bgbrush);
@@ -528,7 +583,7 @@ void debugview_info::draw_contents(HDC windc)
FillRect(dc, &bounds, bgbrush);
if (do_filldown)
{
- COLORREF const filldown = (last_attrib & DCA_ANCILLARY) ? RGB(0xe0,0xe0,0xe0) : RGB(0xff,0xff,0xff);
+ COLORREF const filldown = metrics().view_colors(last_attrib & DCA_ANCILLARY).second;
if (bgcolor != filldown)
{
DeleteObject(bgbrush);
@@ -1021,3 +1076,5 @@ void debugview_info::register_window_class()
s_window_class_registered = true;
}
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/debugviewinfo.h b/src/osd/modules/debugger/win/debugviewinfo.h
index beb5ee66ff0..a009c368441 100644
--- a/src/osd/modules/debugger/win/debugviewinfo.h
+++ b/src/osd/modules/debugger/win/debugviewinfo.h
@@ -17,6 +17,8 @@
#include "debug/debugvw.h"
+namespace osd::debugger::win {
+
class debugview_info : protected debugbase_info
{
public:
@@ -42,6 +44,7 @@ public:
bool cursor_supported() const { return m_view->cursor_supported(); }
bool cursor_visible() const { return m_view->cursor_visible(); }
+ int source_index() const;
char const *source_name() const;
device_t *source_device() const;
bool source_is_visible_cpu() const;
@@ -51,6 +54,9 @@ public:
HWND create_source_combobox(HWND parent, LONG_PTR userdata);
+ virtual void restore_configuration_from_node(util::xml::data_node const &node);
+ virtual void save_configuration_to_node(util::xml::data_node &node);
+
protected:
enum
{
@@ -86,4 +92,6 @@ private:
static bool s_window_class_registered;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_DEBUGVIEWINFO_H
diff --git a/src/osd/modules/debugger/win/debugwin.h b/src/osd/modules/debugger/win/debugwin.h
index e999b87334f..b123921a23f 100644
--- a/src/osd/modules/debugger/win/debugwin.h
+++ b/src/osd/modules/debugger/win/debugwin.h
@@ -10,6 +10,8 @@
#pragma once
+#include "../xmlconfig.h"
+
// standard windows headers
#include <windows.h>
#include <windowsx.h>
@@ -20,6 +22,8 @@
#endif
+namespace osd::debugger::win {
+
class debugview_info;
class debugwin_info;
class ui_metrics;
@@ -33,6 +37,9 @@ public:
virtual running_machine &machine() const = 0;
virtual ui_metrics &metrics() const = 0;
+ virtual void set_color_theme(int index) = 0;
+ virtual bool get_save_window_arrangement() const = 0;
+ virtual void set_save_window_arrangement(bool save) = 0;
virtual bool const &waiting_for_debugger() const = 0;
virtual bool seq_pressed() const = 0;
@@ -47,4 +54,6 @@ public:
virtual void hide_all() = 0;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_DEBUGWIN_H
diff --git a/src/osd/modules/debugger/win/debugwininfo.cpp b/src/osd/modules/debugger/win/debugwininfo.cpp
index fdd486f3e80..63d257b6529 100644
--- a/src/osd/modules/debugger/win/debugwininfo.cpp
+++ b/src/osd/modules/debugger/win/debugwininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// debugwininfo.c - Win32 debug window handling
+// debugwininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -14,12 +14,19 @@
#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+
+#include "util/xmlfile.h"
+
#include "window.h"
#include "winutf8.h"
-
#include "winutil.h"
+
#include "modules/lib/osdobj_common.h"
+#include <cstring>
+
+
+namespace osd::debugger::win {
bool debugwin_info::s_window_class_registered = false;
@@ -54,6 +61,12 @@ debugwin_info::~debugwin_info()
}
+void debugwin_info::redraw()
+{
+ RedrawWindow(m_wnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN);
+}
+
+
void debugwin_info::destroy()
{
for (int curview = 0; curview < MAX_VIEWS; curview++)
@@ -251,6 +264,89 @@ bool debugwin_info::handle_key(WPARAM wparam, LPARAM lparam)
}
+void debugwin_info::save_configuration(util::xml::data_node &parentnode)
+{
+ util::xml::data_node *const node = parentnode.add_child(NODE_WINDOW, nullptr);
+ if (node)
+ save_configuration_to_node(*node);
+}
+
+
+void debugwin_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ // get current size to use for defaults
+ RECT bounds;
+ POINT origin;
+ origin.x = 0;
+ origin.y = 0;
+ if (!GetClientRect(window(), &bounds) && ClientToScreen(window(), &origin))
+ return;
+
+ // get saved size and adjust for window chrome
+ RECT desired;
+ desired.left = node.get_attribute_int(ATTR_WINDOW_POSITION_X, origin.x);
+ desired.top = node.get_attribute_int(ATTR_WINDOW_POSITION_Y, origin.y);
+ desired.right = desired.left + node.get_attribute_int(ATTR_WINDOW_WIDTH, bounds.right);
+ desired.bottom = desired.top + node.get_attribute_int(ATTR_WINDOW_HEIGHT, bounds.bottom);
+ // TODO: sanity checks...
+ if (!AdjustWindowRectEx(&desired, DEBUG_WINDOW_STYLE, GetMenu(window()) ? TRUE : FALSE, DEBUG_WINDOW_STYLE_EX))
+ return;
+
+ // actually move the window
+ MoveWindow(
+ window(),
+ desired.left,
+ desired.top,
+ desired.right - desired.left,
+ desired.bottom - desired.top,
+ TRUE);
+
+ // restrict to one monitor and avoid toolbars
+ HMONITOR const nearest_monitor = MonitorFromWindow(window(), MONITOR_DEFAULTTONEAREST);
+ if (nearest_monitor)
+ {
+ MONITORINFO info;
+ std::memset(&info, 0, sizeof(info));
+ info.cbSize = sizeof(info);
+ if (GetMonitorInfo(nearest_monitor, &info))
+ {
+ if (desired.right > info.rcWork.right)
+ {
+ desired.left -= desired.right - info.rcWork.right;
+ desired.right = info.rcWork.right;
+ }
+ if (desired.bottom > info.rcWork.bottom)
+ {
+ desired.top -= desired.bottom - info.rcWork.bottom;
+ desired.bottom = info.rcWork.bottom;
+ }
+ if (desired.left < info.rcWork.left)
+ {
+ desired.right += info.rcWork.left - desired.left;
+ desired.left = info.rcWork.left;
+ }
+ if (desired.top < info.rcWork.top)
+ {
+ desired.bottom += info.rcWork.top - desired.top;
+ desired.top = info.rcWork.top;
+ }
+ desired.bottom = std::min(info.rcWork.bottom, desired.bottom);
+ desired.right = std::min(info.rcWork.right, desired.right);
+ MoveWindow(
+ window(),
+ desired.left,
+ desired.top,
+ desired.right - desired.left,
+ desired.bottom - desired.top,
+ TRUE);
+ }
+ }
+
+ // sort out contents
+ recompute_children();
+}
+
+
void debugwin_info::recompute_children()
{
if (m_views[0] != nullptr)
@@ -392,6 +488,22 @@ void debugwin_info::draw_border(HDC dc, RECT &bounds)
}
+void debugwin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ RECT bounds;
+ POINT origin;
+ origin.x = 0;
+ origin.y = 0;
+ if (GetClientRect(window(), &bounds) && ClientToScreen(window(), &origin))
+ {
+ node.set_attribute_int(ATTR_WINDOW_POSITION_X, origin.x);
+ node.set_attribute_int(ATTR_WINDOW_POSITION_Y, origin.y);
+ node.set_attribute_int(ATTR_WINDOW_WIDTH, bounds.right);
+ node.set_attribute_int(ATTR_WINDOW_HEIGHT, bounds.bottom);
+ }
+}
+
+
void debugwin_info::draw_border(HDC dc, HWND child)
{
RECT bounds;
@@ -620,3 +732,5 @@ void debugwin_info::register_window_class()
s_window_class_registered = true;
}
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/debugwininfo.h b/src/osd/modules/debugger/win/debugwininfo.h
index 20cea0d477d..1fa5e79796f 100644
--- a/src/osd/modules/debugger/win/debugwininfo.h
+++ b/src/osd/modules/debugger/win/debugwininfo.h
@@ -15,6 +15,8 @@
#include "debugbaseinfo.h"
+namespace osd::debugger::win {
+
class debugwin_info : protected debugbase_info
{
public:
@@ -40,6 +42,7 @@ public:
void show() const { smart_show_window(m_wnd, true); }
void hide() const { smart_show_window(m_wnd, false); }
void set_foreground() const { SetForegroundWindow(m_wnd); }
+ void redraw();
void destroy();
virtual bool set_default_focus();
@@ -49,6 +52,9 @@ public:
virtual bool handle_key(WPARAM wparam, LPARAM lparam);
+ void save_configuration(util::xml::data_node &parentnode);
+ virtual void restore_configuration_from_node(util::xml::data_node const &node);
+
protected:
static DWORD const DEBUG_WINDOW_STYLE = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN) & (~WS_MINIMIZEBOX & ~WS_MAXIMIZEBOX);
static DWORD const DEBUG_WINDOW_STYLE_EX = 0;
@@ -108,6 +114,10 @@ protected:
ID_CLEAR_LOG,
+ ID_SAVE_WINDOWS,
+ ID_LIGHT_BACKGROUND,
+ ID_DARK_BACKGROUND,
+
ID_DEVICE_OPTIONS // always keep this at the end
};
@@ -125,6 +135,8 @@ protected:
void draw_border(HDC dc, RECT &bounds);
void draw_border(HDC dc, HWND child);
+ virtual void save_configuration_to_node(util::xml::data_node &node);
+
std::unique_ptr<debugview_info> m_views[MAX_VIEWS];
private:
@@ -141,12 +153,14 @@ private:
HWND m_wnd;
WNDPROC const m_handler;
- uint32_t m_minwidth, m_maxwidth;
- uint32_t m_minheight, m_maxheight;
+ uint32_t m_minwidth, m_maxwidth;
+ uint32_t m_minheight, m_maxheight;
- uint16_t m_ignore_char_lparam;
+ uint16_t m_ignore_char_lparam;
static bool s_window_class_registered;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_DEBUGWININFO_H
diff --git a/src/osd/modules/debugger/win/disasmbasewininfo.cpp b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
index f68a7652c77..48771c4f133 100644
--- a/src/osd/modules/debugger/win/disasmbasewininfo.cpp
+++ b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// disasmbasewininfo.c - Win32 debug window handling
+// disasmbasewininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -20,6 +20,8 @@
//#include "winutf8.h"
+namespace osd::debugger::win {
+
disasmbasewin_info::disasmbasewin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) :
editwin_info(debugger, is_main_console, title, handler)
{
@@ -27,7 +29,7 @@ disasmbasewin_info::disasmbasewin_info(debugger_windows_interface &debugger, boo
return;
m_views[0].reset(new disasmview_info(debugger, *this, window()));
- if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
+ if (!m_views[0] || !m_views[0]->is_valid())
{
m_views[0].reset();
return;
@@ -118,7 +120,7 @@ void disasmbasewin_info::update_menu()
// first find an existing breakpoint at this address
const debug_breakpoint *bp = debug->breakpoint_find(address);
- if (bp == nullptr)
+ if (!bp)
{
ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Set breakpoint at cursor\tF9"));
ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Disable breakpoint at cursor\tShift+F9"));
@@ -131,7 +133,7 @@ void disasmbasewin_info::update_menu()
else
ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Enable breakpoint at cursor\tShift+F9"));
}
- bool const available = (bp != nullptr) && (!is_main_console() || dasmview->source_is_visible_cpu());
+ bool const available = bp && (!is_main_console() || dasmview->source_is_visible_cpu());
EnableMenuItem(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND | (available ? MF_ENABLED : MF_GRAYED));
}
else
@@ -174,7 +176,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
if (bp == nullptr)
{
- int32_t bpindex = debug->breakpoint_set(address, nullptr, nullptr);
+ int32_t bpindex = debug->breakpoint_set(address);
machine().debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
@@ -263,3 +265,19 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
}
return editwin_info::handle_command(wparam, lparam);
}
+
+
+void disasmbasewin_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ editwin_info::restore_configuration_from_node(node);
+ m_views[0]->restore_configuration_from_node(node);
+}
+
+
+void disasmbasewin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ editwin_info::save_configuration_to_node(node);
+ m_views[0]->save_configuration_to_node(node);
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/disasmbasewininfo.h b/src/osd/modules/debugger/win/disasmbasewininfo.h
index c22f7f08e78..1ef8245b5a0 100644
--- a/src/osd/modules/debugger/win/disasmbasewininfo.h
+++ b/src/osd/modules/debugger/win/disasmbasewininfo.h
@@ -15,6 +15,8 @@
#include "editwininfo.h"
+namespace osd::debugger::win {
+
class disasmbasewin_info : public editwin_info
{
public:
@@ -22,10 +24,14 @@ public:
virtual ~disasmbasewin_info();
virtual bool handle_key(WPARAM wparam, LPARAM lparam) override;
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
protected:
virtual void update_menu() override;
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
};
+} // namespace osd::debugger::win
+
#endif // MAME_DEBUGGER_WIN_DISASMBASEWININFO_H
diff --git a/src/osd/modules/debugger/win/disasmviewinfo.cpp b/src/osd/modules/debugger/win/disasmviewinfo.cpp
index 8884bee5195..3cf9dbd70ff 100644
--- a/src/osd/modules/debugger/win/disasmviewinfo.cpp
+++ b/src/osd/modules/debugger/win/disasmviewinfo.cpp
@@ -2,13 +2,17 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// disasmviewinfo.c - Win32 debug window handling
+// disasmviewinfo.cpp - Win32 debug window handling
//
//============================================================
#include "emu.h"
#include "disasmviewinfo.h"
+#include "util/xmlfile.h"
+
+
+namespace osd::debugger::win {
disasmview_info::disasmview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent) :
debugview_info(debugger, owner, parent, DVT_DISASSEMBLY)
@@ -21,6 +25,12 @@ disasmview_info::~disasmview_info()
}
+char const *disasmview_info::expression() const
+{
+ return view<debug_view_disasm>()->expression();
+}
+
+
disasm_right_column disasmview_info::right_column() const
{
return view<debug_view_disasm>()->right_column();
@@ -43,3 +53,23 @@ void disasmview_info::set_right_column(disasm_right_column contents)
{
view<debug_view_disasm>()->set_right_column(contents);
}
+
+
+void disasmview_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ debug_view_disasm &dasmview(*view<debug_view_disasm>());
+ dasmview.set_right_column(disasm_right_column(node.get_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmview.right_column())));
+
+ debugview_info::restore_configuration_from_node(node);
+}
+
+
+void disasmview_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ debugview_info::save_configuration_to_node(node);
+
+ debug_view_disasm &dasmview(*view<debug_view_disasm>());
+ node.set_attribute_int(ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN, dasmview.right_column());
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/disasmviewinfo.h b/src/osd/modules/debugger/win/disasmviewinfo.h
index 0685d762346..809f92b0c14 100644
--- a/src/osd/modules/debugger/win/disasmviewinfo.h
+++ b/src/osd/modules/debugger/win/disasmviewinfo.h
@@ -17,17 +17,25 @@
#include "debug/dvdisasm.h"
+namespace osd::debugger::win {
+
class disasmview_info : public debugview_info
{
public:
disasmview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent);
virtual ~disasmview_info();
+ char const *expression() const;
disasm_right_column right_column() const;
offs_t selected_address() const;
void set_expression(const std::string &expression);
void set_right_column(disasm_right_column contents);
+
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
};
+} // namespace osd::debugger::win
+
#endif // MAME_DEBUGGER_WIN_DISASMVIEWINFO_H
diff --git a/src/osd/modules/debugger/win/disasmwininfo.cpp b/src/osd/modules/debugger/win/disasmwininfo.cpp
index b94eadbba03..709ff4faa59 100644
--- a/src/osd/modules/debugger/win/disasmwininfo.cpp
+++ b/src/osd/modules/debugger/win/disasmwininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// disasmwininfo.c - Win32 debug window handling
+// disasmwininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -12,9 +12,14 @@
#include "debugviewinfo.h"
#include "disasmviewinfo.h"
#include "uimetrics.h"
+
+#include "util/xmlfile.h"
+
#include "winutf8.h"
+namespace osd::debugger::win {
+
disasmwin_info::disasmwin_info(debugger_windows_interface &debugger) :
disasmbasewin_info(debugger, false, "Disassembly", nullptr),
m_combownd(nullptr)
@@ -143,3 +148,34 @@ void disasmwin_info::update_caption()
{
win_set_window_text_utf8(window(), std::string("Disassembly: ").append(m_views[0]->source_name()).c_str());
}
+
+
+void disasmwin_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ m_views[0]->set_source_index(node.get_attribute_int(ATTR_WINDOW_DISASSEMBLY_CPU, m_views[0]->source_index()));
+ int const cursource = m_views[0]->source_index();
+ if (0 <= cursource)
+ SendMessage(m_combownd, CB_SETCURSEL, cursource, 0);
+ update_caption();
+
+ util::xml::data_node const *const expr = node.get_child(NODE_WINDOW_EXPRESSION);
+ if (expr && expr->get_value())
+ {
+ set_editwnd_text(expr->get_value());
+ process_string(expr->get_value());
+ }
+
+ disasmbasewin_info::restore_configuration_from_node(node);
+}
+
+
+void disasmwin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ disasmbasewin_info::save_configuration_to_node(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_DISASSEMBLY_VIEWER);
+ node.set_attribute_int(ATTR_WINDOW_DISASSEMBLY_CPU, m_views[0]->source_index());
+ node.add_child(NODE_WINDOW_EXPRESSION, downcast<disasmview_info *>(m_views[0].get())->expression());
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/disasmwininfo.h b/src/osd/modules/debugger/win/disasmwininfo.h
index 71764bab0ef..e5a5ceaaa0e 100644
--- a/src/osd/modules/debugger/win/disasmwininfo.h
+++ b/src/osd/modules/debugger/win/disasmwininfo.h
@@ -15,16 +15,21 @@
#include "disasmbasewininfo.h"
+namespace osd::debugger::win {
+
class disasmwin_info : public disasmbasewin_info
{
public:
disasmwin_info(debugger_windows_interface &debugger);
virtual ~disasmwin_info();
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
+
protected:
virtual void recompute_children() override;
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
virtual void draw_contents(HDC dc) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
private:
virtual void process_string(const std::string &string) override;
@@ -34,4 +39,6 @@ private:
HWND m_combownd;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_DISASMWININFO_H
diff --git a/src/osd/modules/debugger/win/editwininfo.cpp b/src/osd/modules/debugger/win/editwininfo.cpp
index d7959afd5f1..e5e48746f7f 100644
--- a/src/osd/modules/debugger/win/editwininfo.cpp
+++ b/src/osd/modules/debugger/win/editwininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// editwininfo.c - Win32 debug window handling
+// editwininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -17,6 +17,8 @@
#include "winutil.h"
+namespace osd::debugger::win {
+
namespace {
constexpr DWORD EDIT_BOX_STYLE = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
@@ -241,3 +243,5 @@ LRESULT CALLBACK editwin_info::static_edit_proc(HWND wnd, UINT message, WPARAM w
assert(info->m_editwnd == wnd);
return info->edit_proc(message, wparam, lparam);
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/editwininfo.h b/src/osd/modules/debugger/win/editwininfo.h
index 2156d8ba68d..6a18172b5c6 100644
--- a/src/osd/modules/debugger/win/editwininfo.h
+++ b/src/osd/modules/debugger/win/editwininfo.h
@@ -18,6 +18,8 @@
#include <string>
+namespace osd::debugger::win {
+
class editwin_info : public debugwin_info
{
public:
@@ -55,4 +57,6 @@ private:
int m_last_history;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_EDITWININFO_H
diff --git a/src/osd/modules/debugger/win/logviewinfo.cpp b/src/osd/modules/debugger/win/logviewinfo.cpp
index affd4acd17a..c6bbdfacb88 100644
--- a/src/osd/modules/debugger/win/logviewinfo.cpp
+++ b/src/osd/modules/debugger/win/logviewinfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Samuele Zannoli
//============================================================
//
-// logviewinfo.c - Win32 debug log window handling
+// logviewinfo.cpp - Win32 debug log window handling
//
//============================================================
@@ -12,6 +12,8 @@
#include "debug/dvtext.h"
+namespace osd::debugger::win {
+
logview_info::logview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent) :
debugview_info(debugger, owner, parent, DVT_LOG)
{
@@ -27,3 +29,5 @@ void logview_info::clear()
{
view<debug_view_log>()->clear();
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/logviewinfo.h b/src/osd/modules/debugger/win/logviewinfo.h
index d7ca0df8c9e..15de2a3a095 100644
--- a/src/osd/modules/debugger/win/logviewinfo.h
+++ b/src/osd/modules/debugger/win/logviewinfo.h
@@ -15,6 +15,8 @@
#include "debugviewinfo.h"
+namespace osd::debugger::win {
+
class logview_info : public debugview_info
{
public:
@@ -24,4 +26,6 @@ public:
void clear();
};
+} // namespace osd::debugger::win
+
#endif // MAME_DEBUGGER_WIN_LOGVIEWINFO_H
diff --git a/src/osd/modules/debugger/win/logwininfo.cpp b/src/osd/modules/debugger/win/logwininfo.cpp
index 88b6022aa9a..cd67e11fe8e 100644
--- a/src/osd/modules/debugger/win/logwininfo.cpp
+++ b/src/osd/modules/debugger/win/logwininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// logwininfo.c - Win32 debug window handling
+// logwininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -12,6 +12,10 @@
#include "debugviewinfo.h"
#include "logviewinfo.h"
+#include "util/xmlfile.h"
+
+
+namespace osd::debugger::win {
logwin_info::logwin_info(debugger_windows_interface &debugger) :
debugwin_info(debugger, false, std::string("Errorlog: ").append(debugger.machine().system().type.fullname()).append(" [").append(debugger.machine().system().name).append("]").c_str(), nullptr)
@@ -63,3 +67,12 @@ bool logwin_info::handle_command(WPARAM wparam, LPARAM lparam)
}
return debugwin_info::handle_command(wparam, lparam);
}
+
+
+void logwin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ debugwin_info::save_configuration_to_node(node);
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_ERROR_LOG_VIEWER);
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/logwininfo.h b/src/osd/modules/debugger/win/logwininfo.h
index b40d184485e..4e822f1b534 100644
--- a/src/osd/modules/debugger/win/logwininfo.h
+++ b/src/osd/modules/debugger/win/logwininfo.h
@@ -15,6 +15,8 @@
#include "debugwininfo.h"
+namespace osd::debugger::win {
+
class logwin_info : public debugwin_info
{
public:
@@ -23,6 +25,9 @@ public:
protected:
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_LOGWININFO_H
diff --git a/src/osd/modules/debugger/win/memoryviewinfo.cpp b/src/osd/modules/debugger/win/memoryviewinfo.cpp
index a8891553987..0e58893308a 100644
--- a/src/osd/modules/debugger/win/memoryviewinfo.cpp
+++ b/src/osd/modules/debugger/win/memoryviewinfo.cpp
@@ -2,16 +2,20 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// memoryviewinfo.c - Win32 debug window handling
+// memoryviewinfo.cpp - Win32 debug window handling
//
//============================================================
#include "emu.h"
#include "memoryviewinfo.h"
+#include "util/xmlfile.h"
+
#include "strconv.h"
+namespace osd::debugger::win {
+
memoryview_info::memoryview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent) :
debugview_info(debugger, owner, parent, DVT_MEMORY)
{
@@ -23,6 +27,12 @@ memoryview_info::~memoryview_info()
}
+char const *memoryview_info::expression() const
+{
+ return view<debug_view_memory>()->expression();
+}
+
+
debug_view_memory::data_format memoryview_info::data_format() const
{
return view<debug_view_memory>()->get_data_format();
@@ -83,6 +93,32 @@ void memoryview_info::set_address_radix(int radix)
}
+void memoryview_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ debug_view_memory &memview(*view<debug_view_memory>());
+ memview.set_reverse(0 != node.get_attribute_int(ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, memview.reverse() ? 1 : 0));
+ memview.set_physical(0 != node.get_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_MODE, memview.physical() ? 1 : 0));
+ memview.set_address_radix(node.get_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_RADIX, memview.address_radix()));
+ memview.set_data_format(debug_view_memory::data_format(node.get_attribute_int(ATTR_WINDOW_MEMORY_DATA_FORMAT, int(memview.get_data_format()))));
+ memview.set_chunks_per_row(node.get_attribute_int(ATTR_WINDOW_MEMORY_ROW_CHUNKS, memview.chunks_per_row()));
+
+ debugview_info::restore_configuration_from_node(node);
+}
+
+
+void memoryview_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ debugview_info::save_configuration_to_node(node);
+
+ debug_view_memory &memview(*view<debug_view_memory>());
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_REVERSE_COLUMNS, memview.reverse() ? 1 : 0);
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_MODE, memview.physical() ? 1 : 0);
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ADDRESS_RADIX, memview.address_radix());
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_DATA_FORMAT, int(memview.get_data_format()));
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_ROW_CHUNKS, memview.chunks_per_row());
+}
+
+
void memoryview_info::add_items_to_context_menu(HMENU menu)
{
debugview_info::add_items_to_context_menu(menu);
@@ -167,3 +203,5 @@ void memoryview_info::handle_context_menu(unsigned command)
};
}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/memoryviewinfo.h b/src/osd/modules/debugger/win/memoryviewinfo.h
index ccc451acd3e..514c6c13ec6 100644
--- a/src/osd/modules/debugger/win/memoryviewinfo.h
+++ b/src/osd/modules/debugger/win/memoryviewinfo.h
@@ -18,12 +18,15 @@
#include <string>
+namespace osd::debugger::win {
+
class memoryview_info : public debugview_info
{
public:
memoryview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent);
virtual ~memoryview_info();
+ char const *expression() const;
debug_view_memory::data_format data_format() const;
uint32_t chunks_per_row() const;
bool reverse() const;
@@ -37,6 +40,9 @@ public:
void set_physical(bool physical);
void set_address_radix(int radix);
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
+
protected:
enum
{
@@ -51,4 +57,6 @@ private:
std::string m_lastpc;
};
+} // namespace osd::debugger::win
+
#endif // MAME_DEBUGGER_WIN_MEMORYVIEWINFO_H
diff --git a/src/osd/modules/debugger/win/memorywininfo.cpp b/src/osd/modules/debugger/win/memorywininfo.cpp
index 3ed9b6b9482..59972cdde42 100644
--- a/src/osd/modules/debugger/win/memorywininfo.cpp
+++ b/src/osd/modules/debugger/win/memorywininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// memorywininfo.c - Win32 debug window handling
+// memorywininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -13,9 +13,13 @@
#include "memoryviewinfo.h"
#include "uimetrics.h"
+#include "util/xmlfile.h"
+
#include "winutf8.h"
+namespace osd::debugger::win {
+
memorywin_info::memorywin_info(debugger_windows_interface &debugger) :
editwin_info(debugger, false, "Memory", nullptr),
m_combownd(nullptr)
@@ -388,3 +392,37 @@ void memorywin_info::update_caption()
{
win_set_window_text_utf8(window(), std::string("Memory: ").append(m_views[0]->source_name()).c_str());
}
+
+
+void memorywin_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ m_views[0]->set_source_index(node.get_attribute_int(ATTR_WINDOW_MEMORY_REGION, m_views[0]->source_index()));
+ int const cursource = m_views[0]->source_index();
+ if (0 <= cursource)
+ SendMessage(m_combownd, CB_SETCURSEL, cursource, 0);
+ update_caption();
+
+ util::xml::data_node const *const expr = node.get_child(NODE_WINDOW_EXPRESSION);
+ if (expr && expr->get_value())
+ {
+ set_editwnd_text(expr->get_value());
+ process_string(expr->get_value());
+ }
+
+ editwin_info::restore_configuration_from_node(node);
+
+ m_views[0]->restore_configuration_from_node(node);
+}
+
+
+void memorywin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ editwin_info::save_configuration_to_node(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_MEMORY_VIEWER);
+ node.set_attribute_int(ATTR_WINDOW_MEMORY_REGION, m_views[0]->source_index());
+ node.add_child(NODE_WINDOW_EXPRESSION, downcast<memoryview_info *>(m_views[0].get())->expression());
+ m_views[0]->save_configuration_to_node(node);
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/memorywininfo.h b/src/osd/modules/debugger/win/memorywininfo.h
index e0436605707..a0a4072be0f 100644
--- a/src/osd/modules/debugger/win/memorywininfo.h
+++ b/src/osd/modules/debugger/win/memorywininfo.h
@@ -15,6 +15,8 @@
#include "editwininfo.h"
+namespace osd::debugger::win {
+
class memorywin_info : public editwin_info
{
public:
@@ -22,12 +24,14 @@ public:
virtual ~memorywin_info();
virtual bool handle_key(WPARAM wparam, LPARAM lparam) override;
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
protected:
virtual void recompute_children() override;
virtual void update_menu() override;
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
virtual void draw_contents(HDC dc) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
private:
virtual void process_string(const std::string &string) override;
@@ -37,4 +41,6 @@ private:
HWND m_combownd;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_MEMORYWININFO_H
diff --git a/src/osd/modules/debugger/win/pointswininfo.cpp b/src/osd/modules/debugger/win/pointswininfo.cpp
index 93926a697ae..9a4e52c3cf3 100644
--- a/src/osd/modules/debugger/win/pointswininfo.cpp
+++ b/src/osd/modules/debugger/win/pointswininfo.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// pointswininfo.c - Win32 debug window handling
+// pointswininfo.cpp - Win32 debug window handling
//
//============================================================
@@ -11,9 +11,13 @@
#include "debugviewinfo.h"
+#include "util/xmlfile.h"
+
#include "winutf8.h"
+namespace osd::debugger::win {
+
pointswin_info::pointswin_info(debugger_windows_interface &debugger) :
debugwin_info(debugger, false, std::string("All Breakpoints").c_str(), nullptr)
{
@@ -131,3 +135,46 @@ bool pointswin_info::handle_command(WPARAM wparam, LPARAM lparam)
}
return debugwin_info::handle_command(wparam, lparam);
}
+
+
+void pointswin_info::restore_configuration_from_node(util::xml::data_node const &node)
+{
+ switch (node.get_attribute_int(ATTR_WINDOW_POINTS_TYPE, -1))
+ {
+ case 0:
+ SendMessage(window(), WM_COMMAND, ID_SHOW_BREAKPOINTS, 0);
+ break;
+ case 1:
+ SendMessage(window(), WM_COMMAND, ID_SHOW_WATCHPOINTS, 0);
+ break;
+ case 2:
+ SendMessage(window(), WM_COMMAND, ID_SHOW_REGISTERPOINTS, 0);
+ break;
+ }
+
+ debugwin_info::restore_configuration_from_node(node);
+}
+
+
+void pointswin_info::save_configuration_to_node(util::xml::data_node &node)
+{
+ debugwin_info::save_configuration_to_node(node);
+
+ node.set_attribute_int(ATTR_WINDOW_TYPE, WINDOW_TYPE_POINTS_VIEWER);
+ switch (m_views[0]->type())
+ {
+ case DVT_BREAK_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 0);
+ break;
+ case DVT_WATCH_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 1);
+ break;
+ case DVT_REGISTER_POINTS:
+ node.set_attribute_int(ATTR_WINDOW_POINTS_TYPE, 2);
+ break;
+ default:
+ break;
+ }
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/pointswininfo.h b/src/osd/modules/debugger/win/pointswininfo.h
index 4e36155105e..506c68519e8 100644
--- a/src/osd/modules/debugger/win/pointswininfo.h
+++ b/src/osd/modules/debugger/win/pointswininfo.h
@@ -15,6 +15,8 @@
#include "debugwininfo.h"
+namespace osd::debugger::win {
+
class pointswin_info : public debugwin_info
{
public:
@@ -22,10 +24,14 @@ public:
virtual ~pointswin_info();
virtual bool handle_key(WPARAM wparam, LPARAM lparam) override;
+ virtual void restore_configuration_from_node(util::xml::data_node const &node) override;
protected:
virtual void update_menu() override;
virtual bool handle_command(WPARAM wparam, LPARAM lparam) override;
+ virtual void save_configuration_to_node(util::xml::data_node &node) override;
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_POINTSWININFO_H
diff --git a/src/osd/modules/debugger/win/uimetrics.cpp b/src/osd/modules/debugger/win/uimetrics.cpp
index 67eb045c619..e3d21cda06d 100644
--- a/src/osd/modules/debugger/win/uimetrics.cpp
+++ b/src/osd/modules/debugger/win/uimetrics.cpp
@@ -2,15 +2,48 @@
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
-// uimetrics.c - Win32 debug window handling
+// uimetrics.cpp - Win32 debug window handling
//
//============================================================
#include "emu.h"
#include "uimetrics.h"
+#include "debug/debugvw.h"
+
#include "strconv.h"
+#include <algorithm>
+
+
+namespace osd::debugger::win {
+
+COLORREF const ui_metrics::s_themes[][COLOR_COUNT] = {
+ {
+ RGB(0x00, 0x00, 0x00), // foreground normal
+ RGB(0xff, 0x00, 0x00), // foreground changed
+ RGB(0x00, 0x00, 0xff), // foreground invalid
+ RGB(0x00, 0x80, 0x00), // foreground comment
+ RGB(0xff, 0xff, 0xff), // background normal
+ RGB(0xff, 0x80, 0x80), // background selected
+ RGB(0xe0, 0xe0, 0xe0), // background ancillary
+ RGB(0xff, 0xff, 0x00), // background current
+ RGB(0xff, 0xc0, 0x80), // background current selected
+ RGB(0xc0, 0xe0, 0xff) // background visited
+ },
+ {
+ RGB(0xe0, 0xe0, 0xe0), // foreground normal
+ RGB(0xff, 0x60, 0xff), // foreground changed
+ RGB(0x00, 0xc0, 0xe0), // foreground invalid
+ RGB(0x00, 0xe0, 0x00), // foreground comment
+ RGB(0x00, 0x00, 0x00), // background normal
+ RGB(0xe0, 0x00, 0x00), // background selected
+ RGB(0x40, 0x40, 0x40), // background ancillary
+ RGB(0x00, 0x00, 0xc0), // background current
+ RGB(0xb0, 0x60, 0x00), // background current selected
+ RGB(0x00, 0x40, 0x80) // background visited
+ } };
+
ui_metrics::ui_metrics(osd_options const &options) :
m_debug_font(nullptr),
@@ -22,7 +55,7 @@ ui_metrics::ui_metrics(osd_options const &options) :
{
// create a temporary DC
HDC const temp_dc = GetDC(nullptr);
- if (temp_dc != nullptr)
+ if (temp_dc)
{
float const size = options.debugger_font_size();
char const *const face = options.debugger_font();
@@ -47,6 +80,9 @@ ui_metrics::ui_metrics(osd_options const &options) :
SelectObject(temp_dc, old_font);
ReleaseDC(nullptr, temp_dc);
}
+
+ // set default color theme
+ set_color_theme(THEME_LIGHT_BACKGROUND);
}
@@ -69,3 +105,56 @@ ui_metrics::~ui_metrics()
if (m_debug_font)
DeleteObject(m_debug_font);
}
+
+
+std::pair<COLORREF, COLORREF> ui_metrics::view_colors(u8 attrib) const
+{
+ std::pair<COLORREF, COLORREF> result;
+
+ if (attrib & DCA_SELECTED)
+ result.second = (attrib & DCA_CURRENT) ? m_colors[COLOR_BG_CURRENT_SELECTED] : m_colors[COLOR_BG_SELECTED];
+ else if (attrib & DCA_CURRENT)
+ result.second = m_colors[COLOR_BG_CURRENT];
+ else if (attrib & DCA_ANCILLARY)
+ result.second = m_colors[COLOR_BG_ANCILLARY];
+ else if (attrib & DCA_VISITED)
+ result.second = m_colors[COLOR_BG_VISITED];
+ else
+ result.second = m_colors[COLOR_BG_NORMAL];
+
+ if (DCA_COMMENT & attrib)
+ {
+ result.first = m_colors[COLOR_FG_COMMENT];
+ }
+ else
+ {
+ if (attrib & DCA_INVALID)
+ result.first = m_colors[COLOR_FG_INVALID];
+ else if (attrib & DCA_CHANGED)
+ result.first = m_colors[COLOR_FG_CHANGED];
+ else
+ result.first = m_colors[COLOR_FG_NORMAL];
+
+ if (attrib & DCA_DISABLED)
+ {
+ result.first = RGB(
+ (GetRValue(result.first) + GetRValue(result.second) + 1) >> 1,
+ (GetGValue(result.first) + GetGValue(result.second) + 1) >> 1,
+ (GetBValue(result.first) + GetBValue(result.second) + 1) >> 1);
+ }
+ }
+
+ return result;
+}
+
+
+void ui_metrics::set_color_theme(int index)
+{
+ if ((0 <= index) && (std::size(s_themes) > index))
+ {
+ std::copy(std::begin(s_themes[index]), std::end(s_themes[index]), m_colors);
+ m_color_theme = index;
+ }
+}
+
+} // namespace osd::debugger::win
diff --git a/src/osd/modules/debugger/win/uimetrics.h b/src/osd/modules/debugger/win/uimetrics.h
index 2687ada036c..e45ae810fa6 100644
--- a/src/osd/modules/debugger/win/uimetrics.h
+++ b/src/osd/modules/debugger/win/uimetrics.h
@@ -12,13 +12,22 @@
#include "debugwin.h"
-
#include "modules/lib/osdobj_common.h"
+#include <utility>
+
+
+namespace osd::debugger::win {
class ui_metrics
{
public:
+ enum
+ {
+ THEME_LIGHT_BACKGROUND,
+ THEME_DARK_BACKGROUND
+ };
+
ui_metrics(osd_options const &options);
ui_metrics(ui_metrics const &that);
~ui_metrics();
@@ -31,7 +40,28 @@ public:
uint32_t hscroll_height() const { return m_hscroll_height; }
uint32_t vscroll_width() const { return m_vscroll_width; }
+ std::pair<COLORREF, COLORREF> view_colors(u8 attrib) const;
+ int get_color_theme() const { return m_color_theme; }
+ void set_color_theme(int index);
+
private:
+ enum
+ {
+ COLOR_FG_NORMAL,
+ COLOR_FG_CHANGED,
+ COLOR_FG_INVALID,
+ COLOR_FG_COMMENT,
+
+ COLOR_BG_NORMAL,
+ COLOR_BG_SELECTED,
+ COLOR_BG_ANCILLARY,
+ COLOR_BG_CURRENT,
+ COLOR_BG_CURRENT_SELECTED,
+ COLOR_BG_VISITED,
+
+ COLOR_COUNT
+ };
+
HFONT m_debug_font;
uint32_t m_debug_font_height;
uint32_t m_debug_font_width;
@@ -39,6 +69,13 @@ private:
uint32_t const m_hscroll_height;
uint32_t const m_vscroll_width;
+
+ COLORREF m_colors[COLOR_COUNT];
+ int m_color_theme;
+
+ static COLORREF const s_themes[][COLOR_COUNT];
};
-#endif
+} // namespace osd::debugger::win
+
+#endif // MAME_DEBUGGER_WIN_UIMETRICS_H
diff --git a/src/osd/modules/debugger/xmlconfig.cpp b/src/osd/modules/debugger/xmlconfig.cpp
new file mode 100644
index 00000000000..9cdd34fc5da
--- /dev/null
+++ b/src/osd/modules/debugger/xmlconfig.cpp
@@ -0,0 +1,50 @@
+// license:BSD-3-Clause
+// copyright-holders:Vas Crabb
+
+#include "xmlconfig.h"
+
+namespace osd::debugger {
+
+char const *const NODE_WINDOW = "window";
+char const *const NODE_COLORS = "colors";
+
+char const *const NODE_WINDOW_SPLITS = "splits";
+char const *const NODE_WINDOW_SELECTION = "selection";
+char const *const NODE_WINDOW_SCROLL = "scroll";
+char const *const NODE_WINDOW_EXPRESSION = "expression";
+
+char const *const ATTR_DEBUGGER_SAVE_WINDOWS = "savewindows";
+
+char const *const ATTR_WINDOW_TYPE = "type";
+char const *const ATTR_WINDOW_POSITION_X = "position_x";
+char const *const ATTR_WINDOW_POSITION_Y = "position_y";
+char const *const ATTR_WINDOW_WIDTH = "size_x";
+char const *const ATTR_WINDOW_HEIGHT = "size_y";
+
+char const *const ATTR_WINDOW_MEMORY_REGION = "memoryregion";
+char const *const ATTR_WINDOW_MEMORY_REVERSE_COLUMNS = "reverse";
+char const *const ATTR_WINDOW_MEMORY_ADDRESS_MODE = "addressmode";
+char const *const ATTR_WINDOW_MEMORY_ADDRESS_RADIX = "addressradix";
+char const *const ATTR_WINDOW_MEMORY_DATA_FORMAT = "dataformat";
+char const *const ATTR_WINDOW_MEMORY_ROW_CHUNKS = "rowchunks";
+
+char const *const ATTR_WINDOW_DISASSEMBLY_CPU = "cpu";
+char const *const ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN = "rightbar";
+
+char const *const ATTR_WINDOW_POINTS_TYPE = "bwtype";
+
+char const *const ATTR_WINDOW_DEVICE_TAG = "device-tag";
+
+char const *const ATTR_COLORS_THEME = "theme";
+
+char const *const ATTR_SPLITS_CONSOLE_STATE = "state";
+char const *const ATTR_SPLITS_CONSOLE_DISASSEMBLY = "disassembly";
+
+char const *const ATTR_SELECTION_CURSOR_VISIBLE = "visible";
+char const *const ATTR_SELECTION_CURSOR_X = "start_x";
+char const *const ATTR_SELECTION_CURSOR_Y = "start_y";
+
+char const *const ATTR_SCROLL_ORIGIN_X = "position_x";
+char const *const ATTR_SCROLL_ORIGIN_Y = "position_y";
+
+} // namespace osd::debugger
diff --git a/src/osd/modules/debugger/xmlconfig.h b/src/osd/modules/debugger/xmlconfig.h
new file mode 100644
index 00000000000..a83f6ae960a
--- /dev/null
+++ b/src/osd/modules/debugger/xmlconfig.h
@@ -0,0 +1,68 @@
+// license:BSD-3-Clause
+// copyright-holders:Vas Crabb
+#ifndef MAME_OSD_DEBUGGER_XMLCONFIG_H
+#define MAME_OSD_DEBUGGER_XMLCONFIG_H
+
+#pragma once
+
+namespace osd::debugger {
+
+// Qt debugger started using these numeric types - they should be switched to mnemonics at some point
+enum
+{
+
+WINDOW_TYPE_CONSOLE = 1,
+WINDOW_TYPE_MEMORY_VIEWER,
+WINDOW_TYPE_DISASSEMBLY_VIEWER,
+WINDOW_TYPE_ERROR_LOG_VIEWER,
+WINDOW_TYPE_POINTS_VIEWER,
+WINDOW_TYPE_DEVICES_VIEWER,
+WINDOW_TYPE_DEVICE_INFO_VIEWER
+
+};
+
+extern char const *const NODE_WINDOW;
+extern char const *const NODE_COLORS;
+
+extern char const *const NODE_WINDOW_SPLITS;
+extern char const *const NODE_WINDOW_SELECTION;
+extern char const *const NODE_WINDOW_SCROLL;
+extern char const *const NODE_WINDOW_EXPRESSION;
+
+extern char const *const ATTR_DEBUGGER_SAVE_WINDOWS;
+
+extern char const *const ATTR_WINDOW_TYPE;
+extern char const *const ATTR_WINDOW_POSITION_X;
+extern char const *const ATTR_WINDOW_POSITION_Y;
+extern char const *const ATTR_WINDOW_WIDTH;
+extern char const *const ATTR_WINDOW_HEIGHT;
+
+extern char const *const ATTR_WINDOW_MEMORY_REGION;
+extern char const *const ATTR_WINDOW_MEMORY_REVERSE_COLUMNS;
+extern char const *const ATTR_WINDOW_MEMORY_ADDRESS_MODE;
+extern char const *const ATTR_WINDOW_MEMORY_ADDRESS_RADIX;
+extern char const *const ATTR_WINDOW_MEMORY_DATA_FORMAT;
+extern char const *const ATTR_WINDOW_MEMORY_ROW_CHUNKS;
+
+extern char const *const ATTR_WINDOW_DISASSEMBLY_CPU;
+extern char const *const ATTR_WINDOW_DISASSEMBLY_RIGHT_COLUMN;
+
+extern char const *const ATTR_WINDOW_POINTS_TYPE;
+
+extern char const *const ATTR_WINDOW_DEVICE_TAG;
+
+extern char const *const ATTR_COLORS_THEME;
+
+extern char const *const ATTR_SPLITS_CONSOLE_STATE;
+extern char const *const ATTR_SPLITS_CONSOLE_DISASSEMBLY;
+
+extern char const *const ATTR_SELECTION_CURSOR_VISIBLE;
+extern char const *const ATTR_SELECTION_CURSOR_X;
+extern char const *const ATTR_SELECTION_CURSOR_Y;
+
+extern char const *const ATTR_SCROLL_ORIGIN_X;
+extern char const *const ATTR_SCROLL_ORIGIN_Y;
+
+} // namespace osd::debugger
+
+#endif // MAME_OSD_DEBUGGER_XMLCONFIG_H
diff --git a/src/osd/modules/diagnostics/diagnostics_win32.cpp b/src/osd/modules/diagnostics/diagnostics_win32.cpp
index b80bbdfcdba..5b82b63f2c3 100644
--- a/src/osd/modules/diagnostics/diagnostics_win32.cpp
+++ b/src/osd/modules/diagnostics/diagnostics_win32.cpp
@@ -509,6 +509,9 @@ bool symbol_manager::parse_sym_line(const char *line, uintptr_t &address, std::s
// first look for a (ty) entry
const char *type = strstr(line, "(ty 20)");
if (type == nullptr)
+ type = strstr(line, "(ty 20)");
+
+ if (type == nullptr)
return false;
// scan forward in the line to find the address
diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp
index 199537bbdee..173021121f1 100644
--- a/src/osd/modules/file/winfile.cpp
+++ b/src/osd/modules/file/winfile.cpp
@@ -62,12 +62,12 @@ public:
LARGE_INTEGER largeOffset;
largeOffset.QuadPart = offset;
if (!SetFilePointerEx(m_handle, largeOffset, nullptr, FILE_BEGIN))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
// then perform the read
DWORD result = 0;
if (!ReadFile(m_handle, buffer, length, &result, nullptr))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
actual = result;
return std::error_condition();
@@ -79,12 +79,12 @@ public:
LARGE_INTEGER largeOffset;
largeOffset.QuadPart = offset;
if (!SetFilePointerEx(m_handle, largeOffset, nullptr, FILE_BEGIN))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
// then perform the write
DWORD result = 0;
if (!WriteFile(m_handle, buffer, length, &result, nullptr))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
actual = result;
return std::error_condition();
@@ -96,11 +96,11 @@ public:
LARGE_INTEGER largeOffset;
largeOffset.QuadPart = offset;
if (!SetFilePointerEx(m_handle, largeOffset, nullptr, FILE_BEGIN))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
// then perform the truncation
if (!SetEndOfFile(m_handle))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
else
return std::error_condition();
}
@@ -229,7 +229,7 @@ std::error_condition osd_file::open(std::string const &orig_path, uint32_t openf
// if we still failed, clean up and free
if (INVALID_HANDLE_VALUE == h)
- return win_error_to_file_error(err);
+ return win_error_to_error_condition(err);
}
// get the file size
@@ -259,7 +259,7 @@ std::error_condition osd_file::open(std::string const &orig_path, uint32_t openf
if (NO_ERROR != err)
{
CloseHandle(h);
- return win_error_to_file_error(err);
+ return win_error_to_error_condition(err);
}
}
@@ -299,7 +299,7 @@ std::error_condition osd_file::remove(std::string const &filename) noexcept
std::error_condition filerr;
if (!DeleteFile(tempstr.c_str()))
- filerr = win_error_to_file_error(GetLastError());
+ filerr = win_error_to_error_condition(GetLastError());
return filerr;
}
@@ -415,12 +415,12 @@ std::error_condition osd_get_full_path(std::string &dst, std::string const &path
std::wstring const w_path(osd::text::to_wstring(path));
DWORD const length(GetFullPathNameW(w_path.c_str(), 0, nullptr, nullptr));
if (!length)
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
// allocate a buffer and get the canonical path
std::unique_ptr<wchar_t []> buffer(std::make_unique<wchar_t []>(length));
if (!GetFullPathNameW(w_path.c_str(), length, buffer.get(), nullptr))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
// convert the result back to UTF-8
osd::text::from_wstring(dst, buffer.get());
@@ -534,69 +534,3 @@ bool osd_is_valid_filepath_char(char32_t uchar) noexcept
&& !(uchar >= '\x7F' && uchar <= '\x9F')
&& uchar_isvalid(uchar);
}
-
-
-
-//============================================================
-// win_error_to_file_error
-//============================================================
-
-std::error_condition win_error_to_file_error(DWORD error) noexcept
-{
- // TODO: work out if there's a better way to do this
- switch (error)
- {
- case ERROR_SUCCESS:
- return std::error_condition();
-
- case ERROR_INVALID_HANDLE:
- return std::errc::bad_file_descriptor;
-
- case ERROR_OUTOFMEMORY:
- return std::errc::not_enough_memory;
-
- case ERROR_NOT_SUPPORTED:
- return std::errc::not_supported;
-
- case ERROR_FILE_NOT_FOUND:
- case ERROR_PATH_NOT_FOUND:
- case ERROR_INVALID_NAME:
- return std::errc::no_such_file_or_directory;
-
- case ERROR_FILENAME_EXCED_RANGE:
- return std::errc::filename_too_long;
-
- case ERROR_ACCESS_DENIED:
- case ERROR_SHARING_VIOLATION:
- return std::errc::permission_denied;
-
- case ERROR_ALREADY_EXISTS:
- return std::errc::file_exists;
-
- case ERROR_TOO_MANY_OPEN_FILES:
- return std::errc::too_many_files_open;
-
- case ERROR_WRITE_FAULT:
- case ERROR_READ_FAULT:
- return std::errc::io_error;
-
- case ERROR_HANDLE_DISK_FULL:
- case ERROR_DISK_FULL:
- return std::errc::no_space_on_device;
-
- case ERROR_PATH_BUSY:
- case ERROR_BUSY:
- return std::errc::device_or_resource_busy;
-
- case ERROR_FILE_TOO_LARGE:
- return std::errc::file_too_large;
-
- case ERROR_INVALID_ACCESS:
- case ERROR_NEGATIVE_SEEK:
- case ERROR_BAD_ARGUMENTS:
- return std::errc::invalid_argument;
-
- default:
- return std::error_condition(error, std::system_category());
- }
-}
diff --git a/src/osd/modules/file/winfile.h b/src/osd/modules/file/winfile.h
index 83f0814733d..90cf6e69a60 100644
--- a/src/osd/modules/file/winfile.h
+++ b/src/osd/modules/file/winfile.h
@@ -32,6 +32,4 @@ std::error_condition win_open_socket(std::string const &path, std::uint32_t open
bool win_check_ptty_path(std::string const &path) noexcept;
std::error_condition win_open_ptty(std::string const &path, std::uint32_t openflags, osd_file::ptr &file, std::uint64_t &filesize) noexcept;
-std::error_condition win_error_to_file_error(DWORD error) noexcept;
-
#endif // MAME_OSD_MODULES_FILE_WINFILE_H
diff --git a/src/osd/modules/file/winptty.cpp b/src/osd/modules/file/winptty.cpp
index 7feeacce137..9aac0c5a990 100644
--- a/src/osd/modules/file/winptty.cpp
+++ b/src/osd/modules/file/winptty.cpp
@@ -8,11 +8,11 @@
#include "winutil.h"
#include <cassert>
-
-#include <windows.h>
#include <cstdlib>
#include <cstring>
+#include <windows.h>
+
namespace {
@@ -44,7 +44,7 @@ public:
{
DWORD bytes_read;
if (!ReadFile(m_handle, buffer, count, &bytes_read, nullptr))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
actual = bytes_read;
return std::error_condition();
@@ -54,7 +54,7 @@ public:
{
DWORD bytes_written;
if (!WriteFile(m_handle, buffer, count, &bytes_written, nullptr))
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
actual = bytes_written;
return std::error_condition();
@@ -99,7 +99,7 @@ std::error_condition win_open_ptty(std::string const &path, std::uint32_t openfl
if (openflags & OPEN_FLAG_CREATE)
pipe = CreateNamedPipe(t_name.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 32, 32, 0, nullptr);
if (INVALID_HANDLE_VALUE == pipe)
- return win_error_to_file_error(GetLastError());
+ return win_error_to_error_condition(GetLastError());
}
else
{
diff --git a/src/osd/modules/font/font_dwrite.cpp b/src/osd/modules/font/font_dwrite.cpp
index 70edc24c0f1..47a52dbd197 100644
--- a/src/osd/modules/font/font_dwrite.cpp
+++ b/src/osd/modules/font/font_dwrite.cpp
@@ -11,12 +11,19 @@
#if defined(OSD_WINDOWS)
-#include <windows.h>
+#include "corestr.h"
+
+#include "winutil.h"
+
+#include "osdcore.h"
+#include "strconv.h"
#include <cmath>
#include <memory>
#include <stdexcept>
+#include <windows.h>
+
// Windows Imaging Components
#include <wincodec.h>
@@ -34,11 +41,6 @@ DEFINE_GUID(GUID_WICPixelFormat8bppAlpha, 0xe6cd0116, 0xeeba, 0x4161, 0xaa, 0x85
#include <wrl/client.h>
#undef interface
-#include "strconv.h"
-#include "corestr.h"
-#include "winutil.h"
-#include "osdcore.h"
-
using namespace Microsoft::WRL;
//-------------------------------------------------
diff --git a/src/osd/modules/font/font_sdl.cpp b/src/osd/modules/font/font_sdl.cpp
index 6c97f0a71f0..ee3024177d4 100644
--- a/src/osd/modules/font/font_sdl.cpp
+++ b/src/osd/modules/font/font_sdl.cpp
@@ -351,10 +351,10 @@ bool font_sdl::get_font_families(std::string const &font_path, std::vector<std::
{
auto const compare_fonts = [](std::pair<std::string, std::string> const &a, std::pair<std::string, std::string> const &b) -> bool
{
- int const second = core_stricmp(a.second.c_str(), b.second.c_str());
+ int const second = core_stricmp(a.second, b.second);
if (second < 0) return true;
else if (second > 0) return false;
- else return core_stricmp(b.first.c_str(), b.first.c_str()) < 0;
+ else return core_stricmp(b.first, b.first) < 0;
};
std::string config((const char *)val.u.s);
std::string display(config);
diff --git a/src/osd/modules/font/font_windows.cpp b/src/osd/modules/font/font_windows.cpp
index 8e0bd568349..b11ffe75111 100644
--- a/src/osd/modules/font/font_windows.cpp
+++ b/src/osd/modules/font/font_windows.cpp
@@ -109,7 +109,7 @@ bool osd_font_windows::open(std::string const &font_path, std::string const &_na
// if it doesn't match our request, fail
std::string utf = osd::text::from_tstring(&realname[0]);
- int result = core_stricmp(utf.c_str(), name.c_str());
+ int result = core_stricmp(utf, name);
// if we didn't match, nuke our font and fall back
if (result != 0)
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index a3bbe494194..2c8f604c9a2 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -1039,6 +1039,13 @@ public:
char guid_str[256];
guid_str[0] = '\0';
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str) - 1);
+ char const *serial = nullptr;
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ serial = SDL_JoystickGetSerial(joy);
+#endif
+ std::string id(guid_str);
+ if (serial)
+ id.append(1, '-').append(serial);
sdl_joystick_device *const devinfo = m_sixaxis_mode
? &devicelist().create_device<sdl_sixaxis_joystick_device>(machine, name ? name : guid_str, guid_str, *this)
@@ -1053,20 +1060,16 @@ public:
devinfo->sdl_state.device = joy;
devinfo->sdl_state.joystick_id = SDL_JoystickInstanceID(joy);
devinfo->sdl_state.hapdevice = SDL_HapticOpenFromJoystick(joy);
-#if SDL_VERSION_ATLEAST(2, 0, 14)
- char const *const serial = SDL_JoystickGetSerial(joy);
if (serial)
devinfo->sdl_state.serial = serial;
- else
-#endif // SDL_VERSION_ATLEAST(2, 0, 14)
- devinfo->sdl_state.serial = std::nullopt;
- osd_printf_verbose("Joystick: %s [GUID %s] Vendor ID %04X, Product ID %04X, Revision %04X\n",
+ osd_printf_verbose("Joystick: %s [GUID %s] Vendor ID %04X, Product ID %04X, Revision %04X, Serial %s\n",
name ? name : "<nullptr>",
guid_str,
SDL_JoystickGetVendor(joy),
SDL_JoystickGetProduct(joy),
- SDL_JoystickGetProductVersion(joy));
+ SDL_JoystickGetProductVersion(joy),
+ serial ? serial : "<nullptr>");
osd_printf_verbose("Joystick: ... %d axes, %d buttons %d hats %d balls\n",
SDL_JoystickNumAxes(joy),
SDL_JoystickNumButtons(joy),
diff --git a/src/osd/modules/input/input_sdlcommon.cpp b/src/osd/modules/input/input_sdlcommon.cpp
index 659add8dc79..f0d8a8632f6 100644
--- a/src/osd/modules/input/input_sdlcommon.cpp
+++ b/src/osd/modules/input/input_sdlcommon.cpp
@@ -139,11 +139,6 @@ void sdl_event_manager::process_window_event(running_machine &machine, SDL_Event
void sdl_osd_interface::customize_input_type_list(std::vector<input_type_entry> &typelist)
{
- input_item_id mameid_code;
- input_code ui_code;
- const char* uimode;
- char fullmode[64];
-
// loop over the defaults
for (input_type_entry &entry : typelist)
{
@@ -151,22 +146,27 @@ void sdl_osd_interface::customize_input_type_list(std::vector<input_type_entry>
{
// configurable UI mode switch
case IPT_UI_TOGGLE_UI:
- uimode = options().ui_mode_key();
- if (!strcmp(uimode, "auto"))
{
+ char const *const uimode = options().ui_mode_key();
+ input_item_id mameid_code = ITEM_ID_INVALID;
+ if (!uimode || !*uimode || !strcmp(uimode, "auto"))
+ {
#if defined(__APPLE__) && defined(__MACH__)
- mameid_code = keyboard_trans_table::instance().lookup_mame_code("ITEM_ID_INSERT");
-#else
- mameid_code = keyboard_trans_table::instance().lookup_mame_code("ITEM_ID_SCRLOCK");
+ mameid_code = keyboard_trans_table::instance().lookup_mame_code("ITEM_ID_INSERT");
#endif
+ }
+ else
+ {
+ std::string fullmode("ITEM_ID_");
+ fullmode.append(uimode);
+ mameid_code = keyboard_trans_table::instance().lookup_mame_code(fullmode.c_str());
+ }
+ if (ITEM_ID_INVALID != mameid_code)
+ {
+ input_code const ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code));
+ entry.defseq(SEQ_TYPE_STANDARD).set(ui_code);
+ }
}
- else
- {
- snprintf(fullmode, 63, "ITEM_ID_%s", uimode);
- mameid_code = keyboard_trans_table::instance().lookup_mame_code(fullmode);
- }
- ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code));
- entry.defseq(SEQ_TYPE_STANDARD).set(ui_code);
break;
// alt-enter for fullscreen
case IPT_OSD_1:
diff --git a/src/osd/modules/input/input_windows.cpp b/src/osd/modules/input/input_windows.cpp
index 60306765f72..3b3765ce19e 100644
--- a/src/osd/modules/input/input_windows.cpp
+++ b/src/osd/modules/input/input_windows.cpp
@@ -78,8 +78,6 @@ void windows_osd_interface::poll_input(running_machine &machine) const
void windows_osd_interface::customize_input_type_list(std::vector<input_type_entry> &typelist)
{
- const char* uimode;
-
// loop over the defaults
for (input_type_entry &entry : typelist)
switch (entry.type())
@@ -91,16 +89,18 @@ void windows_osd_interface::customize_input_type_list(std::vector<input_type_ent
break;
// configurable UI mode switch
case IPT_UI_TOGGLE_UI:
- uimode = options().ui_mode_key();
- if (strcmp(uimode, "auto"))
{
- std::string fullmode = "ITEM_ID_";
- fullmode += uimode;
- input_item_id const mameid_code = keyboard_trans_table::instance().lookup_mame_code(fullmode.c_str());
- if (ITEM_ID_INVALID != mameid_code)
+ char const *const uimode = options().ui_mode_key();
+ if (uimode && *uimode && strcmp(uimode, "auto"))
{
- input_code const ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code));
- entry.defseq(SEQ_TYPE_STANDARD).set(ui_code);
+ std::string fullmode("ITEM_ID_");
+ fullmode.append(uimode);
+ input_item_id const mameid_code = keyboard_trans_table::instance().lookup_mame_code(fullmode.c_str());
+ if (ITEM_ID_INVALID != mameid_code)
+ {
+ input_code const ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code));
+ entry.defseq(SEQ_TYPE_STANDARD).set(ui_code);
+ }
}
}
break;
diff --git a/src/osd/modules/lib/osdlib.h b/src/osd/modules/lib/osdlib.h
index 8ca4762a111..c84901002ad 100644
--- a/src/osd/modules/lib/osdlib.h
+++ b/src/osd/modules/lib/osdlib.h
@@ -12,16 +12,20 @@
// - osd_ticks
// - osd_sleep
//============================================================
+#ifndef MAME_OSD_LIB_OSDLIB_H
+#define MAME_OSD_LIB_OSDLIB_H
-#ifndef __OSDLIB__
-#define __OSDLIB__
+#pragma once
#include <initializer_list>
#include <string>
+#include <string_view>
+#include <system_error>
#include <type_traits>
#include <vector>
#include <memory>
+
/*-----------------------------------------------------------------------------
osd_process_kill: kill the current process
@@ -54,10 +58,22 @@ void osd_process_kill();
int osd_setenv(const char *name, const char *value, int overwrite);
-/*-----------------------------------------------------------------------------
- osd_get_clipboard_text: retrieves text from the clipboard
------------------------------------------------------------------------------*/
-std::string osd_get_clipboard_text();
+/// \brief Get clipboard text
+///
+/// Gets current clipboard content as UTF-8 text. Returns an empty
+/// string if the clipboard contents cannot be converted to plain text.
+/// \return Clipboard contents or an empty string.
+std::string osd_get_clipboard_text() noexcept;
+
+
+/// \brief Set clipboard text
+///
+/// Sets the desktop environment's clipboard contents to the supplied
+/// UTF-8 text. The contents of the clipboard may be changed on error.
+/// \param [in] text The text to copy to the clipboard.
+/// \return An error condition if the operation failed or is
+/// unsupported.
+std::error_condition osd_set_clipboard_text(std::string_view text) noexcept;
namespace osd {
@@ -193,4 +209,4 @@ protected:
#define OSD_DYNAMIC_CALL(fname, ...) (*m_##fname##_pfn) ( __VA_ARGS__ )
#define OSD_DYNAMIC_API_TEST(fname) (m_##fname##_pfn != nullptr)
-#endif /* __OSDLIB__ */
+#endif // MAME_OSD_LIB_OSDLIB_H
diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp
index 19b228b6369..8f61bb4e998 100644
--- a/src/osd/modules/lib/osdlib_macosx.cpp
+++ b/src/osd/modules/lib/osdlib_macosx.cpp
@@ -85,7 +85,7 @@ void osd_break_into_debugger(const char *message)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text()
+std::string osd_get_clipboard_text() noexcept
{
std::string result;
bool has_result = false;
@@ -121,31 +121,48 @@ std::string osd_get_clipboard_text()
CFStringEncoding encoding;
if (UTTypeConformsTo(flavor_type, kUTTypeUTF16PlainText))
encoding = kCFStringEncodingUTF16;
- else if (UTTypeConformsTo (flavor_type, kUTTypeUTF8PlainText))
+ else if (UTTypeConformsTo(flavor_type, kUTTypeUTF8PlainText))
encoding = kCFStringEncodingUTF8;
- else if (UTTypeConformsTo (flavor_type, kUTTypePlainText))
+ else if (UTTypeConformsTo(flavor_type, kUTTypePlainText))
encoding = kCFStringEncodingMacRoman;
else
continue;
CFDataRef flavor_data;
err = PasteboardCopyItemFlavorData(pasteboard_ref, item_id, flavor_type, &flavor_data);
+ if (err)
+ continue;
- if (!err)
+ CFDataRef utf8_data;
+ if (kCFStringEncodingUTF8 == encoding)
+ {
+ utf8_data = flavor_data;
+ }
+ else
{
CFStringRef string_ref = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, flavor_data, encoding);
- CFDataRef data_ref = CFStringCreateExternalRepresentation (kCFAllocatorDefault, string_ref, kCFStringEncodingUTF8, '?');
- CFRelease(string_ref);
CFRelease(flavor_data);
+ if (!string_ref)
+ continue;
- CFIndex const length = CFDataGetLength(data_ref);
- CFRange const range = CFRangeMake(0, length);
-
- result.resize(length);
- CFDataGetBytes(data_ref, range, reinterpret_cast<unsigned char *>(&result[0]));
- has_result = true;
+ utf8_data = CFStringCreateExternalRepresentation(kCFAllocatorDefault, string_ref, kCFStringEncodingUTF8, '?');
+ CFRelease(string_ref);
+ }
- CFRelease(data_ref);
+ if (utf8_data)
+ {
+ CFIndex const length = CFDataGetLength(utf8_data);
+ CFRange const range = CFRangeMake(0, length);
+ try
+ {
+ result.resize(length);
+ CFDataGetBytes(utf8_data, range, reinterpret_cast<UInt8 *>(result.data()));
+ has_result = true;
+ }
+ catch (std::bad_alloc const &)
+ {
+ }
+ CFRelease(utf8_data);
}
}
@@ -157,6 +174,46 @@ std::string osd_get_clipboard_text()
return result;
}
+
+//============================================================
+// osd_set_clipboard_text
+//============================================================
+
+std::error_condition osd_set_clipboard_text(std::string_view text) noexcept
+{
+ // FIXME: better conversion of OSStatus to std::error_condition
+ OSStatus err;
+
+ CFDataRef const data = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<UInt8 const *>(text.data()), text.length());
+ if (!data)
+ return std::errc::not_enough_memory;
+
+ PasteboardRef pasteboard_ref;
+ err = PasteboardCreate(kPasteboardClipboard, &pasteboard_ref);
+ if (err)
+ {
+ CFRelease(data);
+ return std::errc::io_error;
+ }
+
+ err = PasteboardClear(pasteboard_ref);
+ if (err)
+ {
+ CFRelease(data);
+ CFRelease(pasteboard_ref);
+ return std::errc::io_error;
+ }
+
+ err = PasteboardPutItemFlavor(pasteboard_ref, PasteboardItemID(1), kUTTypeUTF8PlainText, data, kPasteboardFlavorNoFlags);
+ CFRelease(data);
+ CFRelease(pasteboard_ref);
+ if (err)
+ return std::errc::io_error;
+
+ return std::error_condition();
+}
+
+
//============================================================
// osd_getpid
//============================================================
diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp
index 4b091450116..0c6eb8622ab 100644
--- a/src/osd/modules/lib/osdlib_unix.cpp
+++ b/src/osd/modules/lib/osdlib_unix.cpp
@@ -69,28 +69,66 @@ void osd_break_into_debugger(const char *message)
}
#ifdef SDLMAME_ANDROID
-std::string osd_get_clipboard_text()
+std::string osd_get_clipboard_text() noexcept
{
return std::string();
}
+
+std::error_condition osd_set_clipboard_text(std::string_view text) noexcept
+{
+ return std::errc::io_error; // TODO: better error code?
+}
#else
//============================================================
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text()
+std::string osd_get_clipboard_text() noexcept
{
+ // TODO: better error handling
std::string result;
if (SDL_HasClipboardText())
{
- char *temp = SDL_GetClipboardText();
- result.assign(temp);
- SDL_free(temp);
+ char *const temp = SDL_GetClipboardText();
+ if (temp)
+ {
+ try
+ {
+ result.assign(temp);
+ }
+ catch (std::bad_alloc const &)
+ {
+ }
+ SDL_free(temp);
+ }
}
return result;
}
+
+//============================================================
+// osd_set_clipboard_text
+//============================================================
+
+std::error_condition osd_set_clipboard_text(std::string_view text) noexcept
+{
+ try
+ {
+ std::string const clip(text); // need to do this to ensure there's a terminating NUL for SDL
+ if (0 > SDL_SetClipboardText(clip.c_str()))
+ {
+ // SDL_GetError returns a message, can't really convert it to an error condition
+ return std::errc::io_error; // TODO: better error code?
+ }
+
+ return std::error_condition();
+ }
+ catch (std::bad_alloc const &)
+ {
+ return std::errc::not_enough_memory;
+ }
+}
#endif
//============================================================
diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp
index 174dc769760..d209e98c474 100644
--- a/src/osd/modules/lib/osdlib_win32.cpp
+++ b/src/osd/modules/lib/osdlib_win32.cpp
@@ -14,10 +14,10 @@
#include "osdcore.h"
#include "strconv.h"
-#ifdef OSD_WINDOWS
#include "winutf8.h"
-#endif
+#include "winutil.h"
+#include <algorithm>
#include <cstdio>
#include <cstdlib>
@@ -168,21 +168,88 @@ static std::string convert_ansi(LPCVOID data)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text()
+std::string osd_get_clipboard_text() noexcept
{
std::string result;
- // try to access unicode text
- if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide))
+ // TODO: better error handling
+ try
+ {
+ // try to access unicode text
+ if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide))
+ {
+ // try to access ANSI text
+ get_clipboard_text_by_format(result, CF_TEXT, convert_ansi);
+ }
+ }
+ catch (...)
{
- // try to access ANSI text
- get_clipboard_text_by_format(result, CF_TEXT, convert_ansi);
}
return result;
}
//============================================================
+// osd_set_clipboard_text
+//============================================================
+
+std::error_condition osd_set_clipboard_text(std::string_view text) noexcept
+{
+ try
+ {
+ // convert the text to a wide char string and create a moveable global block
+ std::wstring const wtext = osd::text::to_wstring(text);
+ HGLOBAL const clip = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(wchar_t));
+ if (!clip)
+ return win_error_to_error_condition(GetLastError());
+ LPWSTR const lock = reinterpret_cast<LPWSTR>(GlobalLock(clip));
+ if (!lock)
+ {
+ DWORD const err(GetLastError());
+ GlobalFree(clip);
+ return win_error_to_error_condition(err);
+ }
+
+ // clear current clipboard contents
+ if (!OpenClipboard(nullptr))
+ {
+ DWORD const err(GetLastError());
+ GlobalUnlock(clip);
+ GlobalFree(clip);
+ return win_error_to_error_condition(err);
+ }
+ if (!OpenClipboard(nullptr))
+ {
+ DWORD const err(GetLastError());
+ CloseClipboard();
+ GlobalUnlock(clip);
+ GlobalFree(clip);
+ return win_error_to_error_condition(err);
+ }
+
+ // copy the text (plus NUL terminator) to the moveable block and put it on the clipboard
+ std::copy_n(wtext.c_str(), wtext.length() + 1, lock);
+ GlobalUnlock(clip);
+ if (!SetClipboardData(CF_UNICODETEXT, clip))
+ {
+ DWORD const err(GetLastError());
+ CloseClipboard();
+ GlobalFree(clip);
+ return win_error_to_error_condition(err);
+ }
+
+ // clean up
+ if (!CloseClipboard())
+ return win_error_to_error_condition(GetLastError());
+ return std::error_condition();
+ }
+ catch (std::bad_alloc const &)
+ {
+ return std::errc::not_enough_memory;
+ }
+}
+
+//============================================================
// osd_getpid
//============================================================
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index 9adf9f2e604..09254f32042 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -17,6 +17,7 @@
#include "modules/netdev/netdev_module.h"
#include "modules/midi/midi_module.h"
#include "modules/monitor/monitor_module.h"
+#include "osdnet.h"
#include "watchdog.h"
#include "emu.h"
@@ -31,7 +32,7 @@ const options_entry osd_options::s_option_entries[] =
#if defined(SDLMAME_MACOSX) || defined(OSD_MAC)
{ OSDOPTION_UIMODEKEY, "DEL", core_options::option_type::STRING, "key to enable/disable MAME controls when emulated system has keyboard inputs" },
#else
- { OSDOPTION_UIMODEKEY, "SCRLOCK", core_options::option_type::STRING, "key to enable/disable MAME controls when emulated system has keyboard inputs" },
+ { OSDOPTION_UIMODEKEY, "auto", core_options::option_type::STRING, "key to enable/disable MAME controls when emulated system has keyboard inputs" },
#endif // SDLMAME_MACOSX
{ nullptr, nullptr, core_options::option_type::HEADER, "OSD FONT OPTIONS" },
diff --git a/src/osd/modules/midi/portmidi.cpp b/src/osd/modules/midi/portmidi.cpp
index 9cb5ddac39b..73d965d854a 100644
--- a/src/osd/modules/midi/portmidi.cpp
+++ b/src/osd/modules/midi/portmidi.cpp
@@ -2,7 +2,7 @@
// copyright-holders:R. Belmont
/***************************************************************************
- portmap.c
+ portmidi.cpp
Midi implementation based on portmidi library
@@ -11,9 +11,10 @@
#ifndef NO_USE_MIDI
#include <portmidi.h>
-#include "osdcore.h"
#include "modules/osdmodule.h"
#include "midi_module.h"
+#include <cstdio>
+#include <cstring>
class pm_module : public osd_module, public midi_module
{
diff --git a/src/osd/modules/netdev/pcap.cpp b/src/osd/modules/netdev/pcap.cpp
index 2ae32df0f3b..3ff82484b28 100644
--- a/src/osd/modules/netdev/pcap.cpp
+++ b/src/osd/modules/netdev/pcap.cpp
@@ -4,6 +4,7 @@
#if defined(OSD_NET_USE_PCAP)
#include "emu.h"
+#include "dinetwork.h"
#include "osdnet.h"
#include "netdev_module.h"
#include "modules/osdmodule.h"
diff --git a/src/osd/modules/netdev/taptun.cpp b/src/osd/modules/netdev/taptun.cpp
index c0d99ec750c..10ca76fb2d0 100644
--- a/src/osd/modules/netdev/taptun.cpp
+++ b/src/osd/modules/netdev/taptun.cpp
@@ -14,6 +14,7 @@
#endif
#include "emu.h"
+#include "dinetwork.h"
#include "osdnet.h"
#include "modules/osdmodule.h"
#include "netdev_module.h"
diff --git a/src/osd/modules/render/bgfx/statereader.cpp b/src/osd/modules/render/bgfx/statereader.cpp
index acaeddd35b5..bd7923f1c5e 100644
--- a/src/osd/modules/render/bgfx/statereader.cpp
+++ b/src/osd/modules/render/bgfx/statereader.cpp
@@ -11,6 +11,7 @@
#include "osdcore.h"
+#include <cstdarg>
#include <cmath>
bool state_reader::READER_CHECK(bool condition, const char* format, ...)