mirror of
https://github.com/holub/mame
synced 2025-07-06 18:39:28 +03:00
Merge branch 'master' of https://github.com/mamedev/mame.git
This commit is contained in:
commit
22f8848c25
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/romcmp.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -108,6 +109,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/chdman.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
MAME_DIR .. "src/version.cpp",
|
||||
}
|
||||
|
||||
@ -157,6 +159,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/jedutil.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -280,6 +283,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/ldresample.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -340,6 +344,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/ldverify.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -388,6 +393,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/regrep.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -436,6 +442,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/srcclean.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -484,6 +491,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/src2html.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -543,6 +551,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/split.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -591,6 +600,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/pngcmp.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -652,6 +662,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/lib/netlist/prg/nltool.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -690,7 +701,8 @@ includedirs {
|
||||
}
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/lib/netlist/prg/nlwav.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/prg/nlwav.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -752,6 +764,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/castool.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
@ -814,6 +827,7 @@ includedirs {
|
||||
|
||||
files {
|
||||
MAME_DIR .. "src/tools/floptool.cpp",
|
||||
MAME_DIR .. "src/emu/emucore.cpp",
|
||||
}
|
||||
|
||||
configuration { "mingw*" or "vs*" }
|
||||
|
@ -712,7 +712,7 @@ void ui_menu_file_selector::handle()
|
||||
// from current entry to the end
|
||||
for (entry = cur_selected; entry != nullptr; entry = entry->next)
|
||||
{
|
||||
if (entry->basename != nullptr && m_filename_buffer != nullptr)
|
||||
if (entry->basename != nullptr && m_filename_buffer[0] != '\0')
|
||||
{
|
||||
int match = 0;
|
||||
for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++)
|
||||
@ -731,7 +731,7 @@ void ui_menu_file_selector::handle()
|
||||
// and from the first entry to current one
|
||||
for (entry = m_entrylist; entry != cur_selected; entry = entry->next)
|
||||
{
|
||||
if (entry->basename != nullptr && m_filename_buffer != nullptr)
|
||||
if (entry->basename != nullptr && m_filename_buffer[0] != '\0')
|
||||
{
|
||||
int match = 0;
|
||||
for (int i = 0; i < ARRAY_LENGTH(m_filename_buffer); i++)
|
||||
|
@ -544,7 +544,7 @@ void ui_menu::draw(bool customonly, bool noimage, bool noinput)
|
||||
machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
|
||||
|
||||
// determine the first visible line based on the current selection
|
||||
if (selected > top_line + visible_lines)
|
||||
if (selected > top_line + visible_lines || selected < top_line - visible_lines)
|
||||
top_line = selected - (visible_lines / 2);
|
||||
if (top_line < 0 || selected == 0)
|
||||
top_line = 0;
|
||||
|
@ -1040,7 +1040,7 @@ public:
|
||||
{
|
||||
return (m_end && (m_end == it)) || (m_check_nul && (format_chars<char_type>::nul == *it));
|
||||
}
|
||||
std::size_t size() const
|
||||
std::size_t argument_count() const
|
||||
{
|
||||
return m_argument_count;
|
||||
}
|
||||
@ -1131,6 +1131,9 @@ class format_argument_pack_impl
|
||||
, public format_argument_pack<Stream>
|
||||
{
|
||||
public:
|
||||
using typename format_argument_pack<Stream>::iterator;
|
||||
using format_argument_pack<Stream>::operator[];
|
||||
|
||||
template <typename Format, typename... Params>
|
||||
format_argument_pack_impl(Format &&fmt, Params &&... args)
|
||||
: std::array<format_argument<Stream>, Count>({ { format_argument<Stream>(std::forward<Params>(args))... } })
|
||||
@ -1147,15 +1150,9 @@ public:
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// ARGUMENT PACK CREATOR FUNCTIONS
|
||||
// ARGUMENT PACK CREATOR FUNCTION
|
||||
//**************************************************************************
|
||||
|
||||
template <typename Stream = std::ostream, typename... Params>
|
||||
inline std::array<format_argument<Stream>, sizeof...(Params)> make_format_arguments(Params &&... args)
|
||||
{
|
||||
return std::array<format_argument<Stream>, sizeof...(Params)>({ { format_argument<Stream>(std::forward<Params>(args))... } });
|
||||
}
|
||||
|
||||
template <typename Stream = std::ostream, typename Format, typename... Params>
|
||||
inline format_argument_pack_impl<Stream, sizeof...(Params)> make_format_argument_pack(Format &&fmt, Params &&... args)
|
||||
{
|
||||
@ -1164,54 +1161,16 @@ inline format_argument_pack_impl<Stream, sizeof...(Params)> make_format_argument
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// FORMAT STRING PARSING HELPERS
|
||||
// FORMAT STRING PARSING HELPER
|
||||
//**************************************************************************
|
||||
|
||||
template <typename Format>
|
||||
class format_helper_base : public format_chars<std::remove_cv_t<std::remove_reference_t<decltype(*std::cbegin(std::declval<Format>()))> > >
|
||||
{
|
||||
public:
|
||||
typedef std::remove_reference_t<decltype(std::cbegin(std::declval<Format>()))> iterator;
|
||||
static iterator begin(Format const &fmt) { return std::cbegin(fmt); }
|
||||
static bool at_end(Format const &fmt, iterator const &it) { return std::cend(fmt) == it; }
|
||||
};
|
||||
|
||||
template <typename Character>
|
||||
class format_helper_base<Character *> : public format_chars<std::remove_cv_t<Character> >
|
||||
{
|
||||
public:
|
||||
typedef Character const *iterator;
|
||||
static iterator begin(Character const *fmt) { return fmt; }
|
||||
static bool at_end(Character const *fmt, iterator const &it) { return format_helper_base::nul == *it; }
|
||||
};
|
||||
|
||||
template <typename Character, std::size_t Length>
|
||||
class format_helper_base<Character [Length]> : public format_chars<std::remove_cv_t<Character> >
|
||||
{
|
||||
public:
|
||||
typedef Character const *iterator;
|
||||
static iterator begin(std::remove_const_t<Character> (&fmt)[Length]) { return std::cbegin(fmt); }
|
||||
static iterator begin(std::add_const_t<Character> (&fmt)[Length]) { return std::cbegin(fmt); }
|
||||
static bool at_end(std::remove_const_t<Character> (&fmt)[Length], iterator const &it) { return (std::cend(fmt) == it) || (format_chars<Character>::nul == *it); }
|
||||
static bool at_end(std::add_const_t<Character> (&fmt)[Length], iterator const &it) { return (std::cend(fmt) == it) || (format_helper_base::nul == *it); }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
class format_helper_base<format_argument_pack<Stream> > : public format_chars<typename format_argument_pack<Stream>::char_type>
|
||||
{
|
||||
public:
|
||||
typedef typename format_argument_pack<Stream>::iterator iterator;
|
||||
static iterator begin(format_argument_pack<Stream> const &fmt) { return fmt.format_begin(); }
|
||||
static bool at_end(format_argument_pack<Stream> const &fmt, iterator const &it) { return fmt.format_at_end(it); }
|
||||
};
|
||||
|
||||
template <typename Format>
|
||||
class format_helper : public format_helper_base<Format>
|
||||
class format_helper : public format_chars<typename Format::char_type>
|
||||
{
|
||||
public:
|
||||
static bool parse_format(
|
||||
Format const &fmt,
|
||||
typename format_helper::iterator &it,
|
||||
typename Format::iterator &it,
|
||||
format_flags &flags,
|
||||
int &next_position,
|
||||
int &argument_position,
|
||||
@ -1219,7 +1178,7 @@ public:
|
||||
int &precision_position)
|
||||
{
|
||||
static_assert((format_helper::nine - format_helper::zero) == 9, "Digits must be contiguous");
|
||||
assert(!format_helper::at_end(fmt, it));
|
||||
assert(!fmt.format_at_end(it));
|
||||
assert(format_helper::percent == *it);
|
||||
|
||||
int num;
|
||||
@ -1231,8 +1190,8 @@ public:
|
||||
precision_position = -1;
|
||||
|
||||
// Leading zeroes are tricky - they could be a zero-pad flag or part of a position specifier
|
||||
bool const leading_zero(!format_helper::at_end(fmt, it) && (format_helper::zero == *it));
|
||||
while (!format_helper::at_end(fmt, it) && (format_helper::zero == *it)) ++it;
|
||||
bool const leading_zero(!fmt.format_at_end(it) && (format_helper::zero == *it));
|
||||
while (!fmt.format_at_end(it) && (format_helper::zero == *it)) ++it;
|
||||
|
||||
// Digits encountered at this point could be a field width or a position specifier
|
||||
num = 0;
|
||||
@ -1258,7 +1217,7 @@ public:
|
||||
}
|
||||
|
||||
// Parse flag characters
|
||||
while (!format_helper::at_end(fmt, it))
|
||||
while (!fmt.format_at_end(it))
|
||||
{
|
||||
switch (*it)
|
||||
{
|
||||
@ -1275,7 +1234,7 @@ public:
|
||||
}
|
||||
|
||||
// Check for literal or parameterised field width
|
||||
if (!format_helper::at_end(fmt, it))
|
||||
if (!fmt.format_at_end(it))
|
||||
{
|
||||
if (is_digit(*it))
|
||||
{
|
||||
@ -1302,14 +1261,14 @@ public:
|
||||
}
|
||||
|
||||
// Check for literal or parameterised precision
|
||||
if (!format_helper::at_end(fmt, it) && (*it == format_helper::point))
|
||||
if (!fmt.format_at_end(it) && (*it == format_helper::point))
|
||||
{
|
||||
++it;
|
||||
if (have_digit(fmt, it))
|
||||
{
|
||||
flags.set_precision(read_number(fmt, it));
|
||||
}
|
||||
else if (!format_helper::at_end(fmt, it) && (format_helper::asterisk == *it))
|
||||
else if (!fmt.format_at_end(it) && (format_helper::asterisk == *it))
|
||||
{
|
||||
++it;
|
||||
if (have_digit(fmt, it))
|
||||
@ -1333,11 +1292,11 @@ public:
|
||||
}
|
||||
|
||||
// Check for length modifiers
|
||||
if (!format_helper::at_end(fmt, it)) switch (*it)
|
||||
if (!fmt.format_at_end(it)) switch (*it)
|
||||
{
|
||||
case format_helper::h:
|
||||
++it;
|
||||
if (!format_helper::at_end(fmt, it) && (format_helper::h == *it))
|
||||
if (!fmt.format_at_end(it) && (format_helper::h == *it))
|
||||
{
|
||||
++it;
|
||||
flags.set_length(format_flags::length::character);
|
||||
@ -1349,7 +1308,7 @@ public:
|
||||
break;
|
||||
case format_helper::l:
|
||||
++it;
|
||||
if (!format_helper::at_end(fmt, it) && (format_helper::l == *it))
|
||||
if (!fmt.format_at_end(it) && (format_helper::l == *it))
|
||||
{
|
||||
++it;
|
||||
flags.set_length(format_flags::length::long_long_integer);
|
||||
@ -1379,13 +1338,13 @@ public:
|
||||
{
|
||||
++it;
|
||||
format_flags::length length = format_flags::length::size_type;
|
||||
if (!format_helper::at_end(fmt, it))
|
||||
if (!fmt.format_at_end(it))
|
||||
{
|
||||
if ((typename format_helper::char_type(format_helper::zero) + 3) == *it)
|
||||
{
|
||||
typename format_helper::iterator tmp(it);
|
||||
typename Format::iterator tmp(it);
|
||||
++tmp;
|
||||
if (!format_helper::at_end(fmt, tmp) && ((typename format_helper::char_type(format_helper::zero) + 2) == *tmp))
|
||||
if (!fmt.format_at_end(tmp) && ((typename format_helper::char_type(format_helper::zero) + 2) == *tmp))
|
||||
{
|
||||
length = format_flags::length::integer_32;
|
||||
it = ++tmp;
|
||||
@ -1393,9 +1352,9 @@ public:
|
||||
}
|
||||
else if ((typename format_helper::char_type(format_helper::zero) + 6) == *it)
|
||||
{
|
||||
typename format_helper::iterator tmp(it);
|
||||
typename Format::iterator tmp(it);
|
||||
++tmp;
|
||||
if (!format_helper::at_end(fmt, tmp) && ((typename format_helper::char_type(format_helper::zero) + 4) == *tmp))
|
||||
if (!fmt.format_at_end(tmp) && ((typename format_helper::char_type(format_helper::zero) + 4) == *tmp))
|
||||
{
|
||||
length = format_flags::length::integer_64;
|
||||
it = ++tmp;
|
||||
@ -1414,8 +1373,8 @@ public:
|
||||
}
|
||||
|
||||
// Now we should find a conversion specifier
|
||||
assert(!format_helper::at_end(fmt, it)); // missing conversion
|
||||
if (format_helper::at_end(fmt, it)) return false;
|
||||
assert(!fmt.format_at_end(it)); // missing conversion
|
||||
if (fmt.format_at_end(it)) return false;
|
||||
switch (*it)
|
||||
{
|
||||
case format_helper::d:
|
||||
@ -1498,14 +1457,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static bool have_dollar(Format const &fmt, typename format_helper::iterator const &it)
|
||||
static bool have_dollar(Format const &fmt, typename Format::iterator const &it)
|
||||
{
|
||||
return !format_helper::at_end(fmt, it) && (*it == format_helper::dollar);
|
||||
return !fmt.format_at_end(it) && (*it == format_helper::dollar);
|
||||
}
|
||||
|
||||
static bool have_digit(Format const &fmt, typename format_helper::iterator const &it)
|
||||
static bool have_digit(Format const &fmt, typename Format::iterator const &it)
|
||||
{
|
||||
return !format_helper::at_end(fmt, it) && is_digit(*it);
|
||||
return !fmt.format_at_end(it) && is_digit(*it);
|
||||
}
|
||||
|
||||
static bool is_digit(typename format_helper::char_type value)
|
||||
@ -1524,7 +1483,7 @@ private:
|
||||
num = (num * 10) + digit_value(digit);
|
||||
}
|
||||
|
||||
static int read_number(Format const &fmt, typename format_helper::iterator &it)
|
||||
static int read_number(Format const &fmt, typename Format::iterator &it)
|
||||
{
|
||||
assert(have_digit(fmt, it));
|
||||
int value = 0;
|
||||
@ -1538,11 +1497,11 @@ private:
|
||||
// CORE FORMATTING FUNCTION
|
||||
//**************************************************************************
|
||||
|
||||
template <typename Stream, typename Format, typename Params>
|
||||
typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args)
|
||||
template <typename Stream, typename Format>
|
||||
typename Stream::off_type stream_format(Stream &str, Format const &args)
|
||||
{
|
||||
typedef format_helper<std::remove_cv_t<std::remove_reference_t<Format> > > format_helper;
|
||||
typedef typename format_helper::iterator iterator;
|
||||
typedef format_helper<std::remove_cv_t<Format> > format_helper;
|
||||
typedef typename Format::iterator iterator;
|
||||
class stream_preserver
|
||||
{
|
||||
public:
|
||||
@ -1572,21 +1531,21 @@ typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args
|
||||
typename Stream::pos_type const begin(str.tellp());
|
||||
stream_preserver const preserver(str);
|
||||
int next_pos(1);
|
||||
iterator start = format_helper::begin(fmt);
|
||||
for (iterator it = start; !format_helper::at_end(fmt, start); )
|
||||
iterator start = args.format_begin();
|
||||
for (iterator it = start; !args.format_at_end(start); )
|
||||
{
|
||||
while (!format_helper::at_end(fmt, it) && (format_helper::percent != *it)) ++it;
|
||||
while (!args.format_at_end(it) && (format_helper::percent != *it)) ++it;
|
||||
if (start != it)
|
||||
{
|
||||
str.write(&*start, it - start);
|
||||
start = it;
|
||||
}
|
||||
if (!format_helper::at_end(fmt, it))
|
||||
if (!args.format_at_end(it))
|
||||
{
|
||||
// Try to parse a percent format specification
|
||||
format_flags flags;
|
||||
int arg_pos, width_pos, prec_pos;
|
||||
if (!format_helper::parse_format(fmt, it, flags, next_pos, arg_pos, width_pos, prec_pos))
|
||||
if (!format_helper::parse_format(args, it, flags, next_pos, arg_pos, width_pos, prec_pos))
|
||||
continue;
|
||||
|
||||
// Handle parameterised width
|
||||
@ -1594,8 +1553,8 @@ typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args
|
||||
{
|
||||
assert(flags.get_field_width() == 0U);
|
||||
assert(0 < width_pos);
|
||||
assert(args.size() >= unsigned(width_pos));
|
||||
if ((0 < width_pos) && (args.size() >= unsigned(width_pos)))
|
||||
assert(args.argument_count() >= unsigned(width_pos));
|
||||
if ((0 < width_pos) && (args.argument_count() >= unsigned(width_pos)))
|
||||
{
|
||||
int width;
|
||||
if (args[width_pos - 1].make_integer(width))
|
||||
@ -1622,8 +1581,8 @@ typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args
|
||||
{
|
||||
assert(flags.get_precision() < 0);
|
||||
assert(0 < prec_pos);
|
||||
assert(args.size() >= unsigned(prec_pos));
|
||||
if ((0 < prec_pos) && (args.size() >= unsigned(prec_pos)))
|
||||
assert(args.argument_count() >= unsigned(prec_pos));
|
||||
if ((0 < prec_pos) && (args.argument_count() >= unsigned(prec_pos)))
|
||||
{
|
||||
int precision;
|
||||
if (args[prec_pos - 1].make_integer(precision))
|
||||
@ -1648,8 +1607,8 @@ typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args
|
||||
else
|
||||
{
|
||||
assert(0 < arg_pos);
|
||||
assert(args.size() >= unsigned(arg_pos));
|
||||
if ((0 >= arg_pos) || (args.size() < unsigned(arg_pos)))
|
||||
assert(args.argument_count() >= unsigned(arg_pos));
|
||||
if ((0 >= arg_pos) || (args.argument_count() < unsigned(arg_pos)))
|
||||
continue;
|
||||
if (format_flags::conversion::tell == flags.get_conversion())
|
||||
{
|
||||
@ -1683,19 +1642,19 @@ typename Stream::off_type stream_format(Stream &str, Format &&fmt, Params &&args
|
||||
template <typename Stream, typename Format, typename... Params>
|
||||
inline typename Stream::off_type stream_format(Stream &str, Format const &fmt, Params &&... args)
|
||||
{
|
||||
return detail::stream_format(str, fmt, detail::make_format_arguments<Stream>(std::forward<Params>(args)...));
|
||||
return detail::stream_format(str, detail::make_format_argument_pack<Stream>(fmt, std::forward<Params>(args)...));
|
||||
}
|
||||
|
||||
template <typename Stream, typename Base>
|
||||
inline typename Stream::off_type stream_format(Stream &str, detail::format_argument_pack<Base> const &args)
|
||||
{
|
||||
return detail::stream_format(str, args, args);
|
||||
return detail::stream_format(str, args);
|
||||
}
|
||||
|
||||
template <typename Stream, typename Base>
|
||||
inline typename Stream::off_type stream_format(Stream &str, detail::format_argument_pack<Base> &&args)
|
||||
{
|
||||
return detail::stream_format(str, args, args);
|
||||
return detail::stream_format(str, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <ios>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <streambuf>
|
||||
#include <string>
|
||||
@ -103,10 +107,11 @@ public:
|
||||
|
||||
void swap(basic_vectorbuf &that)
|
||||
{
|
||||
using std::swap;
|
||||
std::basic_streambuf<CharT, Traits>::swap(that);
|
||||
std::swap(m_mode, that.m_mode);
|
||||
m_storage.swap(that.m_storage);
|
||||
std::swap(m_threshold, that.m_threshold);
|
||||
swap(m_mode, that.m_mode);
|
||||
swap(m_storage, that.m_storage);
|
||||
swap(m_threshold, that.m_threshold);
|
||||
}
|
||||
|
||||
void reserve(typename vector_type::size_type size)
|
||||
@ -382,6 +387,16 @@ typedef basic_ovectorstream<wchar_t> wovectorstream;
|
||||
typedef basic_vectorstream<char> vectorstream;
|
||||
typedef basic_vectorstream<wchar_t> wvectorstream;
|
||||
|
||||
template <typename CharT, typename Traits, typename Allocator>
|
||||
void swap(basic_vectorbuf<CharT, Traits, Allocator> &a, basic_vectorbuf<CharT, Traits, Allocator> &b) { a.swap(b); }
|
||||
|
||||
template <typename CharT, typename Traits, typename Allocator>
|
||||
void swap(basic_ivectorstream<CharT, Traits, Allocator> &a, basic_ivectorstream<CharT, Traits, Allocator> &b) { a.swap(b); }
|
||||
template <typename CharT, typename Traits, typename Allocator>
|
||||
void swap(basic_ovectorstream<CharT, Traits, Allocator> &a, basic_ovectorstream<CharT, Traits, Allocator> &b) { a.swap(b); }
|
||||
template <typename CharT, typename Traits, typename Allocator>
|
||||
void swap(basic_vectorstream<CharT, Traits, Allocator> &a, basic_vectorstream<CharT, Traits, Allocator> &b) { a.swap(b); }
|
||||
|
||||
} // namespace util
|
||||
|
||||
#endif // __MAME_UTIL_VECSTREAM_H__
|
||||
|
@ -721,7 +721,7 @@ static MACHINE_CONFIG_START( tsamurai, tsamurai_state )
|
||||
MCFG_SCREEN_REFRESH_RATE(60)
|
||||
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
|
||||
MCFG_SCREEN_SIZE(32*8, 32*8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 16, 255-16)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(tsamurai_state, screen_update)
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
@ -762,7 +762,7 @@ static MACHINE_CONFIG_START( vsgongf, tsamurai_state )
|
||||
MCFG_SCREEN_REFRESH_RATE(60)
|
||||
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
|
||||
MCFG_SCREEN_SIZE(32*8, 32*8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 16, 255-16)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(tsamurai_state, screen_update_vsgongf)
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
@ -807,7 +807,7 @@ static MACHINE_CONFIG_START( m660, tsamurai_state )
|
||||
MCFG_SCREEN_REFRESH_RATE(60)
|
||||
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
|
||||
MCFG_SCREEN_SIZE(32*8, 32*8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0, 255, 16, 255-16)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(tsamurai_state, screen_update)
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
|
3986
src/mame/mame.lst
3986
src/mame/mame.lst
File diff suppressed because it is too large
Load Diff
@ -374,7 +374,7 @@ int igs017_igs031_device::debug_viewer(bitmap_ind16 &bitmap,const rectangle &cli
|
||||
popmessage("a: %08X w: %03X p: %02x-%02x-%02x",a,w,m_sprites_gfx[a/3*3+0],m_sprites_gfx[a/3*3+1],m_sprites_gfx[a/3*3+2]);
|
||||
m_debug_addr = a;
|
||||
m_debug_width = w;
|
||||
osd_sleep(200000);
|
||||
osd_sleep(osd_ticks_per_second() / 1000 * 200);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -284,23 +284,4 @@ _count_leading_ones(UINT32 value)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
INLINE TIMING FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
get_profile_ticks - return a tick counter
|
||||
from the processor that can be used for
|
||||
profiling. It does not need to run at any
|
||||
particular rate.
|
||||
-------------------------------------------------*/
|
||||
|
||||
#define get_profile_ticks _get_profile_ticks
|
||||
static inline INT64 ATTR_UNUSED ATTR_FORCE_INLINE _get_profile_ticks(void)
|
||||
{
|
||||
// fix me - should use the time base
|
||||
return osd_ticks();
|
||||
}
|
||||
|
||||
#endif /* __EIGCCPPC__ */
|
||||
|
@ -521,40 +521,4 @@ _count_leading_ones(UINT32 value)
|
||||
return result;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
INLINE TIMING FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
get_profile_ticks - return a tick counter
|
||||
from the processor that can be used for
|
||||
profiling. It does not need to run at any
|
||||
particular rate.
|
||||
-------------------------------------------------*/
|
||||
|
||||
#define get_profile_ticks _get_profile_ticks
|
||||
|
||||
#ifndef __x86_64__
|
||||
static inline UINT64 ATTR_UNUSED ATTR_FORCE_INLINE _get_profile_ticks(void)
|
||||
{
|
||||
UINT64 result;
|
||||
__asm__ __volatile__ (
|
||||
"rdtsc"
|
||||
: "=A" (result)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static inline UINT64 ATTR_UNUSED ATTR_FORCE_INLINE _get_profile_ticks(void)
|
||||
{
|
||||
_x86_union r;
|
||||
__asm__ __volatile__ (
|
||||
"rdtsc"
|
||||
: "=a" (r.u32.l), "=d" (r.u32.h)
|
||||
);
|
||||
|
||||
return (UINT64) r.u64;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __EIGCCX86__ */
|
||||
|
@ -460,45 +460,4 @@ static inline UINT8 _count_leading_ones(UINT32 value)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
INLINE TIMING FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
get_profile_ticks - return a tick counter
|
||||
from the processor that can be used for
|
||||
profiling. It does not need to run at any
|
||||
particular rate.
|
||||
-------------------------------------------------*/
|
||||
|
||||
#define get_profile_ticks _get_profile_ticks
|
||||
|
||||
#ifdef PTR64
|
||||
|
||||
static inline osd_ticks_t _get_profile_ticks(void)
|
||||
{
|
||||
return __rdtsc();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline osd_ticks_t _get_profile_ticks(void)
|
||||
{
|
||||
UINT64 result;
|
||||
UINT64 *presult = &result;
|
||||
|
||||
__asm {
|
||||
__asm _emit 0Fh __asm _emit 031h // rdtsc
|
||||
mov ebx, presult
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edx
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __EIVCX86__ */
|
||||
|
@ -317,7 +317,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
|
||||
mainQtWindow->setProcessor(&device);
|
||||
|
||||
// Run our own QT event loop
|
||||
osd_sleep(50000);
|
||||
osd_sleep(osd_ticks_per_second() / 1000 * 50);
|
||||
qApp->processEvents(QEventLoop::AllEvents, 1);
|
||||
|
||||
// Refresh everyone if requested
|
||||
|
@ -14,11 +14,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <mach/mach_traps.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
// MAME headers
|
||||
#include "osdcore.h"
|
||||
#include "osdlib.h"
|
||||
@ -54,30 +49,6 @@ void osd_process_kill(void)
|
||||
kill(getpid(), SIGKILL);
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_num_processors
|
||||
//============================================================
|
||||
|
||||
int osd_get_num_processors(void)
|
||||
{
|
||||
int processors = 1;
|
||||
|
||||
struct host_basic_info host_basic_info;
|
||||
unsigned int count;
|
||||
kern_return_t r;
|
||||
mach_port_t my_mach_host_self;
|
||||
|
||||
count = HOST_BASIC_INFO_COUNT;
|
||||
my_mach_host_self = mach_host_self();
|
||||
if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS )
|
||||
{
|
||||
processors = host_basic_info.avail_cpus;
|
||||
}
|
||||
mach_port_deallocate(mach_task_self(), my_mach_host_self);
|
||||
|
||||
return processors;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_malloc
|
||||
//============================================================
|
||||
@ -166,120 +137,3 @@ void osd_break_into_debugger(const char *message)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// PROTOTYPES
|
||||
//============================================================
|
||||
|
||||
static osd_ticks_t init_cycle_counter(void);
|
||||
static osd_ticks_t mach_cycle_counter(void);
|
||||
|
||||
//============================================================
|
||||
// STATIC VARIABLES
|
||||
//============================================================
|
||||
|
||||
static osd_ticks_t (*cycle_counter)(void) = init_cycle_counter;
|
||||
static osd_ticks_t (*ticks_counter)(void) = init_cycle_counter;
|
||||
static osd_ticks_t ticks_per_second;
|
||||
|
||||
//============================================================
|
||||
// init_cycle_counter
|
||||
//
|
||||
// to avoid total grossness, this function is split by subarch
|
||||
//============================================================
|
||||
|
||||
static osd_ticks_t init_cycle_counter(void)
|
||||
{
|
||||
osd_ticks_t start, end;
|
||||
osd_ticks_t a, b;
|
||||
|
||||
cycle_counter = mach_cycle_counter;
|
||||
ticks_counter = mach_cycle_counter;
|
||||
|
||||
// wait for an edge on the timeGetTime call
|
||||
a = SDL_GetTicks();
|
||||
do
|
||||
{
|
||||
b = SDL_GetTicks();
|
||||
} while (a == b);
|
||||
|
||||
// get the starting cycle count
|
||||
start = (*cycle_counter)();
|
||||
|
||||
// now wait for 1/4 second total
|
||||
do
|
||||
{
|
||||
a = SDL_GetTicks();
|
||||
} while (a - b < 250);
|
||||
|
||||
// get the ending cycle count
|
||||
end = (*cycle_counter)();
|
||||
|
||||
// compute ticks_per_sec
|
||||
ticks_per_second = (end - start) * 4;
|
||||
|
||||
// return the current cycle count
|
||||
return (*cycle_counter)();
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// performance_cycle_counter
|
||||
//============================================================
|
||||
|
||||
//============================================================
|
||||
// mach_cycle_counter
|
||||
//============================================================
|
||||
static osd_ticks_t mach_cycle_counter(void)
|
||||
{
|
||||
return mach_absolute_time();
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_ticks
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks(void)
|
||||
{
|
||||
return (*cycle_counter)();
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks_per_second
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks_per_second(void)
|
||||
{
|
||||
if (ticks_per_second == 0)
|
||||
{
|
||||
// if we haven't computed the value yet, there's no time like the present
|
||||
init_cycle_counter();
|
||||
}
|
||||
return ticks_per_second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_sleep
|
||||
//============================================================
|
||||
|
||||
void osd_sleep(osd_ticks_t duration)
|
||||
{
|
||||
UINT32 msec;
|
||||
|
||||
// make sure we've computed ticks_per_second
|
||||
if (ticks_per_second == 0)
|
||||
(void)osd_ticks();
|
||||
|
||||
// convert to milliseconds, rounding down
|
||||
msec = (UINT32)(duration * 1000 / ticks_per_second);
|
||||
|
||||
// only sleep if at least 2 full milliseconds
|
||||
if (msec >= 2)
|
||||
{
|
||||
// take a couple of msecs off the top for good measure
|
||||
msec -= 2;
|
||||
usleep(msec*1000);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef SDLMAME_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
@ -50,20 +49,6 @@ void osd_process_kill(void)
|
||||
kill(getpid(), SIGKILL);
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_num_processors
|
||||
//============================================================
|
||||
|
||||
int osd_get_num_processors(void)
|
||||
{
|
||||
int processors = 1;
|
||||
|
||||
#if defined(_SC_NPROCESSORS_ONLN)
|
||||
processors = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#endif
|
||||
return processors;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_malloc
|
||||
//============================================================
|
||||
@ -150,53 +135,3 @@ void osd_break_into_debugger(const char *message)
|
||||
printf("Ignoring MAME exception: %s\n", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks(void)
|
||||
{
|
||||
#ifdef SDLMAME_EMSCRIPTEN
|
||||
return (osd_ticks_t)(emscripten_get_now() * 1000.0);
|
||||
#else
|
||||
struct timeval tp;
|
||||
static osd_ticks_t start_sec = 0;
|
||||
|
||||
gettimeofday(&tp, NULL);
|
||||
if (start_sec==0)
|
||||
start_sec = tp.tv_sec;
|
||||
return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks_per_second
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks_per_second(void)
|
||||
{
|
||||
return (osd_ticks_t) 1000000;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_sleep
|
||||
//============================================================
|
||||
|
||||
void osd_sleep(osd_ticks_t duration)
|
||||
{
|
||||
UINT32 msec;
|
||||
|
||||
// convert to milliseconds, rounding down
|
||||
msec = (UINT32)(duration * 1000 / osd_ticks_per_second());
|
||||
|
||||
// only sleep if at least 2 full milliseconds
|
||||
if (msec >= 2)
|
||||
{
|
||||
// take a couple of msecs off the top for good measure
|
||||
msec -= 2;
|
||||
usleep(msec*1000);
|
||||
}
|
||||
}
|
||||
|
@ -100,21 +100,6 @@ void osd_process_kill(void)
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_num_processors
|
||||
//============================================================
|
||||
|
||||
int osd_get_num_processors(void)
|
||||
{
|
||||
SYSTEM_INFO info;
|
||||
|
||||
// otherwise, fetch the info from the system
|
||||
GetSystemInfo(&info);
|
||||
|
||||
// max out at 4 for now since scaling above that seems to do poorly
|
||||
return MIN(info.dwNumberOfProcessors, 4);
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_malloc
|
||||
//============================================================
|
||||
@ -256,94 +241,3 @@ void osd_break_into_debugger(const char *message)
|
||||
#endif
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// GLOBAL VARIABLES
|
||||
//============================================================
|
||||
|
||||
static osd_ticks_t ticks_per_second = 0;
|
||||
static osd_ticks_t suspend_ticks = 0;
|
||||
static BOOL using_qpc = TRUE;
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks(void)
|
||||
{
|
||||
LARGE_INTEGER performance_count;
|
||||
|
||||
// if we're suspended, just return that
|
||||
if (suspend_ticks != 0)
|
||||
return suspend_ticks;
|
||||
|
||||
// if we have a per second count, just go for it
|
||||
if (ticks_per_second != 0)
|
||||
{
|
||||
// QueryPerformanceCounter if we can
|
||||
if (using_qpc)
|
||||
{
|
||||
QueryPerformanceCounter(&performance_count);
|
||||
return (osd_ticks_t)performance_count.QuadPart - suspend_ticks;
|
||||
}
|
||||
|
||||
// otherwise, fall back to timeGetTime
|
||||
else
|
||||
return (osd_ticks_t)timeGetTime() - suspend_ticks;
|
||||
}
|
||||
|
||||
// if not, we have to determine it
|
||||
using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0);
|
||||
if (using_qpc)
|
||||
ticks_per_second = (osd_ticks_t)performance_count.QuadPart;
|
||||
else
|
||||
ticks_per_second = 1000;
|
||||
|
||||
// call ourselves to get the first value
|
||||
return osd_ticks();
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks_per_second
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks_per_second(void)
|
||||
{
|
||||
if (ticks_per_second == 0)
|
||||
osd_ticks();
|
||||
return ticks_per_second;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_sleep
|
||||
//============================================================
|
||||
|
||||
void osd_sleep(osd_ticks_t duration)
|
||||
{
|
||||
DWORD msec;
|
||||
|
||||
// make sure we've computed ticks_per_second
|
||||
if (ticks_per_second == 0)
|
||||
(void)osd_ticks();
|
||||
|
||||
// convert to milliseconds, rounding down
|
||||
msec = (DWORD)(duration * 1000 / ticks_per_second);
|
||||
|
||||
// only sleep if at least 2 full milliseconds
|
||||
if (msec >= 2)
|
||||
{
|
||||
HANDLE current_thread = GetCurrentThread();
|
||||
int old_priority = GetThreadPriority(current_thread);
|
||||
|
||||
// take a couple of msecs off the top for good measure
|
||||
msec -= 2;
|
||||
|
||||
// bump our thread priority super high so that we get
|
||||
// priority when we need it
|
||||
SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
Sleep(msec);
|
||||
SetThreadPriority(current_thread, old_priority);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// copyright-holders:Aaron Giles
|
||||
|
||||
#include "osdcore.h"
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
static const int MAXSTACK = 10;
|
||||
static osd_output *m_stack[MAXSTACK];
|
||||
@ -141,3 +143,41 @@ void CLIB_DECL osd_printf_log(const char *format, ...)
|
||||
va_end(argptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//============================================================
|
||||
// osd_ticks
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks(void)
|
||||
{
|
||||
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// osd_ticks_per_second
|
||||
//============================================================
|
||||
|
||||
osd_ticks_t osd_ticks_per_second(void)
|
||||
{
|
||||
return std::chrono::high_resolution_clock::period::den;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_sleep
|
||||
//============================================================
|
||||
|
||||
void osd_sleep(osd_ticks_t duration)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::high_resolution_clock::duration(duration));
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// osd_num_processors
|
||||
//============================================================
|
||||
|
||||
int osd_get_num_processors(void)
|
||||
{
|
||||
// max out at 4 for now since scaling above that seems to do poorly
|
||||
return MIN(std::thread::hardware_concurrency(), 4);
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ static void sdlwindow_sync(void)
|
||||
while (!osd_work_queue_wait(work_queue, osd_ticks_per_second()*10))
|
||||
{
|
||||
osd_printf_warning("sdlwindow_sync: Sleeping...\n");
|
||||
osd_sleep(100000);
|
||||
osd_sleep(osd_ticks_per_second() / 1000 * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user