summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-29 00:51:28 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-29 00:51:28 +1100
commit86666f388eb8ee809a953e320acb828f2bd574c1 (patch)
treeeead887b37a9fd071fb505e640bba2fe11f6387c
parent1832b25ad131c25c9f85cf68ef9ff053a74c0341 (diff)
Bug fixes and usablility enhancements:
* Declare intent when requesting virtual memory (for NetBSD, 7712) * Improve scrolling behaviour in Qt debugger (MT07795) * Added prompts to input mapping menu to make it less intimidating
-rw-r--r--src/devices/cpu/drccache.cpp4
-rw-r--r--src/emu/debug/debugvw.cpp2
-rw-r--r--src/frontend/mame/ui/inputmap.cpp19
-rw-r--r--src/frontend/mame/ui/inputmap.h2
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.cpp63
-rw-r--r--src/osd/modules/lib/osdlib.h14
-rw-r--r--src/osd/modules/lib/osdlib_macosx.cpp6
-rw-r--r--src/osd/modules/lib/osdlib_unix.cpp22
-rw-r--r--src/osd/modules/lib/osdlib_uwp.cpp6
-rw-r--r--src/osd/modules/lib/osdlib_win32.cpp2
10 files changed, 90 insertions, 50 deletions
diff --git a/src/devices/cpu/drccache.cpp b/src/devices/cpu/drccache.cpp
index 96d0b7800a3..edee380a61f 100644
--- a/src/devices/cpu/drccache.cpp
+++ b/src/devices/cpu/drccache.cpp
@@ -39,7 +39,7 @@ template <typename T, typename U> constexpr T *ALIGN_PTR_DOWN(T *p, U align)
//-------------------------------------------------
drc_cache::drc_cache(size_t bytes) :
- m_cache({ NEAR_CACHE_SIZE, bytes - NEAR_CACHE_SIZE }),
+ m_cache({ NEAR_CACHE_SIZE, bytes - NEAR_CACHE_SIZE }, osd::virtual_memory_allocation::READ_WRITE_EXECUTE),
m_near(reinterpret_cast<drccodeptr>(m_cache.get())),
m_neartop(m_near),
m_base(ALIGN_PTR_UP(m_near + NEAR_CACHE_SIZE, m_cache.page_size())),
@@ -68,7 +68,7 @@ drc_cache::drc_cache(size_t bytes) :
{
throw emu_fatalerror("drc_cache: Error marking cache read/write");
}
- else if (m_cache.set_access(m_base - m_near, m_end - m_base, osd::virtual_memory_allocation::READ_WRITE | osd::virtual_memory_allocation::EXECUTE))
+ else if (m_cache.set_access(m_base - m_near, m_end - m_base, osd::virtual_memory_allocation::READ_WRITE_EXECUTE))
{
osd_printf_verbose("drc_cache: RWX pages supported\n");
m_rwx = true;
diff --git a/src/emu/debug/debugvw.cpp b/src/emu/debug/debugvw.cpp
index a104bb82529..120152b3d5f 100644
--- a/src/emu/debug/debugvw.cpp
+++ b/src/emu/debug/debugvw.cpp
@@ -250,6 +250,7 @@ void debug_view::adjust_visible_x_for_cursor()
m_topleft.x = m_cursor.x;
else if (m_cursor.x >= m_topleft.x + m_visible.x - 1)
m_topleft.x = m_cursor.x - m_visible.x + 2;
+ m_topleft.x = (std::max)((std::min)(m_topleft.x, m_total.x - m_visible.x), 0);
}
@@ -265,6 +266,7 @@ void debug_view::adjust_visible_y_for_cursor()
m_topleft.y = m_cursor.y;
else if (m_cursor.y >= m_topleft.y + m_visible.y - 1)
m_topleft.y = m_cursor.y - m_visible.y + 2;
+ m_topleft.y = (std::max)((std::min)(m_topleft.y, m_total.y - m_visible.y), 0);
}
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp
index a1bba50822e..a8985ed6bdc 100644
--- a/src/frontend/mame/ui/inputmap.cpp
+++ b/src/frontend/mame/ui/inputmap.cpp
@@ -307,6 +307,17 @@ void menu_input::custom_render(void *selectedref, float top, float bottom, float
ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), ui().colors().background_color(), 1.0f);
}
+ else
+ {
+ char const *const text[] = {
+ record_next ? appendprompt.c_str() : assignprompt.c_str(),
+ item.seq.empty() ? defaultprompt.c_str() : clearprompt.c_str() };
+ draw_text_box(
+ std::begin(text), std::end(text),
+ x1, x2, y2 + ui().box_tb_border(), y2 + bottom,
+ ui::text_layout::CENTER, ui::text_layout::NEVER, false,
+ ui().colors().text_color(), ui().colors().background_color(), 1.0f);
+ }
}
}
}
@@ -485,8 +496,14 @@ void menu_input::populate_sorted(float &customtop, float &custombottom)
item_append(std::move(text), std::move(subtext), flags, &item);
}
+ // pre-format messages
+ assignprompt = util::string_format(_("Press %1$s to set\n"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT)));
+ appendprompt = util::string_format(_("Press %1$s to append\n"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT)));
+ clearprompt = util::string_format(_("Press %1$s to clear\n"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_CLEAR)));
+ defaultprompt = util::string_format(_("Press %1$s to restore default\n"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_CLEAR)));
+
// leave space for showing the input sequence below the menu
- custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
+ custombottom = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
}
} // namespace ui
diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h
index 5ed8c057c96..8058342515e 100644
--- a/src/frontend/mame/ui/inputmap.h
+++ b/src/frontend/mame/ui/inputmap.h
@@ -71,6 +71,8 @@ protected:
private:
std::unique_ptr<input_sequence_poller> seq_poll;
+ std::string assignprompt, appendprompt;
+ std::string clearprompt, defaultprompt;
std::string errormsg;
input_item_data *erroritem;
input_item_data *lastitem;
diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp
index 8b7086684d0..fcbbda81f54 100644
--- a/src/osd/modules/debugger/qt/debuggerview.cpp
+++ b/src/osd/modules/debugger/qt/debuggerview.cpp
@@ -33,6 +33,7 @@ DebuggerView::DebuggerView(
viewFontRequest.setStyleHint(QFont::TypeWriter);
viewFontRequest.setPointSize((selectedFontSize <= 0) ? 11 : selectedFontSize);
setFont(viewFontRequest);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_view = m_machine.debug_view().alloc_view(
type,
@@ -54,22 +55,21 @@ void DebuggerView::paintEvent(QPaintEvent *event)
{
// Tell the MAME debug view how much real estate is available
QFontMetrics actualFont = fontMetrics();
- const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
- const int fontHeight = std::max(1, actualFont.lineSpacing());
- m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight));
-
+ double const fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
+ int const fontHeight = std::max(1, actualFont.lineSpacing());
+ int const contentWidth = width() - verticalScrollBar()->width();
+ int const lineWidth = contentWidth / fontWidth;
+ bool const fullWidth = lineWidth >= m_view->total_size().x;
+ int const contentHeight = height() - (fullWidth ? 0 : horizontalScrollBar()->height());
+ m_view->set_visible_size(debug_view_xy(lineWidth, contentHeight / fontHeight));
// Handle the scroll bars
- const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x;
- const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff;
- horizontalScrollBar()->setRange(0, horizontalScrollSize);
-
- // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly
- const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0;
+ int const horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x;
+ horizontalScrollBar()->setRange(0, (std::max)(0, horizontalScrollCharDiff));
- const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
- const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust;
- const bool atEnd = verticalScrollBar()->value() == verticalScrollBar()->maximum();
+ int const verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
+ int const verticalScrollSize = (std::max)(0, verticalScrollCharDiff);
+ bool const atEnd = verticalScrollBar()->value() == verticalScrollBar()->maximum();
verticalScrollBar()->setRange(0, verticalScrollSize);
if (m_preferBottom && atEnd)
verticalScrollBar()->setValue(verticalScrollSize);
@@ -85,15 +85,14 @@ void DebuggerView::paintEvent(QPaintEvent *event)
bgBrush.setStyle(Qt::SolidPattern);
painter.setPen(QPen(QColor(0,0,0)));
- size_t viewDataOffset = 0;
- const debug_view_xy& visibleCharDims = m_view->visible_size();
- const debug_view_char* viewdata = m_view->viewdata();
- for (int y = 0; y < visibleCharDims.y; y++)
+ const debug_view_xy visibleCharDims = m_view->visible_size();
+ const debug_view_char *viewdata = m_view->viewdata();
+ for (int y = 0; y < visibleCharDims.y; y++, viewdata += visibleCharDims.x)
{
int width = 1;
- for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width)
+ for (int x = 0; x < visibleCharDims.x; x += width)
{
- const unsigned char textAttr = viewdata[viewDataOffset].attrib;
+ const unsigned char textAttr = viewdata[x].attrib;
// Text color handling
QColor fgColor(0,0,0);
@@ -128,27 +127,32 @@ void DebuggerView::paintEvent(QPaintEvent *event)
(fgColor.blue() + bgColor.blue()) >> 1);
}
- if(textAttr & DCA_COMMENT)
+ if (textAttr & DCA_COMMENT)
fgColor.setRgb(0x00, 0x80, 0x00);
bgBrush.setColor(bgColor);
painter.setBackground(bgBrush);
painter.setPen(QPen(fgColor));
- QString text(QChar(viewdata[viewDataOffset].byte));
- for (width = 1; x + width < visibleCharDims.x; width++)
+ QString text(QChar(viewdata[x].byte));
+ for (width = 1; (x + width) < visibleCharDims.x; width++)
{
- if (textAttr != viewdata[viewDataOffset + width].attrib)
+ if (textAttr != viewdata[x + width].attrib)
break;
- text.append(QChar(viewdata[viewDataOffset + width].byte));
+ text.append(QChar(viewdata[x + width].byte));
}
// Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before.
- painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush);
+ painter.fillRect(
+ x * fontWidth,
+ y * fontHeight,
+ ((x + width) < visibleCharDims.x) ? (width * fontWidth) : (contentWidth - (x * fontWidth)),
+ ((y + 1) < visibleCharDims.y) ? fontHeight : (contentHeight - (y * fontHeight)),
+ bgBrush);
// There is a touchy interplay between font height, drawing difference, visible position, etc
// Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed.
- painter.drawText(x*fontWidth, (y*fontHeight + (fontHeight*0.80)), text);
+ painter.drawText(x * fontWidth, (y * fontHeight + (fontHeight * 0.80)), text);
}
}
}
@@ -234,10 +238,11 @@ void DebuggerView::mousePressEvent(QMouseEvent *event)
const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
const int fontHeight = std::max(1, actualFont.lineSpacing());
- debug_view_xy topLeft = m_view->visible_position();
+ debug_view_xy const topLeft = m_view->visible_position();
+ debug_view_xy const visibleCharDims = m_view->visible_size();
debug_view_xy clickViewPosition;
- clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
- clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
+ clickViewPosition.x = (std::min)(int(topLeft.x + (event->x() / fontWidth)), topLeft.x + visibleCharDims.x - 1);
+ clickViewPosition.y = (std::min)(int(topLeft.y + (event->y() / fontHeight)), topLeft.y + visibleCharDims.y - 1);
if (event->button() == Qt::LeftButton)
{
diff --git a/src/osd/modules/lib/osdlib.h b/src/osd/modules/lib/osdlib.h
index 59b5291b0a8..cb3c2dcdce8 100644
--- a/src/osd/modules/lib/osdlib.h
+++ b/src/osd/modules/lib/osdlib.h
@@ -34,7 +34,7 @@
None.
-----------------------------------------------------------------------------*/
-void osd_process_kill(void);
+void osd_process_kill();
/*-----------------------------------------------------------------------------
@@ -57,7 +57,8 @@ 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(void);
+std::string osd_get_clipboard_text();
+
namespace osd {
@@ -74,16 +75,17 @@ public:
WRITE = 0x02,
EXECUTE = 0x04,
READ_WRITE = READ | WRITE,
- READ_EXECUTE = READ | EXECUTE
+ READ_EXECUTE = READ | EXECUTE,
+ READ_WRITE_EXECUTE = READ | WRITE | EXECUTE
};
virtual_memory_allocation(virtual_memory_allocation const &) = delete;
virtual_memory_allocation &operator=(virtual_memory_allocation const &) = delete;
virtual_memory_allocation() { }
- virtual_memory_allocation(std::initializer_list<std::size_t> blocks)
+ virtual_memory_allocation(std::initializer_list<std::size_t> blocks, unsigned intent)
{
- m_memory = do_alloc(blocks, m_size, m_page_size);
+ m_memory = do_alloc(blocks, intent, m_size, m_page_size);
}
virtual_memory_allocation(virtual_memory_allocation &&that) : m_memory(that.m_memory), m_size(that.m_size), m_page_size(that.m_page_size)
{
@@ -134,7 +136,7 @@ public:
}
private:
- static void *do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size);
+ static void *do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size);
static void do_free(void *start, std::size_t size);
static bool do_set_access(void *start, std::size_t size, unsigned access);
diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp
index 0b4c30bc14a..27124b6ef2e 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(void)
+std::string osd_get_clipboard_text()
{
std::string result;
bool has_result = false;
@@ -161,7 +161,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return getpid();
}
@@ -234,7 +234,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
long const p(sysconf(_SC_PAGE_SIZE));
if (0 >= p)
diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp
index 5b182eb6a9c..4b091450116 100644
--- a/src/osd/modules/lib/osdlib_unix.cpp
+++ b/src/osd/modules/lib/osdlib_unix.cpp
@@ -69,7 +69,7 @@ void osd_break_into_debugger(const char *message)
}
#ifdef SDLMAME_ANDROID
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
return std::string();
}
@@ -78,7 +78,7 @@ std::string osd_get_clipboard_text(void)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
std::string result;
@@ -97,7 +97,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return getpid();
}
@@ -172,7 +172,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
long const p(sysconf(_SC_PAGE_SIZE));
if (0 >= p)
@@ -183,13 +183,25 @@ void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blo
s *= p;
if (!s)
return nullptr;
+#if defined __NetBSD__
+ int req((NONE == intent) ? PROT_NONE : 0);
+ if (intent & READ)
+ req |= PROT_READ;
+ if (intent & WRITE)
+ req |= PROT_WRITE;
+ if (intent & EXECUTE)
+ req |= PROT_EXEC;
+ int const prot(PROT_MPROTECT(req));
+#else
+ int const prot(PROT_NONE);
+#endif
#if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) || defined(SDLMAME_EMSCRIPTEN)
int const fd(-1);
#else
// TODO: portable applications are supposed to use -1 for anonymous mappings - detect whatever requires 0 specifically
int const fd(0);
#endif
- void *const result(mmap(nullptr, s, PROT_NONE, MAP_ANON | MAP_SHARED, fd, 0));
+ void *const result(mmap(nullptr, s, prot, MAP_ANON | MAP_SHARED, fd, 0));
if (result == (void *)-1)
return nullptr;
size = s;
diff --git a/src/osd/modules/lib/osdlib_uwp.cpp b/src/osd/modules/lib/osdlib_uwp.cpp
index f9a3e6a5cf9..87035e9db97 100644
--- a/src/osd/modules/lib/osdlib_uwp.cpp
+++ b/src/osd/modules/lib/osdlib_uwp.cpp
@@ -138,7 +138,7 @@ static std::string convert_ansi(LPCVOID data)
// osd_get_clipboard_text
//============================================================
-std::string osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text()
{
std::string result;
@@ -156,7 +156,7 @@ std::string osd_get_clipboard_text(void)
// osd_getpid
//============================================================
-int osd_getpid(void)
+int osd_getpid()
{
return GetCurrentProcessId();
}
@@ -170,7 +170,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
SYSTEM_INFO info;
GetSystemInfo(&info);
diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp
index 768b71463d2..b75500deee9 100644
--- a/src/osd/modules/lib/osdlib_win32.cpp
+++ b/src/osd/modules/lib/osdlib_win32.cpp
@@ -268,7 +268,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size)
}
-void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, std::size_t &size, std::size_t &page_size)
+void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size)
{
SYSTEM_INFO info;
GetSystemInfo(&info);