summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/src/main.lua15
-rw-r--r--src/emu/schedule.cpp181
-rw-r--r--src/emu/schedule.h74
-rw-r--r--src/lib/util/endianness.h46
-rw-r--r--src/mame/drivers/macquadra700.cpp26
-rw-r--r--src/mame/drivers/sun2.cpp8
-rw-r--r--src/mame/drivers/sun3.cpp10
-rw-r--r--src/mame/drivers/sun3x.cpp8
-rw-r--r--src/mame/drivers/targeth.cpp4
-rw-r--r--src/mame/drivers/thoop2.cpp4
-rw-r--r--src/mame/drivers/twins.cpp10
-rw-r--r--src/mame/drivers/ultrsprt.cpp12
-rw-r--r--src/mame/drivers/wrally.cpp4
-rw-r--r--src/mame/machine/gaelco2.cpp4
-rw-r--r--src/mame/machine/kaneko_toybox.cpp8
-rw-r--r--src/mame/video/beathead.cpp28
-rw-r--r--src/mame/video/mac.cpp20
-rw-r--r--src/mame/video/psikyo.cpp22
-rw-r--r--src/mame/video/psikyo4.cpp14
-rw-r--r--src/mame/video/psikyosh.cpp19
-rw-r--r--src/mame/video/rungun.cpp11
-rw-r--r--src/mame/video/segas32.cpp4
-rw-r--r--src/mame/video/taitojc.cpp60
23 files changed, 335 insertions, 257 deletions
diff --git a/scripts/src/main.lua b/scripts/src/main.lua
index ec19bc578f6..12e42834cd0 100644
--- a/scripts/src/main.lua
+++ b/scripts/src/main.lua
@@ -215,6 +215,14 @@ end
GEN_DIR .. "resource",
}
+ configuration { "vs20*"}
+ -- See https://github.com/bkaradzic/GENie/issues/544
+ includedirs {
+ MAME_DIR .. "scripts/resources/windows/" .. _target,
+ GEN_DIR .. "resource",
+ }
+ configuration { }
+
if (STANDALONE==true) then
standalone();
@@ -256,6 +264,12 @@ if (STANDALONE~=true) then
resincludedirs {
MAME_DIR .. "scripts/resources/windows/mame",
}
+ configuration { "vs20*"}
+ -- See https://github.com/bkaradzic/GENie/issues/544
+ includedirs {
+ MAME_DIR .. "scripts/resources/windows/mame",
+ }
+ configuration { }
end
local mainfile = MAME_DIR .. "src/" .. _target .. "/" .. _subtarget .. ".cpp"
@@ -353,6 +367,7 @@ if (STANDALONE~=true) then
{ "$(OBJDIR)/" .. _target .. "_" .. _subtarget .. "_vers.res", rcincfile, true },
}
prebuildcommands {
+ "mkdir \"" .. path.translate(GEN_DIR .. "resource/", "\\") .. "\" 2>NUL",
"mkdir \"" .. path.translate(GEN_DIR .. _target .. "/" .. _subtarget .. "/", "\\") .. "\" 2>NUL",
"@echo Emitting " .. _target .. "_" .. _subtarget .. "_vers.rc" .. "...",
PYTHON .. " \"" .. path.translate(MAME_DIR .. "scripts/build/verinfo.py", "\\") .. "\" -f rc -t " .. _target .. " -s " .. _subtarget .. " -e " .. exename .. " -o \"" .. path.translate(rcversfile) .. "\" -r \"" .. path.translate(rcincfile, "\\") .. "\" \"" .. path.translate(GEN_DIR .. "version.cpp", "\\") .. "\"",
diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp
index 4605dbb82de..52a2b84d2f3 100644
--- a/src/emu/schedule.cpp
+++ b/src/emu/schedule.cpp
@@ -44,8 +44,8 @@ enum
// emu_timer - constructor
//-------------------------------------------------
-emu_timer::emu_timer() :
- m_machine(nullptr),
+inline emu_timer::emu_timer() noexcept :
+ m_scheduler(nullptr),
m_next(nullptr),
m_prev(nullptr),
m_param(0),
@@ -72,7 +72,7 @@ emu_timer::~emu_timer()
// re-allocated as a non-device timer
//-------------------------------------------------
-emu_timer &emu_timer::init(
+inline emu_timer &emu_timer::init(
running_machine &machine,
timer_expired_delegate &&callback,
attotime start_delay,
@@ -80,7 +80,7 @@ emu_timer &emu_timer::init(
bool temporary)
{
// ensure the entire timer state is clean
- m_machine = &machine;
+ m_scheduler = &machine.scheduler();
m_next = nullptr;
m_prev = nullptr;
m_callback = std::move(callback);
@@ -88,43 +88,31 @@ emu_timer &emu_timer::init(
m_temporary = temporary;
m_period = attotime::never;
- device_scheduler &scheduler = machine.scheduler();
- m_start = scheduler.time();
+ m_start = m_scheduler->time();
m_expire = m_start + start_delay;
m_enabled = !m_expire.is_never();
// if we're not temporary, register ourselves with the save state system
if (!m_temporary)
- register_save();
+ register_save(machine.save());
// insert into the list
- scheduler.timer_list_insert(*this);
- if (this == scheduler.first_timer())
- scheduler.abort_timeslice();
+ m_scheduler->timer_list_insert(*this);
+ if (this == m_scheduler->first_timer())
+ m_scheduler->abort_timeslice();
return *this;
}
//-------------------------------------------------
-// release - release us from the global list
-// management when deallocating
-//-------------------------------------------------
-
-inline emu_timer &emu_timer::release()
-{
- // unhook us from the global list
- machine().scheduler().timer_list_remove(*this);
- return *this;
-}
-
-
-//-------------------------------------------------
// enable - enable/disable a timer
//-------------------------------------------------
-bool emu_timer::enable(bool enable)
+bool emu_timer::enable(bool enable) noexcept
{
+ assert(m_scheduler);
+
// reschedule only if the state has changed
const bool old = m_enabled;
if (old != enable)
@@ -133,8 +121,8 @@ bool emu_timer::enable(bool enable)
m_enabled = enable;
// remove the timer and insert back into the list
- machine().scheduler().timer_list_remove(*this);
- machine().scheduler().timer_list_insert(*this);
+ m_scheduler->timer_list_remove(*this);
+ m_scheduler->timer_list_insert(*this);
}
return old;
}
@@ -146,12 +134,13 @@ bool emu_timer::enable(bool enable)
// firings
//-------------------------------------------------
-void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period)
+void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period) noexcept
{
+ assert(m_scheduler);
+
// if this is the callback timer, mark it modified
- device_scheduler &scheduler = machine().scheduler();
- if (scheduler.m_callback_timer == this)
- scheduler.m_callback_timer_modified = true;
+ if (m_scheduler->m_callback_timer == this)
+ m_scheduler->m_callback_timer_modified = true;
// compute the time of the next firing and insert into the list
m_param = param;
@@ -162,17 +151,17 @@ void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period)
start_delay = attotime::zero;
// set the start and expire times
- m_start = scheduler.time();
+ m_start = m_scheduler->time();
m_expire = m_start + start_delay;
m_period = period;
// remove and re-insert the timer in its new order
- scheduler.timer_list_remove(*this);
- scheduler.timer_list_insert(*this);
+ m_scheduler->timer_list_remove(*this);
+ m_scheduler->timer_list_insert(*this);
// if this was inserted as the head, abort the current timeslice and resync
- if (this == scheduler.first_timer())
- scheduler.abort_timeslice();
+ if (this == m_scheduler->first_timer())
+ m_scheduler->abort_timeslice();
}
@@ -183,7 +172,9 @@ void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period)
attotime emu_timer::elapsed() const noexcept
{
- return machine().time() - m_start;
+ assert(m_scheduler);
+
+ return m_scheduler->time() - m_start;
}
@@ -194,7 +185,9 @@ attotime emu_timer::elapsed() const noexcept
attotime emu_timer::remaining() const noexcept
{
- attotime curtime = machine().time();
+ assert(m_scheduler);
+
+ const attotime curtime = m_scheduler->time();
if (curtime >= m_expire)
return attotime::zero;
return m_expire - curtime;
@@ -206,37 +199,37 @@ attotime emu_timer::remaining() const noexcept
// state system
//-------------------------------------------------
-void emu_timer::register_save()
+void emu_timer::register_save(save_manager &manager)
{
// determine our instance number - timers are indexed based on the callback function name
int index = 0;
std::string name = m_callback.name() ? m_callback.name() : "unnamed";
- for (emu_timer *curtimer = machine().scheduler().first_timer(); curtimer != nullptr; curtimer = curtimer->next())
+ for (const emu_timer *curtimer = m_scheduler->first_timer(); curtimer; curtimer = curtimer->m_next)
{
if (!curtimer->m_temporary)
{
- if (curtimer->m_callback.name() != nullptr && m_callback.name() != nullptr && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0)
+ if (curtimer->m_callback.name() && m_callback.name() && !strcmp(curtimer->m_callback.name(), m_callback.name()))
index++;
- else if (curtimer->m_callback.name() == nullptr && m_callback.name() == nullptr)
+ else if (!curtimer->m_callback.name() && !m_callback.name())
index++;
}
}
- for (emu_timer *curtimer = machine().scheduler().m_inactive_timers; curtimer != nullptr; curtimer = curtimer->next())
+ for (const emu_timer *curtimer = m_scheduler->m_inactive_timers; curtimer; curtimer = curtimer->m_next)
{
assert(!curtimer->m_temporary);
- if (curtimer->m_callback.name() != nullptr && m_callback.name() != nullptr && strcmp(curtimer->m_callback.name(), m_callback.name()) == 0)
+ if (curtimer->m_callback.name() && m_callback.name() && !strcmp(curtimer->m_callback.name(), m_callback.name()))
index++;
- else if (curtimer->m_callback.name() == nullptr && m_callback.name() == nullptr)
+ else if (!curtimer->m_callback.name() && !m_callback.name())
index++;
}
// save the bits
- machine().save().save_item(nullptr, "timer", name.c_str(), index, NAME(m_param));
- machine().save().save_item(nullptr, "timer", name.c_str(), index, NAME(m_enabled));
- machine().save().save_item(nullptr, "timer", name.c_str(), index, NAME(m_period));
- machine().save().save_item(nullptr, "timer", name.c_str(), index, NAME(m_start));
- machine().save().save_item(nullptr, "timer", name.c_str(), index, NAME(m_expire));
+ manager.save_item(nullptr, "timer", name.c_str(), index, NAME(m_param));
+ manager.save_item(nullptr, "timer", name.c_str(), index, NAME(m_enabled));
+ manager.save_item(nullptr, "timer", name.c_str(), index, NAME(m_period));
+ manager.save_item(nullptr, "timer", name.c_str(), index, NAME(m_start));
+ manager.save_item(nullptr, "timer", name.c_str(), index, NAME(m_expire));
}
@@ -245,16 +238,17 @@ void emu_timer::register_save()
// period
//-------------------------------------------------
-inline void emu_timer::schedule_next_period()
+inline void emu_timer::schedule_next_period() noexcept
{
+ assert(m_scheduler);
+
// advance by one period
m_start = m_expire;
m_expire += m_period;
// remove and re-insert us
- device_scheduler &scheduler = machine().scheduler();
- scheduler.timer_list_remove(*this);
- scheduler.timer_list_insert(*this);
+ m_scheduler->timer_list_remove(*this);
+ m_scheduler->timer_list_insert(*this);
}
@@ -265,11 +259,13 @@ inline void emu_timer::schedule_next_period()
void emu_timer::dump() const
{
- machine().logerror("%p: en=%d temp=%d exp=%15s start=%15s per=%15s param=%d", this, m_enabled, m_temporary, m_expire.as_string(PRECISION), m_start.as_string(PRECISION), m_period.as_string(PRECISION), m_param);
- if (m_callback.name() == nullptr)
- machine().logerror(" cb=NULL\n");
+ assert(m_scheduler);
+
+ m_scheduler->machine().logerror("%p: en=%d temp=%d exp=%15s start=%15s per=%15s param=%d", this, m_enabled, m_temporary, m_expire.as_string(PRECISION), m_start.as_string(PRECISION), m_period.as_string(PRECISION), m_param);
+ if (!m_callback.name())
+ m_scheduler->machine().logerror(" cb=NULL\n");
else
- machine().logerror(" cb=%s\n", m_callback.name());
+ m_scheduler->machine().logerror(" cb=%s\n", m_callback.name());
}
@@ -319,9 +315,9 @@ device_scheduler::~device_scheduler()
{
// remove all timers
while (m_inactive_timers)
- m_timer_allocator.reclaim(m_inactive_timers->release());
+ m_timer_allocator.reclaim(timer_list_remove(*m_inactive_timers));
while (m_timer_list)
- m_timer_allocator.reclaim(m_timer_list->release());
+ m_timer_allocator.reclaim(timer_list_remove(*m_timer_list));
}
@@ -349,13 +345,15 @@ attotime device_scheduler::time() const noexcept
bool device_scheduler::can_save() const
{
// if any live temporary timers exit, fail
- for (emu_timer *timer = m_timer_list; timer != nullptr; timer = timer->next())
+ for (emu_timer *timer = m_timer_list; timer; timer = timer->m_next)
+ {
if (timer->m_temporary && !timer->expire().is_never())
{
machine().logerror("Failed save state attempt due to anonymous timers:\n");
dump_timers();
return false;
}
+ }
// otherwise, we're good
return true;
@@ -513,7 +511,7 @@ void device_scheduler::timeslice()
// current timeslice
//-------------------------------------------------
-void device_scheduler::abort_timeslice()
+void device_scheduler::abort_timeslice() noexcept
{
if (m_executing_device != nullptr)
m_executing_device->abort_timeslice();
@@ -570,6 +568,40 @@ emu_timer *device_scheduler::timer_alloc(timer_expired_delegate callback)
//-------------------------------------------------
+// timer_set - allocate an anonymous non-device
+// timer and set it to go off after the given
+// amount of time
+//-------------------------------------------------
+
+void device_scheduler::timer_set(const attotime &duration, timer_expired_delegate callback, int param)
+{
+ [[maybe_unused]] emu_timer &timer = m_timer_allocator.alloc()->init(
+ machine(),
+ std::move(callback),
+ duration,
+ param,
+ true);
+ assert(!timer.m_expire.is_never()); // this is not handled
+}
+
+
+//-------------------------------------------------
+// synchronize - allocate an anonymous non-device
+// timer and set it to go off as soon as possible
+//-------------------------------------------------
+
+void device_scheduler::synchronize(timer_expired_delegate callback, int param)
+{
+ m_timer_allocator.alloc()->init(
+ machine(),
+ std::move(callback),
+ attotime::zero,
+ param,
+ true);
+}
+
+
+//-------------------------------------------------
// eat_all_cycles - eat a ton of cycles on all
// CPUs to force a quick exit
//-------------------------------------------------
@@ -613,13 +645,14 @@ void device_scheduler::presave()
void device_scheduler::postload()
{
// remove all timers and make a private list of permanent ones
- simple_list<emu_timer> private_list;
+ emu_timer *private_list = nullptr;
while (m_inactive_timers)
{
emu_timer &timer = *m_inactive_timers;
assert(!timer.m_temporary);
- private_list.append(timer_list_remove(timer));
+ timer_list_remove(timer).m_next = private_list;
+ private_list = &timer;
}
while (m_timer_list->m_next)
{
@@ -630,12 +663,13 @@ void device_scheduler::postload()
assert(!timer.expire().is_never());
// temporary timers go away entirely (except our special never-expiring one)
- m_timer_allocator.reclaim(timer.release());
+ m_timer_allocator.reclaim(timer_list_remove(timer));
}
else
{
// permanent ones get added to our private list
- private_list.append(timer_list_remove(timer));
+ timer_list_remove(timer).m_next = private_list;
+ private_list = &timer;
}
}
@@ -645,9 +679,12 @@ void device_scheduler::postload()
assert(m_timer_list->m_expire.is_never());
// now re-insert them; this effectively re-sorts them by time
- emu_timer *timer;
- while ((timer = private_list.detach_head()) != nullptr)
- timer_list_insert(*timer);
+ while (private_list)
+ {
+ emu_timer &timer = *private_list;
+ private_list = timer.m_next;
+ timer_list_insert(timer);
+ }
m_suspend_changes_pending = true;
rebuild_execute_list();
@@ -768,7 +805,7 @@ inline emu_timer &device_scheduler::timer_list_insert(emu_timer &timer)
{
// loop over the timer list
emu_timer *prevtimer = nullptr;
- for (emu_timer *curtimer = m_timer_list; curtimer; prevtimer = curtimer, curtimer = curtimer->next())
+ for (emu_timer *curtimer = m_timer_list; curtimer; prevtimer = curtimer, curtimer = curtimer->m_next)
{
// if the current list entry expires after us, we should be inserted before it
if (curtimer->m_expire > timer.m_expire)
@@ -887,7 +924,7 @@ inline void device_scheduler::execute_timers()
else
{
// otherwise, remove it now
- m_timer_allocator.reclaim(timer.release());
+ m_timer_allocator.reclaim(timer_list_remove(timer));
}
}
}
@@ -950,7 +987,9 @@ void device_scheduler::dump_timers() const
{
machine().logerror("=============================================\n");
machine().logerror("Timer Dump: Time = %15s\n", time().as_string(PRECISION));
- for (emu_timer *timer = first_timer(); timer != nullptr; timer = timer->next())
+ for (emu_timer *timer = m_timer_list; timer; timer = timer->m_next)
+ timer->dump();
+ for (emu_timer *timer = m_inactive_timers; timer; timer = timer->m_next)
timer->dump();
machine().logerror("=============================================\n");
}
diff --git a/src/emu/schedule.h b/src/emu/schedule.h
index 76b809aff63..926890c9e09 100644
--- a/src/emu/schedule.h
+++ b/src/emu/schedule.h
@@ -36,53 +36,46 @@ typedef named_delegate<void (s32)> timer_expired_delegate;
class emu_timer
{
- friend class device_scheduler;
- friend class simple_list<emu_timer>;
- friend class fixed_allocator<emu_timer>;
-
- // construction/destruction
- emu_timer();
- ~emu_timer();
-
- // allocation and re-use
- emu_timer &init(
- running_machine &machine,
- timer_expired_delegate &&callback,
- attotime start_delay,
- int param,
- bool temporary) ATTR_HOT;
- emu_timer &release();
-
public:
// getters
- emu_timer *next() const { return m_next; }
- running_machine &machine() const noexcept { assert(m_machine != nullptr); return *m_machine; }
- bool enabled() const { return m_enabled; }
- int param() const { return m_param; }
+ bool enabled() const noexcept { return m_enabled; }
+ int param() const noexcept { return m_param; }
// setters
- bool enable(bool enable = true);
- void set_param(int param) { m_param = param; }
+ bool enable(bool enable = true) noexcept;
+ void set_param(int param) noexcept { m_param = param; }
// control
- void reset(const attotime &duration = attotime::never) { adjust(duration, m_param, m_period); }
- void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never);
+ void reset(const attotime &duration = attotime::never) noexcept { adjust(duration, m_param, m_period); }
+ void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never) noexcept;
// timing queries
attotime elapsed() const noexcept;
attotime remaining() const noexcept;
- attotime start() const { return m_start; }
- attotime expire() const { return m_expire; }
- attotime period() const { return m_period; }
+ attotime start() const noexcept { return m_start; }
+ attotime expire() const noexcept { return m_expire; }
+ attotime period() const noexcept { return m_period; }
private:
+ // construction/destruction
+ emu_timer() noexcept;
+ ~emu_timer();
+
+ // allocation and re-use
+ emu_timer &init(
+ running_machine &machine,
+ timer_expired_delegate &&callback,
+ attotime start_delay,
+ int param,
+ bool temporary);
+
// internal helpers
- void register_save();
- void schedule_next_period();
+ void register_save(save_manager &manager) ATTR_COLD;
+ void schedule_next_period() noexcept;
void dump() const;
// internal state
- running_machine * m_machine; // reference to the owning machine
+ device_scheduler * m_scheduler; // reference to the owning machine
emu_timer * m_next; // next timer in order in the list
emu_timer * m_prev; // previous timer in order in the list
timer_expired_delegate m_callback; // callback function
@@ -92,6 +85,10 @@ private:
attotime m_period; // the repeat frequency of the timer
attotime m_start; // time when the timer was started
attotime m_expire; // time when the timer will expire
+
+ friend class device_scheduler;
+ friend class fixed_allocator<emu_timer>;
+ friend class simple_list<emu_timer>; // FIXME: fixed_allocator requires this
};
@@ -110,13 +107,13 @@ public:
// getters
running_machine &machine() const noexcept { return m_machine; }
attotime time() const noexcept;
- emu_timer *first_timer() const { return m_timer_list; }
+ emu_timer *first_timer() const noexcept { return m_timer_list; }
device_execute_interface *currently_executing() const noexcept { return m_executing_device; }
bool can_save() const;
// execution
void timeslice();
- void abort_timeslice();
+ void abort_timeslice() noexcept;
void trigger(int trigid, const attotime &after = attotime::zero);
void boost_interleave(const attotime &timeslice_time, const attotime &boost_duration);
void suspend_resume_changed() { m_suspend_changes_pending = true; }
@@ -124,15 +121,8 @@ public:
// timers, specified by callback/name
emu_timer *timer_alloc(timer_expired_delegate callback);
[[deprecated("timer_set is deprecated; please avoid anonymous timers. Use TIMER_CALLBACK_MEMBER and an allocated emu_timer instead.")]]
- void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0)
- {
- [[maybe_unused]] emu_timer &timer = m_timer_allocator.alloc()->init(machine(), std::move(callback), duration, param, true);
- assert(!timer.m_expire.is_never()); // this is not handled
- }
- void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0)
- {
- m_timer_allocator.alloc()->init(machine(), std::move(callback), attotime::zero, param, true);
- }
+ void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0);
+ void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0);
// debugging
void dump_timers() const;
diff --git a/src/lib/util/endianness.h b/src/lib/util/endianness.h
index d983afe8c6b..aa83421f1d7 100644
--- a/src/lib/util/endianness.h
+++ b/src/lib/util/endianness.h
@@ -38,6 +38,37 @@ enum class endianness
#endif
};
+
+// helper for accessing data adjusted for endianness
+template <typename In, typename Out, endianness Endian>
+class offset_endian_cast
+{
+private:
+ static inline constexpr std::ptrdiff_t SWIZZLE = (sizeof(In) / sizeof(Out)) - 1;
+
+ static_assert(!(sizeof(In) % sizeof(Out)), "input size must be a multiple of output size");
+ static_assert(!((sizeof(In) / sizeof(Out)) & SWIZZLE), "ratio of input size to output size must be a power of two");
+
+ Out *m_ptr;
+ std::ptrdiff_t m_offs;
+
+public:
+ constexpr offset_endian_cast(In *ptr, std::ptrdiff_t offs) noexcept : m_ptr(reinterpret_cast<Out *>(ptr)), m_offs(offs) { }
+
+ constexpr Out &operator[](std::ptrdiff_t i) const noexcept { return m_ptr[(m_offs + i) ^ ((Endian != endianness::native) ? SWIZZLE : 0)]; }
+
+ constexpr offset_endian_cast operator+(std::ptrdiff_t i) const noexcept { return offset_endian_cast(*this) += i; }
+ constexpr offset_endian_cast operator-(std::ptrdiff_t i) const noexcept { return offset_endian_cast(*this) -= i; }
+
+ offset_endian_cast &operator+=(std::ptrdiff_t i) noexcept { m_offs += i; return *this; }
+ offset_endian_cast &operator-=(std::ptrdiff_t i) noexcept { m_offs -= i; return *this; }
+ offset_endian_cast &operator++() noexcept { ++m_offs; return *this; }
+ offset_endian_cast &operator--() noexcept { --m_offs; return *this; }
+ offset_endian_cast operator++(int) noexcept { offset_endian_cast result(*this); ++m_offs; return result; }
+ offset_endian_cast operator--(int) noexcept { offset_endian_cast result(*this); --m_offs; return result; }
+};
+
+
// helper for accessing data adjusted for endianness
template <typename In, typename Out, endianness Endian>
class endian_cast
@@ -54,9 +85,24 @@ public:
constexpr endian_cast(In *ptr) noexcept : m_ptr(reinterpret_cast<Out *>(ptr)) { }
constexpr Out &operator[](std::ptrdiff_t i) const noexcept { return m_ptr[i ^ ((Endian != endianness::native) ? SWIZZLE : 0)]; }
+
+ constexpr auto operator+(std::ptrdiff_t offs) const noexcept
+ {
+ using required_const = std::conditional_t<std::is_const_v<Out>, std::add_const_t<In>, In>;
+ using required_cv = std::conditional_t<std::is_volatile_v<Out>, std::add_volatile<required_const>, required_const>;
+ return offset_endian_cast<required_cv, Out, Endian>(reinterpret_cast<required_cv *>(m_ptr), offs);
+ }
+
+ constexpr auto operator-(std::ptrdiff_t offs) const noexcept
+ {
+ using required_const = std::conditional_t<std::is_const_v<Out>, std::add_const_t<In>, In>;
+ using required_cv = std::conditional_t<std::is_volatile_v<Out>, std::add_volatile<required_const>, required_const>;
+ return offset_endian_cast<required_cv, Out, Endian>(reinterpret_cast<required_cv *>(m_ptr), -offs);
+ }
};
+
//**************************************************************************
// MACROS AND INLINE FUNCTIONS
//**************************************************************************
diff --git a/src/mame/drivers/macquadra700.cpp b/src/mame/drivers/macquadra700.cpp
index 82e9d692cc5..d9b0ea00c91 100644
--- a/src/mame/drivers/macquadra700.cpp
+++ b/src/mame/drivers/macquadra700.cpp
@@ -550,19 +550,18 @@ void macquadra_state::dafb_dac_w(offs_t offset, uint32_t data, uint32_t mem_mask
uint32_t macquadra_state::screen_update_dafb(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
+ auto const vram8 = util::big_endian_cast<uint8_t const>(m_vram.target()) + m_dafb_base;
+
switch (m_dafb_mode)
{
case 0: // 1bpp
{
- uint8_t const *vram8 = (uint8_t *)m_vram.target();
- vram8 += m_dafb_base;
-
for (int y = 0; y < 870; y++)
{
uint32_t *scanline = &bitmap.pix(y);
- for (int x = 0; x < 1152; x+=8)
+ for (int x = 0; x < 1152/8; x++)
{
- uint8_t const pixels = vram8[(y * m_dafb_stride) + ((x/8)^3)];
+ uint8_t const pixels = vram8[(y * m_dafb_stride) + x];
*scanline++ = m_dafb_palette[(pixels>>7)&1];
*scanline++ = m_dafb_palette[(pixels>>6)&1];
@@ -579,15 +578,12 @@ uint32_t macquadra_state::screen_update_dafb(screen_device &screen, bitmap_rgb32
case 1: // 2bpp
{
- uint8_t const *vram8 = (uint8_t *)m_vram.target();
- vram8 += m_dafb_base;
-
for (int y = 0; y < 870; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152/4; x++)
{
- uint8_t const pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * m_dafb_stride) + x];
*scanline++ = m_dafb_palette[((pixels>>6)&3)];
*scanline++ = m_dafb_palette[((pixels>>4)&3)];
@@ -600,15 +596,12 @@ uint32_t macquadra_state::screen_update_dafb(screen_device &screen, bitmap_rgb32
case 2: // 4bpp
{
- uint8_t const *vram8 = (uint8_t *)m_vram.target();
- vram8 += m_dafb_base;
-
for (int y = 0; y < 870; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152/2; x++)
{
- uint8_t const pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * m_dafb_stride) + x];
*scanline++ = m_dafb_palette[(pixels>>4)];
*scanline++ = m_dafb_palette[(pixels&0xf)];
@@ -619,15 +612,12 @@ uint32_t macquadra_state::screen_update_dafb(screen_device &screen, bitmap_rgb32
case 3: // 8bpp
{
- uint8_t const *vram8 = (uint8_t *)m_vram.target();
- vram8 += m_dafb_base;
-
for (int y = 0; y < 870; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152; x++)
{
- uint8_t const pixels = vram8[(y * m_dafb_stride) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * m_dafb_stride) + x];
*scanline++ = m_dafb_palette[pixels];
}
}
@@ -638,7 +628,7 @@ uint32_t macquadra_state::screen_update_dafb(screen_device &screen, bitmap_rgb32
for (int y = 0; y < 480; y++)
{
uint32_t *scanline = &bitmap.pix(y);
- uint32_t const *base = (uint32_t *)&m_vram[(y * (m_dafb_stride/4)) + (m_dafb_base/4)];
+ uint32_t const *base = &m_vram[(y * (m_dafb_stride/4)) + (m_dafb_base/4)];
for (int x = 0; x < 640; x++)
{
*scanline++ = *base++;
diff --git a/src/mame/drivers/sun2.cpp b/src/mame/drivers/sun2.cpp
index f6b895fd502..f04a211cdbb 100644
--- a/src/mame/drivers/sun2.cpp
+++ b/src/mame/drivers/sun2.cpp
@@ -563,7 +563,7 @@ void sun2_state::vmetype0space_map(address_map &map)
// type 1 device space
void sun2_state::vmetype1space_map(address_map &map)
{
- map(0x000000, 0x01ffff).ram().share("bw2_vram");
+ map(0x000000, 0x01ffff).ram().share(m_bw2_vram);
map(0x020000, 0x020001).rw(FUNC(sun2_state::video_ctrl_r), FUNC(sun2_state::video_ctrl_w));
map(0x7f0000, 0x7f07ff).rom().region("bootprom", 0); // uses MMU loophole to read 32k from a 2k window
map(0x7f0800, 0x7f0800).mirror(0x7fe).rw(FUNC(sun2_state::ethernet_r), FUNC(sun2_state::ethernet_w)).cswidth(16);
@@ -625,7 +625,7 @@ void sun2_state::mbustype3space_map(address_map &map)
uint32_t sun2_state::bw2_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
static const uint32_t palette[2] = { 0, 0xffffff };
- uint8_t const *const m_vram = (uint8_t *)m_bw2_vram.target();
+ auto const vram = util::big_endian_cast<uint8_t const>(m_bw2_vram.target());
if (!(m_bw2_ctrl & 0x8000)) return 0;
@@ -634,7 +634,7 @@ uint32_t sun2_state::bw2_update(screen_device &screen, bitmap_rgb32 &bitmap, con
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152/8; x++)
{
- uint8_t const pixels = m_vram[(y * (1152/8)) + (BYTE_XOR_BE(x))];
+ uint8_t const pixels = vram[(y * (1152 / 8)) + x];
*scanline++ = palette[BIT(pixels, 7)];
*scanline++ = palette[BIT(pixels, 6)];
@@ -662,6 +662,8 @@ void sun2_state::machine_start()
m_ram_size = m_ram->size();
m_ram_size_words = m_ram_size >> 1;
+ m_bw2_ctrl = 0;
+
m_ethernet_status = 0;
}
diff --git a/src/mame/drivers/sun3.cpp b/src/mame/drivers/sun3.cpp
index 4c3b32ad307..703e97e46dd 100644
--- a/src/mame/drivers/sun3.cpp
+++ b/src/mame/drivers/sun3.cpp
@@ -769,7 +769,7 @@ void sun3_state::vmetype0space_map(address_map &map)
{
map(0x00000000, 0x08ffffff).rw(FUNC(sun3_state::ram_r), FUNC(sun3_state::ram_w));
map(0xfe400000, 0xfe41ffff).ram(); // not sure what's going on here (3/110)
- map(0xff000000, 0xff03ffff).ram().share("bw2_vram");
+ map(0xff000000, 0xff03ffff).ram().share(m_bw2_vram);
}
// type 0 without VRAM (3/50)
@@ -905,14 +905,14 @@ template <unsigned W, unsigned H>
uint32_t sun3_state::bw2_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
static const uint32_t palette[2] = { 0, 0xffffff };
- uint8_t const *const m_vram = (uint8_t *)m_bw2_vram.target();
+ auto const vram = util::big_endian_cast<uint8_t const>(m_bw2_vram.target());
for (int y = 0; y < H; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < W/8; x++)
{
- uint8_t const pixels = m_vram[(y * (W/8)) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram[(y * (W / 8)) + x];
*scanline++ = palette[BIT(pixels, 7)];
*scanline++ = palette[BIT(pixels, 6)];
@@ -930,14 +930,14 @@ uint32_t sun3_state::bw2_update(screen_device &screen, bitmap_rgb32 &bitmap, con
uint32_t sun3_state::bw2_350_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
static const uint32_t palette[2] = { 0, 0xffffff };
- uint8_t const *const m_vram = (uint8_t *)&m_ram_ptr[(0x100000>>2)];
+ auto const vram = util::big_endian_cast<uint8_t const>(m_ram_ptr + (0x100000 >> 2));
for (int y = 0; y < 900; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152/8; x++)
{
- uint8_t const pixels = m_vram[(y * (1152/8)) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram[(y * (1152 / 8)) + x];
*scanline++ = palette[BIT(pixels, 7)];
*scanline++ = palette[BIT(pixels, 6)];
diff --git a/src/mame/drivers/sun3x.cpp b/src/mame/drivers/sun3x.cpp
index 74702c6f6fc..05d8f83f66e 100644
--- a/src/mame/drivers/sun3x.cpp
+++ b/src/mame/drivers/sun3x.cpp
@@ -229,7 +229,7 @@ void sun3x_state::sun3_80_mem(address_map &map)
map(0x00000000, 0x03ffffff).ram().share("p_ram").w(FUNC(sun3x_state::ramwrite_w));
map(0x40000000, 0x40000003).rw(FUNC(sun3x_state::cause_buserr_r), FUNC(sun3x_state::cause_buserr_w));
map(0x50300000, 0x50300003).r(FUNC(sun3x_state::p4id_r));
- map(0x50400000, 0x504fffff).ram().share("bw2_vram");
+ map(0x50400000, 0x504fffff).ram().share(m_bw2_vram);
map(0x60000000, 0x60001fff).rw(FUNC(sun3x_state::iommu_r), FUNC(sun3x_state::iommu_w));
map(0x61000000, 0x61000003).rw(FUNC(sun3x_state::enable_r), FUNC(sun3x_state::enable_w));
map(0x61000400, 0x61000403).rw(FUNC(sun3x_state::buserr_r), FUNC(sun3x_state::buserr_w));
@@ -253,7 +253,7 @@ void sun3x_state::sun3_460_mem(address_map &map)
map(0x00000000, 0x03ffffff).ram().share("p_ram").w(FUNC(sun3x_state::ramwrite_w));
map(0x09000000, 0x09000003).rw(FUNC(sun3x_state::cause_buserr_r), FUNC(sun3x_state::cause_buserr_w));
map(0x50300000, 0x50300003).r(FUNC(sun3x_state::p4id_r));
- map(0x50400000, 0x504fffff).ram().share("bw2_vram");
+ map(0x50400000, 0x504fffff).ram().share(m_bw2_vram);
map(0x5c000f14, 0x5c000f17).r(FUNC(sun3x_state::fpa_r));
map(0x60000000, 0x60001fff).rw(FUNC(sun3x_state::iommu_r), FUNC(sun3x_state::iommu_w));
map(0x61000000, 0x61000003).rw(FUNC(sun3x_state::enable_r), FUNC(sun3x_state::enable_w));
@@ -530,14 +530,14 @@ TIMER_DEVICE_CALLBACK_MEMBER(sun3x_state::sun380_timer)
uint32_t sun3x_state::bw2_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
static const uint32_t palette[2] = { 0, 0xffffff };
- uint8_t const *const m_vram = (uint8_t *)m_bw2_vram.target();
+ auto const vram = util::big_endian_cast<uint8_t const>(m_bw2_vram.target());
for (int y = 0; y < 900; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < 1152/8; x++)
{
- uint8_t const pixels = m_vram[(y * (1152/8)) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram[(y * (1152 / 8)) + x];
*scanline++ = palette[BIT(pixels, 7)];
*scanline++ = palette[BIT(pixels, 6)];
diff --git a/src/mame/drivers/targeth.cpp b/src/mame/drivers/targeth.cpp
index 3c520c4d268..a88e6bf1f8e 100644
--- a/src/mame/drivers/targeth.cpp
+++ b/src/mame/drivers/targeth.cpp
@@ -126,13 +126,13 @@ WRITE_LINE_MEMBER(targeth_state::coin2_counter_w)
void targeth_state::shareram_w(offs_t offset, uint8_t data)
{
// why isn't there address map functionality for this?
- reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+ util::big_endian_cast<u8>(m_shareram.target())[offset] = data;
}
uint8_t targeth_state::shareram_r(offs_t offset)
{
// why isn't there address map functionality for this?
- return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+ return util::big_endian_cast<u8 const>(m_shareram.target())[offset];
}
diff --git a/src/mame/drivers/thoop2.cpp b/src/mame/drivers/thoop2.cpp
index f25608f9724..06c52ee8876 100644
--- a/src/mame/drivers/thoop2.cpp
+++ b/src/mame/drivers/thoop2.cpp
@@ -102,13 +102,13 @@ WRITE_LINE_MEMBER(thoop2_state::coin2_counter_w)
void thoop2_state::shareram_w(offs_t offset, uint8_t data)
{
// why isn't there address map functionality for this?
- reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+ util::big_endian_cast<u8>(m_shareram.target())[offset] = data;
}
uint8_t thoop2_state::shareram_r(offs_t offset)
{
// why isn't there address map functionality for this?
- return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+ return util::big_endian_cast<u8 const>(m_shareram.target())[offset];
}
diff --git a/src/mame/drivers/twins.cpp b/src/mame/drivers/twins.cpp
index 65d216ef47c..9e8674009bb 100644
--- a/src/mame/drivers/twins.cpp
+++ b/src/mame/drivers/twins.cpp
@@ -232,13 +232,13 @@ void twins_state::video_start()
void twins_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- uint8_t *videoram = (uint8_t*)m_bgvram.get();
+ auto const videoram = util::little_endian_cast<uint8_t const>(m_bgvram.get());
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
int count = (y * 320) + cliprect.left();
- for(int x = cliprect.left(); x <= cliprect.right(); x++)
- bitmap.pix(y, x) = videoram[BYTE_XOR_LE(count++)];
+ for (int x = cliprect.left(); x <= cliprect.right(); x++)
+ bitmap.pix(y, x) = videoram[count++];
}
}
@@ -251,14 +251,14 @@ uint32_t twins_state::screen_update_twins(screen_device &screen, bitmap_ind16 &b
void spider_state::draw_foreground(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- uint8_t *videoram = (uint8_t*)m_fgvram.get();
+ auto const videoram = util::little_endian_cast<uint8_t const>(m_fgvram.get());
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
int count = (y * 320) + cliprect.left();
for(int x = cliprect.left(); x <= cliprect.right(); x++)
{
- u8 pixel = videoram[BYTE_XOR_LE(count++)];
+ u8 const pixel = videoram[count++];
if (pixel)
bitmap.pix(y, x) = pixel;
}
diff --git a/src/mame/drivers/ultrsprt.cpp b/src/mame/drivers/ultrsprt.cpp
index 247f75da58a..84a64bd5bb6 100644
--- a/src/mame/drivers/ultrsprt.cpp
+++ b/src/mame/drivers/ultrsprt.cpp
@@ -69,7 +69,7 @@ private:
void sound_map(address_map &map);
void main_map(address_map &map);
- std::unique_ptr<u8[]> m_vram;
+ std::unique_ptr<u32[]> m_vram;
u32 m_cpu_vram_page;
};
@@ -78,7 +78,7 @@ private:
u32 ultrsprt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- u8 const *const vram = m_vram.get() + (m_cpu_vram_page ^ 1) * VRAM_PAGE_BYTES;
+ auto const vram = util::big_endian_cast<u8 const>(m_vram.get()) + (m_cpu_vram_page ^ 1) * VRAM_PAGE_BYTES;
for (int y = cliprect.min_y; y <= cliprect.max_y; ++y)
{
@@ -87,10 +87,10 @@ u32 ultrsprt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c
for (int x = cliprect.min_x; x <= cliprect.max_x; ++x)
{
- u8 const p1 = vram[BYTE4_XOR_BE(fb_index + x + 512)];
+ u8 const p1 = vram[fb_index + x + 512];
if (p1 == 0)
- *dest++ = vram[BYTE4_XOR_BE(fb_index + x)];
+ *dest++ = vram[fb_index + x];
else
*dest++ = 0x100 + p1;
}
@@ -224,11 +224,11 @@ void ultrsprt_state::machine_start()
// configure fast RAM regions for DRC
m_maincpu->ppcdrc_add_fastram(0xff000000, 0xff01ffff, false, m_workram);
- m_vram = std::make_unique<u8[]>(VRAM_PAGE_BYTES * VRAM_PAGES);
+ m_vram = std::make_unique<u32[]>(VRAM_PAGE_BYTES / sizeof(u32) * VRAM_PAGES);
m_vrambank->configure_entries(0, VRAM_PAGES, m_vram.get(), VRAM_PAGE_BYTES);
- save_pointer(NAME(m_vram), VRAM_PAGE_BYTES * VRAM_PAGES);
+ save_pointer(NAME(m_vram), VRAM_PAGE_BYTES / sizeof(u32) * VRAM_PAGES);
save_item(NAME(m_cpu_vram_page));
}
diff --git a/src/mame/drivers/wrally.cpp b/src/mame/drivers/wrally.cpp
index c8503826455..766b50285ba 100644
--- a/src/mame/drivers/wrally.cpp
+++ b/src/mame/drivers/wrally.cpp
@@ -155,13 +155,13 @@ void wrally_state::machine_start()
void wrally_state::shareram_w(offs_t offset, uint8_t data)
{
// why isn't there address map functionality for this?
- reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+ util::big_endian_cast<u8>(m_shareram.target())[offset] = data;
}
uint8_t wrally_state::shareram_r(offs_t offset)
{
// why isn't there address map functionality for this?
- return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+ return util::big_endian_cast<u8 const>(m_shareram.target())[offset];
}
void wrally_state::vram_w(offs_t offset, uint16_t data, uint16_t mem_mask)
diff --git a/src/mame/machine/gaelco2.cpp b/src/mame/machine/gaelco2.cpp
index 944af41b8e7..5d8c121a710 100644
--- a/src/mame/machine/gaelco2.cpp
+++ b/src/mame/machine/gaelco2.cpp
@@ -168,13 +168,13 @@ void gaelco2_state::init_wrally2()
void gaelco2_state::shareram_w(offs_t offset, u8 data)
{
// why isn't there address map functionality for this?
- reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+ util::big_endian_cast<u8>(m_shareram.target())[offset] = data;
}
u8 gaelco2_state::shareram_r(offs_t offset)
{
// why isn't there address map functionality for this?
- return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+ return util::big_endian_cast<u8 const>(m_shareram.target())[offset];
}
diff --git a/src/mame/machine/kaneko_toybox.cpp b/src/mame/machine/kaneko_toybox.cpp
index ecc89d04bb3..a092545ac1e 100644
--- a/src/mame/machine/kaneko_toybox.cpp
+++ b/src/mame/machine/kaneko_toybox.cpp
@@ -417,9 +417,8 @@ void kaneko_toybox_device::decrypt_rom()
void kaneko_toybox_device::handle_04_subcommand(uint8_t mcu_subcmd, uint16_t *mcu_ram)
{
- uint8_t* src = (uint8_t *)&m_mcudata[0x10000];
- uint8_t* dst = (uint8_t *)mcu_ram;
- int offs = (mcu_subcmd & 0x3f) * 8;
+ uint8_t const *const src = &m_mcudata[0x10000];
+ int const offs = (mcu_subcmd & 0x3f) * 8;
//uint16_t unused = src[offs + 0] | (src[offs + 1] << 8);
uint16_t romstart = src[offs + 2] | (src[offs + 3] << 8);
@@ -429,9 +428,10 @@ void kaneko_toybox_device::handle_04_subcommand(uint8_t mcu_subcmd, uint16_t *mc
//printf("romstart %04x length %04x\n", romstart, romlength);
+ auto const dst = util::little_endian_cast<uint8_t>(mcu_ram);
for (int x = 0; x < romlength; x++)
{
- dst[BYTE_XOR_LE(ramdest + x)] = src[(romstart + x)];
+ dst[ramdest + x] = src[romstart + x];
}
}
diff --git a/src/mame/video/beathead.cpp b/src/mame/video/beathead.cpp
index 33e3c822bf1..39bde2b0bf6 100644
--- a/src/mame/video/beathead.cpp
+++ b/src/mame/video/beathead.cpp
@@ -143,32 +143,32 @@ void beathead_state::hsync_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask
uint32_t beathead_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- uint8_t *videoram = reinterpret_cast<uint8_t *>(m_videoram.target());
- int x, y;
+ const auto videoram = util::little_endian_cast<const uint8_t>(m_videoram.target());
- /* generate the final screen */
- for (y = cliprect.top(); y <= cliprect.bottom(); y++)
+ // generate the final screen
+ for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
- pen_t pen_base = (*m_palette_select & 0x7f) * 256;
+ const pen_t pen_base = (*m_palette_select & 0x7f) * 256;
uint16_t scanline[336];
- /* blanking */
if (m_finescroll & 8)
- for (x = cliprect.left(); x <= cliprect.right(); x++)
+ {
+ // blanking
+ for (int x = cliprect.left(); x <= cliprect.right(); x++)
scanline[x] = pen_base;
-
- /* non-blanking */
+ }
else
{
- offs_t scanline_offset = m_vram_latch_offset + (m_finescroll & 3);
+ // non-blanking
+ const offs_t scanline_offset = m_vram_latch_offset + (m_finescroll & 3);
offs_t src = scanline_offset + cliprect.left();
- /* unswizzle the scanline first */
- for (x = cliprect.left(); x <= cliprect.right(); x++)
- scanline[x] = pen_base | videoram[BYTE4_XOR_LE(src++)];
+ // unswizzle the scanline first
+ for (int x = cliprect.left(); x <= cliprect.right(); x++)
+ scanline[x] = pen_base | videoram[src++];
}
- /* then draw it */
+ // then draw it
draw_scanline16(bitmap, cliprect.left(), y, cliprect.width(), &scanline[cliprect.left()], nullptr);
}
return 0;
diff --git a/src/mame/video/mac.cpp b/src/mame/video/mac.cpp
index 92d71618c89..a89a18d9f53 100644
--- a/src/mame/video/mac.cpp
+++ b/src/mame/video/mac.cpp
@@ -369,14 +369,14 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
{
case 0: // 1bpp
{
- uint8_t const *const vram8 = (uint8_t *)m_vram.target();
+ auto const vram8 = util::big_endian_cast<uint8_t const>(m_vram.target());
for (int y = 0; y < vres; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < hres; x+=8)
{
- uint8_t const pixels = vram8[(y * 2048) + ((x/8)^3)];
+ uint8_t const pixels = vram8[(y * 2048) + (x / 8)];
*scanline++ = m_rbv_palette[0x7f|(pixels&0x80)];
*scanline++ = m_rbv_palette[0x7f|((pixels<<1)&0x80)];
@@ -393,14 +393,14 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
case 1: // 2bpp
{
- uint8_t const *const vram8 = (uint8_t *)m_vram.target();
+ auto const vram8 = util::big_endian_cast<uint8_t const>(m_vram.target());
for (int y = 0; y < vres; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < hres/4; x++)
{
- uint8_t const pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * 2048) + x];
*scanline++ = m_rbv_palette[0x3f|(pixels&0xc0)];
*scanline++ = m_rbv_palette[0x3f|((pixels<<2)&0xc0)];
@@ -413,7 +413,7 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
case 2: // 4bpp
{
- uint8_t const *const vram8 = (uint8_t *)m_vram.target();
+ auto const vram8 = util::big_endian_cast<uint8_t const>(m_vram.target());
for (int y = 0; y < vres; y++)
{
@@ -421,7 +421,7 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
for (int x = 0; x < hres/2; x++)
{
- uint8_t const pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * 2048) + x];
*scanline++ = m_rbv_palette[0x0f|(pixels&0xf0)];
*scanline++ = m_rbv_palette[0x0f|((pixels<<4)&0xf0)];
@@ -432,7 +432,7 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
case 3: // 8bpp
{
- uint8_t const *const vram8 = (uint8_t *)m_vram.target();
+ auto const vram8 = util::big_endian_cast<uint8_t const>(m_vram.target());
for (int y = 0; y < vres; y++)
{
@@ -440,7 +440,7 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
for (int x = 0; x < hres; x++)
{
- uint8_t const pixels = vram8[(y * 2048) + (BYTE4_XOR_BE(x))];
+ uint8_t const pixels = vram8[(y * 2048) + x];
*scanline++ = m_rbv_palette[pixels];
}
}
@@ -449,14 +449,14 @@ uint32_t mac_state::screen_update_macrbvvram(screen_device &screen, bitmap_rgb32
case 4: // 16bpp
{
- uint16_t const *const vram16 = (uint16_t *)m_vram.target();
+ auto const vram16 = util::big_endian_cast<uint16_t const>(m_vram.target());
for (int y = 0; y < vres; y++)
{
uint32_t *scanline = &bitmap.pix(y);
for (int x = 0; x < hres; x++)
{
- uint16_t const pixels = vram16[(y * 1024) + (x ^ 1)];
+ uint16_t const pixels = vram16[(y * 1024) + x];
*scanline++ = rgb_t(((pixels >> 10) & 0x1f) << 3, ((pixels >> 5) & 0x1f) << 3, (pixels & 0x1f) << 3);
}
}
diff --git a/src/mame/video/psikyo.cpp b/src/mame/video/psikyo.cpp
index c505c1680ce..b91dcba1a83 100644
--- a/src/mame/video/psikyo.cpp
+++ b/src/mame/video/psikyo.cpp
@@ -185,7 +185,7 @@ void psikyo_state::get_sprites()
/* tile layers 0 & 1 have priorities 1 & 2 */
m_sprite_ctrl = m_spriteram->buffer()[0x1ffe / 4] & 0xffff;
static const int pri[] = { 0, 0xfc, 0xff, 0xff };
- const u16 *spritelist = (u16 *)(m_spriteram->buffer() + 0x1800 / 4);
+ const auto spritelist = util::big_endian_cast<const u16>(m_spriteram->buffer() + 0x1800 / 4);
u16 const width = m_screen->width();
u16 const height = m_screen->height();
@@ -198,10 +198,8 @@ void psikyo_state::get_sprites()
/* Look for "end of sprites" marker in the sprites list */
for (int offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2) // skip last "sprite"
{
- int xstart, ystart, xend, yend, xinc, yinc;
-
/* Get next entry in the list */
- u16 sprite = spritelist[BYTE_XOR_BE(offs)];
+ u16 sprite = spritelist[offs];
if (sprite == 0xffff)
break;
@@ -246,9 +244,11 @@ void psikyo_state::get_sprites()
flipy = !flipy;
}
+ int xstart, xend, xinc;
if (flipx) { xstart = nx - 1; xend = -1; xinc = -1; }
else { xstart = 0; xend = nx; xinc = +1; }
+ int ystart, yend, yinc;
if (flipy) { ystart = ny - 1; yend = -1; yinc = -1; }
else { ystart = 0; yend = ny; yinc = +1; }
@@ -292,7 +292,7 @@ void psikyo_state::get_sprites_bootleg()
/* tile layers 0 & 1 have priorities 1 & 2 */
m_sprite_ctrl = m_spriteram->buffer()[0x1ffe / 4] & 0xffff;
static const int pri[] = { 0, 0xfc, 0xff, 0xff };
- const u16 *spritelist = (u16 *)(m_spriteram->buffer() + 0x1800 / 4);
+ const auto spritelist = util::big_endian_cast<const u16>(m_spriteram->buffer() + 0x1800 / 4);
u16 const width = m_screen->width();
u16 const height = m_screen->height();
@@ -305,10 +305,8 @@ void psikyo_state::get_sprites_bootleg()
/* Look for "end of sprites" marker in the sprites list */
for (int offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2) // skip last "sprite"
{
- int xstart, ystart, xend, yend, xinc, yinc;
-
/* Get next entry in the list */
- u16 sprite = spritelist[BYTE_XOR_BE(offs)];
+ u16 sprite = spritelist[offs];
if (sprite == 0xffff)
break;
@@ -353,9 +351,11 @@ void psikyo_state::get_sprites_bootleg()
flipy = !flipy;
}
+ int xstart, xend, xinc;
if (flipx) { xstart = nx - 1; xend = -1; xinc = -1; }
else { xstart = 0; xend = nx; xinc = +1; }
+ int ystart, yend, yinc;
if (flipy) { ystart = ny - 1; yend = -1; yinc = -1; }
else { ystart = 0; yend = ny; yinc = +1; }
@@ -495,9 +495,10 @@ u32 psikyo_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, con
m_tilemap[layer]->set_scroll_rows(0x800);
m_old_linescroll[layer] = (layer_ctrl[layer] & 0x0300);
}
+ const auto vregs = util::big_endian_cast<const u16>(m_vregs.target());
for (i = 0; i < 256; i++) /* 256 screen lines */
{
- int x0 = ((u16 *)m_vregs.target())[BYTE_XOR_BE((layer * 0x200)/2 + (i >> tile_rowscroll))];
+ const int x0 = vregs[(layer * 0x200)/2 + (i >> tile_rowscroll)];
m_tilemap[layer]->set_scrollx(
(i + scrolly[layer]) & 0x7ff,
scrollx[layer] + x0 );
@@ -615,9 +616,10 @@ u32 psikyo_state::screen_update_bootleg(screen_device &screen, bitmap_rgb32 &bit
m_tilemap[layer]->set_scroll_rows(0x800);
m_old_linescroll[layer] = (layer_ctrl[layer] & 0x0300);
}
+ const auto vregs = util::big_endian_cast<const u16>(m_vregs.target());
for (i = 0; i < 256; i++) /* 256 screen lines */
{
- int x0 = ((u16 *)m_vregs.target())[BYTE_XOR_BE((layer * 0x200)/2 + (i >> tile_rowscroll))];
+ const int x0 = vregs[(layer * 0x200)/2 + (i >> tile_rowscroll)];
m_tilemap[layer]->set_scrollx(
(i + scrolly[layer]) & 0x7ff,
scrollx[layer] + x0);
diff --git a/src/mame/video/psikyo4.cpp b/src/mame/video/psikyo4.cpp
index 748ed209456..64a31bf7dc4 100644
--- a/src/mame/video/psikyo4.cpp
+++ b/src/mame/video/psikyo4.cpp
@@ -54,23 +54,23 @@ void psikyo4_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, co
**- End Sprite Format -*/
- gfx_element *gfx = m_gfxdecode->gfx(0);
- uint32_t *source = m_spriteram;
- uint16_t *list = (uint16_t *)m_spriteram.target() + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
- uint16_t listlen = (0xc00/2 - 0x04/2), listcntr = 0;
+ gfx_element *const gfx = m_gfxdecode->gfx(0);
+ uint32_t const *const source = m_spriteram;
+ auto const list = util::big_endian_cast<uint16_t const>(m_spriteram.target() + 0x2c00/4 + 0x04/4); /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
+ uint16_t const listlen = 0xc00/2 - 0x04/2;
+ uint16_t listcntr = 0;
bool const flipscreen = BIT(m_vidregs[1], (scr == 0 ? 31 : 23));
uint16_t const screen_height = screen.visible_area().max_y + 1;
while (listcntr < listlen)
{
- uint16_t const listdat = list[BYTE_XOR_BE(listcntr)];
+ uint16_t const listdat = list[listcntr];
uint16_t const sprnum = (listdat & 0x03ff) * 2;
/* start drawing */
if ((listdat & 0x8000) == 0 && (listdat & 0x2000) == scr) /* draw only selected screen */
{
int loopnum = 0;
- int xstart, ystart, xend, yend, xinc, yinc;
int16_t ypos = (source[sprnum + 0] & 0x03ff0000) >> 16;
int16_t xpos = (source[sprnum + 0] & 0x000003ff) >> 00;
@@ -97,9 +97,11 @@ void psikyo4_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, co
flipy = !flipy;
}
+ int xstart, xend, xinc;
if (flipx) { xstart = wide - 1; xend = -1; xinc = -1; }
else { xstart = 0; xend = wide; xinc = +1; }
+ int ystart, yend, yinc;
if (flipy) { ystart = high - 1; yend = -1; yinc = -1; }
else { ystart = 0; yend = high; yinc = +1; }
diff --git a/src/mame/video/psikyosh.cpp b/src/mame/video/psikyosh.cpp
index 219a70b416e..9bb763311e0 100644
--- a/src/mame/video/psikyosh.cpp
+++ b/src/mame/video/psikyosh.cpp
@@ -893,14 +893,14 @@ void psikyosh_state::get_sprites()
**- End Sprite Format -*/
- const u16 *list = (u16 *)(m_spriteram.target()) + 0x3800 / 2;
+ auto const list = util::big_endian_cast<u16 const>(m_spriteram.target() + 0x3800 / 4);
u16 const listlen = 0x800 / 2;
struct sprite_t *sprite_ptr = m_spritelist.get();
u16 listcntr = 0;
while (listcntr < listlen)
{
- u16 const listdat = list[BYTE_XOR_BE(listcntr)];
+ u16 const listdat = list[listcntr];
u16 const sprnum = (listdat & 0x03ff) * 4;
s32 ypos = (m_spriteram[sprnum + 0] & 0x03ff0000) >> 16;
@@ -948,9 +948,8 @@ void psikyosh_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec
}
#endif
- gfx_element *gfx;
- const u16 *zoom_table = (u16 *)m_zoomram.target();
- const u8 *alpha_table = (u8 *)&(m_vidregs[0]);
+ auto const zoom_table = util::big_endian_cast<u16 const>(m_zoomram.target());
+ auto const alpha_table = util::big_endian_cast<u8 const>(&m_vidregs[0]);
int i = 0;
struct sprite_t *sprite_ptr = m_spritelist.get();
@@ -961,14 +960,14 @@ void psikyosh_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec
// sprite vs backgrounds pri
if (bg_pri == req_pri)
{
- u32 const zoomy = zoom_table[BYTE_XOR_BE(sprite_ptr->zoomy)];
- u32 const zoomx = zoom_table[BYTE_XOR_BE(sprite_ptr->zoomx)];
+ u32 const zoomy = zoom_table[sprite_ptr->zoomy];
+ u32 const zoomx = zoom_table[sprite_ptr->zoomx];
s16 alpha = sprite_ptr->alpha;
- u8 const alphamap = (alpha_table[BYTE4_XOR_BE(alpha)] & 0x80)? 1:0;
- alpha = alpha_table[BYTE4_XOR_BE(alpha)] & 0x3f;
+ bool const alphamap = BIT(alpha_table[alpha], 7);
+ alpha = alpha_table[alpha] & 0x3f;
- gfx = sprite_ptr->dpth ? m_gfxdecode->gfx(1) : m_gfxdecode->gfx(0);
+ gfx_element *const gfx = sprite_ptr->dpth ? m_gfxdecode->gfx(1) : m_gfxdecode->gfx(0);
if (alphamap) /* alpha values are per-pen */
alpha = -1;
diff --git a/src/mame/video/rungun.cpp b/src/mame/video/rungun.cpp
index 6e3e081dc38..4e500c58680 100644
--- a/src/mame/video/rungun.cpp
+++ b/src/mame/video/rungun.cpp
@@ -12,18 +12,17 @@
*************************************************************************/
#include "emu.h"
-
#include "includes/rungun.h"
+
/* TTL text plane stuff */
TILE_GET_INFO_MEMBER(rungun_state::ttl_get_tile_info)
{
- uint32_t base_addr = (uintptr_t)tilemap.user_data();
- uint8_t *lvram = (uint8_t *)m_ttl_vram.get() + base_addr;
- int attr, code;
+ uint32_t const base_addr = uintptr_t(tilemap.user_data());
+ auto const lvram = util::little_endian_cast<uint8_t const>(m_ttl_vram.get()) + base_addr;
- attr = (lvram[BYTE_XOR_LE(tile_index<<2)] & 0xf0) >> 4;
- code = ((lvram[BYTE_XOR_LE(tile_index<<2)] & 0x0f) << 8) | (lvram[BYTE_XOR_LE((tile_index<<2)+2)]);
+ int const attr = (lvram[tile_index << 2] & 0xf0) >> 4;
+ int const code = ((lvram[tile_index << 2] & 0x0f) << 8) | lvram[(tile_index << 2) + 2];
tileinfo.set(m_ttl_gfx_index, code, attr, 0);
}
diff --git a/src/mame/video/segas32.cpp b/src/mame/video/segas32.cpp
index 942b387f578..ffaa12b9bba 100644
--- a/src/mame/video/segas32.cpp
+++ b/src/mame/video/segas32.cpp
@@ -1183,11 +1183,11 @@ void segas32_state::update_bitmap(screen_device &screen, segas32_state::layer_in
/* 8bpp mode case */
if (bpp == 8)
{
- uint8_t const *src = (uint8_t *)&m_videoram[512/2 * ((y + yscroll) & 0xff)];
+ auto const src = util::little_endian_cast<uint8_t const>(&m_videoram[512/2 * ((y + yscroll) & 0xff)]);
for (int x = extents[0]; x < extents[1]; x++)
{
int effx = (x + xscroll) & 0x1ff;
- int pix = src[BYTE_XOR_LE(effx)] + color;
+ int pix = src[effx] + color;
if ((pix & 0xff) == 0)
pix = 0, transparent++;
dst[x] = pix;
diff --git a/src/mame/video/taitojc.cpp b/src/mame/video/taitojc.cpp
index 529d0773e87..7a21426f408 100644
--- a/src/mame/video/taitojc.cpp
+++ b/src/mame/video/taitojc.cpp
@@ -122,42 +122,36 @@ void taitojc_state::taitojc_char_w(offs_t offset, uint32_t data, uint32_t mem_ma
void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect, uint32_t w1, uint32_t w2, uint8_t bank_type)
{
- int x, y, width, height, palette;
- int x1, x2, y1, y2;
- int ix, iy;
- uint32_t address;
- uint8_t *v;
- uint8_t color_depth;
- uint8_t mask_screen;
-
- color_depth = (w2 & 0x10000) >> 16;
- mask_screen = (w2 & 0x20000) >> 17;
-
- address = (w2 & 0x7fff) * 0x20;
- if (w2 & 0x4000)
+ uint8_t const color_depth = (w2 & 0x10000) >> 16;
+ uint8_t const mask_screen = (w2 & 0x20000) >> 17;
+
+ uint32_t address = (w2 & 0x7fff) * 0x20;
+ if(w2 & 0x4000)
address |= 0x40000;
- x = ((w1 >> 0) & 0x3ff);
- if (x & 0x200)
+ int x = ((w1 >> 0) & 0x3ff);
+ if(x & 0x200)
x |= ~0x1ff; // sign-extend
- y = ((w1 >> 16) & 0x3ff);
- if (y & 0x200)
+ int y = ((w1 >> 16) & 0x3ff);
+ if(y & 0x200)
y |= ~0x1ff; // sign-extend
- width = ((w1 >> 10) & 0x3f) * 16;
- height = ((w1 >> 26) & 0x3f) * 16;
- palette = ((w2 >> 22) & 0x7f) << 8;
+ int width = ((w1 >> 10) & 0x3f) * 16;
+ int height = ((w1 >> 26) & 0x3f) * 16;
+ int palette = ((w2 >> 22) & 0x7f) << 8;
/* TODO: untangle this! */
+ uint32_t const *v;
if(address >= 0xff000)
- v = (uint8_t*)&m_objlist[(address-0xff000)/4];
+ v = &m_objlist[(address-0xff000)/4];
if(address >= 0xfc000)
- v = (uint8_t*)&m_char_ram[(address-0xfc000)/4];
+ v = &m_char_ram[(address-0xfc000)/4];
else if(address >= 0xf8000)
- v = (uint8_t*)&m_tile_ram[(address-0xf8000)/4];
+ v = &m_tile_ram[(address-0xf8000)/4];
else
- v = (uint8_t*)&m_vram[address/4];
+ v = &m_vram[address/4];
+ auto const v8 = util::big_endian_cast<u8>(v);
/* guess, but it's probably doable via a vreg ... */
if ((width == 0 || height == 0) && bank_type == 2)
@@ -166,10 +160,10 @@ void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect,
if(width == 0 || height == 0)
return;
- x1 = x;
- x2 = x + width;
- y1 = y;
- y2 = y + height;
+ int x1 = x;
+ int x2 = x + width;
+ int y1 = y;
+ int y2 = y + height;
// trivial rejection
if (x1 > cliprect.max_x || x2 < cliprect.min_x || y1 > cliprect.max_y || y2 < cliprect.min_y)
@@ -179,8 +173,8 @@ void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect,
// osd_printf_debug("draw_object: %08X %08X, X: %d, Y: %d, W: %d, H: %d\n", w1, w2, x, y, width, height);
- ix = 0;
- iy = 0;
+ int ix = 0;
+ int iy = 0;
// clip
if (x1 < cliprect.min_x)
@@ -234,11 +228,11 @@ void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect,
for (int i=x1; i < x2; i+=2)
{
- uint8_t pen = (v[BYTE4_XOR_BE(index)] & 0xf0) >> 4;
+ uint8_t pen = (v8[index] & 0xf0) >> 4;
if (pen != 0)
d[i] = palette + pen;
- pen = (v[BYTE4_XOR_BE(index)] & 0x0f);
+ pen = v8[index] & 0x0f;
if (pen != 0)
d[i+1] = palette + pen;
@@ -258,7 +252,7 @@ void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect,
for (int i=x1; i < x2; i++)
{
- uint8_t pen = v[BYTE4_XOR_BE(index)];
+ uint8_t pen = v8[index];
if (pen != 0)
{
d[i] = palette + pen;