summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/megadrive/cart/action_replay.cpp
blob: 575709d47c10ac4568bbe40bfda94be59b1afc8d (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
67
// license: BSD-3-Clause
// copyright-holders: Angelo Salese
/***********************************************************************************************

Datel Action Replay lock-on carts

TODO:
- Actual cheat interface (needs a dynamic overlay for user work RAM mods)

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

#include "emu.h"
#include "action_replay.h"

#include "options.h"

DEFINE_DEVICE_TYPE(MEGADRIVE_ACTION_REPLAY, megadrive_action_replay_device, "megadrive_ar", "Megadrive Datel Action Replay cart")

megadrive_action_replay_device::megadrive_action_replay_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
	: megadrive_rom_device(mconfig, type, tag, owner, clock)
	, m_lockon_cart(*this, "cart")
	, m_ar_view(*this, "ar_view")
{
}

megadrive_action_replay_device::megadrive_action_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: megadrive_action_replay_device(mconfig, MEGADRIVE_ACTION_REPLAY, tag, owner, clock)
{
}

void megadrive_action_replay_device::device_add_mconfig(machine_config &config)
{
	MEGADRIVE_CART_SLOT(config, m_lockon_cart, this->clock(), megadrive_cart_options, nullptr).set_must_be_loaded(false);
	// TODO: /VRES connection?
}

void megadrive_action_replay_device::device_start()
{
	megadrive_rom_device::device_start();
}

void megadrive_action_replay_device::device_reset()
{
	megadrive_rom_device::device_reset();
	m_ar_view.select(0);
}

void megadrive_action_replay_device::unlock_cart_w(offs_t offset, u16 data, u16 mem_mask)
{
	if (data == 0xffff)
	{
		m_ar_view.disable();
	}
}

void megadrive_action_replay_device::cart_map(address_map &map)
{
	map(0x00'0000, 0x7f'ffff).rw(m_lockon_cart, FUNC(megadrive_cart_slot_device::base_r), FUNC(megadrive_cart_slot_device::base_w));
	map(0x00'0000, 0x01'ffff).view(m_ar_view);
	m_ar_view[0](0x00'0000, 0x00'7fff).mirror(0x00'8000).bankr(m_rom);
	m_ar_view[0](0x01'0006, 0x01'0007).w(FUNC(megadrive_action_replay_device::unlock_cart_w));
}

void megadrive_action_replay_device::time_io_map(address_map &map)
{
	map(0x00, 0xff).rw(m_lockon_cart, FUNC(megadrive_cart_slot_device::time_r), FUNC(megadrive_cart_slot_device::time_w));
}