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

    flash.c

    Z88 Flash cartridges emulation

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

#include "emu.h"
#include "flash.h"


//**************************************************************************
//  MACROS/CONSTANTS
//**************************************************************************

#define FLASH_TAG   "flash"

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

const device_type Z88_1024K_FLASH =  &device_creator<z88_1024k_flash_device>;

//-------------------------------------------------
//  MACHINE_CONFIG_FRAGMENT( z88_flash )
//-------------------------------------------------

static MACHINE_CONFIG_FRAGMENT(z88_flash)
	MCFG_INTEL_E28F008SA_ADD(FLASH_TAG)
MACHINE_CONFIG_END


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

//-------------------------------------------------
//  z88_1024k_flash_device - constructor
//-------------------------------------------------

z88_1024k_flash_device::z88_1024k_flash_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
		: device_t(mconfig, Z88_1024K_FLASH, "Z88 1024KB Flash", tag, owner, clock, "z88_1024k_flash", __FILE__),
		device_z88cart_interface( mconfig, *this ),
		m_flash(*this, FLASH_TAG)
{
}

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

void z88_1024k_flash_device::device_start()
{
}


//-------------------------------------------------
//  device_mconfig_additions
//-------------------------------------------------

machine_config_constructor z88_1024k_flash_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( z88_flash );
}

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

UINT8* z88_1024k_flash_device::get_cart_base()
{
	return (UINT8*)m_flash->space().get_read_ptr(0);
}

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

READ8_MEMBER(z88_1024k_flash_device::read)
{
	return m_flash->read(offset & (get_cart_size() - 1));
}

/*-------------------------------------------------
    write
-------------------------------------------------*/

WRITE8_MEMBER(z88_1024k_flash_device::write)
{
	m_flash->write(offset & (get_cart_size() - 1), data);
}