Ejemplo n.º 1
0
void sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const sam_bank *bank, UINT16 offset, UINT16 mask, memory_bank *&memory_bank, INT32 addrstart, INT32 addrend, bool is_write)
{
	char buffer[16];

	if (bank->m_memory != nullptr)
	{
		// normalize offset
		if (mask != 0)
			offset &= mask;

		// this bank is a memory bank - first ensure that we have a bank
		if (!memory_bank || !memory_bank->matches_exactly(addrstart, addrend) || (mask != m_mask))
		{
			// name the bank
			snprintf(buffer, ARRAY_LENGTH(buffer), "bank%04X_%c", addrstart, is_write ? 'w' : 'r');

			// install it
			if (is_write)
				cpu_space().install_write_bank(addrstart, addrend, mask, 0, buffer);
			else
				cpu_space().install_read_bank(addrstart, addrend, mask, 0, buffer);
			m_mask = mask;

			// and get it
			memory_bank = cpu_space().device().owner()->membank(buffer);
		}

		// point the bank
		if (memory_bank != nullptr)
		{
			if (is_write && bank->m_memory_read_only)
				memory_bank->set_base(m_owner.m_dummy);
			else
				memory_bank->set_base(bank->m_memory + offset);
		}
	}
	else
	{
		// this bank uses handlers
		assert((offset == 0) && (mask == 0));   // changes to the offset are not supported

		if (is_write)
		{
			if (!bank->m_whandler.isnull())
				cpu_space().install_write_handler(addrstart, addrend, 0, 0, bank->m_whandler);
		}
		else
		{
			if (!bank->m_rhandler.isnull())
				cpu_space().install_read_handler(addrstart, addrend, 0, 0, bank->m_rhandler);
		}
	}
}
Ejemplo n.º 2
0
void sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const sam_bank *bank, uint32_t offset, uint32_t length, memory_bank *&memory_bank, uint32_t addrstart, uint32_t addrend, bool is_write)
{
	if (bank->m_memory != nullptr)
	{
		// this bank is a memory bank - first lets adjust the length as per the offset; as
		// passed to this method, the length is from offset zero
		if (length != ~0)
			length -= std::min(offset, length);

		// do we even have a bank?  and if so, have legit changes occured?
		if (!memory_bank || !memory_bank->matches_exactly(addrstart, addrend) || (length != m_length))
		{
			// name the bank
			auto tag = string_format("bank%04X_%c", addrstart, is_write ? 'w' : 'r');

			// determine "nop_addrstart" - where the bank ends, and above which is AM_NOP
			uint32_t nop_addrstart = (length != ~0)
				? std::min(addrend + 1, addrstart + length)
				: addrend + 1;

			// install the bank
			if (is_write)
			{
				if (addrstart < nop_addrstart)
					cpu_space().install_write_bank(addrstart, nop_addrstart - 1, 0, tag.c_str());
				if (nop_addrstart <= addrend)
					cpu_space().nop_write(nop_addrstart, addrend);
			}
			else
			{
				if (addrstart < nop_addrstart)
					cpu_space().install_read_bank(addrstart, nop_addrstart - 1, 0, tag.c_str());
				if (nop_addrstart <= addrend)
					cpu_space().nop_read(nop_addrstart, addrend);
			}

			m_length = length;

			// and get it
			memory_bank = cpu_space().device().owner()->membank(tag.c_str());
		}

		// point the bank
		if (memory_bank != nullptr)
		{
			if (is_write && bank->m_memory_read_only)
				memory_bank->set_base(m_owner.m_dummy);
			else
				memory_bank->set_base(bank->m_memory + offset);
		}
	}
	else
	{
		// this bank uses handlers - first thing's first, assert that we are not doing
		// any weird stuff with offfsets and lengths - that isn't supported in this path
		assert((offset == 0) && (length == (uint32_t)~0));

		if (is_write)
		{
			if (!bank->m_whandler.isnull())
				cpu_space().install_write_handler(addrstart, addrend, bank->m_whandler);
		}
		else
		{
			if (!bank->m_rhandler.isnull())
				cpu_space().install_read_handler(addrstart, addrend, bank->m_rhandler);
		}
	}
}