summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/z88/rom.cpp
blob: 21d5ff34aebc671f545769a7046af53627b40a85 (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
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/***************************************************************************

    rom.c

    Z88 ROM cartridges emulation

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

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

/***************************************************************************
    IMPLEMENTATION
***************************************************************************/

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

const device_type Z88_32K_ROM = &device_creator<z88_32k_rom_device>;
const device_type Z88_128K_ROM = &device_creator<z88_128k_rom_device>;
const device_type Z88_256K_ROM = &device_creator<z88_256k_rom_device>;

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

//-------------------------------------------------
//  z88_32k_rom_device - constructor
//-------------------------------------------------

z88_32k_rom_device::z88_32k_rom_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock)
		: device_t(mconfig, Z88_32K_ROM, "Z88 32KB ROM", tag, owner, clock, "z88_32k_rom", __FILE__),
		device_z88cart_interface( mconfig, *this ), m_rom(nullptr)
	{
}

z88_32k_rom_device::z88_32k_rom_device(const machine_config &mconfig, device_type type, std::string name, std::string tag, device_t *owner, UINT32 clock, std::string shortname, std::string source)
		: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
		device_z88cart_interface( mconfig, *this ), m_rom(nullptr)
	{
}

//-------------------------------------------------
//  z88_128k_rom_device - constructor
//-------------------------------------------------

z88_128k_rom_device::z88_128k_rom_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock)
		: z88_32k_rom_device(mconfig, Z88_128K_ROM, "Z88 128KB ROM", tag, owner, clock, "z88_128k_rom", __FILE__)
{
}

//-------------------------------------------------
//  z88_256k_rom_device - constructor
//-------------------------------------------------

z88_256k_rom_device::z88_256k_rom_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock)
		: z88_32k_rom_device(mconfig, Z88_256K_ROM, "Z88 256KB ROM", tag, owner, clock, "z88_256k_rom", __FILE__)
{
}

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

void z88_32k_rom_device::device_start()
{
	m_rom = machine().memory().region_alloc(tag().c_str(), get_cart_size(), 1, ENDIANNESS_LITTLE)->base();
}

/*-------------------------------------------------
    get_cart_base
-------------------------------------------------*/

UINT8* z88_32k_rom_device::get_cart_base()
{
	return m_rom;
}

/*-------------------------------------------------
    read
-------------------------------------------------*/

READ8_MEMBER(z88_32k_rom_device::read)
{
	return m_rom[offset & (get_cart_size() - 1)];
}