summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/vic10/multimax.cpp
blob: dfef6373aa4eae1dd42834072bbaca8925ac6299 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    MultiMAX 1MB ROM / 2KB RAM cartridge emulation

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

#include "emu.h"
#include "multimax.h"



//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(VIC10_MULTIMAX, vic10_multimax_device, "vic10_multimax", "VIC-10 MultiMAX Cartridge")



//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  vic10_multimax_device - constructor
//-------------------------------------------------

vic10_multimax_device::vic10_multimax_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	device_t(mconfig, VIC10_MULTIMAX, tag, owner, clock), device_vic10_expansion_card_interface(mconfig, *this),
	m_latch(0)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void vic10_multimax_device::device_start()
{
	// state saving
	save_item(NAME(m_latch));
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void vic10_multimax_device::device_reset()
{
	m_latch = 0;
}


//-------------------------------------------------
//  vic10_cd_r - cartridge data read
//-------------------------------------------------

uint8_t vic10_multimax_device::vic10_cd_r(offs_t offset, uint8_t data, int lorom, int uprom, int exram)
{
	if (!lorom)
	{
		data = m_lorom[((m_latch & 0x3f) << 14) | (offset & 0x1fff)];
	}
	else if (!uprom)
	{
		data = m_lorom[((m_latch & 0x3f) << 14) | 0x2000 | (offset & 0x1fff)];
	}
	else if (!exram)
	{
		if (m_latch)
		{
			data = m_exram[offset & 0x7ff];
		}
	}

	return data;
}


//-------------------------------------------------
//  vic10_cd_w - cartridge data write
//-------------------------------------------------

void vic10_multimax_device::vic10_cd_w(offs_t offset, uint8_t data, int lorom, int uprom, int exram)
{
	if (!exram)
	{
		if (m_latch)
		{
			m_exram[offset & 0x7ff] = data;
		}
		else
		{
			m_latch = data;
		}
	}
}