summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bus/vtech/memexp/memory.c
blob: 0d52e18ab0d55b0963e8c132ed03b911cf0ab1a4 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/***************************************************************************

    VTech Laser/VZ Laser Memory Expansions

    license: MAME, GPL-2.0+
    copyright-holders: Dirk Best

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

#include "memory.h"


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

const device_type LASER110_16K = &device_creator<laser110_16k_device>;
const device_type LASER210_16K = &device_creator<laser210_16k_device>;
const device_type LASER310_16K = &device_creator<laser310_16k_device>;
const device_type LASER_64K = &device_creator<laser_64k_device>;


//**************************************************************************
//  LASER 110 16K DEVICE
//**************************************************************************

//-------------------------------------------------
//  laser110_16k_device - constructor
//-------------------------------------------------

laser110_16k_device::laser110_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, LASER110_16K, "Laser 110/200/VZ-200 16k Memory", tag, owner, clock, "laser110_16k", __FILE__),
	device_memexp_interface(mconfig, *this)
{
}

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

void laser110_16k_device::device_start()
{
	m_ram.resize(16 * 1024);
}

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

void laser110_16k_device::device_reset()
{
	m_slot->m_program->install_ram(0x8000, 0xbfff, m_ram);
}


//**************************************************************************
//  LASER 210 16K DEVICE
//**************************************************************************

//-------------------------------------------------
//  laser210_16k_device - constructor
//-------------------------------------------------

laser210_16k_device::laser210_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, LASER210_16K, "Laser 210/VZ-200 (DSE) 16k Memory", tag, owner, clock, "laser210_16k", __FILE__),
	device_memexp_interface(mconfig, *this)
{
}

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

void laser210_16k_device::device_start()
{
	m_ram.resize(16 * 1024);
}

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

void laser210_16k_device::device_reset()
{
	m_slot->m_program->install_ram(0x9000, 0xcfff, m_ram);
}


//**************************************************************************
//  VZ300 16K DEVICE
//**************************************************************************

//-------------------------------------------------
//  laser310_16k_device - constructor
//-------------------------------------------------

laser310_16k_device::laser310_16k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, LASER310_16K, "Laser 310/VZ-300 16k Memory", tag, owner, clock, "laser310_16k", __FILE__),
	device_memexp_interface(mconfig, *this)
{
}

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

void laser310_16k_device::device_start()
{
	m_ram.resize(16 * 1024);
}

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

void laser310_16k_device::device_reset()
{
	m_slot->m_program->install_ram(0xb800, 0xf7ff, m_ram);
}


//**************************************************************************
//  VZ300 64K DEVICE
//**************************************************************************

//-------------------------------------------------
//  laser_64k_device - constructor
//-------------------------------------------------

laser_64k_device::laser_64k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
	device_t(mconfig, LASER_64K, "Laser/VZ 64k Memory", tag, owner, clock, "laser_64k", __FILE__),
	device_memexp_interface(mconfig, *this)
{
}

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

void laser_64k_device::device_start()
{
	m_ram.resize(64 * 1024);
}

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

void laser_64k_device::device_reset()
{
	// fixed first bank
	m_slot->m_program->install_ram(0x8000, 0xbfff, m_ram);

	// other banks
	m_slot->m_program->install_readwrite_bank(0xc000, 0xffff, tag());

	membank(tag())->configure_entries(0, 4, m_ram, 0x4000);
	membank(tag())->set_entry(1);

	// bank switch
	m_slot->m_io->install_write_handler(0x70, 0x7f, write8_delegate(FUNC(laser_64k_device::bankswitch_w), this));
}

WRITE8_MEMBER( laser_64k_device::bankswitch_w )
{
	membank(tag())->set_entry(data & 0x03);
}