summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/eigccppc.h3
-rw-r--r--src/osd/eigccx86.h30
-rw-r--r--src/osd/eminline.h71
-rw-r--r--src/osd/modules/file/winfile.cpp21
-rw-r--r--src/osd/modules/input/input_sdl.cpp3
-rw-r--r--src/osd/modules/input/input_xinput.cpp14
-rw-r--r--src/osd/modules/input/input_xinput.h10
-rw-r--r--src/osd/modules/lib/osdobj_common.cpp2
8 files changed, 121 insertions, 33 deletions
diff --git a/src/osd/eigccppc.h b/src/osd/eigccppc.h
index 7c322299e3c..7f932eb1e88 100644
--- a/src/osd/eigccppc.h
+++ b/src/osd/eigccppc.h
@@ -275,10 +275,9 @@ _count_leading_ones(uint32_t value)
uint32_t result;
__asm__ (
- " not %[result], %[value] \n"
" cntlzw %[result], %[result] \n"
: [result] "=r" (result) /* result can be in any register */
- : [value] "r" (value) /* 'value' can be in any register */
+ : [value] "r" (~value) /* 'value' can be in any register */
);
return result;
diff --git a/src/osd/eigccx86.h b/src/osd/eigccx86.h
index 363daba5f5f..b67b646451e 100644
--- a/src/osd/eigccx86.h
+++ b/src/osd/eigccx86.h
@@ -472,13 +472,13 @@ _count_leading_zeros(uint32_t value)
{
uint32_t result;
__asm__ (
- " bsrl %[value], %[result] ;"
- " jnz 1f ;"
- " movl $63, %[result] ;"
- "1: xorl $31, %[result] ;"
- : [result] "=r" (result) // result can be in any register
- : [value] "rm" (value) // 'value' can be register or memory
- : "cc" // clobbers condition codes
+ " bsrl %[value], %[result] ;"
+ " cmovzl %[bias], %[result] ;"
+ " xorl $31, %[result] ;"
+ : [result] "=&r" (result) // result can be in any register
+ : [value] "rm" (value) // 'value' can be register or memory
+ , [bias] "rm" (uint32_t(63)) // 'bias' can be register or memory
+ : "cc" // clobbers condition codes
);
return result;
}
@@ -495,15 +495,13 @@ _count_leading_ones(uint32_t value)
{
uint32_t result;
__asm__ (
- " movl %[value], %[result] ;"
- " notl %[result] ;"
- " bsrl %[result], %[result] ;"
- " jnz 1f ;"
- " movl $63, %[result] ;"
- "1: xorl $31, %[result] ;"
- : [result] "=r" (result) // result can be in any register
- : [value] "rmi" (value) // 'value' can be register, memory or immediate
- : "cc" // clobbers condition codes
+ " bsrl %[value], %[result] ;"
+ " cmovzl %[bias], %[result] ;"
+ " xorl $31, %[result] ;"
+ : [result] "=&r" (result) // result can be in any register
+ : [value] "rm" (~value) // 'value' can be register or memory
+ , [bias] "rm" (uint32_t(63)) // 'bias' can be register or memory
+ : "cc" // clobbers condition codes
);
return result;
}
diff --git a/src/osd/eminline.h b/src/osd/eminline.h
index 43316491a08..685df59abae 100644
--- a/src/osd/eminline.h
+++ b/src/osd/eminline.h
@@ -295,6 +295,77 @@ inline uint8_t count_leading_ones(uint32_t val)
#endif
+/*-------------------------------------------------
+ population_count_32 - return the number of
+ one bits in a 32-bit value
+-------------------------------------------------*/
+
+#ifndef population_count_32
+#if defined(__NetBSD__)
+#define population_count_32 popcount32
+#else
+inline unsigned population_count_32(uint32_t val)
+{
+#if defined(__GNUC__)
+ // uses CPU feature if available, otherwise falls back to implementation similar to what follows
+ static_assert(sizeof(val) == sizeof(unsigned), "expected 32-bit unsigned int");
+ return unsigned(__builtin_popcount(static_cast<unsigned>(val)));
+#else
+ // optimal Hamming weight assuing fast 32*32->32
+ constexpr uint32_t m1(0x55555555);
+ constexpr uint32_t m2(0x33333333);
+ constexpr uint32_t m4(0x0f0f0f0f);
+ constexpr uint32_t h01(0x01010101);
+ val -= (val >> 1) & m1;
+ val = (val & m2) + ((val >> 2) & m2);
+ val = (val + (val >> 4)) & m4;
+ return unsigned((val * h01) >> 24);
+#endif
+}
+#endif
+#endif
+
+
+/*-------------------------------------------------
+ population_count_64 - return the number of
+ one bits in a 64-bit value
+-------------------------------------------------*/
+
+#ifndef population_count_64
+#if defined(__NetBSD__)
+#define population_count_64 popcount64
+#else
+inline unsigned population_count_64(uint64_t val)
+{
+#if defined(__GNUC__)
+ // uses CPU feature if available, otherwise falls back to implementation similar to what follows
+ static_assert(sizeof(val) == sizeof(unsigned long long), "expected 64-bit unsigned long long int");
+ return unsigned(__builtin_popcountll(static_cast<unsigned long long>(val)));
+#else
+ // guess that architectures with 64-bit pointers have 64-bit multiplier
+ if (sizeof(void *) >= sizeof(uint64_t))
+ {
+ // optimal Hamming weight assuming fast 64*64->64
+ constexpr uint64_t m1(0x5555555555555555);
+ constexpr uint64_t m2(0x3333333333333333);
+ constexpr uint64_t m4(0x0f0f0f0f0f0f0f0f);
+ constexpr uint64_t h01(0x0101010101010101);
+ val -= (val >> 1) & m1;
+ val = (val & m2) + ((val >> 2) & m2);
+ val = (val + (val >> 4)) & m4;
+ return unsigned((val * h01) >> 56);
+ }
+ else
+ {
+ // fall back to two 32-bit operations to avoid slow multiply
+ return population_count_32(uint32_t(val)) + population_count_32(uint32_t(val >> 32));
+ }
+#endif
+}
+#endif
+#endif
+
+
/***************************************************************************
INLINE TIMING FUNCTIONS
***************************************************************************/
diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp
index 745b9112b7b..66281d08b4a 100644
--- a/src/osd/modules/file/winfile.cpp
+++ b/src/osd/modules/file/winfile.cpp
@@ -185,6 +185,7 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
{
disposition = (!is_path_to_physical_drive(path.c_str()) && (openflags & OPEN_FLAG_CREATE)) ? CREATE_ALWAYS : OPEN_EXISTING;
access = (openflags & OPEN_FLAG_READ) ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_WRITE;
+ if (is_path_to_physical_drive(path.c_str())) access |= GENERIC_READ;
sharemode = FILE_SHARE_READ;
}
else if (openflags & OPEN_FLAG_READ)
@@ -230,7 +231,25 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
// get the file size
DWORD upper, lower;
- lower = GetFileSize(h, &upper);
+ if (is_path_to_physical_drive(path.c_str()))
+ {
+ GET_LENGTH_INFORMATION gli;
+ DWORD ret;
+ if (!DeviceIoControl(h, IOCTL_DISK_GET_LENGTH_INFO, nullptr, 0, &gli, sizeof(gli), &ret, nullptr))
+ {
+ upper = 0;
+ lower = INVALID_FILE_SIZE;
+ }
+ else
+ {
+ lower = gli.Length.LowPart;
+ upper = gli.Length.HighPart;
+ }
+ }
+ else
+ {
+ lower = GetFileSize(h, &upper);
+ }
if (INVALID_FILE_SIZE == lower)
{
DWORD const err = GetLastError();
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index 93e14313de8..a3cbed7c107 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -250,7 +250,8 @@ public:
{
machine().ui_input().push_mouse_down_event(window->target(), cx, cy);
- if (click - last_click < double_click_speed
+ // avoid overflow with std::chrono::time_point::min() by adding rather than subtracting
+ if (click < last_click + double_click_speed
&& (cx >= last_x - 4 && cx <= last_x + 4)
&& (cy >= last_y - 4 && cy <= last_y + 4))
{
diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp
index e6ecdd4d177..67348ebe162 100644
--- a/src/osd/modules/input/input_xinput.cpp
+++ b/src/osd/modules/input/input_xinput.cpp
@@ -130,9 +130,9 @@ void xinput_joystick_device::poll()
gamepad.right_thumb_x = normalize_absolute_axis(xinput_state.xstate.Gamepad.sThumbRX, XINPUT_AXIS_MINVALUE, XINPUT_AXIS_MAXVALUE);
gamepad.right_thumb_y = normalize_absolute_axis(-xinput_state.xstate.Gamepad.sThumbRY, XINPUT_AXIS_MINVALUE, XINPUT_AXIS_MAXVALUE);
- // Now the triggers
- gamepad.left_trigger = normalize_absolute_axis(xinput_state.xstate.Gamepad.bLeftTrigger, 0, 255);
- gamepad.right_trigger = normalize_absolute_axis(xinput_state.xstate.Gamepad.bRightTrigger, 0, 255);
+ // Now the triggers, place them on half-axes (negative side)
+ gamepad.left_trigger = -normalize_absolute_axis(xinput_state.xstate.Gamepad.bLeftTrigger, -255, 255);
+ gamepad.right_trigger = -normalize_absolute_axis(xinput_state.xstate.Gamepad.bRightTrigger, -255, 255);
}
void xinput_joystick_device::reset()
@@ -179,16 +179,16 @@ void xinput_joystick_device::configure()
}
device()->add_item(
- "Left Trigger",
+ "RT",
ITEM_ID_ZAXIS,
generic_axis_get_state<LONG>,
- &gamepad.left_trigger);
+ &gamepad.right_trigger);
device()->add_item(
- "Right Trigger",
+ "LT",
ITEM_ID_RZAXIS,
generic_axis_get_state<LONG>,
- &gamepad.right_trigger);
+ &gamepad.left_trigger);
m_configured = true;
}
diff --git a/src/osd/modules/input/input_xinput.h b/src/osd/modules/input/input_xinput.h
index 2cd8f15a250..9772e941bb7 100644
--- a/src/osd/modules/input/input_xinput.h
+++ b/src/osd/modules/input/input_xinput.h
@@ -62,12 +62,12 @@ static const char *const xinput_button_names[] = {
"B",
"X",
"Y",
- "Left Shoulder",
- "Right Shoulder",
+ "LB",
+ "RB",
"Start",
"Back",
- "Left Thumb",
- "Right Thumb"
+ "LS",
+ "RS"
};
struct gamepad_state
@@ -85,7 +85,7 @@ struct gamepad_state
// state information for a gamepad; state must be first element
struct xinput_api_state
{
- uint32_t player_index;
+ uint32_t player_index;
XINPUT_STATE xstate;
XINPUT_CAPABILITIES caps;
};
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index 5bacf0c341d..704ee399819 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -91,7 +91,7 @@ const options_entry osd_options::s_option_entries[] =
{ nullptr, nullptr, OPTION_HEADER, "OSD ACCELERATED VIDEO OPTIONS" },
{ OSDOPTION_FILTER ";glfilter;flt", "1", OPTION_BOOLEAN, "enable bilinear filtering on screen output" },
- { OSDOPTION_PRESCALE, "1", OPTION_INTEGER, "scale screen rendering by this amount in software" },
+ { OSDOPTION_PRESCALE "(1-3)", "1", OPTION_INTEGER, "scale screen rendering by this amount in software" },
#if USE_OPENGL
{ nullptr, nullptr, OPTION_HEADER, "OpenGL-SPECIFIC OPTIONS" },