summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bus/odyssey2/rom.c
blob: da0f02f694114cdae89d286aeafc85fc89346e85 (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
// license:BSD-3-Clause
// copyright-holders:etabeta
/***********************************************************************************************************


 Magnavox Odyssey cart emulation


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


#include "emu.h"
#include "rom.h"


//-------------------------------------------------
//  o2_rom_device - constructor
//-------------------------------------------------

const device_type O2_ROM_STD = &device_creator<o2_rom_device>;
const device_type O2_ROM_12K = &device_creator<o2_rom12_device>;
const device_type O2_ROM_16K = &device_creator<o2_rom16_device>;


o2_rom_device::o2_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
					: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
						device_o2_cart_interface( mconfig, *this )
{
}

o2_rom_device::o2_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: device_t(mconfig, O2_ROM_STD, "Odyssey 2 Standard Carts", tag, owner, clock, "o2_rom", __FILE__),
						device_o2_cart_interface( mconfig, *this )
{
}

o2_rom12_device::o2_rom12_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: o2_rom_device(mconfig, O2_ROM_12K, "Odyssey 2 12K Carts", tag, owner, clock, "o2_rom12", __FILE__)
{
}

o2_rom16_device::o2_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: o2_rom_device(mconfig, O2_ROM_16K, "Odyssey 2 16K Carts", tag, owner, clock, "o2_rom16", __FILE__)
{
}


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

void o2_rom_device::device_start()
{	
	save_item(NAME(m_bank_base));
}

void o2_rom_device::device_reset()
{	
	m_bank_base = 0;
}

/*-------------------------------------------------
 mapper specific handlers
 -------------------------------------------------*/

void o2_rom_device::write_bank(int bank)
{
	m_bank_base = bank;
}

READ8_MEMBER(o2_rom_device::read_rom04)
{
	return m_rom[(offset + (m_bank_base & 0x03) * 0x800) & (m_rom_size - 1)];
}
READ8_MEMBER(o2_rom_device::read_rom0c)
{
	return m_rom[(offset + (m_bank_base & 0x03) * 0x800) & (m_rom_size - 1)];
}

READ8_MEMBER(o2_rom12_device::read_rom04)
{
	return m_rom[offset + (m_bank_base & 0x03) * 0xc00];
}
READ8_MEMBER(o2_rom12_device::read_rom0c)
{
	return m_rom[offset + 0x800 + (m_bank_base & 0x03) * 0xc00];
}

READ8_MEMBER(o2_rom16_device::read_rom04)
{
	return m_rom[offset + 0x400 + (m_bank_base & 0x03) * 0x1000];
}
READ8_MEMBER(o2_rom16_device::read_rom0c)
{
	return m_rom[offset + 0xc00 + (m_bank_base & 0x03) * 0x1000];
}