mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
bus/generic/slot.h: Added a variant of the non-power-of-two installer function that generates a decode mask.
This commit is contained in:
parent
e61c2a92a2
commit
bdf8aebac2
@ -77,7 +77,6 @@ void flat_ram_device_base<Base>::install_ram()
|
||||
nvrambytes,
|
||||
0x1fff,
|
||||
0,
|
||||
0,
|
||||
0xa000,
|
||||
[this, nvrambase] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
@ -111,7 +110,6 @@ void flat_ram_device_base<Base>::install_ram()
|
||||
rambytes,
|
||||
0x1fff,
|
||||
0,
|
||||
0,
|
||||
0xa000,
|
||||
[this, rambase] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
@ -131,7 +129,6 @@ void flat_ram_device_base<Base>::install_ram()
|
||||
rambytes,
|
||||
nvrambytes - 1,
|
||||
0,
|
||||
0,
|
||||
0xa000 | nvrambytes,
|
||||
[this, rambase, highmirror = 0x1fff & ~(nvrambytes | (nvrambytes - 1))] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
@ -353,7 +350,6 @@ void mbc_ram_device_base<Base>::install_ram(
|
||||
nvrambytes ? nvrambytes : rambytes,
|
||||
PAGE_RAM_SIZE - 1,
|
||||
0,
|
||||
0,
|
||||
0xa000,
|
||||
[this, rospace, rwspace, base = nvrambase ? nvrambase : rambase] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
|
@ -479,7 +479,6 @@ void mbc6_device::install_ram()
|
||||
nvrambytes ? nvrambytes : rambytes,
|
||||
PAGE_RAM_SIZE - 1,
|
||||
0,
|
||||
0,
|
||||
0xa000,
|
||||
[this, base = nvrambase ? nvrambase : rambase] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
|
@ -330,7 +330,6 @@ public:
|
||||
bytes,
|
||||
0x7fff,
|
||||
0,
|
||||
0,
|
||||
0x0000,
|
||||
[this, base = &romregion->as_u8()] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
|
@ -63,6 +63,33 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: find a better home for this helper
|
||||
template <unsigned Shift, typename T>
|
||||
static void install_non_power_of_two(
|
||||
offs_t length,
|
||||
offs_t decode_limit,
|
||||
offs_t decode_offset,
|
||||
offs_t base,
|
||||
T &&install)
|
||||
{
|
||||
offs_t decode_mask(length - 1);
|
||||
for (unsigned i = 31 - count_leading_zeros_32(decode_mask); 0U < i; --i)
|
||||
{
|
||||
if (!BIT(decode_mask, i - 1))
|
||||
{
|
||||
decode_mask &= ~((offs_t(1) << i) - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
install_non_power_of_two<Shift, T>(
|
||||
length,
|
||||
decode_limit,
|
||||
decode_mask,
|
||||
decode_offset,
|
||||
base,
|
||||
std::forward<T>(install));
|
||||
}
|
||||
|
||||
// TODO: find a better home for this helper
|
||||
template <typename T, typename U>
|
||||
static T map_non_power_of_two(T count, U &&map)
|
||||
@ -72,7 +99,7 @@ public:
|
||||
|
||||
T const max(count - 1);
|
||||
T mask(max);
|
||||
for (unsigned i = 1; (sizeof(T) * 8) > i; i <<= 1)
|
||||
for (unsigned i = 1U; (sizeof(T) * 8) > i; i <<= 1)
|
||||
mask = T(std::make_unsigned_t<T>(mask) | (std::make_unsigned_t<T>(mask) >> i));
|
||||
int bits(0);
|
||||
while (BIT(mask, bits))
|
||||
|
@ -62,7 +62,6 @@ std::error_condition vboy_flat_rom_device::load()
|
||||
romregion->bytes() >> 2,
|
||||
0x00ff'ffff >> 2,
|
||||
0,
|
||||
0,
|
||||
rom_base(),
|
||||
[this, rom = &romregion->as_u32()] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
@ -118,7 +117,6 @@ std::error_condition vboy_flat_rom_sram_device::load()
|
||||
sramregion->bytes() >> 1,
|
||||
0x00ff'ffff >> 2,
|
||||
0,
|
||||
0,
|
||||
chip_base(),
|
||||
[this, sramregion] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
@ -151,7 +149,6 @@ std::error_condition vboy_flat_rom_sram_device::load()
|
||||
sramregion->bytes() >> 2,
|
||||
0x00ff'ffff >> 2,
|
||||
0,
|
||||
0,
|
||||
chip_base(),
|
||||
[this, sramregion] (offs_t begin, offs_t end, offs_t mirror, offs_t src)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user