summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/megadrive/tplay96.cpp
blob: 7e2c13ea5fa6e495ae49af7b698ac98f1e230e4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/**************************************************************************************************

Electronic Arts Triple Play 96/Gold mapper

8-bit NVRAM with NO write protection control lanes

At title screen hold A+B+C then press start, SFX plays, release all to get prompted for NVRAM reinitialize.

TODO:
- find out if any other cart needs this mapping (from header start with $200001?);

**************************************************************************************************/


#include "emu.h"
#include "tplay96.h"

DEFINE_DEVICE_TYPE(MD_ROM_TPLAY96, md_rom_tplay96_device, "md_rom_tplay96", "MD EA Triple Play 96 (8-bit SRAM)")

md_rom_tplay96_device::md_rom_tplay96_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, MD_ROM_TPLAY96, tag, owner, clock)
	, device_md_cart_interface(mconfig, *this)
	, m_nvram(*this, "nvram")
{
}

void md_rom_tplay96_device::device_add_mconfig(machine_config &config)
{
	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1);
}

void md_rom_tplay96_device::device_start()
{
	const u32 nvram_size = 0x8000;
	m_nvram_ptr = std::make_unique<uint8_t[]>(nvram_size);
	m_nvram->set_base(m_nvram_ptr.get(), nvram_size);

	save_pointer(NAME(m_nvram_ptr), nvram_size);
}

uint16_t md_rom_tplay96_device::read(offs_t offset)
{
	if (offset >= 0x200000/2 && offset < 0x210000/2)
	{
		const u32 nvram_offset = offset & 0x7fff;
		return 0xff00 | m_nvram_ptr[nvram_offset];
	}

	if (offset < 0x400000/2)
	{
		return m_rom[offset];
	}

	return 0xffff;
}

void md_rom_tplay96_device::write(offs_t offset, uint16_t data, uint16_t mem_mask)
{
	if (offset >= 0x200000/2 && offset < 0x210000/2 && ACCESSING_BITS_0_7)
	{
		const u32 nvram_offset = offset & 0x7fff;
		m_nvram_ptr[nvram_offset] = data & 0xff;
	}
}