summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/debugimgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/debugger/debugimgui.cpp')
-rw-r--r--src/osd/modules/debugger/debugimgui.cpp682
1 files changed, 395 insertions, 287 deletions
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp
index 39dcb3310cf..e027cb5339c 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,30 +16,37 @@
#include "debug/dvwpoints.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
+#include "debugger.h"
+#include "render.h"
+#include "ui/uimain.h"
+#include "uiinput.h"
+
+#include "formats/flopimg.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 osd {
+
+namespace {
class debug_area
{
DISABLE_COPYING(debug_area);
public:
- debug_area(running_machine &machine, debug_view_type type)
- : next(nullptr),
- type(0),
- ofs_x(0),
- ofs_y(0),
- is_collapsed(false),
- exec_cmd(false),
- scroll_end(false),
- scroll_follow(false)
- {
+ debug_area(running_machine &machine, debug_view_type type) :
+ next(nullptr),
+ type(0),
+ ofs_x(0),
+ ofs_y(0),
+ is_collapsed(false),
+ exec_cmd(false),
+ scroll_end(false),
+ scroll_follow(false)
+ {
this->view = machine.debug_view().alloc_view(type, nullptr, this);
this->type = type;
this->m_machine = &machine;
@@ -55,7 +64,7 @@ public:
default:
break;
}
- }
+ }
~debug_area()
{
//this->target->debug_free(*this->container);
@@ -64,7 +73,7 @@ public:
running_machine &machine() const { assert(m_machine != nullptr); return *m_machine; }
- debug_area * next;
+ debug_area * next;
int type;
debug_view * view;
@@ -91,9 +100,11 @@ public:
class debug_imgui : public osd_module, public debug_module
{
public:
- debug_imgui()
- : osd_module(OSD_DEBUG_PROVIDER, "imgui"), debug_module(),
+ debug_imgui() :
+ osd_module(OSD_DEBUG_PROVIDER, "imgui"), debug_module(),
m_machine(nullptr),
+ m_take_ui(false),
+ m_current_pointer(-1),
m_mouse_x(0),
m_mouse_y(0),
m_mouse_button(false),
@@ -118,7 +129,7 @@ public:
virtual ~debug_imgui() { }
- virtual int init(const osd_options &options) override { return 0; }
+ virtual int init(osd_interface &osd, const osd_options &options) override { return 0; }
virtual void exit() override {};
virtual void init_debugger(running_machine &machine) override;
@@ -142,14 +153,13 @@ private:
struct image_type_entry
{
- floppy_image_format_t* format;
+ const floppy_image_format_t* format;
std::string shortname;
std::string longname;
};
- void handle_mouse();
+ void handle_events();
void handle_mouse_views();
- void handle_keys();
void handle_keys_views();
void handle_console(running_machine* machine);
void update();
@@ -172,19 +182,21 @@ private:
void refresh_filelist();
void refresh_typelist();
void update_cpu_view(device_t* device);
- static bool get_view_source(void* data, int idx, const char** out_text);
+ static const char* get_view_source(void* data, int idx);
static int history_set(ImGuiInputTextCallbackData* data);
running_machine* m_machine;
- int32_t m_mouse_x;
- int32_t m_mouse_y;
+ bool m_take_ui;
+ int32_t m_current_pointer;
+ int32_t m_mouse_x;
+ int32_t m_mouse_y;
bool m_mouse_button;
bool m_prev_mouse_button;
bool m_running;
const char* font_name;
float font_size;
ImVec2 m_text_size; // size of character (assumes monospaced font is in use)
- uint8_t m_key_char;
+ uint8_t m_key_char;
bool m_hide;
int m_win_count; // number of active windows, does not decrease, used to ID individual windows
bool m_has_images; // true if current system has any image devices
@@ -199,6 +211,7 @@ private:
file_entry* m_selected_file;
int m_format_sel;
char m_path[1024]; // path text field buffer
+ std::unordered_map<input_item_id,ImGuiKey> m_mapping;
};
// globals
@@ -225,11 +238,7 @@ static void view_list_remove(debug_area* item)
static debug_area *dview_alloc(running_machine &machine, debug_view_type type)
{
- debug_area *dv;
-
- dv = global_alloc(debug_area(machine, type));
-
- return dv;
+ return new debug_area(machine, type);
}
static inline void map_attr_to_fg_bg(unsigned char attr, rgb_t *fg, rgb_t *bg)
@@ -259,107 +268,92 @@ static inline void map_attr_to_fg_bg(unsigned char attr, rgb_t *fg, rgb_t *bg)
}
}
-bool debug_imgui::get_view_source(void* data, int idx, const char** out_text)
-{
- debug_view* vw = static_cast<debug_view*>(data);
- *out_text = vw->source_list().find(idx)->name();
- return true;
-}
-
-void debug_imgui::handle_mouse()
+const char* debug_imgui::get_view_source(void* data, int idx)
{
- m_prev_mouse_button = m_mouse_button;
- m_machine->ui_input().find_mouse(&m_mouse_x, &m_mouse_y, &m_mouse_button);
+ auto* vw = static_cast<debug_view*>(data);
+ return vw->source(idx)->name();
}
-void debug_imgui::handle_mouse_views()
-{
- rectangle rect;
- bool clicked = false;
- if(m_mouse_button == true && m_prev_mouse_button == false)
- clicked = true;
-
- // check all views, and pass mouse clicks to them
- if(!m_mouse_button)
- return;
- rect.min_x = view_main_disasm->ofs_x;
- rect.min_y = view_main_disasm->ofs_y;
- rect.max_x = view_main_disasm->ofs_x + view_main_disasm->view_width;
- rect.max_y = view_main_disasm->ofs_y + view_main_disasm->view_height;
- if(rect.contains(m_mouse_x,m_mouse_y) && clicked && view_main_disasm->has_focus)
- {
- debug_view_xy topleft = view_main_disasm->view->visible_position();
- debug_view_xy newpos;
- newpos.x = topleft.x + (m_mouse_x-view_main_disasm->ofs_x) / m_text_size.x;
- newpos.y = topleft.y + (m_mouse_y-view_main_disasm->ofs_y) / m_text_size.y;
- view_main_disasm->view->set_cursor_position(newpos);
- view_main_disasm->view->set_cursor_visible(true);
- }
- for(std::vector<debug_area*>::iterator it = view_list.begin();it != view_list.end();++it)
- {
- rect.min_x = (*it)->ofs_x;
- rect.min_y = (*it)->ofs_y;
- rect.max_x = (*it)->ofs_x + (*it)->view_width;
- rect.max_y = (*it)->ofs_y + (*it)->view_height;
- if(rect.contains(m_mouse_x,m_mouse_y) && clicked && (*it)->has_focus)
- {
- if((*it)->view->cursor_supported())
- {
- debug_view_xy topleft = (*it)->view->visible_position();
- debug_view_xy newpos;
- newpos.x = topleft.x + (m_mouse_x-(*it)->ofs_x) / m_text_size.x;
- newpos.y = topleft.y + (m_mouse_y-(*it)->ofs_y) / m_text_size.y;
- (*it)->view->set_cursor_position(newpos);
- (*it)->view->set_cursor_visible(true);
- }
- }
- }
-}
-
-void debug_imgui::handle_keys()
+void debug_imgui::handle_events()
{
ImGuiIO& io = ImGui::GetIO();
- ui_event event;
- debug_area* focus_view = nullptr;
// find view that has focus (should only be one at a time)
- for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
+ debug_area* focus_view = nullptr;
+ for(auto view_ptr = view_list.begin();view_ptr != view_list.end(); ++view_ptr)
if((*view_ptr)->has_focus)
focus_view = *view_ptr;
// check views in main views also (only the disassembler view accepts inputs)
- if(view_main_disasm->has_focus)
- focus_view = view_main_disasm;
+ if(view_main_disasm)
+ if(view_main_disasm->has_focus)
+ focus_view = view_main_disasm;
- if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
- io.KeyCtrl = true;
- else
- io.KeyCtrl = false;
- if(m_machine->input().code_pressed(KEYCODE_LSHIFT))
- io.KeyShift = true;
- else
- io.KeyShift = false;
- if(m_machine->input().code_pressed(KEYCODE_LALT))
- io.KeyAlt = true;
- else
- io.KeyAlt = false;
+ io.KeyCtrl = m_machine->input().code_pressed(KEYCODE_LCONTROL);
+ io.KeyShift = m_machine->input().code_pressed(KEYCODE_LSHIFT);
+ io.KeyAlt = m_machine->input().code_pressed(KEYCODE_LALT);
for(input_item_id id = ITEM_ID_A; id <= ITEM_ID_CANCEL; ++id)
{
if(m_machine->input().code_pressed(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
- io.KeysDown[id] = true;
+ {
+ if(m_mapping.count(id))
+ io.AddKeyEvent(m_mapping[id], true);
+ }
else
- io.KeysDown[id] = false;
+ {
+ if(m_mapping.count(id))
+ io.AddKeyEvent(m_mapping[id], false);
+ }
}
+ m_prev_mouse_button = m_mouse_button;
m_key_char = 0;
- while (m_machine->ui_input().pop_event(&event))
+ ui_event event;
+ while(m_machine->ui_input().pop_event(&event))
{
switch (event.event_type)
{
- case ui_event::IME_CHAR:
- m_key_char = event.ch;
- if(focus_view != nullptr)
+ case ui_event::type::POINTER_UPDATE:
+ if(&m_machine->render().ui_target() != event.target)
+ break;
+ if(event.pointer_id != m_current_pointer)
+ {
+ if((0 > m_current_pointer) || ((event.pointer_pressed & 1) && !m_mouse_button))
+ m_current_pointer = event.pointer_id;
+ }
+ if(event.pointer_id == m_current_pointer)
+ {
+ bool changed = (m_mouse_x != event.pointer_x) || (m_mouse_y != event.pointer_y) || (m_mouse_button != bool(event.pointer_buttons & 1));
+ m_mouse_x = event.pointer_x;
+ m_mouse_y = event.pointer_y;
+ m_mouse_button = bool(event.pointer_buttons & 1);
+ if(changed)
+ {
+ io.MousePos = ImVec2(m_mouse_x,m_mouse_y);
+ io.MouseDown[0] = m_mouse_button;
+ }
+ }
+ break;
+ case ui_event::type::POINTER_LEAVE:
+ case ui_event::type::POINTER_ABORT:
+ if((&m_machine->render().ui_target() == event.target) && (event.pointer_id == m_current_pointer))
+ {
+ m_current_pointer = -1;
+ bool changed = (m_mouse_x != event.pointer_x) || (m_mouse_y != event.pointer_y) || m_mouse_button;
+ m_mouse_x = event.pointer_x;
+ m_mouse_y = event.pointer_y;
+ m_mouse_button = false;
+ if(changed)
+ {
+ io.MousePos = ImVec2(m_mouse_x,m_mouse_y);
+ io.MouseDown[0] = m_mouse_button;
+ }
+ }
+ break;
+ case ui_event::type::IME_CHAR:
+ m_key_char = event.ch; // FIXME: assigning 4-byte UCS4 character to 8-bit variable
+ if(focus_view)
focus_view->view->process_char(m_key_char);
return;
default:
@@ -368,108 +362,153 @@ void debug_imgui::handle_keys()
}
// global keys
- if(ImGui::IsKeyPressed(ITEM_ID_F3,false))
+ if(ImGui::IsKeyPressed(ImGuiKey_F3,false))
{
- if(ImGui::IsKeyDown(ITEM_ID_LSHIFT))
+ if(ImGui::IsKeyDown(ImGuiKey_LeftShift))
m_machine->schedule_hard_reset();
else
{
m_machine->schedule_soft_reset();
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
}
}
- if(ImGui::IsKeyPressed(ITEM_ID_F5,false))
+ if(ImGui::IsKeyPressed(ImGuiKey_F5,false))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
m_running = true;
}
- if(ImGui::IsKeyPressed(ITEM_ID_F6,false))
+ if(ImGui::IsKeyPressed(ImGuiKey_F6,false))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_next_device();
m_running = true;
}
- if(ImGui::IsKeyPressed(ITEM_ID_F7,false))
+ if(ImGui::IsKeyPressed(ImGuiKey_F7,false))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_interrupt();
m_running = true;
}
- if(ImGui::IsKeyPressed(ITEM_ID_F8,false))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
- if(ImGui::IsKeyPressed(ITEM_ID_F9,false))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
- if(ImGui::IsKeyPressed(ITEM_ID_F10,false))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
- if(ImGui::IsKeyPressed(ITEM_ID_F11,false))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
- if(ImGui::IsKeyPressed(ITEM_ID_F12,false))
+ if(ImGui::IsKeyPressed(ImGuiKey_F8,false))
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_vblank();
+ if(ImGui::IsKeyPressed(ImGuiKey_F9,false))
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step_out();
+ if(ImGui::IsKeyPressed(ImGuiKey_F10,false))
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step_over();
+ if(ImGui::IsKeyPressed(ImGuiKey_F11,false))
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
+ if(ImGui::IsKeyPressed(ImGuiKey_F12,false))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
m_hide = true;
}
- if(ImGui::IsKeyPressed(ITEM_ID_D,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ImGuiKey_D,false) && io.KeyCtrl)
add_disasm(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_M,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ImGuiKey_M,false) && io.KeyCtrl)
add_memory(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_B,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ImGuiKey_B,false) && io.KeyCtrl)
add_bpoints(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_W,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ImGuiKey_W,false) && io.KeyCtrl)
add_wpoints(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_L,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ImGuiKey_L,false) && io.KeyCtrl)
add_log(++m_win_count);
}
+void debug_imgui::handle_mouse_views()
+{
+ rectangle rect;
+ bool clicked = false;
+ if(m_mouse_button == true && m_prev_mouse_button == false)
+ clicked = true;
+
+ // check all views, and pass mouse clicks to them
+ if(!m_mouse_button)
+ return;
+ rect.min_x = view_main_disasm->ofs_x;
+ rect.min_y = view_main_disasm->ofs_y;
+ rect.max_x = view_main_disasm->ofs_x + view_main_disasm->view_width;
+ rect.max_y = view_main_disasm->ofs_y + view_main_disasm->view_height;
+ if(rect.contains(m_mouse_x,m_mouse_y) && clicked && view_main_disasm->has_focus)
+ {
+ debug_view_xy topleft = view_main_disasm->view->visible_position();
+ debug_view_xy newpos;
+ newpos.x = topleft.x + (m_mouse_x-view_main_disasm->ofs_x) / m_text_size.x;
+ newpos.y = topleft.y + (m_mouse_y-view_main_disasm->ofs_y) / m_text_size.y;
+ view_main_disasm->view->set_cursor_position(newpos);
+ view_main_disasm->view->set_cursor_visible(true);
+ }
+ for(auto it = view_list.begin();it != view_list.end();++it)
+ {
+ rect.min_x = (*it)->ofs_x;
+ rect.min_y = (*it)->ofs_y;
+ rect.max_x = (*it)->ofs_x + (*it)->view_width;
+ rect.max_y = (*it)->ofs_y + (*it)->view_height;
+ if(rect.contains(m_mouse_x,m_mouse_y) && clicked && (*it)->has_focus)
+ {
+ if((*it)->view->cursor_supported())
+ {
+ debug_view_xy topleft = (*it)->view->visible_position();
+ debug_view_xy newpos;
+ newpos.x = topleft.x + (m_mouse_x-(*it)->ofs_x) / m_text_size.x;
+ newpos.y = topleft.y + (m_mouse_y-(*it)->ofs_y) / m_text_size.y;
+ (*it)->view->set_cursor_position(newpos);
+ (*it)->view->set_cursor_visible(true);
+ }
+ }
+ }
+}
+
void debug_imgui::handle_keys_views()
{
debug_area* focus_view = nullptr;
// find view that has focus (should only be one at a time)
- for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
+ for(auto view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
if((*view_ptr)->has_focus)
focus_view = *view_ptr;
// check views in main views also (only the disassembler view accepts inputs)
- if(view_main_disasm->has_focus)
- focus_view = view_main_disasm;
+ if(view_main_disasm != nullptr)
+ if(view_main_disasm->has_focus)
+ focus_view = view_main_disasm;
// if no view has focus, then there's nothing to do
if(focus_view == nullptr)
return;
// pass keypresses to debug view with focus
- if(ImGui::IsKeyPressed(ITEM_ID_UP))
+ if(ImGui::IsKeyPressed(ImGuiKey_UpArrow))
focus_view->view->process_char(DCH_UP);
- if(ImGui::IsKeyPressed(ITEM_ID_DOWN))
+ if(ImGui::IsKeyPressed(ImGuiKey_DownArrow))
focus_view->view->process_char(DCH_DOWN);
- if(ImGui::IsKeyPressed(ITEM_ID_LEFT))
+ if(ImGui::IsKeyPressed(ImGuiKey_LeftArrow))
{
- if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
focus_view->view->process_char(DCH_CTRLLEFT);
else
focus_view->view->process_char(DCH_LEFT);
}
- if(ImGui::IsKeyPressed(ITEM_ID_RIGHT))
+ if(ImGui::IsKeyPressed(ImGuiKey_RightArrow))
{
- if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
focus_view->view->process_char(DCH_CTRLRIGHT);
else
focus_view->view->process_char(DCH_RIGHT);
}
- if(ImGui::IsKeyPressed(ITEM_ID_PGUP))
+ if(ImGui::IsKeyPressed(ImGuiKey_PageUp))
focus_view->view->process_char(DCH_PUP);
- if(ImGui::IsKeyPressed(ITEM_ID_PGDN))
+ if(ImGui::IsKeyPressed(ImGuiKey_PageDown))
focus_view->view->process_char(DCH_PDOWN);
- if(ImGui::IsKeyPressed(ITEM_ID_HOME))
+ if(ImGui::IsKeyPressed(ImGuiKey_Home))
{
- if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
focus_view->view->process_char(DCH_CTRLHOME);
else
focus_view->view->process_char(DCH_HOME);
}
- if(ImGui::IsKeyPressed(ITEM_ID_END))
+ if(ImGui::IsKeyPressed(ImGuiKey_End))
{
- if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
focus_view->view->process_char(DCH_CTRLEND);
else
focus_view->view->process_char(DCH_END);
@@ -484,7 +523,7 @@ void debug_imgui::handle_console(running_machine* machine)
// if console input is empty, then do a single step
if(strlen(view_main_console->console_input) == 0)
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
view_main_console->exec_cmd = false;
history_pos = view_main_console->console_history.size();
return;
@@ -522,7 +561,7 @@ void debug_imgui::handle_console(running_machine* machine)
// don't bother adding to history if the current command matches the previous one
if(view_main_console->console_prev != view_main_console->console_input)
{
- view_main_console->console_history.push_back(std::string(view_main_console->console_input));
+ view_main_console->console_history.emplace_back(std::string(view_main_console->console_input));
view_main_console->console_prev = view_main_console->console_input;
}
history_pos = view_main_console->console_history.size();
@@ -546,6 +585,8 @@ int debug_imgui::history_set(ImGuiInputTextCallbackData* data)
if(history_pos < view_main_console->console_history.size())
history_pos++;
break;
+ default:
+ break;
}
if(history_pos == view_main_console->console_history.size())
@@ -605,7 +646,10 @@ void debug_imgui::draw_view(debug_area* view_ptr, bool exp_change)
// temporarily set cursor to the last line, this will set the scroll bar range
if(view_ptr->type != DVT_MEMORY) // no scroll bars in memory views
+ {
ImGui::SetCursorPosY((totalsize.y) * fsize.y);
+ ImGui::Dummy(ImVec2(0,0)); // some object is required for validation
+ }
// set the visible area to be displayed
vsize.x = view_ptr->view_width / fsize.x;
@@ -754,13 +798,9 @@ void debug_imgui::add_log(int id)
void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
{
- const debug_view_source* src;
-
ImGui::SetNextWindowSize(ImVec2(view_ptr->width,view_ptr->height + ImGui::GetTextLineHeight()),ImGuiCond_Once);
if(ImGui::Begin(view_ptr->title.c_str(),opened,ImGuiWindowFlags_MenuBar))
{
- int idx;
- bool done = false;
bool exp_change = false;
view_ptr->is_collapsed = false;
@@ -768,7 +808,7 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
{
if(ImGui::BeginMenu("Options"))
{
- debug_view_disasm* disasm = downcast<debug_view_disasm*>(view_ptr->view);
+ auto* disasm = downcast<debug_view_disasm*>(view_ptr->view);
int rightcol = disasm->right_column();
if(ImGui::MenuItem("Raw opcodes", nullptr,(rightcol == DASM_RIGHTCOL_RAW) ? true : false))
@@ -788,7 +828,7 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll;
if(m_running)
flags |= ImGuiInputTextFlags_ReadOnly;
- ImGui::Combo("##cpu",&view_ptr->src_sel,get_view_source,view_ptr->view,view_ptr->view->source_list().count());
+ ImGui::Combo("##cpu",&view_ptr->src_sel,get_view_source,view_ptr->view,view_ptr->view->source_count());
ImGui::SameLine();
ImGui::PushItemWidth(-1.0f);
if(ImGui::InputText("##addr",view_ptr->console_input,512,flags))
@@ -800,17 +840,15 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
ImGui::Separator();
// disassembly portion
- src = view_ptr->view->first_source();
- idx = 0;
- while (!done)
+ unsigned idx = 0;
+ const debug_view_source* src = view_ptr->view->source(idx);
+ do
{
if(view_ptr->src_sel == idx)
view_ptr->view->set_source(*src);
- idx++;
- src = src->next();
- if(src == nullptr)
- done = true;
+ src = view_ptr->view->source(++idx);
}
+ while (src);
ImGui::BeginChild("##disasm_output", ImVec2(ImGui::GetWindowWidth() - 16,ImGui::GetWindowHeight() - ImGui::GetTextLineHeight() - ImGui::GetCursorPosY())); // account for title bar and widgets already drawn
draw_view(view_ptr,exp_change);
@@ -841,13 +879,9 @@ void debug_imgui::add_disasm(int id)
void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened)
{
- const debug_view_source* src;
-
ImGui::SetNextWindowSize(ImVec2(view_ptr->width,view_ptr->height + ImGui::GetTextLineHeight()),ImGuiCond_Once);
if(ImGui::Begin(view_ptr->title.c_str(),opened,ImGuiWindowFlags_MenuBar))
{
- int idx;
- bool done = false;
bool exp_change = false;
view_ptr->is_collapsed = false;
@@ -855,26 +889,42 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened)
{
if(ImGui::BeginMenu("Options"))
{
- debug_view_memory* mem = downcast<debug_view_memory*>(view_ptr->view);
+ auto* mem = downcast<debug_view_memory*>(view_ptr->view);
bool physical = mem->physical();
bool rev = mem->reverse();
- int format = mem->get_data_format();
+ debug_view_memory::data_format format = mem->get_data_format();
uint32_t chunks = mem->chunks_per_row();
-
- if(ImGui::MenuItem("1-byte chunks", nullptr,(format == 1) ? true : false))
- mem->set_data_format(1);
- if(ImGui::MenuItem("2-byte chunks", nullptr,(format == 2) ? true : false))
- mem->set_data_format(2);
- if(ImGui::MenuItem("4-byte chunks", nullptr,(format == 4) ? true : false))
- mem->set_data_format(4);
- if(ImGui::MenuItem("8-byte chunks", nullptr,(format == 8) ? true : false))
- mem->set_data_format(8);
- if(ImGui::MenuItem("32-bit floating point", nullptr,(format == 9) ? true : false))
- mem->set_data_format(9);
- if(ImGui::MenuItem("64-bit floating point", nullptr,(format == 10) ? true : false))
- mem->set_data_format(10);
- if(ImGui::MenuItem("80-bit floating point", nullptr,(format == 11) ? true : false))
- mem->set_data_format(11);
+ int radix = mem->address_radix();
+
+ if(ImGui::MenuItem("1-byte hexadecimal", nullptr,(format == debug_view_memory::data_format::HEX_8BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::HEX_8BIT);
+ if(ImGui::MenuItem("2-byte hexadecimal", nullptr,(format == debug_view_memory::data_format::HEX_16BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::HEX_16BIT);
+ if(ImGui::MenuItem("4-byte hexadecimal", nullptr,(format == debug_view_memory::data_format::HEX_32BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::HEX_32BIT);
+ if(ImGui::MenuItem("8-byte hexadecimal", nullptr,(format == debug_view_memory::data_format::HEX_64BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::HEX_64BIT);
+ if(ImGui::MenuItem("1-byte octal", nullptr,(format == debug_view_memory::data_format::OCTAL_8BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::OCTAL_8BIT);
+ if(ImGui::MenuItem("2-byte octal", nullptr,(format == debug_view_memory::data_format::OCTAL_16BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::OCTAL_16BIT);
+ if(ImGui::MenuItem("4-byte octal", nullptr,(format == debug_view_memory::data_format::OCTAL_32BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::OCTAL_32BIT);
+ if(ImGui::MenuItem("8-byte octal", nullptr,(format == debug_view_memory::data_format::OCTAL_64BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::OCTAL_64BIT);
+ if(ImGui::MenuItem("32-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_32BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::FLOAT_32BIT);
+ if(ImGui::MenuItem("64-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_64BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::FLOAT_64BIT);
+ if(ImGui::MenuItem("80-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_80BIT) ? true : false))
+ mem->set_data_format(debug_view_memory::data_format::FLOAT_80BIT);
+ ImGui::Separator();
+ if(ImGui::MenuItem("Hexadecimal Addresses", nullptr,(radix == 16)))
+ mem->set_address_radix(16);
+ if(ImGui::MenuItem("Decimal Addresses", nullptr,(radix == 10)))
+ mem->set_address_radix(10);
+ if(ImGui::MenuItem("Octal Addresses", nullptr,(radix == 8)))
+ mem->set_address_radix(8);
ImGui::Separator();
if(ImGui::MenuItem("Logical addresses", nullptr,!physical))
mem->set_physical(false);
@@ -906,22 +956,20 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened)
ImGui::PopItemWidth();
ImGui::SameLine();
ImGui::PushItemWidth(-1.0f);
- ImGui::Combo("##region",&view_ptr->src_sel,get_view_source,view_ptr->view,view_ptr->view->source_list().count());
+ ImGui::Combo("##region",&view_ptr->src_sel,get_view_source,view_ptr->view,view_ptr->view->source_count());
ImGui::PopItemWidth();
ImGui::Separator();
// memory editor portion
- src = view_ptr->view->first_source();
- idx = 0;
- while (!done)
+ unsigned idx = 0;
+ const debug_view_source* src = view_ptr->view->source(idx);
+ do
{
if(view_ptr->src_sel == idx)
view_ptr->view->set_source(*src);
- idx++;
- src = src->next();
- if(src == nullptr)
- done = true;
+ src = view_ptr->view->source(++idx);
}
+ while (src);
ImGui::BeginChild("##memory_output", ImVec2(ImGui::GetWindowWidth() - 16,ImGui::GetWindowHeight() - ImGui::GetTextLineHeight() - ImGui::GetCursorPosY())); // account for title bar and widgets already drawn
draw_view(view_ptr,exp_change);
@@ -954,24 +1002,25 @@ void debug_imgui::mount_image()
{
if(m_selected_file != nullptr)
{
- osd_file::error err;
+ std::error_condition err;
switch(m_selected_file->type)
{
case file_entry_type::DRIVE:
case file_entry_type::DIRECTORY:
{
util::zippath_directory::ptr dir;
- err = util::zippath_directory::open(m_selected_file->fullpath.c_str(), dir);
+ err = util::zippath_directory::open(m_selected_file->fullpath, dir);
}
- if(err == osd_file::error::NONE)
+ if(!err)
{
m_filelist_refresh = true;
strcpy(m_path,m_selected_file->fullpath.c_str());
}
break;
case file_entry_type::FILE:
- m_dialog_image->load(m_selected_file->fullpath.c_str());
+ m_dialog_image->load(m_selected_file->fullpath);
ImGui::CloseCurrentPopup();
+ m_mount_open = false;
break;
}
}
@@ -979,18 +1028,18 @@ void debug_imgui::mount_image()
void debug_imgui::create_image()
{
- image_init_result res;
+ std::pair<std::error_condition, std::string> res;
- if(m_dialog_image->image_type() == IO_FLOPPY)
+ auto *fd = dynamic_cast<floppy_image_device *>(m_dialog_image);
+ if(fd != nullptr)
{
- floppy_image_device *fd = static_cast<floppy_image_device *>(m_dialog_image);
res = fd->create(m_path,nullptr,nullptr);
- if(res == image_init_result::PASS)
+ if(!res.first)
fd->setup_write(m_typelist.at(m_format_sel).format);
}
else
res = m_dialog_image->create(m_path,nullptr,nullptr);
- if(res == image_init_result::PASS)
+ if(!res.first)
ImGui::CloseCurrentPopup();
// TODO: add a messagebox to display on an error
}
@@ -1004,32 +1053,29 @@ void debug_imgui::refresh_filelist()
m_filelist_refresh = false;
util::zippath_directory::ptr dir;
- osd_file::error const err = util::zippath_directory::open(m_path,dir);
- if(err == osd_file::error::NONE)
+ std::error_condition const err = util::zippath_directory::open(m_path,dir);
+ if(!err)
{
- int x = 0;
// add drives
- const char *volume_name;
- while((volume_name = osd_get_volume_name(x))!=nullptr)
+ for(std::string const &volume_name : osd_get_volume_names())
{
file_entry temp;
temp.type = file_entry_type::DRIVE;
- temp.basename = std::string(volume_name);
- temp.fullpath = std::string(volume_name);
+ 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;
+ const directory::entry *dirent;
while((dirent = dir->readdir()) != nullptr)
{
file_entry temp;
switch(dirent->type)
{
- case osd::directory::entry::entry_type::FILE:
+ case directory::entry::entry_type::FILE:
temp.type = file_entry_type::FILE;
break;
- case osd::directory::entry::entry_type::DIR:
+ case directory::entry::entry_type::DIR:
temp.type = file_entry_type::DIRECTORY;
break;
default:
@@ -1048,7 +1094,7 @@ void debug_imgui::refresh_filelist()
void debug_imgui::refresh_typelist()
{
- floppy_image_device *fd = static_cast<floppy_image_device *>(m_dialog_image);
+ auto *fd = static_cast<floppy_image_device *>(m_dialog_image);
m_typelist.clear();
if(m_dialog_image->formatlist().empty())
@@ -1056,8 +1102,7 @@ void debug_imgui::refresh_typelist()
if(fd == nullptr)
return;
- floppy_image_format_t* format_list = fd->get_formats();
- for(floppy_image_format_t* flist = format_list; flist; flist = flist->next)
+ for(const floppy_image_format_t* flist : fd->get_formats())
{
if(flist->supports_save())
{
@@ -1075,7 +1120,7 @@ void debug_imgui::draw_images_menu()
if(ImGui::BeginMenu("Images"))
{
int x = 0;
- for (device_image_interface &img : image_interface_iterator(m_machine->root_device()))
+ for (device_image_interface &img : image_interface_enumerator(m_machine->root_device()))
{
x++;
std::string str = string_format(" %s : %s##%i",img.device().name(),img.exists() ? img.filename() : "[Empty slot]",x);
@@ -1118,16 +1163,21 @@ void debug_imgui::draw_mount_dialog(const char* label)
{
// render dialog
//ImGui::SetNextWindowContentWidth(200.0f);
- if(ImGui::BeginPopupModal(label,NULL,ImGuiWindowFlags_AlwaysAutoResize))
+ if(ImGui::BeginPopupModal(label,nullptr,ImGuiWindowFlags_AlwaysAutoResize))
{
if(m_filelist_refresh)
refresh_filelist();
if(ImGui::InputText("##mountpath",m_path,1024,ImGuiInputTextFlags_EnterReturnsTrue))
m_filelist_refresh = true;
ImGui::Separator();
+
+ ImVec2 listbox_size;
+ listbox_size.x = 0.0f;
+ listbox_size.y = ImGui::GetTextLineHeightWithSpacing() * 15.25f;
+
+ if(ImGui::BeginListBox("##filelist",listbox_size))
{
- ImGui::ListBoxHeader("##filelist",m_filelist.size(),15);
- for(std::vector<file_entry>::iterator f = m_filelist.begin();f != m_filelist.end();++f)
+ for(auto f = m_filelist.begin();f != m_filelist.end();++f)
{
std::string txt_name;
bool sel = false;
@@ -1150,14 +1200,19 @@ void debug_imgui::draw_mount_dialog(const char* label)
{
m_selected_file = &(*f);
if(ImGui::IsMouseDoubleClicked(0))
+ {
mount_image();
+ }
}
}
- ImGui::ListBoxFooter();
+ ImGui::EndListBox();
}
ImGui::Separator();
if(ImGui::Button("Cancel##mount"))
+ {
ImGui::CloseCurrentPopup();
+ m_mount_open = false;
+ }
ImGui::SameLine();
if(ImGui::Button("OK##mount"))
mount_image();
@@ -1169,27 +1224,28 @@ void debug_imgui::draw_create_dialog(const char* label)
{
// render dialog
//ImGui::SetNextWindowContentWidth(200.0f);
- if(ImGui::BeginPopupModal(label,NULL,ImGuiWindowFlags_AlwaysAutoResize))
+ if(ImGui::BeginPopupModal(label,nullptr,ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::LabelText("##static1","Filename:");
ImGui::SameLine();
if(ImGui::InputText("##createfilename",m_path,1024,ImGuiInputTextFlags_EnterReturnsTrue))
{
auto entry = osd_stat(m_path);
- auto file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
- if(file_type == osd::directory::entry::entry_type::NONE)
+ auto file_type = (entry != nullptr) ? entry->type : directory::entry::entry_type::NONE;
+ if(file_type == directory::entry::entry_type::NONE)
create_image();
- if(file_type == osd::directory::entry::entry_type::FILE)
+ if(file_type == directory::entry::entry_type::FILE)
m_create_confirm_wait = true;
// cannot overwrite a directory, so nothing will be none in that case.
}
// format combo box for floppy devices
- if(m_dialog_image->image_type() == IO_FLOPPY)
+ auto *fd = dynamic_cast<floppy_image_device *>(m_dialog_image);
+ if(fd != nullptr)
{
std::string combo_str;
combo_str.clear();
- for(std::vector<image_type_entry>::iterator f = m_typelist.begin();f != m_typelist.end();++f)
+ for(auto f = m_typelist.begin();f != m_typelist.end();++f)
{
// TODO: perhaps do this at the time the format list is generated, rather than every frame
combo_str.append((*f).longname);
@@ -1217,17 +1273,21 @@ void debug_imgui::draw_create_dialog(const char* label)
{
ImGui::Separator();
if(ImGui::Button("Cancel##mount"))
+ {
ImGui::CloseCurrentPopup();
+ m_create_open = false;
+ }
ImGui::SameLine();
if(ImGui::Button("OK##mount"))
{
auto entry = osd_stat(m_path);
- auto file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
- if(file_type == osd::directory::entry::entry_type::NONE)
+ auto file_type = (entry != nullptr) ? entry->type : directory::entry::entry_type::NONE;
+ if(file_type == directory::entry::entry_type::NONE)
create_image();
- if(file_type == osd::directory::entry::entry_type::FILE)
+ if(file_type == directory::entry::entry_type::FILE)
m_create_confirm_wait = true;
// cannot overwrite a directory, so nothing will be none in that case.
+ m_create_open = false;
}
}
ImGui::EndPopup();
@@ -1237,6 +1297,10 @@ void debug_imgui::draw_create_dialog(const char* label)
void debug_imgui::draw_console()
{
ImGuiWindowFlags flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
+ bool show_menu = false;
+
+ if(view_main_disasm == nullptr || view_main_regs == nullptr || view_main_console == nullptr)
+ return;
ImGui::SetNextWindowSize(ImVec2(view_main_regs->width + view_main_disasm->width,view_main_disasm->height + view_main_console->height + ImGui::GetTextLineHeight()*3),ImGuiCond_Once);
if(ImGui::Begin(view_main_console->title.c_str(), nullptr,flags))
@@ -1247,6 +1311,7 @@ void debug_imgui::draw_console()
{
if(ImGui::BeginMenu("Debug"))
{
+ show_menu = true;
if(ImGui::MenuItem("New disassembly window", "Ctrl+D"))
add_disasm(++m_win_count);
if(ImGui::MenuItem("New memory window", "Ctrl+M"))
@@ -1260,46 +1325,47 @@ void debug_imgui::draw_console()
ImGui::Separator();
if(ImGui::MenuItem("Run", "F5"))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
m_running = true;
}
if(ImGui::MenuItem("Go to next CPU", "F6"))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_next_device();
m_running = true;
}
if(ImGui::MenuItem("Run until next interrupt", "F7"))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_interrupt();
m_running = true;
}
if(ImGui::MenuItem("Run until VBLANK", "F8"))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go_vblank();
if(ImGui::MenuItem("Run and hide debugger", "F12"))
{
- m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
m_hide = true;
}
ImGui::Separator();
if(ImGui::MenuItem("Single step", "F11"))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
if(ImGui::MenuItem("Step over", "F10"))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step_over();
if(ImGui::MenuItem("Step out", "F9"))
- m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
+ m_machine->debugger().console().get_visible_cpu()->debug()->single_step_out();
ImGui::EndMenu();
}
if(ImGui::BeginMenu("Window"))
{
+ show_menu = true;
if(ImGui::MenuItem("Show all"))
{
- for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
+ for(auto view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
ImGui::SetWindowCollapsed((*view_ptr)->title.c_str(),false);
}
ImGui::Separator();
// list all extra windows, so we can un-collapse the windows if necessary
- for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
+ for(auto view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
{
bool collapsed = false;
if((*view_ptr)->is_collapsed)
@@ -1310,7 +1376,10 @@ void debug_imgui::draw_console()
ImGui::EndMenu();
}
if(m_has_images)
+ {
+ show_menu = true;
draw_images_menu();
+ }
ImGui::EndMenuBar();
}
@@ -1341,20 +1410,18 @@ void debug_imgui::draw_console()
ImGui::PushItemWidth(-1.0f);
if(ImGui::InputText("##console_input",view_main_console->console_input,512,flags,history_set))
view_main_console->exec_cmd = true;
- if ((ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)))
+ if ((ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0) && !show_menu))
ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
if(m_mount_open)
{
ImGui::OpenPopup("Mount Image");
- m_mount_open = false;
+ draw_mount_dialog("Mount Image"); // draw mount image dialog if open
}
if(m_create_open)
{
ImGui::OpenPopup("Create Image");
- m_create_open = false;
+ draw_create_dialog("Create Image"); // draw create image dialog if open
}
- draw_mount_dialog("Mount Image"); // draw mount image dialog if open
- draw_create_dialog("Create Image"); // draw create image dialog if open
ImGui::PopItemWidth();
ImGui::EndChild();
ImGui::End();
@@ -1367,7 +1434,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));
@@ -1412,13 +1478,12 @@ void debug_imgui::update()
break;
}
++view_ptr;
- count++;
}
// check for a closed window
if(to_delete != nullptr)
{
view_list_remove(to_delete);
- global_free(to_delete);
+ delete to_delete;
}
ImGui::PopStyleColor(12);
@@ -1433,31 +1498,44 @@ void debug_imgui::init_debugger(running_machine &machine)
fatalerror("Error: ImGui debugger requires the BGFX renderer.\n");
// check for any image devices (cassette, floppy, etc...)
- image_interface_iterator iter(m_machine->root_device());
+ image_interface_enumerator iter(m_machine->root_device());
if (iter.first() != nullptr)
m_has_images = true;
// map keys to ImGui inputs
- io.KeyMap[ImGuiKey_A] = ITEM_ID_A;
- io.KeyMap[ImGuiKey_C] = ITEM_ID_C;
- io.KeyMap[ImGuiKey_V] = ITEM_ID_V;
- io.KeyMap[ImGuiKey_X] = ITEM_ID_X;
- io.KeyMap[ImGuiKey_C] = ITEM_ID_C;
- io.KeyMap[ImGuiKey_Y] = ITEM_ID_Y;
- io.KeyMap[ImGuiKey_Z] = ITEM_ID_Z;
- io.KeyMap[ImGuiKey_Backspace] = ITEM_ID_BACKSPACE;
- io.KeyMap[ImGuiKey_Delete] = ITEM_ID_DEL;
- io.KeyMap[ImGuiKey_Tab] = ITEM_ID_TAB;
- io.KeyMap[ImGuiKey_PageUp] = ITEM_ID_PGUP;
- io.KeyMap[ImGuiKey_PageDown] = ITEM_ID_PGDN;
- io.KeyMap[ImGuiKey_Home] = ITEM_ID_HOME;
- io.KeyMap[ImGuiKey_End] = ITEM_ID_END;
- io.KeyMap[ImGuiKey_Escape] = ITEM_ID_ESC;
- io.KeyMap[ImGuiKey_Enter] = ITEM_ID_ENTER;
- io.KeyMap[ImGuiKey_LeftArrow] = ITEM_ID_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = ITEM_ID_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = ITEM_ID_UP;
- io.KeyMap[ImGuiKey_DownArrow] = ITEM_ID_DOWN;
+ m_mapping[ITEM_ID_A] = ImGuiKey_A;
+ m_mapping[ITEM_ID_C] = ImGuiKey_C;
+ m_mapping[ITEM_ID_V] = ImGuiKey_V;
+ m_mapping[ITEM_ID_X] = ImGuiKey_X;
+ m_mapping[ITEM_ID_Y] = ImGuiKey_Y;
+ m_mapping[ITEM_ID_Z] = ImGuiKey_Z;
+ m_mapping[ITEM_ID_D] = ImGuiKey_D;
+ m_mapping[ITEM_ID_M] = ImGuiKey_M;
+ m_mapping[ITEM_ID_B] = ImGuiKey_B;
+ m_mapping[ITEM_ID_W] = ImGuiKey_W;
+ m_mapping[ITEM_ID_L] = ImGuiKey_L;
+ m_mapping[ITEM_ID_BACKSPACE] = ImGuiKey_Backspace;
+ m_mapping[ITEM_ID_DEL] = ImGuiKey_Delete;
+ m_mapping[ITEM_ID_TAB] = ImGuiKey_Tab;
+ m_mapping[ITEM_ID_PGUP] = ImGuiKey_PageUp;
+ m_mapping[ITEM_ID_PGDN] = ImGuiKey_PageDown;
+ m_mapping[ITEM_ID_HOME] = ImGuiKey_Home;
+ m_mapping[ITEM_ID_END] = ImGuiKey_End;
+ m_mapping[ITEM_ID_ESC] = ImGuiKey_Escape;
+ m_mapping[ITEM_ID_ENTER] = ImGuiKey_Enter;
+ m_mapping[ITEM_ID_LEFT] = ImGuiKey_LeftArrow;
+ m_mapping[ITEM_ID_RIGHT] = ImGuiKey_RightArrow;
+ m_mapping[ITEM_ID_UP] = ImGuiKey_UpArrow;
+ m_mapping[ITEM_ID_DOWN] = ImGuiKey_DownArrow;
+ m_mapping[ITEM_ID_F3] = ImGuiKey_F3;
+ m_mapping[ITEM_ID_F5] = ImGuiKey_F5;
+ m_mapping[ITEM_ID_F6] = ImGuiKey_F6;
+ m_mapping[ITEM_ID_F7] = ImGuiKey_F7;
+ m_mapping[ITEM_ID_F8] = ImGuiKey_F8;
+ m_mapping[ITEM_ID_F9] = ImGuiKey_F9;
+ m_mapping[ITEM_ID_F10] = ImGuiKey_F10;
+ m_mapping[ITEM_ID_F11] = ImGuiKey_F11;
+ m_mapping[ITEM_ID_F12] = ImGuiKey_F12;
// set key delay and repeat rates
io.KeyRepeatDelay = 0.400f;
@@ -1503,38 +1581,68 @@ void debug_imgui::wait_for_debugger(device_t &device, bool firststop)
}
if(firststop)
{
-// debug_show_all();
- device.machine().ui_input().reset();
+ //debug_show_all();
m_running = false;
}
+ if(!m_take_ui)
+ {
+ if (!m_machine->ui().set_ui_event_handler([this] () { return m_take_ui; }))
+ {
+ // can't break if we can't take over UI input
+ m_machine->debugger().console().get_visible_cpu()->debug()->go();
+ m_running = true;
+ return;
+ }
+ m_take_ui = true;
+
+ }
m_hide = false;
-// m_machine->ui_input().frame_update();
- handle_mouse();
- handle_keys();
+ m_machine->osd().input_update(false);
+ handle_events();
handle_console(m_machine);
update_cpu_view(&device);
- imguiBeginFrame(m_mouse_x,m_mouse_y,m_mouse_button ? IMGUI_MBUT_LEFT : 0, 0, width, height,m_key_char);
- update();
- imguiEndFrame();
+ imguiBeginFrame(m_mouse_x, m_mouse_y, m_mouse_button ? IMGUI_MBUT_LEFT : 0, 0, width, height,m_key_char);
handle_mouse_views();
handle_keys_views();
- m_machine->ui_input().reset(); // clear remaining inputs, so they don't fall through to the UI
+ update();
+ imguiEndFrame();
device.machine().osd().update(false);
+ osd_sleep(osd_ticks_per_second() / 1000 * 50);
}
void debug_imgui::debugger_update()
{
- if (m_machine && (m_machine->phase() == machine_phase::RUNNING) && !m_machine->debugger().cpu().is_stopped() && !m_hide)
+ if(!view_main_disasm || !view_main_regs || !view_main_console || !m_machine || (m_machine->phase() != machine_phase::RUNNING))
+ return;
+
+ if(!m_machine->debugger().cpu().is_stopped())
{
- uint32_t width = m_machine->render().ui_target().width();
- uint32_t height = m_machine->render().ui_target().height();
- handle_mouse();
- handle_keys();
- imguiBeginFrame(m_mouse_x,m_mouse_y,m_mouse_button ? IMGUI_MBUT_LEFT : 0, 0, width, height, m_key_char);
- update();
- imguiEndFrame();
+ if(m_take_ui)
+ {
+ m_take_ui = false;
+ m_current_pointer = -1;
+ m_prev_mouse_button = m_mouse_button;
+ if(m_mouse_button)
+ {
+ m_mouse_button = false;
+ ImGuiIO& io = ImGui::GetIO();
+ io.MouseDown[0] = false;
+ }
+ }
+ if(!m_hide)
+ {
+ uint32_t width = m_machine->render().ui_target().width();
+ uint32_t height = m_machine->render().ui_target().height();
+ imguiBeginFrame(m_mouse_x, m_mouse_y, 0, 0, width, height, m_key_char);
+ update();
+ imguiEndFrame();
+ }
}
}
-MODULE_DEFINITION(DEBUG_IMGUI, debug_imgui)
+} // anonymous namespace
+
+} // namespace osd
+
+MODULE_DEFINITION(DEBUG_IMGUI, osd::debug_imgui)