summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/jakks_gamekey/rom.cpp
blob: 4492d62bddb260444c09d713cda67ed4082f24e3 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood

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

//-------------------------------------------------
//  jakks_gamekey_rom_device - constructor
//-------------------------------------------------

DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_PLAIN,         jakks_gamekey_rom_plain_device,       "jakks_gamekey_rom_plain",        "JAKKS Pacific GameKey")
DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_BASE,      jakks_gamekey_rom_i2c_base_device,    "jakks_gamekey_rom_i2c_base",     "JAKKS Pacific GameKey with I2C")
DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_24LC04,    jakks_gamekey_rom_i2c_24lc04_device,  "jakks_gamekey_rom_i2c_24lc04",   "JAKKS Pacific GameKey with I2C 24LC04")


jakks_gamekey_rom_plain_device::jakks_gamekey_rom_plain_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, type, tag, owner, clock), device_jakks_gamekey_interface(mconfig, *this)
{
}

jakks_gamekey_rom_plain_device::jakks_gamekey_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	jakks_gamekey_rom_plain_device(mconfig, JAKKS_GAMEKEY_ROM_PLAIN, tag, owner, clock)
{
}

jakks_gamekey_rom_i2c_base_device::jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
	jakks_gamekey_rom_plain_device(mconfig, type, tag, owner, clock),
	m_i2cmem(*this, "i2cmem")
{
}

jakks_gamekey_rom_i2c_base_device::jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	jakks_gamekey_rom_i2c_base_device(mconfig, JAKKS_GAMEKEY_ROM_I2C_BASE, tag, owner, clock)
{
}

jakks_gamekey_rom_i2c_24lc04_device::jakks_gamekey_rom_i2c_24lc04_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	jakks_gamekey_rom_i2c_base_device(mconfig, JAKKS_GAMEKEY_ROM_I2C_24LC04, tag, owner, clock)
{
}

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

// plain

uint16_t jakks_gamekey_rom_plain_device::read_cart(offs_t offset)
{
	return read_rom(offset);
}

uint16_t jakks_gamekey_rom_plain_device::read_rom(offs_t offset)
{
	return m_rom[offset & (m_rom_size-1)];
}

void jakks_gamekey_rom_plain_device::write_cart(offs_t offset, uint16_t data)
{
	write_rom(offset, data);
}

void jakks_gamekey_rom_plain_device::write_rom(offs_t offset, uint16_t data)
{
	logerror("jakks_gamekey_rom_plain_device::write_rom %08x %04x\n", offset, data);
}

// i2c base

void jakks_gamekey_rom_i2c_base_device::write_rom(offs_t offset, uint16_t data)
{
	logerror("jakks_gamekey_rom_i2c_base_device::write_rom %08x %04x\n", offset, data);
}

uint16_t jakks_gamekey_rom_i2c_base_device::read_rom(offs_t offset)
{
	return m_rom[offset & (m_rom_size - 1)];
}

uint8_t jakks_gamekey_rom_i2c_base_device::read_cart_seeprom(void)
{
	logerror("jakks_gamekey_rom_i2c_base_device::read_cart_seeprom\n");

	return m_i2cmem->read_sda();
}

void jakks_gamekey_rom_i2c_base_device::write_cart_seeprom(offs_t offset, uint16_t data, uint16_t mem_mask)
{
	if (BIT(mem_mask, 1))
		m_i2cmem->write_scl(BIT(data, 1));
	if (BIT(mem_mask, 0))
		m_i2cmem->write_sda(BIT(data, 0));
}

// i2c 24lc04

void jakks_gamekey_rom_i2c_24lc04_device::device_add_mconfig(machine_config &config)
{
	I2C_24C04(config, "i2cmem", 0); // 24LC04
}


/*-------------------------------------------------
 slot interface
 -------------------------------------------------*/

void jakks_gamekey(device_slot_interface &device)
{
	device.option_add_internal("plain",       JAKKS_GAMEKEY_ROM_PLAIN);
	device.option_add_internal("rom_24lc04",  JAKKS_GAMEKEY_ROM_I2C_24LC04);
}